@orkestrel/browser 0.0.19 → 0.0.21
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/dist/src/core/index.cjs +11 -2
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +1 -1
- package/dist/src/core/index.d.ts +1 -1
- package/dist/src/core/index.js +11 -2
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +1 -1
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.js +1 -1
- package/dist/src/server/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["isString","isInstance","attempt","isRecord","isString","isRecord","isString","isInteger","isBoolean","isFiniteNumber","parseJSONAs","isArray","attempt","parseEnum","parseArray","isString","isArray","isRecord","attempt","isInteger","isFiniteNumber","isBoolean","parseArray","parseEnum","isFunction","isJSONValue","isString","isArray","isRecord","Emitter","parseJSON","isRecord","isInteger","isString","isFiniteNumber","isRecord","Emitter","isRecord","isString","isInteger","isArray","createHTML","renderMarkdown","htmlToMarkdown","renderText","isRecord","isArray","isString","isError","isNumber","isInteger","isInteger","isRecord","isArray","isString","Emitter","createTool","isRecord","isString","isArray","isInteger","isString","Emitter","isRecord","isString","isRecord","isString","isInteger","isString","Emitter","Emitter","isRecord","isString","attempt","isFiniteNumber","isString","isInteger","Emitter","isError","isRecord","isFiniteNumber","isString","isInteger","isArray","attempt","Emitter","isRecord","isString","instanceOf","extractKeys","Emitter","Emitter","isString","createTool","attempt","isInteger","isString","isArray","isRecord","isInteger","createToolManager","Emitter","isArray","isString","cloneJSONRecord","isError","createTool","isBoolean","isFiniteNumber","isRecord"],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/validators.ts","../../../src/core/parsers.ts","../../../src/core/helpers.ts","../../../src/core/compilers.ts","../../../src/core/BrowserTransition.ts","../../../src/core/CDPClient.ts","../../../src/core/BrowserAccessibility.ts","../../../src/core/BrowserClock.ts","../../../src/core/BrowserCoverage.ts","../../../src/core/BrowserCookieManager.ts","../../../src/core/BrowserEmulationManager.ts","../../../src/core/recorders/BrowserCodegen.ts","../../../src/core/BrowserReading.ts","../../../src/core/elements/BrowserPageElement.ts","../../../src/core/elements/BrowserElementManager.ts","../../../src/core/BrowserRegistry.ts","../../../src/core/BrowserPerformance.ts","../../../src/core/BrowserProfiler.ts","../../../src/core/BrowserTracing.ts","../../../src/core/BrowserDiagnostics.ts","../../../src/core/BrowserDialog.ts","../../../src/core/BrowserDownload.ts","../../../src/core/BrowserHandle.ts","../../../src/core/BrowserFrame.ts","../../../src/core/BrowserFileChooser.ts","../../../src/core/BrowserKeyboard.ts","../../../src/core/BrowserMouse.ts","../../../src/core/BrowserTouch.ts","../../../src/core/BrowserHARManager.ts","../../../src/core/BrowserRoute.ts","../../../src/core/BrowserWebSocket.ts","../../../src/core/BrowserNetworkManager.ts","../../../src/core/BrowserNavigationRecord.ts","../../../src/core/BrowserNavigationManager.ts","../../../src/core/BrowserScriptManager.ts","../../../src/core/BrowserSnapshot.ts","../../../src/core/BrowserWorker.ts","../../../src/core/BrowserPage.ts","../../../src/core/BrowserPermissionManager.ts","../../../src/core/BrowserStorageManager.ts","../../../src/core/BrowserContext.ts","../../../src/core/BrowserHold.ts","../../../src/core/recorders/BrowserRecorder.ts","../../../src/core/BrowserReplay.ts","../../../src/core/stores/MemoryBrowserJourneyStore.ts","../../../src/core/stores/MemoryBrowserRunStore.ts","../../../src/core/factories.ts","../../../src/core/BrowserJourneyToolset.ts","../../../src/core/BrowserToolset.ts"],"sourcesContent":["import type { ToolDefinition } from '@orkestrel/tool'\nimport type {\n\tBrowserElementRefusal,\n\tBrowserJourney,\n\tBrowserMouseButton,\n\tBrowserNavigationReason,\n\tBrowserNavigationStage,\n\tBrowserStepOutcome,\n\tBrowserToolName,\n} from './types.js'\n\n// === Base64\n//\n// The lookup table is written out rather than computed from BASE64_CHARS at module scope:\n// constants.ts holds data, and a module-scope callback here is a placement violation the fleet\n// policy sweep rejects. Entry n of the table is BASE64_CHARS[n], and the whole-alphabet\n// round-trip in tests/src/core/helpers.test.ts fails on any single-entry disagreement.\n\n/** Holds the index-ordered base64 alphabet used to build {@link BASE64_LOOKUP}. */\nexport const BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\n\n/** Maps each base64 character to its 6-bit value, derived from {@link BASE64_CHARS}. */\nexport const BASE64_LOOKUP: Readonly<Record<string, number>> = Object.freeze({\n\tA: 0,\n\tB: 1,\n\tC: 2,\n\tD: 3,\n\tE: 4,\n\tF: 5,\n\tG: 6,\n\tH: 7,\n\tI: 8,\n\tJ: 9,\n\tK: 10,\n\tL: 11,\n\tM: 12,\n\tN: 13,\n\tO: 14,\n\tP: 15,\n\tQ: 16,\n\tR: 17,\n\tS: 18,\n\tT: 19,\n\tU: 20,\n\tV: 21,\n\tW: 22,\n\tX: 23,\n\tY: 24,\n\tZ: 25,\n\ta: 26,\n\tb: 27,\n\tc: 28,\n\td: 29,\n\te: 30,\n\tf: 31,\n\tg: 32,\n\th: 33,\n\ti: 34,\n\tj: 35,\n\tk: 36,\n\tl: 37,\n\tm: 38,\n\tn: 39,\n\to: 40,\n\tp: 41,\n\tq: 42,\n\tr: 43,\n\ts: 44,\n\tt: 45,\n\tu: 46,\n\tv: 47,\n\tw: 48,\n\tx: 49,\n\ty: 50,\n\tz: 51,\n\t'0': 52,\n\t'1': 53,\n\t'2': 54,\n\t'3': 55,\n\t'4': 56,\n\t'5': 57,\n\t'6': 58,\n\t'7': 59,\n\t'8': 60,\n\t'9': 61,\n\t'+': 62,\n\t'/': 63,\n})\n\n// === Browser\n\n/**\n * Sets the default timeout for browser connection, requests, and navigation, `30_000`\n * milliseconds.\n */\nexport const BROWSER_DEFAULT_TIMEOUT_MS = 30_000\n\n/**\n * Caps the serialized-character length for an `evaluate()`/`read()` result at `2_500_000`,\n * enforced in-page before the result is returned to CDP.\n *\n * @remarks\n * This counts UTF-16 string length (`String#length`), not transport bytes —\n * the actual CDP frame is UTF-8 encoded (up to 3 bytes/char for common\n * multibyte content) and carries additional JSON/CDP framing overhead on top\n * of the raw content. A `Runtime.evaluate` result above this size, once\n * framed as a CDP JSON response, overflows the native WebSocket inbound frame\n * limit and closes the whole CDP connection — a page-level failure with no\n * clean error. The limit is set well under the observed ~3-4MB transport\n * ceiling (rather than at it) to leave headroom for the length-vs-bytes gap\n * and framing overhead. The cap is enforced by stringifying the candidate\n * result in-page and throwing a recognizable sentinel error (see\n * {@link BROWSER_RESULT_LIMIT_SENTINEL_PREFIX}) before the oversized frame is\n * ever produced, so the caller gets a coded error instead of a dropped\n * connection.\n */\nexport const BROWSER_RESULT_LIMIT = 2_500_000\n\n/**\n * Names the distinctive prefix for the in-page result-limit sentinel error,\n * `'[[ORKESTREL_BROWSER_RESULT_LIMIT]]'`, immediately followed by the serialized length.\n *\n * @remarks\n * Deliberately unlikely to appear in a page's own thrown error text (unlike\n * a plain `BROWSER_RESULT_LIMIT: ` label), so {@link BROWSER_RESULT_LIMIT_PATTERN}\n * can distinguish the guard's own throw from a page error that merely\n * mentions similar text.\n */\nexport const BROWSER_RESULT_LIMIT_SENTINEL_PREFIX = '[[ORKESTREL_BROWSER_RESULT_LIMIT]]'\n\n/**\n * Matches the in-page result-limit sentinel error message, anchored immediately after the\n * `Error:` (optionally `Uncaught Error:`) prefix Chromium prepends to a thrown error's\n * description, `/^(?:Uncaught )?Error: \\[\\[ORKESTREL_BROWSER_RESULT_LIMIT\\]\\](\\d+)/`.\n *\n * @remarks\n * The anchor matches the guard's own throw only at the start of the message, rather than\n * wherever the substring happens to occur.\n */\nexport const BROWSER_RESULT_LIMIT_PATTERN = new RegExp(\n\t`^(?:Uncaught )?Error: \\\\[\\\\[ORKESTREL_BROWSER_RESULT_LIMIT\\\\]\\\\](\\\\d+)`,\n)\n\n/**\n * Sets the default maximum node count accepted from a decoded CDP DOM snapshot, `100_000`.\n */\nexport const BROWSER_SNAPSHOT_NODE_LIMIT = 100_000\n\n/** Names the isolated world used for iframe evaluation, `'__orkestrelBrowserFrame'`. */\nexport const BROWSER_FRAME_WORLD_NAME = '__orkestrelBrowserFrame'\n\n/** Sets the number of animation frames whose element bounds must agree before trusted input. */\nexport const BROWSER_STABLE_FRAME_COUNT = 2\n\n/** Maps a canonical modifier name to its CDP Input modifier bit value. */\nexport const BROWSER_KEY_MODIFIERS: Readonly<Record<string, number>> = Object.freeze({\n\tAlt: 1,\n\tControl: 2,\n\tMeta: 4,\n\tShift: 8,\n})\n\n/** Maps each public mouse button to its CDP Input pressed-button bit value. */\nexport const BROWSER_MOUSE_BUTTON_MASKS: Readonly<Record<BrowserMouseButton, number>> =\n\tObject.freeze({\n\t\tleft: 1,\n\t\tright: 2,\n\t\tmiddle: 4,\n\t\tback: 8,\n\t\tforward: 16,\n\t})\n\n/**\n * Names the tool identity embedded in HAR 1.2 documents.\n *\n * @remarks\n * `version` is this package's own released version. A parity test in\n * `tests/src/core/BrowserHARManager.test.ts` compares it against the manifest,\n * so the archive stamp cannot drift away from the release that wrote it.\n */\nexport const BROWSER_HAR_CREATOR = Object.freeze({\n\tname: '@orkestrel/browser',\n\tversion: '0.0.19',\n})\n\n/** Names the attribute that tags temporary screenshot styles and masks. */\nexport const BROWSER_SCREENSHOT_ATTRIBUTE = 'data-orkestrel-screenshot'\n\n/**\n * Lists every CDP `Page.ClientNavigationReason` value a page accepts as a navigation's reason, as\n * of Chromium 141; a page reads any other reason as undefined.\n */\nexport const BROWSER_NAVIGATION_REASONS: readonly BrowserNavigationReason[] = Object.freeze([\n\t'anchorClick',\n\t'formSubmissionGet',\n\t'formSubmissionPost',\n\t'httpHeaderRefresh',\n\t'initialFrameNavigation',\n\t'metaTagRefresh',\n\t'other',\n\t'pageBlockInterstitial',\n\t'reload',\n\t'scriptInitiated',\n])\n\n/**\n * Lists the CDP `Page.frameStartedNavigating` `navigationType` values that repeat or restore a\n * history entry rather than follow a request, as of Chromium 141.\n */\nexport const BROWSER_RELOAD_NAVIGATION_TYPES: readonly string[] = Object.freeze([\n\t'reload',\n\t'reloadBypassingCache',\n\t'restore',\n\t'restoreWithPost',\n\t'historySameDocument',\n\t'historyDifferentDocument',\n])\n\n/**\n * Names the isolated-world property that holds the `submit` observer an action installs before\n * its input, `'__orkestrelSubmit'`.\n */\nexport const BROWSER_SUBMIT_KEY = '__orkestrelSubmit'\n\n/**\n * Bounds the best-effort `Page.stopLoading` call issued after a failed `navigate()` at `1_000`\n * milliseconds.\n *\n * @remarks\n * A wedged renderer can make the underlying CDP call hang for the full\n * per-call timeout; capping it to a small fixed bound keeps a navigate\n * failure's total latency close to the original timeout instead of doubling\n * it. Best-effort only — never masks the original navigate error.\n */\nexport const BROWSER_STOP_LOADING_TIMEOUT_MS = 1_000\n\n/** Sets the default viewport width, `1280` pixels. */\nexport const BROWSER_DEFAULT_VIEWPORT_WIDTH = 1280\n\n/** Sets the default viewport height, `720` pixels. */\nexport const BROWSER_DEFAULT_VIEWPORT_HEIGHT = 720\n\n// === Browser codegen\n\n/**\n * Names the CDP runtime binding the codegen recorder script calls into,\n * `'__orkestrelBrowserCodegen'`.\n */\nexport const BROWSER_CODEGEN_BINDING_NAME = '__orkestrelBrowserCodegen'\n\n/**\n * Holds the self-contained document listener installed before a frame resumes.\n * Password input carries a marker; only Enter carries a key. Node indices are local to a document.\n */\nexport const BROWSER_CODEGEN_SOURCE = `(() => {\n\tconst binding = '__orkestrelBrowserCodegen'\n\twindow[binding + '__state']?.controller.abort()\n\tconst state = { controller: new AbortController(), nodes: [], indices: new WeakMap() }\n\twindow[binding + '__state'] = state\n\tfor (const event of ['click', 'input', 'change', 'keydown', 'focusout', 'submit', 'contextmenu', 'drop']) {\n\t\tdocument.addEventListener(event, (event) => {\n\t\t\tif (!event.isTrusted || typeof window[binding] !== 'function') return\n\t\t\tif (event.type === 'keydown' && event.key !== 'Enter') return\n\t\t\tconst element = event.composedPath()[0]\n\t\t\tif (!(element instanceof Element)) return\n\t\t\tlet index = state.indices.get(element)\n\t\t\tif (index === undefined) {\n\t\t\t\tindex = state.nodes.push(element) - 1\n\t\t\t\tstate.indices.set(element, index)\n\t\t\t}\n\t\t\tconst control = element.tagName === 'SELECT' ? (element.multiple ? 'multiple' : 'select')\n\t\t\t\t: element.tagName === 'OPTION' ? 'option'\n\t\t\t\t: element.tagName === 'INPUT' && element.type === 'password' ? 'password'\n\t\t\t\t: element.tagName === 'TEXTAREA' || element.isContentEditable ||\n\t\t\t\t\t(element.tagName === 'INPUT' && ['text', 'search', 'url', 'tel', 'email', 'number'].includes(element.type)) ? 'text' : 'other'\n\t\t\tconst payload = { event: event.type, index, top: window === window.top && element.ownerDocument === document, control, form: !!element.form }\n\t\t\tif (event.type === 'click') payload.detail = event.detail\n\t\t\tif (event.type === 'keydown') payload.key = 'Enter'\n\t\t\tif (event.type === 'input' && control === 'password') payload.secret = true\n\t\t\tif (event.type === 'input' && control === 'text') payload.value = element.isContentEditable ? element.textContent || '' : element.value\n\t\t\tif (event.type === 'change' && control === 'select') {\n\t\t\t\tpayload.value = element.value\n\t\t\t\tpayload.roundtrip = Array.from(element.options).find(option => option.value === element.value) === element.selectedOptions[0]\n\t\t\t}\n\t\t\tif (element.getRootNode() !== document) {\n\t\t\t\tpayload.event = 'unsupported'\n\t\t\t\tpayload.gap = 'the element is in a shadow root'\n\t\t\t} else if (event.type === 'contextmenu' || event.type === 'drop' || (event.type === 'click' && (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) && !['select', 'multiple', 'option'].includes(control))) {\n\t\t\t\tpayload.event = 'unsupported'\n\t\t\t\tpayload.gap = 'an unsupported gesture'\n\t\t\t}\n\t\t\twindow[binding](JSON.stringify(payload.event === 'unsupported' ? { event: payload.event, index, top: payload.top, control, form: payload.form, gap: payload.gap } : payload))\n\t\t}, { capture: true, signal: state.controller.signal })\n\t}\n})()`\n\n/** Identifies the CDP method-not-found response when WebMCP is absent. */\nexport const BROWSER_REGISTRY_ABSENT_CODE = -32601\n\n/** Bounds adopted tool JSON output and error messages to 4096 UTF-16 code units. */\nexport const BROWSER_REGISTRY_OUTPUT_LIMIT = 4096\n/** Prefixes stable element references within a browser context. */\nexport const BROWSER_REFERENCE_PREFIX = 'e'\n\n/** Bounds the default number of actionable elements in an outline. */\nexport const BROWSER_OUTLINE_LIMIT = 150\n\n/** Names accessibility roles that receive actionable outline references. */\nexport const BROWSER_INTERACTIVE_ROLES: ReadonlySet<string> = Object.freeze(\n\tnew Set([\n\t\t'button',\n\t\t'link',\n\t\t'textbox',\n\t\t'searchbox',\n\t\t'combobox',\n\t\t'listbox',\n\t\t'option',\n\t\t'checkbox',\n\t\t'radio',\n\t\t'switch',\n\t\t'slider',\n\t\t'spinbutton',\n\t\t'menuitem',\n\t\t'menuitemcheckbox',\n\t\t'menuitemradio',\n\t\t'tab',\n\t\t'treeitem',\n\t\t'DisclosureTriangle',\n\t\t'PopUpButton',\n\t\t'ColorWell',\n\t\t'Date',\n\t\t'DateTime',\n\t\t'Time',\n\t\t'InputTime',\n\t\t'Iframe',\n\t]),\n)\n\n/**\n * Maps the first line of each refusal the compiled element functions throw, without its `Error: `\n * prefix, to the reason and the one-line detail an element action reports it with.\n *\n * @remarks\n * `compileActionabilityFunction` throws the detached, not-visible, disabled, not-editable, and\n * pointer-event refusals; `compileSelectFunction` throws the text-control, select-control, and\n * missing-option refusals.\n */\nexport const BROWSER_ELEMENT_REFUSALS: ReadonlyMap<string, BrowserElementRefusal> = Object.freeze(\n\tnew Map<string, BrowserElementRefusal>([\n\t\t['Element is detached', { reason: 'GONE', detail: undefined }],\n\t\t['Element is not visible', { reason: 'HIDDEN', detail: 'is not visible' }],\n\t\t['Element is disabled', { reason: 'DISABLED', detail: 'is disabled' }],\n\t\t['Element is not editable', { reason: 'UNKNOWN', detail: 'is not editable' }],\n\t\t[\n\t\t\t'Element does not receive pointer events',\n\t\t\t{ reason: 'OCCLUDED', detail: 'does not receive pointer events' },\n\t\t],\n\t\t['Element is not a text control', { reason: 'UNKNOWN', detail: 'is not a text control' }],\n\t\t['Element is not a select control', { reason: 'UNKNOWN', detail: 'is not a select control' }],\n\t\t['Select option was not found', { reason: 'UNKNOWN', detail: 'has no such option' }],\n\t]),\n)\n\n/** Names accessibility roles whose own rows add no outline content. */\nexport const BROWSER_OUTLINE_OMITTED_ROLES: ReadonlySet<string> = Object.freeze(\n\tnew Set(['none', 'generic', 'InlineTextBox', 'RootWebArea', 'WebArea']),\n)\n\n/** Names accessibility roles rendered as text without an actionable reference. */\nexport const BROWSER_TEXT_ROLES: ReadonlySet<string> = Object.freeze(\n\tnew Set(['heading', 'StaticText']),\n)\n\n// === Browser toolset\n\n/**\n * Bounds each tool result and error message at `4_000` UTF-16 code units before its footer.\n *\n * @remarks\n * A page tool's error message and JSON output reach the toolset already cut at\n * {@link BROWSER_REGISTRY_OUTPUT_LIMIT}, so a toolset limit over that shows at most\n * `4_096` characters of either.\n */\nexport const BROWSER_TOOL_LIMIT = 4_000\n\n/**\n * Sets the `wait` tool's default and an action receipt's bound on a requested navigation,\n * `5_000` milliseconds.\n *\n * @remarks\n * The receipt's bound runs from the moment the receipt starts waiting for the requested\n * navigation, so the time an action spent queued and the load wait of an explicit `navigate`\n * precede it.\n */\nexport const BROWSER_TOOL_TIMEOUT_MS = 5_000\n\n/**\n * Reserves `1_000` milliseconds of an action receipt's `BROWSER_TOOL_TIMEOUT_MS` deadline for the\n * view capture, so a receipt whose navigation wait reaches its bound still carries the view.\n */\nexport const BROWSER_TOOL_CAPTURE_MS = 1_000\n\n/**\n * Holds the note an action receipt carries in place of the view when the receipt's deadline\n * passed before the view could be captured.\n */\nexport const BROWSER_TOOL_DEADLINE_NOTE =\n\t'(The view could not be read before the deadline; call look.)'\n\n/**\n * Holds the status an action receipt carries after a submission a page listener prevented, with no\n * navigation after it, naming `wait` as the next call because the page's outcome can arrive later.\n */\nexport const BROWSER_TOOL_HANDLED_STATUS =\n\t'the page handled the submission without navigating; call wait for the text you expect'\n\n/** Holds the refusal for a hold requested while an earlier input remains pending. */\nexport const BROWSER_TOOL_PENDING_NOTE = 'An earlier input is still pending; call look.'\n\n/** Names the tools that observe the view without recording an action. */\nexport const BROWSER_OBSERVATION_TOOL_NAMES: readonly string[] = Object.freeze([\n\t'look',\n\t'read',\n\t'tabs',\n])\n\n/**\n * Holds the note an action receipt carries in place of the view when the page changed under the\n * capture twice: once after the action, and again during the one retry that follows the page's\n * readiness.\n */\nexport const BROWSER_TOOL_CHANGED_NOTE =\n\t'(The page changed before the view could be read; call look.)'\n\n/**\n * Holds the clause that ends the footer of a cut result that carries no view: a read note, a tab\n * list, a wait, a page tool's output, or an error message.\n */\nexport const BROWSER_TOOL_CUT_FOOTER = 'the rest was cut'\n\n/**\n * Holds the clause that ends the footer of a cut result that carries a view, the result of\n * `look` and of every action, and names `read` as the call that returns the page's text.\n */\nexport const BROWSER_TOOL_VIEW_FOOTER = \"the rest was cut; call read for the page's text\"\n\n/**\n * Names the accessibility roles the `type` tool writes to: `textbox`, `searchbox`, and\n * `spinbutton` take typed text, and `combobox` and `listbox` take a select control's option\n * or, for a text input with suggestions, typed text.\n *\n * @remarks\n * The set names the roles the tool admits, not every element that accepts text: an element\n * with another explicit role can still accept text through its element contract. Chromium\n * 141.0.7390.37 reports a `contenteditable` region without an explicit role as `generic`, which\n * the outline gives no reference.\n */\nexport const BROWSER_TYPED_ROLES: ReadonlySet<string> = Object.freeze(\n\tnew Set(['textbox', 'searchbox', 'spinbutton', 'combobox', 'listbox']),\n)\n\n/** Caps the `wait` tool's `timeout` parameter at `30_000` milliseconds. */\nexport const BROWSER_TOOL_TIMEOUT_LIMIT_MS = 30_000\n\n/**\n * Names every tool the browser toolset reserves: `look`, `read`, `click`, `type`, `press`,\n * `navigate`, `wait`, `dialog`, `tabs`, and `switch`.\n */\nexport const BROWSER_TOOL_NAMES: readonly BrowserToolName[] = Object.freeze([\n\t'look',\n\t'read',\n\t'click',\n\t'type',\n\t'press',\n\t'navigate',\n\t'wait',\n\t'dialog',\n\t'tabs',\n\t'switch',\n])\n\n/**\n * Matches a page tool name the toolset can advertise: 1 to 64 ASCII letters, digits,\n * underscores, and hyphens.\n *\n * @remarks\n * The pattern is the narrowest of the tool-name rules of the providers the fleet targets. The\n * Anthropic Messages API tool definition requires a `name` matching `^[a-zA-Z0-9_-]{1,64}$`, and\n * the OpenAI function-calling definition requires a function `name` of letters, digits,\n * underscores, and dashes, at most 64 characters long. The WebMCP specification draft allows a\n * period and up to 128 code points (the guide's \"Declared conformance gaps\" section), so a page tool\n * named `a.b` or one longer than 64 characters is skipped with the reason `pattern`.\n */\nexport const BROWSER_TOOL_NAME_PATTERN = /^[A-Za-z0-9_-]{1,64}$/\n\n/** Names the URL schemes the `navigate` tool accepts by default: `http:` and `https:`. */\nexport const BROWSER_SCHEMES: readonly string[] = Object.freeze(['http:', 'https:'])\n\n/**\n * Holds the advertised definition of each reserved tool: its description, its JSON Schema\n * parameters, and its annotations.\n *\n * @remarks\n * Every tool description is at most 25 words and says what the tool shows or does, and for\n * `look` and `read` when to call it; every parameter description is at most 100 characters.\n * Every tool declares at least one required parameter, because the streamed tool-call parser of\n * Ollama 0.34.4 rejects a call to a tool that declares no parameter. `look` takes `what` alone\n * and `read` takes `what` and `offset`; neither is scoped to an element, and an element's own\n * reading is `BrowserElementInterface.read`. `look`, `read`, and `journeys` annotate `pure` and\n * `untrusted`, `wait` and `tabs` annotate `pure`, and the rest carry no annotation. `type` takes\n * `secret` beside `ref`, `text`, and `submit`. The journey tools `record`, `save`, `journeys`,\n * `edit`, and `replay` are advertised only by a toolset constructed with `journeys`.\n */\nexport const BROWSER_TOOL_COPY: Readonly<Record<BrowserToolName, ToolDefinition>> = Object.freeze({\n\tlook: Object.freeze({\n\t\tname: 'look',\n\t\tdescription:\n\t\t\t\"Shows the page's text and the elements you can act on, each with a reference like e4. Call it first and after the page changes.\",\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\twhat: Object.freeze({ type: 'string', description: 'What you want to find or act on.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['what']),\n\t\t}),\n\t\tannotations: Object.freeze({ pure: true, untrusted: true }),\n\t}),\n\tread: Object.freeze({\n\t\tname: 'read',\n\t\tdescription:\n\t\t\t\"Reads the page's text for what you name. Call it to learn a fact; continue with the offset a cut result names.\",\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\twhat: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'What you want to learn from the page.',\n\t\t\t\t}),\n\t\t\t\toffset: Object.freeze({\n\t\t\t\t\ttype: 'integer',\n\t\t\t\t\tdescription: 'The character to continue from, as the last reply names. Default: 0.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['what']),\n\t\t}),\n\t\tannotations: Object.freeze({ pure: true, untrusted: true }),\n\t}),\n\tclick: Object.freeze({\n\t\tname: 'click',\n\t\tdescription: 'Clicks the element with that reference.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tref: Object.freeze({ type: 'string', description: 'The reference, such as e4.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['ref']),\n\t\t}),\n\t}),\n\ttype: Object.freeze({\n\t\tname: 'type',\n\t\tdescription:\n\t\t\t'Types into the text control with that reference; set submit to true to submit its form.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tref: Object.freeze({ type: 'string', description: 'The reference, such as e4.' }),\n\t\t\t\ttext: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The text to type or the option to choose.',\n\t\t\t\t}),\n\t\t\t\tsubmit: Object.freeze({\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdescription: 'True to submit its form after typing.',\n\t\t\t\t}),\n\t\t\t\tsecret: Object.freeze({\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdescription: 'True to keep the text out of the receipt, such as a password.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['ref', 'text']),\n\t\t}),\n\t}),\n\tpress: Object.freeze({\n\t\tname: 'press',\n\t\tdescription: 'Presses that key or chord, such as Enter or Control+a.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tkey: Object.freeze({ type: 'string', description: 'The key or chord, such as Enter.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['key']),\n\t\t}),\n\t}),\n\tnavigate: Object.freeze({\n\t\tname: 'navigate',\n\t\tdescription: 'Opens that absolute web address in the current tab.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\turl: Object.freeze({ type: 'string', description: 'The absolute http or https address.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['url']),\n\t\t}),\n\t}),\n\twait: Object.freeze({\n\t\tname: 'wait',\n\t\tdescription: 'Waits for that text to appear on the page.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\ttext: Object.freeze({ type: 'string', description: 'The text to wait for.' }),\n\t\t\t\ttimeout: Object.freeze({\n\t\t\t\t\ttype: 'integer',\n\t\t\t\t\tdescription: 'The most seconds to wait, at most 30. Default: 5.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['text']),\n\t\t}),\n\t\tannotations: Object.freeze({ pure: true }),\n\t}),\n\tdialog: Object.freeze({\n\t\tname: 'dialog',\n\t\tdescription: 'Accepts or dismisses the open dialog.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\taccept: Object.freeze({\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdescription: 'True to accept the dialog; false to dismiss it.',\n\t\t\t\t}),\n\t\t\t\ttext: Object.freeze({ type: 'string', description: 'The answer to a prompt dialog.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['accept']),\n\t\t}),\n\t}),\n\ttabs: Object.freeze({\n\t\tname: 'tabs',\n\t\tdescription: 'Lists the open tabs; the current one is marked.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\twhat: Object.freeze({ type: 'string', description: 'What you are looking for.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['what']),\n\t\t}),\n\t\tannotations: Object.freeze({ pure: true }),\n\t}),\n\tswitch: Object.freeze({\n\t\tname: 'switch',\n\t\tdescription: 'Switches to a tab from tabs, such as t2.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\ttab: Object.freeze({ type: 'string', description: 'The tab, such as t2.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['tab']),\n\t\t}),\n\t}),\n\trecord: Object.freeze({\n\t\tname: 'record',\n\t\tdescription:\n\t\t\t'Starts recording your next actions as a journey with that name; call save when it is done.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tjourney: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The journey name: lowercase words joined by hyphens, such as add-kettle.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['journey']),\n\t\t}),\n\t}),\n\tsave: Object.freeze({\n\t\tname: 'save',\n\t\tdescription:\n\t\t\t'Stops recording and saves the journey; describe what it achieves in one sentence.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tdescription: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'What the journey achieves, in one sentence.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['description']),\n\t\t}),\n\t}),\n\tjourneys: Object.freeze({\n\t\tname: 'journeys',\n\t\tdescription: 'Lists the saved journeys with their steps and the parameters each one takes.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\twhat: Object.freeze({ type: 'string', description: 'What you are looking for.' }),\n\t\t\t\toffset: Object.freeze({\n\t\t\t\t\ttype: 'integer',\n\t\t\t\t\tdescription: 'The character to continue from, as the last reply names. Default: 0.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['what']),\n\t\t}),\n\t\tannotations: Object.freeze({ pure: true, untrusted: true }),\n\t}),\n\tedit: Object.freeze({\n\t\tname: 'edit',\n\t\tdescription:\n\t\t\t'Changes a saved journey: add, remove, or update steps by their ids from journeys, or declare a parameter.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tjourney: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The journey name, such as add-kettle.',\n\t\t\t\t}),\n\t\t\t\tedits: Object.freeze({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'The changes, as an array or a JSON string of the array, applied in order; one invalid change refuses them all.',\n\t\t\t\t\tanyOf: Object.freeze([\n\t\t\t\t\t\tObject.freeze({\n\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\titems: Object.freeze({\n\t\t\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\t\t\tproperties: Object.freeze({\n\t\t\t\t\t\t\t\t\toperation: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tenum: Object.freeze(['add', 'remove', 'update', 'declare']),\n\t\t\t\t\t\t\t\t\t\tdescription: 'What the change does.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tid: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The step to remove or update, such as s3.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tstep: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The step to add: its action, its arguments, and ref or tab.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tbefore: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The step to add it before, such as s3.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tafter: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The step to add it after, such as s3.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tref: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The element the added or updated step acts on, such as e4.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\targuments: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The arguments to change, merged by key.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tname: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The parameter to declare, such as email.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tparameter: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The parameter: its default, or secret set to true.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\trequired: Object.freeze(['operation']),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tObject.freeze({ type: 'string' }),\n\t\t\t\t\t]),\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['journey', 'edits']),\n\t\t}),\n\t}),\n\treplay: Object.freeze({\n\t\tname: 'replay',\n\t\tdescription: \"Replays a saved journey step by step; give each parameter's value under inputs.\",\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tjourney: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The journey name, such as add-kettle.',\n\t\t\t\t}),\n\t\t\t\tinputs: Object.freeze({\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\tdescription: \"Each parameter's value by its name.\",\n\t\t\t\t\tadditionalProperties: Object.freeze({ type: 'string' }),\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['journey']),\n\t\t}),\n\t}),\n\tforget: Object.freeze({\n\t\tname: 'forget',\n\t\tdescription: 'Removes a saved journey and all its runs; the name is free to record again.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tjourney: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The journey name, such as add-kettle.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['journey']),\n\t\t}),\n\t}),\n})\n\n// === Browser journeys\n\n/**\n * Matches a journey name: lowercase letters and digits in words joined by single hyphens, at most\n * 64 characters, and never a Windows reserved device name.\n *\n * @remarks\n * A journey's name is its directory under the store's root, so the pattern refuses `con`, `prn`,\n * `aux`, `nul`, `com1` to `com9`, and `lpt1` to `lpt9`, which a Windows host refuses as a path\n * segment.\n */\nexport const BROWSER_JOURNEY_NAME_PATTERN =\n\t/^(?=.{1,64}$)(?!(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$)[a-z0-9]+(?:-[a-z0-9]+)*$/\n\n/** Matches a journey parameter name: a lowercase letter followed by letters and digits. */\nexport const BROWSER_JOURNEY_PARAMETER_PATTERN = /^[a-z][a-zA-Z0-9]*$/\n\n/** Matches a run id containing an ISO timestamp with hyphenated time and a hexadecimal suffix. */\nexport const BROWSER_RUN_ID_PATTERN = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}\\.\\d{3}Z-[a-f0-9]{4}$/\n\n/** Holds the journey and run file format this package writes and reads, `1`. */\nexport const BROWSER_JOURNEY_FORMAT_VERSION: BrowserJourney['format'] = 1\n\n/**\n * Names the native actions a journey step can hold: `click`, `type`, `press`, `navigate`, `wait`,\n * `dialog`, and `switch`.\n *\n * @remarks\n * A step's action is one of these, an adopted page tool's name, or `unresolved`.\n */\nexport const BROWSER_JOURNEY_ACTIONS: readonly BrowserToolName[] = Object.freeze([\n\t'click',\n\t'type',\n\t'press',\n\t'navigate',\n\t'wait',\n\t'dialog',\n\t'switch',\n])\n\n/**\n * Lists every outcome a `BrowserAction` and a run step carry: `done`, `refused`, `timeout`, and\n * `interrupted`.\n */\nexport const BROWSER_ACTION_OUTCOMES: readonly BrowserStepOutcome[] = Object.freeze([\n\t'done',\n\t'refused',\n\t'timeout',\n\t'interrupted',\n])\n\n/**\n * Lists every navigation stage a `BrowserAction` and a run step carry: `requested`, `committed`,\n * and `loaded`.\n */\nexport const BROWSER_ACTION_STAGES: readonly BrowserNavigationStage[] = Object.freeze([\n\t'requested',\n\t'committed',\n\t'loaded',\n])\n\n/** Holds the result the `journeys` tool returns when no journey is saved. */\nexport const BROWSER_JOURNEY_EMPTY_LISTING = 'No journeys are saved; call record to start one.'\n\n/**\n * Names the journey tools a toolset constructed with `journeys` registers and reserves: `record`,\n * `save`, `journeys`, `edit`, `replay`, and `forget`.\n */\nexport const BROWSER_JOURNEY_TOOL_NAMES: readonly BrowserToolName[] = Object.freeze([\n\t'record',\n\t'save',\n\t'journeys',\n\t'edit',\n\t'replay',\n\t'forget',\n])\n\n/** Names observation and journey tools that cannot become journey steps. */\nexport const BROWSER_JOURNEY_NON_STEP_TOOLS: readonly string[] = Object.freeze([\n\t...BROWSER_OBSERVATION_TOOL_NAMES,\n\t...BROWSER_JOURNEY_TOOL_NAMES,\n])\n\n/** Names native tool arguments represented by journey targets, tabs, or secret bindings. */\nexport const BROWSER_JOURNEY_STEP_KEYS: readonly string[] = Object.freeze(['ref', 'tab', 'secret'])\n\n/** Holds the refusal `record`, `save`, `edit`, and `forget` return when the journeys are read-only. */\nexport const BROWSER_JOURNEY_READONLY_REFUSAL = 'The journeys are read-only; call replay.'\n\n/** Holds the refusal `record` returns while another journey is recording. */\nexport const BROWSER_JOURNEY_RECORDING_REFUSAL = 'A journey is recording; call save first.'\n\n/** Holds the refusal `save` returns when no journey is recording. */\nexport const BROWSER_JOURNEY_IDLE_REFUSAL =\n\t'No journey is recording, so nothing can be saved; answer the user. A journey holds only the actions after record, so call record before them.'\n","import type { BrowserAction, BrowserElementReason, BrowserElementSubject } from './types.js'\nimport { isInstance, isString } from '@orkestrel/contract'\n\n// === Browser errors\n\n/**\n * Represents the base error for all browser automation operations, carrying the code\n * `BROWSER_ERROR` and a `context` record.\n *\n * @remarks\n * A caller branches in a `catch` on the `code` rather than parsing message strings.\n */\nexport class BrowserError extends Error {\n\treadonly code: string\n\treadonly context: Readonly<Record<string, unknown>> | undefined\n\n\tconstructor(\n\t\tmessage: string,\n\t\tcode = 'BROWSER_ERROR',\n\t\tcontext?: Readonly<Record<string, unknown>>,\n\t) {\n\t\tsuper(message)\n\t\tthis.name = 'BrowserError'\n\t\tthis.code = code\n\t\tthis.context = context\n\t}\n}\n\n/**\n * Reports a refused element operation with a reason and, for `GONE`, the refresh directive.\n *\n * @remarks\n * The message names the element and the detail on one line. It ends with\n * `; call look for fresh refs.` for `GONE` alone, because only a changed page makes a fresh\n * reference the remedy; every other reason ends the message with a period, and a caller whose\n * refusal a fresh reference does fix names that remedy in its detail.\n */\nexport class BrowserElementError extends BrowserError {\n\tconstructor(\n\t\treference: string | BrowserElementSubject,\n\t\treason: BrowserElementReason,\n\t\tdetail?: string,\n\t) {\n\t\tconst subject = isString(reference) ? `Element ${reference}` : reference.subject\n\t\tconst text =\n\t\t\tdetail ??\n\t\t\t(reason === 'GONE'\n\t\t\t\t? 'is gone because the page changed'\n\t\t\t\t: reason === 'UNTRUSTED'\n\t\t\t\t\t? 'needs a trusted event'\n\t\t\t\t\t: reason.toLowerCase())\n\t\tsuper(\n\t\t\t`${subject} ${text}${reason === 'GONE' ? '; call look for fresh refs.' : '.'}`,\n\t\t\t'BROWSER_ELEMENT_ERROR',\n\t\t\tisString(reference) ? { reference, reason } : { subject: reference.subject, reason },\n\t\t)\n\t\tthis.name = 'BrowserElementError'\n\t}\n}\n\n/**\n * Checks whether a value is an element refusal.\n * @param value - Caught value\n * @returns True if the value is an element error; false otherwise\n */\nexport function isBrowserElementError(value: unknown): value is BrowserElementError {\n\treturn isInstance(value, BrowserElementError)\n}\n\n/**\n * Reports a journey step whose action did not complete, under the code `BROWSER_STEP_ERROR`, with\n * the performed action in `action`.\n *\n * @remarks\n * The message is `ID: RECEIPT`, where `ID` is the step's id and `RECEIPT` the action's receipt, and\n * `context` names the step under `step`. A caller reads the outcome, stage, reason, receipt, and\n * elapsed time from `action` rather than from the message.\n */\nexport class BrowserStepError extends BrowserError {\n\treadonly action: BrowserAction\n\n\tconstructor(id: string, action: BrowserAction) {\n\t\tsuper(`${id}: ${action.receipt}`, 'BROWSER_STEP_ERROR', { step: id })\n\t\tthis.name = 'BrowserStepError'\n\t\tthis.action = action\n\t}\n}\n\n/**\n * Checks whether a value is a journey step error.\n * @param value - Caught value\n * @returns True if the value is a step error; false otherwise\n */\nexport function isBrowserStepError(value: unknown): value is BrowserStepError {\n\treturn isInstance(value, BrowserStepError)\n}\n\n/**\n * Reports that a CDP request received an error response from the remote endpoint, under the\n * code `BROWSER_CDP_ERROR`, with the `method`, the CDP `code`, the `message`, and any `data`\n * in its context.\n *\n * @remarks\n * Branch on the protocol-level error in `context` instead of parsing the message string.\n */\nexport class CDPError extends BrowserError {\n\tconstructor(message: string, context?: Readonly<Record<string, unknown>>) {\n\t\tsuper(message, 'BROWSER_CDP_ERROR', context)\n\t\tthis.name = 'CDPError'\n\t}\n}\n\n/**\n * Reports that a CDP request could not be sent or completed because the client was not in a\n * connectable state — not connected, closed while connecting, or the connection dropped\n * mid-request — under the code `BROWSER_CDP_CONNECTION_ERROR`.\n */\nexport class CDPConnectionError extends BrowserError {\n\tconstructor(message: string, context?: Readonly<Record<string, unknown>>) {\n\t\tsuper(message, 'BROWSER_CDP_CONNECTION_ERROR', context)\n\t\tthis.name = 'CDPConnectionError'\n\t}\n}\n\n/**\n * Reports that a pending CDP request was not answered within its timeout window, under the\n * code `BROWSER_CDP_TIMEOUT_ERROR`.\n */\nexport class CDPTimeoutError extends BrowserError {\n\tconstructor(message: string, context?: Readonly<Record<string, unknown>>) {\n\t\tsuper(message, 'BROWSER_CDP_TIMEOUT_ERROR', context)\n\t\tthis.name = 'CDPTimeoutError'\n\t}\n}\n\n/**\n * Reports that an `evaluate()`/`read()` result exceeded {@link BROWSER_RESULT_LIMIT} and\n * was rejected in-page before it could overflow the CDP transport frame, under the code\n * `BROWSER_RESULT_LIMIT_ERROR`.\n */\nexport class BrowserResultLimitError extends BrowserError {\n\tconstructor(message: string, context?: Readonly<Record<string, unknown>>) {\n\t\tsuper(message, 'BROWSER_RESULT_LIMIT_ERROR', context)\n\t\tthis.name = 'BrowserResultLimitError'\n\t}\n}\n\n// === Browser type guards\n\n/**\n * Narrows an unknown value to a `BrowserError`.\n *\n * @param value - Value to check\n * @returns True if value is a BrowserError instance; false otherwise\n */\nexport function isBrowserError(value: unknown): value is BrowserError {\n\treturn isInstance(value, BrowserError)\n}\n\n/**\n * Narrows an unknown value to a `CDPError`.\n *\n * @param value - Value to check\n * @returns True if value is a CDPError instance; false otherwise\n */\nexport function isCDPError(value: unknown): value is CDPError {\n\treturn isInstance(value, CDPError)\n}\n\n/**\n * Narrows an unknown value to a `CDPConnectionError`.\n *\n * @param value - Value to check\n * @returns True if value is a CDPConnectionError instance; false otherwise\n */\nexport function isCDPConnectionError(value: unknown): value is CDPConnectionError {\n\treturn isInstance(value, CDPConnectionError)\n}\n\n/**\n * Narrows an unknown value to a `CDPTimeoutError`.\n *\n * @param value - Value to check\n * @returns True if value is a CDPTimeoutError instance; false otherwise\n */\nexport function isCDPTimeoutError(value: unknown): value is CDPTimeoutError {\n\treturn isInstance(value, CDPTimeoutError)\n}\n\n/**\n * Narrows an unknown value to a `BrowserResultLimitError`.\n *\n * @param value - Value to check\n * @returns True if value is a BrowserResultLimitError instance; false otherwise\n */\nexport function isBrowserResultLimitError(value: unknown): value is BrowserResultLimitError {\n\treturn isInstance(value, BrowserResultLimitError)\n}\n\n/**\n * Reports that a CDP connection, discovery, or launch attempt failed, under the code\n * `BROWSER_CONNECTION_ERROR`.\n */\nexport class BrowserConnectionError extends BrowserError {\n\tconstructor(message: string, context?: Readonly<Record<string, unknown>>) {\n\t\tsuper(message, 'BROWSER_CONNECTION_ERROR', context)\n\t\tthis.name = 'BrowserConnectionError'\n\t}\n}\n\n/**\n * Narrows an unknown value to a `BrowserConnectionError`.\n *\n * @param value - Value to check\n * @returns True if value is a BrowserConnectionError instance; false otherwise\n */\nexport function isBrowserConnectionError(value: unknown): value is BrowserConnectionError {\n\treturn isInstance(value, BrowserConnectionError)\n}\n","import type {\n\tBrowserJourneyBinding,\n\tBrowserJourneyTarget,\n\tBrowserJourneyTab,\n\tBrowserJourneyValidationContext,\n} from './types.js'\nimport { attempt, isRecord, isString } from '@orkestrel/contract'\nimport { BROWSER_JOURNEY_PARAMETER_PATTERN } from './constants.js'\n\n/**\n * Checks whether a validation context identifies a parameter, step, and field.\n * @param value - Candidate error context\n * @returns True if the binding coordinates are strings; false otherwise\n * @example\n * isBrowserJourneyValidationContext({ parameter: 'email', step: 's4', field: 'text' })\n */\nexport function isBrowserJourneyValidationContext(\n\tvalue: unknown,\n): value is BrowserJourneyValidationContext {\n\tconst result = attempt(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisString(value['parameter']) &&\n\t\t\tisString(value['step']) &&\n\t\t\tisString(value['field']),\n\t)\n\treturn result.success && result.value\n}\n\n/**\n * Checks whether a native string argument is a literal or a parameter binding.\n * @param value - Candidate argument\n * @returns True if the binding has the declared shape; false otherwise\n */\nexport function isBrowserJourneyBinding(value: unknown): value is BrowserJourneyBinding {\n\tconst result = attempt(\n\t\t() =>\n\t\t\tisString(value) ||\n\t\t\t(isRecord(value) &&\n\t\t\t\tObject.keys(value).length === 1 &&\n\t\t\t\tisString(value['parameter']) &&\n\t\t\t\tBROWSER_JOURNEY_PARAMETER_PATTERN.test(value['parameter'])),\n\t)\n\treturn result.success && result.value\n}\n\n/**\n * Checks whether a target carries its role, name, and optional evidence.\n * @param value - Candidate target\n * @returns True if the target has the declared shape; false otherwise\n */\nexport function isBrowserJourneyTarget(value: unknown): value is BrowserJourneyTarget {\n\tconst result = attempt(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tObject.keys(value).every((key) => ['role', 'name', 'css', 'reference'].includes(key)) &&\n\t\t\tisString(value['role']) &&\n\t\t\tvalue['role'].length > 0 &&\n\t\t\tisBrowserJourneyBinding(value['name']) &&\n\t\t\t(value['css'] === undefined || isString(value['css'])) &&\n\t\t\t(value['reference'] === undefined || isString(value['reference'])),\n\t)\n\treturn result.success && result.value\n}\n\n/**\n * Checks whether a tab carries its portable URL and title.\n * @param value - Candidate tab\n * @returns True if both fields are strings; false otherwise\n */\nexport function isBrowserJourneyTab(value: unknown): value is BrowserJourneyTab {\n\tconst result = attempt(\n\t\t() => isRecord(value) && isString(value['url']) && isString(value['title']),\n\t)\n\treturn result.success && result.value\n}\n\n/**\n * Checks whether a step binds a declared secret through type.text.\n * @param step - Candidate step\n * @param parameters - Candidate parameter declarations\n * @returns True if the text binds a declared secret on a type action; false otherwise\n */\nexport function isBrowserSecretBinding(\n\tstep: unknown,\n\tparameters: unknown,\n): step is {\n\treadonly action: 'type'\n\treadonly arguments: { readonly text: { readonly parameter: string } }\n} {\n\tconst result = attempt(() => {\n\t\tif (\n\t\t\t!isRecord(step) ||\n\t\t\tstep['action'] !== 'type' ||\n\t\t\t!isRecord(step['arguments']) ||\n\t\t\t!isRecord(parameters)\n\t\t)\n\t\t\treturn false\n\t\tconst binding = step['arguments']['text']\n\t\tif (!isBrowserJourneyBinding(binding) || isString(binding)) return false\n\t\tconst parameter = parameters[binding.parameter]\n\t\treturn isRecord(parameter) && parameter['secret'] === true\n\t})\n\treturn result.success && result.value\n}\n","import type {\n\tBrowserJourney,\n\tBrowserJourneyEdit,\n\tBrowserRun,\n\tBrowserTool,\n\tBrowserToolRemoval,\n\tBrowserInvocation,\n\tBrowserInvocationResult,\n\tBrowserBindingCall,\n\tBrowserCodegenGesture,\n\tBrowserConsoleMessage,\n\tBrowserCookiePartition,\n\tBrowserDownloadProgress,\n\tBrowserDownloadStart,\n\tBrowserPageError,\n\tBrowserRect,\n\tBrowserRequest,\n\tBrowserRequestFailure,\n\tBrowserResponse,\n\tBrowserSecurity,\n\tBrowserTiming,\n\tBrowserTimingRange,\n\tBrowserWebSocketFrame,\n} from './types.js'\nimport {\n\tattempt,\n\tisArray,\n\tisBoolean,\n\tisFiniteNumber,\n\tisInteger,\n\tisRecord,\n\tisString,\n\tparseArray,\n\tparseEnum,\n\tparseJSONAs,\n} from '@orkestrel/contract'\nimport {\n\tvalidateBrowserJourney,\n\tvalidateBrowserJourneyEdit,\n\tvalidateBrowserRun,\n\treadBrowserAXValue,\n\treadBrowserHeaders,\n\treadBrowserRemoteValue,\n\treadBrowserStack,\n} from './helpers.js'\n\n/**\n * Coerces a WebMCP `Tool` object to its browser-domain representation.\n * @param value - Unknown protocol tool\n * @returns The decoded tool, or undefined when required fields are malformed\n */\nexport function parseBrowserTool(value: unknown): BrowserTool | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['name']) ||\n\t\t!isString(value['description']) ||\n\t\t!isString(value['frameId'])\n\t)\n\t\treturn undefined\n\tconst hints = isRecord(value['annotations']) ? value['annotations'] : {}\n\treturn {\n\t\tname: value['name'],\n\t\tdescription: value['description'],\n\t\tframe: value['frameId'],\n\t\tschema: isRecord(value['inputSchema']) ? value['inputSchema'] : undefined,\n\t\tnode: isInteger(value['backendNodeId']) ? value['backendNodeId'] : undefined,\n\t\tannotation: {\n\t\t\t...(isBoolean(hints['readOnly']) ? { readOnly: hints['readOnly'] } : {}),\n\t\t\t...(isBoolean(hints['untrustedContent'])\n\t\t\t\t? { untrustedContent: hints['untrustedContent'] }\n\t\t\t\t: {}),\n\t\t\t...(isBoolean(hints['consequential']) ? { consequential: hints['consequential'] } : {}),\n\t\t\t...(isBoolean(hints['debugging']) ? { debugging: hints['debugging'] } : {}),\n\t\t\t...(isBoolean(hints['autosubmit']) ? { autosubmit: hints['autosubmit'] } : {}),\n\t\t},\n\t}\n}\n\n/**\n * Coerces a WebMCP `RemovedTool` object to its document and name key.\n * @param value - Unknown protocol removal\n * @returns The decoded key, or undefined when malformed\n */\nexport function parseBrowserRemoval(value: unknown): BrowserToolRemoval | undefined {\n\tif (!isRecord(value) || !isString(value['name']) || !isString(value['frameId'])) return undefined\n\treturn { frame: value['frameId'], name: value['name'] }\n}\n\n/**\n * Coerces a WebMCP `toolInvoked` event without parsing its authored input text.\n * @param value - Unknown event parameters\n * @returns The invocation, or undefined when malformed\n */\nexport function parseBrowserInvocation(value: unknown): BrowserInvocation | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['invocationId']) ||\n\t\t!isString(value['toolName']) ||\n\t\t!isString(value['frameId']) ||\n\t\t!isString(value['input'])\n\t)\n\t\treturn undefined\n\treturn {\n\t\tid: value['invocationId'],\n\t\ttool: value['toolName'],\n\t\tframe: value['frameId'],\n\t\tinput: value['input'],\n\t}\n}\n\n/**\n * Coerces a WebMCP `toolResponded` event, preserving output and terminal status.\n * @param value - Unknown event parameters\n * @returns The result, or undefined when required fields are malformed\n */\nexport function parseBrowserInvocationResult(value: unknown): BrowserInvocationResult | undefined {\n\tif (!isRecord(value) || !isString(value['invocationId']) || !isString(value['status']))\n\t\treturn undefined\n\tconst exception = isRecord(value['exception']) ? value['exception'] : undefined\n\treturn {\n\t\tid: value['invocationId'],\n\t\tstatus: value['status'],\n\t\toutput: value['output'],\n\t\terror: isString(value['errorText'])\n\t\t\t? value['errorText']\n\t\t\t: isString(exception?.['description'])\n\t\t\t\t? exception['description']\n\t\t\t\t: undefined,\n\t}\n}\n\n/**\n * Coerces one `Network.requestWillBeSent` or `Fetch.requestPaused` event to a\n * `BrowserRequest`, or `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Request or undefined\n */\nexport function parseBrowserRequest(value: unknown): BrowserRequest | undefined {\n\tif (!isRecord(value) || !isString(value['requestId']) || !isRecord(value['request'])) {\n\t\treturn undefined\n\t}\n\tconst request = value['request']\n\tif (!isString(request['url']) || !isString(request['method'])) {\n\t\treturn undefined\n\t}\n\tconst timestamp = isFiniteNumber(value['timestamp']) ? value['timestamp'] : undefined\n\tconst walltime = isFiniteNumber(value['wallTime']) ? value['wallTime'] : undefined\n\treturn {\n\t\tid: value['requestId'],\n\t\tloader: isString(value['loaderId']) ? value['loaderId'] : undefined,\n\t\tframe: isString(value['frameId']) ? value['frameId'] : undefined,\n\t\turl: request['url'],\n\t\tmethod: request['method'],\n\t\theaders: readBrowserHeaders(request['headers']),\n\t\tpost: isString(request['postData']) ? request['postData'] : undefined,\n\t\tresource: isString(value['type'])\n\t\t\t? value['type']\n\t\t\t: isString(value['resourceType'])\n\t\t\t\t? value['resourceType']\n\t\t\t\t: undefined,\n\t\ttimestamp,\n\t\twalltime,\n\t\tredirect: parseBrowserResponseRecord(\n\t\t\tvalue['redirectResponse'],\n\t\t\tvalue['requestId'],\n\t\t\tisString(value['loaderId']) ? value['loaderId'] : '',\n\t\t\tisString(value['frameId']) ? value['frameId'] : undefined,\n\t\t\ttimestamp ?? 0,\n\t\t),\n\t}\n}\n\n/**\n * Coerces one `Network.responseReceived` event to a `BrowserResponse`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Response or undefined\n */\nexport function parseBrowserResponse(value: unknown): BrowserResponse | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['requestId']) ||\n\t\t!isString(value['loaderId']) ||\n\t\t!isFiniteNumber(value['timestamp'])\n\t) {\n\t\treturn undefined\n\t}\n\treturn parseBrowserResponseRecord(\n\t\tvalue['response'],\n\t\tvalue['requestId'],\n\t\tvalue['loaderId'],\n\t\tisString(value['frameId']) ? value['frameId'] : undefined,\n\t\tvalue['timestamp'],\n\t)\n}\n\n/**\n * Coerces one Chromium response object plus its event identity to a\n * `BrowserResponse`, or `undefined` off-shape.\n *\n * @param value - Unknown response object\n * @param id - Request id\n * @param loader - Loader id\n * @param frame - Optional frame id\n * @param timestamp - Monotonic event timestamp\n * @returns Response or undefined\n */\nexport function parseBrowserResponseRecord(\n\tvalue: unknown,\n\tid: string,\n\tloader: string,\n\tframe: string | undefined,\n\ttimestamp: number,\n): BrowserResponse | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['url']) ||\n\t\t!isFiniteNumber(value['status']) ||\n\t\t!isString(value['statusText']) ||\n\t\t!isString(value['mimeType']) ||\n\t\t!isString(value['protocol']) ||\n\t\t!isFiniteNumber(timestamp)\n\t) {\n\t\treturn undefined\n\t}\n\treturn {\n\t\tid,\n\t\tloader,\n\t\tframe,\n\t\turl: value['url'],\n\t\tstatus: value['status'],\n\t\tphrase: value['statusText'],\n\t\theaders: readBrowserHeaders(value['headers']),\n\t\tmime: value['mimeType'],\n\t\tprotocol: value['protocol'],\n\t\taddress: isString(value['remoteIPAddress']) ? value['remoteIPAddress'] : undefined,\n\t\tport: isFiniteNumber(value['remotePort']) ? value['remotePort'] : undefined,\n\t\tcached: value['fromDiskCache'] === true || value['fromPrefetchCache'] === true,\n\t\tworker: value['fromServiceWorker'] === true,\n\t\ttimestamp,\n\t\ttiming: parseBrowserTiming(value['timing']),\n\t\tsecurity: parseBrowserSecurity(value['securityDetails']),\n\t}\n}\n\n/**\n * Coerces Chromium response timing to a `BrowserTiming`, or `undefined`\n * off-shape.\n *\n * @param value - Unknown timing object\n * @returns Timing or undefined\n */\nexport function parseBrowserTiming(value: unknown): BrowserTiming | undefined {\n\tif (!isRecord(value) || !isFiniteNumber(value['requestTime']) || value['requestTime'] < 0) {\n\t\treturn undefined\n\t}\n\tconst receive = value['receiveHeadersEnd']\n\treturn {\n\t\trequest: value['requestTime'],\n\t\tproxy: parseBrowserTimingRange(value, 'proxyStart', 'proxyEnd'),\n\t\tdns: parseBrowserTimingRange(value, 'dnsStart', 'dnsEnd'),\n\t\tconnect: parseBrowserTimingRange(value, 'connectStart', 'connectEnd'),\n\t\tssl: parseBrowserTimingRange(value, 'sslStart', 'sslEnd'),\n\t\tsend: parseBrowserTimingRange(value, 'sendStart', 'sendEnd'),\n\t\treceive: isFiniteNumber(receive) && receive >= 0 ? receive : undefined,\n\t}\n}\n\n/**\n * Coerces one named start/end pair of Chromium network timing to a\n * `BrowserTimingRange`, or `undefined` off-shape.\n *\n * @param value - Unknown timing object\n * @param start - Start field\n * @param end - End field\n * @returns Timing range or undefined\n */\nexport function parseBrowserTimingRange(\n\tvalue: unknown,\n\tstart: string,\n\tend: string,\n): BrowserTimingRange | undefined {\n\tif (!isRecord(value)) return undefined\n\tconst startValue = value[start]\n\tconst endValue = value[end]\n\tif (\n\t\t!isFiniteNumber(startValue) ||\n\t\tstartValue < 0 ||\n\t\t!isFiniteNumber(endValue) ||\n\t\tendValue < startValue\n\t) {\n\t\treturn undefined\n\t}\n\treturn { start: startValue, end: endValue }\n}\n\n/**\n * Coerces Chromium TLS security details to a `BrowserSecurity`, or `undefined`\n * off-shape.\n *\n * @param value - Unknown security details\n * @returns Security metadata or undefined\n */\nexport function parseBrowserSecurity(value: unknown): BrowserSecurity | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['protocol']) ||\n\t\t!isString(value['issuer']) ||\n\t\t!isFiniteNumber(value['validFrom']) ||\n\t\t!isFiniteNumber(value['validTo']) ||\n\t\tvalue['validTo'] < value['validFrom']\n\t) {\n\t\treturn undefined\n\t}\n\treturn {\n\t\tprotocol: value['protocol'],\n\t\tissuer: value['issuer'],\n\t\tfrom: value['validFrom'],\n\t\tto: value['validTo'],\n\t}\n}\n\n/**\n * Coerces one `Network.loadingFailed` event to a `BrowserRequestFailure`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Failure or undefined\n */\nexport function parseBrowserRequestFailure(value: unknown): BrowserRequestFailure | undefined {\n\tif (!isRecord(value) || !isString(value['requestId']) || !isString(value['errorText'])) {\n\t\treturn undefined\n\t}\n\treturn {\n\t\tid: value['requestId'],\n\t\terror: value['errorText'],\n\t\tcancelled: value['canceled'] === true,\n\t\tblocked: isString(value['blockedReason']) ? value['blockedReason'] : undefined,\n\t}\n}\n\n/**\n * Coerces one WebSocket frame event to a `BrowserWebSocketFrame`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Frame or undefined\n */\nexport function parseBrowserWebSocketFrame(value: unknown): BrowserWebSocketFrame | undefined {\n\tif (!isRecord(value) || !isRecord(value['response']) || !isFiniteNumber(value['timestamp'])) {\n\t\treturn undefined\n\t}\n\tconst frame = value['response']\n\tif (!isInteger(frame['opcode']) || frame['opcode'] < 0 || !isString(frame['payloadData'])) {\n\t\treturn undefined\n\t}\n\treturn {\n\t\topcode: frame['opcode'],\n\t\tdata: frame['payloadData'],\n\t\tmasked: frame['mask'] === true,\n\t\ttimestamp: value['timestamp'],\n\t}\n}\n\n/**\n * Coerces one Runtime binding invocation to a `BrowserBindingCall`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown `Runtime.bindingCalled` parameters\n * @returns Valid call or undefined\n */\nexport function parseBrowserBindingCall(value: unknown): BrowserBindingCall | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['name']) ||\n\t\t!isString(value['payload']) ||\n\t\t!isInteger(value['executionContextId'])\n\t) {\n\t\treturn undefined\n\t}\n\tconst payload = parseJSONAs(value['payload'], isRecord)\n\tif (\n\t\tpayload === undefined ||\n\t\t!isString(payload['id']) ||\n\t\t!isString(payload['name']) ||\n\t\t!isArray(payload['args']) ||\n\t\tpayload['name'] !== value['name']\n\t) {\n\t\treturn undefined\n\t}\n\treturn {\n\t\tid: payload['id'],\n\t\tname: payload['name'],\n\t\targs: payload['args'],\n\t\tcontext: value['executionContextId'],\n\t}\n}\n\n/**\n * Coerces a string-valued Accessibility-domain AXValue to a string, or\n * `undefined` off-shape.\n *\n * @param value - Unknown AX value\n * @returns String or undefined\n */\nexport function parseBrowserAXString(value: unknown): string | undefined {\n\tconst decoded = readBrowserAXValue(value)\n\treturn isString(decoded) ? decoded : undefined\n}\n\n/**\n * Coerces an optional Chromium cookie partition key to a\n * `BrowserCookiePartition`, or `undefined` off-shape.\n *\n * @param value - Unknown partition value\n * @returns Partition key or undefined\n */\nexport function parseBrowserCookiePartition(value: unknown): BrowserCookiePartition | undefined {\n\tif (!isRecord(value) || !isString(value['topLevelSite'])) return undefined\n\treturn {\n\t\tsite: value['topLevelSite'],\n\t\t...(isBoolean(value['hasCrossSiteAncestor'])\n\t\t\t? { ancestor: value['hasCrossSiteAncestor'] }\n\t\t\t: {}),\n\t}\n}\n\n/**\n * Coerces one `Runtime.consoleAPICalled` event to a `BrowserConsoleMessage`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Console message or undefined\n */\nexport function parseBrowserConsoleMessage(value: unknown): BrowserConsoleMessage | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['type']) ||\n\t\t!isFiniteNumber(value['timestamp']) ||\n\t\t!isArray(value['args'])\n\t) {\n\t\treturn undefined\n\t}\n\tconst values = value['args'].map(readBrowserRemoteValue)\n\treturn {\n\t\tlevel: value['type'],\n\t\ttext: values\n\t\t\t.map((entry) => {\n\t\t\t\tif (isString(entry)) return entry\n\t\t\t\tconst serialized = attempt<unknown>(() => JSON.stringify(entry))\n\t\t\t\treturn serialized.success && isString(serialized.value) ? serialized.value : String(entry)\n\t\t\t})\n\t\t\t.join(' '),\n\t\tvalues,\n\t\ttimestamp: value['timestamp'],\n\t\tstack: readBrowserStack(value['stackTrace']),\n\t}\n}\n\n/**\n * Coerces one `Runtime.exceptionThrown` event to a `BrowserPageError`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Page error or undefined\n */\nexport function parseBrowserPageError(value: unknown): BrowserPageError | undefined {\n\tif (!isRecord(value) || !isRecord(value['exceptionDetails'])) return undefined\n\tconst details = value['exceptionDetails']\n\tconst timestamp = isFiniteNumber(value['timestamp']) ? value['timestamp'] : Date.now()\n\tconst exception = readBrowserRemoteValue(details['exception'])\n\tconst message = isString(exception)\n\t\t? exception\n\t\t: isString(details['text'])\n\t\t\t? details['text']\n\t\t\t: 'Uncaught page exception'\n\treturn {\n\t\tmessage,\n\t\tstack: readBrowserStack(details['stackTrace']),\n\t\ttimestamp,\n\t}\n}\n\n/**\n * Coerces one `Browser.downloadWillBegin` event to a `BrowserDownloadStart`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Download start or undefined\n */\nexport function parseBrowserDownloadStart(value: unknown): BrowserDownloadStart | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['guid']) ||\n\t\t!isString(value['url']) ||\n\t\t!isString(value['suggestedFilename']) ||\n\t\t!isString(value['frameId'])\n\t) {\n\t\treturn undefined\n\t}\n\treturn {\n\t\tid: value['guid'],\n\t\turl: value['url'],\n\t\tname: value['suggestedFilename'],\n\t\tframe: value['frameId'],\n\t}\n}\n\n/**\n * Coerces one `Browser.downloadProgress` event to a `BrowserDownloadProgress`,\n * or `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Download id and progress, or undefined\n */\nexport function parseBrowserDownloadProgress(\n\tvalue: unknown,\n): readonly [id: string, progress: BrowserDownloadProgress] | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['guid']) ||\n\t\t!isFiniteNumber(value['receivedBytes']) ||\n\t\tvalue['receivedBytes'] < 0 ||\n\t\t!isFiniteNumber(value['totalBytes']) ||\n\t\tvalue['totalBytes'] < 0\n\t) {\n\t\treturn undefined\n\t}\n\tconst state = parseEnum(value['state'], ['completed', 'canceled', 'inProgress'])\n\tconst status =\n\t\tstate === 'completed'\n\t\t\t? 'complete'\n\t\t\t: state === 'canceled'\n\t\t\t\t? 'aborted'\n\t\t\t\t: state === 'inProgress'\n\t\t\t\t\t? 'pending'\n\t\t\t\t\t: undefined\n\tif (status === undefined) return undefined\n\treturn [\n\t\tvalue['guid'],\n\t\t{\n\t\t\tstatus,\n\t\t\treceived: value['receivedBytes'],\n\t\t\ttotal: value['totalBytes'],\n\t\t\t...(isString(value['filePath']) ? { path: value['filePath'] } : {}),\n\t\t},\n\t]\n}\n\n/**\n * Parses a sanitized document gesture, refusing malformed or secret-bearing payloads.\n * @param payload - The runtime binding's JSON string\n * @returns The gesture, or undefined for an invalid payload\n * @example\n * parseCodegenActionPayload('invalid') // undefined\n */\nexport function parseCodegenActionPayload(payload: unknown): BrowserCodegenGesture | undefined {\n\tif (!isString(payload)) return undefined\n\tconst value = parseJSONAs(payload, isRecord)\n\tif (value === undefined) return undefined\n\tconst event = parseEnum(value['event'], [\n\t\t'click',\n\t\t'input',\n\t\t'change',\n\t\t'keydown',\n\t\t'focusout',\n\t\t'submit',\n\t\t'unsupported',\n\t])\n\tconst control = parseEnum(value['control'], [\n\t\t'text',\n\t\t'password',\n\t\t'select',\n\t\t'multiple',\n\t\t'option',\n\t\t'other',\n\t])\n\tconst index = value['index']\n\tconst top = value['top']\n\tconst form = value['form']\n\tif (\n\t\tevent === undefined ||\n\t\tcontrol === undefined ||\n\t\t!isInteger(index) ||\n\t\tindex < 0 ||\n\t\t!Number.isSafeInteger(index) ||\n\t\t!isBoolean(top) ||\n\t\t!isBoolean(form)\n\t)\n\t\treturn undefined\n\tif (\n\t\tObject.keys(value).some(\n\t\t\t(key) =>\n\t\t\t\t![\n\t\t\t\t\t'event',\n\t\t\t\t\t'control',\n\t\t\t\t\t'index',\n\t\t\t\t\t'top',\n\t\t\t\t\t'form',\n\t\t\t\t\t'detail',\n\t\t\t\t\t'key',\n\t\t\t\t\t'value',\n\t\t\t\t\t'secret',\n\t\t\t\t\t'roundtrip',\n\t\t\t\t\t'gap',\n\t\t\t\t].includes(key),\n\t\t)\n\t)\n\t\treturn undefined\n\tif ('key' in value && (event !== 'keydown' || value['key'] !== 'Enter')) return undefined\n\tif (event === 'keydown' && value['key'] !== 'Enter') return undefined\n\tif (\n\t\t'detail' in value &&\n\t\t(!isInteger(value['detail']) || value['detail'] < 0 || event !== 'click')\n\t)\n\t\treturn undefined\n\tif (event === 'click' && !isInteger(value['detail'])) return undefined\n\tif (\n\t\t'value' in value &&\n\t\t(!isString(value['value']) ||\n\t\t\t!((event === 'input' && control === 'text') || (event === 'change' && control === 'select')))\n\t)\n\t\treturn undefined\n\tif (\n\t\t'secret' in value &&\n\t\t(value['secret'] !== true || control !== 'password' || event !== 'input')\n\t)\n\t\treturn undefined\n\tif (event === 'input' && control === 'password' && value['secret'] !== true) return undefined\n\tif (event === 'input' && control === 'text' && !isString(value['value'])) return undefined\n\tif (\n\t\t'roundtrip' in value &&\n\t\t(event !== 'change' || control !== 'select' || !isBoolean(value['roundtrip']))\n\t)\n\t\treturn undefined\n\tif (\n\t\tevent === 'change' &&\n\t\tcontrol === 'select' &&\n\t\t(!isString(value['value']) || !isBoolean(value['roundtrip']))\n\t)\n\t\treturn undefined\n\tif ('gap' in value && (event !== 'unsupported' || !isString(value['gap']))) return undefined\n\tif (event === 'unsupported' && !isString(value['gap'])) return undefined\n\treturn {\n\t\tevent,\n\t\tcontrol,\n\t\tindex,\n\t\ttop,\n\t\tform,\n\t\t...(isInteger(value['detail']) ? { detail: value['detail'] } : {}),\n\t\t...(value['key'] === 'Enter' ? { key: 'Enter' } : {}),\n\t\t...(isString(value['value']) ? { value: value['value'] } : {}),\n\t\t...(value['secret'] === true ? { secret: true } : {}),\n\t\t...(isBoolean(value['roundtrip']) ? { roundtrip: value['roundtrip'] } : {}),\n\t\t...(isString(value['gap']) ? { gap: value['gap'] } : {}),\n\t}\n}\n\n/**\n * Coerces an unknown value to an all-number array, or `undefined` off-shape.\n *\n * @param value - Candidate value\n * @returns The number array, or undefined\n */\nexport function parseNumberArray(value: unknown): readonly number[] | undefined {\n\treturn parseArray(value, isFiniteNumber)\n}\n\n/**\n * Coerces one CDP snapshot string-table index to its string, or `undefined`\n * off-shape.\n *\n * @param strings - Snapshot string table\n * @param index - Candidate string index\n * @returns The resolved string, or undefined\n */\nexport function parseSnapshotString(\n\tstrings: readonly string[],\n\tindex: unknown,\n): string | undefined {\n\tif (!isInteger(index)) return undefined\n\treturn strings[index]\n}\n\n/**\n * Coerces a four-number CSS-pixel rectangle to a `BrowserRect`, or `undefined` off-shape.\n *\n * @param value - Candidate four-number array\n * @returns A rectangle, or undefined\n */\nexport function parseBrowserRect(value: unknown): BrowserRect | undefined {\n\tconst numbers = parseNumberArray(value)\n\tif (numbers === undefined || numbers.length !== 4) return undefined\n\tconst x = numbers[0]\n\tconst y = numbers[1]\n\tconst width = numbers[2]\n\tconst height = numbers[3]\n\tif (x === undefined || y === undefined || width === undefined || height === undefined) {\n\t\treturn undefined\n\t}\n\treturn [x, y, width, height]\n}\n/**\n * Parses the supported element-reference spellings into their canonical form.\n * @param value - Reference supplied by a caller\n * @returns Canonical reference, or undefined for an invalid spelling\n */\nexport function parseBrowserReference(value: string): string | undefined {\n\tconst match =\n\t\t/^(?:e([1-9]\\d*)|([1-9]\\d*)|\\[e([1-9]\\d*)\\]|ref=e([1-9]\\d*)|\\[ref=e([1-9]\\d*)\\])$/i.exec(value)\n\tconst number = match?.slice(1).find((part) => part !== undefined)\n\treturn number === undefined ? undefined : `e${number}`\n}\n\n/**\n * Parses a journey without throwing when validation fails.\n * @param value - Candidate journey\n * @returns The validated value, or undefined\n */\nexport function parseBrowserJourney(value: unknown): BrowserJourney | undefined {\n\tconst result = attempt(() => {\n\t\tvalidateBrowserJourney(value)\n\t\treturn value\n\t})\n\treturn result.success ? result.value : undefined\n}\n\n/**\n * Parses an edit without throwing when its structure fails validation.\n * @param value - Candidate edit\n * @returns The validated value, or undefined\n */\nexport function parseBrowserJourneyEdit(value: unknown): BrowserJourneyEdit | undefined {\n\tconst result = attempt(() => {\n\t\tvalidateBrowserJourneyEdit(value)\n\t\treturn value\n\t})\n\treturn result.success ? result.value : undefined\n}\n\n/**\n * Parses a run without throwing when validation fails.\n * @param value - Candidate run\n * @returns The validated value, or undefined\n */\nexport function parseBrowserRun(value: unknown): BrowserRun | undefined {\n\tconst result = attempt(() => {\n\t\tvalidateBrowserRun(value)\n\t\treturn value\n\t})\n\treturn result.success ? result.value : undefined\n}\n","import type {\n\tBrowserJourney,\n\tBrowserStoreFault,\n\tBrowserJourneyEdit,\n\tBrowserJourneyParameter,\n\tBrowserJourneyStep,\n\tBrowserJourneyStepInput,\n\tBrowserRun,\n\tBrowserElementQuery,\n\tBrowserOutline,\n\tBrowserOutlineNode,\n\tBrowserChord,\n\tBrowserCookie,\n\tBrowserCookieInput,\n\tBrowserContextOptions,\n\tBrowserCoverageRange,\n\tBrowserDocument,\n\tBrowserEmulationOptions,\n\tBrowserFrameInfo,\n\tBrowserFunctionCoverage,\n\tBrowserHAR,\n\tBrowserHAREntry,\n\tBrowserHARPending,\n\tBrowserHARValue,\n\tBrowserLayout,\n\tBrowserMetric,\n\tBrowserOperationOptions,\n\tBrowserAccessibilityOptions,\n\tBrowserAccessibilitySnapshot,\n\tBrowserAXNode,\n\tBrowserKey,\n\tBrowserNode,\n\tBrowserNodePredicate,\n\tBrowserNodeQuery,\n\tBrowserProfile,\n\tBrowserProfileFrame,\n\tBrowserProfileNode,\n\tBrowserMouseButton,\n\tBrowserPoint,\n\tBrowserPDFOptions,\n\tBrowserMedia,\n\tBrowserRequest,\n\tBrowserRouteQuery,\n\tBrowserQuad,\n\tBrowserReadResult,\n\tBrowserReceipt,\n\tBrowserElementInterface,\n\tBrowserSnapshotInput,\n\tBrowserScriptCoverage,\n\tBrowserScreenshotOptions,\n\tBrowserStorageEntry,\n\tBrowserStorageOrigin,\n\tBrowserStreamChunk,\n\tBrowserStackFrame,\n\tBrowserStyleCoverage,\n\tBrowserTeardownFunction,\n\tBrowserViewport,\n} from './types.js'\nimport type { ToolDefinition } from '@orkestrel/tool'\nimport {\n\tattempt,\n\tisArray,\n\tisBoolean,\n\tisFiniteNumber,\n\tisFunction,\n\tisInteger,\n\tisJSONValue,\n\tisRecord,\n\tisString,\n\tparseArray,\n\tparseEnum,\n} from '@orkestrel/contract'\nimport {\n\tBROWSER_TOOL_COPY,\n\tBROWSER_ACTION_OUTCOMES,\n\tBROWSER_ACTION_STAGES,\n\tBROWSER_NAVIGATION_REASONS,\n\tBROWSER_JOURNEY_ACTIONS,\n\tBROWSER_JOURNEY_NON_STEP_TOOLS,\n\tBROWSER_JOURNEY_STEP_KEYS,\n\tBROWSER_RUN_ID_PATTERN,\n\tBROWSER_JOURNEY_FORMAT_VERSION,\n\tBROWSER_JOURNEY_NAME_PATTERN,\n\tBROWSER_JOURNEY_PARAMETER_PATTERN,\n\tBASE64_CHARS,\n\tBROWSER_OUTLINE_OMITTED_ROLES,\n\tBASE64_LOOKUP,\n\tBROWSER_RESULT_LIMIT,\n\tBROWSER_REGISTRY_OUTPUT_LIMIT,\n\tBROWSER_RESULT_LIMIT_PATTERN,\n\tBROWSER_SNAPSHOT_NODE_LIMIT,\n\tBROWSER_KEY_MODIFIERS,\n\tBROWSER_MOUSE_BUTTON_MASKS,\n} from './constants.js'\nimport {\n\tisBrowserJourneyBinding,\n\tisBrowserJourneyValidationContext,\n\tisBrowserJourneyTarget,\n\tisBrowserJourneyTab,\n\tisBrowserSecretBinding,\n} from './validators.js'\nimport {\n\tBrowserElementError,\n\tBrowserError,\n\tBrowserResultLimitError,\n\tisBrowserError,\n} from './errors.js'\nimport {\n\tparseBrowserAXString,\n\tparseBrowserCookiePartition,\n\tparseBrowserRect,\n\tparseBrowserReference,\n\tparseNumberArray,\n\tparseSnapshotString,\n} from './parsers.js'\n\n/**\n * Normalizes an accessible name for display and matching.\n * @param value - Accessible name\n * @returns Trimmed name with collapsed whitespace\n */\nexport function normalizeBrowserName(value: string): string {\n\treturn value.trim().replace(/\\s+/g, ' ')\n}\n\n/**\n * Filters document-order outline rows by accessibility role and name.\n * @param nodes - Captured rows\n * @param query - Role and name constraints, with whole, case-sensitive matching when exact is true\n * @returns Matching rows in their original order\n */\nexport function filterBrowserOutline(\n\tnodes: readonly BrowserOutlineNode[],\n\tquery: BrowserElementQuery,\n): readonly BrowserOutlineNode[] {\n\treturn nodes.filter(\n\t\t(node) =>\n\t\t\t!node.ignored &&\n\t\t\t!BROWSER_OUTLINE_OMITTED_ROLES.has(node.role ?? '') &&\n\t\t\t(query.role === undefined || node.role === query.role) &&\n\t\t\t(query.name === undefined ||\n\t\t\t\t(query.exact === true\n\t\t\t\t\t? normalizeBrowserName(node.name ?? '') === normalizeBrowserName(query.name)\n\t\t\t\t\t: normalizeBrowserName(node.name ?? '')\n\t\t\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t\t\t.includes(normalizeBrowserName(query.name).toLowerCase()))),\n\t)\n}\n\n/**\n * Renders document-order text and referenced elements with a bounded element count.\n * @param url - Document address\n * @param title - Document title\n * @param nodes - Ordered accessibility rows\n * @param limit - Maximum referenced rows to include\n * @returns Outline text and element counts\n */\nexport function renderBrowserOutline(\n\turl: string,\n\ttitle: string,\n\tnodes: readonly BrowserOutlineNode[],\n\tlimit: number,\n): BrowserOutline {\n\tconst rows = [`page ${JSON.stringify(title)} ${url}`]\n\tlet count = 0\n\tlet total = 0\n\tfor (const node of nodes) {\n\t\tif (node.ignored || BROWSER_OUTLINE_OMITTED_ROLES.has(node.role ?? '')) continue\n\t\tconst name = normalizeBrowserName(node.name ?? '')\n\t\tif (node.role === 'heading') {\n\t\t\trows.push(`# ${name}`)\n\t\t\tcontinue\n\t\t}\n\t\tif (node.role === 'StaticText') {\n\t\t\tconst parent = nodes.find(\n\t\t\t\t(candidate) => candidate.session === node.session && candidate.id === node.parent,\n\t\t\t)\n\t\t\tif (name !== '' && name !== normalizeBrowserName(parent?.name ?? '')) rows.push(name)\n\t\t\tcontinue\n\t\t}\n\t\tif (node.reference === undefined) continue\n\t\ttotal += 1\n\t\tif (count >= limit) continue\n\t\tcount += 1\n\t\tlet row = `${node.reference} ${node.role ?? 'unknown'} ${JSON.stringify(name)}`\n\t\tif (node.value !== undefined && node.value !== '')\n\t\t\trow += ` value=${JSON.stringify(String(node.value))}`\n\t\tif (node.properties['checked'] === true || node.properties['checked'] === 'true')\n\t\t\trow += ' [checked]'\n\t\tif (node.properties['disabled'] === true) row += ' [disabled]'\n\t\tif (node.tool !== undefined) row += ` [tool=${node.tool}]`\n\t\trows.push(row)\n\t}\n\trows.push(`(${count} of ${total} elements)`)\n\treturn { url, title, text: rows.join('\\n'), count, total }\n}\n\n/**\n * Composes a frame-local point with its ancestor frame offsets.\n * @param point - Local point\n * @param offsets - Frame rectangles' origins, ordered from child to parent\n * @returns Validated page point\n */\nexport function composeBrowserPoint(\n\tpoint: BrowserPoint,\n\toffsets: readonly BrowserPoint[],\n): BrowserPoint {\n\tvalidateBrowserPoint(point)\n\tlet x = point.x\n\tlet y = point.y\n\tfor (const offset of offsets) {\n\t\tvalidateBrowserPoint(offset)\n\t\tx += offset.x\n\t\ty += offset.y\n\t}\n\tconst result = { x, y }\n\tvalidateBrowserPoint(result)\n\treturn result\n}\n\n/**\n * Normalizes named keys and modifier aliases before trusted keyboard input.\n * @param value - Key or modifier chord\n * @returns Canonical key chord\n * @throws Thrown when a key or modifier is unsupported, listing accepted names.\n */\nexport function normalizeBrowserKey(value: string): string {\n\tconst accepted = [\n\t\t'Backspace',\n\t\t'Tab',\n\t\t'Enter',\n\t\t'Shift',\n\t\t'Control',\n\t\t'Alt',\n\t\t'Escape',\n\t\t'Space',\n\t\t'PageUp',\n\t\t'PageDown',\n\t\t'End',\n\t\t'Home',\n\t\t'ArrowLeft',\n\t\t'ArrowUp',\n\t\t'ArrowRight',\n\t\t'ArrowDown',\n\t\t'Delete',\n\t\t'Meta',\n\t]\n\tconst aliases: Readonly<Record<string, string>> = {\n\t\treturn: 'Enter',\n\t\tesc: 'Escape',\n\t\tctrl: 'Control',\n\t\tcmd: 'Meta',\n\t\tcommand: 'Meta',\n\t}\n\tconst parts = value.split('+')\n\tconst normalized = parts.map(\n\t\t(part) =>\n\t\t\taliases[part.toLowerCase()] ??\n\t\t\taccepted.find((name) => name.toLowerCase() === part.toLowerCase()) ??\n\t\t\tpart,\n\t)\n\ttry {\n\t\tconst chord = extractBrowserChord(normalized.join('+'))\n\t\tkeyToBrowserInput(chord.key)\n\t\tif (parts.some((part) => part === '')) throw new BrowserError('Empty key')\n\t\treturn normalized.join('+')\n\t} catch {\n\t\tthrow new BrowserError(\n\t\t\t`Unknown browser key ${JSON.stringify(value)}. Accepted names: ${accepted.join(', ')}, a single character, and modifier chords such as Control+a.`,\n\t\t)\n\t}\n}\n\n/**\n * Renders tool strings unchanged, content-array text blocks joined, and other values as bounded JSON.\n * @param value - Untrusted tool output\n * @returns Rendered output; non-serializable values receive a bounded diagnostic\n */\nexport function renderBrowserToolOutput(value: unknown): string {\n\tif (isString(value)) return value\n\tif (isArray(value) && value.every((block) => isRecord(block) && isString(block['type']))) {\n\t\treturn value\n\t\t\t.filter(isRecord)\n\t\t\t.filter((block) => block['type'] === 'text' && isString(block['text']))\n\t\t\t.map((block) => block['text'])\n\t\t\t.join('\\n')\n\t}\n\tconst rendered = attempt(() => JSON.stringify(value))\n\treturn (\n\t\trendered.success ? (rendered.value ?? String(value)) : '[Unserializable tool output]'\n\t).slice(0, BROWSER_REGISTRY_OUTPUT_LIMIT)\n}\n\n/**\n * Derives the advertised input schema from an authored one, adding a required `what` parameter when the schema requires nothing.\n * @param schema - Authored input schema, or undefined for a parameterless tool\n * @returns An advertised schema, or undefined when the authored `what` parameter is optional\n * @remarks The caller strips only a synthetic `what` parameter before invoking the page tool.\n */\nexport function deriveBrowserToolSchema(\n\tschema: Readonly<Record<string, unknown>> | undefined,\n): Readonly<Record<string, unknown>> | undefined {\n\tconst properties = isRecord(schema?.['properties']) ? schema['properties'] : {}\n\tconst required = isArray(schema?.['required']) ? schema['required'].filter(isString) : []\n\tif (Object.hasOwn(properties, 'what') && !required.includes('what')) return undefined\n\tif (required.length > 0) return schema\n\treturn {\n\t\t...schema,\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\t...properties,\n\t\t\twhat: { type: 'string', description: 'Describe the purpose of this action.' },\n\t\t},\n\t\trequired: ['what'],\n\t}\n}\n\n/**\n * Bounds a tool string at a character limit, appending a footer that names the cut and the\n * caller's closing clause.\n *\n * @remarks\n * A string within the limit returns unchanged. A longer one keeps its first `limit` UTF-16 code\n * units, one fewer when the last would split a surrogate pair (so a limit of 1 before a pair keeps\n * nothing), followed by `\\n[characters 0–END of TOTAL; FOOTER]`. The footer has no default, so\n * every caller states what the cut result's reader does next: the toolset passes\n * `BROWSER_TOOL_VIEW_FOOTER` for a result that carries a view and `BROWSER_TOOL_CUT_FOOTER` for\n * any other.\n *\n * @param text - The page-authored or composed string\n * @param limit - The most characters kept before the footer, a positive integer\n * @param footer - The clause that closes the footer after the character range\n * @returns The string, cut and footed when it exceeds the limit\n * @throws Thrown when `limit` is not a positive integer.\n *\n * @example\n * ```ts\n * import { boundBrowserText } from '@orkestrel/browser'\n *\n * boundBrowserText('abcdef', 4, 'the rest was cut') // 'abcd\\n[characters 0–4 of 6; the rest was cut]'\n * boundBrowserText('abc', 4, 'the rest was cut') // 'abc'\n * ```\n */\nexport function boundBrowserText(text: string, limit: number, footer: string): string {\n\tif (!isInteger(limit) || limit < 1) {\n\t\tthrow new BrowserError('Browser tool limit must be a positive integer', undefined, { limit })\n\t}\n\tif (text.length <= limit) return text\n\tconst last = text.charCodeAt(limit - 1)\n\tconst end = last >= 0xd800 && last <= 0xdbff ? limit - 1 : limit\n\treturn `${text.slice(0, end)}\\n[characters 0–${end} of ${text.length}; ${footer}]`\n}\n\n/**\n * Refuses a tool call that carries a parameter its definition does not advertise, naming the\n * parameters the tool takes.\n *\n * @param definition - The advertised tool definition whose `parameters.properties` names the\n * accepted keys\n * @param args - The arguments a model supplied\n * @throws Thrown as a `BrowserError` coded `BROWSER_TOOLSET_ARGUMENT`, with the refused key in its\n * context, when an argument key is not an advertised parameter.\n *\n * @example\n * ```ts\n * import { BROWSER_TOOL_COPY, validateBrowserToolArguments } from '@orkestrel/browser'\n *\n * validateBrowserToolArguments(BROWSER_TOOL_COPY.look, { what: 'cart', ref: 'e1' })\n * // throws 'The look tool takes no ref parameter; call look with what.'\n * ```\n */\nexport function validateBrowserToolArguments(\n\tdefinition: ToolDefinition,\n\targs: Readonly<Record<string, unknown>>,\n): void {\n\tconst properties = definition.parameters?.['properties']\n\tconst keys = isRecord(properties) ? Object.keys(properties) : []\n\tconst key = Object.keys(args).find((candidate) => !keys.includes(candidate))\n\tif (key === undefined) return\n\tconst accepted = new Intl.ListFormat('en', { type: 'conjunction' }).format(keys)\n\tthrow new BrowserError(\n\t\t`The ${definition.name} tool takes no ${key} parameter; call ${definition.name} with ${accepted}.`,\n\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t{ key },\n\t)\n}\n\n/**\n * Renders an element as its outline row reads: reference, role, and quoted name.\n *\n * @param element - The referenced element\n * @returns The element's reference, role, and JSON-quoted name\n *\n * @example\n * ```ts\n * import { renderBrowserElement } from '@orkestrel/browser'\n *\n * const element = page.elements.element('e4')\n * if (element !== undefined) renderBrowserElement(element) // 'e4 button \"Place order\"'\n * ```\n */\nexport function renderBrowserElement(element: BrowserElementInterface): string {\n\treturn `${element.reference} ${element.role} ${JSON.stringify(element.name)}`\n}\n\n/**\n * Requires a tool argument to be an element reference in any spelling `parseBrowserReference`\n * accepts, and returns its canonical form.\n *\n * @param value - The argument a model supplied\n * @returns The canonical reference, such as `e12`\n * @throws Thrown as a `BrowserElementError` with reason `UNKNOWN` when the value is not a\n * reference, naming `look` as the next call.\n *\n * @example\n * ```ts\n * import { requireBrowserReference } from '@orkestrel/browser'\n *\n * requireBrowserReference('[ref=e12]') // 'e12'\n * ```\n */\nexport function requireBrowserReference(value: unknown): string {\n\tconst reference = isString(value) ? parseBrowserReference(value) : undefined\n\tif (reference === undefined)\n\t\tthrow new BrowserElementError(\n\t\t\t{ subject: `Reference ${JSON.stringify(value)}` },\n\t\t\t'UNKNOWN',\n\t\t\t'is not a reference such as e12; call look for fresh refs',\n\t\t)\n\treturn reference\n}\n\n/**\n * Reads a required string argument from a tool call.\n *\n * @param args - The arguments a model supplied\n * @param key - The parameter name\n * @returns The string the argument holds\n * @throws Thrown as a `BrowserError` coded `BROWSER_TOOLSET_ARGUMENT` when the argument is not a\n * string.\n *\n * @example\n * ```ts\n * import { readBrowserToolString } from '@orkestrel/browser'\n *\n * readBrowserToolString({ url: 'https://example.com/' }, 'url') // 'https://example.com/'\n * ```\n */\nexport function readBrowserToolString(\n\targs: Readonly<Record<string, unknown>>,\n\tkey: string,\n): string {\n\tconst value = args[key]\n\tif (!isString(value))\n\t\tthrow new BrowserError(`The ${key} parameter must be a string.`, 'BROWSER_TOOLSET_ARGUMENT', {\n\t\t\tkey,\n\t\t})\n\treturn value\n}\n\n/**\n * Renders a tool receipt: the action and its status on one line, the interrupting dialog, then\n * a blank line and the fresh view.\n *\n * @remarks\n * The status joins the action with a semicolon, and a period closes the line. A dialog adds\n * `A CATEGORY dialog is open: \"MESSAGE\"; call dialog.`, with `An` before `alert`. An empty\n * action with no status leaves the dialog sentence, or the view, alone. A `trusted` of `false`\n * ends the line with ` (untrusted event)`.\n *\n * @param receipt - The action, status, dialog, and view\n * @returns The receipt text\n *\n * @example\n * ```ts\n * import { renderBrowserReceipt } from '@orkestrel/browser'\n *\n * renderBrowserReceipt({\n * \taction: 'Clicked e7 button \"Delete\"',\n * \tdialog: { category: 'confirm', message: 'Delete the draft?' },\n * })\n * // 'Clicked e7 button \"Delete\". A confirm dialog is open: \"Delete the draft?\"; call dialog.'\n * ```\n */\nexport function renderBrowserReceipt(receipt: BrowserReceipt): string {\n\tconst sentences: string[] = []\n\tif (receipt.action !== '' || receipt.status !== undefined)\n\t\tsentences.push(\n\t\t\t`${[receipt.action, receipt.status].filter((part) => part !== undefined && part !== '').join('; ')}.`,\n\t\t)\n\tif (receipt.dialog !== undefined)\n\t\tsentences.push(\n\t\t\t`${receipt.dialog.category === 'alert' ? 'An' : 'A'} ${receipt.dialog.category} dialog is open: ${JSON.stringify(receipt.dialog.message)}; call dialog.`,\n\t\t)\n\tconst line = `${sentences.join(' ')}${receipt.trusted === false ? ' (untrusted event)' : ''}`\n\tif (receipt.view === undefined) return line\n\treturn line === '' ? receipt.view : `${line}\\n\\n${receipt.view}`\n}\n\n/**\n * Decodes a base64-encoded string into raw bytes.\n *\n * @remarks\n * Pure JS implementation — no `Buffer`, no `atob` (DOM-only) — so it runs\n * identically in Node and browser environments. Whitespace and `=` padding\n * are ignored; invalid characters are skipped.\n *\n * @param text - Base64-encoded input string\n * @returns Decoded bytes\n *\n * @example\n * ```ts\n * decodeBase64('aGVsbG8=') // Uint8Array [104, 101, 108, 108, 111]\n * ```\n */\nexport function decodeBase64(text: string): Uint8Array {\n\tconst clean = text.replace(/[^A-Za-z0-9+/]/g, '')\n\tconst bytes: number[] = []\n\n\tlet buffer = 0\n\tlet bits = 0\n\n\tfor (const char of clean) {\n\t\tconst value = BASE64_LOOKUP[char]\n\t\tif (value === undefined) continue\n\n\t\tbuffer = (buffer << 6) | value\n\t\tbits += 6\n\n\t\tif (bits >= 8) {\n\t\t\tbits -= 8\n\t\t\tbytes.push((buffer >> bits) & 0xff)\n\t\t}\n\t}\n\n\treturn new Uint8Array(bytes)\n}\n\n/**\n * Encodes raw bytes as base64 without relying on Node or DOM globals.\n *\n * @param bytes - Raw input bytes\n * @returns Base64 text\n */\nexport function encodeBase64(bytes: Uint8Array): string {\n\tlet result = ''\n\tfor (let index = 0; index < bytes.length; index += 3) {\n\t\tconst first = bytes[index]\n\t\tconst second = bytes[index + 1]\n\t\tconst third = bytes[index + 2]\n\t\tif (first === undefined) break\n\t\tconst value = (first << 16) | ((second ?? 0) << 8) | (third ?? 0)\n\t\tresult += BASE64_CHARS[(value >> 18) & 63] ?? ''\n\t\tresult += BASE64_CHARS[(value >> 12) & 63] ?? ''\n\t\tresult += second === undefined ? '=' : (BASE64_CHARS[(value >> 6) & 63] ?? '')\n\t\tresult += third === undefined ? '=' : (BASE64_CHARS[value & 63] ?? '')\n\t}\n\treturn result\n}\n\n/** Encodes UTF-8 text as bytes. */\nexport function textToBytes(value: string): Uint8Array {\n\treturn new TextEncoder().encode(value)\n}\n\n/** Decodes UTF-8 bytes as text. */\nexport function bytesToText(value: Uint8Array): string {\n\treturn new TextDecoder().decode(value)\n}\n\n/**\n * Converts a header record to Fetch-domain name/value entries.\n *\n * @param headers - Header record\n * @returns Protocol header entries\n */\nexport function browserHeadersToProtocol(\n\theaders: Readonly<Record<string, string>>,\n): ReadonlyArray<Readonly<Record<string, string>>> {\n\treturn Object.entries(headers).map(([name, value]) => ({ name, value }))\n}\n\n/**\n * Decodes a Chromium Headers object into string values, skipping every entry that is neither a\n * string nor a finite number.\n *\n * @param value - Unknown headers\n * @returns Frozen-compatible header record\n */\nexport function readBrowserHeaders(value: unknown): Readonly<Record<string, string>> {\n\tif (!isRecord(value)) return {}\n\tconst headers: Record<string, string> = {}\n\tfor (const [name, entry] of Object.entries(value)) {\n\t\tif (isString(entry) || isFiniteNumber(entry)) headers[name] = String(entry)\n\t}\n\treturn headers\n}\n\n/**\n * Builds a standards-shaped HAR 1.2 entry from one observed exchange.\n *\n * @param pending - Request and optional response captured by the recorder\n * @param duration - Whole exchange duration in milliseconds\n * @param body - Optional decoded response body\n * @param error - Optional request failure description\n * @returns HAR 1.2 entry\n */\nexport function createBrowserHAREntry(\n\tpending: BrowserHARPending,\n\tduration: number,\n\tbody?: Uint8Array,\n\terror?: string,\n): BrowserHAREntry {\n\tconst response = pending.response\n\tconst requestHeaders: BrowserHARValue[] = Object.entries(pending.request.headers).map(\n\t\t([name, value]) => ({ name, value }),\n\t)\n\tconst responseHeaders: BrowserHARValue[] =\n\t\tresponse === undefined\n\t\t\t? []\n\t\t\t: Object.entries(response.headers).map(([name, value]) => ({ name, value }))\n\tconst query: BrowserHARValue[] = []\n\tif (URL.canParse(pending.request.url)) {\n\t\tfor (const [name, value] of new URL(pending.request.url).searchParams) {\n\t\t\tquery.push({ name, value })\n\t\t}\n\t}\n\tconst post = pending.request.post\n\tconst requestMime =\n\t\tObject.entries(pending.request.headers).find(\n\t\t\t([name]) => name.toLowerCase() === 'content-type',\n\t\t)?.[1] ?? 'application/octet-stream'\n\tconst redirect =\n\t\tresponse === undefined\n\t\t\t? ''\n\t\t\t: (Object.entries(response.headers).find(\n\t\t\t\t\t([name]) => name.toLowerCase() === 'location',\n\t\t\t\t)?.[1] ?? '')\n\tconst timing = response?.timing\n\tconst dns = timing?.dns === undefined ? -1 : Math.max(0, timing.dns.end - timing.dns.start)\n\tconst connect =\n\t\ttiming?.connect === undefined ? -1 : Math.max(0, timing.connect.end - timing.connect.start)\n\tconst send = timing?.send === undefined ? 0 : Math.max(0, timing.send.end - timing.send.start)\n\tconst wait =\n\t\ttiming?.receive === undefined\n\t\t\t? Math.max(0, duration)\n\t\t\t: Math.max(0, timing.receive - (timing.send?.end ?? 0))\n\tconst ssl = timing?.ssl === undefined ? -1 : Math.max(0, timing.ssl.end - timing.ssl.start)\n\tconst text = body === undefined ? undefined : encodeBase64(body)\n\tconst size = body?.byteLength ?? (response === undefined ? 0 : -1)\n\n\treturn {\n\t\tstartedDateTime: new Date(pending.started).toISOString(),\n\t\ttime: Math.max(0, duration),\n\t\trequest: {\n\t\t\tmethod: pending.request.method,\n\t\t\turl: pending.request.url,\n\t\t\thttpVersion: response?.protocol ?? 'HTTP/0.0',\n\t\t\tcookies: [],\n\t\t\theaders: requestHeaders,\n\t\t\tqueryString: query,\n\t\t\t...(post !== undefined\n\t\t\t\t? {\n\t\t\t\t\t\tpostData: {\n\t\t\t\t\t\t\tmimeType: requestMime,\n\t\t\t\t\t\t\ttext: post,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\theadersSize: -1,\n\t\t\tbodySize: post === undefined ? 0 : textToBytes(post).byteLength,\n\t\t},\n\t\tresponse: {\n\t\t\tstatus: response?.status ?? 0,\n\t\t\tstatusText: response?.phrase ?? error ?? 'Request failed',\n\t\t\thttpVersion: response?.protocol ?? 'HTTP/0.0',\n\t\t\tcookies: [],\n\t\t\theaders: responseHeaders,\n\t\t\tcontent: {\n\t\t\t\tsize,\n\t\t\t\tmimeType: response?.mime ?? 'application/octet-stream',\n\t\t\t\t...(text !== undefined ? { text, encoding: 'base64' } : {}),\n\t\t\t},\n\t\t\tredirectURL: redirect,\n\t\t\theadersSize: -1,\n\t\t\tbodySize: size,\n\t\t},\n\t\tcache: {},\n\t\ttimings: {\n\t\t\tblocked: -1,\n\t\t\tdns,\n\t\t\tconnect,\n\t\t\tsend,\n\t\t\twait,\n\t\t\treceive: Math.max(0, duration - wait - send),\n\t\t\tssl,\n\t\t},\n\t}\n}\n\n/**\n * Converts HAR name/value headers into a Fetch-domain header record.\n *\n * @param headers - HAR header entries\n * @returns Header record with later duplicate names replacing earlier values\n */\nexport function browserHARHeadersToRecord(\n\theaders: readonly BrowserHARValue[],\n): Readonly<Record<string, string>> {\n\tconst result: Record<string, string> = {}\n\tfor (const header of headers) {\n\t\tObject.defineProperty(result, header.name, {\n\t\t\tvalue: header.value,\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\twritable: true,\n\t\t})\n\t}\n\treturn result\n}\n\n/**\n * Validates the HAR 1.2 fields required for deterministic replay.\n *\n * @param value - Candidate archive\n */\nexport function validateBrowserHAR(value: unknown): asserts value is BrowserHAR {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isRecord(value['log']) ||\n\t\tvalue['log']['version'] !== '1.2' ||\n\t\t!isRecord(value['log']['creator']) ||\n\t\t!isString(value['log']['creator']['name']) ||\n\t\t!isString(value['log']['creator']['version']) ||\n\t\t!isArray(value['log']['entries'])\n\t) {\n\t\tthrow new BrowserError('Browser HAR document is malformed')\n\t}\n\tfor (const [index, entry] of value['log']['entries'].entries()) {\n\t\tif (\n\t\t\t!isRecord(entry) ||\n\t\t\t!isString(entry['startedDateTime']) ||\n\t\t\t!isFiniteNumber(Date.parse(entry['startedDateTime'])) ||\n\t\t\t!isFiniteNumber(entry['time']) ||\n\t\t\tentry['time'] < 0 ||\n\t\t\t!isRecord(entry['request']) ||\n\t\t\t!isString(entry['request']['url']) ||\n\t\t\t!URL.canParse(entry['request']['url']) ||\n\t\t\t!isString(entry['request']['method']) ||\n\t\t\t!isString(entry['request']['httpVersion']) ||\n\t\t\t!isArray(entry['request']['cookies']) ||\n\t\t\t!isArray(entry['request']['headers']) ||\n\t\t\t!isArray(entry['request']['queryString']) ||\n\t\t\t!isInteger(entry['request']['headersSize']) ||\n\t\t\tentry['request']['headersSize'] < -1 ||\n\t\t\t!isInteger(entry['request']['bodySize']) ||\n\t\t\tentry['request']['bodySize'] < -1 ||\n\t\t\t!isRecord(entry['response']) ||\n\t\t\t!isInteger(entry['response']['status']) ||\n\t\t\tentry['response']['status'] < 0 ||\n\t\t\tentry['response']['status'] > 999 ||\n\t\t\t!isString(entry['response']['statusText']) ||\n\t\t\t!isString(entry['response']['httpVersion']) ||\n\t\t\t!isArray(entry['response']['cookies']) ||\n\t\t\t!isArray(entry['response']['headers']) ||\n\t\t\t!isRecord(entry['response']['content']) ||\n\t\t\t!isString(entry['response']['redirectURL']) ||\n\t\t\t!isInteger(entry['response']['headersSize']) ||\n\t\t\tentry['response']['headersSize'] < -1 ||\n\t\t\t!isInteger(entry['response']['bodySize']) ||\n\t\t\tentry['response']['bodySize'] < -1 ||\n\t\t\t!isRecord(entry['cache']) ||\n\t\t\t!isRecord(entry['timings'])\n\t\t) {\n\t\t\tthrow new BrowserError('Browser HAR entry is malformed', undefined, { index })\n\t\t}\n\t\tfor (const [cookieIndex, cookie] of entry['request']['cookies'].entries()) {\n\t\t\tif (\n\t\t\t\t!isRecord(cookie) ||\n\t\t\t\t!isString(cookie['name']) ||\n\t\t\t\t!isString(cookie['value']) ||\n\t\t\t\t(cookie['path'] !== undefined && !isString(cookie['path'])) ||\n\t\t\t\t(cookie['domain'] !== undefined && !isString(cookie['domain'])) ||\n\t\t\t\t(cookie['expires'] !== undefined && !isString(cookie['expires'])) ||\n\t\t\t\t(cookie['httpOnly'] !== undefined && !isBoolean(cookie['httpOnly'])) ||\n\t\t\t\t(cookie['secure'] !== undefined && !isBoolean(cookie['secure']))\n\t\t\t) {\n\t\t\t\tthrow new BrowserError('Browser HAR request cookie is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\tcookie: cookieIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tfor (const [headerIndex, header] of entry['request']['headers'].entries()) {\n\t\t\tif (!isRecord(header) || !isString(header['name']) || !isString(header['value'])) {\n\t\t\t\tthrow new BrowserError('Browser HAR request header is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\theader: headerIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tfor (const [queryIndex, query] of entry['request']['queryString'].entries()) {\n\t\t\tif (!isRecord(query) || !isString(query['name']) || !isString(query['value'])) {\n\t\t\t\tthrow new BrowserError('Browser HAR query value is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\tquery: queryIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tconst post = entry['request']['postData']\n\t\tif (\n\t\t\tpost !== undefined &&\n\t\t\t(!isRecord(post) || !isString(post['mimeType']) || !isString(post['text']))\n\t\t) {\n\t\t\tthrow new BrowserError('Browser HAR request body is malformed', undefined, { index })\n\t\t}\n\t\tfor (const [cookieIndex, cookie] of entry['response']['cookies'].entries()) {\n\t\t\tif (\n\t\t\t\t!isRecord(cookie) ||\n\t\t\t\t!isString(cookie['name']) ||\n\t\t\t\t!isString(cookie['value']) ||\n\t\t\t\t(cookie['path'] !== undefined && !isString(cookie['path'])) ||\n\t\t\t\t(cookie['domain'] !== undefined && !isString(cookie['domain'])) ||\n\t\t\t\t(cookie['expires'] !== undefined && !isString(cookie['expires'])) ||\n\t\t\t\t(cookie['httpOnly'] !== undefined && !isBoolean(cookie['httpOnly'])) ||\n\t\t\t\t(cookie['secure'] !== undefined && !isBoolean(cookie['secure']))\n\t\t\t) {\n\t\t\t\tthrow new BrowserError('Browser HAR response cookie is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\tcookie: cookieIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tfor (const [headerIndex, header] of entry['response']['headers'].entries()) {\n\t\t\tif (!isRecord(header) || !isString(header['name']) || !isString(header['value'])) {\n\t\t\t\tthrow new BrowserError('Browser HAR response header is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\theader: headerIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tconst text = entry['response']['content']['text']\n\t\tconst encoding = entry['response']['content']['encoding']\n\t\tif (\n\t\t\t!isInteger(entry['response']['content']['size']) ||\n\t\t\tentry['response']['content']['size'] < -1 ||\n\t\t\t!isString(entry['response']['content']['mimeType']) ||\n\t\t\t(text !== undefined && !isString(text)) ||\n\t\t\t(encoding !== undefined && encoding !== 'base64') ||\n\t\t\t(encoding === 'base64' &&\n\t\t\t\t(text === undefined ||\n\t\t\t\t\t!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(text)))\n\t\t) {\n\t\t\tthrow new BrowserError('Browser HAR response content is malformed', undefined, { index })\n\t\t}\n\t\tfor (const name of ['blocked', 'dns', 'connect', 'send', 'wait', 'receive', 'ssl']) {\n\t\t\tconst timing = entry['timings'][name]\n\t\t\tif (!isFiniteNumber(timing) || timing < -1) {\n\t\t\t\tthrow new BrowserError('Browser HAR timing is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\ttiming: name,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Matches a request against route criteria.\n *\n * @param request - Observed request\n * @param query - Match criteria\n * @returns True if every supplied criterion matches; false otherwise\n */\nexport function matchesBrowserRoute(request: BrowserRequest, query: BrowserRouteQuery): boolean {\n\tif (query.method !== undefined && request.method !== query.method) return false\n\tif (query.resource !== undefined && request.resource !== query.resource) return false\n\tif (query.url === undefined) return true\n\treturn matchesBrowserURL(request.url, query.url)\n}\n\n/**\n * Matches a URL using Chromium-style `*` and `**` glob segments.\n *\n * @param url - Candidate URL\n * @param pattern - Glob pattern\n * @returns True if the whole URL matches; false otherwise\n */\nexport function matchesBrowserURL(url: string, pattern: string): boolean {\n\tconst source = pattern\n\t\t.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\t\t.replace(/\\*\\*/g, '[[DOUBLE_STAR]]')\n\t\t.replace(/\\*/g, '[^/]*')\n\t\t.replace(/\\[\\[DOUBLE_STAR\\]\\]/g, '.*')\n\treturn new RegExp(`^${source}$`).test(url)\n}\n\n/**\n * Decodes the `Page.addScriptToEvaluateOnNewDocument` result, throwing a `BrowserError`\n * off-shape.\n *\n * @param value - Unknown protocol result\n * @returns Script identifier\n */\nexport function readBrowserScriptIdentifier(value: unknown): string {\n\tif (!isRecord(value) || !isString(value['identifier'])) {\n\t\tthrow new BrowserError('Browser init script identifier is malformed')\n\t}\n\treturn value['identifier']\n}\n\n/**\n * Validates viewport input coordinates.\n *\n * @param point - Candidate point\n */\nexport function validateBrowserPoint(point: BrowserPoint): void {\n\tif (!isFiniteNumber(point.x) || !isFiniteNumber(point.y)) {\n\t\tthrow new BrowserError('Browser input coordinates must be finite', undefined, { point })\n\t}\n}\n\n/**\n * Validates the bounded delay, count, and steps of one trusted-input operation.\n *\n * @remarks\n * The parameter is `BrowserOperationOptions`, so one validator answers for a\n * mouse click, a mouse drag, and keyboard entry alike.\n *\n * @param options - Candidate input options\n */\nexport function validateBrowserInputOptions(options?: BrowserOperationOptions): void {\n\tif (options?.delay !== undefined && (!isFiniteNumber(options.delay) || options.delay < 0)) {\n\t\tthrow new BrowserError('Browser input delay must be non-negative and finite', undefined, {\n\t\t\tdelay: options.delay,\n\t\t})\n\t}\n\tif (options?.count !== undefined && (!isInteger(options.count) || options.count <= 0)) {\n\t\tthrow new BrowserError('Browser click count must be a positive integer', undefined, {\n\t\t\tcount: options.count,\n\t\t})\n\t}\n\tif (options?.steps !== undefined && (!isInteger(options.steps) || options.steps <= 0)) {\n\t\tthrow new BrowserError('Browser drag steps must be a positive integer', undefined, {\n\t\t\tsteps: options.steps,\n\t\t})\n\t}\n}\n\n/**\n * Validates a public browser timeout before protocol work begins.\n *\n * @param timeout - Timeout in milliseconds\n */\nexport function validateBrowserTimeout(timeout: number): void {\n\tif (!isFiniteNumber(timeout) || timeout < 0) {\n\t\tthrow new BrowserError('Browser timeout must be a non-negative finite number', undefined, {\n\t\t\ttimeout,\n\t\t})\n\t}\n}\n\n/**\n * Validates Chromium viewport metrics.\n *\n * @param viewport - Public viewport configuration\n */\nexport function validateBrowserViewport(viewport: BrowserViewport): void {\n\tif (\n\t\t!isInteger(viewport.width) ||\n\t\tviewport.width <= 0 ||\n\t\t!isInteger(viewport.height) ||\n\t\tviewport.height <= 0\n\t) {\n\t\tthrow new BrowserError('Browser viewport dimensions must be positive integers', undefined, {\n\t\t\tviewport,\n\t\t})\n\t}\n\tif (viewport.scale !== undefined && (!isFiniteNumber(viewport.scale) || viewport.scale <= 0)) {\n\t\tthrow new BrowserError('Browser viewport scale must be positive and finite', undefined, {\n\t\t\tscale: viewport.scale,\n\t\t})\n\t}\n}\n\n/**\n * Validates context emulation boundaries before partial application.\n *\n * @param options - Public emulation configuration\n */\nexport function validateBrowserEmulationOptions(options: BrowserEmulationOptions): void {\n\tif (options.viewport !== undefined) validateBrowserViewport(options.viewport)\n\tif (options.user !== undefined && options.user.value.length === 0) {\n\t\tthrow new BrowserError('Browser user agent cannot be empty')\n\t}\n\tif (options.locale !== undefined && options.locale.length === 0) {\n\t\tthrow new BrowserError('Browser locale cannot be empty')\n\t}\n\tif (options.timezone !== undefined && options.timezone.length === 0) {\n\t\tthrow new BrowserError('Browser timezone cannot be empty')\n\t}\n\tif (options.geolocation !== undefined) {\n\t\tconst location = options.geolocation\n\t\tif (\n\t\t\t!isFiniteNumber(location.latitude) ||\n\t\t\tlocation.latitude < -90 ||\n\t\t\tlocation.latitude > 90 ||\n\t\t\t!isFiniteNumber(location.longitude) ||\n\t\t\tlocation.longitude < -180 ||\n\t\t\tlocation.longitude > 180 ||\n\t\t\t(location.accuracy !== undefined &&\n\t\t\t\t(!isFiniteNumber(location.accuracy) || location.accuracy < 0))\n\t\t) {\n\t\t\tthrow new BrowserError('Browser geolocation is outside valid coordinate bounds', undefined, {\n\t\t\t\tlocation,\n\t\t\t})\n\t\t}\n\t}\n\tfor (const name of Object.keys(options.headers ?? {})) {\n\t\tif (name.length === 0) throw new BrowserError('Browser header name cannot be empty')\n\t}\n}\n\n/**\n * Validates isolated-context options before creating remote state.\n *\n * @param options - Public context configuration\n */\nexport function validateBrowserContextOptions(options?: BrowserContextOptions): void {\n\tif (options === undefined) return\n\tif (options.emulation !== undefined) validateBrowserEmulationOptions(options.emulation)\n\tif (options.proxy !== undefined) {\n\t\tif (options.proxy.server.length === 0) {\n\t\t\tthrow new BrowserError('Browser proxy server cannot be empty')\n\t\t}\n\t\tif (options.proxy.bypass?.some((entry) => entry.length === 0) === true) {\n\t\t\tthrow new BrowserError('Browser proxy bypass entries cannot be empty')\n\t\t}\n\t}\n\tfor (const origin of options.origins ?? []) {\n\t\tconst result = attempt(() => new URL(origin))\n\t\tif (!result.success) {\n\t\t\tthrow new BrowserError('Browser context origin must be valid', undefined, { origin })\n\t\t}\n\t\tconst url = result.value\n\t\tif (\n\t\t\t(url.protocol !== 'http:' && url.protocol !== 'https:') ||\n\t\t\turl.origin !== origin.replace(/\\/$/, '')\n\t\t) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Browser context origin must be an absolute HTTP(S) origin',\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\torigin,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t}\n\tif (options.downloads !== undefined && options.downloads.path.length === 0) {\n\t\tthrow new BrowserError('Browser download path cannot be empty')\n\t}\n}\n\n/**\n * Validates Accessibility-domain snapshot bounds.\n *\n * @param options - Public accessibility snapshot options\n */\nexport function validateBrowserAccessibilityOptions(options?: BrowserAccessibilityOptions): void {\n\tif (options?.root !== undefined && (!isInteger(options.root) || options.root <= 0)) {\n\t\tthrow new BrowserError('Browser accessibility root must be a positive integer', undefined, {\n\t\t\troot: options.root,\n\t\t})\n\t}\n\tif (options?.depth !== undefined && (!isInteger(options.depth) || options.depth < 0)) {\n\t\tthrow new BrowserError(\n\t\t\t'Browser accessibility depth must be a non-negative integer',\n\t\t\tundefined,\n\t\t\t{ depth: options.depth },\n\t\t)\n\t}\n}\n\n/**\n * Validates and compiles Page.printToPDF parameters.\n *\n * @param options - Public PDF options\n * @returns Protocol parameter record\n */\nexport function browserPDFToParams(options?: BrowserPDFOptions): Readonly<Record<string, unknown>> {\n\tconst params: Record<string, unknown> = {\n\t\tlandscape: options?.landscape ?? false,\n\t\tprintBackground: options?.background ?? false,\n\t\tdisplayHeaderFooter: options?.header !== undefined || options?.footer !== undefined,\n\t\tgenerateTaggedPDF: options?.tagged ?? false,\n\t\tgenerateDocumentOutline: options?.outline ?? false,\n\t}\n\tif (options?.scale !== undefined) {\n\t\tvalidateBrowserRange(options.scale, 'PDF scale', 0.1, 2)\n\t\tparams['scale'] = options.scale\n\t}\n\tif (options?.width !== undefined) {\n\t\tvalidateBrowserRange(options.width, 'PDF width', 0, Number.MAX_VALUE, false)\n\t\tparams['paperWidth'] = options.width\n\t}\n\tif (options?.height !== undefined) {\n\t\tvalidateBrowserRange(options.height, 'PDF height', 0, Number.MAX_VALUE, false)\n\t\tparams['paperHeight'] = options.height\n\t}\n\tif (options?.ranges !== undefined) params['pageRanges'] = options.ranges\n\tif (options?.header !== undefined) params['headerTemplate'] = options.header\n\tif (options?.footer !== undefined) params['footerTemplate'] = options.footer\n\tfor (const [name, value] of Object.entries(options?.margin ?? {})) {\n\t\tif (!isFiniteNumber(value)) continue\n\t\tvalidateBrowserRange(value, `PDF ${name} margin`, 0, Number.MAX_VALUE)\n\t\tparams[`margin${name[0]?.toUpperCase()}${name.slice(1)}`] = value\n\t}\n\treturn params\n}\n\n/**\n * Validates and compiles basic Page.captureScreenshot parameters.\n *\n * @param options - Public screenshot options\n * @returns Protocol parameter record\n */\nexport function browserScreenshotToParams(\n\toptions?: BrowserScreenshotOptions,\n): Readonly<Record<string, unknown>> {\n\tconst format = options?.format ?? 'png'\n\tif (options?.quality !== undefined) {\n\t\tif (format !== 'jpeg') {\n\t\t\tthrow new BrowserError('Browser screenshot quality is only valid for JPEG')\n\t\t}\n\t\tif (!isInteger(options.quality) || options.quality < 0 || options.quality > 100) {\n\t\t\tthrow new BrowserError('Browser screenshot quality must be an integer from 0 to 100')\n\t\t}\n\t}\n\tif (options?.full === true && options.clip !== undefined) {\n\t\tthrow new BrowserError('Browser screenshot cannot combine full-page and clip capture')\n\t}\n\tconst params: Record<string, unknown> = {\n\t\tformat,\n\t\tfromSurface: true,\n\t}\n\tif (options?.quality !== undefined) params['quality'] = options.quality\n\tif (options?.clip !== undefined) {\n\t\tconst [x, y, width, height] = options.clip\n\t\tvalidateBrowserRange(x, 'Screenshot clip x', -Number.MAX_VALUE, Number.MAX_VALUE)\n\t\tvalidateBrowserRange(y, 'Screenshot clip y', -Number.MAX_VALUE, Number.MAX_VALUE)\n\t\tvalidateBrowserRange(width, 'Screenshot clip width', 0, Number.MAX_VALUE, false)\n\t\tvalidateBrowserRange(height, 'Screenshot clip height', 0, Number.MAX_VALUE, false)\n\t\tparams['clip'] = { x, y, width, height, scale: 1 }\n\t\tparams['captureBeyondViewport'] = true\n\t}\n\treturn params\n}\n\n/**\n * Validates a finite numeric range.\n *\n * @param value - Candidate number\n * @param field - Diagnostic field\n * @param minimum - Inclusive lower bound\n * @param maximum - Inclusive upper bound\n * @param inclusive - Whether the lower bound is inclusive\n */\nexport function validateBrowserRange(\n\tvalue: number,\n\tfield: string,\n\tminimum: number,\n\tmaximum: number,\n\tinclusive = true,\n): void {\n\tif (\n\t\t!isFiniteNumber(value) ||\n\t\t(inclusive ? value < minimum : value <= minimum) ||\n\t\tvalue > maximum\n\t) {\n\t\tthrow new BrowserError(`${field} is outside its valid range`, undefined, {\n\t\t\tvalue,\n\t\t\tminimum,\n\t\t\tmaximum,\n\t\t\tinclusive,\n\t\t})\n\t}\n}\n\n/**\n * Decodes Accessibility-domain nodes into a flat serializable tree, throwing a `BrowserError`\n * off-shape.\n *\n * @param value - Unknown full or partial AX-tree result\n * @returns Valid accessibility snapshot\n */\nexport function readBrowserAccessibility(value: unknown): BrowserAccessibilitySnapshot {\n\tif (!isRecord(value) || !isArray(value['nodes'])) {\n\t\tthrow new BrowserError('Browser accessibility tree is malformed')\n\t}\n\tconst nodes: BrowserAXNode[] = []\n\tfor (const [index, candidate] of value['nodes'].entries()) {\n\t\tif (!isRecord(candidate) || !isString(candidate['nodeId'])) {\n\t\t\tthrow new BrowserError('Browser accessibility node is malformed', undefined, { index })\n\t\t}\n\t\tconst children = isArray(candidate['childIds']) ? candidate['childIds'].filter(isString) : []\n\t\tconst properties: Record<string, unknown> = {}\n\t\tif (isArray(candidate['properties'])) {\n\t\t\tfor (const property of candidate['properties']) {\n\t\t\t\tif (!isRecord(property) || !isString(property['name'])) continue\n\t\t\t\tproperties[property['name']] = readBrowserAXValue(property['value'])\n\t\t\t}\n\t\t}\n\t\tnodes.push({\n\t\t\tid: candidate['nodeId'],\n\t\t\tparent: isString(candidate['parentId']) ? candidate['parentId'] : undefined,\n\t\t\tchildren,\n\t\t\tbackend: isInteger(candidate['backendDOMNodeId']) ? candidate['backendDOMNodeId'] : undefined,\n\t\t\tframe: isString(candidate['frameId']) ? candidate['frameId'] : undefined,\n\t\t\tignored: candidate['ignored'] === true,\n\t\t\trole: parseBrowserAXString(candidate['role']),\n\t\t\tname: parseBrowserAXString(candidate['name']),\n\t\t\tdescription: parseBrowserAXString(candidate['description']),\n\t\t\tvalue: readBrowserAXValue(candidate['value']),\n\t\t\tproperties,\n\t\t})\n\t}\n\treturn {\n\t\troots: nodes.filter((node) => node.parent === undefined).map((node) => node.id),\n\t\tnodes,\n\t}\n}\n\n/**\n * Decodes an Accessibility-domain AXValue, or `undefined` when the record carries none.\n *\n * @param value - Unknown AX value\n * @returns Underlying value\n */\nexport function readBrowserAXValue(value: unknown): unknown {\n\treturn isRecord(value) && 'value' in value ? value['value'] : undefined\n}\n\n/**\n * Concatenates byte chunks without Node-specific buffers.\n *\n * @param chunks - Byte arrays in source order\n * @returns Combined bytes\n */\nexport function concatBytes(chunks: readonly Uint8Array[]): Uint8Array {\n\tconst count = chunks.reduce((total, chunk) => total + chunk.byteLength, 0)\n\tconst result = new Uint8Array(count)\n\tlet offset = 0\n\tfor (const chunk of chunks) {\n\t\tresult.set(chunk, offset)\n\t\toffset += chunk.byteLength\n\t}\n\treturn result\n}\n\n/**\n * Decodes one `IO.read` response, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown protocol result\n * @returns Valid stream chunk\n */\nexport function readBrowserStreamChunk(value: unknown): BrowserStreamChunk {\n\tif (!isRecord(value) || !isString(value['data'])) {\n\t\tthrow new BrowserError('Browser IO stream chunk is malformed')\n\t}\n\treturn {\n\t\tbytes:\n\t\t\tvalue['base64Encoded'] === true ? decodeBase64(value['data']) : textToBytes(value['data']),\n\t\teof: value['eof'] === true,\n\t}\n}\n\n/**\n * Decodes JavaScript precise coverage, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown `Profiler.takePreciseCoverage` result\n * @returns Script coverage\n */\nexport function readBrowserScriptCoverage(value: unknown): readonly BrowserScriptCoverage[] {\n\tif (!isRecord(value) || !isArray(value['result'])) {\n\t\tthrow new BrowserError('Browser JavaScript coverage is malformed')\n\t}\n\treturn value['result'].map((script, index) => {\n\t\tif (\n\t\t\t!isRecord(script) ||\n\t\t\t!isString(script['scriptId']) ||\n\t\t\t!isString(script['url']) ||\n\t\t\t!isArray(script['functions'])\n\t\t) {\n\t\t\tthrow new BrowserError('Browser script coverage entry is malformed', undefined, { index })\n\t\t}\n\t\tconst functions: BrowserFunctionCoverage[] = script['functions'].map((entry, functionIndex) => {\n\t\t\tif (!isRecord(entry) || !isString(entry['functionName']) || !isArray(entry['ranges'])) {\n\t\t\t\tthrow new BrowserError('Browser function coverage entry is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\tfunction: functionIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tname: entry['functionName'],\n\t\t\t\tranges: readBrowserCoverageRanges(entry['ranges'], index),\n\t\t\t\tblock: entry['isBlockCoverage'] === true,\n\t\t\t}\n\t\t})\n\t\treturn {\n\t\t\tid: script['scriptId'],\n\t\t\turl: script['url'],\n\t\t\tfunctions,\n\t\t}\n\t})\n}\n\n/**\n * Decodes CSS rule usage, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown `CSS.stopRuleUsageTracking` result\n * @returns Stylesheet coverage\n */\nexport function readBrowserStyleCoverage(value: unknown): readonly BrowserStyleCoverage[] {\n\tif (!isRecord(value) || !isArray(value['ruleUsage'])) {\n\t\tthrow new BrowserError('Browser CSS coverage is malformed')\n\t}\n\tconst styles = new Map<string, BrowserCoverageRange[]>()\n\tfor (const [index, entry] of value['ruleUsage'].entries()) {\n\t\tif (\n\t\t\t!isRecord(entry) ||\n\t\t\t!isString(entry['styleSheetId']) ||\n\t\t\t!isInteger(entry['startOffset']) ||\n\t\t\tentry['startOffset'] < 0 ||\n\t\t\t!isInteger(entry['endOffset']) ||\n\t\t\tentry['endOffset'] < entry['startOffset']\n\t\t) {\n\t\t\tthrow new BrowserError('Browser CSS coverage entry is malformed', undefined, { index })\n\t\t}\n\t\tconst ranges = styles.get(entry['styleSheetId']) ?? []\n\t\tranges.push({\n\t\t\tstart: entry['startOffset'],\n\t\t\tend: entry['endOffset'],\n\t\t\tcount: entry['used'] === true ? 1 : 0,\n\t\t})\n\t\tstyles.set(entry['styleSheetId'], ranges)\n\t}\n\treturn [...styles].map(([id, ranges]) => ({ id, ranges }))\n}\n\n/**\n * Decodes and normalizes coverage ranges, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown ranges\n * @param script - Script index for diagnostics\n * @returns Valid ranges\n */\nexport function readBrowserCoverageRanges(\n\tvalue: unknown,\n\tscript: number,\n): readonly BrowserCoverageRange[] {\n\tif (!isArray(value)) {\n\t\tthrow new BrowserError('Browser coverage ranges are malformed', undefined, { script })\n\t}\n\treturn value.map((range, index) => {\n\t\tif (\n\t\t\t!isRecord(range) ||\n\t\t\t!isInteger(range['startOffset']) ||\n\t\t\trange['startOffset'] < 0 ||\n\t\t\t!isInteger(range['endOffset']) ||\n\t\t\trange['endOffset'] < range['startOffset'] ||\n\t\t\t!isInteger(range['count']) ||\n\t\t\trange['count'] < 0\n\t\t) {\n\t\t\tthrow new BrowserError('Browser coverage range is malformed', undefined, {\n\t\t\t\tscript,\n\t\t\t\tindex,\n\t\t\t})\n\t\t}\n\t\treturn {\n\t\t\tstart: range['startOffset'],\n\t\t\tend: range['endOffset'],\n\t\t\tcount: range['count'],\n\t\t}\n\t})\n}\n\n/**\n * Decodes Performance-domain metrics, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown metrics result\n * @returns Valid metrics\n */\nexport function readBrowserMetrics(value: unknown): readonly BrowserMetric[] {\n\tif (!isRecord(value) || !isArray(value['metrics'])) {\n\t\tthrow new BrowserError('Browser performance metrics are malformed')\n\t}\n\treturn value['metrics'].map((metric, index) => {\n\t\tif (!isRecord(metric) || !isString(metric['name']) || !isFiniteNumber(metric['value'])) {\n\t\t\tthrow new BrowserError('Browser performance metric is malformed', undefined, { index })\n\t\t}\n\t\treturn { name: metric['name'], value: metric['value'] }\n\t})\n}\n\n/**\n * Decodes one CPU profile, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown `Profiler.stop` result\n * @returns Valid profile\n */\nexport function readBrowserProfile(value: unknown): BrowserProfile {\n\tif (!isRecord(value) || !isRecord(value['profile'])) {\n\t\tthrow new BrowserError('Browser CPU profile is malformed')\n\t}\n\tconst profile = value['profile']\n\tif (\n\t\t!isFiniteNumber(profile['startTime']) ||\n\t\t!isFiniteNumber(profile['endTime']) ||\n\t\tprofile['endTime'] < profile['startTime'] ||\n\t\t!isArray(profile['nodes'])\n\t) {\n\t\tthrow new BrowserError('Browser CPU profile metadata is malformed')\n\t}\n\tconst nodes: BrowserProfileNode[] = profile['nodes'].map((node, index) => {\n\t\tif (\n\t\t\t!isRecord(node) ||\n\t\t\t!isInteger(node['id']) ||\n\t\t\tnode['id'] < 0 ||\n\t\t\t(node['hitCount'] !== undefined && (!isInteger(node['hitCount']) || node['hitCount'] < 0))\n\t\t) {\n\t\t\tthrow new BrowserError('Browser CPU profile node is malformed', undefined, { index })\n\t\t}\n\t\tconst children = node['children'] === undefined ? [] : parseArray(node['children'], isInteger)\n\t\tif (children === undefined || children.some((child) => child < 0)) {\n\t\t\tthrow new BrowserError('Browser CPU profile node is malformed', undefined, { index })\n\t\t}\n\t\treturn {\n\t\t\tid: node['id'],\n\t\t\tframe: readBrowserProfileFrame(node['callFrame'], index),\n\t\t\thit: isInteger(node['hitCount']) ? node['hitCount'] : undefined,\n\t\t\tchildren,\n\t\t}\n\t})\n\tconst samples = profile['samples'] === undefined ? [] : parseArray(profile['samples'], isInteger)\n\tif (samples === undefined || samples.some((sample) => sample < 0)) {\n\t\tthrow new BrowserError('Browser CPU profile samples are malformed')\n\t}\n\tconst deltas =\n\t\tprofile['timeDeltas'] === undefined ? [] : parseArray(profile['timeDeltas'], isFiniteNumber)\n\tif (deltas === undefined || deltas.some((delta) => delta < 0)) {\n\t\tthrow new BrowserError('Browser CPU profile deltas are malformed')\n\t}\n\treturn {\n\t\tstart: profile['startTime'],\n\t\tend: profile['endTime'],\n\t\tnodes,\n\t\tsamples,\n\t\tdeltas,\n\t}\n}\n\n/**\n * Decodes a CPU profile call frame, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown call frame\n * @param node - Node index for diagnostics\n * @returns Valid call frame\n */\nexport function readBrowserProfileFrame(value: unknown, node: number): BrowserProfileFrame {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['functionName']) ||\n\t\t!isString(value['scriptId']) ||\n\t\t!isString(value['url']) ||\n\t\t!isInteger(value['lineNumber']) ||\n\t\t!isInteger(value['columnNumber'])\n\t) {\n\t\tthrow new BrowserError('Browser CPU profile call frame is malformed', undefined, { node })\n\t}\n\treturn {\n\t\tfunction: value['functionName'],\n\t\tscript: value['scriptId'],\n\t\turl: value['url'],\n\t\tline: value['lineNumber'],\n\t\tcolumn: value['columnNumber'],\n\t}\n}\n\n/**\n * Converts a typed cookie input into Chromium protocol fields.\n *\n * @param cookie - Validated public cookie input\n * @returns Protocol cookie record\n */\nexport function cookieToProtocol(cookie: BrowserCookieInput): Readonly<Record<string, unknown>> {\n\tif (cookie.name.length === 0) throw new BrowserError('Browser cookie name cannot be empty')\n\tif (cookie.url === undefined && (cookie.domain === undefined || cookie.path === undefined)) {\n\t\tthrow new BrowserError('Browser cookie requires either url or domain with path', undefined, {\n\t\t\tname: cookie.name,\n\t\t})\n\t}\n\tif (cookie.url !== undefined && !URL.canParse(cookie.url)) {\n\t\tthrow new BrowserError('Browser cookie URL must be valid', undefined, {\n\t\t\tname: cookie.name,\n\t\t\turl: cookie.url,\n\t\t})\n\t}\n\tif (cookie.expires !== undefined && !isFiniteNumber(cookie.expires)) {\n\t\tthrow new BrowserError('Browser cookie expiry must be finite', undefined, {\n\t\t\tname: cookie.name,\n\t\t\texpires: cookie.expires,\n\t\t})\n\t}\n\tconst result: Record<string, unknown> = {\n\t\tname: cookie.name,\n\t\tvalue: cookie.value,\n\t}\n\tif (cookie.url !== undefined) result['url'] = cookie.url\n\tif (cookie.domain !== undefined) result['domain'] = cookie.domain\n\tif (cookie.path !== undefined) result['path'] = cookie.path\n\tif (cookie.expires !== undefined) result['expires'] = cookie.expires\n\tif (cookie.http !== undefined) result['httpOnly'] = cookie.http\n\tif (cookie.secure !== undefined) result['secure'] = cookie.secure\n\tif (cookie.site !== undefined) result['sameSite'] = cookie.site\n\tif (cookie.priority !== undefined) result['priority'] = cookie.priority\n\tif (cookie.partition !== undefined) {\n\t\tresult['partitionKey'] = {\n\t\t\ttopLevelSite: cookie.partition.site,\n\t\t\thasCrossSiteAncestor: cookie.partition.ancestor ?? false,\n\t\t}\n\t}\n\treturn result\n}\n\n/**\n * Decodes the cookies `Storage.getCookies` returns, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown protocol result\n * @returns Valid cookies\n */\nexport function readBrowserCookies(value: unknown): readonly BrowserCookie[] {\n\tif (!isRecord(value) || !isArray(value['cookies'])) {\n\t\tthrow new BrowserError('Browser cookie result is malformed')\n\t}\n\treturn value['cookies'].map((candidate, index) => readBrowserCookie(candidate, index))\n}\n\n/**\n * Decodes one Chromium cookie, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown cookie record\n * @param index - Source array position for diagnostics\n * @returns Valid cookie\n */\nexport function readBrowserCookie(value: unknown, index: number): BrowserCookie {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['name']) ||\n\t\t!isString(value['value']) ||\n\t\t!isString(value['domain']) ||\n\t\t!isString(value['path']) ||\n\t\t!isFiniteNumber(value['expires']) ||\n\t\t!isBoolean(value['httpOnly']) ||\n\t\t!isBoolean(value['secure'])\n\t) {\n\t\tthrow new BrowserError('Browser cookie is malformed', undefined, { index })\n\t}\n\tconst sameSite = parseEnum(value['sameSite'], ['Strict', 'Lax', 'None'])\n\tif (value['sameSite'] !== undefined && sameSite === undefined) {\n\t\tthrow new BrowserError('Browser cookie same-site policy is malformed', undefined, { index })\n\t}\n\treturn {\n\t\tname: value['name'],\n\t\tvalue: value['value'],\n\t\tdomain: value['domain'],\n\t\tpath: value['path'],\n\t\texpires: value['expires'],\n\t\thttp: value['httpOnly'],\n\t\tsecure: value['secure'],\n\t\tsite: sameSite,\n\t\tpartition: parseBrowserCookiePartition(value['partitionKey']),\n\t}\n}\n\n/**\n * Matches a decoded cookie against one request URL.\n *\n * @param cookie - Decoded context cookie\n * @param value - Candidate absolute URL\n * @returns True if domain, path, and secure constraints match; false otherwise\n */\nexport function matchesBrowserCookieURL(cookie: BrowserCookie, value: string): boolean {\n\tconst result = attempt(() => new URL(value))\n\tif (!result.success) {\n\t\tthrow new BrowserError('Browser cookie URL must be valid', undefined, { url: value })\n\t}\n\tconst url = result.value\n\tconst domain = cookie.domain.startsWith('.') ? cookie.domain.slice(1) : cookie.domain\n\tconst domainMatches = url.hostname === domain || url.hostname.endsWith(`.${domain}`)\n\tconst pathMatches =\n\t\turl.pathname === cookie.path ||\n\t\t(url.pathname.startsWith(cookie.path) &&\n\t\t\t(cookie.path.endsWith('/') || url.pathname[cookie.path.length] === '/'))\n\tconst secureMatches = !cookie.secure || url.protocol === 'https:' || url.protocol === 'wss:'\n\treturn domainMatches && pathMatches && secureMatches\n}\n\n/**\n * Decodes one in-page web-storage snapshot, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown evaluation result\n * @param origin - Origin represented by the result\n * @returns Valid origin storage\n */\nexport function readBrowserStorageOrigin(value: unknown, origin: string): BrowserStorageOrigin {\n\tif (!isRecord(value))\n\t\tthrow new BrowserError('Browser storage result is malformed', undefined, { origin })\n\treturn {\n\t\torigin,\n\t\tlocal: readBrowserStorageEntries(value['local'], origin, 'local'),\n\t\tsession: readBrowserStorageEntries(value['session'], origin, 'session'),\n\t}\n}\n\n/**\n * Decodes a list of web-storage entries, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown entry list\n * @param origin - Origin used for diagnostics\n * @param storage - Storage family used for diagnostics\n * @returns Valid key/value entries\n */\nexport function readBrowserStorageEntries(\n\tvalue: unknown,\n\torigin: string,\n\tstorage: 'local' | 'session',\n): readonly BrowserStorageEntry[] {\n\tif (!isArray(value)) {\n\t\tthrow new BrowserError('Browser storage entries are malformed', undefined, { origin, storage })\n\t}\n\treturn value.map((entry, index) => {\n\t\tif (!isRecord(entry) || !isString(entry['name']) || !isString(entry['value'])) {\n\t\t\tthrow new BrowserError('Browser storage entry is malformed', undefined, {\n\t\t\t\torigin,\n\t\t\t\tstorage,\n\t\t\t\tindex,\n\t\t\t})\n\t\t}\n\t\treturn { name: entry['name'], value: entry['value'] }\n\t})\n}\n\n/**\n * Converts typed media preferences to Chromium emulated media features.\n *\n * @param media - Public media configuration\n * @returns Protocol feature records\n */\nexport function mediaToFeatures(\n\tmedia: BrowserMedia,\n): ReadonlyArray<Readonly<Record<string, string>>> {\n\tconst features: Array<Readonly<Record<string, string>>> = []\n\tif (media.scheme !== undefined) {\n\t\tfeatures.push({ name: 'prefers-color-scheme', value: media.scheme })\n\t}\n\tif (media.contrast !== undefined) {\n\t\tfeatures.push({ name: 'prefers-contrast', value: media.contrast })\n\t}\n\tif (media.motion !== undefined) {\n\t\tfeatures.push({ name: 'prefers-reduced-motion', value: media.motion })\n\t}\n\tif (media.colors !== undefined) {\n\t\tfeatures.push({ name: 'forced-colors', value: media.colors })\n\t}\n\treturn features\n}\n\n/**\n * Decodes a Chromium runtime stack trace, skipping every off-shape call frame.\n *\n * @param value - Unknown stack trace or call-frame list\n * @returns Valid stack frames\n */\nexport function readBrowserStack(value: unknown): readonly BrowserStackFrame[] {\n\tconst frames = isRecord(value) ? value['callFrames'] : value\n\tif (!isArray(frames)) return []\n\tconst stack: BrowserStackFrame[] = []\n\tfor (const frame of frames) {\n\t\tif (\n\t\t\t!isRecord(frame) ||\n\t\t\t!isString(frame['url']) ||\n\t\t\t!isString(frame['functionName']) ||\n\t\t\t!isInteger(frame['lineNumber']) ||\n\t\t\t!isInteger(frame['columnNumber'])\n\t\t) {\n\t\t\tcontinue\n\t\t}\n\t\tstack.push({\n\t\t\turl: frame['url'],\n\t\t\tfunction: frame['functionName'],\n\t\t\tline: frame['lineNumber'],\n\t\t\tcolumn: frame['columnNumber'],\n\t\t})\n\t}\n\treturn stack\n}\n\n/**\n * Decodes a Runtime remote object's printable value, falling back to its unserializable form\n * and then its description, or `undefined` when it carries none.\n *\n * @param value - Unknown remote object\n * @returns By-value data or a description\n */\nexport function readBrowserRemoteValue(value: unknown): unknown {\n\tif (!isRecord(value)) return undefined\n\tif ('value' in value) return value['value']\n\tif (isString(value['unserializableValue'])) return value['unserializableValue']\n\tif (isString(value['description'])) return value['description']\n\treturn undefined\n}\n\n/**\n * Decodes one CDP `Runtime.evaluate` result, throwing a `BrowserError` on a failed evaluation\n * and a `BrowserResultLimitError` past the guarded result size.\n *\n * @param value - Unknown CDP result\n * @returns The returned by-value payload, or undefined\n */\nexport function readEvaluationResult(value: unknown): unknown {\n\tif (!isRecord(value)) return undefined\n\n\tif (isRecord(value['exceptionDetails'])) {\n\t\tconst details = value['exceptionDetails']\n\t\tif (isRecord(details['exception']) && isString(details['exception']['description'])) {\n\t\t\tconst description = details['exception']['description']\n\t\t\tconst limitMatch = BROWSER_RESULT_LIMIT_PATTERN.exec(description)\n\t\t\tif (limitMatch !== null) {\n\t\t\t\tthrow new BrowserResultLimitError('Evaluation result exceeds BROWSER_RESULT_LIMIT', {\n\t\t\t\t\tlength: Number(limitMatch[1]),\n\t\t\t\t\tlimit: BROWSER_RESULT_LIMIT,\n\t\t\t\t})\n\t\t\t}\n\t\t\tthrow new BrowserError(description)\n\t\t}\n\t\tthrow new BrowserError('JavaScript evaluation failed')\n\t}\n\n\tconst remoteObject = value['result']\n\tif (!isRecord(remoteObject)) return undefined\n\treturn 'value' in remoteObject ? remoteObject['value'] : undefined\n}\n\n/**\n * Requires an evaluated browser value to be a string.\n *\n * @param value - Candidate evaluated value\n * @param field - Human-readable field name used in the error\n * @returns The narrowed string\n */\nexport function requireBrowserString(value: unknown, field: string): string {\n\tif (isString(value)) return value\n\tthrow new BrowserError(`${field} failed: no string value returned`)\n}\n\n/**\n * Reads the execution context id from a CDP `Page.createIsolatedWorld` reply.\n *\n * @param value - Unknown CDP result\n * @param frame - The frame id the world was created for, which the error context names\n * @returns The execution context id of the created world\n * @throws Thrown when the reply carries no integer `executionContextId`.\n */\nexport function readBrowserWorld(value: unknown, frame: string): number {\n\tif (isRecord(value) && isInteger(value['executionContextId'])) {\n\t\treturn value['executionContextId']\n\t}\n\tthrow new BrowserError('Failed to create frame execution context', undefined, { frame })\n}\n\n/**\n * Extracts one bounded slice of a projected text, cutting after a line break where one fits.\n *\n * @remarks\n * `offset` and `limit` count UTF-16 code units. A slice whose window reaches the end of the text\n * holds the rest of it. Otherwise the slice ends after the last line break inside\n * `offset` to `offset + limit` that lies past `offset`, and at `offset + limit` when none does. A\n * hard cut that would end on the high half of a surrogate pair ends one unit earlier, so a limit\n * of 1 before a pair yields an empty slice rather than a lone surrogate. An `offset` at or past\n * the end yields an empty slice.\n *\n * @param text - The whole projection\n * @param offset - The index the slice starts at. Default: `0`\n * @param limit - The most characters the slice holds. Default: unbounded\n * @returns The slice, its start, and the length of the whole text\n * @throws Thrown when `offset` is not a non-negative integer or `limit` is not a positive integer.\n *\n * @example\n * ```ts\n * import { extractBrowserSlice } from '@orkestrel/browser'\n *\n * extractBrowserSlice('alpha\\nbeta\\ngamma', 0, 12) // { text: 'alpha\\nbeta\\n', offset: 0, total: 16 }\n * ```\n */\nexport function extractBrowserSlice(text: string, offset = 0, limit?: number): BrowserReadResult {\n\tif (!isInteger(offset) || offset < 0) {\n\t\tthrow new BrowserError('Browser read offset must be a non-negative integer', undefined, {\n\t\t\toffset,\n\t\t})\n\t}\n\tif (limit !== undefined && (!isInteger(limit) || limit < 1)) {\n\t\tthrow new BrowserError('Browser read limit must be a positive integer', undefined, { limit })\n\t}\n\tconst total = text.length\n\tif (limit === undefined || offset + limit >= total) {\n\t\treturn { text: text.slice(offset), offset, total }\n\t}\n\tconst window = text.slice(offset, offset + limit)\n\tconst line = window.lastIndexOf('\\n')\n\tif (line > 0) return { text: window.slice(0, line + 1), offset, total }\n\tconst last = window.charCodeAt(limit - 1)\n\tconst next = text.charCodeAt(offset + limit)\n\tconst split = last >= 0xd800 && last <= 0xdbff && next >= 0xdc00 && next <= 0xdfff\n\treturn { text: split ? window.slice(0, -1) : window, offset, total }\n}\n\n/**\n * Decodes a flattened CDP `Page.getFrameTree` result into depth-first frame metadata, skipping\n * every off-shape frame, then appends each attached out-of-process iframe target the tree does\n * not list.\n *\n * @param value - Unknown CDP result\n * @param targets - Attached iframe targets, each described as a frame\n * @returns Frame metadata in depth-first, main-frame-first order, then the unlisted targets\n */\nexport function readBrowserFrames(\n\tvalue: unknown,\n\ttargets: readonly BrowserFrameInfo[] = [],\n): readonly BrowserFrameInfo[] {\n\tconst frames: BrowserFrameInfo[] = []\n\tconst stack: Array<Readonly<Record<string, unknown>>> =\n\t\tisRecord(value) && isRecord(value['frameTree']) ? [value['frameTree']] : []\n\n\twhile (stack.length > 0) {\n\t\tconst node = stack.pop()\n\t\tif (node === undefined) break\n\t\tconst frame = node['frame']\n\n\t\tif (isRecord(frame) && isString(frame['id']) && isString(frame['url'])) {\n\t\t\tframes.push({\n\t\t\t\tid: frame['id'],\n\t\t\t\tparent: isString(frame['parentId']) ? frame['parentId'] : undefined,\n\t\t\t\tname: isString(frame['name']) && frame['name'] !== '' ? frame['name'] : undefined,\n\t\t\t\turl: frame['url'],\n\t\t\t})\n\t\t}\n\n\t\tconst children = node['childFrames']\n\t\tif (!isArray(children)) continue\n\t\tfor (let index = children.length - 1; index >= 0; index -= 1) {\n\t\t\tconst child = children[index]\n\t\t\tif (isRecord(child)) stack.push(child)\n\t\t}\n\t}\n\n\tfor (const target of targets) {\n\t\tif (!frames.some((frame) => frame.id === target.id)) frames.push(target)\n\t}\n\treturn frames\n}\n\n/**\n * Decodes the first `DOM.getContentQuads` quad and its center, throwing a `BrowserError`\n * off-shape.\n *\n * @param value - Unknown CDP result\n * @returns Decoded quad\n */\nexport function readBrowserQuad(value: unknown): BrowserQuad {\n\tif (!isRecord(value) || !isArray(value['quads'])) {\n\t\tthrow new BrowserError('Element has no content quad')\n\t}\n\tconst points = parseNumberArray(value['quads'][0])\n\tif (points === undefined || points.length !== 8) {\n\t\tthrow new BrowserError('Element has a malformed content quad')\n\t}\n\tconst x1 = points[0]\n\tconst y1 = points[1]\n\tconst x2 = points[2]\n\tconst y2 = points[3]\n\tconst x3 = points[4]\n\tconst y3 = points[5]\n\tconst x4 = points[6]\n\tconst y4 = points[7]\n\tif (\n\t\tx1 === undefined ||\n\t\ty1 === undefined ||\n\t\tx2 === undefined ||\n\t\ty2 === undefined ||\n\t\tx3 === undefined ||\n\t\ty3 === undefined ||\n\t\tx4 === undefined ||\n\t\ty4 === undefined\n\t) {\n\t\tthrow new BrowserError('Element has a malformed content quad')\n\t}\n\treturn {\n\t\tpoints: [x1, y1, x2, y2, x3, y3, x4, y4],\n\t\tcenter: {\n\t\t\tx: (x1 + x2 + x3 + x4) / 4,\n\t\t\ty: (y1 + y2 + y3 + y4) / 4,\n\t\t},\n\t}\n}\n\n/**\n * Extracts a keyboard chord such as `Control+Shift+P` into its parts, throwing a\n * `BrowserError` on an empty chord or an unsupported modifier.\n *\n * @param value - Chord source\n * @returns Canonical modifiers and terminal key\n * @throws Thrown when the chord is empty or names an unsupported modifier.\n */\nexport function extractBrowserChord(value: string): BrowserChord {\n\tconst parts = value.split('+').filter((part) => part.length > 0)\n\tconst key = parts.pop()\n\tif (key === undefined) throw new BrowserError('Browser key chord is empty')\n\tconst modifiers = parts.map((modifier) => {\n\t\tswitch (modifier) {\n\t\t\tcase 'Ctrl':\n\t\t\t\treturn 'Control'\n\t\t\tcase 'Cmd':\n\t\t\tcase 'Command':\n\t\t\t\treturn 'Meta'\n\t\t\tdefault:\n\t\t\t\treturn modifier\n\t\t}\n\t})\n\tfor (const modifier of modifiers) {\n\t\tif (BROWSER_KEY_MODIFIERS[modifier] === undefined) {\n\t\t\tthrow new BrowserError(`Unsupported browser key modifier: ${modifier}`)\n\t\t}\n\t}\n\treturn { modifiers, key }\n}\n\n/**\n * Computes the CDP Input modifier bitmask.\n *\n * @param modifiers - Canonical modifier names\n * @returns Combined CDP modifier mask\n */\nexport function computeBrowserModifiers(modifiers: readonly string[]): number {\n\tlet mask = 0\n\tfor (const modifier of modifiers) mask |= BROWSER_KEY_MODIFIERS[modifier] ?? 0\n\treturn mask\n}\n\n/**\n * Computes the CDP Input pressed-button bitmask.\n *\n * @param buttons - Pressed public mouse buttons\n * @returns Combined CDP pressed-button mask\n */\nexport function computeBrowserButtons(buttons: readonly BrowserMouseButton[]): number {\n\tlet mask = 0\n\tfor (const button of buttons) mask |= BROWSER_MOUSE_BUTTON_MASKS[button]\n\treturn mask\n}\n\n/**\n * Normalizes one key to CDP keyboard event data.\n *\n * @param value - Key value or canonical key name\n * @returns Normalized key data\n */\nexport function keyToBrowserInput(value: string): BrowserKey {\n\tconst named: Readonly<Record<string, BrowserKey>> = {\n\t\tBackspace: { key: 'Backspace', code: 'Backspace', text: undefined, number: 8 },\n\t\tTab: { key: 'Tab', code: 'Tab', text: '\\t', number: 9 },\n\t\tEnter: { key: 'Enter', code: 'Enter', text: '\\r', number: 13 },\n\t\tShift: { key: 'Shift', code: 'ShiftLeft', text: undefined, number: 16 },\n\t\tControl: { key: 'Control', code: 'ControlLeft', text: undefined, number: 17 },\n\t\tAlt: { key: 'Alt', code: 'AltLeft', text: undefined, number: 18 },\n\t\tEscape: { key: 'Escape', code: 'Escape', text: undefined, number: 27 },\n\t\tSpace: { key: ' ', code: 'Space', text: ' ', number: 32 },\n\t\tPageUp: { key: 'PageUp', code: 'PageUp', text: undefined, number: 33 },\n\t\tPageDown: { key: 'PageDown', code: 'PageDown', text: undefined, number: 34 },\n\t\tEnd: { key: 'End', code: 'End', text: undefined, number: 35 },\n\t\tHome: { key: 'Home', code: 'Home', text: undefined, number: 36 },\n\t\tArrowLeft: { key: 'ArrowLeft', code: 'ArrowLeft', text: undefined, number: 37 },\n\t\tArrowUp: { key: 'ArrowUp', code: 'ArrowUp', text: undefined, number: 38 },\n\t\tArrowRight: { key: 'ArrowRight', code: 'ArrowRight', text: undefined, number: 39 },\n\t\tArrowDown: { key: 'ArrowDown', code: 'ArrowDown', text: undefined, number: 40 },\n\t\tDelete: { key: 'Delete', code: 'Delete', text: undefined, number: 46 },\n\t\tMeta: { key: 'Meta', code: 'MetaLeft', text: undefined, number: 91 },\n\t}\n\tconst matched = named[value]\n\tif (matched !== undefined) return matched\n\tif ([...value].length !== 1) throw new BrowserError(`Unsupported browser key: ${value}`)\n\tconst character = [...value][0]\n\tif (character === undefined) throw new BrowserError('Browser key is empty')\n\tconst upper = character.toUpperCase()\n\tconst letter = /^[A-Z]$/.test(upper)\n\tconst digit = /^[0-9]$/.test(character)\n\treturn {\n\t\tkey: character,\n\t\tcode: letter ? `Key${upper}` : digit ? `Digit${character}` : '',\n\t\ttext: character,\n\t\tnumber: upper.charCodeAt(0),\n\t}\n}\n\n/**\n * Decodes CDP snapshot sparse string data into a node-index map, skipping every off-shape\n * entry.\n *\n * @param value - Sparse `{ index, value }` record\n * @param strings - Snapshot string table\n * @returns Node-index to string map\n */\nexport function readRareStringData(\n\tvalue: unknown,\n\tstrings: readonly string[],\n): ReadonlyMap<number, string> {\n\tconst decoded = new Map<number, string>()\n\tif (!isRecord(value)) return decoded\n\tconst indexes = parseNumberArray(value['index'])\n\tconst values = parseNumberArray(value['value'])\n\tif (indexes === undefined || values === undefined) return decoded\n\n\tfor (let index = 0; index < indexes.length; index += 1) {\n\t\tconst node = indexes[index]\n\t\tconst text = parseSnapshotString(strings, values[index])\n\t\tif (node !== undefined && text !== undefined) decoded.set(node, text)\n\t}\n\treturn decoded\n}\n\n/**\n * Decodes CDP snapshot sparse boolean data into a set of node indexes, skipping every\n * off-shape entry.\n *\n * @param value - Sparse `{ index }` record\n * @returns Set of node indexes whose value is true\n */\nexport function readRareBooleanData(value: unknown): ReadonlySet<number> {\n\tif (!isRecord(value)) return new Set()\n\treturn new Set(parseNumberArray(value['index']) ?? [])\n}\n\n/**\n * Decodes CDP snapshot sparse integer data into a node-index map, skipping every off-shape\n * entry.\n *\n * @param value - Sparse `{ index, value }` record\n * @returns Node-index to integer map\n */\nexport function readRareIntegerData(value: unknown): ReadonlyMap<number, number> {\n\tconst decoded = new Map<number, number>()\n\tif (!isRecord(value)) return decoded\n\tconst indexes = parseNumberArray(value['index'])\n\tconst values = parseNumberArray(value['value'])\n\tif (indexes === undefined || values === undefined) return decoded\n\n\tfor (let index = 0; index < indexes.length; index += 1) {\n\t\tconst node = indexes[index]\n\t\tconst integer = values[index]\n\t\tif (node !== undefined && integer !== undefined) decoded.set(node, integer)\n\t}\n\treturn decoded\n}\n\n/**\n * Decodes flattened CDP node attributes into a frozen record, skipping every off-shape pair.\n *\n * @param value - Candidate string-index array\n * @param strings - Snapshot string table\n * @returns Frozen attribute record\n */\nexport function readBrowserAttributes(\n\tvalue: unknown,\n\tstrings: readonly string[],\n): Readonly<Record<string, string>> {\n\tconst indexes = parseNumberArray(value)\n\tconst attributes: Record<string, string> = {}\n\tif (indexes === undefined) return Object.freeze(attributes)\n\n\tfor (let index = 0; index < indexes.length; index += 2) {\n\t\tconst name = parseSnapshotString(strings, indexes[index])\n\t\tconst attribute = parseSnapshotString(strings, indexes[index + 1])\n\t\tif (name !== undefined && attribute !== undefined) attributes[name] = attribute\n\t}\n\treturn Object.freeze(attributes)\n}\n\n/**\n * Decodes a CDP `DOMSnapshot.captureSnapshot` result into a serializable\n * `BrowserSnapshotInput`, throwing a `BrowserError` off-shape and a `BrowserResultLimitError`\n * past the configured node limit.\n *\n * @param value - Unknown CDP result\n * @param styles - Requested computed-style names, in protocol order\n * @param limit - Maximum accepted node count\n * @returns A typed serializable browser snapshot\n */\nexport function readBrowserSnapshot(\n\tvalue: unknown,\n\tstyles: readonly string[] = [],\n\tlimit = BROWSER_SNAPSHOT_NODE_LIMIT,\n): BrowserSnapshotInput {\n\tif (!isInteger(limit) || limit < 0) {\n\t\tthrow new BrowserError('Browser snapshot limit must be a non-negative integer', undefined, {\n\t\t\tlimit,\n\t\t})\n\t}\n\tif (!isRecord(value) || !isArray(value['strings']) || !isArray(value['documents'])) {\n\t\tthrow new BrowserError('Malformed DOMSnapshot.captureSnapshot result')\n\t}\n\tconst strings = parseArray(value['strings'], isString)\n\tif (strings === undefined) {\n\t\tthrow new BrowserError('Malformed DOMSnapshot string table')\n\t}\n\tlet count = 0\n\tfor (const document of value['documents']) {\n\t\tif (!isRecord(document) || !isRecord(document['nodes'])) continue\n\t\tcount += parseNumberArray(document['nodes']['nodeType'])?.length ?? 0\n\t}\n\tif (count > limit) {\n\t\tthrow new BrowserResultLimitError('DOM snapshot exceeds the configured node limit', {\n\t\t\tlength: count,\n\t\t\tlimit,\n\t\t})\n\t}\n\n\tconst documents: BrowserDocument[] = []\n\tfor (let documentIndex = 0; documentIndex < value['documents'].length; documentIndex += 1) {\n\t\tconst rawDocument = value['documents'][documentIndex]\n\t\tif (!isRecord(rawDocument) || !isRecord(rawDocument['nodes'])) {\n\t\t\tthrow new BrowserError('Malformed DOM snapshot document', undefined, {\n\t\t\t\tdocument: documentIndex,\n\t\t\t})\n\t\t}\n\n\t\tconst rawNodes = rawDocument['nodes']\n\t\tconst frame = parseSnapshotString(strings, rawDocument['frameId'])\n\t\tconst url = parseSnapshotString(strings, rawDocument['documentURL'])\n\t\tconst title =\n\t\t\trawDocument['title'] === -1 ? '' : parseSnapshotString(strings, rawDocument['title'])\n\t\tif (frame === undefined || url === undefined || title === undefined) {\n\t\t\tthrow new BrowserError('Malformed DOM snapshot document metadata', undefined, {\n\t\t\t\tdocument: documentIndex,\n\t\t\t})\n\t\t}\n\t\tconst types = parseNumberArray(rawNodes['nodeType'])\n\t\tconst names = parseNumberArray(rawNodes['nodeName'])\n\t\tconst values = parseNumberArray(rawNodes['nodeValue'])\n\t\tif (types === undefined || names === undefined || values === undefined) {\n\t\t\tthrow new BrowserError('Malformed DOM snapshot node table', undefined, {\n\t\t\t\tdocument: documentIndex,\n\t\t\t})\n\t\t}\n\n\t\tconst parents = parseNumberArray(rawNodes['parentIndex']) ?? []\n\t\tconst ids = parseNumberArray(rawNodes['backendNodeId']) ?? []\n\t\tconst rawAttributes = isArray(rawNodes['attributes']) ? rawNodes['attributes'] : []\n\t\tconst texts = readRareStringData(rawNodes['textValue'], strings)\n\t\tconst inputs = readRareStringData(rawNodes['inputValue'], strings)\n\t\tconst checked = readRareBooleanData(rawNodes['inputChecked'])\n\t\tconst selected = readRareBooleanData(rawNodes['optionSelected'])\n\t\tconst clickable = readRareBooleanData(rawNodes['isClickable'])\n\t\tconst shadows = readRareStringData(rawNodes['shadowRootType'], strings)\n\t\tconst contents = readRareIntegerData(rawNodes['contentDocumentIndex'])\n\t\tconst pseudos = readRareStringData(rawNodes['pseudoType'], strings)\n\t\tconst sources = readRareStringData(rawNodes['currentSourceURL'], strings)\n\t\tconst origins = readRareStringData(rawNodes['originURL'], strings)\n\t\tconst layouts = new Map<number, BrowserLayout>()\n\n\t\tif (isRecord(rawDocument['layout'])) {\n\t\t\tconst rawLayout = rawDocument['layout']\n\t\t\tconst nodeIndexes = parseNumberArray(rawLayout['nodeIndex']) ?? []\n\t\t\tconst rawStyles = isArray(rawLayout['styles']) ? rawLayout['styles'] : []\n\t\t\tconst rawBounds = isArray(rawLayout['bounds']) ? rawLayout['bounds'] : []\n\t\t\tconst rawTexts = parseNumberArray(rawLayout['text']) ?? []\n\t\t\tconst paints = parseNumberArray(rawLayout['paintOrders']) ?? []\n\t\t\tconst rawOffsets = isArray(rawLayout['offsetRects']) ? rawLayout['offsetRects'] : []\n\t\t\tconst rawScrolls = isArray(rawLayout['scrollRects']) ? rawLayout['scrollRects'] : []\n\t\t\tconst rawClients = isArray(rawLayout['clientRects']) ? rawLayout['clientRects'] : []\n\n\t\t\tfor (let layoutIndex = 0; layoutIndex < nodeIndexes.length; layoutIndex += 1) {\n\t\t\t\tconst nodeIndex = nodeIndexes[layoutIndex]\n\t\t\t\tif (nodeIndex === undefined) continue\n\t\t\t\tconst styleIndexes = parseNumberArray(rawStyles[layoutIndex]) ?? []\n\t\t\t\tconst computed: Record<string, string> = {}\n\t\t\t\tfor (let styleIndex = 0; styleIndex < styles.length; styleIndex += 1) {\n\t\t\t\t\tconst name = styles[styleIndex]\n\t\t\t\t\tconst style = parseSnapshotString(strings, styleIndexes[styleIndex])\n\t\t\t\t\tif (name !== undefined && style !== undefined) computed[name] = style\n\t\t\t\t}\n\t\t\t\tlayouts.set(nodeIndex, {\n\t\t\t\t\tbounds: parseBrowserRect(rawBounds[layoutIndex]),\n\t\t\t\t\tstyles: Object.freeze(computed),\n\t\t\t\t\ttext: parseSnapshotString(strings, rawTexts[layoutIndex]),\n\t\t\t\t\tpaint: paints[layoutIndex],\n\t\t\t\t\toffset: parseBrowserRect(rawOffsets[layoutIndex]),\n\t\t\t\t\tscroll: parseBrowserRect(rawScrolls[layoutIndex]),\n\t\t\t\t\tclient: parseBrowserRect(rawClients[layoutIndex]),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tconst nodes: BrowserNode[] = []\n\t\tfor (let nodeIndex = 0; nodeIndex < types.length; nodeIndex += 1) {\n\t\t\tconst category = types[nodeIndex]\n\t\t\tconst name = parseSnapshotString(strings, names[nodeIndex])\n\t\t\tconst nodeValue =\n\t\t\t\tvalues[nodeIndex] === -1 ? '' : parseSnapshotString(strings, values[nodeIndex])\n\t\t\tif (category === undefined || name === undefined || nodeValue === undefined) {\n\t\t\t\tthrow new BrowserError('Malformed DOM snapshot node', undefined, {\n\t\t\t\t\tdocument: documentIndex,\n\t\t\t\t\tindex: nodeIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst parent = parents[nodeIndex]\n\t\t\tnodes.push({\n\t\t\t\tdocument: documentIndex,\n\t\t\t\tframe,\n\t\t\t\tindex: nodeIndex,\n\t\t\t\tid: ids[nodeIndex],\n\t\t\t\tparent: parent === undefined || parent < 0 ? undefined : parent,\n\t\t\t\tcategory,\n\t\t\t\tname,\n\t\t\t\tvalue: nodeValue,\n\t\t\t\tattributes: readBrowserAttributes(rawAttributes[nodeIndex], strings),\n\t\t\t\ttext: texts.get(nodeIndex),\n\t\t\t\tinput: inputs.get(nodeIndex),\n\t\t\t\tchecked: checked.has(nodeIndex) ? true : undefined,\n\t\t\t\tselected: selected.has(nodeIndex) ? true : undefined,\n\t\t\t\tclickable: clickable.has(nodeIndex) ? true : undefined,\n\t\t\t\tshadow: shadows.get(nodeIndex),\n\t\t\t\tcontent: contents.get(nodeIndex),\n\t\t\t\tpseudo: pseudos.get(nodeIndex),\n\t\t\t\tsource: sources.get(nodeIndex),\n\t\t\t\torigin: origins.get(nodeIndex),\n\t\t\t\tlayout: layouts.get(nodeIndex),\n\t\t\t})\n\t\t}\n\n\t\tdocuments.push({\n\t\t\tindex: documentIndex,\n\t\t\tframe,\n\t\t\turl,\n\t\t\ttitle,\n\t\t\tnodes,\n\t\t\tscroll: [\n\t\t\t\tisFiniteNumber(rawDocument['scrollOffsetX']) ? rawDocument['scrollOffsetX'] : undefined,\n\t\t\t\tisFiniteNumber(rawDocument['scrollOffsetY']) ? rawDocument['scrollOffsetY'] : undefined,\n\t\t\t],\n\t\t\twidth: isFiniteNumber(rawDocument['contentWidth']) ? rawDocument['contentWidth'] : undefined,\n\t\t\theight: isFiniteNumber(rawDocument['contentHeight'])\n\t\t\t\t? rawDocument['contentHeight']\n\t\t\t\t: undefined,\n\t\t})\n\t}\n\n\treturn { documents, styles: [...styles] }\n}\n\n/**\n * Tests whether a browser-node matcher is a declarative query rather than a predicate.\n *\n * @param value - Browser-node query or predicate\n * @returns True if the matcher is a declarative query; false otherwise\n *\n * @example\n * ```ts\n * import { isBrowserNodeQuery } from '@orkestrel/browser'\n *\n * isBrowserNodeQuery({ name: 'main' }) // true\n * isBrowserNodeQuery(() => true) // false\n * ```\n */\nexport function isBrowserNodeQuery(\n\tvalue: BrowserNodeQuery | BrowserNodePredicate,\n): value is BrowserNodeQuery {\n\treturn !isFunction(value)\n}\n\n/**\n * Tests a captured node against a declarative query.\n *\n * @param node - Captured browser node\n * @param query - Fields every candidate must satisfy\n * @returns True if the node matches; false otherwise\n */\nexport function matchesBrowserNode(node: BrowserNode, query: BrowserNodeQuery): boolean {\n\tif (query.name !== undefined && node.name.toLowerCase() !== query.name.toLowerCase()) return false\n\tif (\n\t\tquery.text !== undefined &&\n\t\t!node.value.includes(query.text) &&\n\t\tnode.text?.includes(query.text) !== true\n\t) {\n\t\treturn false\n\t}\n\tif (query.frame !== undefined && node.frame !== query.frame) return false\n\tif (query.clickable !== undefined && (node.clickable === true) !== query.clickable) return false\n\tif (query.visible !== undefined && isBrowserNodeVisible(node) !== query.visible) return false\n\tif (query.attributes !== undefined) {\n\t\tfor (const [name, value] of Object.entries(query.attributes)) {\n\t\t\tif (node.attributes[name] !== value) return false\n\t\t}\n\t}\n\treturn true\n}\n\n/**\n * Tests whether a captured node has a non-empty rendered layout box.\n *\n * @param node - Captured browser node\n * @returns True if the snapshot reports a visible layout box; false otherwise\n */\nexport function isBrowserNodeVisible(node: BrowserNode): boolean {\n\tconst bounds = node.layout?.bounds\n\treturn bounds !== undefined && bounds[2] > 0 && bounds[3] > 0\n}\n\n/**\n * Awaits every teardown step in order and returns the first failure.\n *\n * @remarks\n * A teardown runs every step even after one of them fails, so a later release\n * is never skipped by an earlier fault, and the failure the caller reports is\n * the first one. The failure is returned rather than thrown, so the caller\n * keeps the cleanup that must still run after the steps and decides where the\n * throw belongs. A step may throw any value, `undefined` and `null` included,\n * so the first throw is retained by a separate flag rather than by testing the\n * retained value.\n *\n * @param steps - The teardown steps, in the order they must run\n * @returns The value the first failing step threw, or undefined when no step threw\n *\n * @example\n * ```ts\n * import { settleBrowserTeardown } from '@orkestrel/browser'\n *\n * const failure = await settleBrowserTeardown(\n * \t() => client.close(),\n * \t() => transport.close(),\n * )\n * if (failure !== undefined) throw failure\n * ```\n */\nexport async function settleBrowserTeardown(\n\t...steps: readonly BrowserTeardownFunction[]\n): Promise<unknown> {\n\tlet failure: unknown\n\tlet settled = false\n\tfor (const step of steps) {\n\t\ttry {\n\t\t\tawait step()\n\t\t} catch (error) {\n\t\t\tif (!settled) {\n\t\t\t\tfailure = error\n\t\t\t\tsettled = true\n\t\t\t}\n\t\t}\n\t}\n\treturn failure\n}\n\n/**\n * Collects parameter uses from native arguments and target names, keeping page arguments literal.\n * @param steps - Validated steps\n * @returns Parameter names mapped to their action and field paths\n */\nexport function collectBrowserJourneyBindings(\n\tsteps: readonly BrowserJourneyStepInput[],\n): ReadonlyMap<string, readonly string[]> {\n\tconst bindings = new Map<string, string[]>()\n\tfor (const step of steps) {\n\t\tif (!BROWSER_JOURNEY_ACTIONS.some((action) => action === step.action)) continue\n\t\tconst fields = Object.entries(step.arguments)\n\t\tif (step.target !== undefined) fields.push(['target.name', step.target.name])\n\t\tfor (const [field, value] of fields) {\n\t\t\tif (!isString(value) && isBrowserJourneyBinding(value)) {\n\t\t\t\tbindings.set(value.parameter, [\n\t\t\t\t\t...(bindings.get(value.parameter) ?? []),\n\t\t\t\t\t`${step.action}.${field}`,\n\t\t\t\t])\n\t\t\t}\n\t\t}\n\t}\n\treturn bindings\n}\n\n/**\n * Applies an ordered edit batch to a copy and validates its nonempty result and final bindings.\n * @param journey - Valid journey to edit\n * @param edits - Edits in application order\n * @returns The edited journey, with unbound parameters removed\n * @throws BrowserError - Thrown with BROWSER_JOURNEY_EDIT, a one-based index, and a reason clause when the batch fails\n */\nexport function editBrowserJourney(\n\tjourney: BrowserJourney,\n\tedits: readonly BrowserJourneyEdit[],\n): BrowserJourney {\n\tvalidateBrowserJourney(journey)\n\tconst steps = [...journey.steps]\n\tlet parameters = { ...journey.parameters }\n\tlet next = journey.next\n\tlet index = 0\n\tlet removal = 0\n\tconst declarations = new Map<string, number>()\n\tconst origins = new Map<string, number>()\n\tconst secrets = new Map<string, number>()\n\ttry {\n\t\tfor (const edit of edits) {\n\t\t\tindex += 1\n\t\t\tvalidateBrowserJourneyEdit(edit)\n\t\t\tswitch (edit.operation) {\n\t\t\t\tcase 'add': {\n\t\t\t\t\tconst anchor = edit.before ?? edit.after\n\t\t\t\t\tconst position =\n\t\t\t\t\t\tanchor === undefined ? steps.length : steps.findIndex((step) => step.id === anchor)\n\t\t\t\t\tif (position < 0) throw new BrowserError(`names unknown anchor \"${anchor}\"`)\n\t\t\t\t\tconst step = { ...edit.step, id: `s${next}` }\n\t\t\t\t\tnext += 1\n\t\t\t\t\tif (!Number.isSafeInteger(next))\n\t\t\t\t\t\tthrow new BrowserError('Invariant 2 (ids): has an invalid next counter')\n\t\t\t\t\tfor (const field of [...Object.keys(step.arguments), 'target.name'])\n\t\t\t\t\t\torigins.set(step.id + '.' + field, index)\n\t\t\t\t\tsteps.splice(position + (edit.after === undefined ? 0 : 1), 0, step)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'remove':\n\t\t\t\tcase 'update': {\n\t\t\t\t\tconst position = steps.findIndex((step) => step.id === edit.id)\n\t\t\t\t\tconst step = steps[position]\n\t\t\t\t\tif (step === undefined) throw new BrowserError(`names unknown step \"${edit.id}\"`)\n\t\t\t\t\tif (edit.operation === 'remove') {\n\t\t\t\t\t\tsteps.splice(position, 1)\n\t\t\t\t\t\tremoval = index\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst updated = {\n\t\t\t\t\t\t\t...step,\n\t\t\t\t\t\t\targuments: { ...step.arguments, ...edit.arguments },\n\t\t\t\t\t\t\t...(edit.target === undefined ? {} : { target: edit.target }),\n\t\t\t\t\t\t\t...(edit.tab === undefined ? {} : { tab: edit.tab }),\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalidateBrowserJourneyStep(updated)\n\t\t\t\t\t\tconst fields = [\n\t\t\t\t\t\t\t...Object.entries(edit.arguments ?? {}),\n\t\t\t\t\t\t\t...(edit.target === undefined ? [] : [['target.name', edit.target.name]]),\n\t\t\t\t\t\t]\n\t\t\t\t\t\tfor (const [field, value] of fields) {\n\t\t\t\t\t\t\tif (!isString(field)) continue\n\t\t\t\t\t\t\tconst previous = field === 'target.name' ? step.target?.name : step.arguments[field]\n\t\t\t\t\t\t\tif (JSON.stringify(previous) !== JSON.stringify(value))\n\t\t\t\t\t\t\t\torigins.set(step.id + '.' + field, index)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsteps[position] = updated\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'declare':\n\t\t\t\t\tif (edit.parameter.secret !== parameters[edit.name]?.secret) secrets.set(edit.name, index)\n\t\t\t\t\tparameters = { ...parameters, [edit.name]: edit.parameter }\n\t\t\t\t\tdeclarations.set(edit.name, index)\n\t\t\t}\n\t\t}\n\t\tif (steps.length === 0) {\n\t\t\tindex = removal\n\t\t\tthrow new BrowserError('removes the last step')\n\t\t}\n\t\tconst bindings = collectBrowserJourneyBindings(steps)\n\t\tfor (const [name, declaration] of declarations) {\n\t\t\tif (!bindings.has(name)) {\n\t\t\t\tindex = declaration\n\t\t\t\tthrow new BrowserError(`declares \"${name}\" but no step binds it`)\n\t\t\t}\n\t\t}\n\t\tparameters = Object.fromEntries(\n\t\t\tObject.entries(parameters).filter(([name]) => bindings.has(name)),\n\t\t)\n\t\tconst candidate = { ...journey, steps, parameters, next }\n\t\ttry {\n\t\t\tvalidateBrowserJourney(candidate)\n\t\t} catch (error) {\n\t\t\tif (isBrowserError(error) && isBrowserJourneyValidationContext(error.context)) {\n\t\t\t\tconst { parameter, step, field } = error.context\n\t\t\t\tindex = Math.max(origins.get(step + '.' + field) ?? 0, secrets.get(parameter) ?? 0)\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t\treturn structuredClone(candidate)\n\t} catch (error) {\n\t\tconst reason = normalizeBrowserJourneyReason(error)\n\t\tthrow new BrowserError(\n\t\t\t`Edit ${index} is refused: ${reason.startsWith('its ') ? reason : `it ${reason}`}`,\n\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t{\n\t\t\t\tindex,\n\t\t\t\treason,\n\t\t\t},\n\t\t)\n\t}\n}\n\n/**\n * Checks a journey name before store access.\n * @param name - Journey name\n * @throws BrowserError - Thrown with BROWSER_JOURNEY_PATH when the name is invalid\n * @example\n * validateBrowserJourneyName('add-kettle')\n */\nexport function validateBrowserJourneyName(name: string): void {\n\tif (!BROWSER_JOURNEY_NAME_PATTERN.test(name))\n\t\tthrow new BrowserError(`Refused journey name: ${name}`, 'BROWSER_JOURNEY_PATH')\n}\n\n/**\n * Checks the offset and limit of a store page.\n * @param offset - Nonnegative safe integer offset\n * @param limit - Positive safe integer limit\n * @throws BrowserError - Thrown with BROWSER_JOURNEY_ARGUMENT when either bound is invalid\n * @example\n * validateBrowserStorePage(0, 10)\n */\nexport function validateBrowserStorePage(offset: number, limit: number): void {\n\tif (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(limit) || limit < 1)\n\t\tthrow new BrowserError(\n\t\t\t'Paging requires a nonnegative integer offset and a positive integer limit',\n\t\t\t'BROWSER_JOURNEY_ARGUMENT',\n\t\t)\n}\n\n/**\n * Normalizes a failure to its first paragraph without an invariant label, directive, or final period.\n * @param error - Failure or reason text\n * @returns Reason clause\n * @example\n * normalizeBrowserJourneyReason(new Error('Invariant 4 (bindings): has an invalid binding.'))\n */\nexport function normalizeBrowserJourneyReason(error: unknown): string {\n\treturn renderBrowserRunResult(error instanceof Error ? error.message : String(error))\n\t\t.replace(/^Invariant \\d+ \\([^)]*\\): /, '')\n\t\t.replace(/\\.+$/, '')\n}\n\n/**\n * Renders an unreadable journey from its name and path-free reason.\n * @param fault - Structured store fault\n * @returns Listing fault line\n * @example\n * renderBrowserJourneyFault({ name: 'add-kettle', reason: 'Malformed journey revision' })\n */\nexport function renderBrowserJourneyFault(fault: BrowserStoreFault): string {\n\treturn `${fault.name} cannot be read: ${fault.reason}`\n}\n\n/**\n * Resolves a native string binding from supplied inputs.\n * @param value - Literal or parameter binding\n * @param inputs - Parameter values\n * @returns Literal text or the bound value\n * @throws BrowserError - Thrown when a binding has no input or the argument is malformed\n */\nexport function resolveBrowserJourneyBinding(\n\tvalue: unknown,\n\tinputs: Readonly<Record<string, string>>,\n): string {\n\tif (isString(value)) return value\n\tif (\n\t\tisBrowserJourneyBinding(value) &&\n\t\t!isString(value) &&\n\t\tObject.hasOwn(inputs, value.parameter)\n\t) {\n\t\tconst input = inputs[value.parameter]\n\t\tif (input !== undefined) return input\n\t}\n\tthrow new BrowserError('A journey binding has no value', 'BROWSER_JOURNEY_INPUT')\n}\n\n/**\n * Renders a journey with its parameter declarations and stable step ids.\n * @param journey - Valid journey\n * @returns The listing text without a trailing newline\n */\nexport function renderBrowserJourney(journey: BrowserJourney): string {\n\tvalidateBrowserJourney(journey)\n\tconst parameters = Object.entries(journey.parameters)\n\tconst defaults = Object.fromEntries(\n\t\tparameters.map(([name, parameter]) => [name, parameter.default ?? name]),\n\t)\n\tconst heading = `${journey.name} ${JSON.stringify(journey.description)}${parameters.length === 0 ? '' : ` (parameters: ${parameters.map(([name, parameter]) => `${name}${parameter.secret === true ? ' (secret)' : ''}`).join(', ')})`}`\n\tconst lines = journey.steps.map((step) => {\n\t\tconst name =\n\t\t\tstep.target === undefined\n\t\t\t\t? ''\n\t\t\t\t: `${step.target.role} ${JSON.stringify(resolveBrowserJourneyBinding(step.target.name, defaults))}${isString(step.target.name) ? '' : ` as ${step.target.name.parameter}`}`\n\t\tconst field = step.action === 'navigate' ? 'url' : step.action === 'press' ? 'key' : 'text'\n\t\tconst binding = step.arguments[field]\n\t\tconst text = isBrowserJourneyBinding(binding)\n\t\t\t? resolveBrowserJourneyBinding(binding, defaults)\n\t\t\t: ''\n\t\tconst suffix =\n\t\t\t!isString(binding) && isBrowserJourneyBinding(binding) ? ` as ${binding.parameter}` : ''\n\t\tswitch (step.action) {\n\t\t\tcase 'navigate':\n\t\t\t\treturn `${step.id} navigate ${text}${suffix}`\n\t\t\tcase 'click':\n\t\t\t\treturn `${step.id} click ${name}`\n\t\t\tcase 'type': {\n\t\t\t\tconst secret = isBrowserSecretBinding(step, journey.parameters)\n\t\t\t\treturn `${step.id} type ${secret ? '(secret)' : JSON.stringify(text)}${suffix} into ${name}${step.arguments['submit'] === true ? ', submit' : ''}`\n\t\t\t}\n\t\t\tcase 'press':\n\t\t\t\treturn `${step.id} press ${text}${suffix}`\n\t\t\tcase 'wait':\n\t\t\t\treturn `${step.id} wait ${JSON.stringify(text)}${suffix}`\n\t\t\tcase 'dialog':\n\t\t\t\treturn `${step.id} dialog ${step.arguments['accept'] === true ? 'accept' : 'dismiss'}${binding === undefined ? '' : ` ${JSON.stringify(text)}${suffix}`}`\n\t\t\tcase 'switch':\n\t\t\t\treturn `${step.id} switch ${JSON.stringify(step.tab?.title)} ${step.tab?.url}`\n\t\t\tcase 'unresolved':\n\t\t\t\treturn `${step.id} unresolved: ${step.gap}`\n\t\t\tdefault:\n\t\t\t\treturn `${step.id} ${step.action} ${JSON.stringify(step.arguments)}`\n\t\t}\n\t})\n\treturn [heading, ...lines].join('\\n')\n}\n\n/**\n * Derives the trigger text a run records for an action.\n * @param step - Valid step\n * @param inputs - Resolved parameter values; default: an empty record\n * @returns The action's trigger in the journey vocabulary\n */\nexport function deriveBrowserJourneyTrigger(\n\tstep: BrowserJourneyStepInput,\n\tinputs: Readonly<Record<string, string>> = {},\n): string {\n\tswitch (step.action) {\n\t\tcase 'click':\n\t\tcase 'type':\n\t\t\treturn resolveBrowserJourneyBinding(step.target?.name, inputs)\n\t\tcase 'press':\n\t\t\treturn resolveBrowserJourneyBinding(step.arguments['key'], inputs)\n\t\tcase 'navigate':\n\t\t\treturn resolveBrowserJourneyBinding(step.arguments['url'], inputs)\n\t\tcase 'wait':\n\t\t\treturn resolveBrowserJourneyBinding(step.arguments['text'], inputs)\n\t\tcase 'switch':\n\t\t\treturn step.tab?.title ?? ''\n\t\tcase 'dialog':\n\t\t\treturn step.arguments['accept'] === true ? 'accept' : 'dismiss'\n\t\tdefault:\n\t\t\treturn step.action\n\t}\n}\n\n/**\n * Collects the parameter names a native `type` step's `text` binds.\n *\n * @remarks\n * The names are the bindings `collectBrowserJourneyBindings` reports under `type.text`, so a page\n * tool's literal `text` argument binds no name. A recorder reads them as the names a derived\n * secret parameter cannot take.\n *\n * @param steps - Recorded steps\n * @returns Each bound name once, in the order `collectBrowserJourneyBindings` reports it\n */\nexport function collectBrowserJourneyTextBindings(\n\tsteps: readonly BrowserJourneyStepInput[],\n): readonly string[] {\n\treturn [...collectBrowserJourneyBindings(steps)]\n\t\t.filter(([, fields]) => fields.includes('type.text'))\n\t\t.map(([name]) => name)\n}\n\n/**\n * Derives an unused lower camel case secret parameter name from an accessible name.\n * @param name - Accessible name of the control\n * @param taken - Already declared names; default: an empty collection\n * @returns The derived name, or the first unused secretN fallback\n */\nexport function deriveBrowserJourneySecret(name: string, taken: readonly string[] = []): string {\n\tconst words = name\n\t\t.replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n\t\t.replace(/([A-Z])([A-Z][a-z])/g, '$1 $2')\n\t\t.split(/[^\\p{L}\\p{N}]+/u)\n\t\t.filter((word) => word.length > 0)\n\tconst candidate = words\n\t\t.map((word, index) =>\n\t\t\tindex === 0\n\t\t\t\t? word.toLowerCase()\n\t\t\t\t: `${word.charAt(0).toUpperCase()}${word.slice(1).toLowerCase()}`,\n\t\t)\n\t\t.join('')\n\tif (BROWSER_JOURNEY_PARAMETER_PATTERN.test(candidate) && !taken.includes(candidate))\n\t\treturn candidate\n\tlet count = 1\n\twhile (taken.includes(`secret${count}`)) count += 1\n\treturn `secret${count}`\n}\n\n/**\n * Generates a run id from an ISO timestamp and a cryptographic hexadecimal suffix.\n * @returns An ISO timestamp with hyphens replacing colons, followed by four hexadecimal digits\n */\nexport function generateBrowserRunId(): string {\n\tconst suffix = Array.from(crypto.getRandomValues(new Uint8Array(2)), (byte) =>\n\t\tbyte.toString(16).padStart(2, '0'),\n\t).join('')\n\treturn `${new Date().toISOString().replace(/:/g, '-')}-${suffix}`\n}\n\n/**\n * Renders a step receipt without its tool directive or appended view.\n * @param result - Step receipt or refusal\n * @returns A receipt line with directives outside quoted text removed\n */\nexport function renderBrowserRunResult(result: string): string {\n\tconst receipt = result.split('\\n\\n')[0] ?? ''\n\treturn receipt\n\t\t.split('\\n')\n\t\t.map((line) => {\n\t\t\tlet quoted = false\n\t\t\tlet escaped = false\n\t\t\tfor (let index = 0; index < line.length; index += 1) {\n\t\t\t\tconst character = line[index]\n\t\t\t\tif (escaped) {\n\t\t\t\t\tescaped = false\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (character === '\\\\' && quoted) {\n\t\t\t\t\tescaped = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (character === '\"') quoted = !quoted\n\t\t\t\tif (!quoted && line.startsWith('; call ', index))\n\t\t\t\t\treturn `${line.slice(0, index).replace(/\\.+$/, '')}.`\n\t\t\t}\n\t\t\treturn line\n\t\t})\n\t\t.join(' ')\n}\n\n/**\n * Renders a run heading and its receipts, followed by the supplied final view.\n * @param run - Run to render\n * @param view - Final view from the caller; omitted when unavailable\n * @returns The replay result without a trailing newline\n */\nexport function renderBrowserRun(run: BrowserRun, view?: string): string {\n\tconst last = run.steps.at(-1)\n\tconst next = run.journey.steps[run.steps.length]\n\tconst at =\n\t\trun.outcome === 'aborted' && last?.outcome === 'done'\n\t\t\t? (next?.id ?? last.id)\n\t\t\t: (last?.id ?? next?.id ?? 's1')\n\tconst reason = renderBrowserRunResult(last?.result ?? 'no step completed').replace(/\\.+$/, '')\n\tconst heading =\n\t\trun.outcome === 'complete'\n\t\t\t? `Replayed ${run.journey.name}: ${run.steps.length} of ${run.journey.steps.length} steps.`\n\t\t\t: run.outcome === 'stopped'\n\t\t\t\t? `Replay of ${run.journey.name} stopped at ${at} of ${run.journey.steps.length}: ${reason}.`\n\t\t\t\t: `Replay of ${run.journey.name} aborted at ${at} of ${run.journey.steps.length}.`\n\tconst lines = [\n\t\theading,\n\t\t...run.steps.map((step) => `${step.id} ${renderBrowserRunResult(step.result)}`),\n\t].join('\\n')\n\treturn view === undefined || view === '' ? lines : `${lines}\\n\\n${view}`\n}\n\n/**\n * Validates a parameter declaration, including the secret-default exclusion.\n * @param value - Candidate declaration\n * @throws BrowserError - Thrown when invariant 5 or the declaration shape fails\n */\nexport function validateBrowserJourneyParameter(\n\tvalue: unknown,\n): asserts value is BrowserJourneyParameter {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isJSONValue(value) ||\n\t\tObject.keys(value).some((key) => key !== 'default' && key !== 'secret') ||\n\t\t(value['default'] !== undefined && !isString(value['default'])) ||\n\t\t(value['secret'] !== undefined && !isBoolean(value['secret']))\n\t) {\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 5 (secrets): has a malformed parameter declaration',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\t}\n\tif (value['secret'] === true && value['default'] !== undefined)\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 5 (secrets): declares a secret with a default',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n}\n\n/**\n * Validates one step independently of ids and parameter declarations.\n * @param value - Candidate step\n * @throws BrowserError - Thrown when the action, target, tab, arguments, or JSON shape fails\n */\nexport function validateBrowserJourneyStep(\n\tvalue: unknown,\n): asserts value is BrowserJourneyStepInput {\n\tif (\n\t\t!isJSONValue(value) ||\n\t\t!isRecord(value) ||\n\t\t!isString(value['action']) ||\n\t\t!isRecord(value['arguments'])\n\t)\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 6 (JSON round trip): has a malformed step',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tconst action = value['action']\n\tif (action.length === 0 || BROWSER_JOURNEY_NON_STEP_TOOLS.includes(action))\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 7 (actions): uses an observation or journey tool as a step',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tconst native = BROWSER_JOURNEY_ACTIONS.some((name) => name === action)\n\tconst targeted = action === 'click' || action === 'type'\n\tif (\n\t\t(targeted ? !isBrowserJourneyTarget(value['target']) : value['target'] !== undefined) ||\n\t\t(action === 'switch' ? !isBrowserJourneyTab(value['tab']) : value['tab'] !== undefined)\n\t)\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 3 (targets and tabs): has an incompatible target or tab',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tconst args = value['arguments']\n\tif (native && ('ref' in args || 'tab' in args))\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 3 (targets and tabs): carries ref or tab in native arguments',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tif (\n\t\taction === 'unresolved'\n\t\t\t? !isString(value['gap']) || value['gap'].length === 0\n\t\t\t: value['gap'] !== undefined\n\t)\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 7 (actions): has an incompatible gap',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tif (!native) return\n\tconst name = BROWSER_JOURNEY_ACTIONS.find((candidate) => candidate === action)\n\tif (name === undefined) return\n\tconst schema = BROWSER_TOOL_COPY[name].parameters\n\tconst properties = schema?.['properties']\n\tconst required = schema?.['required']\n\tconst fields = isRecord(properties)\n\t\t? Object.entries(properties).filter(([key]) => !BROWSER_JOURNEY_STEP_KEYS.includes(key))\n\t\t: []\n\tif (\n\t\tObject.keys(args).some((key) => !fields.some(([field]) => field === key)) ||\n\t\tfields.some(([key, property]) => {\n\t\t\tconst argument = args[key]\n\t\t\tif (argument === undefined) return isArray(required) && required.includes(key)\n\t\t\tif (!isRecord(property)) return true\n\t\t\tswitch (property['type']) {\n\t\t\t\tcase 'string':\n\t\t\t\t\treturn !isBrowserJourneyBinding(argument)\n\t\t\t\tcase 'boolean':\n\t\t\t\t\treturn !isBoolean(argument)\n\t\t\t\tcase 'integer':\n\t\t\t\t\treturn !isInteger(argument)\n\t\t\t\tcase 'number':\n\t\t\t\t\treturn !isFiniteNumber(argument)\n\t\t\t\tdefault:\n\t\t\t\t\treturn true\n\t\t\t}\n\t\t})\n\t)\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 7 (actions): has malformed native arguments',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n}\n\n/**\n * Validates the journey format and its name, nonempty steps, ids, bindings, secrets, JSON, and actions.\n * @param value - Candidate journey\n * @throws BrowserError - Thrown with BROWSER_JOURNEY_FORMAT for an unknown format, or BROWSER_JOURNEY_INVALID naming the failed invariant\n */\nexport function validateBrowserJourney(value: unknown): asserts value is BrowserJourney {\n\tif (!isJSONValue(value) || !isRecord(value))\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 6 (JSON round trip): is not a JSON record',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tif (value['format'] !== BROWSER_JOURNEY_FORMAT_VERSION)\n\t\tthrow new BrowserError('Has an unknown journey format', 'BROWSER_JOURNEY_FORMAT')\n\tif (!isString(value['name']) || !BROWSER_JOURNEY_NAME_PATTERN.test(value['name']))\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 1 (name): has an invalid journey name',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tif (!isString(value['description']) || !isArray(value['steps']) || !isRecord(value['parameters']))\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 6 (JSON round trip): has malformed journey fields',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tif (value['steps'].length === 0)\n\t\tthrow new BrowserError('Invariant 2 (ids): has no steps', 'BROWSER_JOURNEY_INVALID', {\n\t\t\tfield: 'steps',\n\t\t})\n\tif (!Number.isSafeInteger(value['next']) || !isFiniteNumber(value['next']) || value['next'] < 1)\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 2 (ids): has an invalid next counter',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tconst ids = new Set<string>()\n\tconst steps: BrowserJourneyStep[] = []\n\tfor (const step of value['steps']) {\n\t\tvalidateBrowserJourneyStep(step)\n\t\tif (\n\t\t\t!('id' in step) ||\n\t\t\t!isString(step.id) ||\n\t\t\t!/^s[1-9]\\d*$/.test(step.id) ||\n\t\t\t!Number.isSafeInteger(Number(step.id.slice(1))) ||\n\t\t\tNumber(step.id.slice(1)) >= value['next'] ||\n\t\t\tids.has(step.id)\n\t\t)\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Invariant 2 (ids): repeats an id or exceeds the next counter',\n\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t)\n\t\tids.add(step.id)\n\t\tsteps.push({ ...step, id: step.id })\n\t}\n\tconst bindings = collectBrowserJourneyBindings(steps)\n\tfor (const [name, parameter] of Object.entries(value['parameters'])) {\n\t\tif (!BROWSER_JOURNEY_PARAMETER_PATTERN.test(name))\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Invariant 4 (bindings): has an invalid parameter name',\n\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t)\n\t\tvalidateBrowserJourneyParameter(parameter)\n\t\tif (!bindings.has(name))\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Invariant 4 (bindings): declares \"${name}\" but no step binds it`,\n\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t)\n\t}\n\tfor (const name of bindings.keys()) {\n\t\tconst declared = Object.hasOwn(value['parameters'], name)\n\t\tconst parameter = value['parameters'][name]\n\t\tif (declared) validateBrowserJourneyParameter(parameter)\n\t\tfor (const step of steps) {\n\t\t\tconst fields = collectBrowserJourneyBindings([step]).get(name) ?? []\n\t\t\tfor (const binding of fields) {\n\t\t\t\tconst field = binding.slice(step.action.length + 1)\n\t\t\t\tconst context = { parameter: name, step: step.id, field }\n\t\t\t\tif (!declared)\n\t\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t\t`Invariant 4 (bindings): binds undeclared parameter \"${name}\"`,\n\t\t\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t)\n\t\t\t\tif (\n\t\t\t\t\tisRecord(parameter) &&\n\t\t\t\t\tparameter['secret'] === true &&\n\t\t\t\t\t(step.action !== 'type' || field !== 'text')\n\t\t\t\t)\n\t\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t\t`Invariant 5 (secrets): binds secret \"${name}\" outside type.text`,\n\t\t\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Validates an edit structure and names the operation and field in each refusal.\n * @param value - Candidate edit\n * @throws BrowserError - Thrown when the operation or its fields are malformed\n */\nexport function validateBrowserJourneyEdit(value: unknown): asserts value is BrowserJourneyEdit {\n\tif (!isRecord(value))\n\t\tthrow new BrowserError('has no edit object with an \"operation\" field', 'BROWSER_JOURNEY_EDIT')\n\tconst operation = value['operation']\n\tconst fields =\n\t\toperation === 'add'\n\t\t\t? ['operation', 'step', 'before', 'after']\n\t\t\t: operation === 'remove'\n\t\t\t\t? ['operation', 'id']\n\t\t\t\t: operation === 'update'\n\t\t\t\t\t? ['operation', 'id', 'arguments', 'target', 'tab']\n\t\t\t\t\t: operation === 'declare'\n\t\t\t\t\t\t? ['operation', 'name', 'parameter']\n\t\t\t\t\t\t: undefined\n\tif (fields === undefined)\n\t\tthrow new BrowserError(\n\t\t\t'names no operation among add, update, remove, and declare',\n\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t)\n\tfor (const [field, content] of Object.entries(value)) {\n\t\tif (!fields.includes(field))\n\t\t\tthrow new BrowserError(\n\t\t\t\t`its \"${operation}\" carries an unknown field ${JSON.stringify(field)}`,\n\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t)\n\t\tif (!isJSONValue(content))\n\t\t\tthrow new BrowserError(\n\t\t\t\t`its \"${operation}\" has non-JSON content in ${JSON.stringify(field)}`,\n\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t)\n\t}\n\tswitch (operation) {\n\t\tcase 'add':\n\t\t\tif (value['before'] !== undefined && value['after'] !== undefined)\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t'its \"add\" carries both \"before\" and \"after\"',\n\t\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t\t)\n\t\t\tfor (const field of ['before', 'after']) {\n\t\t\t\tif (value[field] !== undefined && (!isString(value[field]) || value[field].length === 0))\n\t\t\t\t\tthrow new BrowserError(`its \"add\" has no step id in \"${field}\"`, 'BROWSER_JOURNEY_EDIT')\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tvalidateBrowserJourneyStep(value['step'])\n\t\t\t} catch (error) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`its \"add\" has an invalid \"step\": ${normalizeBrowserJourneyReason(error)}`,\n\t\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif ('id' in value['step'])\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t'its \"add\" supplies \"step.id\", which is assigned automatically',\n\t\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t\t)\n\t\t\treturn\n\t\tcase 'remove':\n\t\t\tif (!isString(value['id']) || value['id'].length === 0)\n\t\t\t\tthrow new BrowserError('its \"remove\" names no step in \"id\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\treturn\n\t\tcase 'update':\n\t\t\tif (!isString(value['id']) || value['id'].length === 0)\n\t\t\t\tthrow new BrowserError('its \"update\" names no step in \"id\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\tif (value['arguments'] !== undefined && !isRecord(value['arguments']))\n\t\t\t\tthrow new BrowserError('its \"update\" has no object in \"arguments\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\tif (value['target'] !== undefined && !isBrowserJourneyTarget(value['target']))\n\t\t\t\tthrow new BrowserError('its \"update\" has an invalid \"target\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\tif (value['tab'] !== undefined && !isBrowserJourneyTab(value['tab']))\n\t\t\t\tthrow new BrowserError('its \"update\" has an invalid \"tab\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\treturn\n\t\tcase 'declare':\n\t\t\tif (!isString(value['name']) || value['name'].length === 0)\n\t\t\t\tthrow new BrowserError('its \"declare\" has no \"name\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\tif (!BROWSER_JOURNEY_PARAMETER_PATTERN.test(value['name']))\n\t\t\t\tthrow new BrowserError('its \"declare\" has an invalid \"name\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\ttry {\n\t\t\t\tvalidateBrowserJourneyParameter(value['parameter'])\n\t\t\t} catch (error) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`its \"declare\" has an invalid \"parameter\": ${normalizeBrowserJourneyReason(error)}`,\n\t\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn\n\t}\n}\n\n/**\n * Validates a persisted run and the journey it carries.\n * @param value - Candidate run\n * @throws BrowserError - Thrown when the format, run fields, or embedded journey fails validation\n */\nexport function validateBrowserRun(value: unknown): asserts value is BrowserRun {\n\tif (!isJSONValue(value) || !isRecord(value))\n\t\tthrow new BrowserError('Run is not a JSON record', 'BROWSER_JOURNEY_INVALID')\n\tif (value['format'] !== BROWSER_JOURNEY_FORMAT_VERSION)\n\t\tthrow new BrowserError('Has an unknown run format', 'BROWSER_JOURNEY_FORMAT')\n\tvalidateBrowserJourney(value['journey'])\n\tconst journey = value['journey']\n\tif (\n\t\t!isString(value['id']) ||\n\t\t!BROWSER_RUN_ID_PATTERN.test(value['id']) ||\n\t\t!isRecord(value['inputs']) ||\n\t\t!Object.values(value['inputs']).every(isString) ||\n\t\t!isArray(value['steps']) ||\n\t\tparseEnum(value['outcome'], ['complete', 'stopped', 'aborted']) === undefined ||\n\t\t!isFiniteNumber(value['elapsed']) ||\n\t\tvalue['elapsed'] < 0 ||\n\t\t(value['revision'] !== undefined &&\n\t\t\t(!isFiniteNumber(value['revision']) ||\n\t\t\t\t!Number.isSafeInteger(value['revision']) ||\n\t\t\t\tvalue['revision'] < 1)) ||\n\t\t(value['fault'] !== undefined && !isString(value['fault'])) ||\n\t\t(value['output'] !== undefined &&\n\t\t\t(!isArray(value['output']) || !value['output'].every(isString)))\n\t)\n\t\tthrow new BrowserError('Run has malformed fields', 'BROWSER_JOURNEY_INVALID')\n\tfor (const [index, step] of value['steps'].entries()) {\n\t\tconst source = journey.steps[index]\n\t\tif (\n\t\t\t!isRecord(step) ||\n\t\t\tsource === undefined ||\n\t\t\tstep['id'] !== source.id ||\n\t\t\tstep['action'] !== source.action ||\n\t\t\t!isString(step['trigger']) ||\n\t\t\t!isRecord(step['arguments']) ||\n\t\t\t!isString(step['result']) ||\n\t\t\t!isFiniteNumber(step['elapsed']) ||\n\t\t\tstep['elapsed'] < 0 ||\n\t\t\tparseEnum(step['outcome'], BROWSER_ACTION_OUTCOMES) === undefined ||\n\t\t\t(step['capture'] !== undefined && !isString(step['capture'])) ||\n\t\t\t(step['stage'] !== undefined &&\n\t\t\t\tparseEnum(step['stage'], BROWSER_ACTION_STAGES) === undefined) ||\n\t\t\t(step['reason'] !== undefined &&\n\t\t\t\tparseEnum(step['reason'], BROWSER_NAVIGATION_REASONS) === undefined)\n\t\t)\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Run has a malformed step or is not a journey prefix',\n\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t)\n\t}\n\tfor (const [name, parameter] of Object.entries(journey.parameters)) {\n\t\tif (\n\t\t\tparameter.secret === true &&\n\t\t\t(Object.hasOwn(value['inputs'], name) ||\n\t\t\t\tvalue['output'] !== undefined ||\n\t\t\t\tvalue['steps'].some((step) => isRecord(step) && step['capture'] !== undefined))\n\t\t)\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Invariant 5 (secrets): run retains secret inputs, output, or captures',\n\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t)\n\t}\n\tif (Object.keys(value['inputs']).some((name) => !Object.hasOwn(journey.parameters, name)))\n\t\tthrow new BrowserError('Run has an unknown input', 'BROWSER_JOURNEY_INVALID')\n\tif (\n\t\tvalue['outcome'] === 'complete' &&\n\t\t(value['steps'].length !== journey.steps.length ||\n\t\t\tvalue['steps'].some((step, index) => {\n\t\t\t\tif (!isRecord(step)) return true\n\t\t\t\tconst following = journey.steps[index + 1]\n\t\t\t\treturn (\n\t\t\t\t\t(step['outcome'] !== 'done' &&\n\t\t\t\t\t\t!(step['outcome'] === 'interrupted' && following?.action === 'dialog')) ||\n\t\t\t\t\t(step['stage'] !== undefined && step['stage'] !== 'loaded')\n\t\t\t\t)\n\t\t\t}))\n\t)\n\t\tthrow new BrowserError('Run completion does not match its steps', 'BROWSER_JOURNEY_INVALID')\n\tfor (const [index, source] of journey.steps.entries()) {\n\t\tconst step = value['steps'][index]\n\t\tif (\n\t\t\tisBrowserSecretBinding(source, journey.parameters) &&\n\t\t\tisRecord(step) &&\n\t\t\tisRecord(step['arguments']) &&\n\t\t\tObject.hasOwn(step['arguments'], 'text')\n\t\t)\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Invariant 5 (secrets): run retains secret type.text',\n\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t)\n\t}\n}\n\n/**\n * Builds a validated journey from recorded steps and declares their secret bindings.\n * @param steps - Recorded steps in order\n * @param options - Journey name and description\n * @returns An owned journey with its next id and secret declarations\n * @throws BrowserError - Thrown when the assembled journey fails validation\n */\nexport function buildBrowserJourney(\n\tsteps: readonly BrowserJourneyStep[],\n\toptions: Pick<BrowserJourney, 'name' | 'description'>,\n): BrowserJourney {\n\tconst parameters: Record<string, BrowserJourneyParameter> = {}\n\tfor (const step of steps) {\n\t\tconst binding = step.arguments['text']\n\t\tif (\n\t\t\tisBrowserJourneyBinding(binding) &&\n\t\t\t!isString(binding) &&\n\t\t\tisBrowserSecretBinding(step, { [binding.parameter]: { secret: true } })\n\t\t)\n\t\t\tparameters[binding.parameter] = { secret: true }\n\t}\n\tconst journey: BrowserJourney = {\n\t\tformat: BROWSER_JOURNEY_FORMAT_VERSION,\n\t\t...options,\n\t\tparameters,\n\t\tnext: steps.length + 1,\n\t\tsteps: structuredClone(steps),\n\t}\n\tvalidateBrowserJourney(journey)\n\treturn journey\n}\n","import type {\n\tBrowserActionabilityOptions,\n\tBrowserCodegenLanguage,\n\tBrowserCodegenScript,\n\tBrowserJourney,\n\tBrowserRect,\n\tBrowserScreenshotOptions,\n\tBrowserStorageOrigin,\n} from './types.js'\nimport type { JSONValue } from '@orkestrel/contract'\nimport { isArray, isRecord, isString } from '@orkestrel/contract'\nimport {\n\tBROWSER_JOURNEY_ACTIONS,\n\tBROWSER_RESULT_LIMIT_SENTINEL_PREFIX,\n\tBROWSER_SCREENSHOT_ATTRIBUTE,\n\tBROWSER_STABLE_FRAME_COUNT,\n\tBROWSER_SUBMIT_KEY,\n} from './constants.js'\nimport { validateBrowserJourney } from './helpers.js'\nimport { isBrowserSecretBinding } from './validators.js'\n\n/**\n * Compiles a mutation-driven wait with one deadline and explicit disconnect ownership.\n * @param deadline - Maximum time in milliseconds\n * @param key - Isolated-world property owning this observer\n * @param predicate - Optional expression checked immediately and after each mutation batch\n * @returns Promise expression resolving true on a match or change, false at the deadline\n */\nexport function compileQueryWaitExpression(\n\tdeadline: number,\n\tkey: string,\n\tpredicate?: string,\n): string {\n\treturn `new Promise((resolve) => {\n\tlet frame\n\tlet timer\n\tlet observer\n\tconst finish = (value) => {\n\t\tobserver?.disconnect()\n\t\tif (frame !== undefined) cancelAnimationFrame(frame)\n\t\tclearTimeout(timer)\n\t\tdelete globalThis[${JSON.stringify(key)}]\n\t\tresolve(value)\n\t}\n\tconst check = () => {\n\t\tframe = undefined\n\t\tif (${predicate ?? 'true'}) finish(true)\n\t}\n\tglobalThis[${JSON.stringify(key)}] = () => finish(false)\n\tobserver = new MutationObserver(() => {\n\t\tif (frame === undefined) frame = requestAnimationFrame(check)\n\t})\n\tobserver.observe(document, { childList: true, attributes: true, characterData: true, subtree: true })\n\ttimer = setTimeout(() => finish(false), ${JSON.stringify(deadline)})\n\t${predicate === undefined ? '' : 'check()'}\n})`\n}\n\n/**\n * Compiles a visible-text wait coalesced by animation frames.\n * @param text - Text to find in the main document body\n * @param deadline - Maximum time in milliseconds\n * @param key - Isolated-world property owning this observer\n * @returns Mutation-driven promise expression with one deadline\n */\nexport function compileTextWaitExpression(text: string, deadline: number, key: string): string {\n\treturn compileQueryWaitExpression(\n\t\tdeadline,\n\t\tkey,\n\t\t`(document.body?.innerText ?? '').includes(${JSON.stringify(text)})`,\n\t)\n}\n\n/**\n * Compiles text selection or select-option assignment against the resolved element.\n * @param values - Option values or labels; absence selects the text control's contents\n * @returns Function declaration for an isolated-world element call\n */\nexport function compileSelectFunction(values?: readonly string[]): string {\n\tif (values === undefined)\n\t\treturn `function() {\n\tif (this.isContentEditable) {\n\t\tthis.ownerDocument.getSelection().selectAllChildren(this)\n\t\treturn true\n\t}\n\tif (typeof this.select !== 'function') throw new Error('Element is not a text control')\n\tthis.select()\n\treturn true\n}`\n\treturn `function() {\n\tif (!(this instanceof HTMLSelectElement)) throw new Error('Element is not a select control')\n\tconst values = ${JSON.stringify(values)}\n\tconst selected = values.map((value) => [...this.options].find((option) => option.value === value) ?? [...this.options].find((option) => option.label === value))\n\tif (selected.some((option) => option === undefined)) throw new Error('Select option was not found')\n\tfor (const option of this.options) option.selected = selected.includes(option)\n\tthis.dispatchEvent(new Event('input', { bubbles: true }))\n\tthis.dispatchEvent(new Event('change', { bubbles: true }))\n\treturn true\n}`\n}\n\n/**\n * Compiles the descendant hit check for a resolved element.\n * @returns Function declaration accepting the resolved covering node\n */\nexport function compileHitFunction(): string {\n\treturn `function(target) {\n\t\twhile (target && target.nodeType !== 9) {\n\t\t\tif (target === this) return true\n\t\t\ttarget = target instanceof ShadowRoot ? target.host : target.parentNode\n\t\t}\n\t\treturn false\n\t}`\n}\n\n/**\n * Compiles the installation of a capture-phase `submit` observer owned by `token` on the window of\n * the world it runs in.\n *\n * @remarks\n * The observer records every `submit` event the window sees from installation until\n * {@link compileSubmitReadExpression} with the same `token` reads and removes it, under\n * {@link BROWSER_SUBMIT_KEY}, and replaces an observer an earlier installation left in place,\n * whatever its token. A capture-phase `keydown` listener beside it records whether an Enter's\n * target is an `input` a form owns, before any handler of the page can move the focus. A listener\n * of an isolated world observes the events the page's own scripts dispatch, because both worlds\n * share one DOM.\n *\n * @param token - The integer that identifies the action owning the observer\n * @returns Expression source that resolves `true`\n */\nexport function compileSubmitObserverExpression(token: number): string {\n\tconst key = JSON.stringify(BROWSER_SUBMIT_KEY)\n\treturn `(() => {\n\tconst token = ${JSON.stringify(token)}\n\tconst previous = globalThis[${key}]\n\tif (previous !== undefined) {\n\t\tremoveEventListener('submit', previous.listener, true)\n\t\tremoveEventListener('keydown', previous.keys, true)\n\t}\n\tconst state = { token, events: [], implicit: false, listener: undefined, keys: undefined }\n\tstate.listener = (event) => { state.events.push(event) }\n\tstate.keys = (event) => {\n\t\tconst target = event.target ?? null\n\t\tif (event.key === 'Enter' && target?.localName === 'input' && (target.form ?? null) !== null) state.implicit = true\n\t}\n\tglobalThis[${key}] = state\n\taddEventListener('submit', state.listener, true)\n\taddEventListener('keydown', state.keys, true)\n\treturn true\n})()`\n}\n\n/**\n * Compiles the read of the `submit` observer {@link compileSubmitObserverExpression} installs for\n * `token`, removing the observer.\n *\n * @remarks\n * The read resolves an object of four members:\n * - `destinations` — without repeats and in the order first recorded, the relationship of the\n * destination of every recorded `submit` that kept its default action: `self` for a target\n * that is empty or `_self`, `parent` for `_parent`, and `top` for `_top`. The target is the one\n * the submitter, the form, or the document's `base` element names. A prevented submission, one\n * whose method is `dialog`, and one aimed at another browsing context add nothing.\n * - `prevented` — true when a listener prevented any recorded `submit`; false otherwise\n * - `submitted` — true when the observer recorded any `submit`; false otherwise\n * - `implicit` — true when the observer recorded an Enter whose target is an `input` a form owns,\n * the control whose Enter submits that form implicitly; false otherwise. The target is recorded\n * in the capture phase, so a handler that moves the focus afterwards does not change it.\n *\n * Every listener of an event has run by the time the input that fired it settles, so\n * `defaultPrevented` is final by then. The read resolves `null` and removes nothing when no\n * observer of `token` is installed, so a delayed read of an earlier action leaves a later\n * action's observer in place.\n *\n * @param token - The integer that identifies the action owning the observer\n * @returns Expression source that resolves `{ destinations, prevented, submitted, implicit }`, or\n * `null`\n */\nexport function compileSubmitReadExpression(token: number): string {\n\tconst key = JSON.stringify(BROWSER_SUBMIT_KEY)\n\treturn `(() => {\n\tconst token = ${JSON.stringify(token)}\n\tconst state = globalThis[${key}]\n\tif (state === undefined || state.token !== token) return null\n\tdelete globalThis[${key}]\n\tremoveEventListener('submit', state.listener, true)\n\tremoveEventListener('keydown', state.keys, true)\n\tconst destinations = { '': 'self', _self: 'self', _parent: 'parent', _top: 'top' }\n\tconst found = []\n\tfor (const event of state.events) {\n\t\tif (event.defaultPrevented) continue\n\t\tconst submitter = event.submitter ?? null\n\t\tconst form = event.target\n\t\tconst method = (submitter?.getAttribute('formmethod') ?? form.getAttribute('method') ?? '').toLowerCase()\n\t\tconst target = (submitter?.getAttribute('formtarget') ?? form.getAttribute('target') ?? document.querySelector('base[target]')?.getAttribute('target') ?? '').toLowerCase()\n\t\tconst destination = Object.hasOwn(destinations, target) ? destinations[target] : undefined\n\t\tif (method !== 'dialog' && destination !== undefined && !found.includes(destination)) found.push(destination)\n\t}\n\treturn {\n\t\tdestinations: found,\n\t\tprevented: state.events.some((event) => event.defaultPrevented),\n\t\tsubmitted: state.events.length > 0,\n\t\timplicit: state.implicit,\n\t}\n})()`\n}\n\n/**\n * Compiles the page-side promise facade for one Runtime binding.\n *\n * @param name - Binding identifier\n * @returns Self-installing script source\n */\nexport function compileBrowserBindingSource(name: string): string {\n\tconst binding = JSON.stringify(name)\n\tconst state = JSON.stringify(`__orkestrelBinding_${name}`)\n\treturn `(() => {\n\tconst name = ${binding}\n\tconst key = ${state}\n\tif (globalThis[key]) return\n\tconst send = globalThis[name]\n\tif (typeof send !== 'function') throw new Error('Browser binding transport is unavailable')\n\tconst pending = new Map()\n\tlet sequence = 0\n\tglobalThis[key] = {\n\t\tresolve(id, success, value) {\n\t\t\tconst entry = pending.get(id)\n\t\t\tif (!entry) return\n\t\t\tpending.delete(id)\n\t\t\tif (success) entry.resolve(value)\n\t\t\telse entry.reject(new Error(String(value)))\n\t\t},\n\t}\n\tglobalThis[name] = (...args) => new Promise((resolve, reject) => {\n\t\tsequence += 1\n\t\tconst id = String(sequence)\n\t\tpending.set(id, { resolve, reject })\n\t\tsend(JSON.stringify({ id, name, args }))\n\t})\n})()`\n}\n\n/**\n * Compiles delivery of a host binding result to one execution context.\n *\n * @param name - Binding identifier\n * @param id - Call identifier\n * @param success - Resolve rather than reject\n * @param value - Serializable result or error\n * @returns Runtime expression\n */\nexport function compileBrowserBindingResult(\n\tname: string,\n\tid: string,\n\tsuccess: boolean,\n\tvalue: unknown,\n): string {\n\treturn `globalThis[${JSON.stringify(`__orkestrelBinding_${name}`)}]?.resolve(${JSON.stringify(id)}, ${JSON.stringify(success)}, ${JSON.stringify(value)})`\n}\n\n/**\n * Compiles current-document cleanup for one page-side host binding facade.\n *\n * @param name - Binding identifier\n * @returns Runtime cleanup expression\n */\nexport function compileBrowserBindingCleanup(name: string): string {\n\treturn `(() => {\n\tdelete globalThis[${JSON.stringify(name)}]\n\tdelete globalThis[${JSON.stringify(`__orkestrelBinding_${name}`)}]\n\treturn true\n})()`\n}\n\n/**\n * Compiles temporary animation, caret, and mask setup for a screenshot.\n *\n * @param options - Screenshot controls\n * @param masks - Viewport rectangles to cover, resolved from the masked elements\n * @returns Setup expression or undefined when no preparation is required\n */\nexport function compileScreenshotPreparationExpression(\n\toptions?: BrowserScreenshotOptions,\n\tmasks: readonly BrowserRect[] = [],\n): string | undefined {\n\tif (options?.animations !== false && options?.caret !== false && masks.length === 0) {\n\t\treturn undefined\n\t}\n\treturn `(() => {\n\tconst attribute = ${JSON.stringify(BROWSER_SCREENSHOT_ATTRIBUTE)}\n\tconst sequence = (globalThis.__orkestrelScreenshotSequence ?? 0) + 1\n\tglobalThis.__orkestrelScreenshotSequence = sequence\n\tconst token = String(sequence)\n\tif (${JSON.stringify(options?.animations === false || options?.caret === false)}) {\n\t\tconst style = document.createElement('style')\n\t\tstyle.setAttribute(attribute, token)\n\t\tstyle.textContent = ${JSON.stringify(\n\t\t\t`${options?.animations === false ? '*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}' : ''}${options?.caret === false ? '*{caret-color:transparent!important}' : ''}`,\n\t\t)}\n\t\tdocument.documentElement.appendChild(style)\n\t}\n\tconst rects = ${JSON.stringify(masks)}\n\tfor (const [left, top, width, height] of rects) {\n\t\tconst mask = document.createElement('div')\n\t\tmask.setAttribute(attribute, token)\n\t\tmask.style.cssText = 'position:fixed;pointer-events:none;z-index:2147483647;' +\n\t\t\t'left:' + left + 'px;top:' + top + 'px;width:' + width + 'px;height:' + height + 'px;' +\n\t\t\t'background:' + ${JSON.stringify(options?.color ?? '#ff00ff')}\n\t\tdocument.documentElement.appendChild(mask)\n\t}\n\treturn token\n})()`\n}\n\n/**\n * Compiles cleanup for temporary screenshot styles and masks.\n *\n * @param token - Preparation token\n * @returns Cleanup expression\n */\nexport function compileScreenshotCleanupExpression(token: string): string {\n\treturn `(() => {\n\tconst attribute = ${JSON.stringify(BROWSER_SCREENSHOT_ATTRIBUTE)}\n\tfor (const element of document.querySelectorAll('[' + attribute + ']')) {\n\t\tif (element.getAttribute(attribute) === ${JSON.stringify(token)}) element.remove()\n\t}\n\treturn true\n})()`\n}\n\n/**\n * Compiles an expression that serializes local and session storage.\n *\n * @returns In-page storage expression\n */\nexport function compileStorageReadExpression(): string {\n\treturn `({\n\tlocal: Array.from({ length: localStorage.length }, (_, index) => {\n\t\tconst name = localStorage.key(index)\n\t\treturn { name, value: name === null ? '' : localStorage.getItem(name) ?? '' }\n\t}),\n\tsession: Array.from({ length: sessionStorage.length }, (_, index) => {\n\t\tconst name = sessionStorage.key(index)\n\t\treturn { name, value: name === null ? '' : sessionStorage.getItem(name) ?? '' }\n\t}),\n})`\n}\n\n/**\n * Compiles an expression that restores one origin's web storage.\n *\n * @param origin - Storage values to restore\n * @returns In-page restore expression\n */\nexport function compileStorageRestoreExpression(origin: BrowserStorageOrigin): string {\n\treturn `(() => {\n\tconst state = ${JSON.stringify({ local: origin.local, session: origin.session })}\n\tlocalStorage.clear()\n\tsessionStorage.clear()\n\tfor (const entry of state.local) localStorage.setItem(entry.name, entry.value)\n\tfor (const entry of state.session) sessionStorage.setItem(entry.name, entry.value)\n\treturn true\n})()`\n}\n\n/**\n * Compiles an expression that clears local and session storage.\n *\n * @returns In-page clear expression\n */\nexport function compileStorageClearExpression(): string {\n\treturn `(() => {\n\tlocalStorage.clear()\n\tsessionStorage.clear()\n\treturn true\n})()`\n}\n\n/**\n * Compiles a `Runtime.evaluate` expression so the in-page code stringifies its own result and\n * throws a recognizable sentinel error before an oversized result would overflow the CDP\n * transport frame.\n *\n * @remarks\n * A result whose `JSON.stringify` length exceeds `limit` throws\n * `Error('BROWSER_RESULT_LIMIT: <length>')` inside the page instead of being\n * returned — the caller maps that sentinel to a coded\n * {@link BrowserResultLimitError}. A non-serializable result (`undefined`,\n * a function, a symbol) makes `JSON.stringify` return `undefined`, so the\n * length check is skipped and today's undefined-passthrough behavior is\n * unchanged.\n *\n * The expression is placed on its own line inside the wrapper (rather than\n * inline with the guard code) so a trailing `//` line comment in the\n * expression cannot swallow the closing guard syntax that follows it.\n *\n * @param expression - The candidate JavaScript expression to evaluate\n * @param limit - Maximum serialized-character length (see {@link BROWSER_RESULT_LIMIT})\n * @returns The wrapped, guarded expression\n */\nexport function compileGuardedEvaluateExpression(expression: string, limit: number): string {\n\treturn `(() => { const r = (\n${expression}\n); const s = JSON.stringify(r); if (typeof s === 'string' && s.length > ${limit}) throw new Error(${JSON.stringify(BROWSER_RESULT_LIMIT_SENTINEL_PREFIX)} + s.length); return r })()`\n}\n\n/**\n * Compiles the in-page function that reads the document's URL, title, and serialized HTML.\n *\n * @remarks\n * The declaration takes no arguments and returns `{ url, title, html }` from `location.href`,\n * `document.title`, and `document.documentElement.outerHTML`, with `html` empty for a document\n * that has no root element. Call it inside {@link compileGuardedEvaluateExpression} to bound the\n * result under {@link BROWSER_RESULT_LIMIT}.\n *\n * @returns A function declaration source\n */\nexport function compileReadFunction(): string {\n\treturn `function() {\n\tconst root = document.documentElement\n\treturn { url: location.href, title: document.title, html: root ? root.outerHTML : '' }\n}`\n}\n\n/**\n * Compiles a JSON value into the JavaScript literal a generated journey module carries.\n *\n * @remarks\n * A string takes single quotes, an object key that is an identifier stays bare, and an own\n * `__proto__` key compiles to a computed key so the literal keeps it as an own property. An object\n * whose only member is a `parameter` string that `bindings` names compiles to the expression\n * `bindings` maps that name to; without `bindings`, every value compiles literally.\n *\n * @param value - The JSON value to compile\n * @param bindings - The expression each parameter's binding compiles to, by parameter name\n * @returns Expression source that evaluates to the value\n * @example\n * ```ts\n * compileBrowserJourneyValue({ text: { parameter: 'email' }, submit: true }, new Map([['email', 'inputs.email']]))\n * // \"{ text: inputs.email, submit: true }\"\n * ```\n */\nexport function compileBrowserJourneyValue(\n\tvalue: JSONValue,\n\tbindings?: ReadonlyMap<string, string>,\n): string {\n\tif (isString(value))\n\t\treturn `'${JSON.stringify(value)\n\t\t\t.slice(1, -1)\n\t\t\t.replace(/\\\\\"|'/g, (escape) => (escape === \"'\" ? \"\\\\'\" : '\"'))}'`\n\tif (isArray(value))\n\t\treturn `[${value.map((member) => compileBrowserJourneyValue(member, bindings)).join(', ')}]`\n\tif (!isRecord(value)) return JSON.stringify(value)\n\tconst entries = Object.entries(value)\n\tconst parameter = value['parameter']\n\tconst expression =\n\t\tentries.length === 1 && isString(parameter) ? bindings?.get(parameter) : undefined\n\tif (expression !== undefined) return expression\n\tif (entries.length === 0) return '{}'\n\tconst members = entries.map(([key, member]) => {\n\t\tconst name =\n\t\t\tkey === '__proto__'\n\t\t\t\t? `['__proto__']`\n\t\t\t\t: /^[A-Za-z_$][\\w$]*$/.test(key)\n\t\t\t\t\t? key\n\t\t\t\t\t: compileBrowserJourneyValue(key)\n\t\treturn `${name}: ${compileBrowserJourneyValue(member, bindings)}`\n\t})\n\treturn `{ ${members.join(', ')} }`\n}\n\n/**\n * Compiles a journey into a standalone module that performs each step through the `follow`\n * method of a toolset the module constructs on the page. The module checks its inputs before any\n * step.\n *\n * @remarks\n * The module imports only `@orkestrel/browser` and exports `execute(page, inputs)`, which starts\n * the toolset, performs the steps in order, and destroys the toolset in `finally`.\n * - A parameter with a default compiles to an optional input that falls back to the default; a\n * secret and a parameter without a default compile to a required input, and `inputs` then takes\n * no default. `execute` takes no `inputs` when the journey declares no parameter.\n * - A step passes its action, its arguments, and its target's role and name or its tab's URL and\n * title as literals, with each native binding replaced by its input; a page tool's arguments\n * stay literal. A `type` step whose text binds a secret passes `{ secret: true }`.\n * - `execute` checks its inputs before the toolset starts, as replay refuses them at preparation:\n * an input that names no parameter throws `Error('NAME: no parameter has that name')`, then a\n * required parameter whose input is not a string throws `Error('NAME: the input is missing')`,\n * then a defaulted parameter whose input is neither `undefined` nor a string throws\n * `Error('NAME: the input is not a string')`. A journey without parameters compiles no check. A\n * journey with a required parameter reads `inputs ?? {}` and `inputs?.NAME` in its required\n * checks, so `execute(page)` without inputs reports the first required parameter as missing\n * before a defaulted check reads `inputs.NAME`; a journey whose parameters all have defaults\n * reads `inputs`, which defaults to `{}`.\n * - A journey with a gap compiles to an unconditional throw naming the first gap after the input\n * checks and before the toolset starts, as replay refuses a gap at preparation; each gap step\n * compiles to a comment at its position, with its line terminators escaped, and is listed in\n * `gaps`.\n *\n * The JavaScript module is the TypeScript module without the type import and the annotations.\n * `options.language` selects `'javascript'` or `'typescript'`. Default: `'javascript'`.\n *\n * @param journey - The journey to compile\n * @param options - The target language\n * @returns The module source and the gap step ids in step order\n * @throws BrowserError - Thrown with `BROWSER_JOURNEY_FORMAT` or `BROWSER_JOURNEY_INVALID` when the\n * journey fails validation, before any source is compiled\n * @example\n * ```ts\n * const script = compileBrowserJourney(journey, { language: 'typescript' })\n * // script.source begins with the two `@orkestrel/browser` imports; script.gaps lists the gap ids\n * ```\n */\nexport function compileBrowserJourney(\n\tjourney: BrowserJourney,\n\toptions?: { readonly language?: BrowserCodegenLanguage },\n): BrowserCodegenScript {\n\tvalidateBrowserJourney(journey)\n\tconst typed = options?.language === 'typescript'\n\tconst parameters = Object.entries(journey.parameters)\n\tconst defaulted = parameters.flatMap(([name, parameter]) =>\n\t\tparameter.default === undefined\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tfallback: parameter.default,\n\t\t\t\t\t\t// An inherited member such as `toString` is not an input, so only an own property counts.\n\t\t\t\t\t\tread:\n\t\t\t\t\t\t\tname in Object.prototype\n\t\t\t\t\t\t\t\t? `(Object.hasOwn(inputs, '${name}') ? inputs.${name} : undefined)`\n\t\t\t\t\t\t\t\t: `inputs.${name}`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t)\n\tconst bindings = new Map([\n\t\t...parameters.map(([name]): [string, string] => [name, `inputs.${name}`]),\n\t\t...defaulted.map(({ name, fallback, read }): [string, string] => [\n\t\t\tname,\n\t\t\t`${read} ?? ${compileBrowserJourneyValue(fallback)}`,\n\t\t]),\n\t])\n\tconst shape = parameters\n\t\t.map(\n\t\t\t([name, parameter]) =>\n\t\t\t\t`readonly ${name}${parameter.default === undefined ? '' : '?'}: string`,\n\t\t)\n\t\t.join('; ')\n\tconst required = parameters.filter(([, parameter]) => parameter.default === undefined)\n\tconst inputs =\n\t\tparameters.length === 0\n\t\t\t? ''\n\t\t\t: `, inputs${typed ? `: { ${shape} }` : ''}${required.length === 0 ? ' = {}' : ''}`\n\t// A module with a required parameter declares no `inputs` default, so its checks tolerate an absent object.\n\tconst supplied = required.length === 0 ? 'inputs' : 'inputs ?? {}'\n\tconst preflight =\n\t\tparameters.length === 0\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t`\\tfor (const name of Object.keys(${supplied})) if (!${compileBrowserJourneyValue(parameters.map(([name]) => name))}.includes(name)) throw new Error(name + ': no parameter has that name')`,\n\t\t\t\t\t...required.map(\n\t\t\t\t\t\t([name]) =>\n\t\t\t\t\t\t\t`\\tif (typeof inputs?.${name} !== 'string') throw new Error(${compileBrowserJourneyValue(`${name}: the input is missing`)})`,\n\t\t\t\t\t),\n\t\t\t\t\t// The required checks run first, so `inputs` is an object by the time a defaulted check reads it.\n\t\t\t\t\t...defaulted.map(\n\t\t\t\t\t\t({ name, read }) =>\n\t\t\t\t\t\t\t`\\tif (${read} !== undefined && typeof ${read} !== 'string') throw new Error(${compileBrowserJourneyValue(`${name}: the input is not a string`)})`,\n\t\t\t\t\t),\n\t\t\t\t]\n\tconst gap = journey.steps.find((step) => step.action === 'unresolved')\n\tconst statements = journey.steps.map((step) => {\n\t\tif (step.action === 'unresolved')\n\t\t\treturn `\\t\\t// ${step.id}: ${step.gap ?? ''}; handle it here`.replace(\n\t\t\t\t/[\\n\\r\\u2028\\u2029]/gu,\n\t\t\t\t(terminator) => `\\\\u${terminator.charCodeAt(0).toString(16).padStart(4, '0')}`,\n\t\t\t)\n\t\tconst secret = isBrowserSecretBinding(step, journey.parameters)\n\t\tconst call: JSONValue = {\n\t\t\taction: step.action,\n\t\t\targuments: step.arguments,\n\t\t\t...(step.target === undefined\n\t\t\t\t? {}\n\t\t\t\t: { target: { role: step.target.role, name: step.target.name } }),\n\t\t\t...(step.tab === undefined ? {} : { tab: { url: step.tab.url, title: step.tab.title } }),\n\t\t}\n\t\tconst native = BROWSER_JOURNEY_ACTIONS.some((action) => action === step.action)\n\t\treturn `\\t\\tawait toolset.follow(${compileBrowserJourneyValue(step.id)}, ${compileBrowserJourneyValue(call, native ? bindings : undefined)}${secret ? ', { secret: true }' : ''})`\n\t})\n\tconst source = [\n\t\t...(typed ? [`import type { BrowserPageInterface } from '@orkestrel/browser'`] : []),\n\t\t`import { createBrowserToolset } from '@orkestrel/browser'`,\n\t\t'',\n\t\t`export async function execute(page${typed ? ': BrowserPageInterface' : ''}${inputs})${typed ? ': Promise<void>' : ''} {`,\n\t\t...preflight,\n\t\t...(gap === undefined\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t`\\tthrow new Error(${compileBrowserJourneyValue(`${gap.id}: ${gap.gap ?? ''}; handle it here`)})`,\n\t\t\t\t]),\n\t\t'\\tconst toolset = createBrowserToolset(page)',\n\t\t'\\tawait toolset.start()',\n\t\t'\\ttry {',\n\t\t...statements,\n\t\t'\\t} finally {',\n\t\t'\\t\\tawait toolset.destroy()',\n\t\t'\\t}',\n\t\t'}',\n\t\t'',\n\t].join('\\n')\n\treturn {\n\t\tsource,\n\t\tgaps: journey.steps.filter((step) => step.action === 'unresolved').map((step) => step.id),\n\t}\n}\n\n/**\n * Compiles the element-side actionability pass used before trusted input.\n *\n * @param options - Checks required for the action\n * @returns Async `Runtime.callFunctionOn` function declaration\n */\nexport function compileActionabilityFunction(options: BrowserActionabilityOptions): string {\n\t// Visible means a rendered, non-collapsed box; `style` and `rect` are in scope at the interpolation site.\n\tconst VISIBILITY_SOURCE =\n\t\t\"style.display !== 'none' && style.visibility !== 'hidden' && style.visibility !== 'collapse' && rect.width > 0 && rect.height > 0\"\n\treturn `async function() {\n\tif (!(this instanceof Element) || !this.isConnected) throw new Error('Element is detached')\n\tthis.scrollIntoView({ block: 'center', inline: 'center', behavior: 'instant' })\n\tconst visible = () => {\n\t\tconst style = getComputedStyle(this)\n\t\tconst rect = this.getBoundingClientRect()\n\t\treturn ${VISIBILITY_SOURCE}\n\t}\n\tif (${JSON.stringify(options.visible === true)} && !visible()) throw new Error('Element is not visible')\n\tif (${JSON.stringify(options.enabled === true)} && this.matches(':disabled')) throw new Error('Element is disabled')\n\tif (${JSON.stringify(options.editable === true)} && (this.matches('[readonly]') || (!this.isContentEditable && !('value' in this)))) throw new Error('Element is not editable')\n\tlet previous\n\tfor (let index = 0; index < ${BROWSER_STABLE_FRAME_COUNT}; index += 1) {\n\t\tawait new Promise((resolve) => requestAnimationFrame(resolve))\n\t\tconst rect = this.getBoundingClientRect()\n\t\tconst current = [rect.x, rect.y, rect.width, rect.height]\n\t\tif (${JSON.stringify(options.stable === true)} && previous && current.some((value, part) => value !== previous[part])) {\n\t\t\tindex = 0\n\t\t}\n\t\tprevious = current\n\t}\n\tif (${JSON.stringify(options.events === true)}) {\n\t\tconst rect = this.getBoundingClientRect()\n\t\tconst position = ${JSON.stringify(options.position)}\n\t\tconst x = rect.x + (position?.x ?? rect.width / 2)\n\t\tconst y = rect.y + (position?.y ?? rect.height / 2)\n\t\tconst target = this.ownerDocument.elementFromPoint(x, y)\n\t\tif (target !== this && !this.contains(target)) throw new Error('Element does not receive pointer events')\n\t}\n\treturn true\n}`\n}\n","import type { BrowserTransitionFunction, BrowserTransitionInterface } from './types.js'\n\n/**\n * Runs one asynchronous transition at a time, shared by every caller that joins it.\n *\n * @remarks\n * An entity with a lifecycle runs the same guard around every transition: take\n * the promise already in flight when one exists, otherwise start the work, hold\n * its promise, and release the field afterwards only when it is still this\n * run's. Holding that guard in one place keeps the identity check — the part a\n * hand-written copy drops — identical at every site. The entry guards stay with\n * each entity, because what makes a transition unnecessary is the entity's own\n * state.\n *\n * @example\n * ```ts\n * import { BrowserTransition } from '@orkestrel/browser'\n *\n * const starting = new BrowserTransition()\n * await starting.execute(() => transport.start())\n * const joined = starting.pending // the in-flight promise, or undefined\n * ```\n */\nexport class BrowserTransition<T = void> implements BrowserTransitionInterface<T> {\n\t#pending: Promise<T> | undefined\n\n\tget pending(): Promise<T> | undefined {\n\t\treturn this.#pending\n\t}\n\n\tasync execute(work: BrowserTransitionFunction<T>): Promise<T> {\n\t\tconst active = this.#pending\n\t\tif (active !== undefined) return await active\n\n\t\tconst started = work()\n\t\tthis.#pending = started\n\t\ttry {\n\t\t\treturn await started\n\t\t} finally {\n\t\t\tif (this.#pending === started) this.#pending = undefined\n\t\t}\n\t}\n}\n","import type {\n\tCDPClientEventMap,\n\tCDPClientInterface,\n\tCDPClientOptions,\n\tCDPHandler,\n\tCDPSendOptions,\n\tCDPTransportInterface,\n} from './types.js'\nimport type { EmitterErrorHandler, EmitterInterface } from '@orkestrel/emitter'\nimport { BrowserTransition } from './BrowserTransition.js'\nimport { BROWSER_DEFAULT_TIMEOUT_MS } from './constants.js'\nimport { CDPConnectionError, CDPError, CDPTimeoutError } from './errors.js'\nimport { Emitter } from '@orkestrel/emitter'\nimport { isInteger, isRecord, isString, parseJSON } from '@orkestrel/contract'\n\n// === CDPClient\n\n/**\n * Provides a lightweight Chrome DevTools Protocol client over a {@link CDPTransportInterface}.\n *\n * @remarks\n * Sends JSON-RPC messages over the injected transport and dispatches\n * responses and events. The transport owns the connection itself\n * (WebSocket, pipe, or any other duplex channel); this class owns only\n * the JSON-RPC framing and id/session correlation.\n *\n * Supports session-scoped event subscriptions: a subscription registered\n * without a session id receives the event whatever session carries it, and a\n * session-scoped subscription receives only its own session's events.\n *\n * @example\n * ```ts\n * import { CDPClient } from '@orkestrel/browser'\n *\n * const client = new CDPClient({ transport })\n * await client.connect()\n * const targets = await client.send('Target.getTargets')\n * await client.close()\n * ```\n */\nexport class CDPClient implements CDPClientInterface {\n\treadonly #emitter: Emitter<CDPClientEventMap>\n\treadonly #transport: CDPTransportInterface\n\t#messageId = 0\n\treadonly #pending: Map<\n\t\tnumber,\n\t\t{\n\t\t\tmethod: string\n\t\t\tresolve: (value: unknown) => void\n\t\t\treject: (reason: unknown) => void\n\t\t\ttimer: ReturnType<typeof setTimeout>\n\t\t\tsignal: AbortSignal | undefined\n\t\t\tlistener: (() => void) | undefined\n\t\t}\n\t> = new Map()\n\treadonly #subscriptions: Map<string | undefined, Map<string, Set<CDPHandler>>> = new Map()\n\t#connected = false\n\t#active = false\n\t#wired = false\n\treadonly #timeout: number\n\treadonly #error: EmitterErrorHandler | undefined\n\treadonly #connecting: BrowserTransition = new BrowserTransition()\n\treadonly #closing: BrowserTransition = new BrowserTransition()\n\t#closeRequested = false\n\t// Set while this client is the one closing the transport, so the transport\n\t// `close` a teardown produces reports `close` rather than `drop`.\n\t#expected = false\n\n\tconstructor(options: CDPClientOptions) {\n\t\tthis.#transport = options.transport\n\t\tthis.#timeout = options.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tthis.#error = options.error\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options.on !== undefined ? { on: options.on } : {}),\n\t\t\t...(options.error !== undefined ? { error: options.error } : {}),\n\t\t})\n\t}\n\n\tget emitter(): EmitterInterface<CDPClientEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget connected(): boolean {\n\t\treturn this.#connected\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tconst closing = this.#closing.pending\n\t\tif (closing !== undefined) await closing\n\t\tif (this.#connected) return\n\t\tconst active = this.#connecting.pending\n\t\tif (active !== undefined) return await active\n\n\t\tthis.#closeRequested = false\n\t\tthis.#expected = false\n\t\tawait this.#connecting.execute(() => this.#connect())\n\t}\n\n\t/**\n\t * Closes the transport and re-establishes a fresh connection.\n\t *\n\t * @remarks\n\t * Client-level subscriptions (`subscribe`/`unsubscribe` registrations)\n\t * survive `close()` and remain active after the reconnect — only pending\n\t * in-flight requests are rejected. This lets a caller reconnect a dropped\n\t * transport without re-registering every handler.\n\t */\n\tasync reconnect(): Promise<void> {\n\t\tawait this.close()\n\t\tawait this.connect()\n\t}\n\n\tasync send(\n\t\tmethod: string,\n\t\tparams?: Readonly<Record<string, unknown>>,\n\t\toptions?: CDPSendOptions,\n\t): Promise<unknown> {\n\t\tif (!this.#connected) {\n\t\t\tthrow new CDPConnectionError('CDP client is not connected', { method })\n\t\t}\n\t\tif (options?.signal?.aborted === true) throw options.signal.reason\n\n\t\tconst id = this.#nextId()\n\t\tconst message: Record<string, unknown> = { id, method }\n\n\t\tif (params !== undefined) {\n\t\t\tmessage['params'] = params\n\t\t}\n\t\tif (options?.session !== undefined) {\n\t\t\tmessage['sessionId'] = options.session\n\t\t}\n\n\t\tconst serialized = JSON.stringify(message)\n\t\tconst effectiveTimeout = options?.timeout ?? this.#timeout\n\t\tconst signal = options?.signal\n\n\t\treturn new Promise<unknown>((resolve, reject) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tthis.#settle(id)?.reject(\n\t\t\t\t\tnew CDPTimeoutError(`CDP request timed out: ${method}`, {\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\ttimeout: effectiveTimeout,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}, effectiveTimeout)\n\t\t\tconst listener = signal === undefined ? undefined : this.#abort(id, signal)\n\t\t\tthis.#pending.set(id, { method, resolve, reject, timer, signal, listener })\n\t\t\tif (listener !== undefined) signal?.addEventListener('abort', listener, { once: true })\n\n\t\t\tthis.#transport.send(serialized).catch((thrown: unknown) => {\n\t\t\t\tthis.#settle(id)?.reject(thrown)\n\t\t\t})\n\t\t})\n\t}\n\n\tsubscribe(method: string, handler: CDPHandler, session?: string): void {\n\t\tlet methods = this.#subscriptions.get(session)\n\t\tif (methods === undefined) {\n\t\t\tmethods = new Map()\n\t\t\tthis.#subscriptions.set(session, methods)\n\t\t}\n\t\tlet handlers = methods.get(method)\n\t\tif (handlers === undefined) {\n\t\t\thandlers = new Set()\n\t\t\tmethods.set(method, handlers)\n\t\t}\n\t\thandlers.add(handler)\n\t}\n\n\tunsubscribe(method: string, handler: CDPHandler, session?: string): void {\n\t\tconst methods = this.#subscriptions.get(session)\n\t\tif (methods === undefined) return\n\t\tconst handlers = methods.get(method)\n\t\tif (handlers !== undefined) {\n\t\t\thandlers.delete(handler)\n\t\t\tif (handlers.size === 0) methods.delete(method)\n\t\t}\n\t\tif (methods.size === 0) this.#subscriptions.delete(session)\n\t}\n\n\t/**\n\t * Closes the transport and rejects all pending requests.\n\t *\n\t * @remarks\n\t * Subscriptions registered through `subscribe()` are client-level\n\t * registrations, not connection-level state — they survive `close()`\n\t * (and a subsequent `reconnect()`/`connect()`) and keep firing once the\n\t * transport is active again. Only pending requests are rejected here.\n\t * If `close()` is called while `connect()` is still awaiting\n\t * `transport.start()`, the in-flight connect is rejected and the\n\t * transport is closed deterministically once `start()` resolves.\n\t */\n\tasync close(): Promise<void> {\n\t\tawait this.#closing.execute(() => this.#close())\n\t}\n\n\t// === Private helpers\n\n\tasync #connect(): Promise<void> {\n\t\tif (!this.#wired) {\n\t\t\tthis.#transport.emitter.on('message', (data) => this.#onMessage(data))\n\t\t\tthis.#transport.emitter.on('close', () => this.#onClose())\n\t\t\tthis.#transport.emitter.on('error', (error) => this.#onError(error))\n\t\t\tthis.#wired = true\n\t\t}\n\n\t\tawait this.#transport.start()\n\t\tthis.#active = true\n\n\t\tif (this.#closeRequested) {\n\t\t\tthis.#closeRequested = false\n\t\t\tthis.#expected = true\n\t\t\ttry {\n\t\t\t\tawait this.#transport.close()\n\t\t\t} finally {\n\t\t\t\tthis.#active = false\n\t\t\t}\n\t\t\tthis.#emitter.emit('close')\n\t\t\tthrow new CDPConnectionError('CDP client was closed while connecting', {\n\t\t\t\tmethod: 'connect',\n\t\t\t})\n\t\t}\n\n\t\tthis.#connected = true\n\t\tthis.#emitter.emit('connect')\n\t}\n\n\tasync #close(): Promise<void> {\n\t\tconst connecting = this.#connecting.pending\n\t\tif (connecting !== undefined) {\n\t\t\tthis.#closeRequested = true\n\t\t\tawait connecting.catch(() => undefined)\n\t\t\t// The in-flight attempt may have already flipped #connected to\n\t\t\t// true before observing #closeRequested (race between the\n\t\t\t// attempt's final steps and #closeRequested being set here).\n\t\t\t// Fall through to the normal connected-close path instead of\n\t\t\t// returning early, or the close would be silently lost.\n\t\t}\n\n\t\tif (!this.#connected && !this.#active) return\n\n\t\tthis.#connected = false\n\n\t\t// Reject all pending requests\n\t\tfor (const [id, entry] of this.#pending) {\n\t\t\tthis.#settle(id)?.reject(\n\t\t\t\tnew CDPConnectionError('CDP connection closed', { method: entry.method }),\n\t\t\t)\n\t\t}\n\n\t\tthis.#expected = true\n\t\ttry {\n\t\t\tawait this.#transport.close()\n\t\t} finally {\n\t\t\tthis.#active = false\n\t\t}\n\t\tthis.#emitter.emit('close')\n\t}\n\n\t// A settled or already-removed entry makes the returned listener a no-op.\n\t#abort(id: number, signal: AbortSignal): () => void {\n\t\treturn () => {\n\t\t\tthis.#settle(id)?.reject(signal.reason)\n\t\t}\n\t}\n\n\t// Takes one request out of flight: the entry leaves the map, its timer stops, and the abort\n\t// listener it holds on the caller's signal is released, so every settlement path leaves the\n\t// signal as it found it. The caller resolves or rejects the returned entry.\n\t#settle(\n\t\tid: number,\n\t):\n\t\t| { method: string; resolve: (value: unknown) => void; reject: (reason: unknown) => void }\n\t\t| undefined {\n\t\tconst entry = this.#pending.get(id)\n\t\tif (entry === undefined) return undefined\n\t\tthis.#pending.delete(id)\n\t\tclearTimeout(entry.timer)\n\t\tif (entry.listener !== undefined) entry.signal?.removeEventListener('abort', entry.listener)\n\t\treturn entry\n\t}\n\n\t#nextId(): number {\n\t\tthis.#messageId += 1\n\t\treturn this.#messageId\n\t}\n\n\t#onClose(): void {\n\t\tthis.#connected = false\n\t\tthis.#active = false\n\n\t\t// Reject all pending requests\n\t\tfor (const [id, entry] of this.#pending) {\n\t\t\tthis.#settle(id)?.reject(\n\t\t\t\tnew CDPConnectionError('CDP connection closed', { method: entry.method }),\n\t\t\t)\n\t\t}\n\t\tif (!this.#expected) this.#emitter.emit('drop')\n\t}\n\n\t#onError(error: unknown): void {\n\t\tthis.#connected = false\n\t\tfor (const [id, entry] of this.#pending) {\n\t\t\tthis.#settle(id)?.reject(\n\t\t\t\tnew CDPConnectionError(`CDP connection failed: ${String(error)}`, {\n\t\t\t\t\tmethod: entry.method,\n\t\t\t\t\terror,\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t\tthis.#emitter.emit('error', error)\n\t}\n\n\t#onMessage(data: string): void {\n\t\tconst parsed = parseJSON(data)\n\t\tif (!isRecord(parsed)) return\n\n\t\t// Response to a pending request\n\t\tif (isInteger(parsed['id'])) {\n\t\t\tconst id = parsed['id']\n\t\t\tconst entry = this.#settle(id)\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst errorValue = parsed['error']\n\t\t\t\tif (isRecord(errorValue)) {\n\t\t\t\t\tconst message = isString(errorValue['message']) ? errorValue['message'] : 'CDP error'\n\t\t\t\t\tconst context: Record<string, unknown> = { method: entry.method }\n\t\t\t\t\tif ('code' in errorValue) context['code'] = errorValue['code']\n\t\t\t\t\tcontext['message'] = message\n\t\t\t\t\tif ('data' in errorValue) context['data'] = errorValue['data']\n\t\t\t\t\tentry.reject(new CDPError(message, context))\n\t\t\t\t} else {\n\t\t\t\t\tentry.resolve('result' in parsed ? parsed['result'] : undefined)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\t// CDP event\n\t\tif (isString(parsed['method'])) {\n\t\t\tconst method = parsed['method']\n\t\t\tconst rawParams = parsed['params']\n\t\t\tconst params: Readonly<Record<string, unknown>> = isRecord(rawParams)\n\t\t\t\t? rawParams\n\t\t\t\t: Object.freeze({})\n\n\t\t\tconst global = this.#subscriptions.get(undefined)?.get(method)\n\t\t\tif (global !== undefined) this.#dispatch(global, method, params)\n\n\t\t\tconst session = parsed['sessionId']\n\t\t\tif (isString(session)) {\n\t\t\t\tconst scoped = this.#subscriptions.get(session)?.get(method)\n\t\t\t\tif (scoped !== undefined) this.#dispatch(scoped, method, params)\n\t\t\t}\n\t\t}\n\t}\n\n\t#dispatch(\n\t\thandlers: ReadonlySet<CDPHandler>,\n\t\tmethod: string,\n\t\tparams: Readonly<Record<string, unknown>>,\n\t): void {\n\t\tfor (const handler of [...handlers]) {\n\t\t\ttry {\n\t\t\t\thandler(params)\n\t\t\t} catch (thrown) {\n\t\t\t\t// One observer must not prevent sibling observers from receiving the\n\t\t\t\t// event, so the throw is reported rather than propagated.\n\t\t\t\tthis.#error?.(thrown, method)\n\t\t\t}\n\t\t}\n\t}\n}\n","import type {\n\tBrowserAccessibilityInterface,\n\tBrowserAccessibilityOptions,\n\tBrowserAccessibilitySnapshot,\n\tBrowserFrameInterface,\n} from './types.js'\nimport { readBrowserAccessibility, validateBrowserAccessibilityOptions } from './helpers.js'\n\n/**\n * Captures Chromium Accessibility-domain snapshots for one page.\n *\n * @example\n * ```ts\n * import { BrowserAccessibility } from '@orkestrel/browser'\n *\n * const accessibility = new BrowserAccessibility(page)\n * const tree = await accessibility.snapshot({ depth: 3 }) // { roots, nodes }\n * ```\n */\nexport class BrowserAccessibility implements BrowserAccessibilityInterface {\n\treadonly #frame: BrowserFrameInterface\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tasync snapshot(options?: BrowserAccessibilityOptions): Promise<BrowserAccessibilitySnapshot> {\n\t\tvalidateBrowserAccessibilityOptions(options)\n\t\tawait this.#frame.send('Accessibility.enable')\n\t\ttry {\n\t\t\tconst result =\n\t\t\t\toptions?.root === undefined\n\t\t\t\t\t? await this.#frame.send('Accessibility.getFullAXTree', {\n\t\t\t\t\t\t\tdepth: options?.depth,\n\t\t\t\t\t\t\tframeId: this.#frame.id,\n\t\t\t\t\t\t})\n\t\t\t\t\t: await this.#frame.send('Accessibility.getPartialAXTree', {\n\t\t\t\t\t\t\tbackendNodeId: options.root,\n\t\t\t\t\t\t\tfetchRelatives: true,\n\t\t\t\t\t\t})\n\t\t\treturn readBrowserAccessibility(result)\n\t\t} finally {\n\t\t\tawait this.#frame.send('Accessibility.disable').catch(() => undefined)\n\t\t}\n\t}\n}\n","import type { BrowserClockInterface, BrowserFrameInterface } from './types.js'\nimport { BROWSER_DEFAULT_TIMEOUT_MS } from './constants.js'\nimport { BrowserError } from './errors.js'\nimport { settleBrowserTeardown } from './helpers.js'\nimport { isFiniteNumber } from '@orkestrel/contract'\n\n/**\n * Controls the Chromium virtual-time budget for deterministic page timers.\n *\n * @example\n * ```ts\n * import { BrowserClock } from '@orkestrel/browser'\n *\n * const clock = new BrowserClock(page)\n * await clock.install(Date.UTC(2026, 0, 1))\n * await clock.advance(5_000)\n * await clock.uninstall()\n * ```\n */\nexport class BrowserClock implements BrowserClockInterface {\n\treadonly #frame: BrowserFrameInterface\n\t#installed = false\n\t#advancing = false\n\t#budgetResolve: (() => void) | undefined\n\treadonly #budgetHandler = this.#handleBudget.bind(this)\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tget installed(): boolean {\n\t\treturn this.#installed\n\t}\n\n\tasync install(time = Date.now()): Promise<void> {\n\t\tif (this.#installed) throw new BrowserError('Browser clock is already installed')\n\t\tif (!isFiniteNumber(time) || time < 0) {\n\t\t\tthrow new BrowserError('Browser clock time must be a non-negative finite epoch', undefined, {\n\t\t\t\ttime,\n\t\t\t})\n\t\t}\n\t\tawait this.#frame.send('Emulation.setVirtualTimePolicy', {\n\t\t\tpolicy: 'pause',\n\t\t\tinitialVirtualTime: time / 1000,\n\t\t})\n\t\tthis.#installed = true\n\t}\n\n\tasync pause(): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#idle()\n\t\tawait this.#frame.send('Emulation.setVirtualTimePolicy', { policy: 'pause' })\n\t}\n\n\tasync resume(): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#idle()\n\t\tawait this.#frame.send('Emulation.setVirtualTimePolicy', {\n\t\t\tpolicy: 'advance',\n\t\t\tmaxVirtualTimeTaskStarvationCount: 10_000,\n\t\t})\n\t}\n\n\tasync advance(ms: number): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#idle()\n\t\tif (!isFiniteNumber(ms) || ms < 0) {\n\t\t\tthrow new BrowserError('Browser clock advance must be non-negative and finite', undefined, {\n\t\t\t\tms,\n\t\t\t})\n\t\t}\n\t\tif (ms === 0) {\n\t\t\tawait this.pause()\n\t\t\treturn\n\t\t}\n\t\tconst deferred = Promise.withResolvers<void>()\n\t\tthis.#advancing = true\n\t\tthis.#budgetResolve = deferred.resolve\n\t\ttry {\n\t\t\tawait this.#frame.subscribe('Emulation.virtualTimeBudgetExpired', this.#budgetHandler)\n\t\t} catch (error) {\n\t\t\tthis.#budgetResolve = undefined\n\t\t\tthis.#advancing = false\n\t\t\tthrow error\n\t\t}\n\t\tconst timer = setTimeout(() => {\n\t\t\tdeferred.reject(new BrowserError('Browser virtual-time budget timed out'))\n\t\t}, BROWSER_DEFAULT_TIMEOUT_MS)\n\t\tlet failure: unknown\n\t\ttry {\n\t\t\tawait this.#frame.send('Emulation.setVirtualTimePolicy', {\n\t\t\t\tpolicy: 'advance',\n\t\t\t\tbudget: ms,\n\t\t\t\tmaxVirtualTimeTaskStarvationCount: 10_000,\n\t\t\t})\n\t\t\tawait deferred.promise\n\t\t} catch (error) {\n\t\t\tfailure = error\n\t\t} finally {\n\t\t\tclearTimeout(timer)\n\t\t\tthis.#budgetResolve = undefined\n\t\t\tconst settled = await settleBrowserTeardown(\n\t\t\t\t() => this.#frame.unsubscribe('Emulation.virtualTimeBudgetExpired', this.#budgetHandler),\n\t\t\t\t() => this.#frame.send('Emulation.setVirtualTimePolicy', { policy: 'pause' }),\n\t\t\t)\n\t\t\tfailure ??= settled\n\t\t\tthis.#advancing = false\n\t\t}\n\t\tif (failure !== undefined) throw failure\n\t}\n\n\tasync uninstall(): Promise<void> {\n\t\tif (!this.#installed) return\n\t\tthis.#idle()\n\t\tawait this.#frame.send('Emulation.setVirtualTimePolicy', {\n\t\t\tpolicy: 'advance',\n\t\t\tmaxVirtualTimeTaskStarvationCount: 10_000,\n\t\t})\n\t\tthis.#installed = false\n\t}\n\n\t#assert(): void {\n\t\tif (!this.#installed) throw new BrowserError('Browser clock is not installed')\n\t}\n\n\t#idle(): void {\n\t\tif (this.#advancing) throw new BrowserError('Browser clock advance is already active')\n\t}\n\n\t#handleBudget(): void {\n\t\tthis.#budgetResolve?.()\n\t}\n}\n","import type {\n\tBrowserCoverageInterface,\n\tBrowserCoverageOptions,\n\tBrowserCoverageResult,\n\tBrowserFrameInterface,\n} from './types.js'\nimport {\n\treadBrowserScriptCoverage,\n\treadBrowserStyleCoverage,\n\tsettleBrowserTeardown,\n} from './helpers.js'\nimport { BrowserError } from './errors.js'\n\n/**\n * Collects JavaScript precise coverage and CSS rule usage for one page target.\n *\n * @example\n * ```ts\n * import { BrowserCoverage } from '@orkestrel/browser'\n *\n * const coverage = new BrowserCoverage(page)\n * await coverage.start({ javascript: true, css: true })\n * const usage = await coverage.stop() // { scripts, styles }\n * ```\n */\nexport class BrowserCoverage implements BrowserCoverageInterface {\n\treadonly #frame: BrowserFrameInterface\n\t#active = false\n\t#options: BrowserCoverageOptions | undefined\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tget active(): boolean {\n\t\treturn this.#active\n\t}\n\n\tasync start(options?: BrowserCoverageOptions): Promise<void> {\n\t\tif (this.#active) throw new BrowserError('Browser coverage is already active')\n\t\tconst javascript = options?.javascript ?? true\n\t\tconst css = options?.css ?? true\n\t\tif (!javascript && !css) {\n\t\t\tthrow new BrowserError('Browser coverage requires JavaScript, CSS, or both')\n\t\t}\n\t\tlet profiler = false\n\t\tlet precise = false\n\t\tlet dom = false\n\t\tlet styles = false\n\t\tlet rules = false\n\t\ttry {\n\t\t\tif (javascript) {\n\t\t\t\tawait this.#frame.send('Profiler.enable')\n\t\t\t\tprofiler = true\n\t\t\t\tawait this.#frame.send('Profiler.startPreciseCoverage', {\n\t\t\t\t\tcallCount: true,\n\t\t\t\t\tdetailed: options?.detailed ?? true,\n\t\t\t\t\tallowTriggeredUpdates: false,\n\t\t\t\t})\n\t\t\t\tprecise = true\n\t\t\t}\n\t\t\tif (css) {\n\t\t\t\tawait this.#frame.send('DOM.enable')\n\t\t\t\tdom = true\n\t\t\t\tawait this.#frame.send('CSS.enable')\n\t\t\t\tstyles = true\n\t\t\t\tawait this.#frame.send('CSS.startRuleUsageTracking')\n\t\t\t\trules = true\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (rules) {\n\t\t\t\tawait this.#frame.send('CSS.stopRuleUsageTracking').catch(() => undefined)\n\t\t\t}\n\t\t\tif (styles) await this.#frame.send('CSS.disable').catch(() => undefined)\n\t\t\tif (dom) await this.#frame.send('DOM.disable').catch(() => undefined)\n\t\t\tif (precise) {\n\t\t\t\tawait this.#frame.send('Profiler.stopPreciseCoverage').catch(() => undefined)\n\t\t\t}\n\t\t\tif (profiler) await this.#frame.send('Profiler.disable').catch(() => undefined)\n\t\t\tthrow error\n\t\t}\n\t\tthis.#options = options\n\t\tthis.#active = true\n\t}\n\n\tasync stop(): Promise<BrowserCoverageResult> {\n\t\tif (!this.#active) throw new BrowserError('Browser coverage is not active')\n\t\tthis.#active = false\n\t\tconst javascript = this.#options?.javascript ?? true\n\t\tconst css = this.#options?.css ?? true\n\t\tlet scripts: BrowserCoverageResult['scripts'] = []\n\t\tlet styles: BrowserCoverageResult['styles'] = []\n\t\tconst failure = await settleBrowserTeardown(\n\t\t\tasync () => {\n\t\t\t\tif (javascript) scripts = await this.#stopJavaScript()\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tif (css) styles = await this.#stopCSS()\n\t\t\t},\n\t\t)\n\t\tthis.#options = undefined\n\t\tif (failure !== undefined) throw failure\n\t\treturn { scripts, styles }\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tif (!this.#active) return\n\t\tawait this.stop().catch(() => undefined)\n\t}\n\n\tasync #stopJavaScript(): Promise<BrowserCoverageResult['scripts']> {\n\t\tlet result: unknown\n\t\tconst failure = await settleBrowserTeardown(\n\t\t\tasync () => {\n\t\t\t\tresult = await this.#frame.send('Profiler.takePreciseCoverage')\n\t\t\t},\n\t\t\t() => this.#frame.send('Profiler.stopPreciseCoverage'),\n\t\t\t() => this.#frame.send('Profiler.disable'),\n\t\t)\n\t\tif (failure !== undefined) throw failure\n\t\treturn readBrowserScriptCoverage(result)\n\t}\n\n\tasync #stopCSS(): Promise<BrowserCoverageResult['styles']> {\n\t\tlet result: unknown\n\t\tconst failure = await settleBrowserTeardown(\n\t\t\tasync () => {\n\t\t\t\tresult = await this.#frame.send('CSS.stopRuleUsageTracking')\n\t\t\t},\n\t\t\t() => this.#frame.send('CSS.disable'),\n\t\t\t() => this.#frame.send('DOM.disable'),\n\t\t)\n\t\tif (failure !== undefined) throw failure\n\t\treturn readBrowserStyleCoverage(result)\n\t}\n}\n","import type {\n\tBrowserCookie,\n\tBrowserCookieFilter,\n\tBrowserCookieInput,\n\tBrowserCookieManagerInterface,\n\tCDPClientInterface,\n} from './types.js'\nimport { cookieToProtocol, matchesBrowserCookieURL, readBrowserCookies } from './helpers.js'\nimport { isRecord } from '@orkestrel/contract'\nimport { BrowserError } from './errors.js'\n\n/**\n * Performs cookie operations isolated to one browser context.\n *\n * @example\n * ```ts\n * import { BrowserCookieManager } from '@orkestrel/browser'\n *\n * const cookies = new BrowserCookieManager(client)\n * await cookies.set([{ name: 'session', value: 'value', url: 'https://example.com/' }])\n * const current = await cookies.cookies(['https://example.com/'])\n * ```\n */\nexport class BrowserCookieManager implements BrowserCookieManagerInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #context: string | undefined\n\n\tconstructor(client: CDPClientInterface, context?: string) {\n\t\tthis.#client = client\n\t\tthis.#context = context\n\t}\n\n\tasync cookies(urls?: readonly string[]): Promise<readonly BrowserCookie[]> {\n\t\tconst params: Record<string, unknown> = {}\n\t\tif (this.#context !== undefined) params['browserContextId'] = this.#context\n\t\tconst result = await this.#client.send('Storage.getCookies', params)\n\t\tconst cookies = readBrowserCookies(result)\n\t\tif (urls === undefined || urls.length === 0) return cookies\n\n\t\treturn cookies.filter((cookie) => urls.some((value) => matchesBrowserCookieURL(cookie, value)))\n\t}\n\n\tasync set(cookies: readonly BrowserCookieInput[]): Promise<void> {\n\t\tif (cookies.length === 0) return\n\t\tconst params: Record<string, unknown> = {\n\t\t\tcookies: cookies.map(cookieToProtocol),\n\t\t}\n\t\tif (this.#context !== undefined) params['browserContextId'] = this.#context\n\t\tawait this.#client.send('Storage.setCookies', params)\n\t}\n\n\tasync clear(filter?: BrowserCookieFilter): Promise<void> {\n\t\tconst params: Record<string, unknown> = {}\n\t\tif (this.#context !== undefined) params['browserContextId'] = this.#context\n\t\tif (filter === undefined) {\n\t\t\tawait this.#client.send('Storage.clearCookies', params)\n\t\t\treturn\n\t\t}\n\n\t\tconst retained = (await this.cookies()).filter((cookie) => {\n\t\t\tif (filter.name !== undefined && cookie.name !== filter.name) return true\n\t\t\tif (filter.domain !== undefined && cookie.domain !== filter.domain) return true\n\t\t\tif (filter.path !== undefined && cookie.path !== filter.path) return true\n\t\t\treturn false\n\t\t})\n\t\tawait this.#client.send('Storage.clearCookies', params)\n\t\tif (retained.length === 0) return\n\t\tconst cookies = retained.map((cookie) =>\n\t\t\tcookieToProtocol({\n\t\t\t\tname: cookie.name,\n\t\t\t\tvalue: cookie.value,\n\t\t\t\tdomain: cookie.domain,\n\t\t\t\tpath: cookie.path,\n\t\t\t\texpires: cookie.expires,\n\t\t\t\thttp: cookie.http,\n\t\t\t\tsecure: cookie.secure,\n\t\t\t\t...(cookie.site !== undefined ? { site: cookie.site } : {}),\n\t\t\t\t...(cookie.partition !== undefined ? { partition: cookie.partition } : {}),\n\t\t\t}),\n\t\t)\n\t\tconst restore: Record<string, unknown> = { cookies }\n\t\tif (this.#context !== undefined) restore['browserContextId'] = this.#context\n\t\tconst result = await this.#client.send('Storage.setCookies', restore)\n\t\tif (result !== undefined && !isRecord(result)) {\n\t\t\tthrow new BrowserError('Browser cookie restore returned a malformed result')\n\t\t}\n\t}\n}\n","import type {\n\tBrowserEmulationManagerInterface,\n\tBrowserEmulationOptions,\n\tBrowserPageInterface,\n\tBrowserPagesFunction,\n} from './types.js'\nimport { mediaToFeatures, validateBrowserEmulationOptions } from './helpers.js'\n\n/**\n * Applies rendering, identity, location, and network emulation for context pages.\n *\n * @example\n * ```ts\n * import { BrowserEmulationManager } from '@orkestrel/browser'\n *\n * const emulation = new BrowserEmulationManager(() => context.pages())\n * await emulation.apply({ locale: 'en-US', media: { scheme: 'dark' } })\n * await emulation.clear()\n * ```\n */\nexport class BrowserEmulationManager implements BrowserEmulationManagerInterface {\n\treadonly #pages: BrowserPagesFunction\n\t#options: BrowserEmulationOptions | undefined\n\n\tconstructor(pages: BrowserPagesFunction, options?: BrowserEmulationOptions) {\n\t\tif (options !== undefined) validateBrowserEmulationOptions(options)\n\t\tthis.#pages = pages\n\t\tthis.#options = options\n\t}\n\n\tasync apply(options: BrowserEmulationOptions): Promise<void> {\n\t\tvalidateBrowserEmulationOptions(options)\n\t\tconst previous = this.#options\n\t\tconst changed: BrowserPageInterface[] = []\n\t\ttry {\n\t\t\tfor (const page of this.#pages()) {\n\t\t\t\tchanged.push(page)\n\t\t\t\tif (previous !== undefined) await this.#clearPage(page, previous)\n\t\t\t\tawait this.#configurePage(page, options)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfor (const page of changed.reverse()) {\n\t\t\t\tawait this.#clearPage(page, options).catch(() => undefined)\n\t\t\t\tif (previous !== undefined) {\n\t\t\t\t\tawait this.#configurePage(page, previous).catch(() => undefined)\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t\tthis.#options = options\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tconst previous = this.#options\n\t\tif (previous === undefined) return\n\t\tconst changed: BrowserPageInterface[] = []\n\t\ttry {\n\t\t\tfor (const page of this.#pages()) {\n\t\t\t\tchanged.push(page)\n\t\t\t\tawait this.#clearPage(page, previous)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfor (const page of changed.reverse()) {\n\t\t\t\tawait this.#clearPage(page, previous).catch(() => undefined)\n\t\t\t\tawait this.#configurePage(page, previous).catch(() => undefined)\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t\tthis.#options = undefined\n\t}\n\n\tasync attach(page: BrowserPageInterface): Promise<void> {\n\t\tconst options = this.#options\n\t\tif (options === undefined) return\n\t\ttry {\n\t\t\tawait this.#configurePage(page, options)\n\t\t} catch (error) {\n\t\t\tawait this.#clearPage(page, options).catch(() => undefined)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #configurePage(\n\t\tpage: BrowserPageInterface,\n\t\toptions: BrowserEmulationOptions,\n\t): Promise<void> {\n\t\tif (options.viewport !== undefined) {\n\t\t\tawait page.send('Emulation.setDeviceMetricsOverride', {\n\t\t\t\twidth: options.viewport.width,\n\t\t\t\theight: options.viewport.height,\n\t\t\t\tdeviceScaleFactor: options.viewport.scale ?? 1,\n\t\t\t\tmobile: options.viewport.mobile ?? false,\n\t\t\t\tscreenOrientation:\n\t\t\t\t\toptions.viewport.landscape === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\ttype: options.viewport.landscape ? 'landscapePrimary' : 'portraitPrimary',\n\t\t\t\t\t\t\t\tangle: options.viewport.landscape ? 90 : 0,\n\t\t\t\t\t\t\t},\n\t\t\t})\n\t\t\tawait page.send('Emulation.setTouchEmulationEnabled', {\n\t\t\t\tenabled: options.viewport.touch ?? false,\n\t\t\t})\n\t\t}\n\t\tif (options.user !== undefined) {\n\t\t\tawait page.send('Emulation.setUserAgentOverride', {\n\t\t\t\tuserAgent: options.user.value,\n\t\t\t\tacceptLanguage: options.user.language,\n\t\t\t\tplatform: options.user.platform,\n\t\t\t})\n\t\t}\n\t\tif (options.locale !== undefined) {\n\t\t\tawait page.send('Emulation.setLocaleOverride', { locale: options.locale })\n\t\t}\n\t\tif (options.timezone !== undefined) {\n\t\t\tawait page.send('Emulation.setTimezoneOverride', { timezoneId: options.timezone })\n\t\t}\n\t\tif (options.geolocation !== undefined) {\n\t\t\tawait page.send('Emulation.setGeolocationOverride', {\n\t\t\t\tlatitude: options.geolocation.latitude,\n\t\t\t\tlongitude: options.geolocation.longitude,\n\t\t\t\taccuracy: options.geolocation.accuracy,\n\t\t\t})\n\t\t}\n\t\tif (options.media !== undefined) {\n\t\t\tawait page.send('Emulation.setEmulatedMedia', {\n\t\t\t\tmedia: options.media.output ?? '',\n\t\t\t\tfeatures: mediaToFeatures(options.media),\n\t\t\t})\n\t\t}\n\t\tif (options.offline !== undefined) {\n\t\t\tawait page.network.offline(options.offline)\n\t\t}\n\t\tif (options.headers !== undefined) {\n\t\t\tawait page.network.headers(options.headers)\n\t\t}\n\t\tif (options.credentials !== undefined) {\n\t\t\tawait page.network.credentials(options.credentials)\n\t\t}\n\t}\n\n\tasync #clearPage(page: BrowserPageInterface, options: BrowserEmulationOptions): Promise<void> {\n\t\tif (options.viewport !== undefined) {\n\t\t\tawait page.send('Emulation.clearDeviceMetricsOverride')\n\t\t\tawait page.send('Emulation.setTouchEmulationEnabled', { enabled: false })\n\t\t}\n\t\tif (options.user !== undefined) {\n\t\t\tawait page.send('Emulation.setUserAgentOverride', { userAgent: '' })\n\t\t}\n\t\tif (options.locale !== undefined) {\n\t\t\tawait page.send('Emulation.setLocaleOverride', { locale: '' })\n\t\t}\n\t\tif (options.timezone !== undefined) {\n\t\t\tawait page.send('Emulation.setTimezoneOverride', { timezoneId: '' })\n\t\t}\n\t\tif (options.geolocation !== undefined) {\n\t\t\tawait page.send('Emulation.clearGeolocationOverride')\n\t\t}\n\t\tif (options.media !== undefined) {\n\t\t\tawait page.send('Emulation.setEmulatedMedia', { media: '', features: [] })\n\t\t}\n\t\tif (options.offline !== undefined) {\n\t\t\tawait page.network.offline(false)\n\t\t}\n\t\tif (options.headers !== undefined) {\n\t\t\tawait page.network.headers({})\n\t\t}\n\t\tif (options.credentials !== undefined) await page.network.credentials(undefined)\n\t}\n}\n","import type {\n\tBrowserCodegenGesture,\n\tBrowserCodegenInterface,\n\tBrowserCodegenLanguage,\n\tBrowserCodegenScript,\n\tBrowserJourney,\n\tBrowserJourneyStep,\n\tBrowserJourneyStepInput,\n\tBrowserJourneyTarget,\n\tBrowserRecorderEventMap,\n\tBrowserRecorderOptions,\n\tCDPClientInterface,\n\tCDPHandler,\n} from '../types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { isArray, isInteger, isRecord, isString } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { BrowserTransition } from '../BrowserTransition.js'\nimport {\n\tBROWSER_CODEGEN_BINDING_NAME,\n\tBROWSER_CODEGEN_SOURCE,\n\tBROWSER_INTERACTIVE_ROLES,\n} from '../constants.js'\nimport { compileBrowserJourney } from '../compilers.js'\nimport { BrowserError } from '../errors.js'\nimport {\n\tbuildBrowserJourney,\n\tcollectBrowserJourneyTextBindings,\n\tderiveBrowserJourneySecret,\n\treadBrowserAXValue,\n\treadBrowserFrames,\n} from '../helpers.js'\nimport { parseCodegenActionPayload } from '../parsers.js'\n\n/**\n * Records semantic page gestures and compiles them into a journey module.\n * @example\n * const recorder = await page.codegen()\n * await recorder.stop()\n * const script = recorder.script({ name: \"add-note\", description: \"Add a note\" })\n */\nexport class BrowserCodegen implements BrowserCodegenInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #session: string\n\treadonly #frames: (() => readonly string[]) | undefined\n\treadonly #emitter: Emitter<BrowserRecorderEventMap>\n\treadonly #starting = new BrowserTransition()\n\treadonly #stopping = new BrowserTransition<readonly BrowserJourneyStep[]>()\n\treadonly #sessions = new Map<\n\t\tstring,\n\t\t{\n\t\t\treadonly handlers: ReadonlyArray<readonly [string, CDPHandler]>\n\t\t\treadonly contexts: Set<number>\n\t\t\treadonly attempt: Promise<void>\n\t\t}\n\t>()\n\treadonly #scripts = new Map<string, string>()\n\t#started = false\n\t#shutdown: Promise<void> | undefined\n\t#queue: Promise<void> = Promise.resolve()\n\t#steps: readonly BrowserJourneyStep[] = []\n\t#pending: { readonly key: string; readonly step: BrowserJourneyStepInput } | undefined\n\t#enter: string | undefined\n\t#epoch = 0\n\t#frame: string | undefined\n\n\tconstructor(\n\t\tclient: CDPClientInterface,\n\t\tsession: string,\n\t\toptions?: BrowserRecorderOptions,\n\t\tframes?: () => readonly string[],\n\t) {\n\t\tthis.#client = client\n\t\tthis.#session = session\n\t\tthis.#frames = frames\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t}\n\tget emitter(): EmitterInterface<BrowserRecorderEventMap> {\n\t\treturn this.#emitter\n\t}\n\tget started(): boolean {\n\t\treturn this.#started\n\t}\n\n\tasync start(): Promise<void> {\n\t\tif (this.#shutdown !== undefined || this.#emitter.destroyed)\n\t\t\tthrow new BrowserError('The recorder was destroyed')\n\t\tawait this.#stopping.pending\n\t\tif (this.#starting.pending !== undefined) return await this.#starting.pending\n\t\tif (this.#started) return\n\t\tawait this.#starting.execute(async () => {\n\t\t\tthis.clear()\n\t\t\ttry {\n\t\t\t\tawait this.#install(this.#session)\n\t\t\t\tawait Promise.all((this.#frames?.() ?? []).map((session) => this.#install(session)))\n\t\t\t\tthis.#started = true\n\t\t\t\tthis.#emitter.emit('start')\n\t\t\t} catch (error) {\n\t\t\t\tawait this.#remove()\n\t\t\t\tthrow error\n\t\t\t}\n\t\t})\n\t}\n\t/**\n\t * Installs recording on an attached frame before its owner resumes it.\n\t * @param session - The attached frame session\n\t * @returns Completion of listener installation\n\t */\n\tasync attach(session: string): Promise<void> {\n\t\tif (\n\t\t\t(!this.#started && this.#starting.pending === undefined) ||\n\t\t\tthis.#stopping.pending !== undefined ||\n\t\t\tthis.#shutdown !== undefined\n\t\t)\n\t\t\treturn\n\t\tawait this.#install(session)\n\t}\n\tasync stop(): Promise<readonly BrowserJourneyStep[]> {\n\t\tawait this.#starting.pending?.catch(() => undefined)\n\t\tif (this.#stopping.pending !== undefined) return await this.#stopping.pending\n\t\tif (!this.#started) return this.steps()\n\t\treturn await this.#stopping.execute(async () => {\n\t\t\tawait this.#remove()\n\t\t\tawait this.#queue\n\t\t\tthis.#flush()\n\t\t\tthis.#enter = undefined\n\t\t\tthis.#started = false\n\t\t\tconst steps = this.steps()\n\t\t\tthis.#emitter.emit('stop', structuredClone(steps))\n\t\t\treturn steps\n\t\t})\n\t}\n\tsteps(): readonly BrowserJourneyStep[] {\n\t\treturn structuredClone(this.#steps)\n\t}\n\tjourney(options: { readonly name: string; readonly description: string }): BrowserJourney {\n\t\treturn buildBrowserJourney(this.#steps, options)\n\t}\n\tscript(options: {\n\t\treadonly name: string\n\t\treadonly description: string\n\t\treadonly language?: BrowserCodegenLanguage\n\t}): BrowserCodegenScript {\n\t\treturn compileBrowserJourney(\n\t\t\tthis.journey({ name: options.name, description: options.description }),\n\t\t\toptions.language === undefined ? {} : { language: options.language },\n\t\t)\n\t}\n\tclear(): void {\n\t\tthis.#epoch += 1\n\t\tthis.#steps = []\n\t\tthis.#pending = undefined\n\t\tthis.#enter = undefined\n\t\tthis.#emitter.emit('clear')\n\t}\n\tasync destroy(): Promise<void> {\n\t\tif (this.#shutdown !== undefined) return await this.#shutdown\n\t\tthis.#shutdown = this.#destroy()\n\t\tawait this.#shutdown\n\t}\n\tasync #destroy(): Promise<void> {\n\t\tawait this.stop()\n\t\tthis.clear()\n\t\tthis.#emitter.destroy()\n\t}\n\tasync #install(session: string): Promise<void> {\n\t\tconst active = this.#sessions.get(session)\n\t\tif (active !== undefined) return await active.attempt\n\t\tconst handlers: ReadonlyArray<readonly [string, CDPHandler]> = [\n\t\t\t['Runtime.bindingCalled', this.#binding.bind(this, session)],\n\t\t\t['Page.frameNavigated', this.#navigation.bind(this, session)],\n\t\t\t['Page.navigatedWithinDocument', this.#navigation.bind(this, session)],\n\t\t\t['Page.javascriptDialogClosed', this.#dialog.bind(this)],\n\t\t]\n\t\tfor (const [method, handler] of handlers) this.#client.subscribe(method, handler, session)\n\t\tconst attempt = this.#inject(session)\n\t\tthis.#sessions.set(session, { handlers, contexts: new Set(), attempt })\n\t\tawait attempt\n\t}\n\tasync #inject(session: string): Promise<void> {\n\t\tawait this.#client.send('Page.enable', undefined, { session })\n\t\tif (session === this.#session) {\n\t\t\tconst tree = await this.#client.send('Page.getFrameTree', undefined, { session })\n\t\t\tthis.#frame = readBrowserFrames(tree).find((frame) => frame.parent === undefined)?.id\n\t\t\tif (this.#frame === undefined) throw new BrowserError('The recorder requires a main frame')\n\t\t}\n\t\tawait this.#client.send('Runtime.enable', undefined, { session })\n\t\tawait this.#client.send(\n\t\t\t'Runtime.addBinding',\n\t\t\t{ name: BROWSER_CODEGEN_BINDING_NAME },\n\t\t\t{ session },\n\t\t)\n\t\tconst result = await this.#client.send(\n\t\t\t'Page.addScriptToEvaluateOnNewDocument',\n\t\t\t{ source: BROWSER_CODEGEN_SOURCE, runImmediately: true },\n\t\t\t{ session },\n\t\t)\n\t\tif (isRecord(result) && isString(result['identifier']))\n\t\t\tthis.#scripts.set(session, result['identifier'])\n\t\tif (session === this.#session)\n\t\t\tawait this.#client.send(\n\t\t\t\t'Runtime.evaluate',\n\t\t\t\t{ expression: BROWSER_CODEGEN_SOURCE },\n\t\t\t\t{ session },\n\t\t\t)\n\t}\n\tasync #remove(): Promise<void> {\n\t\tawait Promise.all(\n\t\t\t[...this.#sessions].map(async ([session, entry]) => {\n\t\t\t\tawait entry.attempt.catch(() => undefined)\n\t\t\t\tconst identifier = this.#scripts.get(session)\n\t\t\t\tif (identifier !== undefined)\n\t\t\t\t\tawait this.#client\n\t\t\t\t\t\t.send('Page.removeScriptToEvaluateOnNewDocument', { identifier }, { session })\n\t\t\t\t\t\t.catch(() => undefined)\n\t\t\t\t// Removing the binding acknowledges reports already sent by this renderer.\n\t\t\t\tawait this.#client\n\t\t\t\t\t.send('Runtime.removeBinding', { name: BROWSER_CODEGEN_BINDING_NAME }, { session })\n\t\t\t\t\t.catch(() => undefined)\n\t\t\t\tfor (const [method, handler] of entry.handlers)\n\t\t\t\t\tthis.#client.unsubscribe(method, handler, session)\n\t\t\t\tconst expression = `window[${JSON.stringify(BROWSER_CODEGEN_BINDING_NAME + '__state')}]?.controller.abort()`\n\t\t\t\tawait Promise.all(\n\t\t\t\t\t[undefined, ...entry.contexts].map(async (contextId) => {\n\t\t\t\t\t\tawait this.#client\n\t\t\t\t\t\t\t.send(\n\t\t\t\t\t\t\t\t'Runtime.evaluate',\n\t\t\t\t\t\t\t\t{ expression, ...(contextId === undefined ? {} : { contextId }) },\n\t\t\t\t\t\t\t\t{ session },\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.catch(() => undefined)\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}),\n\t\t)\n\t\tthis.#sessions.clear()\n\t\tthis.#scripts.clear()\n\t}\n\t#binding(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tif (params['name'] !== BROWSER_CODEGEN_BINDING_NAME) return\n\t\tconst gesture = parseCodegenActionPayload(params['payload'])\n\t\tconst context = params['executionContextId']\n\t\tif (gesture === undefined || !isInteger(context) || context < 1) return\n\t\tthis.#sessions.get(session)?.contexts.add(context)\n\t\tconst key = `${session}:${context}:${gesture.index}`\n\t\tconst document = `${session}:${context}`\n\t\tconst epoch = this.#epoch\n\t\t// Start the lookup while the node still exists; serialize only the projection.\n\t\tconst target =\n\t\t\tgesture.top && gesture.event !== 'submit' && gesture.event !== 'focusout'\n\t\t\t\t? this.#target(session, context, gesture.index).catch(() => undefined)\n\t\t\t\t: Promise.resolve(undefined)\n\t\tthis.#queue = this.#queue.then(async () => {\n\t\t\tconst resolved = await target\n\t\t\tif (epoch !== this.#epoch) return\n\t\t\tthis.#project(gesture, key, document, resolved)\n\t\t})\n\t}\n\tasync #target(\n\t\tsession: string,\n\t\tcontextId: number,\n\t\tindex: number,\n\t): Promise<BrowserJourneyTarget | undefined> {\n\t\tconst result = await this.#client.send(\n\t\t\t'Runtime.evaluate',\n\t\t\t{\n\t\t\t\texpression: `window[${JSON.stringify(BROWSER_CODEGEN_BINDING_NAME + '__state')}].nodes[${index}]`,\n\t\t\t\tcontextId,\n\t\t\t},\n\t\t\t{ session },\n\t\t)\n\t\tif (!isRecord(result) || !isRecord(result['result']) || !isString(result['result']['objectId']))\n\t\t\treturn undefined\n\t\tconst objectId = result['result']['objectId']\n\t\ttry {\n\t\t\tconst tree = await this.#client.send(\n\t\t\t\t'Accessibility.getPartialAXTree',\n\t\t\t\t{ objectId, fetchRelatives: true },\n\t\t\t\t{ session },\n\t\t\t)\n\t\t\tif (!isRecord(tree) || !isArray(tree['nodes'])) return undefined\n\t\t\tfor (const node of tree['nodes']) {\n\t\t\t\tif (!isRecord(node) || node['ignored'] === true) continue\n\t\t\t\tconst role = readBrowserAXValue(node['role'])\n\t\t\t\tconst name = readBrowserAXValue(node['name'])\n\t\t\t\tif (isString(role) && BROWSER_INTERACTIVE_ROLES.has(role) && isString(name))\n\t\t\t\t\treturn { role, name }\n\t\t\t}\n\t\t\treturn undefined\n\t\t} finally {\n\t\t\tawait this.#client\n\t\t\t\t.send('Runtime.releaseObject', { objectId }, { session })\n\t\t\t\t.catch(() => undefined)\n\t\t}\n\t}\n\t#project(\n\t\tgesture: BrowserCodegenGesture,\n\t\tkey: string,\n\t\tdocument: string,\n\t\ttarget: BrowserJourneyTarget | undefined,\n\t): void {\n\t\tif (gesture.event === 'submit') {\n\t\t\tthis.#enter = undefined\n\t\t\tthis.#flush()\n\t\t\treturn\n\t\t}\n\t\tif (gesture.event === 'focusout') {\n\t\t\tif (this.#pending?.key === key) this.#flush()\n\t\t\tthis.#enter = undefined\n\t\t\treturn\n\t\t}\n\t\tif (\n\t\t\tgesture.event === 'change' &&\n\t\t\t(gesture.control === 'text' || gesture.control === 'password')\n\t\t)\n\t\t\treturn\n\t\tif (gesture.event === 'input' && ['select', 'multiple', 'option'].includes(gesture.control))\n\t\t\treturn\n\t\tif (gesture.event === 'click' && ['select', 'multiple', 'option'].includes(gesture.control))\n\t\t\treturn\n\t\tif (gesture.event === 'click' && gesture.detail === 0 && this.#enter === document) return\n\t\tif (!gesture.top) {\n\t\t\tthis.#gap('the element is in a child frame')\n\t\t\treturn\n\t\t}\n\t\tif (gesture.event === 'unsupported') {\n\t\t\tthis.#gap(gesture.gap ?? 'an unsupported gesture')\n\t\t\treturn\n\t\t}\n\t\tif (gesture.event === 'keydown') {\n\t\t\tif (this.#pending?.key === key && this.#pending.step.action === 'type') {\n\t\t\t\tif (gesture.form)\n\t\t\t\t\tthis.#pending = {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tstep: {\n\t\t\t\t\t\t\t...this.#pending.step,\n\t\t\t\t\t\t\targuments: { ...this.#pending.step.arguments, submit: true },\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\tthis.#flush()\n\t\t\t\tif (!gesture.form) this.#append({ action: 'press', arguments: { key: 'Enter' } })\n\t\t\t} else {\n\t\t\t\tthis.#flush()\n\t\t\t\tthis.#append({ action: 'press', arguments: { key: 'Enter' } })\n\t\t\t}\n\t\t\tthis.#enter = gesture.form ? document : undefined\n\t\t\treturn\n\t\t}\n\t\tthis.#enter = undefined\n\t\tif (gesture.event === 'change' && gesture.control === 'multiple') {\n\t\t\tthis.#gap('a multiple selection')\n\t\t\treturn\n\t\t}\n\t\tif (gesture.event === 'change' && gesture.control === 'select' && !gesture.roundtrip) {\n\t\t\tthis.#gap('the option does not round-trip')\n\t\t\treturn\n\t\t}\n\t\tif (target === undefined) {\n\t\t\tthis.#gap('the element has no portable accessible target')\n\t\t\treturn\n\t\t}\n\t\tif (gesture.event === 'click') {\n\t\t\tthis.#flush()\n\t\t\tconst step = { action: 'click', arguments: {}, target }\n\t\t\tif (gesture.control === 'text' || gesture.control === 'password')\n\t\t\t\tthis.#pending = { key, step }\n\t\t\telse this.#append(step)\n\t\t\treturn\n\t\t}\n\t\tif (\n\t\t\tgesture.event === 'input' &&\n\t\t\t(gesture.control === 'text' || gesture.control === 'password')\n\t\t) {\n\t\t\tif (this.#pending?.key !== key) this.#flush()\n\t\t\tlet text = gesture.secret ? this.#pending?.step.arguments['text'] : gesture.value\n\t\t\tif (gesture.secret && !isRecord(text)) {\n\t\t\t\tconst taken = collectBrowserJourneyTextBindings(this.#steps)\n\t\t\t\ttext = {\n\t\t\t\t\tparameter: deriveBrowserJourneySecret(isString(target.name) ? target.name : '', taken),\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.#pending = { key, step: { action: 'type', arguments: { text: text ?? '' }, target } }\n\t\t\treturn\n\t\t}\n\t\tif (gesture.event === 'change' && gesture.control === 'select') {\n\t\t\tthis.#flush()\n\t\t\tthis.#append({ action: 'type', arguments: { text: gesture.value ?? '' }, target })\n\t\t\treturn\n\t\t}\n\t\tthis.#gap('an unsupported gesture')\n\t}\n\t#append(step: BrowserJourneyStepInput): void {\n\t\tconst recorded = structuredClone({ ...step, id: `s${this.#steps.length + 1}` })\n\t\tthis.#steps = [...this.#steps, recorded]\n\t\tthis.#emitter.emit('step', structuredClone(recorded))\n\t}\n\t#flush(): void {\n\t\tif (this.#pending === undefined) return\n\t\tconst pending = this.#pending\n\t\tthis.#pending = undefined\n\t\tthis.#append(pending.step)\n\t}\n\t#gap(gap: string): void {\n\t\tthis.#flush()\n\t\tthis.#append({ action: 'unresolved', arguments: {}, gap })\n\t}\n\t#navigation(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tif (session !== this.#session) return\n\t\tconst id = params['frameId']\n\t\tif (isString(id) && id !== this.#frame) return\n\t\tconst frame = params['frame']\n\t\tif (isRecord(frame) && 'parentId' in frame) return\n\t\tif (isRecord(frame) && isString(frame['id'])) this.#frame = frame['id']\n\t\tconst epoch = this.#epoch\n\t\tthis.#queue = this.#queue.then(() => {\n\t\t\tif (epoch === this.#epoch) {\n\t\t\t\tthis.#flush()\n\t\t\t\tthis.#enter = undefined\n\t\t\t}\n\t\t})\n\t}\n\t#dialog(): void {\n\t\tconst epoch = this.#epoch\n\t\tthis.#queue = this.#queue.then(() => {\n\t\t\tif (epoch === this.#epoch) this.#gap('a native dialog answer')\n\t\t})\n\t}\n}\n","import type {\n\tBrowserEpochFunction,\n\tBrowserReadOptions,\n\tBrowserReadResult,\n\tBrowserReadingInput,\n\tBrowserReadingInterface,\n} from './types.js'\nimport type { HTMLInterface } from '@orkestrel/html'\nimport { extractBrowserSlice } from './helpers.js'\nimport { createHTML, renderText } from '@orkestrel/html'\nimport { htmlToMarkdown, renderMarkdown } from '@orkestrel/markdown'\n\n/**\n * Represents one captured document, parsed one time and projected to Markdown or plain text in\n * bounded slices.\n *\n * @example\n * ```ts\n * import { BrowserReading } from '@orkestrel/browser'\n *\n * const reading = new BrowserReading({\n * \turl: 'https://example.com/',\n * \ttitle: 'Example',\n * \thtml: '<nav>Menu</nav><main><p>Body</p></main>',\n * })\n * reading.markdown() // { text: 'Body', offset: 0, total: 4 }\n * ```\n */\nexport class BrowserReading implements BrowserReadingInterface {\n\treadonly #url: string\n\treadonly #title: string\n\treadonly #html: HTMLInterface\n\treadonly #epoch: number | undefined\n\treadonly #navigation: BrowserEpochFunction | undefined\n\t// A projection reads only the immutable handle, so each one is computed once per mode.\n\treadonly #markdowns: Map<boolean, string> = new Map()\n\treadonly #texts: Map<boolean, string> = new Map()\n\t#distilled: HTMLInterface | undefined\n\n\tconstructor(input: BrowserReadingInput) {\n\t\tthis.#url = input.url\n\t\tthis.#title = input.title\n\t\tthis.#html = createHTML(input.html)\n\t\tthis.#navigation = input.navigation\n\t\tthis.#epoch = input.epoch ?? input.navigation?.()\n\t}\n\n\tget url(): string {\n\t\treturn this.#url\n\t}\n\n\tget title(): string {\n\t\treturn this.#title\n\t}\n\n\tget html(): HTMLInterface {\n\t\treturn this.#html\n\t}\n\n\tget stale(): boolean {\n\t\treturn this.#navigation !== undefined && this.#navigation() !== this.#epoch\n\t}\n\n\tmarkdown(options?: BrowserReadOptions): BrowserReadResult {\n\t\tconst distill = options?.distill ?? true\n\t\tlet text = this.#markdowns.get(distill)\n\t\tif (text === undefined) {\n\t\t\ttext = renderMarkdown(htmlToMarkdown(this.#source(distill).document))\n\t\t\tthis.#markdowns.set(distill, text)\n\t\t}\n\t\treturn extractBrowserSlice(text, options?.offset, options?.limit)\n\t}\n\n\ttext(options?: BrowserReadOptions): BrowserReadResult {\n\t\tconst distill = options?.distill ?? true\n\t\tlet text = this.#texts.get(distill)\n\t\tif (text === undefined) {\n\t\t\ttext = renderText(this.#source(distill).document)\n\t\t\tthis.#texts.set(distill, text)\n\t\t}\n\t\treturn extractBrowserSlice(text, options?.offset, options?.limit)\n\t}\n\n\t#source(distill: boolean): HTMLInterface {\n\t\tif (!distill) return this.#html\n\t\tthis.#distilled ??= this.#html.distill({ base: this.#url })\n\t\treturn this.#distilled\n\t}\n}\n","import type {\n\tBrowserCallOptions,\n\tBrowserElementInput,\n\tBrowserElementGeometry,\n\tBrowserPageElementInterface,\n\tBrowserPoint,\n\tBrowserQuad,\n\tBrowserReadingInterface,\n\tBrowserScreenshotOptions,\n\tBrowserScreenshotResult,\n} from '../types.js'\nimport { BrowserReading } from '../BrowserReading.js'\nimport { BrowserElementError, isBrowserElementError } from '../errors.js'\nimport { BROWSER_ELEMENT_REFUSALS, BROWSER_RESULT_LIMIT } from '../constants.js'\nimport {\n\tcompileActionabilityFunction,\n\tcompileGuardedEvaluateExpression,\n\tcompileHitFunction,\n\tcompileReadFunction,\n\tcompileSelectFunction,\n} from '../compilers.js'\nimport {\n\tcomputeBrowserButtons,\n\tcomputeBrowserModifiers,\n\textractBrowserChord,\n\tkeyToBrowserInput,\n\tnormalizeBrowserKey,\n\tnormalizeBrowserName,\n\treadBrowserQuad,\n\treadEvaluationResult,\n\trequireBrowserString,\n} from '../helpers.js'\nimport { isArray, isError, isInteger, isNumber, isRecord, isString } from '@orkestrel/contract'\n\n/**\n * Drives a referenced DOM element through its document's isolated world and the page input stream.\n * @example\n * ```ts\n * const element = page.elements.element('e1')\n * await element?.click()\n * ```\n */\nexport class BrowserPageElement implements BrowserPageElementInterface {\n\treadonly #input: BrowserElementInput\n\n\tconstructor(input: BrowserElementInput) {\n\t\tthis.#input = input\n\t}\n\n\tget reference(): string {\n\t\treturn this.#input.node.reference\n\t}\n\n\tget frame(): string {\n\t\treturn this.#input.frame\n\t}\n\n\tget role(): string {\n\t\treturn this.#input.description().role ?? 'unknown'\n\t}\n\n\tget name(): string {\n\t\treturn normalizeBrowserName(this.#input.description().name ?? '')\n\t}\n\n\tasync click(options?: BrowserCallOptions): Promise<void> {\n\t\tconst point = await this.#pointer(options)\n\t\tawait this.#pair(point, point, options)\n\t}\n\n\tasync fill(value: string, options?: BrowserCallOptions): Promise<void> {\n\t\tawait this.focus(options)\n\t\tawait this.#call(\n\t\t\tcompileActionabilityFunction({ visible: true, enabled: true, editable: true }),\n\t\t\toptions,\n\t\t)\n\t\tawait this.#call(compileSelectFunction(), options)\n\t\tthis.#assert(options)\n\t\tawait this.#input.page.send('Input.insertText', { text: value }, options)\n\t}\n\n\tasync select(values: readonly string[], options?: BrowserCallOptions): Promise<void> {\n\t\tawait this.#call(compileActionabilityFunction({ visible: true, enabled: true }), options)\n\t\tawait this.#call(compileSelectFunction(values), options)\n\t}\n\n\tasync focus(options?: BrowserCallOptions): Promise<void> {\n\t\tthis.#assert(options)\n\t\tconst resolved = await this.#resolve(options)\n\t\ttry {\n\t\t\tawait this.#input.client.send(\n\t\t\t\t'DOM.focus',\n\t\t\t\t{ backendNodeId: this.#input.backend },\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthis.#failure(options, error)\n\t\t} finally {\n\t\t\tawait this.#release(resolved.object)\n\t\t}\n\t}\n\n\tasync read(options?: BrowserCallOptions): Promise<BrowserReadingInterface> {\n\t\tconst epoch = this.#epoch()\n\t\tconst capture = await this.#call(\n\t\t\t`function() {\n\t\tconst capture = (${compileReadFunction()})()\n\t\tcapture.html = this.outerHTML\n\t\treturn ${compileGuardedEvaluateExpression('capture', BROWSER_RESULT_LIMIT)}\n\t}`,\n\t\t\toptions,\n\t\t)\n\t\tif (!isRecord(capture))\n\t\t\tthrow new BrowserElementError(this.reference, 'UNKNOWN', 'returned an invalid reading')\n\t\treturn new BrowserReading({\n\t\t\turl: requireBrowserString(capture['url'], 'Element URL'),\n\t\t\ttitle: requireBrowserString(capture['title'], 'Element title'),\n\t\t\thtml: requireBrowserString(capture['html'], 'Element HTML'),\n\t\t\tepoch,\n\t\t\tnavigation: this.#epoch.bind(this),\n\t\t})\n\t}\n\n\tasync hover(options?: BrowserCallOptions): Promise<void> {\n\t\tconst point = await this.#pointer(options)\n\t\tawait this.#input.page.send(\n\t\t\t'Input.dispatchMouseEvent',\n\t\t\t{ type: 'mouseMoved', ...point, buttons: 0 },\n\t\t\toptions,\n\t\t)\n\t}\n\n\tasync press(value: string, options?: BrowserCallOptions): Promise<void> {\n\t\tconst chord = extractBrowserChord(normalizeBrowserKey(value))\n\t\tconst key = keyToBrowserInput(chord.key)\n\t\tconst modifiers = computeBrowserModifiers(chord.modifiers)\n\t\tawait this.focus(options)\n\t\tthis.#assert(options)\n\t\tconst params = {\n\t\t\tkey: key.key,\n\t\t\tcode: key.code,\n\t\t\twindowsVirtualKeyCode: key.number,\n\t\t\tnativeVirtualKeyCode: key.number,\n\t\t\tmodifiers,\n\t\t}\n\t\ttry {\n\t\t\tawait this.#input.page.send(\n\t\t\t\t'Input.dispatchKeyEvent',\n\t\t\t\t{\n\t\t\t\t\ttype: 'keyDown',\n\t\t\t\t\t...params,\n\t\t\t\t\ttext: modifiers === 0 || modifiers === 8 ? key.text : undefined,\n\t\t\t\t},\n\t\t\t\toptions,\n\t\t\t)\n\t\t} finally {\n\t\t\tawait this.#input.page.send(\n\t\t\t\t'Input.dispatchKeyEvent',\n\t\t\t\t{ type: 'keyUp', ...params },\n\t\t\t\toptions?.timeout === undefined ? undefined : { timeout: options.timeout },\n\t\t\t)\n\t\t}\n\t\toptions?.signal?.throwIfAborted()\n\t}\n\n\tasync submit(options?: BrowserCallOptions): Promise<void> {\n\t\t// A trusted Enter on the focused control runs the form's implicit submission.\n\t\tawait this.press('Enter', options)\n\t}\n\n\tasync upload(files: readonly string[], options?: BrowserCallOptions): Promise<void> {\n\t\tconst resolved = await this.#resolve(options)\n\t\ttry {\n\t\t\tawait this.#input.client.send(\n\t\t\t\t'DOM.setFileInputFiles',\n\t\t\t\t{ backendNodeId: this.#input.backend, files },\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t} finally {\n\t\t\tawait this.#release(resolved.object)\n\t\t}\n\t}\n\n\tasync drag(target: BrowserPageElementInterface, options?: BrowserCallOptions): Promise<void> {\n\t\tconst start = await this.#pointer(options)\n\t\tconst end = (await target.quad(options)).center\n\t\tawait this.#pair(start, end, options)\n\t}\n\n\tasync quad(options?: BrowserCallOptions): Promise<BrowserQuad> {\n\t\treturn (await this.#geometry(options)).page\n\t}\n\n\tasync #geometry(options?: BrowserCallOptions): Promise<BrowserElementGeometry> {\n\t\tthis.#assert(options)\n\t\tconst result = await this.#input.client\n\t\t\t.send(\n\t\t\t\t'DOM.getContentQuads',\n\t\t\t\t{ backendNodeId: this.#input.backend },\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t\t.catch(this.#failure.bind(this, options))\n\t\tif (!isRecord(result) || !isArray(result['quads']) || result['quads'].length === 0)\n\t\t\tthrow new BrowserElementError(this.reference, 'HIDDEN')\n\t\tconst quad = readBrowserQuad(result)\n\t\t// The frame owners' box models are read here, so a collected owner reaches the classifier too.\n\t\tconst center = await this.#input\n\t\t\t.point(this.#input.frame, quad.center, options)\n\t\t\t.catch(this.#failure.bind(this, options))\n\t\tconst x = center.x - quad.center.x\n\t\tconst y = center.y - quad.center.y\n\t\treturn {\n\t\t\tlocal: quad,\n\t\t\tpage: {\n\t\t\t\tpoints: [\n\t\t\t\t\tquad.points[0] + x,\n\t\t\t\t\tquad.points[1] + y,\n\t\t\t\t\tquad.points[2] + x,\n\t\t\t\t\tquad.points[3] + y,\n\t\t\t\t\tquad.points[4] + x,\n\t\t\t\t\tquad.points[5] + y,\n\t\t\t\t\tquad.points[6] + x,\n\t\t\t\t\tquad.points[7] + y,\n\t\t\t\t],\n\t\t\t\tcenter,\n\t\t\t},\n\t\t}\n\t}\n\n\tasync screenshot(options?: BrowserScreenshotOptions): Promise<BrowserScreenshotResult> {\n\t\tconst quad = await this.quad()\n\t\tconst scroll = await this.#scroll(this.#input.session)\n\t\tconst xs = quad.points.filter((_value, index) => index % 2 === 0)\n\t\tconst ys = quad.points.filter((_value, index) => index % 2 !== 0)\n\t\tconst x = Math.min(...xs)\n\t\tconst y = Math.min(...ys)\n\t\treturn await this.#input.page.screenshot({\n\t\t\t...options,\n\t\t\tfull: false,\n\t\t\tclip: [x + scroll.x, y + scroll.y, Math.max(...xs) - x, Math.max(...ys) - y],\n\t\t})\n\t}\n\n\t#assert(options?: BrowserCallOptions): void {\n\t\toptions?.signal?.throwIfAborted()\n\t\tif (!this.#input.current())\n\t\t\tthrow new BrowserElementError(this.reference, 'GONE', 'is gone because the page changed')\n\t\tthis.#input.page.assert()\n\t}\n\n\t#epoch(): number {\n\t\treturn this.#input.navigation(this.#input.frame)\n\t}\n\n\tasync #resolve(\n\t\toptions?: BrowserCallOptions,\n\t\tbackend = this.#input.backend,\n\t): Promise<{ readonly object: string; readonly context: number }> {\n\t\tthis.#assert(options)\n\t\tconst context = await this.#input.world(this.#input.frame, this.#input.node.session, options)\n\t\ttry {\n\t\t\tconst result = await this.#input.client.send(\n\t\t\t\t'DOM.resolveNode',\n\t\t\t\t{ backendNodeId: backend, executionContextId: context },\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t\tif (\n\t\t\t\t!isRecord(result) ||\n\t\t\t\t!isRecord(result['object']) ||\n\t\t\t\t!isString(result['object']['objectId'])\n\t\t\t)\n\t\t\t\tthrow new BrowserElementError(this.reference, 'GONE')\n\t\t\tthis.#assert(options)\n\t\t\treturn { object: result['object']['objectId'], context }\n\t\t} catch {\n\t\t\toptions?.signal?.throwIfAborted()\n\t\t\tthrow new BrowserElementError(this.reference, 'GONE')\n\t\t}\n\t}\n\n\tasync #call(\n\t\tdeclaration: string,\n\t\toptions?: BrowserCallOptions,\n\t\ttarget?: number,\n\t): Promise<unknown> {\n\t\tconst resolved = await this.#resolve(options)\n\t\tlet hit: { readonly object: string; readonly context: number } | undefined\n\t\ttry {\n\t\t\tif (target !== undefined) hit = await this.#resolve(options, target)\n\t\t\tconst result = await this.#input.client.send(\n\t\t\t\t'Runtime.callFunctionOn',\n\t\t\t\t{\n\t\t\t\t\tfunctionDeclaration: `function(element, target) { return (${declaration}).call(element, target) }`,\n\t\t\t\t\texecutionContextId: resolved.context,\n\t\t\t\t\targuments: [\n\t\t\t\t\t\t{ objectId: resolved.object },\n\t\t\t\t\t\t...(hit === undefined ? [] : [{ objectId: hit.object }]),\n\t\t\t\t\t],\n\t\t\t\t\treturnByValue: true,\n\t\t\t\t\tawaitPromise: true,\n\t\t\t\t},\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t\tthis.#assert(options)\n\t\t\treturn readEvaluationResult(result)\n\t\t} catch (error) {\n\t\t\tthis.#failure(options, error)\n\t\t} finally {\n\t\t\tawait this.#release(resolved.object)\n\t\t\tif (hit !== undefined) await this.#release(hit.object)\n\t\t}\n\t}\n\n\t#failure(options: BrowserCallOptions | undefined, error: unknown): never {\n\t\toptions?.signal?.throwIfAborted()\n\t\tif (isBrowserElementError(error)) throw error\n\t\t// An in-page refusal carries the page's stack after its first line; only that line reaches\n\t\t// the refusal.\n\t\tconst message = (isError(error) ? error.message : String(error)).split('\\n', 1)[0] ?? ''\n\t\tconst known = BROWSER_ELEMENT_REFUSALS.get(message.replace(/^Error: /, ''))\n\t\tif (known !== undefined)\n\t\t\tthrow new BrowserElementError(this.reference, known.reason, known.detail)\n\t\tconst reason = /layout object|not visible/i.test(message)\n\t\t\t? 'HIDDEN'\n\t\t\t: /disabled/i.test(message)\n\t\t\t\t? 'DISABLED'\n\t\t\t\t: /detached|Could not find node|No node with given id|No node found for given backend id|not found|context/i.test(\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t )\n\t\t\t\t\t? 'GONE'\n\t\t\t\t\t: undefined\n\t\tif (reason === undefined) throw error\n\t\tthrow new BrowserElementError(this.reference, reason, reason === 'GONE' ? undefined : message)\n\t}\n\n\tasync #scroll(session: string, options?: BrowserCallOptions): Promise<BrowserPoint> {\n\t\tconst result = await this.#input.client.send(\n\t\t\t'Page.getLayoutMetrics',\n\t\t\t{},\n\t\t\t{ session, ...options },\n\t\t)\n\t\tconst viewport = isRecord(result)\n\t\t\t? (result['cssLayoutViewport'] ?? result['cssVisualViewport'])\n\t\t\t: undefined\n\t\treturn {\n\t\t\tx: isRecord(viewport) && isNumber(viewport['pageX']) ? viewport['pageX'] : 0,\n\t\t\ty: isRecord(viewport) && isNumber(viewport['pageY']) ? viewport['pageY'] : 0,\n\t\t}\n\t}\n\n\tasync #release(object: string): Promise<void> {\n\t\tawait this.#input.client\n\t\t\t.send(\n\t\t\t\t'Runtime.releaseObject',\n\t\t\t\t{ objectId: object },\n\t\t\t\t{ session: this.#input.node.session, timeout: 1000 },\n\t\t\t)\n\t\t\t.catch(() => undefined)\n\t}\n\n\tasync #pointer(options?: BrowserCallOptions): Promise<BrowserPoint> {\n\t\tthis.#assert(options)\n\t\tawait this.#input.client\n\t\t\t.send(\n\t\t\t\t'DOM.scrollIntoViewIfNeeded',\n\t\t\t\t{ backendNodeId: this.#input.backend },\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t\t.catch(this.#failure.bind(this, options))\n\t\tawait this.#call(\n\t\t\tcompileActionabilityFunction({ visible: true, enabled: true, stable: true }),\n\t\t\toptions,\n\t\t)\n\t\tconst geometry = await this.#geometry(options)\n\t\tconst point = geometry.page.center\n\t\tconst local = geometry.local.center\n\t\tconst scroll = await this.#scroll(this.#input.node.session, options)\n\t\tconst hit = await this.#input.client.send(\n\t\t\t'DOM.getNodeForLocation',\n\t\t\t{ x: Math.round(local.x + scroll.x), y: Math.round(local.y + scroll.y) },\n\t\t\t{ session: this.#input.node.session, ...options },\n\t\t)\n\t\tif (\n\t\t\t!isRecord(hit) ||\n\t\t\t!isInteger(hit['backendNodeId']) ||\n\t\t\t(hit['frameId'] !== undefined && hit['frameId'] !== this.#input.frame)\n\t\t)\n\t\t\tthrow new BrowserElementError(this.reference, 'OCCLUDED')\n\t\tif (\n\t\t\thit['backendNodeId'] !== this.#input.backend &&\n\t\t\t(await this.#call(compileHitFunction(), options, hit['backendNodeId'])) !== true\n\t\t) {\n\t\t\tconst described = await this.#input.client.send(\n\t\t\t\t'DOM.describeNode',\n\t\t\t\t{ backendNodeId: hit['backendNodeId'] },\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t\tconst node =\n\t\t\t\tisRecord(described) && isRecord(described['node']) ? described['node'] : undefined\n\t\t\tlet name = isString(node?.['nodeName']) ? node['nodeName'].toLowerCase() : 'element'\n\t\t\tconst attributes = node?.['attributes']\n\t\t\tif (isArray(attributes)) {\n\t\t\t\tconst id = attributes[attributes.indexOf('id') + 1]\n\t\t\t\tconst classes = attributes[attributes.indexOf('class') + 1]\n\t\t\t\tif (attributes.includes('id') && isString(id) && id !== '') name += `#${id}`\n\t\t\t\telse if (attributes.includes('class') && isString(classes) && classes.trim() !== '')\n\t\t\t\t\tname += `.${classes.trim().split(/\\s+/).join('.')}`\n\t\t\t}\n\t\t\tthrow new BrowserElementError(this.reference, 'OCCLUDED', `is covered by ${name}`)\n\t\t}\n\t\treturn point\n\t}\n\n\tasync #pair(start: BrowserPoint, end: BrowserPoint, options?: BrowserCallOptions): Promise<void> {\n\t\tthis.#assert(options)\n\t\ttry {\n\t\t\tawait this.#input.page.send(\n\t\t\t\t'Input.dispatchMouseEvent',\n\t\t\t\t{\n\t\t\t\t\ttype: 'mousePressed',\n\t\t\t\t\t...start,\n\t\t\t\t\tbutton: 'left',\n\t\t\t\t\tbuttons: computeBrowserButtons(['left']),\n\t\t\t\t\tclickCount: 1,\n\t\t\t\t},\n\t\t\t\toptions,\n\t\t\t)\n\t\t\tif (start.x !== end.x || start.y !== end.y)\n\t\t\t\tawait this.#input.page.send(\n\t\t\t\t\t'Input.dispatchMouseEvent',\n\t\t\t\t\t{ type: 'mouseMoved', ...end, button: 'left', buttons: computeBrowserButtons(['left']) },\n\t\t\t\t\toptions,\n\t\t\t\t)\n\t\t} finally {\n\t\t\tawait this.#input.page.send(\n\t\t\t\t'Input.dispatchMouseEvent',\n\t\t\t\t{ type: 'mouseReleased', ...end, button: 'left', buttons: 0, clickCount: 1 },\n\t\t\t\toptions?.timeout === undefined ? undefined : { timeout: options.timeout },\n\t\t\t)\n\t\t}\n\t\toptions?.signal?.throwIfAborted()\n\t}\n}\n","import type {\n\tBrowserAXNode,\n\tBrowserCallOptions,\n\tBrowserElementManagerInput,\n\tBrowserElementManagerInterface,\n\tBrowserElementQuery,\n\tBrowserElementWaitOptions,\n\tBrowserOutline,\n\tBrowserOutlineNode,\n\tBrowserOutlineOptions,\n\tBrowserPageElementInterface,\n\tBrowserPoint,\n} from '../types.js'\nimport { BrowserPageElement } from './BrowserPageElement.js'\nimport { BrowserElementError, BrowserError } from '../errors.js'\nimport {\n\tBROWSER_DEFAULT_TIMEOUT_MS,\n\tBROWSER_OUTLINE_LIMIT,\n\tBROWSER_INTERACTIVE_ROLES,\n} from '../constants.js'\nimport { compileQueryWaitExpression } from '../compilers.js'\nimport {\n\tcomposeBrowserPoint,\n\tfilterBrowserOutline,\n\treadBrowserAccessibility,\n\treadBrowserQuad,\n\treadEvaluationResult,\n\trenderBrowserOutline,\n\trequireBrowserString,\n\tvalidateBrowserTimeout,\n} from '../helpers.js'\nimport { parseBrowserReference } from '../parsers.js'\nimport { isArray, isInteger, isRecord, isString } from '@orkestrel/contract'\n\n/**\n * Captures accessibility trees and binds stable references to their owning frame sessions.\n *\n * @remarks\n * A reference is dropped when the page reports its frame's document replaced or detached through\n * `input.steps`, which carries only the steps of each frame's owning session.\n * @example\n * ```ts\n * const outline = await page.elements.outline()\n * const matches = await page.elements.find({ role: 'button', name: 'save' })\n * await matches[0]?.click()\n * ```\n */\nexport class BrowserElementManager implements BrowserElementManagerInterface<BrowserPageElementInterface> {\n\treadonly #input: BrowserElementManagerInput\n\treadonly #records = new Map<\n\t\tstring,\n\t\t{ readonly node: BrowserOutlineNode; readonly element: BrowserPageElement }\n\t>()\n\treadonly #owners = new Map<\n\t\tstring,\n\t\t{ readonly frame: string; readonly session: string; readonly backend: number }\n\t>()\n\treadonly #lifetime = new AbortController()\n\t#sequence = 0\n\treadonly #generations = new Map<string, number>()\n\t// Counts every generation step across all frames, so a capture can tell whether any frame it\n\t// reads navigated while it ran.\n\t#changes = 0\n\treadonly #queries = new Map<string, Promise<readonly BrowserOutlineNode[]>>()\n\treadonly #navigationHandler = this.#navigate.bind(this)\n\treadonly #commitHandler = this.#commit.bind(this)\n\treadonly #detachHandler = this.#detach.bind(this)\n\treadonly #closeHandler = this.#close.bind(this)\n\n\tconstructor(input: BrowserElementManagerInput) {\n\t\tthis.#input = input\n\t\tinput.page.emitter.on('navigate', this.#navigationHandler)\n\t\tinput.steps.on('commit', this.#commitHandler)\n\t\tinput.steps.on('detach', this.#detachHandler)\n\t\tinput.page.emitter.on('close', this.#closeHandler)\n\t}\n\n\tasync outline(options?: BrowserOutlineOptions): Promise<BrowserOutline> {\n\t\tconst limit = options?.limit ?? BROWSER_OUTLINE_LIMIT\n\t\tif (!isInteger(limit) || limit < 0)\n\t\t\tthrow new BrowserError('Outline limit must be a nonnegative integer')\n\t\tawait this.#input.ready(options)\n\t\tconst epoch = this.#generation(this.#input.page.id)\n\t\tconst changes = this.#changes\n\t\ttry {\n\t\t\tconst rows = await this.#capture(options)\n\t\t\tconst context = await this.#input.world(this.#input.page.id, this.#input.session, options)\n\t\t\tconst result = await this.#input.client.send(\n\t\t\t\t'Runtime.evaluate',\n\t\t\t\t{ expression: 'document.title', contextId: context, returnByValue: true },\n\t\t\t\t{ session: this.#input.session, ...options },\n\t\t\t)\n\t\t\tthis.#assertCapture(this.#input.page.id, epoch)\n\t\t\treturn renderBrowserOutline(\n\t\t\t\tthis.#input.page.url,\n\t\t\t\trequireBrowserString(readEvaluationResult(result), 'Document title'),\n\t\t\t\tthis.#within(rows, options?.within),\n\t\t\t\tlimit,\n\t\t\t)\n\t\t} catch (error) {\n\t\t\t// A navigation destroys the contexts, nodes, and sessions the capture was reading, so a\n\t\t\t// rejection that follows one reports the change rather than the protocol failure.\n\t\t\tif (options?.signal?.aborted === true || this.#changes === changes) throw error\n\t\t\tthis.#lifetime.signal.throwIfAborted()\n\t\t\tthrow new BrowserElementError({ subject: 'outline' }, 'GONE')\n\t\t}\n\t}\n\n\t/** A CSS query searches the page's main-frame document; use the accessibility outline for in-process child documents. */\n\tasync find(\n\t\tquery: BrowserElementQuery,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<readonly BrowserPageElementInterface[]> {\n\t\tawait this.#input.ready(options)\n\t\tconst epoch = this.#generation(this.#input.page.id)\n\t\tconst rows = this.#within(await this.#capture(options), query.within)\n\t\tlet matches = filterBrowserOutline(rows, query)\n\t\tif (query.css !== undefined) {\n\t\t\tconst session = this.#input.session\n\t\t\tconst previous = this.#queries.get(session) ?? Promise.resolve([])\n\t\t\tconst pending = previous.catch(() => []).then(this.#css.bind(this, query, epoch, options))\n\t\t\tthis.#queries.set(session, pending)\n\t\t\ttry {\n\t\t\t\tconst selected = await pending\n\t\t\t\tconst keys = new Set(selected.map((node) => `${node.session}:${node.backend}`))\n\t\t\t\tif (query.role === undefined && query.name === undefined) matches = selected\n\t\t\t\telse matches = matches.filter((node) => keys.has(`${node.session}:${node.backend}`))\n\t\t\t} finally {\n\t\t\t\tif (this.#queries.get(session) === pending) this.#queries.delete(session)\n\t\t\t}\n\t\t}\n\t\tthis.#assertCapture(this.#input.page.id, epoch)\n\t\treturn matches.flatMap((node) => {\n\t\t\tconst entry = this.#records.get(`${node.session}:${node.backend}`)\n\t\t\treturn entry === undefined ? [] : [entry.element]\n\t\t})\n\t}\n\n\tasync #css(\n\t\tquery: BrowserElementQuery,\n\t\tepoch: number,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<readonly BrowserOutlineNode[]> {\n\t\tconst frame = this.#input.page.id\n\t\tconst session = this.#input.session\n\t\tthis.#assertCapture(frame, epoch)\n\t\tconst scope = query.within === undefined ? undefined : this.#record(query.within)\n\t\tif (scope !== undefined && scope.node.frame !== frame) return []\n\t\tlet document = await this.#input.client.send('DOM.getDocument', {}, { session, ...options })\n\t\tif (scope !== undefined)\n\t\t\tdocument = await this.#input.client.send(\n\t\t\t\t'DOM.pushNodesByBackendIdsToFrontend',\n\t\t\t\t{ backendNodeIds: [scope.node.backend] },\n\t\t\t\t{ session, ...options },\n\t\t\t)\n\t\tconst root =\n\t\t\tisRecord(document) && isRecord(document['root'])\n\t\t\t\t? document['root']['nodeId']\n\t\t\t\t: isRecord(document) && isArray(document['nodeIds'])\n\t\t\t\t\t? document['nodeIds'][0]\n\t\t\t\t\t: undefined\n\t\tif (!isInteger(root)) throw new BrowserElementError({ subject: 'document' }, 'GONE')\n\t\tconst result = await this.#input.client.send(\n\t\t\t'DOM.querySelectorAll',\n\t\t\t{ nodeId: root, selector: query.css },\n\t\t\t{ session, ...options },\n\t\t)\n\t\tif (!isRecord(result) || !isArray(result['nodeIds']))\n\t\t\tthrow new BrowserError('CSS query result is malformed')\n\t\tconst rows: BrowserOutlineNode[] = []\n\t\tfor (const nodeId of result['nodeIds']) {\n\t\t\tif (!isInteger(nodeId)) continue\n\t\t\tconst described = await this.#input.client.send(\n\t\t\t\t'DOM.describeNode',\n\t\t\t\t{ nodeId },\n\t\t\t\t{ session, ...options },\n\t\t\t)\n\t\t\tif (\n\t\t\t\t!isRecord(described) ||\n\t\t\t\t!isRecord(described['node']) ||\n\t\t\t\t!isInteger(described['node']['backendNodeId'])\n\t\t\t)\n\t\t\t\tcontinue\n\t\t\tconst backend = described['node']['backendNodeId']\n\t\t\tthis.#assertCapture(frame, epoch)\n\t\t\tconst existing = this.#records.get(`${session}:${backend}`)\n\t\t\tif (existing !== undefined) rows.push(existing.node)\n\t\t\telse\n\t\t\t\trows.push(\n\t\t\t\t\tthis.#bind(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: `${session}:${backend}`,\n\t\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t\t\tbackend,\n\t\t\t\t\t\t\tframe,\n\t\t\t\t\t\t\tignored: false,\n\t\t\t\t\t\t\trole: 'generic',\n\t\t\t\t\t\t\tname: '',\n\t\t\t\t\t\t\tdescription: undefined,\n\t\t\t\t\t\t\tvalue: undefined,\n\t\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tframe,\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t}\n\t\treturn rows\n\t}\n\n\tasync wait(\n\t\tquery: BrowserElementQuery,\n\t\toptions?: BrowserElementWaitOptions,\n\t): Promise<readonly BrowserPageElementInterface[]> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst end = performance.now() + timeout\n\t\tconst signal =\n\t\t\toptions?.signal === undefined\n\t\t\t\t? this.#lifetime.signal\n\t\t\t\t: AbortSignal.any([options.signal, this.#lifetime.signal])\n\t\twhile (true) {\n\t\t\tsignal.throwIfAborted()\n\t\t\tconst remaining = Math.max(0, end - performance.now())\n\t\t\tconst call = { timeout: remaining, signal }\n\t\t\tawait this.#input.ready(call)\n\t\t\tconst frame = this.#scopeFrame(query.within)\n\t\t\tconst session = await this.#input.resolve(frame)\n\t\t\tconst context = await this.#input.world(frame, session, call)\n\t\t\tconst key = `__browserQueryWait${++this.#sequence}`\n\t\t\t// Arm before capturing so mutations during find are retained by the pending promise.\n\t\t\tconst pending = this.#input.client\n\t\t\t\t.send(\n\t\t\t\t\t'Runtime.evaluate',\n\t\t\t\t\t{\n\t\t\t\t\t\texpression: compileQueryWaitExpression(remaining, key),\n\t\t\t\t\t\tcontextId: context,\n\t\t\t\t\t\treturnByValue: true,\n\t\t\t\t\t\tawaitPromise: true,\n\t\t\t\t\t},\n\t\t\t\t\t{ session, timeout: remaining + 1000, signal },\n\t\t\t\t)\n\t\t\t\t.then(\n\t\t\t\t\t(result) => ({ result }),\n\t\t\t\t\t(error: unknown) => ({ error }),\n\t\t\t\t)\n\t\t\ttry {\n\t\t\t\tconst found = await this.find(query, call)\n\t\t\t\tif (options?.absent === true ? found.length === 0 : found.length > 0) return found\n\t\t\t\tconst outcome = await pending\n\t\t\t\tif ('error' in outcome) throw outcome.error\n\t\t\t\tif (readEvaluationResult(outcome.result) !== true || performance.now() >= end)\n\t\t\t\t\tthrow new BrowserError('Element wait timed out', 'BROWSER_WAIT_TIMEOUT')\n\t\t\t} finally {\n\t\t\t\tawait this.#input.client\n\t\t\t\t\t.send(\n\t\t\t\t\t\t'Runtime.evaluate',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\texpression: `globalThis[${JSON.stringify(key)}]?.()`,\n\t\t\t\t\t\t\tcontextId: context,\n\t\t\t\t\t\t\treturnByValue: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ session, timeout: 1000 },\n\t\t\t\t\t)\n\t\t\t\t\t.catch(() => undefined)\n\t\t\t}\n\t\t}\n\t}\n\n\telement(reference: string): BrowserPageElementInterface | undefined {\n\t\tconst canonical = parseBrowserReference(reference)\n\t\treturn [...this.#records.values()].find((entry) => entry.node.reference === canonical)?.element\n\t}\n\n\telements(): readonly BrowserPageElementInterface[] {\n\t\treturn [...this.#records.values()].map((entry) => entry.element)\n\t}\n\n\tclear(): void {\n\t\tthis.#changes += 1\n\t\tfor (const [frame, epoch] of this.#generations) this.#generations.set(frame, epoch + 1)\n\t\tthis.#records.clear()\n\t\tthis.#owners.clear()\n\t}\n\n\tasync #capture(options?: BrowserCallOptions): Promise<readonly BrowserOutlineNode[]> {\n\t\tthis.#input.page.assert()\n\t\tconst rows = await this.#tree(this.#input.page.id, this.#input.session, new Set(), options)\n\t\treturn rows\n\t}\n\n\tasync #tree(\n\t\tframe: string,\n\t\tsession: string,\n\t\tvisited: Set<string>,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<readonly BrowserOutlineNode[]> {\n\t\tif (visited.has(frame)) return []\n\t\tvisited.add(frame)\n\t\tconst epoch = this.#generation(frame)\n\t\tawait this.#input.client.send('Accessibility.enable', undefined, { session, ...options })\n\t\tthis.#assertCapture(frame, epoch)\n\t\tconst snapshot = readBrowserAccessibility(\n\t\t\tawait this.#input.client.send(\n\t\t\t\t'Accessibility.getFullAXTree',\n\t\t\t\t{ frameId: frame },\n\t\t\t\t{ session, ...options },\n\t\t\t),\n\t\t)\n\t\tthis.#assertCapture(frame, epoch)\n\t\tconst nodes = new Map(snapshot.nodes.map((node) => [node.id, node]))\n\t\tconst stack = [...snapshot.roots].reverse()\n\t\tconst seen = new Set<string>()\n\t\tconst rows: BrowserOutlineNode[] = []\n\t\twhile (stack.length > 0) {\n\t\t\tthis.#assertCapture(frame, epoch)\n\t\t\toptions?.signal?.throwIfAborted()\n\t\t\tconst id = stack.pop()\n\t\t\tconst node = id === undefined ? undefined : nodes.get(id)\n\t\t\tif (node === undefined || seen.has(node.id)) continue\n\t\t\tseen.add(node.id)\n\t\t\trows.push(this.#bind(node, frame, session))\n\t\t\tif (node.role === 'Iframe' && node.backend !== undefined) {\n\t\t\t\tconst described = await this.#input.client.send(\n\t\t\t\t\t'DOM.describeNode',\n\t\t\t\t\t{ backendNodeId: node.backend },\n\t\t\t\t\t{ session, ...options },\n\t\t\t\t)\n\t\t\t\tconst child =\n\t\t\t\t\tisRecord(described) && isRecord(described['node'])\n\t\t\t\t\t\t? described['node']['frameId']\n\t\t\t\t\t\t: undefined\n\t\t\t\tthis.#assertCapture(frame, epoch)\n\t\t\t\tif (isString(child)) {\n\t\t\t\t\tthis.#owners.set(child, { frame, session, backend: node.backend })\n\t\t\t\t\tconst childSession = await this.#input.resolve(child)\n\t\t\t\t\trows.push(...(await this.#tree(child, childSession, visited, options)))\n\t\t\t\t}\n\t\t\t}\n\t\t\tstack.push(...[...node.children].reverse())\n\t\t}\n\t\tthis.#assertCapture(frame, epoch)\n\t\treturn rows\n\t}\n\n\t#generation(frame: string): number {\n\t\tconst epoch = this.#generations.get(frame) ?? 0\n\t\tthis.#generations.set(frame, epoch)\n\t\treturn epoch\n\t}\n\n\t#assertCapture(frame: string, epoch: number): void {\n\t\tthis.#lifetime.signal.throwIfAborted()\n\t\tif (this.#generation(frame) !== epoch)\n\t\t\tthrow new BrowserElementError({ subject: 'outline' }, 'GONE')\n\t}\n\n\t#bind(node: BrowserAXNode, frame: string, session: string, css = false): BrowserOutlineNode {\n\t\tconst backend = node.backend\n\t\tconst tool =\n\t\t\tbackend === undefined\n\t\t\t\t? undefined\n\t\t\t\t: this.#input.page.registry\n\t\t\t\t\t\t.tools()\n\t\t\t\t\t\t.find((candidate) => candidate.frame === frame && candidate.node === backend)?.name\n\t\tif (\n\t\t\tbackend === undefined ||\n\t\t\t(!css &&\n\t\t\t\t(node.ignored || (tool === undefined && !BROWSER_INTERACTIVE_ROLES.has(node.role ?? ''))))\n\t\t)\n\t\t\treturn { ...node, frame, session, reference: undefined }\n\t\tconst key = `${session}:${backend}`\n\t\tconst existing = this.#records.get(key)\n\t\tif (existing !== undefined) {\n\t\t\tconst row = {\n\t\t\t\t...node,\n\t\t\t\tframe,\n\t\t\t\tsession,\n\t\t\t\treference: existing.node.reference,\n\t\t\t\t...(tool === undefined ? {} : { tool }),\n\t\t\t}\n\t\t\tthis.#records.set(key, { node: row, element: existing.element })\n\t\t\treturn row\n\t\t}\n\t\tconst reference = this.#input.reference()\n\t\tconst row = { ...node, frame, session, reference, ...(tool === undefined ? {} : { tool }) }\n\t\tconst element = new BrowserPageElement({\n\t\t\t...this.#input,\n\t\t\tdescription: this.#description.bind(this, key, row),\n\t\t\tnode: row,\n\t\t\tbackend,\n\t\t\tframe,\n\t\t\tcurrent: this.#current.bind(this, key, reference),\n\t\t\tpoint: this.#point.bind(this),\n\t\t})\n\t\tthis.#records.set(key, { node: row, element })\n\t\treturn row\n\t}\n\n\t#current(key: string, reference: string): boolean {\n\t\treturn this.#records.get(key)?.node.reference === reference\n\t}\n\n\t#description(key: string, fallback: BrowserOutlineNode): BrowserOutlineNode {\n\t\tconst current = this.#records.get(key)?.node\n\t\treturn current !== undefined && current.reference === fallback.reference ? current : fallback\n\t}\n\n\t#scopeFrame(reference?: string): string {\n\t\tif (reference === undefined) return this.#input.page.id\n\t\tconst scope = this.#record(reference).node\n\t\tfor (const [frame, owner] of this.#owners) {\n\t\t\tif (owner.session === scope.session && owner.backend === scope.backend) return frame\n\t\t}\n\t\treturn scope.frame ?? this.#input.page.id\n\t}\n\n\t#record(reference: string): {\n\t\treadonly node: BrowserOutlineNode\n\t\treadonly element: BrowserPageElement\n\t} {\n\t\tconst canonical = parseBrowserReference(reference)\n\t\tconst entry = [...this.#records.values()].find((record) => record.node.reference === canonical)\n\t\tif (entry === undefined) throw new BrowserElementError(reference, 'GONE')\n\t\treturn entry\n\t}\n\n\t#within(rows: readonly BrowserOutlineNode[], reference?: string): readonly BrowserOutlineNode[] {\n\t\tif (reference === undefined) return rows\n\t\tconst scope = this.#record(reference).node\n\t\tconst key = `${scope.session}:${scope.backend}`\n\t\tconst included = new Set<string>()\n\t\tconst frames = new Set<string>()\n\t\treturn rows.filter((node) => {\n\t\t\tif (\n\t\t\t\t`${node.session}:${node.backend}` !== key &&\n\t\t\t\t!included.has(`${node.session}:${node.id}`) &&\n\t\t\t\t!included.has(`${node.session}:${node.parent}`) &&\n\t\t\t\t!frames.has(node.frame ?? '')\n\t\t\t)\n\t\t\t\treturn false\n\t\t\tincluded.add(`${node.session}:${node.id}`)\n\t\t\tfor (const [frame, owner] of this.#owners) {\n\t\t\t\tif (owner.session === node.session && owner.backend === node.backend) frames.add(frame)\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t}\n\n\tasync #point(\n\t\tframe: string,\n\t\tpoint: BrowserPoint,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<BrowserPoint> {\n\t\tconst offsets: BrowserPoint[] = []\n\t\tconst visited = new Set<string>()\n\t\tlet current = frame\n\t\twhile (current !== this.#input.page.id && !visited.has(current)) {\n\t\t\tvisited.add(current)\n\t\t\tconst owner = this.#owners.get(current)\n\t\t\tif (owner === undefined) throw new BrowserElementError({ subject: 'frame' }, 'GONE')\n\t\t\tconst session = await this.#input.resolve(current)\n\t\t\tif (session !== owner.session) {\n\t\t\t\tconst result = await this.#input.client.send(\n\t\t\t\t\t'DOM.getBoxModel',\n\t\t\t\t\t{ backendNodeId: owner.backend },\n\t\t\t\t\t{ session: owner.session, ...options },\n\t\t\t\t)\n\t\t\t\tconst content =\n\t\t\t\t\tisRecord(result) && isRecord(result['model']) ? result['model']['content'] : undefined\n\t\t\t\tconst quad = readBrowserQuad({ quads: [content] })\n\t\t\t\toffsets.push({ x: quad.points[0], y: quad.points[1] })\n\t\t\t}\n\t\t\tcurrent = owner.frame\n\t\t}\n\t\treturn composeBrowserPoint(point, offsets)\n\t}\n\n\t#navigate(_url: string, same: boolean): void {\n\t\tif (!same) this.clear()\n\t}\n\n\t#commit(frame: string, _url: string, _loader: string | undefined, same: boolean): void {\n\t\tif (!same) this.#drop(frame)\n\t}\n\n\t// A swap leaves the frame in another renderer, and its references with the document it left.\n\t#detach(frame: string): void {\n\t\tthis.#drop(frame)\n\t}\n\n\t#drop(frame: string): void {\n\t\tif (frame === this.#input.page.id) return\n\t\tthis.#changes += 1\n\t\tthis.#generations.set(frame, this.#generation(frame) + 1)\n\t\tfor (const [key, record] of this.#records)\n\t\t\tif (record.node.frame === frame) this.#records.delete(key)\n\t\tthis.#owners.delete(frame)\n\t}\n\n\t#close(): void {\n\t\tthis.clear()\n\t\tthis.#lifetime.abort(new BrowserError('Browser session ended'))\n\t\tthis.#input.page.emitter.off('navigate', this.#navigationHandler)\n\t\tthis.#input.steps.off('commit', this.#commitHandler)\n\t\tthis.#input.steps.off('detach', this.#detachHandler)\n\t\tthis.#input.page.emitter.off('close', this.#closeHandler)\n\t}\n}\n","import type {\n\tBrowserCallOptions,\n\tBrowserFrameInterface,\n\tBrowserInvocationResult,\n\tBrowserPageInterface,\n\tBrowserRegistryEventMap,\n\tBrowserRegistryInterface,\n\tBrowserRegistryOptions,\n\tBrowserRegistryPending,\n\tBrowserTool,\n\tCDPClientInterface,\n\tCDPHandler,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport type { ToolAnnotations, ToolContext, ToolInterface } from '@orkestrel/tool'\nimport { isArray, isRecord, isString } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { createTool } from '@orkestrel/tool'\nimport { BrowserTransition } from './BrowserTransition.js'\nimport {\n\tBROWSER_DEFAULT_TIMEOUT_MS,\n\tBROWSER_REGISTRY_ABSENT_CODE,\n\tBROWSER_REGISTRY_OUTPUT_LIMIT,\n} from './constants.js'\nimport { BrowserError, isCDPError } from './errors.js'\nimport {\n\trenderBrowserToolOutput,\n\tderiveBrowserToolSchema,\n\tvalidateBrowserTimeout,\n} from './helpers.js'\nimport {\n\tparseBrowserTool,\n\tparseBrowserRemoval,\n\tparseBrowserInvocation,\n\tparseBrowserInvocationResult,\n} from './parsers.js'\n\n/**\n * Mirrors the experimental WebMCP domain across a page's attached sessions.\n * @remarks The page owns the live session-to-frame map; protocol subscriptions use stable session ids.\n * @example\n * ```ts\n * const registry = page.registry\n * if (await registry.start()) {\n * const tools = await registry.adopt()\n * }\n * ```\n */\nexport class BrowserRegistry implements BrowserRegistryInterface {\n\treadonly #page: BrowserPageInterface\n\treadonly #client: CDPClientInterface\n\treadonly #session: string\n\treadonly #frames: ReadonlyMap<string, string>\n\treadonly #emitter: Emitter<BrowserRegistryEventMap>\n\treadonly #tools = new Map<string, BrowserTool>()\n\treadonly #owners = new Map<string, string>()\n\treadonly #subscriptions = new Map<string, ReadonlyMap<string, CDPHandler>>()\n\treadonly #enabled = new Set<string>()\n\treadonly #enabling = new Map<string, Promise<boolean>>()\n\treadonly #pending = new Set<BrowserRegistryPending>()\n\treadonly #awaiting = new Set<BrowserRegistryPending>()\n\treadonly #identifiers = new Map<BrowserRegistryPending, string>()\n\treadonly #responses = new Map<string, Map<string, BrowserInvocationResult>>()\n\treadonly #starting = new BrowserTransition<boolean>()\n\t#destroying: Promise<void> | undefined\n\treadonly #sessionHandler = this.#attach.bind(this)\n\treadonly #navigateHandler = this.#navigate.bind(this)\n\treadonly #detachHandler = this.#invalidate.bind(this)\n\n\tconstructor(\n\t\tpage: BrowserPageInterface,\n\t\tclient: CDPClientInterface,\n\t\tsession: string,\n\t\tframes: ReadonlyMap<string, string> = new Map(),\n\t\toptions?: BrowserRegistryOptions,\n\t) {\n\t\tthis.#page = page\n\t\tthis.#client = client\n\t\tthis.#session = session\n\t\tthis.#frames = frames\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t}\n\n\tget emitter(): EmitterInterface<BrowserRegistryEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tasync start(options?: BrowserCallOptions): Promise<boolean> {\n\t\tthis.#assert()\n\t\toptions?.signal?.throwIfAborted()\n\t\treturn await this.#starting.execute(() => this.#start(options))\n\t}\n\n\ttool(name: string, frame?: string): BrowserTool | undefined {\n\t\tif (frame !== undefined) return this.#tools.get(JSON.stringify([frame, name]))\n\t\tconst main = this.#tools.get(JSON.stringify([this.#page.id, name]))\n\t\treturn main ?? this.tools().find((tool) => tool.name === name)\n\t}\n\n\ttools(): readonly BrowserTool[] {\n\t\treturn [...this.#tools.values()]\n\t}\n\n\tasync adopt(): Promise<readonly ToolInterface[]> {\n\t\tthis.#assert()\n\t\tconst adopted: ToolInterface[] = []\n\t\tfor (const tool of this.tools()) {\n\t\t\tif (this.tool(tool.name) !== tool) continue\n\t\t\tconst parameters = deriveBrowserToolSchema(tool.schema)\n\t\t\tif (parameters === undefined) continue\n\t\t\tconst annotations: ToolAnnotations = {\n\t\t\t\tuntrusted: true,\n\t\t\t\t...(tool.annotation.readOnly === undefined ? {} : { pure: tool.annotation.readOnly }),\n\t\t\t\t...(tool.annotation.consequential === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { consequential: tool.annotation.consequential }),\n\t\t\t}\n\t\t\tadopted.push(\n\t\t\t\tcreateTool({\n\t\t\t\t\tname: tool.name,\n\t\t\t\t\tdescription: tool.description,\n\t\t\t\t\tparameters,\n\t\t\t\t\tannotations,\n\t\t\t\t\texecute: this.#executeAdopted.bind(this, tool, parameters !== tool.schema),\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t\treturn adopted\n\t}\n\n\tasync execute(\n\t\ttool: BrowserTool,\n\t\tinput: Readonly<Record<string, unknown>>,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<BrowserInvocationResult> {\n\t\tthis.#assert()\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst session = this.#owners.get(tool.frame)\n\t\tif (\n\t\t\tsession === undefined ||\n\t\t\t!this.#enabled.has(session) ||\n\t\t\tthis.tool(tool.name, tool.frame) === undefined\n\t\t) {\n\t\t\tthrow new BrowserError('Browser tool is not registered in an enabled frame')\n\t\t}\n\t\tconst deferred = Promise.withResolvers<BrowserInvocationResult>()\n\t\tconst pending: BrowserRegistryPending = {\n\t\t\tframe: tool.frame,\n\t\t\tsession,\n\t\t\tsignal: options?.signal,\n\t\t\tcontroller: new AbortController(),\n\t\t\ttimer: setTimeout(() => this.#expire(pending), timeout),\n\t\t\tresolve: deferred.resolve,\n\t\t\treject: deferred.reject,\n\t\t}\n\t\tthis.#pending.add(pending)\n\t\tpending.signal?.addEventListener('abort', () => this.#abort(pending), {\n\t\t\tonce: true,\n\t\t\tsignal: pending.controller.signal,\n\t\t})\n\t\tvoid this.#invoke(pending, tool, input, timeout)\n\t\treturn await deferred.promise\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tthis.#destroying ??= this.#destroy()\n\t\treturn this.#destroying\n\t}\n\n\t#assert(): void {\n\t\tif (this.#destroying !== undefined) throw new BrowserError('Browser registry is destroyed')\n\t\tthis.#page.assert()\n\t}\n\n\tasync #start(options?: BrowserCallOptions): Promise<boolean> {\n\t\tthis.#page.emitter.on('session', this.#sessionHandler)\n\t\tthis.#page.emitter.on('navigate', this.#navigateHandler)\n\t\tthis.#page.emitter.on('detach', this.#detachHandler)\n\t\ttry {\n\t\t\tif (!(await this.#enable(this.#session, options))) {\n\t\t\t\tthis.#unwatch()\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tthis.#assert()\n\t\t\tfor (const session of this.#frames.keys()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.#enable(session, options)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (options?.signal?.aborted === true) throw error\n\t\t\t\t\tthis.#invalidateSession(session)\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.#assert()\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\tthis.#unwatch()\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t#unwatch(): void {\n\t\tthis.#page.emitter.off('session', this.#sessionHandler)\n\t\tthis.#page.emitter.off('navigate', this.#navigateHandler)\n\t\tthis.#page.emitter.off('detach', this.#detachHandler)\n\t}\n\n\tasync #enable(session: string, options?: BrowserCallOptions): Promise<boolean> {\n\t\tif (this.#destroying !== undefined) throw new BrowserError('Browser registry is destroyed')\n\t\tif (this.#enabled.has(session)) return true\n\t\tconst active = this.#enabling.get(session)\n\t\tif (active !== undefined) return await active\n\t\tconst subscriptions = new Map<string, CDPHandler>()\n\t\tsubscriptions.set('WebMCP.toolsAdded', this.#add.bind(this, session))\n\t\tsubscriptions.set('WebMCP.toolsRemoved', this.#remove.bind(this))\n\t\tsubscriptions.set('WebMCP.toolInvoked', this.#invoked.bind(this))\n\t\tsubscriptions.set('WebMCP.toolResponded', this.#respond.bind(this, session))\n\t\tsubscriptions.set('Page.frameNavigated', this.#navigated.bind(this))\n\t\tsubscriptions.set('Page.frameDetached', this.#detached.bind(this))\n\t\tthis.#subscriptions.set(session, subscriptions)\n\t\tfor (const [method, handler] of subscriptions) this.#client.subscribe(method, handler, session)\n\t\tconst enabling = this.#activate(session, options)\n\t\tthis.#enabling.set(session, enabling)\n\t\ttry {\n\t\t\treturn await enabling\n\t\t} finally {\n\t\t\tthis.#enabling.delete(session)\n\t\t}\n\t}\n\n\tasync #activate(session: string, options?: BrowserCallOptions): Promise<boolean> {\n\t\ttry {\n\t\t\tawait this.#client.send('WebMCP.enable', undefined, { ...options, session })\n\t\t\tthis.#enabled.add(session)\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\tthis.#unsubscribe(session)\n\t\t\tthis.#invalidateSession(session)\n\t\t\tif (isCDPError(error) && error.context?.['code'] === BROWSER_REGISTRY_ABSENT_CODE)\n\t\t\t\treturn false\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t#invalidateSession(session: string): void {\n\t\tfor (const [frame, owner] of this.#owners) if (owner === session) this.#invalidate(frame)\n\t}\n\n\t#unsubscribe(session: string): void {\n\t\tfor (const [method, handler] of this.#subscriptions.get(session) ?? [])\n\t\t\tthis.#client.unsubscribe(method, handler, session)\n\t\tthis.#subscriptions.delete(session)\n\t}\n\n\t#attach(frame: BrowserFrameInterface): void {\n\t\tif (this.#destroying !== undefined || !this.#enabled.has(this.#session)) return\n\t\tfor (const [session, id] of this.#frames) {\n\t\t\tif (id === frame.id) {\n\t\t\t\tvoid this.#enable(session).catch(() => this.#invalidate(frame.id))\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\t#navigate(_url: string, same: boolean): void {\n\t\tif (same) return\n\t\tfor (const frame of new Set([...this.tools(), ...this.#pending].map((entry) => entry.frame)))\n\t\t\tthis.#invalidate(frame)\n\t}\n\n\t#navigated(params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frame']\n\t\tif (isRecord(frame) && isString(frame['id'])) this.#invalidate(frame['id'])\n\t}\n\n\t#detached(params: Readonly<Record<string, unknown>>): void {\n\t\tif (isString(params['frameId'])) this.#invalidate(params['frameId'])\n\t}\n\n\t#invalidate(frame: string): void {\n\t\tlet removed = false\n\t\tfor (const [key, tool] of this.#tools) {\n\t\t\tif (tool.frame === frame) {\n\t\t\t\tthis.#tools.delete(key)\n\t\t\t\tremoved = true\n\t\t\t}\n\t\t}\n\t\tthis.#owners.delete(frame)\n\t\tfor (const pending of this.#pending) {\n\t\t\tif (pending.frame === frame)\n\t\t\t\tthis.#reject(pending, new BrowserError('Browser tool frame was invalidated'))\n\t\t}\n\t\tif (removed) this.#emitter.emit('change')\n\t}\n\n\t#add(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tif (!isArray(params['tools'])) return\n\t\tfor (const value of params['tools']) {\n\t\t\tconst tool = parseBrowserTool(value)\n\t\t\tif (tool === undefined) continue\n\t\t\tthis.#tools.set(JSON.stringify([tool.frame, tool.name]), tool)\n\t\t\tthis.#owners.set(tool.frame, session)\n\t\t}\n\t\tthis.#emitter.emit('change')\n\t}\n\n\t#remove(params: Readonly<Record<string, unknown>>): void {\n\t\tif (!isArray(params['tools'])) return\n\t\tfor (const value of params['tools']) {\n\t\t\tconst key = parseBrowserRemoval(value)\n\t\t\tif (key !== undefined) this.#tools.delete(JSON.stringify([key.frame, key.name]))\n\t\t}\n\t\tthis.#emitter.emit('change')\n\t}\n\n\t#invoked(params: Readonly<Record<string, unknown>>): void {\n\t\tconst invocation = parseBrowserInvocation(params)\n\t\tif (invocation !== undefined) this.#emitter.emit('invoke', invocation)\n\t}\n\n\t#respond(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst result = parseBrowserInvocationResult(params)\n\t\tif (result === undefined) return\n\t\tconst pending = [...this.#pending].find(\n\t\t\t(entry) => entry.session === session && this.#identifiers.get(entry) === result.id,\n\t\t)\n\t\tif (pending !== undefined) {\n\t\t\tthis.#release(pending)\n\t\t\tpending.resolve(result)\n\t\t} else if ([...this.#awaiting].some((entry) => entry.session === session)) {\n\t\t\tconst responses = this.#responses.get(session) ?? new Map<string, BrowserInvocationResult>()\n\t\t\tresponses.set(result.id, result)\n\t\t\tthis.#responses.set(session, responses)\n\t\t}\n\t\tthis.#emitter.emit('respond', result)\n\t}\n\n\tasync #invoke(\n\t\tpending: BrowserRegistryPending,\n\t\ttool: BrowserTool,\n\t\tinput: Readonly<Record<string, unknown>>,\n\t\ttimeout: number,\n\t): Promise<void> {\n\t\tthis.#awaiting.add(pending)\n\t\ttry {\n\t\t\t// Abort must not discard the reply: its id is needed to cancel the remote invocation.\n\t\t\tconst reply = await this.#client.send(\n\t\t\t\t'WebMCP.invokeTool',\n\t\t\t\t{ frameId: tool.frame, toolName: tool.name, input },\n\t\t\t\t{ session: pending.session, timeout },\n\t\t\t)\n\t\t\tif (!isRecord(reply) || !isString(reply['invocationId']))\n\t\t\t\tthrow new BrowserError('WebMCP invocation reply has no invocationId')\n\t\t\tconst id = reply['invocationId']\n\t\t\t// A settled entry with a reply means the deadline or abort won the race; cancel remotely.\n\t\t\tif (pending.signal?.aborted === true || !this.#pending.has(pending)) {\n\t\t\t\tthis.#abortInvocation(pending.session, id)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.#identifiers.set(pending, id)\n\t\t\tconst result = this.#responses.get(pending.session)?.get(id)\n\t\t\tthis.#responses.get(pending.session)?.delete(id)\n\t\t\tif (result !== undefined) {\n\t\t\t\tthis.#release(pending)\n\t\t\t\tpending.resolve(result)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthis.#reject(pending, error)\n\t\t} finally {\n\t\t\tthis.#awaiting.delete(pending)\n\t\t\tif (![...this.#awaiting].some((entry) => entry.session === pending.session))\n\t\t\t\tthis.#responses.delete(pending.session)\n\t\t}\n\t}\n\n\t#expire(pending: BrowserRegistryPending): void {\n\t\tconst id = this.#identifiers.get(pending)\n\t\tif (id !== undefined) this.#abortInvocation(pending.session, id)\n\t\tthis.#reject(pending, new BrowserError('Browser tool invocation timed out'))\n\t}\n\n\t#abort(pending: BrowserRegistryPending): void {\n\t\tconst id = this.#identifiers.get(pending)\n\t\tif (id !== undefined) this.#abortInvocation(pending.session, id)\n\t\tthis.#reject(pending, pending.signal?.reason)\n\t}\n\n\t#abortInvocation(session: string, id: string): void {\n\t\tvoid this.#client\n\t\t\t.send('WebMCP.cancelInvocation', { invocationId: id }, { session })\n\t\t\t.catch(() => undefined)\n\t}\n\n\t#release(pending: BrowserRegistryPending): void {\n\t\tclearTimeout(pending.timer)\n\t\tpending.controller.abort()\n\t\tthis.#pending.delete(pending)\n\t\tthis.#identifiers.delete(pending)\n\t}\n\n\t#reject(pending: BrowserRegistryPending, error: unknown): void {\n\t\tif (!this.#pending.has(pending)) return\n\t\tthis.#release(pending)\n\t\tpending.reject(error)\n\t}\n\n\tasync #executeAdopted(\n\t\ttool: BrowserTool,\n\t\tsynthetic: boolean,\n\t\tinput: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<string> {\n\t\tconst parameters = synthetic\n\t\t\t? Object.fromEntries(Object.entries(input).filter(([key]) => key !== 'what'))\n\t\t\t: input\n\t\tconst result = await this.execute(tool, parameters, { signal: context.signal })\n\t\tif (result.status !== 'Completed')\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Browser tool ${result.status}: ${result.error ?? 'No error description'}`.slice(\n\t\t\t\t\t0,\n\t\t\t\t\tBROWSER_REGISTRY_OUTPUT_LIMIT,\n\t\t\t\t),\n\t\t\t)\n\t\treturn renderBrowserToolOutput(result.output)\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\tthis.#unwatch()\n\t\tfor (const session of [...this.#subscriptions.keys()]) this.#unsubscribe(session)\n\t\tfor (const pending of [...this.#pending])\n\t\t\tthis.#reject(pending, new BrowserError('Browser registry is destroyed'))\n\t\tthis.#tools.clear()\n\t\tthis.#owners.clear()\n\t\tthis.#responses.clear()\n\t\tawait Promise.allSettled(this.#enabling.values())\n\t\tawait Promise.allSettled(\n\t\t\t[...this.#enabled].map((session) =>\n\t\t\t\tthis.#client.send('WebMCP.disable', undefined, { session }),\n\t\t\t),\n\t\t)\n\t\tthis.#enabled.clear()\n\t\tthis.#emitter.destroy()\n\t}\n}\n","import type { BrowserFrameInterface, BrowserMetric, BrowserPerformanceInterface } from './types.js'\nimport { readBrowserMetrics } from './helpers.js'\n\n/**\n * Reads Performance-domain metrics for one frame.\n *\n * @example\n * ```ts\n * import { BrowserPerformance } from '@orkestrel/browser'\n *\n * const performance = new BrowserPerformance(page)\n * const metrics = await performance.metrics() // readonly BrowserMetric[]\n * ```\n */\nexport class BrowserPerformance implements BrowserPerformanceInterface {\n\treadonly #frame: BrowserFrameInterface\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tasync metrics(): Promise<readonly BrowserMetric[]> {\n\t\tawait this.#frame.send('Performance.enable')\n\t\ttry {\n\t\t\treturn readBrowserMetrics(await this.#frame.send('Performance.getMetrics'))\n\t\t} finally {\n\t\t\tawait this.#frame.send('Performance.disable').catch(() => undefined)\n\t\t}\n\t}\n}\n","import type { BrowserFrameInterface, BrowserProfile, BrowserProfilerInterface } from './types.js'\nimport { readBrowserProfile } from './helpers.js'\nimport { BrowserError } from './errors.js'\nimport { isInteger } from '@orkestrel/contract'\n\n/**\n * Records sampled JavaScript CPU profiles over one frame's Profiler domain.\n *\n * @example\n * ```ts\n * import { BrowserProfiler } from '@orkestrel/browser'\n *\n * const profiler = new BrowserProfiler(page)\n * await profiler.start(100)\n * const profile = await profiler.stop() // { start, end, nodes, samples, deltas }\n * ```\n */\nexport class BrowserProfiler implements BrowserProfilerInterface {\n\treadonly #frame: BrowserFrameInterface\n\t#active = false\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tget active(): boolean {\n\t\treturn this.#active\n\t}\n\n\tasync start(interval?: number): Promise<void> {\n\t\tif (this.#active) throw new BrowserError('Browser CPU profiling is already active')\n\t\tif (interval !== undefined) {\n\t\t\tif (!isInteger(interval) || interval <= 0) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t'Browser CPU sampling interval must be a positive integer',\n\t\t\t\t\tundefined,\n\t\t\t\t\t{\n\t\t\t\t\t\tinterval,\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\tawait this.#frame.send('Profiler.setSamplingInterval', { interval })\n\t\t}\n\t\tawait this.#frame.send('Profiler.enable')\n\t\ttry {\n\t\t\tawait this.#frame.send('Profiler.start')\n\t\t\tthis.#active = true\n\t\t} catch (error) {\n\t\t\tawait this.#frame.send('Profiler.disable').catch(() => undefined)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync stop(): Promise<BrowserProfile> {\n\t\tif (!this.#active) throw new BrowserError('Browser CPU profiling is not active')\n\t\tthis.#active = false\n\t\tlet result: unknown\n\t\ttry {\n\t\t\tresult = await this.#frame.send('Profiler.stop')\n\t\t} finally {\n\t\t\tawait this.#frame.send('Profiler.disable').catch(() => undefined)\n\t\t}\n\t\treturn readBrowserProfile(result)\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tif (!this.#active) return\n\t\tawait this.stop().catch(() => undefined)\n\t}\n}\n","import type {\n\tBrowserFrameInterface,\n\tBrowserTracingInterface,\n\tBrowserTracingOptions,\n\tBrowserTracingResult,\n\tBrowserWriterInterface,\n} from './types.js'\nimport { BROWSER_DEFAULT_TIMEOUT_MS } from './constants.js'\nimport { concatBytes, readBrowserStreamChunk } from './helpers.js'\nimport { BrowserError } from './errors.js'\nimport { isString } from '@orkestrel/contract'\n\n/**\n * Captures Chromium traces streamed through the IO domain.\n *\n * @example\n * ```ts\n * import { BrowserTracing } from '@orkestrel/browser'\n *\n * const tracing = new BrowserTracing(page)\n * await tracing.start({ screenshots: true })\n * const trace = await tracing.stop() // { bytes, path }\n * ```\n */\nexport class BrowserTracing implements BrowserTracingInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #writer: BrowserWriterInterface | undefined\n\t#active = false\n\t#options: BrowserTracingOptions | undefined\n\t#completion: PromiseWithResolvers<string> | undefined\n\treadonly #completeHandler = this.#handleComplete.bind(this)\n\n\tconstructor(frame: BrowserFrameInterface, writer?: BrowserWriterInterface) {\n\t\tthis.#frame = frame\n\t\tthis.#writer = writer\n\t}\n\n\tget active(): boolean {\n\t\treturn this.#active\n\t}\n\n\tasync start(options?: BrowserTracingOptions): Promise<void> {\n\t\tif (this.#active) throw new BrowserError('Browser tracing is already active')\n\t\tconst categories = [...(options?.categories ?? ['devtools.timeline', 'v8.execute'])]\n\t\tif (options?.screenshots === true) {\n\t\t\tcategories.push('disabled-by-default-devtools.screenshot')\n\t\t}\n\t\tif (options?.sampling === true) {\n\t\t\tcategories.push('disabled-by-default-v8.cpu_profiler')\n\t\t}\n\t\tthis.#options = options\n\t\tthis.#completion = Promise.withResolvers<string>()\n\t\ttry {\n\t\t\tawait this.#frame.subscribe('Tracing.tracingComplete', this.#completeHandler)\n\t\t\tawait this.#frame.send('Tracing.start', {\n\t\t\t\ttransferMode: 'ReturnAsStream',\n\t\t\t\ttraceConfig: {\n\t\t\t\t\tincludedCategories: categories,\n\t\t\t\t},\n\t\t\t})\n\t\t\tthis.#active = true\n\t\t} catch (error) {\n\t\t\tawait this.#frame\n\t\t\t\t.unsubscribe('Tracing.tracingComplete', this.#completeHandler)\n\t\t\t\t.catch(() => undefined)\n\t\t\tthis.#options = undefined\n\t\t\tthis.#completion = undefined\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync stop(): Promise<BrowserTracingResult> {\n\t\tif (!this.#active || this.#completion === undefined) {\n\t\t\tthrow new BrowserError('Browser tracing is not active')\n\t\t}\n\t\tconst completion = this.#completion\n\t\tconst options = this.#options\n\t\tthis.#active = false\n\t\tlet stream: string | undefined\n\t\tconst chunks: Uint8Array[] = []\n\t\ttry {\n\t\t\tawait this.#frame.send('Tracing.end')\n\t\t\tstream = await this.#wait(completion.promise)\n\t\t\twhile (true) {\n\t\t\t\tconst chunk = readBrowserStreamChunk(await this.#frame.send('IO.read', { handle: stream }))\n\t\t\t\tchunks.push(chunk.bytes)\n\t\t\t\tif (chunk.eof) break\n\t\t\t}\n\t\t} finally {\n\t\t\tif (stream !== undefined) {\n\t\t\t\tawait this.#frame.send('IO.close', { handle: stream }).catch(() => undefined)\n\t\t\t}\n\t\t\tawait this.#frame\n\t\t\t\t.unsubscribe('Tracing.tracingComplete', this.#completeHandler)\n\t\t\t\t.catch(() => undefined)\n\t\t\tthis.#options = undefined\n\t\t\tthis.#completion = undefined\n\t\t}\n\t\tconst bytes = concatBytes(chunks)\n\t\tif (options?.path !== undefined) {\n\t\t\tif (this.#writer === undefined) {\n\t\t\t\tthrow new BrowserError('Browser trace path requires a configured writer')\n\t\t\t}\n\t\t\tawait this.#writer.write(options.path, bytes)\n\t\t}\n\t\treturn { bytes, path: options?.path }\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tif (!this.#active) return\n\t\tawait this.stop().catch(() => undefined)\n\t}\n\n\tasync #wait(promise: Promise<string>): Promise<string> {\n\t\tconst deferred = Promise.withResolvers<string>()\n\t\tconst timer = setTimeout(() => {\n\t\t\tdeferred.reject(new BrowserError('Browser trace completion timed out'))\n\t\t}, BROWSER_DEFAULT_TIMEOUT_MS)\n\t\tvoid promise.then(deferred.resolve, deferred.reject)\n\t\ttry {\n\t\t\treturn await deferred.promise\n\t\t} finally {\n\t\t\tclearTimeout(timer)\n\t\t}\n\t}\n\n\t#handleComplete(params: Readonly<Record<string, unknown>>): void {\n\t\tconst completion = this.#completion\n\t\tif (completion === undefined) return\n\t\tif (isString(params['stream'])) completion.resolve(params['stream'])\n\t\telse completion.reject(new BrowserError('Browser trace did not return an IO stream'))\n\t}\n}\n","import type {\n\tBrowserCoverageInterface,\n\tBrowserDiagnosticsInterface,\n\tBrowserFrameInterface,\n\tBrowserPerformanceInterface,\n\tBrowserProfilerInterface,\n\tBrowserTracingInterface,\n\tBrowserWriterInterface,\n} from './types.js'\nimport { BrowserCoverage } from './BrowserCoverage.js'\nimport { BrowserPerformance } from './BrowserPerformance.js'\nimport { BrowserProfiler } from './BrowserProfiler.js'\nimport { BrowserTracing } from './BrowserTracing.js'\n\n/**\n * Groups the tracing, coverage, performance, and profiler classes beneath one page.\n *\n * @example\n * ```ts\n * import { BrowserDiagnostics } from '@orkestrel/browser'\n *\n * const diagnostics = new BrowserDiagnostics(page)\n * const metrics = await diagnostics.performance.metrics()\n * await diagnostics.destroy()\n * ```\n */\nexport class BrowserDiagnostics implements BrowserDiagnosticsInterface {\n\treadonly #tracing: BrowserTracing\n\treadonly #coverage: BrowserCoverage\n\treadonly #performance: BrowserPerformance\n\treadonly #profiler: BrowserProfiler\n\n\tconstructor(frame: BrowserFrameInterface, writer?: BrowserWriterInterface) {\n\t\tthis.#tracing = new BrowserTracing(frame, writer)\n\t\tthis.#coverage = new BrowserCoverage(frame)\n\t\tthis.#performance = new BrowserPerformance(frame)\n\t\tthis.#profiler = new BrowserProfiler(frame)\n\t}\n\n\tget tracing(): BrowserTracingInterface {\n\t\treturn this.#tracing\n\t}\n\n\tget coverage(): BrowserCoverageInterface {\n\t\treturn this.#coverage\n\t}\n\n\tget performance(): BrowserPerformanceInterface {\n\t\treturn this.#performance\n\t}\n\n\tget profiler(): BrowserProfilerInterface {\n\t\treturn this.#profiler\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tawait this.#tracing.destroy()\n\t\tawait this.#coverage.destroy()\n\t\tawait this.#profiler.destroy()\n\t}\n}\n","import type {\n\tBrowserDialogCategory,\n\tBrowserDialogInterface,\n\tBrowserFrameInterface,\n} from './types.js'\nimport { BrowserError } from './errors.js'\n\n/**\n * Represents one JavaScript dialog awaiting a user decision.\n */\nexport class BrowserDialog implements BrowserDialogInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #category: BrowserDialogCategory\n\treadonly #message: string\n\treadonly #default: string\n\t#handled = false\n\t#handling = false\n\n\tconstructor(\n\t\tframe: BrowserFrameInterface,\n\t\tcategory: BrowserDialogCategory,\n\t\tmessage: string,\n\t\tvalue: string,\n\t) {\n\t\tthis.#frame = frame\n\t\tthis.#category = category\n\t\tthis.#message = message\n\t\tthis.#default = value\n\t}\n\n\tget category(): BrowserDialogCategory {\n\t\treturn this.#category\n\t}\n\n\tget message(): string {\n\t\treturn this.#message\n\t}\n\n\tget default(): string {\n\t\treturn this.#default\n\t}\n\n\tasync accept(value?: string): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('Page.handleJavaScriptDialog', {\n\t\t\t\taccept: true,\n\t\t\t\tpromptText: value,\n\t\t\t})\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\tasync dismiss(): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('Page.handleJavaScriptDialog', { accept: false })\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\t#assert(): void {\n\t\tif (this.#handled || this.#handling) {\n\t\t\tthrow new BrowserError('Browser dialog is already handled')\n\t\t}\n\t}\n}\n","import type {\n\tBrowserDownloadEventMap,\n\tBrowserDownloadInterface,\n\tBrowserDownloadProgress,\n\tBrowserDownloadStatus,\n\tCDPClientInterface,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { Emitter } from '@orkestrel/emitter'\n\n/**\n * Represents one Chromium download and its progress lifecycle.\n */\nexport class BrowserDownload implements BrowserDownloadInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #context: string | undefined\n\treadonly #emitter: Emitter<BrowserDownloadEventMap>\n\treadonly #id: string\n\treadonly #url: string\n\treadonly #name: string\n\t#status: BrowserDownloadStatus = 'pending'\n\t#received = 0\n\t#total = 0\n\t#path: string | undefined\n\n\tconstructor(client: CDPClientInterface, id: string, url: string, name: string, context?: string) {\n\t\tthis.#client = client\n\t\tthis.#context = context\n\t\tthis.#id = id\n\t\tthis.#url = url\n\t\tthis.#name = name\n\t\tthis.#emitter = new Emitter()\n\t}\n\n\tget emitter(): EmitterInterface<BrowserDownloadEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget url(): string {\n\t\treturn this.#url\n\t}\n\n\tget name(): string {\n\t\treturn this.#name\n\t}\n\n\tget status(): BrowserDownloadStatus {\n\t\treturn this.#status\n\t}\n\n\tget received(): number {\n\t\treturn this.#received\n\t}\n\n\tget total(): number {\n\t\treturn this.#total\n\t}\n\n\tget path(): string | undefined {\n\t\treturn this.#path\n\t}\n\n\tasync abort(): Promise<void> {\n\t\tif (this.#status !== 'pending') return\n\t\tconst params: Record<string, unknown> = { guid: this.#id }\n\t\tif (this.#context !== undefined) params['browserContextId'] = this.#context\n\t\tawait this.#client.send('Browser.cancelDownload', params)\n\t}\n\n\tupdate(progress: BrowserDownloadProgress): void {\n\t\tif (this.#status !== 'pending') return\n\t\tthis.#received = progress.received\n\t\tthis.#total = progress.total\n\t\tthis.#path = progress.path\n\t\tthis.#emitter.emit('progress', this.#received, this.#total)\n\t\tif (progress.status === 'complete') {\n\t\t\tthis.#status = 'complete'\n\t\t\tthis.#emitter.emit('complete', this.#path)\n\t\t\tthis.#emitter.destroy()\n\t\t} else if (progress.status === 'aborted') {\n\t\t\tthis.#status = 'aborted'\n\t\t\tthis.#emitter.emit('abort')\n\t\t\tthis.#emitter.destroy()\n\t\t}\n\t}\n}\n","import type { BrowserCallOptions, BrowserHandleInterface, CDPClientInterface } from './types.js'\nimport { BrowserError } from './errors.js'\nimport { readEvaluationResult } from './helpers.js'\nimport { isRecord, isString } from '@orkestrel/contract'\n\n/**\n * Represents one retained remote object in a frame execution context.\n */\nexport class BrowserHandle implements BrowserHandleInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #session: string\n\treadonly #id: string\n\t#disposed = false\n\n\tconstructor(client: CDPClientInterface, session: string, id: string) {\n\t\tthis.#client = client\n\t\tthis.#session = session\n\t\tthis.#id = id\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tasync value(options?: BrowserCallOptions): Promise<unknown> {\n\t\treturn await this.call('function() { return this }', undefined, options)\n\t}\n\n\tasync call(\n\t\tdeclaration: string,\n\t\targs?: readonly unknown[],\n\t\toptions?: BrowserCallOptions,\n\t): Promise<unknown> {\n\t\tthis.#assert()\n\t\tconst result = await this.#client.send(\n\t\t\t'Runtime.callFunctionOn',\n\t\t\t{\n\t\t\t\tobjectId: this.#id,\n\t\t\t\tfunctionDeclaration: declaration,\n\t\t\t\targuments: args?.map((value) => ({ value })),\n\t\t\t\tawaitPromise: true,\n\t\t\t\treturnByValue: true,\n\t\t\t},\n\t\t\t{ session: this.#session, ...options },\n\t\t)\n\t\treturn readEvaluationResult(result)\n\t}\n\n\tasync property(\n\t\tname: string,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<BrowserHandleInterface | undefined> {\n\t\tthis.#assert()\n\t\tconst result = await this.#client.send(\n\t\t\t'Runtime.callFunctionOn',\n\t\t\t{\n\t\t\t\tobjectId: this.#id,\n\t\t\t\tfunctionDeclaration: 'function(name) { return this[name] }',\n\t\t\t\targuments: [{ value: name }],\n\t\t\t\tawaitPromise: true,\n\t\t\t\treturnByValue: false,\n\t\t\t},\n\t\t\t{ session: this.#session, ...options },\n\t\t)\n\t\tif (!isRecord(result) || !isRecord(result['result'])) return undefined\n\t\tconst id = result['result']['objectId']\n\t\treturn isString(id) ? new BrowserHandle(this.#client, this.#session, id) : undefined\n\t}\n\n\tasync properties(options?: BrowserCallOptions): Promise<Readonly<Record<string, unknown>>> {\n\t\tconst value = await this.call(\n\t\t\t'function() { const values = {}; for (const key of Object.keys(this)) values[key] = this[key]; return values }',\n\t\t\tundefined,\n\t\t\toptions,\n\t\t)\n\t\tif (!isRecord(value)) {\n\t\t\tthrow new BrowserError('Browser handle properties did not resolve to an object')\n\t\t}\n\t\treturn value\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\tif (this.#disposed) return\n\t\tthis.#disposed = true\n\t\tif (!this.#client.connected) return\n\t\ttry {\n\t\t\tawait this.#client.send(\n\t\t\t\t'Runtime.releaseObject',\n\t\t\t\t{ objectId: this.#id },\n\t\t\t\t{\n\t\t\t\t\tsession: this.#session,\n\t\t\t\t},\n\t\t\t)\n\t\t} catch {\n\t\t\t// The execution context may already be gone.\n\t\t}\n\t}\n\n\t#assert(): void {\n\t\tif (this.#disposed) throw new BrowserError('Browser handle is disposed')\n\t\tif (!this.#client.connected) throw new BrowserError('Browser handle is disconnected')\n\t}\n}\n","import type {\n\tBrowserEpochFunction,\n\tBrowserFrameInterface,\n\tBrowserHandleInterface,\n\tBrowserReadingInterface,\n\tBrowserCallOptions,\n\tBrowserSessionFunction,\n\tBrowserWorldFunction,\n\tCDPHandler,\n\tCDPClientInterface,\n} from './types.js'\nimport { BrowserHandle } from './BrowserHandle.js'\nimport { BrowserReading } from './BrowserReading.js'\nimport { BROWSER_FRAME_WORLD_NAME, BROWSER_RESULT_LIMIT } from './constants.js'\nimport { compileGuardedEvaluateExpression, compileReadFunction } from './compilers.js'\nimport { readBrowserWorld, readEvaluationResult, requireBrowserString } from './helpers.js'\nimport { BrowserError } from './errors.js'\nimport { isRecord, isString } from '@orkestrel/contract'\n\n/**\n * Represents one attached document frame, evaluated through its own CDP execution world.\n *\n * @remarks\n * The optional `epoch` constructor parameter reads the frame's navigation counter, which lets\n * `read()` mark a reading stale after a later navigation. The optional `world` parameter\n * resolves a cached isolated-world context, which lets a page share one world across reads.\n * A standalone frame built with neither returns readings whose `stale` stays `false`, because\n * no navigation counter is available to it, and creates a fresh world for each read.\n *\n * @example\n * ```ts\n * import { BrowserFrame } from '@orkestrel/browser'\n *\n * const frame = new BrowserFrame(client, 'session-1', 'frame-1', 'https://example.com')\n * const title = await frame.title()\n * const reading = await frame.read()\n * ```\n */\nexport class BrowserFrame implements BrowserFrameInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #session: string | BrowserSessionFunction\n\treadonly #id: string\n\treadonly #parent: string | undefined\n\treadonly #name: string | undefined\n\treadonly #isolated: boolean\n\treadonly #epoch: BrowserEpochFunction | undefined\n\treadonly #world: BrowserWorldFunction | undefined\n\t#url: string\n\n\tconstructor(\n\t\tclient: CDPClientInterface,\n\t\tsession: string | BrowserSessionFunction,\n\t\tid: string,\n\t\turl: string,\n\t\tparent?: string,\n\t\tname?: string,\n\t\tisolated = true,\n\t\tepoch?: BrowserEpochFunction,\n\t\tworld?: BrowserWorldFunction,\n\t) {\n\t\tthis.#client = client\n\t\tthis.#session = session\n\t\tthis.#id = id\n\t\tthis.#url = url\n\t\tthis.#parent = parent\n\t\tthis.#name = name\n\t\tthis.#isolated = isolated\n\t\tthis.#epoch = epoch\n\t\tthis.#world = world\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget parent(): string | undefined {\n\t\treturn this.#parent\n\t}\n\n\tget name(): string | undefined {\n\t\treturn this.#name\n\t}\n\n\tget url(): string {\n\t\treturn this.#url\n\t}\n\n\tasync title(options?: BrowserCallOptions): Promise<string> {\n\t\tthis.assert()\n\t\tconst result = await this.#evaluate('document.title', options)\n\t\treturn requireBrowserString(result, 'Document title')\n\t}\n\n\tasync read(options?: BrowserCallOptions): Promise<BrowserReadingInterface> {\n\t\tthis.assert()\n\t\t// The epoch is sampled before the capture is issued, so a navigation that lands while the\n\t\t// evaluation is in flight leaves the reading stale rather than current.\n\t\tconst epoch = this.#epoch?.()\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst session = await this.#sessionId()\n\t\tconst context =\n\t\t\tthis.#world === undefined\n\t\t\t\t? await this.#create(session, options)\n\t\t\t\t: await this.#world(session, options)\n\t\tconst result = await this.#client.send(\n\t\t\t'Runtime.evaluate',\n\t\t\t{\n\t\t\t\texpression: compileGuardedEvaluateExpression(\n\t\t\t\t\t`(${compileReadFunction()})()`,\n\t\t\t\t\tBROWSER_RESULT_LIMIT,\n\t\t\t\t),\n\t\t\t\treturnByValue: true,\n\t\t\t\tawaitPromise: true,\n\t\t\t\tcontextId: context,\n\t\t\t},\n\t\t\t{ session, ...options },\n\t\t)\n\t\tconst capture = readEvaluationResult(result)\n\t\tif (\n\t\t\t!isRecord(capture) ||\n\t\t\t!isString(capture['url']) ||\n\t\t\t!isString(capture['title']) ||\n\t\t\t!isString(capture['html'])\n\t\t) {\n\t\t\tthrow new BrowserError('Browser read capture is malformed', undefined, { frame: this.#id })\n\t\t}\n\t\t// A capture that a navigation overtook must not regress the frame URL the navigation set.\n\t\tif (this.#epoch === undefined || this.#epoch() === epoch) this.#url = capture['url']\n\t\treturn new BrowserReading({\n\t\t\turl: capture['url'],\n\t\t\ttitle: capture['title'],\n\t\t\thtml: capture['html'],\n\t\t\t...(epoch === undefined || this.#epoch === undefined\n\t\t\t\t? {}\n\t\t\t\t: { epoch, navigation: this.#epoch }),\n\t\t})\n\t}\n\n\tasync evaluate(expression: string, options?: BrowserCallOptions): Promise<unknown> {\n\t\tthis.assert()\n\t\treturn await this.#evaluate(\n\t\t\tcompileGuardedEvaluateExpression(expression, BROWSER_RESULT_LIMIT),\n\t\t\toptions,\n\t\t)\n\t}\n\n\tasync handle(expression: string, options?: BrowserCallOptions): Promise<BrowserHandleInterface> {\n\t\tthis.assert()\n\t\tconst session = await this.#sessionId()\n\t\tconst params: Record<string, unknown> = {\n\t\t\texpression,\n\t\t\treturnByValue: false,\n\t\t\tawaitPromise: true,\n\t\t}\n\t\tconst context = await this.#context(session, options)\n\t\tif (context !== undefined) params['contextId'] = context\n\t\tconst result = await this.#client.send('Runtime.evaluate', params, {\n\t\t\tsession,\n\t\t\t...options,\n\t\t})\n\t\tif (\n\t\t\t!isRecord(result) ||\n\t\t\t!isRecord(result['result']) ||\n\t\t\t!isString(result['result']['objectId'])\n\t\t) {\n\t\t\tthrow new BrowserError('Browser expression did not resolve to an object handle', undefined, {\n\t\t\t\tframe: this.#id,\n\t\t\t})\n\t\t}\n\t\treturn new BrowserHandle(this.#client, session, result['result']['objectId'])\n\t}\n\n\tasync send(\n\t\tmethod: string,\n\t\tparams?: Readonly<Record<string, unknown>>,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<unknown> {\n\t\tthis.assert()\n\t\treturn await this.#client.send(method, params, {\n\t\t\tsession: await this.#sessionId(),\n\t\t\t...options,\n\t\t})\n\t}\n\n\tasync subscribe(method: string, handler: CDPHandler): Promise<void> {\n\t\tthis.assert()\n\t\tthis.#client.subscribe(method, handler, await this.#sessionId())\n\t}\n\n\tasync unsubscribe(method: string, handler: CDPHandler): Promise<void> {\n\t\tthis.#client.unsubscribe(method, handler, await this.#sessionId())\n\t}\n\n\tasync save(path: string, _bytes: Uint8Array): Promise<void> {\n\t\t// Frames satisfy the persistence contract, but only top-level pages receive a writer.\n\t\tthrow new BrowserError('Browser frame has no configured file writer', undefined, { path })\n\t}\n\n\tassert(): void {\n\t\tif (!this.#client.connected) {\n\t\t\tthrow new BrowserError('Browser frame is disconnected', undefined, { frame: this.#id })\n\t\t}\n\t}\n\n\tupdate(url: string): void {\n\t\tthis.#url = url\n\t}\n\n\tasync #evaluate(expression: string, options?: BrowserCallOptions): Promise<unknown> {\n\t\tconst session = await this.#sessionId()\n\t\tconst params: Record<string, unknown> = {\n\t\t\texpression,\n\t\t\treturnByValue: true,\n\t\t\tawaitPromise: true,\n\t\t}\n\n\t\tconst context = await this.#context(session, options)\n\t\tif (context !== undefined) params['contextId'] = context\n\n\t\tconst result = await this.#client.send('Runtime.evaluate', params, {\n\t\t\tsession,\n\t\t\t...options,\n\t\t})\n\t\treturn readEvaluationResult(result)\n\t}\n\n\tasync #context(session: string, options?: BrowserCallOptions): Promise<number | undefined> {\n\t\tif (!this.#isolated) return undefined\n\t\tif (this.#world !== undefined) return await this.#world(session, options)\n\t\treturn await this.#create(session, options)\n\t}\n\n\tasync #create(session: string, options?: BrowserCallOptions): Promise<number> {\n\t\tconst world = await this.#client.send(\n\t\t\t'Page.createIsolatedWorld',\n\t\t\t{ frameId: this.#id, worldName: BROWSER_FRAME_WORLD_NAME },\n\t\t\t{ session, ...options },\n\t\t)\n\t\treturn readBrowserWorld(world, this.#id)\n\t}\n\n\tasync #sessionId(): Promise<string> {\n\t\tif (isString(this.#session)) return this.#session\n\t\treturn await this.#session(this.#id)\n\t}\n}\n","import type { BrowserFileChooserInterface, BrowserFrameInterface } from './types.js'\nimport { BrowserError } from './errors.js'\n\n/**\n * Represents one intercepted file input selection.\n */\nexport class BrowserFileChooser implements BrowserFileChooserInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #backend: number\n\treadonly #multiple: boolean\n\t#handled = false\n\t#handling = false\n\n\tconstructor(frame: BrowserFrameInterface, backend: number, multiple: boolean) {\n\t\tthis.#frame = frame\n\t\tthis.#backend = backend\n\t\tthis.#multiple = multiple\n\t}\n\n\tget multiple(): boolean {\n\t\treturn this.#multiple\n\t}\n\n\tasync upload(files: readonly string[]): Promise<void> {\n\t\tthis.#assert()\n\t\tif (!this.#multiple && files.length > 1) {\n\t\t\tthrow new BrowserError('Single file chooser cannot accept multiple files')\n\t\t}\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('DOM.setFileInputFiles', {\n\t\t\t\tbackendNodeId: this.#backend,\n\t\t\t\tfiles: [...files],\n\t\t\t})\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\tasync dismiss(): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('DOM.setFileInputFiles', {\n\t\t\t\tbackendNodeId: this.#backend,\n\t\t\t\tfiles: [],\n\t\t\t})\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\t#assert(): void {\n\t\tif (this.#handled || this.#handling) {\n\t\t\tthrow new BrowserError('Browser file chooser is already handled')\n\t\t}\n\t}\n}\n","import type {\n\tBrowserFrameInterface,\n\tBrowserInputOptions,\n\tBrowserKeyboardInterface,\n} from './types.js'\nimport {\n\tcomputeBrowserModifiers,\n\textractBrowserChord,\n\tkeyToBrowserInput,\n\tvalidateBrowserInputOptions,\n} from './helpers.js'\n\n/**\n * Sends trusted keyboard input through Chromium's CDP Input domain.\n *\n * @example\n * ```ts\n * import { BrowserKeyboard } from '@orkestrel/browser'\n *\n * const keyboard = new BrowserKeyboard(page)\n * await keyboard.type('orkestrel', { delay: 10 })\n * await keyboard.press('Control+Enter')\n * ```\n */\nexport class BrowserKeyboard implements BrowserKeyboardInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #modifiers = new Set<string>()\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tasync down(value: string): Promise<void> {\n\t\tconst key = keyToBrowserInput(value)\n\t\tconst modifier = ['Alt', 'Control', 'Meta', 'Shift'].includes(key.key)\n\t\tconst modifiers = computeBrowserModifiers([...this.#modifiers, ...(modifier ? [key.key] : [])])\n\t\tconst text = modifiers === 0 || modifiers === 8 ? key.text : undefined\n\t\tawait this.#frame.send('Input.dispatchKeyEvent', {\n\t\t\ttype: 'keyDown',\n\t\t\tkey: key.key,\n\t\t\tcode: key.code,\n\t\t\ttext,\n\t\t\tunmodifiedText: key.text,\n\t\t\twindowsVirtualKeyCode: key.number,\n\t\t\tnativeVirtualKeyCode: key.number,\n\t\t\tmodifiers,\n\t\t})\n\t\tif (modifier) this.#modifiers.add(key.key)\n\t}\n\n\tasync up(value: string): Promise<void> {\n\t\tconst key = keyToBrowserInput(value)\n\t\ttry {\n\t\t\tawait this.#frame.send('Input.dispatchKeyEvent', {\n\t\t\t\ttype: 'keyUp',\n\t\t\t\tkey: key.key,\n\t\t\t\tcode: key.code,\n\t\t\t\twindowsVirtualKeyCode: key.number,\n\t\t\t\tnativeVirtualKeyCode: key.number,\n\t\t\t\tmodifiers: computeBrowserModifiers([...this.#modifiers]),\n\t\t\t})\n\t\t} finally {\n\t\t\tthis.#modifiers.delete(key.key)\n\t\t}\n\t}\n\n\tasync press(value: string, options?: BrowserInputOptions): Promise<void> {\n\t\tvalidateBrowserInputOptions(options)\n\t\tconst chord = extractBrowserChord(value)\n\t\tfor (const modifier of chord.modifiers) await this.down(modifier)\n\t\ttry {\n\t\t\tawait this.down(chord.key)\n\t\t\tif (options?.delay !== undefined && options.delay > 0) {\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, options.delay))\n\t\t\t}\n\t\t\tawait this.up(chord.key)\n\t\t} finally {\n\t\t\tfor (const modifier of [...chord.modifiers].reverse()) await this.up(modifier)\n\t\t}\n\t}\n\n\tasync type(value: string, options?: BrowserInputOptions): Promise<void> {\n\t\tvalidateBrowserInputOptions(options)\n\t\tfor (const character of value) {\n\t\t\tawait this.down(character)\n\t\t\tawait this.up(character)\n\t\t\tif (options?.delay !== undefined && options.delay > 0) {\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, options.delay))\n\t\t\t}\n\t\t}\n\t}\n\n\tasync insert(value: string): Promise<void> {\n\t\tawait this.#frame.send('Input.insertText', { text: value })\n\t}\n}\n","import type {\n\tBrowserClickOptions,\n\tBrowserDragOptions,\n\tBrowserFrameInterface,\n\tBrowserMouseButton,\n\tBrowserMouseInterface,\n\tBrowserPoint,\n} from './types.js'\nimport {\n\tcomputeBrowserButtons,\n\tvalidateBrowserInputOptions,\n\tvalidateBrowserPoint,\n} from './helpers.js'\n\n/**\n * Sends trusted mouse input through Chromium's CDP Input domain.\n *\n * @example\n * ```ts\n * import { BrowserMouse } from '@orkestrel/browser'\n *\n * const mouse = new BrowserMouse(page)\n * await mouse.click({ x: 50, y: 20 }, { button: 'left', count: 2 })\n * await mouse.drag({ x: 10, y: 10 }, { x: 90, y: 90 }, { steps: 20 })\n * ```\n */\nexport class BrowserMouse implements BrowserMouseInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #buttons = new Set<BrowserMouseButton>()\n\t#point: BrowserPoint = { x: 0, y: 0 }\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tasync move(point: BrowserPoint): Promise<void> {\n\t\tvalidateBrowserPoint(point)\n\t\tthis.#point = point\n\t\tawait this.#frame.send('Input.dispatchMouseEvent', {\n\t\t\ttype: 'mouseMoved',\n\t\t\tx: point.x,\n\t\t\ty: point.y,\n\t\t\tbutton: 'none',\n\t\t\tbuttons: computeBrowserButtons([...this.#buttons]),\n\t\t})\n\t}\n\n\tasync down(button: BrowserMouseButton = 'left', count = 1): Promise<void> {\n\t\tvalidateBrowserInputOptions({ count })\n\t\tconst buttons = new Set(this.#buttons)\n\t\tbuttons.add(button)\n\t\tawait this.#frame.send('Input.dispatchMouseEvent', {\n\t\t\ttype: 'mousePressed',\n\t\t\tx: this.#point.x,\n\t\t\ty: this.#point.y,\n\t\t\tbutton,\n\t\t\tbuttons: computeBrowserButtons([...buttons]),\n\t\t\tclickCount: count,\n\t\t})\n\t\tthis.#buttons.add(button)\n\t}\n\n\tasync up(button: BrowserMouseButton = 'left', count = 1): Promise<void> {\n\t\tvalidateBrowserInputOptions({ count })\n\t\tconst buttons = new Set(this.#buttons)\n\t\tbuttons.delete(button)\n\t\ttry {\n\t\t\tawait this.#frame.send('Input.dispatchMouseEvent', {\n\t\t\t\ttype: 'mouseReleased',\n\t\t\t\tx: this.#point.x,\n\t\t\t\ty: this.#point.y,\n\t\t\t\tbutton,\n\t\t\t\tbuttons: computeBrowserButtons([...buttons]),\n\t\t\t\tclickCount: count,\n\t\t\t})\n\t\t} finally {\n\t\t\tthis.#buttons.delete(button)\n\t\t}\n\t}\n\n\tasync click(point: BrowserPoint, options?: BrowserClickOptions): Promise<void> {\n\t\tvalidateBrowserInputOptions(options)\n\t\tconst button = options?.button ?? 'left'\n\t\tconst count = options?.count ?? 1\n\t\tawait this.move(point)\n\t\tawait this.down(button, count)\n\t\tif (options?.delay !== undefined && options.delay > 0) {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, options.delay))\n\t\t}\n\t\tawait this.up(button, count)\n\t}\n\n\tasync drag(start: BrowserPoint, end: BrowserPoint, options?: BrowserDragOptions): Promise<void> {\n\t\tvalidateBrowserInputOptions(options)\n\t\tvalidateBrowserPoint(start)\n\t\tvalidateBrowserPoint(end)\n\t\tconst steps = options?.steps ?? 10\n\t\tawait this.move(start)\n\t\tawait this.down(options?.button ?? 'left', 1)\n\t\ttry {\n\t\t\tfor (let step = 1; step <= steps; step += 1) {\n\t\t\t\tawait this.move({\n\t\t\t\t\tx: start.x + ((end.x - start.x) * step) / steps,\n\t\t\t\t\ty: start.y + ((end.y - start.y) * step) / steps,\n\t\t\t\t})\n\t\t\t\tif (options?.delay !== undefined && options.delay > 0) {\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, options.delay))\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tawait this.up(options?.button ?? 'left', 1)\n\t\t}\n\t}\n\n\tasync wheel(delta: BrowserPoint): Promise<void> {\n\t\tvalidateBrowserPoint(delta)\n\t\tawait this.#frame.send('Input.dispatchMouseEvent', {\n\t\t\ttype: 'mouseWheel',\n\t\t\tx: this.#point.x,\n\t\t\ty: this.#point.y,\n\t\t\tdeltaX: delta.x,\n\t\t\tdeltaY: delta.y,\n\t\t\tbuttons: computeBrowserButtons([...this.#buttons]),\n\t\t})\n\t}\n}\n","import type { BrowserFrameInterface, BrowserPoint, BrowserTouchInterface } from './types.js'\nimport { validateBrowserPoint } from './helpers.js'\n\n/**\n * Sends trusted touch input through Chromium's CDP Input domain.\n *\n * @example\n * ```ts\n * import { BrowserTouch } from '@orkestrel/browser'\n *\n * const touch = new BrowserTouch(page)\n * await touch.tap({ x: 120, y: 240 })\n * ```\n */\nexport class BrowserTouch implements BrowserTouchInterface {\n\treadonly #frame: BrowserFrameInterface\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tasync tap(point: BrowserPoint): Promise<void> {\n\t\tvalidateBrowserPoint(point)\n\t\tconst touch = { x: point.x, y: point.y }\n\t\tawait this.#frame.send('Input.dispatchTouchEvent', {\n\t\t\ttype: 'touchStart',\n\t\t\ttouchPoints: [touch],\n\t\t})\n\t\ttry {\n\t\t\tawait this.#frame.send('Input.dispatchTouchEvent', {\n\t\t\t\ttype: 'touchEnd',\n\t\t\t\ttouchPoints: [],\n\t\t\t})\n\t\t} catch (error) {\n\t\t\tawait this.#frame\n\t\t\t\t.send('Input.dispatchTouchEvent', {\n\t\t\t\t\ttype: 'touchCancel',\n\t\t\t\t\ttouchPoints: [],\n\t\t\t\t})\n\t\t\t\t.catch(() => undefined)\n\t\t\tthrow error\n\t\t}\n\t}\n}\n","import type {\n\tBrowserHAR,\n\tBrowserHAREntry,\n\tBrowserHARManagerInterface,\n\tBrowserHAROptions,\n\tBrowserHARPending,\n\tBrowserHARReplayOptions,\n\tBrowserNetworkManagerInterface,\n\tBrowserRequest,\n\tBrowserRequestFailure,\n\tBrowserResponse,\n\tBrowserRouteHandler,\n\tBrowserWriterInterface,\n} from './types.js'\nimport { BROWSER_HAR_CREATOR } from './constants.js'\nimport {\n\tbrowserHARHeadersToRecord,\n\tcreateBrowserHAREntry,\n\tdecodeBase64,\n\ttextToBytes,\n\tvalidateBrowserHAR,\n} from './helpers.js'\nimport { BrowserError } from './errors.js'\n\n/**\n * Records and replays HTTP archives over one page network manager.\n *\n * @example\n * ```ts\n * import { BrowserHARManager } from '@orkestrel/browser'\n *\n * const har = new BrowserHARManager(page.network)\n * await har.start({ content: true })\n * const archive = await har.stop() // { log: { version: '1.2', creator, entries } }\n * ```\n */\nexport class BrowserHARManager implements BrowserHARManagerInterface {\n\treadonly #network: BrowserNetworkManagerInterface\n\treadonly #writer: BrowserWriterInterface | undefined\n\treadonly #pending: Map<string, BrowserHARPending> = new Map()\n\treadonly #entries: BrowserHAREntry[] = []\n\treadonly #tasks: Set<Promise<void>> = new Set()\n\t#options: BrowserHAROptions | undefined\n\t#recording = false\n\t#failure: unknown\n\t#archive: BrowserHAR | undefined\n\t#fallback = false\n\treadonly #requestHandler = this.#handleRequest.bind(this)\n\treadonly #responseHandler = this.#handleResponse.bind(this)\n\treadonly #failureHandler = this.#handleFailure.bind(this)\n\treadonly #finishHandler = this.#handleFinish.bind(this)\n\treadonly #replayHandler: BrowserRouteHandler = this.#handleReplay.bind(this)\n\n\tconstructor(network: BrowserNetworkManagerInterface, writer?: BrowserWriterInterface) {\n\t\tthis.#network = network\n\t\tthis.#writer = writer\n\t}\n\n\tget recording(): boolean {\n\t\treturn this.#recording\n\t}\n\n\tasync start(options?: BrowserHAROptions): Promise<void> {\n\t\tif (this.#recording) return\n\t\tthis.#options = options\n\t\tthis.#entries.length = 0\n\t\tthis.#pending.clear()\n\t\tthis.#failure = undefined\n\t\tthis.#network.emitter.on('request', this.#requestHandler)\n\t\tthis.#network.emitter.on('response', this.#responseHandler)\n\t\tthis.#network.emitter.on('failure', this.#failureHandler)\n\t\tthis.#network.emitter.on('finish', this.#finishHandler)\n\t\tthis.#recording = true\n\t\ttry {\n\t\t\tawait this.#network.start()\n\t\t} catch (error) {\n\t\t\tthis.#recording = false\n\t\t\tthis.#network.emitter.off('request', this.#requestHandler)\n\t\t\tthis.#network.emitter.off('response', this.#responseHandler)\n\t\t\tthis.#network.emitter.off('failure', this.#failureHandler)\n\t\t\tthis.#network.emitter.off('finish', this.#finishHandler)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync stop(): Promise<BrowserHAR> {\n\t\tif (this.#recording) {\n\t\t\tthis.#recording = false\n\t\t\tthis.#network.emitter.off('request', this.#requestHandler)\n\t\t\tthis.#network.emitter.off('response', this.#responseHandler)\n\t\t\tthis.#network.emitter.off('failure', this.#failureHandler)\n\t\t\tthis.#network.emitter.off('finish', this.#finishHandler)\n\t\t\tawait Promise.allSettled([...this.#tasks])\n\t\t\tfor (const id of [...this.#pending.keys()]) {\n\t\t\t\tconst pending = this.#pending.get(id)\n\t\t\t\tif (pending === undefined) continue\n\t\t\t\tthis.#pending.delete(id)\n\t\t\t\tthis.#entries.push(\n\t\t\t\t\tcreateBrowserHAREntry(\n\t\t\t\t\t\tpending,\n\t\t\t\t\t\tMath.max(0, Date.now() - pending.started),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t'Request was incomplete when recording stopped',\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tif (this.#failure !== undefined) {\n\t\t\tthrow new BrowserError('Browser HAR recording failed', 'BROWSER_HAR_ERROR', {\n\t\t\t\terror: this.#failure,\n\t\t\t})\n\t\t}\n\t\tconst har: BrowserHAR = {\n\t\t\tlog: {\n\t\t\t\tversion: '1.2',\n\t\t\t\tcreator: BROWSER_HAR_CREATOR,\n\t\t\t\tentries: [...this.#entries],\n\t\t\t},\n\t\t}\n\t\tif (this.#options?.path !== undefined) {\n\t\t\tif (this.#writer === undefined) {\n\t\t\t\tthrow new BrowserError('Browser HAR path requires a configured writer')\n\t\t\t}\n\t\t\tawait this.#writer.write(this.#options.path, textToBytes(JSON.stringify(har, undefined, 2)))\n\t\t}\n\t\treturn har\n\t}\n\n\tasync replay(har: BrowserHAR, options?: BrowserHARReplayOptions): Promise<void> {\n\t\tvalidateBrowserHAR(har)\n\t\tif (this.#archive !== undefined) await this.#network.unroute(this.#replayHandler)\n\t\tthis.#archive = har\n\t\tthis.#fallback = options?.fallback === true\n\t\ttry {\n\t\t\tawait this.#network.route({}, this.#replayHandler)\n\t\t} catch (error) {\n\t\t\tthis.#archive = undefined\n\t\t\tthis.#fallback = false\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tif (this.#recording) await this.stop()\n\t\tconst replaying = this.#archive !== undefined\n\t\tthis.#archive = undefined\n\t\tthis.#fallback = false\n\t\tif (replaying) await this.#network.unroute(this.#replayHandler)\n\t\tthis.#entries.length = 0\n\t\tthis.#pending.clear()\n\t}\n\n\t#handleRequest(request: BrowserRequest): void {\n\t\tif (!this.#recording) return\n\t\tthis.#pending.set(request.id, {\n\t\t\trequest,\n\t\t\tstarted: request.walltime === undefined ? Date.now() : request.walltime * 1000,\n\t\t\tresponse: undefined,\n\t\t})\n\t}\n\n\t#handleResponse(response: BrowserResponse): void {\n\t\tconst pending = this.#pending.get(response.id)\n\t\tif (pending === undefined) return\n\t\tthis.#pending.set(response.id, {\n\t\t\trequest: pending.request,\n\t\t\tstarted: pending.started,\n\t\t\tresponse,\n\t\t})\n\t}\n\n\t#handleFailure(failure: BrowserRequestFailure): void {\n\t\tconst pending = this.#pending.get(failure.id)\n\t\tif (pending === undefined) return\n\t\tthis.#pending.delete(failure.id)\n\t\tthis.#entries.push(\n\t\t\tcreateBrowserHAREntry(\n\t\t\t\tpending,\n\t\t\t\tMath.max(0, Date.now() - pending.started),\n\t\t\t\tundefined,\n\t\t\t\tfailure.error,\n\t\t\t),\n\t\t)\n\t}\n\n\t#handleFinish(id: string): void {\n\t\tthis.#track(this.#complete(id))\n\t}\n\n\tasync #handleReplay(route: Parameters<BrowserRouteHandler>[0]): Promise<void> {\n\t\tconst entry = this.#archive?.log.entries.find(\n\t\t\t(candidate) =>\n\t\t\t\tcandidate.request.url === route.request.url &&\n\t\t\t\tcandidate.request.method === route.request.method,\n\t\t)\n\t\tif (entry === undefined || entry.response.status === 0) {\n\t\t\tif (this.#fallback) await route.continue()\n\t\t\telse await route.abort('Failed')\n\t\t\treturn\n\t\t}\n\t\tconst body =\n\t\t\tentry.response.content.text === undefined\n\t\t\t\t? undefined\n\t\t\t\t: entry.response.content.encoding === 'base64'\n\t\t\t\t\t? decodeBase64(entry.response.content.text)\n\t\t\t\t\t: entry.response.content.text\n\t\tawait route.fulfill({\n\t\t\tstatus: entry.response.status,\n\t\t\tphrase: entry.response.statusText,\n\t\t\theaders: browserHARHeadersToRecord(entry.response.headers),\n\t\t\t...(body !== undefined ? { body } : {}),\n\t\t})\n\t}\n\n\tasync #complete(id: string): Promise<void> {\n\t\tconst pending = this.#pending.get(id)\n\t\tif (pending === undefined) return\n\t\tthis.#pending.delete(id)\n\t\tlet body: Uint8Array | undefined\n\t\tif (this.#options?.content === true && pending.response !== undefined) {\n\t\t\ttry {\n\t\t\t\tbody = await this.#network.body(id)\n\t\t\t} catch {\n\t\t\t\t// Some redirects, cached resources, and protocol errors have no retrievable body.\n\t\t\t}\n\t\t}\n\t\tthis.#entries.push(\n\t\t\tcreateBrowserHAREntry(pending, Math.max(0, Date.now() - pending.started), body),\n\t\t)\n\t}\n\n\t#track(task: Promise<void>): void {\n\t\tthis.#tasks.add(task)\n\t\tvoid task\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tif (this.#failure === undefined) this.#failure = error\n\t\t\t})\n\t\t\t.finally(() => this.#tasks.delete(task))\n\t}\n}\n","import type {\n\tBrowserFrameInterface,\n\tBrowserRequest,\n\tBrowserRouteContinueOptions,\n\tBrowserRouteFulfillOptions,\n\tBrowserRouteInterface,\n} from './types.js'\nimport { browserHeadersToProtocol, encodeBase64, textToBytes } from './helpers.js'\nimport { BrowserError } from './errors.js'\nimport { isInteger, isString } from '@orkestrel/contract'\n\n/**\n * Represents one paused request that can be aborted, continued, or fulfilled exactly once.\n */\nexport class BrowserRoute implements BrowserRouteInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #id: string\n\treadonly #request: BrowserRequest\n\t#handled = false\n\t#handling = false\n\n\tconstructor(frame: BrowserFrameInterface, id: string, request: BrowserRequest) {\n\t\tthis.#frame = frame\n\t\tthis.#id = id\n\t\tthis.#request = request\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget request(): BrowserRequest {\n\t\treturn this.#request\n\t}\n\n\tget handled(): boolean {\n\t\treturn this.#handled\n\t}\n\n\tasync abort(reason = 'Failed'): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('Fetch.failRequest', {\n\t\t\t\trequestId: this.#id,\n\t\t\t\terrorReason: reason,\n\t\t\t})\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\tasync continue(options?: BrowserRouteContinueOptions): Promise<void> {\n\t\tthis.#assert()\n\t\tconst params: Record<string, unknown> = { requestId: this.#id }\n\t\tif (options?.url !== undefined) params['url'] = options.url\n\t\tif (options?.method !== undefined) params['method'] = options.method\n\t\tif (options?.headers !== undefined) {\n\t\t\tparams['headers'] = browserHeadersToProtocol(options.headers)\n\t\t}\n\t\tif (options?.post !== undefined) {\n\t\t\tparams['postData'] = encodeBase64(textToBytes(options.post))\n\t\t}\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('Fetch.continueRequest', params)\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\tasync fulfill(options: BrowserRouteFulfillOptions): Promise<void> {\n\t\tthis.#assert()\n\t\tconst status = options.status ?? 200\n\t\tif (!isInteger(status) || status < 100 || status > 999) {\n\t\t\tthrow new BrowserError('Browser route status must be an integer from 100 to 999', undefined, {\n\t\t\t\tstatus,\n\t\t\t})\n\t\t}\n\t\tconst params: Record<string, unknown> = {\n\t\t\trequestId: this.#id,\n\t\t\tresponseCode: status,\n\t\t}\n\t\tif (options.phrase !== undefined) params['responsePhrase'] = options.phrase\n\t\tif (options.headers !== undefined) {\n\t\t\tparams['responseHeaders'] = browserHeadersToProtocol(options.headers)\n\t\t}\n\t\tif (options.body !== undefined) {\n\t\t\tparams['body'] = encodeBase64(\n\t\t\t\tisString(options.body) ? textToBytes(options.body) : options.body,\n\t\t\t)\n\t\t}\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('Fetch.fulfillRequest', params)\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\t#assert(): void {\n\t\tif (this.#handled || this.#handling) throw new BrowserError('Browser route is already handled')\n\t}\n}\n","import type {\n\tBrowserWebSocketEventMap,\n\tBrowserWebSocketFrame,\n\tBrowserWebSocketInterface,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { Emitter } from '@orkestrel/emitter'\n\n/**\n * Represents an observable WebSocket connection reconstructed from Network-domain events.\n *\n * @example\n * ```ts\n * import { BrowserWebSocket } from '@orkestrel/browser'\n *\n * const socket = new BrowserWebSocket('request-1', 'wss://example.com/live')\n * socket.emitter.on('receive', (frame) => log(frame.data))\n * ```\n */\nexport class BrowserWebSocket implements BrowserWebSocketInterface {\n\treadonly #emitter: Emitter<BrowserWebSocketEventMap>\n\treadonly #id: string\n\treadonly #url: string\n\t#closed = false\n\n\tconstructor(id: string, url: string) {\n\t\tthis.#id = id\n\t\tthis.#url = url\n\t\tthis.#emitter = new Emitter()\n\t}\n\n\tget emitter(): EmitterInterface<BrowserWebSocketEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget url(): string {\n\t\treturn this.#url\n\t}\n\n\treceive(frame: BrowserWebSocketFrame): void {\n\t\tif (!this.#closed) this.#emitter.emit('receive', frame)\n\t}\n\n\ttransmit(frame: BrowserWebSocketFrame): void {\n\t\tif (!this.#closed) this.#emitter.emit('transmit', frame)\n\t}\n\n\tfail(message: string): void {\n\t\tif (!this.#closed) this.#emitter.emit('error', message)\n\t}\n\n\tclose(timestamp: number): void {\n\t\tif (this.#closed) return\n\t\tthis.#closed = true\n\t\tthis.#emitter.emit('close', timestamp)\n\t\tthis.#emitter.destroy()\n\t}\n}\n","import type {\n\tBrowserCredentials,\n\tBrowserFrameInterface,\n\tBrowserHARManagerInterface,\n\tBrowserNetworkEventMap,\n\tBrowserNetworkManagerInterface,\n\tBrowserRouteDefinition,\n\tBrowserRouteHandler,\n\tBrowserRouteQuery,\n\tBrowserWriterInterface,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { BrowserTransition } from './BrowserTransition.js'\nimport { BrowserHARManager } from './BrowserHARManager.js'\nimport { BrowserRoute } from './BrowserRoute.js'\nimport { BrowserWebSocket } from './BrowserWebSocket.js'\nimport {\n\tbytesToText,\n\tdecodeBase64,\n\tmatchesBrowserRoute,\n\tsettleBrowserTeardown,\n\ttextToBytes,\n} from './helpers.js'\nimport {\n\tparseBrowserRequest,\n\tparseBrowserRequestFailure,\n\tparseBrowserResponse,\n\tparseBrowserWebSocketFrame,\n} from './parsers.js'\nimport { BrowserError } from './errors.js'\nimport { attempt, isFiniteNumber, isRecord, isString } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\n\n/**\n * Drives the page-scoped Network and Fetch domain lifecycle.\n *\n * @example\n * ```ts\n * import { BrowserNetworkManager } from '@orkestrel/browser'\n *\n * const network = new BrowserNetworkManager(page)\n * await network.start()\n * network.emitter.on('response', (response) => log(response.status))\n * await network.destroy()\n * ```\n */\nexport class BrowserNetworkManager implements BrowserNetworkManagerInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #emitter: Emitter<BrowserNetworkEventMap>\n\treadonly #har: BrowserHARManager\n\treadonly #routes: BrowserRouteDefinition[] = []\n\treadonly #sockets: Map<string, BrowserWebSocket> = new Map()\n\t#credentials: BrowserCredentials | undefined\n\t#started = false\n\t#intercepting = false\n\t#destroyed = false\n\treadonly #starting: BrowserTransition = new BrowserTransition()\n\treadonly #requestHandler = this.#handleRequest.bind(this)\n\treadonly #responseHandler = this.#handleResponse.bind(this)\n\treadonly #failureHandler = this.#handleFailure.bind(this)\n\treadonly #finishHandler = this.#handleFinish.bind(this)\n\treadonly #pausedHandler = this.#handlePause.bind(this)\n\treadonly #authHandler = this.#handleAuth.bind(this)\n\treadonly #socketHandler = this.#handleSocket.bind(this)\n\treadonly #socketReceiveHandler = this.#handleSocketReceive.bind(this)\n\treadonly #socketTransmitHandler = this.#handleSocketTransmit.bind(this)\n\treadonly #socketErrorHandler = this.#handleSocketError.bind(this)\n\treadonly #socketCloseHandler = this.#handleSocketClose.bind(this)\n\n\tconstructor(frame: BrowserFrameInterface, writer?: BrowserWriterInterface) {\n\t\tthis.#frame = frame\n\t\tthis.#emitter = new Emitter()\n\t\tthis.#har = new BrowserHARManager(this, writer)\n\t}\n\n\tget emitter(): EmitterInterface<BrowserNetworkEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget har(): BrowserHARManagerInterface {\n\t\treturn this.#har\n\t}\n\n\tasync start(): Promise<void> {\n\t\tif (this.#destroyed) throw new BrowserError('Browser network manager is destroyed')\n\t\tif (this.#started) return\n\t\tconst active = this.#starting.pending\n\t\tif (active !== undefined) {\n\t\t\tawait active\n\t\t\treturn\n\t\t}\n\t\tawait this.#starting.execute(() => this.#start())\n\t}\n\n\tasync body(id: string): Promise<Uint8Array> {\n\t\tawait this.start()\n\t\tconst result = await this.#frame.send('Network.getResponseBody', { requestId: id })\n\t\tif (!isRecord(result) || !isString(result['body'])) {\n\t\t\tthrow new BrowserError('Browser response body is malformed', undefined, { id })\n\t\t}\n\t\treturn result['base64Encoded'] === true\n\t\t\t? decodeBase64(result['body'])\n\t\t\t: textToBytes(result['body'])\n\t}\n\n\tasync text(id: string): Promise<string> {\n\t\treturn bytesToText(await this.body(id))\n\t}\n\n\tasync json(id: string): Promise<unknown> {\n\t\tconst text = await this.text(id)\n\t\tconst result = attempt<unknown>(() => JSON.parse(text))\n\t\tif (result.success) return result.value\n\t\tthrow new BrowserError('Browser response body is not valid JSON', 'BROWSER_JSON_ERROR', {\n\t\t\tid,\n\t\t\terror: result.error,\n\t\t})\n\t}\n\n\tasync route(query: BrowserRouteQuery, handler: BrowserRouteHandler): Promise<void> {\n\t\tawait this.start()\n\t\tconst definition = { query, handler }\n\t\tthis.#routes.push(definition)\n\t\ttry {\n\t\t\tawait this.#configure()\n\t\t} catch (error) {\n\t\t\tthis.#routes.splice(this.#routes.indexOf(definition), 1)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync unroute(handler?: BrowserRouteHandler): Promise<void> {\n\t\tif (handler === undefined) {\n\t\t\tthis.#routes.length = 0\n\t\t} else {\n\t\t\tfor (let index = this.#routes.length - 1; index >= 0; index -= 1) {\n\t\t\t\tif (this.#routes[index]?.handler === handler) this.#routes.splice(index, 1)\n\t\t\t}\n\t\t}\n\t\tif (this.#started && !this.#destroyed) await this.#configure()\n\t}\n\n\tasync headers(headers: Readonly<Record<string, string>>): Promise<void> {\n\t\tawait this.start()\n\t\tawait this.#frame.send('Network.setExtraHTTPHeaders', { headers })\n\t}\n\n\tasync offline(offline: boolean): Promise<void> {\n\t\tawait this.start()\n\t\tawait this.#frame.send('Network.emulateNetworkConditions', {\n\t\t\toffline,\n\t\t\tlatency: 0,\n\t\t\tdownloadThroughput: -1,\n\t\t\tuploadThroughput: -1,\n\t\t})\n\t}\n\n\tasync credentials(credentials?: BrowserCredentials): Promise<void> {\n\t\tawait this.start()\n\t\tconst previous = this.#credentials\n\t\tthis.#credentials = credentials\n\t\ttry {\n\t\t\tawait this.#configure()\n\t\t} catch (error) {\n\t\t\tthis.#credentials = previous\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tif (this.#destroyed) return\n\t\tthis.#destroyed = true\n\t\tconst failure = await settleBrowserTeardown(\n\t\t\t() => this.#har.clear(),\n\t\t\tasync () => {\n\t\t\t\tif (this.#intercepting) await this.#frame.send('Fetch.disable')\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tif (this.#started) await this.#frame.send('Network.disable')\n\t\t\t},\n\t\t\t() => this.#unsubscribe(),\n\t\t)\n\t\tfor (const socket of this.#sockets.values()) socket.close(Date.now() / 1000)\n\t\tthis.#sockets.clear()\n\t\tthis.#routes.length = 0\n\t\tthis.#emitter.destroy()\n\t\tif (failure !== undefined) throw failure\n\t}\n\n\t#handleRequest(params: Readonly<Record<string, unknown>>): void {\n\t\tconst request = parseBrowserRequest(params)\n\t\tif (request !== undefined) this.#emitter.emit('request', request)\n\t}\n\n\t#handleResponse(params: Readonly<Record<string, unknown>>): void {\n\t\tconst response = parseBrowserResponse(params)\n\t\tif (response !== undefined) this.#emitter.emit('response', response)\n\t}\n\n\t#handleFailure(params: Readonly<Record<string, unknown>>): void {\n\t\tconst failure = parseBrowserRequestFailure(params)\n\t\tif (failure !== undefined) this.#emitter.emit('failure', failure)\n\t}\n\n\t#handleFinish(params: Readonly<Record<string, unknown>>): void {\n\t\tif (isString(params['requestId'])) this.#emitter.emit('finish', params['requestId'])\n\t}\n\n\t#handlePause(params: Readonly<Record<string, unknown>>): void {\n\t\tvoid this.#route(params).catch(() => undefined)\n\t}\n\n\t#handleAuth(params: Readonly<Record<string, unknown>>): void {\n\t\tvoid this.#authenticate(params).catch(() => undefined)\n\t}\n\n\t#handleSocket(params: Readonly<Record<string, unknown>>): void {\n\t\tif (!isString(params['requestId']) || !isString(params['url'])) return\n\t\tconst socket = new BrowserWebSocket(params['requestId'], params['url'])\n\t\tthis.#sockets.set(socket.id, socket)\n\t\tthis.#emitter.emit('socket', socket)\n\t}\n\n\t#handleSocketReceive(params: Readonly<Record<string, unknown>>): void {\n\t\tconst socket = isString(params['requestId'])\n\t\t\t? this.#sockets.get(params['requestId'])\n\t\t\t: undefined\n\t\tconst frame = parseBrowserWebSocketFrame(params)\n\t\tif (socket !== undefined && frame !== undefined) socket.receive(frame)\n\t}\n\n\t#handleSocketTransmit(params: Readonly<Record<string, unknown>>): void {\n\t\tconst socket = isString(params['requestId'])\n\t\t\t? this.#sockets.get(params['requestId'])\n\t\t\t: undefined\n\t\tconst frame = parseBrowserWebSocketFrame(params)\n\t\tif (socket !== undefined && frame !== undefined) socket.transmit(frame)\n\t}\n\n\t#handleSocketError(params: Readonly<Record<string, unknown>>): void {\n\t\tconst socket = isString(params['requestId'])\n\t\t\t? this.#sockets.get(params['requestId'])\n\t\t\t: undefined\n\t\tif (socket !== undefined && isString(params['errorMessage']))\n\t\t\tsocket.fail(params['errorMessage'])\n\t}\n\n\t#handleSocketClose(params: Readonly<Record<string, unknown>>): void {\n\t\tif (!isString(params['requestId'])) return\n\t\tconst socket = this.#sockets.get(params['requestId'])\n\t\tif (socket === undefined) return\n\t\tthis.#sockets.delete(params['requestId'])\n\t\tsocket.close(isFiniteNumber(params['timestamp']) ? params['timestamp'] : Date.now() / 1000)\n\t}\n\n\tasync #start(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#subscribe()\n\t\t\tawait this.#frame.send('Network.enable')\n\t\t\tthis.#started = true\n\t\t\tawait this.#configure()\n\t\t} catch (error) {\n\t\t\tthis.#started = false\n\t\t\tthis.#intercepting = false\n\t\t\tawait this.#frame.send('Fetch.disable').catch(() => undefined)\n\t\t\tawait this.#frame.send('Network.disable').catch(() => undefined)\n\t\t\tawait this.#unsubscribe().catch(() => undefined)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #configure(): Promise<void> {\n\t\tconst enabled = this.#routes.length > 0 || this.#credentials !== undefined\n\t\tif (!enabled) {\n\t\t\tif (this.#intercepting) {\n\t\t\t\tawait this.#frame.send('Fetch.disable')\n\t\t\t\tthis.#intercepting = false\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tawait this.#frame.send('Fetch.enable', {\n\t\t\tpatterns: this.#routes.map((definition) => ({\n\t\t\t\turlPattern: definition.query.url ?? '*',\n\t\t\t\tresourceType: definition.query.resource,\n\t\t\t\trequestStage: 'Request',\n\t\t\t})),\n\t\t\thandleAuthRequests: this.#credentials !== undefined,\n\t\t})\n\t\tthis.#intercepting = true\n\t}\n\n\tasync #route(params: Readonly<Record<string, unknown>>): Promise<void> {\n\t\tconst request = parseBrowserRequest(params)\n\t\tif (request === undefined) {\n\t\t\tif (isString(params['requestId'])) {\n\t\t\t\tawait this.#frame.send('Fetch.failRequest', {\n\t\t\t\t\trequestId: params['requestId'],\n\t\t\t\t\terrorReason: 'Failed',\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tconst definition = this.#routes.find((candidate) =>\n\t\t\tmatchesBrowserRoute(request, candidate.query),\n\t\t)\n\t\tif (definition === undefined) {\n\t\t\tawait this.#frame.send('Fetch.continueRequest', { requestId: request.id })\n\t\t\treturn\n\t\t}\n\t\tconst route = new BrowserRoute(this.#frame, request.id, request)\n\t\ttry {\n\t\t\tawait definition.handler(route)\n\t\t\tif (!route.handled) await route.continue()\n\t\t} catch {\n\t\t\tif (!route.handled) await route.abort('Failed').catch(() => undefined)\n\t\t}\n\t}\n\n\tasync #authenticate(params: Readonly<Record<string, unknown>>): Promise<void> {\n\t\tconst id = params['requestId']\n\t\tif (!isString(id)) return\n\t\tconst credentials = this.#credentials\n\t\tawait this.#frame.send('Fetch.continueWithAuth', {\n\t\t\trequestId: id,\n\t\t\tauthChallengeResponse:\n\t\t\t\tcredentials === undefined\n\t\t\t\t\t? { response: 'Default' }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tresponse: 'ProvideCredentials',\n\t\t\t\t\t\t\tusername: credentials.username,\n\t\t\t\t\t\t\tpassword: credentials.password,\n\t\t\t\t\t\t},\n\t\t})\n\t}\n\n\tasync #subscribe(): Promise<void> {\n\t\tawait this.#frame.subscribe('Network.requestWillBeSent', this.#requestHandler)\n\t\tawait this.#frame.subscribe('Network.responseReceived', this.#responseHandler)\n\t\tawait this.#frame.subscribe('Network.loadingFailed', this.#failureHandler)\n\t\tawait this.#frame.subscribe('Network.loadingFinished', this.#finishHandler)\n\t\tawait this.#frame.subscribe('Fetch.requestPaused', this.#pausedHandler)\n\t\tawait this.#frame.subscribe('Fetch.authRequired', this.#authHandler)\n\t\tawait this.#frame.subscribe('Network.webSocketCreated', this.#socketHandler)\n\t\tawait this.#frame.subscribe('Network.webSocketFrameReceived', this.#socketReceiveHandler)\n\t\tawait this.#frame.subscribe('Network.webSocketFrameSent', this.#socketTransmitHandler)\n\t\tawait this.#frame.subscribe('Network.webSocketFrameError', this.#socketErrorHandler)\n\t\tawait this.#frame.subscribe('Network.webSocketClosed', this.#socketCloseHandler)\n\t}\n\n\tasync #unsubscribe(): Promise<void> {\n\t\tawait this.#frame.unsubscribe('Network.requestWillBeSent', this.#requestHandler)\n\t\tawait this.#frame.unsubscribe('Network.responseReceived', this.#responseHandler)\n\t\tawait this.#frame.unsubscribe('Network.loadingFailed', this.#failureHandler)\n\t\tawait this.#frame.unsubscribe('Network.loadingFinished', this.#finishHandler)\n\t\tawait this.#frame.unsubscribe('Fetch.requestPaused', this.#pausedHandler)\n\t\tawait this.#frame.unsubscribe('Fetch.authRequired', this.#authHandler)\n\t\tawait this.#frame.unsubscribe('Network.webSocketCreated', this.#socketHandler)\n\t\tawait this.#frame.unsubscribe('Network.webSocketFrameReceived', this.#socketReceiveHandler)\n\t\tawait this.#frame.unsubscribe('Network.webSocketFrameSent', this.#socketTransmitHandler)\n\t\tawait this.#frame.unsubscribe('Network.webSocketFrameError', this.#socketErrorHandler)\n\t\tawait this.#frame.unsubscribe('Network.webSocketClosed', this.#socketCloseHandler)\n\t}\n}\n","import type {\n\tBrowserCallOptions,\n\tBrowserDestination,\n\tBrowserNavigationEventMap,\n\tBrowserNavigationReason,\n\tBrowserNavigationRecordInterface,\n\tBrowserSettlementOptions,\n\tBrowserSettlementResult,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { BROWSER_DEFAULT_TIMEOUT_MS } from './constants.js'\nimport { BrowserError } from './errors.js'\nimport { validateBrowserTimeout } from './helpers.js'\n\n/**\n * Records the navigation steps a page accepts after it opens and settles the navigation an input\n * into one frame started.\n *\n * @remarks\n * `BrowserNavigationManager.record` constructs it over the page's navigation steps, the main\n * frame's id, and a lookup of the parent the page last recorded for a frame, which returns\n * `undefined` for a frame whose parent the page cannot name. `lifetime` aborts when the page\n * closes, with the error the record's pending waits reject with.\n *\n * @example\n * ```ts\n * const record = page.navigation.record(element.frame)\n * await element.click()\n * const settled = await record.settle({ destinations, timeout: 4_000 })\n * record.destroy()\n * ```\n */\nexport class BrowserNavigationRecord implements BrowserNavigationRecordInterface {\n\treadonly #steps: EmitterInterface<BrowserNavigationEventMap>\n\treadonly #main: string\n\treadonly #parent: (frame: string) => string | undefined\n\treadonly #frame: string\n\treadonly #lifetime: AbortSignal\n\t// Every step accepted since the record opened, in arrival order, so a settlement that learns its\n\t// destinations after the input selects among the steps that preceded it.\n\treadonly #log: Array<\n\t\t| {\n\t\t\t\treadonly event: 'request'\n\t\t\t\treadonly frame: string\n\t\t\t\treadonly url: string\n\t\t\t\treadonly loader: string | undefined\n\t\t\t\treadonly reason: BrowserNavigationReason | undefined\n\t\t }\n\t\t| {\n\t\t\t\treadonly event: 'commit'\n\t\t\t\treadonly frame: string\n\t\t\t\treadonly url: string\n\t\t\t\treadonly loader: string | undefined\n\t\t\t\treadonly same: boolean\n\t\t }\n\t\t| { readonly event: 'load'; readonly frame: string; readonly loader: string | undefined }\n\t\t| { readonly event: 'detach'; readonly frame: string; readonly swapped: boolean }\n\t> = []\n\treadonly #waits = new Map<\n\t\tsymbol,\n\t\t{\n\t\t\treadonly timer: ReturnType<typeof setTimeout>\n\t\t\treadonly signal: AbortSignal | undefined\n\t\t\treadonly listener: (() => void) | undefined\n\t\t\treadonly resolve: () => void\n\t\t\treadonly reject: (error: unknown) => void\n\t\t}\n\t>()\n\treadonly #settlements = new Map<\n\t\tsymbol,\n\t\t{\n\t\t\treadonly frames: ReadonlySet<string>\n\t\t\treadonly any: boolean\n\t\t\treadonly timer: ReturnType<typeof setTimeout>\n\t\t\treadonly signal: AbortSignal | undefined\n\t\t\treadonly listener: (() => void) | undefined\n\t\t\treadonly resolve: (result: BrowserSettlementResult | undefined) => void\n\t\t\treadonly reject: (error: unknown) => void\n\t\t}\n\t>()\n\t#ended: { readonly reason: unknown } | undefined\n\treadonly #requestHandler = this.#handleRequest.bind(this)\n\treadonly #commitHandler = this.#handleCommit.bind(this)\n\treadonly #loadHandler = this.#handleLoad.bind(this)\n\treadonly #detachHandler = this.#handleDetach.bind(this)\n\treadonly #closeHandler = this.#handleClose.bind(this)\n\n\tconstructor(\n\t\tsteps: EmitterInterface<BrowserNavigationEventMap>,\n\t\tmain: string,\n\t\tparent: (frame: string) => string | undefined,\n\t\tframe: string,\n\t\tlifetime: AbortSignal,\n\t) {\n\t\tthis.#steps = steps\n\t\tthis.#main = main\n\t\tthis.#parent = parent\n\t\tthis.#frame = frame\n\t\tthis.#lifetime = lifetime\n\t\tif (lifetime.aborted) {\n\t\t\tthis.#ended = { reason: lifetime.reason }\n\t\t\treturn\n\t\t}\n\t\tsteps.on('request', this.#requestHandler)\n\t\tsteps.on('commit', this.#commitHandler)\n\t\tsteps.on('load', this.#loadHandler)\n\t\tsteps.on('detach', this.#detachHandler)\n\t\tlifetime.addEventListener('abort', this.#closeHandler, { once: true })\n\t}\n\n\tasync wait(options?: BrowserCallOptions): Promise<void> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst signal = options?.signal\n\t\tif (this.#ended !== undefined) throw this.#ended.reason\n\t\tif (signal?.aborted === true) throw signal.reason\n\t\tif (this.#started()) return\n\t\tconst deferred = Promise.withResolvers<void>()\n\t\tconst id = Symbol('wait')\n\t\tconst listener = signal === undefined ? undefined : this.#abortWait.bind(this, id, signal)\n\t\tif (listener !== undefined) signal?.addEventListener('abort', listener, { once: true })\n\t\tthis.#waits.set(id, {\n\t\t\ttimer: setTimeout(this.#expireWait.bind(this, id, timeout), timeout),\n\t\t\tsignal,\n\t\t\tlistener,\n\t\t\tresolve: deferred.resolve,\n\t\t\treject: deferred.reject,\n\t\t})\n\t\treturn await deferred.promise\n\t}\n\n\tasync settle(options?: BrowserSettlementOptions): Promise<BrowserSettlementResult | undefined> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst signal = options?.signal\n\t\tif (this.#ended !== undefined) throw this.#ended.reason\n\t\tif (signal?.aborted === true) throw signal.reason\n\t\tconst destinations = options?.destinations ?? []\n\t\tconst [frames, any] = this.#resolveFrames(destinations)\n\t\tconst selection = this.#select(frames, any)\n\t\t// Without a destination, a navigation that has not started when the settlement begins was not\n\t\t// the input's.\n\t\tif (selection.done || (selection.result === undefined && destinations.length === 0))\n\t\t\treturn selection.result\n\t\tconst deferred = Promise.withResolvers<BrowserSettlementResult | undefined>()\n\t\tconst id = Symbol('settle')\n\t\tconst listener = signal === undefined ? undefined : this.#abortSettlement.bind(this, id, signal)\n\t\tif (listener !== undefined) signal?.addEventListener('abort', listener, { once: true })\n\t\tthis.#settlements.set(id, {\n\t\t\tframes,\n\t\t\tany,\n\t\t\ttimer: setTimeout(this.#expireSettlement.bind(this, id), timeout),\n\t\t\tsignal,\n\t\t\tlistener,\n\t\t\tresolve: deferred.resolve,\n\t\t\treject: deferred.reject,\n\t\t})\n\t\treturn await deferred.promise\n\t}\n\n\tdestroy(): void {\n\t\tthis.#end(new BrowserError('Browser navigation record ended'))\n\t}\n\n\t#end(reason: unknown): void {\n\t\tif (this.#ended !== undefined) return\n\t\tthis.#ended = { reason }\n\t\tthis.#steps.off('request', this.#requestHandler)\n\t\tthis.#steps.off('commit', this.#commitHandler)\n\t\tthis.#steps.off('load', this.#loadHandler)\n\t\tthis.#steps.off('detach', this.#detachHandler)\n\t\tthis.#lifetime.removeEventListener('abort', this.#closeHandler)\n\t\tfor (const id of [...this.#waits.keys()]) this.#releaseWait(id)?.reject(reason)\n\t\tfor (const id of [...this.#settlements.keys()]) this.#releaseSettlement(id)?.reject(reason)\n\t}\n\n\t// The record's frame and every ancestor the page names, and the main frame, which is every\n\t// frame's ancestor.\n\t#collectAncestors(): Set<string> {\n\t\tconst frames = new Set<string>([this.#main])\n\t\tlet current: string | undefined = this.#frame\n\t\twhile (current !== undefined && !frames.has(current)) {\n\t\t\tframes.add(current)\n\t\t\tcurrent = this.#parent(current)\n\t\t}\n\t\tframes.add(this.#frame)\n\t\treturn frames\n\t}\n\n\t// Resolves each destination to the frame it names; a parent the page cannot name makes every\n\t// frame eligible, and never stands for the main frame.\n\t#resolveFrames(\n\t\tdestinations: readonly BrowserDestination[],\n\t): readonly [frames: ReadonlySet<string>, any: boolean] {\n\t\tconst frames = this.#collectAncestors()\n\t\tlet any = false\n\t\tfor (const { frame, relationship } of destinations) {\n\t\t\tif (relationship === 'top') frames.add(this.#main)\n\t\t\telse if (relationship === 'self') frames.add(frame)\n\t\t\telse if (frame === this.#main) frames.add(this.#main)\n\t\t\telse {\n\t\t\t\tconst parent = this.#parent(frame)\n\t\t\t\tif (parent === undefined) any = true\n\t\t\t\telse frames.add(parent)\n\t\t\t}\n\t\t}\n\t\treturn [frames, any]\n\t}\n\n\t#started(): boolean {\n\t\tconst frames = this.#collectAncestors()\n\t\treturn this.#log.some((step) => step.event === 'request' && frames.has(step.frame))\n\t}\n\n\t// Replays the log against the eligible frames: the earliest eligible start, superseded by a\n\t// later start in its frame before the commit; the commit that carries its loader, or the\n\t// frame's first commit when either loader is unknown; and the load of the commit's loader, or a\n\t// same-document commit. `done` reports a completed navigation or a selected frame that detached.\n\t#select(\n\t\tframes: ReadonlySet<string>,\n\t\tany: boolean,\n\t): { readonly done: boolean; readonly result: BrowserSettlementResult | undefined } {\n\t\tlet start:\n\t\t\t| {\n\t\t\t\t\treadonly frame: string\n\t\t\t\t\treadonly url: string\n\t\t\t\t\treadonly loader: string | undefined\n\t\t\t\t\treadonly reason: BrowserNavigationReason | undefined\n\t\t\t }\n\t\t\t| undefined\n\t\tlet commit: { readonly url: string; readonly loader: string | undefined } | undefined\n\t\tfor (const step of this.#log) {\n\t\t\tif (step.event === 'request') {\n\t\t\t\tif (\n\t\t\t\t\tstart === undefined\n\t\t\t\t\t\t? any || frames.has(step.frame)\n\t\t\t\t\t\t: step.frame === start.frame && commit === undefined\n\t\t\t\t)\n\t\t\t\t\tstart = step\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (start === undefined || step.frame !== start.frame) continue\n\t\t\tif (step.event === 'detach') {\n\t\t\t\tif (!step.swapped) return { done: true, result: this.#stage(start, commit, false) }\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (step.event === 'commit') {\n\t\t\t\tif (commit !== undefined) continue\n\t\t\t\tif (step.same)\n\t\t\t\t\treturn { done: true, result: { url: step.url, stage: 'loaded', reason: start.reason } }\n\t\t\t\tif (start.loader === undefined || step.loader === undefined || step.loader === start.loader)\n\t\t\t\t\tcommit = step\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (commit !== undefined && step.loader === commit.loader)\n\t\t\t\treturn { done: true, result: this.#stage(start, commit, true) }\n\t\t}\n\t\treturn { done: false, result: this.#stage(start, commit, false) }\n\t}\n\n\t#stage(\n\t\tstart:\n\t\t\t| { readonly url: string; readonly reason: BrowserNavigationReason | undefined }\n\t\t\t| undefined,\n\t\tcommit: { readonly url: string } | undefined,\n\t\tloaded: boolean,\n\t): BrowserSettlementResult | undefined {\n\t\tif (start === undefined) return undefined\n\t\tif (commit === undefined) return { url: start.url, stage: 'requested', reason: start.reason }\n\t\treturn { url: commit.url, stage: loaded ? 'loaded' : 'committed', reason: start.reason }\n\t}\n\n\t#wake(): void {\n\t\tif (this.#waits.size > 0 && this.#started())\n\t\t\tfor (const id of [...this.#waits.keys()]) this.#resolveWait(id)\n\t\tfor (const [id, settlement] of [...this.#settlements]) {\n\t\t\tconst selection = this.#select(settlement.frames, settlement.any)\n\t\t\tif (selection.done) this.#resolveSettlement(id, selection.result)\n\t\t}\n\t}\n\n\t// The resolution waits one microtask, so a cancellation that lands in the same turn as the step\n\t// that completed the wait wins with its reason.\n\t#resolveWait(id: symbol): void {\n\t\tconst wait = this.#releaseWait(id)\n\t\tif (wait !== undefined) queueMicrotask(this.#finishWait.bind(this, wait))\n\t}\n\n\t#finishWait(wait: {\n\t\treadonly signal: AbortSignal | undefined\n\t\treadonly resolve: () => void\n\t\treadonly reject: (error: unknown) => void\n\t}): void {\n\t\tif (wait.signal?.aborted === true) wait.reject(wait.signal.reason)\n\t\telse wait.resolve()\n\t}\n\n\t#resolveSettlement(id: symbol, result: BrowserSettlementResult | undefined): void {\n\t\tconst settlement = this.#releaseSettlement(id)\n\t\tif (settlement !== undefined)\n\t\t\tqueueMicrotask(this.#finishSettlement.bind(this, settlement, result))\n\t}\n\n\t#finishSettlement(\n\t\tsettlement: {\n\t\t\treadonly signal: AbortSignal | undefined\n\t\t\treadonly resolve: (result: BrowserSettlementResult | undefined) => void\n\t\t\treadonly reject: (error: unknown) => void\n\t\t},\n\t\tresult: BrowserSettlementResult | undefined,\n\t): void {\n\t\tif (settlement.signal?.aborted === true) settlement.reject(settlement.signal.reason)\n\t\telse settlement.resolve(result)\n\t}\n\n\t#expireWait(id: symbol, timeout: number): void {\n\t\tthis.#releaseWait(id)?.reject(\n\t\t\tnew BrowserError('Browser navigation wait timed out', 'BROWSER_NAVIGATION_TIMEOUT', {\n\t\t\t\tframe: this.#frame,\n\t\t\t\ttimeout,\n\t\t\t}),\n\t\t)\n\t}\n\n\t#expireSettlement(id: symbol): void {\n\t\tconst settlement = this.#settlements.get(id)\n\t\tif (settlement === undefined) return\n\t\tthis.#resolveSettlement(id, this.#select(settlement.frames, settlement.any).result)\n\t}\n\n\t#abortWait(id: symbol, signal: AbortSignal): void {\n\t\tthis.#releaseWait(id)?.reject(signal.reason)\n\t}\n\n\t#abortSettlement(id: symbol, signal: AbortSignal): void {\n\t\tthis.#releaseSettlement(id)?.reject(signal.reason)\n\t}\n\n\t#releaseWait(id: symbol):\n\t\t| {\n\t\t\t\treadonly signal: AbortSignal | undefined\n\t\t\t\treadonly resolve: () => void\n\t\t\t\treadonly reject: (error: unknown) => void\n\t\t }\n\t\t| undefined {\n\t\tconst wait = this.#waits.get(id)\n\t\tif (wait === undefined) return undefined\n\t\tclearTimeout(wait.timer)\n\t\tif (wait.listener !== undefined) wait.signal?.removeEventListener('abort', wait.listener)\n\t\tthis.#waits.delete(id)\n\t\treturn wait\n\t}\n\n\t#releaseSettlement(id: symbol):\n\t\t| {\n\t\t\t\treadonly signal: AbortSignal | undefined\n\t\t\t\treadonly resolve: (result: BrowserSettlementResult | undefined) => void\n\t\t\t\treadonly reject: (error: unknown) => void\n\t\t }\n\t\t| undefined {\n\t\tconst settlement = this.#settlements.get(id)\n\t\tif (settlement === undefined) return undefined\n\t\tclearTimeout(settlement.timer)\n\t\tif (settlement.listener !== undefined)\n\t\t\tsettlement.signal?.removeEventListener('abort', settlement.listener)\n\t\tthis.#settlements.delete(id)\n\t\treturn settlement\n\t}\n\n\t#handleRequest(\n\t\tframe: string,\n\t\turl: string,\n\t\tloader: string | undefined,\n\t\treason: BrowserNavigationReason | undefined,\n\t): void {\n\t\tthis.#log.push({ event: 'request', frame, url, loader, reason })\n\t\tthis.#wake()\n\t}\n\n\t#handleCommit(frame: string, url: string, loader: string | undefined, same: boolean): void {\n\t\tthis.#log.push({ event: 'commit', frame, url, loader, same })\n\t\tthis.#wake()\n\t}\n\n\t#handleLoad(frame: string, loader: string | undefined): void {\n\t\tthis.#log.push({ event: 'load', frame, loader })\n\t\tthis.#wake()\n\t}\n\n\t#handleDetach(frame: string, swapped: boolean): void {\n\t\tthis.#log.push({ event: 'detach', frame, swapped })\n\t\tthis.#wake()\n\t}\n\n\t#handleClose(): void {\n\t\tthis.#end(this.#lifetime.reason)\n\t}\n}\n","import type {\n\tBrowserCallOptions,\n\tBrowserLoaderFunction,\n\tBrowserNavigationEventMap,\n\tBrowserNavigationManagerInterface,\n\tBrowserNavigationRecordInterface,\n\tBrowserNavigationWait,\n\tBrowserPageInterface,\n\tCDPClientInterface,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { BrowserNavigationRecord } from './BrowserNavigationRecord.js'\nimport { BROWSER_DEFAULT_TIMEOUT_MS } from './constants.js'\nimport { matchesBrowserURL, validateBrowserTimeout } from './helpers.js'\nimport { BrowserError } from './errors.js'\nimport { isString } from '@orkestrel/contract'\n\n/**\n * Parks URL-pattern and network-idle waits on page events and abort signals, and opens the records\n * that settle the navigation an input starts.\n *\n * @remarks\n * `steps` carries the navigation steps the page accepts from the session that owns each frame,\n * and `parent` returns the parent the page last recorded for a frame, or `undefined` when the\n * page cannot name it. A record opened here rejects its pending waits with the page-closed error\n * when the page closes.\n *\n * @example\n * ```ts\n * import { BrowserNavigationManager } from '@orkestrel/browser'\n *\n * const navigation = new BrowserNavigationManager(page, client, 'session-1', () => loader, steps, parent)\n * const url = await navigation.wait('https://example.com/checkout', { timeout: 5_000 })\n * await navigation.idle({ signal: AbortSignal.timeout(10_000) })\n * const record = navigation.record(page.id)\n * ```\n */\nexport class BrowserNavigationManager implements BrowserNavigationManagerInterface {\n\treadonly #page: BrowserPageInterface\n\treadonly #client: CDPClientInterface\n\treadonly #session: string\n\treadonly #loader: BrowserLoaderFunction\n\treadonly #steps: EmitterInterface<BrowserNavigationEventMap>\n\treadonly #parent: (frame: string) => string | undefined\n\t// Aborts with the page-closed error when the page closes, which ends every record.\n\treadonly #lifetime = new AbortController()\n\treadonly #waits: Map<symbol, BrowserNavigationWait> = new Map()\n\treadonly #navigateHandler = this.#handleNavigate.bind(this)\n\treadonly #lifecycleHandler = this.#handleLifecycle.bind(this)\n\treadonly #closeHandler = this.#handleClose.bind(this)\n\n\tconstructor(\n\t\tpage: BrowserPageInterface,\n\t\tclient: CDPClientInterface,\n\t\tsession: string,\n\t\tloader: BrowserLoaderFunction,\n\t\tsteps: EmitterInterface<BrowserNavigationEventMap>,\n\t\tparent: (frame: string) => string | undefined,\n\t) {\n\t\tthis.#page = page\n\t\tthis.#client = client\n\t\tthis.#session = session\n\t\tthis.#loader = loader\n\t\tthis.#steps = steps\n\t\tthis.#parent = parent\n\t\tthis.#page.emitter.on('navigate', this.#navigateHandler)\n\t\tthis.#page.emitter.on('close', this.#closeHandler)\n\t\tthis.#client.subscribe('Page.lifecycleEvent', this.#lifecycleHandler, this.#session)\n\t}\n\n\tasync wait(pattern: string, options?: BrowserCallOptions): Promise<string> {\n\t\tconst timeout = this.#timeout(options)\n\t\tif (options?.signal?.aborted === true) throw options.signal.reason\n\t\tif (matchesBrowserURL(this.#page.url, pattern)) return this.#page.url\n\t\treturn await this.#park(pattern, timeout, options?.signal)\n\t}\n\n\tasync idle(options?: BrowserCallOptions): Promise<void> {\n\t\tconst timeout = this.#timeout(options)\n\t\tif (options?.signal?.aborted === true) throw options.signal.reason\n\t\tawait this.#park(undefined, timeout, options?.signal)\n\t}\n\n\trecord(frame: string): BrowserNavigationRecordInterface {\n\t\tthis.#page.assert()\n\t\treturn new BrowserNavigationRecord(\n\t\t\tthis.#steps,\n\t\t\tthis.#page.id,\n\t\t\tthis.#parent,\n\t\t\tframe,\n\t\t\tthis.#lifetime.signal,\n\t\t)\n\t}\n\n\t#park(pattern: string | undefined, timeout: number, signal?: AbortSignal): Promise<string> {\n\t\tconst deferred = Promise.withResolvers<string>()\n\t\tconst id = Symbol(pattern ?? 'idle')\n\t\tconst timer = setTimeout(() => {\n\t\t\tthis.#settle(id)\n\t\t\tdeferred.reject(\n\t\t\t\tnew BrowserError(\n\t\t\t\t\tpattern === undefined\n\t\t\t\t\t\t? 'Browser network idle wait timed out'\n\t\t\t\t\t\t: 'Browser URL wait timed out',\n\t\t\t\t\t'BROWSER_NAVIGATION_TIMEOUT',\n\t\t\t\t\t{ pattern, timeout },\n\t\t\t\t),\n\t\t\t)\n\t\t}, timeout)\n\t\tconst listener = signal === undefined ? undefined : this.#abort(id, signal, deferred.reject)\n\t\tif (listener !== undefined) signal?.addEventListener('abort', listener, { once: true })\n\t\tthis.#waits.set(id, {\n\t\t\tpattern,\n\t\t\ttimer,\n\t\t\tsignal,\n\t\t\tlistener,\n\t\t\tresolve: deferred.resolve,\n\t\t\treject: deferred.reject,\n\t\t})\n\t\treturn deferred.promise\n\t}\n\n\t#abort(id: symbol, signal: AbortSignal, reject: (error: unknown) => void): () => void {\n\t\treturn () => {\n\t\t\tthis.#settle(id)\n\t\t\treject(signal.reason)\n\t\t}\n\t}\n\n\t#settle(id: symbol): BrowserNavigationWait | undefined {\n\t\tconst wait = this.#waits.get(id)\n\t\tif (wait === undefined) return undefined\n\t\tclearTimeout(wait.timer)\n\t\tif (wait.listener !== undefined) wait.signal?.removeEventListener('abort', wait.listener)\n\t\tthis.#waits.delete(id)\n\t\treturn wait\n\t}\n\n\t#handleNavigate(url: string): void {\n\t\tfor (const [id, wait] of this.#waits) {\n\t\t\tif (wait.pattern === undefined || !matchesBrowserURL(url, wait.pattern)) continue\n\t\t\tthis.#settle(id)?.resolve(url)\n\t\t}\n\t}\n\n\t#handleLifecycle(params: Readonly<Record<string, unknown>>): void {\n\t\tconst loader = this.#loader()\n\t\tif (params['name'] !== 'networkIdle' || !isString(params['loaderId'])) return\n\t\tif (loader === undefined || params['loaderId'] !== loader) return\n\t\tfor (const [id, wait] of this.#waits) {\n\t\t\tif (wait.pattern !== undefined) continue\n\t\t\tthis.#settle(id)?.resolve(this.#page.url)\n\t\t}\n\t}\n\n\t#handleClose(): void {\n\t\tthis.#client.unsubscribe('Page.lifecycleEvent', this.#lifecycleHandler, this.#session)\n\t\tconst closed = new BrowserError('Browser navigation wait ended because the page closed')\n\t\tfor (const id of [...this.#waits.keys()]) this.#settle(id)?.reject(closed)\n\t\tthis.#lifetime.abort(closed)\n\t}\n\n\t#timeout(options?: BrowserCallOptions): number {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\treturn timeout\n\t}\n}\n","import type {\n\tBrowserBindingHandler,\n\tBrowserFrameInterface,\n\tBrowserScriptEntry,\n\tBrowserScriptManagerInterface,\n} from './types.js'\nimport {\n\tcompileBrowserBindingCleanup,\n\tcompileBrowserBindingResult,\n\tcompileBrowserBindingSource,\n} from './compilers.js'\nimport { readBrowserScriptIdentifier } from './helpers.js'\nimport { parseBrowserBindingCall } from './parsers.js'\nimport { BrowserError } from './errors.js'\n\n/**\n * Installs new-document scripts and promise-based host functions for one page.\n *\n * @example\n * ```ts\n * import { BrowserScriptManager } from '@orkestrel/browser'\n *\n * const scripts = new BrowserScriptManager(page)\n * const id = await scripts.add('window.__ready = true')\n * await scripts.remove(id)\n * ```\n */\nexport class BrowserScriptManager implements BrowserScriptManagerInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #bindings: Map<string, BrowserBindingHandler> = new Map()\n\treadonly #scripts: Map<string, BrowserScriptEntry> = new Map()\n\t#subscribed = false\n\t#destroyed = false\n\treadonly #bindingHandler = this.#handleBinding.bind(this)\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tasync add(source: string): Promise<string> {\n\t\tthis.#assert()\n\t\tconst result = await this.#frame.send('Page.addScriptToEvaluateOnNewDocument', { source })\n\t\tconst id = readBrowserScriptIdentifier(result)\n\t\tthis.#scripts.set(id, { source, binding: undefined })\n\t\ttry {\n\t\t\tawait this.#frame.evaluate(`(() => { ${source}\\n })()`)\n\t\t\treturn id\n\t\t} catch (error) {\n\t\t\tawait this.#frame\n\t\t\t\t.send('Page.removeScriptToEvaluateOnNewDocument', { identifier: id })\n\t\t\t\t.catch(() => undefined)\n\t\t\tthis.#scripts.delete(id)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync remove(id: string): Promise<void> {\n\t\tthis.#assert()\n\t\tif (!this.#scripts.has(id)) return\n\t\tawait this.#frame.send('Page.removeScriptToEvaluateOnNewDocument', { identifier: id })\n\t\tthis.#scripts.delete(id)\n\t}\n\n\tasync expose(name: string, handler: BrowserBindingHandler): Promise<void> {\n\t\tthis.#assert()\n\t\tif (!/^[$A-Z_a-z][$\\w]*$/.test(name)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Browser binding name must be a valid JavaScript identifier',\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tname,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (this.#bindings.has(name)) {\n\t\t\tthrow new BrowserError('Browser binding already exists', undefined, { name })\n\t\t}\n\t\tconst subscribed = this.#subscribed\n\t\tif (!subscribed) {\n\t\t\tawait this.#frame.subscribe('Runtime.bindingCalled', this.#bindingHandler)\n\t\t\tthis.#subscribed = true\n\t\t}\n\t\tlet added = false\n\t\ttry {\n\t\t\tawait this.#frame.send('Runtime.addBinding', { name })\n\t\t\tadded = true\n\t\t\tconst id = await this.add(compileBrowserBindingSource(name))\n\t\t\tconst entry = this.#scripts.get(id)\n\t\t\tif (entry === undefined) {\n\t\t\t\tthrow new BrowserError('Browser binding script registration was lost', undefined, {\n\t\t\t\t\tname,\n\t\t\t\t})\n\t\t\t}\n\t\t\tthis.#scripts.set(id, { source: entry.source, binding: name })\n\t\t\tthis.#bindings.set(name, handler)\n\t\t} catch (error) {\n\t\t\tif (added) {\n\t\t\t\tawait this.#frame.send('Runtime.removeBinding', { name }).catch(() => undefined)\n\t\t\t}\n\t\t\tif (!subscribed && this.#bindings.size === 0) {\n\t\t\t\tawait this.#frame\n\t\t\t\t\t.unsubscribe('Runtime.bindingCalled', this.#bindingHandler)\n\t\t\t\t\t.catch(() => undefined)\n\t\t\t\tthis.#subscribed = false\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync revoke(name: string): Promise<void> {\n\t\tthis.#assert()\n\t\tif (!this.#bindings.has(name)) return\n\t\tfor (const [id, entry] of this.#scripts) {\n\t\t\tif (entry.binding !== name) continue\n\t\t\tawait this.#frame.send('Page.removeScriptToEvaluateOnNewDocument', { identifier: id })\n\t\t\tthis.#scripts.delete(id)\n\t\t}\n\t\tawait this.#frame.evaluate(compileBrowserBindingCleanup(name))\n\t\tawait this.#frame.send('Runtime.removeBinding', { name })\n\t\tthis.#bindings.delete(name)\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tif (this.#destroyed) return\n\t\tfor (const name of [...this.#bindings.keys()]) {\n\t\t\tawait this.revoke(name).catch(() => undefined)\n\t\t}\n\t\tfor (const id of [...this.#scripts.keys()]) {\n\t\t\tawait this.remove(id).catch(() => undefined)\n\t\t}\n\t\tif (this.#subscribed) {\n\t\t\tawait this.#frame\n\t\t\t\t.unsubscribe('Runtime.bindingCalled', this.#bindingHandler)\n\t\t\t\t.catch(() => undefined)\n\t\t}\n\t\tthis.#subscribed = false\n\t\tthis.#destroyed = true\n\t}\n\n\tasync #call(params: Readonly<Record<string, unknown>>): Promise<void> {\n\t\tconst call = parseBrowserBindingCall(params)\n\t\tif (call === undefined) return\n\t\tconst handler = this.#bindings.get(call.name)\n\t\tif (handler === undefined) return\n\t\ttry {\n\t\t\tconst value = await handler(...call.args)\n\t\t\tawait this.#frame.send('Runtime.evaluate', {\n\t\t\t\texpression: compileBrowserBindingResult(call.name, call.id, true, value),\n\t\t\t\tcontextId: call.context,\n\t\t\t\tawaitPromise: true,\n\t\t\t})\n\t\t} catch (error) {\n\t\t\tawait this.#frame.send('Runtime.evaluate', {\n\t\t\t\texpression: compileBrowserBindingResult(call.name, call.id, false, String(error)),\n\t\t\t\tcontextId: call.context,\n\t\t\t\tawaitPromise: true,\n\t\t\t})\n\t\t}\n\t}\n\n\t#handleBinding(params: Readonly<Record<string, unknown>>): void {\n\t\tvoid this.#call(params).catch(() => undefined)\n\t}\n\n\t#assert(): void {\n\t\tif (this.#destroyed) throw new BrowserError('Browser script manager is destroyed')\n\t}\n}\n","import type {\n\tBrowserDocument,\n\tBrowserNode,\n\tBrowserNodePredicate,\n\tBrowserNodeQuery,\n\tBrowserSiblingRelation,\n\tBrowserSnapshotInput,\n\tBrowserSnapshotInterface,\n\tBrowserWalkOptions,\n} from './types.js'\nimport { isInteger } from '@orkestrel/contract'\nimport { BrowserError } from './errors.js'\nimport { isBrowserNodeQuery, matchesBrowserNode } from './helpers.js'\n\n/**\n * Represents a navigable, serializable browser DOM snapshot.\n *\n * @example\n * ```ts\n * import { BrowserSnapshot } from '@orkestrel/browser'\n *\n * const snapshot = new BrowserSnapshot({ documents, styles: ['display'] })\n * const main = snapshot.find({ name: 'main', visible: true })\n * ```\n */\nexport class BrowserSnapshot implements BrowserSnapshotInterface {\n\t// Documents are fixed and frozen at construction, so the derived owner index cannot go stale.\n\t#owners: ReadonlyMap<number, BrowserNode> | undefined\n\treadonly documents: readonly BrowserDocument[]\n\treadonly styles: readonly string[]\n\n\tconstructor(input: BrowserSnapshotInput) {\n\t\tthis.documents = Object.freeze([...input.documents])\n\t\tthis.styles = Object.freeze([...input.styles])\n\t}\n\n\twalk(options?: BrowserWalkOptions): Generator<BrowserNode, void, unknown> {\n\t\treturn options?.order === 'breadth' ? this.#breadth(options.root) : this.#depth(options?.root)\n\t}\n\n\t*descendants(node: BrowserNode): Generator<BrowserNode, void, unknown> {\n\t\tlet first = true\n\t\tfor (const descendant of this.#depth(node)) {\n\t\t\tif (first) {\n\t\t\t\tfirst = false\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tyield descendant\n\t\t}\n\t}\n\n\tdocument(node: BrowserNode): BrowserDocument | undefined {\n\t\treturn this.documents.find((document) => document.index === node.document)\n\t}\n\n\tchildren(node: BrowserNode): readonly BrowserNode[] {\n\t\tconst document = this.document(node)\n\t\tif (document === undefined) return []\n\t\tconst children = document.nodes.filter((candidate) => candidate.parent === node.index)\n\t\tif (node.content === undefined) return children\n\t\tconst content = this.documents.find((candidate) => candidate.index === node.content)\n\t\tif (content === undefined) return children\n\t\treturn [...children, ...content.nodes.filter((candidate) => candidate.parent === undefined)]\n\t}\n\n\tparent(node: BrowserNode): BrowserNode | undefined {\n\t\tconst document = this.document(node)\n\t\tif (document === undefined) return undefined\n\t\treturn node.parent === undefined ? this.#owner(node.document) : document.nodes[node.parent]\n\t}\n\n\tsiblings(node: BrowserNode, relation?: BrowserSiblingRelation): readonly BrowserNode[] {\n\t\tconst candidates = this.#candidates(node)\n\t\tconst index = candidates.findIndex(\n\t\t\t(candidate) => candidate.document === node.document && candidate.index === node.index,\n\t\t)\n\t\tif (relation === 'preceding') return index < 0 ? [] : candidates.slice(0, index)\n\t\tif (relation === 'following') return index < 0 ? [] : candidates.slice(index + 1)\n\t\treturn candidates.filter(\n\t\t\t(candidate) => candidate.document !== node.document || candidate.index !== node.index,\n\t\t)\n\t}\n\n\tancestors(node: BrowserNode): readonly BrowserNode[] {\n\t\tconst ancestors: BrowserNode[] = []\n\t\tconst visited = new Set<string>()\n\t\tlet current = node\n\n\t\twhile (true) {\n\t\t\tconst parent = this.parent(current)\n\t\t\tif (parent === undefined) break\n\t\t\tconst identity = this.#identity(parent)\n\t\t\tif (visited.has(identity)) break\n\t\t\tvisited.add(identity)\n\t\t\tancestors.push(parent)\n\t\t\tcurrent = parent\n\t\t}\n\t\treturn ancestors\n\t}\n\n\tcommon(first: BrowserNode, second: BrowserNode): BrowserNode | undefined {\n\t\tconst firstAncestors = this.#chain(first)\n\t\tconst secondAncestors = this.#chain(second)\n\t\tconst identities = new Set(firstAncestors.map((node) => this.#identity(node)))\n\t\treturn secondAncestors.find((node) => identities.has(this.#identity(node)))\n\t}\n\n\tdistance(first: BrowserNode, second: BrowserNode): number | undefined {\n\t\tconst common = this.common(first, second)\n\t\tif (common === undefined) return undefined\n\t\tconst identity = this.#identity(common)\n\t\tconst firstDistance = this.#chain(first).findIndex((node) => this.#identity(node) === identity)\n\t\tconst secondDistance = this.#chain(second).findIndex(\n\t\t\t(node) => this.#identity(node) === identity,\n\t\t)\n\t\tif (firstDistance < 0 || secondDistance < 0) return undefined\n\t\treturn firstDistance + secondDistance\n\t}\n\n\tfind(query: BrowserNodeQuery | BrowserNodePredicate): BrowserNode | undefined {\n\t\tfor (const node of this.walk()) {\n\t\t\tif (this.#match(node, query)) return node\n\t\t}\n\t\treturn undefined\n\t}\n\n\tfilter(query: BrowserNodeQuery | BrowserNodePredicate, limit?: number): readonly BrowserNode[] {\n\t\tif (limit !== undefined && (!isInteger(limit) || limit < 0)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Browser node result limit must be a non-negative integer',\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tlimit,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (limit === 0) return []\n\t\tconst found: BrowserNode[] = []\n\t\tfor (const node of this.walk()) {\n\t\t\tif (!this.#match(node, query)) continue\n\t\t\tfound.push(node)\n\t\t\tif (limit !== undefined && found.length >= limit) break\n\t\t}\n\t\treturn found\n\t}\n\n\tclosest(\n\t\tnode: BrowserNode,\n\t\tquery: BrowserNodeQuery | BrowserNodePredicate,\n\t): BrowserNode | undefined {\n\t\tif (this.#match(node, query)) return node\n\t\tfor (const ancestor of this.ancestors(node)) {\n\t\t\tif (this.#match(ancestor, query)) return ancestor\n\t\t}\n\t\treturn undefined\n\t}\n\n\tpath(node: BrowserNode): string {\n\t\tconst document = this.document(node)\n\t\tif (document === undefined) return `document:${node.document} > node:${node.index}`\n\t\tconst chain = [...this.ancestors(node)].reverse()\n\t\tchain.push(node)\n\t\tconst segments: string[] = []\n\n\t\tfor (const current of chain) {\n\t\t\tif (current.category !== 1) {\n\t\t\t\tsegments.push(`${current.name.toLowerCase()}:${current.index}`)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlet ordinal = 1\n\t\t\tif (current.parent !== undefined) {\n\t\t\t\tconst owner = this.document(current)\n\t\t\t\tfor (const sibling of owner?.nodes ?? []) {\n\t\t\t\t\tif (sibling.index >= current.index) break\n\t\t\t\t\tif (sibling.parent === current.parent && sibling.name === current.name) ordinal += 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tsegments.push(`${current.name.toLowerCase()}:${ordinal}`)\n\t\t}\n\n\t\treturn `frame(${JSON.stringify(document.frame)}) > ${segments.join(' > ')}`\n\t}\n\n\t#roots(): readonly BrowserNode[] {\n\t\tconst roots: BrowserNode[] = []\n\t\tfor (const document of this.documents) {\n\t\t\troots.push(...document.nodes.filter((node) => node.parent === undefined))\n\t\t}\n\t\tfor (const document of this.documents) roots.push(...document.nodes)\n\t\treturn roots\n\t}\n\n\t#owner(document: number): BrowserNode | undefined {\n\t\tconst owners = this.#owners\n\t\tif (owners !== undefined) return owners.get(document)\n\t\tconst index = new Map<number, BrowserNode>()\n\t\tfor (const node of this.walk()) {\n\t\t\tif (node.content !== undefined && !index.has(node.content)) index.set(node.content, node)\n\t\t}\n\t\tthis.#owners = index\n\t\treturn index.get(document)\n\t}\n\n\t*#depth(root?: BrowserNode): Generator<BrowserNode, void, unknown> {\n\t\tconst visited = new Set<string>()\n\t\tfor (const seed of root === undefined ? this.#roots() : [root]) {\n\t\t\tconst stack: BrowserNode[] = [seed]\n\t\t\twhile (stack.length > 0) {\n\t\t\t\tconst node = stack.pop()\n\t\t\t\tif (node === undefined) break\n\t\t\t\tconst identity = this.#identity(node)\n\t\t\t\tif (visited.has(identity)) continue\n\t\t\t\tvisited.add(identity)\n\t\t\t\tyield node\n\n\t\t\t\tconst children = this.children(node)\n\t\t\t\tfor (let index = children.length - 1; index >= 0; index -= 1) {\n\t\t\t\t\tconst child = children[index]\n\t\t\t\t\tif (child !== undefined) stack.push(child)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t*#breadth(root?: BrowserNode): Generator<BrowserNode, void, unknown> {\n\t\tconst visited = new Set<string>()\n\t\tfor (const seed of root === undefined ? this.#roots() : [root]) {\n\t\t\tconst queue: BrowserNode[] = [seed]\n\t\t\tlet cursor = 0\n\t\t\twhile (cursor < queue.length) {\n\t\t\t\tconst node = queue[cursor]\n\t\t\t\tcursor += 1\n\t\t\t\tif (node === undefined) continue\n\t\t\t\tconst identity = this.#identity(node)\n\t\t\t\tif (visited.has(identity)) continue\n\t\t\t\tvisited.add(identity)\n\t\t\t\tyield node\n\t\t\t\tqueue.push(...this.children(node))\n\t\t\t}\n\t\t}\n\t}\n\n\t#candidates(node: BrowserNode): readonly BrowserNode[] {\n\t\tconst parent = this.parent(node)\n\t\treturn parent === undefined\n\t\t\t? (this.document(node)?.nodes.filter((candidate) => candidate.parent === undefined) ?? [])\n\t\t\t: this.children(parent)\n\t}\n\n\t#chain(node: BrowserNode): readonly BrowserNode[] {\n\t\treturn [node, ...this.ancestors(node)]\n\t}\n\n\t#match(node: BrowserNode, query: BrowserNodeQuery | BrowserNodePredicate): boolean {\n\t\treturn isBrowserNodeQuery(query) ? matchesBrowserNode(node, query) : query(node)\n\t}\n\n\t#identity(node: BrowserNode): string {\n\t\treturn `${node.document}:${node.index}`\n\t}\n}\n","import type {\n\tBrowserCallOptions,\n\tBrowserWorkerCategory,\n\tBrowserWorkerInterface,\n\tCDPClientInterface,\n} from './types.js'\nimport { BROWSER_RESULT_LIMIT } from './constants.js'\nimport { compileGuardedEvaluateExpression } from './compilers.js'\nimport { readEvaluationResult } from './helpers.js'\nimport { BrowserError } from './errors.js'\n\n/**\n * Represents a dedicated, shared, or service worker attached through a flattened target session.\n */\nexport class BrowserWorker implements BrowserWorkerInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #session: string\n\treadonly #id: string\n\treadonly #url: string\n\treadonly #category: BrowserWorkerCategory\n\t#closed = false\n\n\tconstructor(\n\t\tclient: CDPClientInterface,\n\t\tsession: string,\n\t\tid: string,\n\t\turl: string,\n\t\tcategory: BrowserWorkerCategory,\n\t) {\n\t\tthis.#client = client\n\t\tthis.#session = session\n\t\tthis.#id = id\n\t\tthis.#url = url\n\t\tthis.#category = category\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget url(): string {\n\t\treturn this.#url\n\t}\n\n\tget category(): BrowserWorkerCategory {\n\t\treturn this.#category\n\t}\n\n\tasync evaluate(expression: string, options?: BrowserCallOptions): Promise<unknown> {\n\t\tthis.#assert()\n\t\treturn readEvaluationResult(\n\t\t\tawait this.#client.send(\n\t\t\t\t'Runtime.evaluate',\n\t\t\t\t{\n\t\t\t\t\texpression: compileGuardedEvaluateExpression(expression, BROWSER_RESULT_LIMIT),\n\t\t\t\t\treturnByValue: true,\n\t\t\t\t\tawaitPromise: true,\n\t\t\t\t},\n\t\t\t\t{ session: this.#session, ...options },\n\t\t\t),\n\t\t)\n\t}\n\n\tasync send(\n\t\tmethod: string,\n\t\tparams?: Readonly<Record<string, unknown>>,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<unknown> {\n\t\tthis.#assert()\n\t\treturn await this.#client.send(method, params, { session: this.#session, ...options })\n\t}\n\n\tdetach(): void {\n\t\tthis.#closed = true\n\t}\n\n\tasync close(): Promise<void> {\n\t\tif (this.#closed) return\n\t\tthis.#closed = true\n\t\ttry {\n\t\t\tawait this.#client.send('Target.closeTarget', { targetId: this.#id })\n\t\t} catch {\n\t\t\t// The worker may already have terminated.\n\t\t}\n\t}\n\n\t#assert(): void {\n\t\tif (this.#closed) throw new BrowserError('Browser worker is closed')\n\t\tif (!this.#client.connected) throw new BrowserError('Browser worker is disconnected')\n\t}\n}\n","import type {\n\tBrowserElementManagerInterface,\n\tBrowserPageElementInterface,\n\tBrowserReadinessWait,\n\tBrowserReferenceFunction,\n\tBrowserCallOptions,\n\tBrowserCodegenInterface,\n\tBrowserRecorderOptions,\n\tBrowserClockInterface,\n\tBrowserDiagnosticsInterface,\n\tBrowserFrameInfo,\n\tBrowserFrameInterface,\n\tBrowserKeyboardInterface,\n\tBrowserMouseInterface,\n\tBrowserNavigationEventMap,\n\tBrowserNavigationReason,\n\tBrowserNavigationOptions,\n\tBrowserNavigationManagerInterface,\n\tBrowserNavigationResult,\n\tBrowserNavigationWatch,\n\tBrowserNetworkManagerInterface,\n\tBrowserPDFOptions,\n\tBrowserPDFResult,\n\tBrowserPageInterface,\n\tBrowserPageEventMap,\n\tBrowserPageOptions,\n\tBrowserPopupManagerInterface,\n\tBrowserPopupRecordInterface,\n\tBrowserReadingInterface,\n\tBrowserRect,\n\tBrowserRegistryInterface,\n\tBrowserResponse,\n\tBrowserScreenshotOptions,\n\tBrowserScreenshotResult,\n\tBrowserScriptManagerInterface,\n\tBrowserSnapshotInterface,\n\tBrowserSnapshotOptions,\n\tBrowserTouchInterface,\n\tBrowserWaitUntil,\n\tBrowserWorkerCategory,\n\tBrowserAccessibilityInterface,\n\tCDPClientInterface,\n\tCDPHandler,\n\tBrowserWriterInterface,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { BrowserCodegen } from './recorders/BrowserCodegen.js'\nimport { BrowserElementManager } from './elements/BrowserElementManager.js'\nimport { BrowserRegistry } from './BrowserRegistry.js'\nimport { BrowserTransition } from './BrowserTransition.js'\nimport { BrowserAccessibility } from './BrowserAccessibility.js'\nimport { BrowserClock } from './BrowserClock.js'\nimport { BrowserDiagnostics } from './BrowserDiagnostics.js'\nimport { BrowserDialog } from './BrowserDialog.js'\nimport { BrowserDownload } from './BrowserDownload.js'\nimport { BrowserFrame } from './BrowserFrame.js'\nimport { BrowserFileChooser } from './BrowserFileChooser.js'\nimport { BrowserKeyboard } from './BrowserKeyboard.js'\nimport { BrowserMouse } from './BrowserMouse.js'\nimport { BrowserTouch } from './BrowserTouch.js'\nimport { BrowserNetworkManager } from './BrowserNetworkManager.js'\nimport { BrowserNavigationManager } from './BrowserNavigationManager.js'\nimport { BrowserScriptManager } from './BrowserScriptManager.js'\nimport { BrowserSnapshot } from './BrowserSnapshot.js'\nimport { BrowserWorker } from './BrowserWorker.js'\nimport { BrowserError } from './errors.js'\nimport {\n\tBROWSER_DEFAULT_TIMEOUT_MS,\n\tBROWSER_NAVIGATION_REASONS,\n\tBROWSER_RELOAD_NAVIGATION_TYPES,\n\tBROWSER_REFERENCE_PREFIX,\n\tBROWSER_FRAME_WORLD_NAME,\n\tBROWSER_SNAPSHOT_NODE_LIMIT,\n\tBROWSER_STOP_LOADING_TIMEOUT_MS,\n} from './constants.js'\nimport {\n\tcompileTextWaitExpression,\n\tcompileScreenshotCleanupExpression,\n\tcompileScreenshotPreparationExpression,\n} from './compilers.js'\nimport {\n\tdecodeBase64,\n\treadBrowserSnapshot,\n\tbrowserPDFToParams,\n\tbrowserScreenshotToParams,\n\treadBrowserFrames,\n\treadBrowserWorld,\n\treadEvaluationResult,\n\trequireBrowserString,\n\tvalidateBrowserTimeout,\n} from './helpers.js'\nimport {\n\tparseBrowserConsoleMessage,\n\tparseBrowserDownloadProgress,\n\tparseBrowserDownloadStart,\n\tparseBrowserPageError,\n} from './parsers.js'\nimport {\n\tisArray,\n\tisError,\n\tisFiniteNumber,\n\tisInteger,\n\tisRecord,\n\tisString,\n} from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\n\n/**\n * Represents a top-level browser page, including its target lifecycle and child frames.\n *\n * @remarks\n * Only a page constructed with a `reference` function, as `BrowserContext` constructs every page,\n * takes part in target ownership and discovery. Such a page holds its target on the client's\n * current connection until it closes, its connection ends, or the `ready` promise its constructing\n * path passes rejects: constructing a second such page for a target a live page holds throws\n * `BROWSER_TARGET_HELD`, and the first such page on a connection enables\n * `Target.setDiscoverTargets` for it. A page constructed without `ready`, with or without an\n * `opener`, is complete as constructed; `ready` is the constructing path's completion, and a\n * popup a page constructs is complete when that page emits it.\n *\n * A page publishes each page it opens through `popup` once, never a closed one, and only after it\n * is complete itself. An unattached page target that discovery reports with this page as\n * `openerId`, live or before this page existed, is attached on the browser session, so the popup\n * outlives its opener; an attachment on this page's session is taken as it arrives; a target\n * another page holds is published as that page after its `ready` resolves, while it still holds\n * the target; and the second session for one target is detached. A page detaches its own session\n * through the session it was attached through.\n *\n * @example\n * ```ts\n * import { BrowserPage } from '@orkestrel/browser'\n *\n * const page = new BrowserPage(client, 'target-1', 'session-1')\n * await page.navigate('https://example.com')\n * const shot = await page.screenshot({ format: 'png' })\n * await page.close()\n * ```\n */\nexport class BrowserPage extends BrowserFrame implements BrowserPageInterface {\n\t// Per client, the pages that hold a target on its current connection and the discovery reports\n\t// whose opener no held page is yet; the end of a connection and a new one clear both.\n\tstatic readonly #held: WeakMap<CDPClientInterface, Map<string, BrowserPage>> = new WeakMap()\n\tstatic readonly #reports: WeakMap<\n\t\tCDPClientInterface,\n\t\tMap<string, Readonly<Record<string, unknown>>>\n\t> = new WeakMap()\n\tstatic readonly #discovered: WeakSet<CDPClientInterface> = new WeakSet()\n\treadonly #client: CDPClientInterface\n\treadonly #targetId: string\n\treadonly #sessionId: string\n\treadonly #writer: BrowserWriterInterface | undefined\n\treadonly #contextId: string | undefined\n\t#opener: BrowserPageInterface | undefined\n\t// The session this page's session was attached through; undefined for the browser session.\n\t#owner: string | undefined\n\t// Settles when the path that constructed this page completes it, or rejects when that path fails:\n\t// for a context page, when the context publishes it; for a popup, when its setup finishes; for a\n\t// page constructed without `ready`, at once.\n\treadonly #setup: Promise<void>\n\t// Resolves when this page is published, which a popup this page publishes and a discovery report\n\t// waiting for this page wait for; rejects when the page releases.\n\treadonly #announcement = Promise.withResolvers<void>()\n\treadonly #emitter: Emitter<BrowserPageEventMap>\n\treadonly #elements: BrowserElementManager\n\treadonly #keyboard: BrowserKeyboard\n\treadonly #mouse: BrowserMouse\n\treadonly #touch: BrowserTouch\n\treadonly #reference: BrowserReferenceFunction\n\treadonly #readiness = new Map<symbol, BrowserReadinessWait>()\n\t#referenceSequence = 0\n\t#waitSequence = 0\n\t#dom: string | undefined\n\t#seed: Promise<void> | undefined\n\treadonly #lifecycleHandler = this.#handleLifecycle.bind(this)\n\treadonly #network: BrowserNetworkManager\n\treadonly #navigationManager: BrowserNavigationManager\n\treadonly #scripts: BrowserScriptManager\n\treadonly #accessibility: BrowserAccessibility\n\treadonly #diagnostics: BrowserDiagnostics\n\treadonly #clock: BrowserClock\n\t// Each frame has one owning session, whose attempt settles to that session once its domains enable.\n\treadonly #frameSessions: Map<\n\t\tstring,\n\t\t{ readonly session: string; readonly attempt: Promise<string> }\n\t> = new Map()\n\treadonly #frameIds: Map<string, string> = new Map()\n\treadonly #iframes: Map<string, BrowserFrameInfo> = new Map()\n\t// The latest current-tab request per frame that no start has taken yet, from any session the\n\t// page knows, because the document that initiates a navigation reports the request even when\n\t// another session owns the navigating frame; the owning session's start for the same URL takes\n\t// its reason unless it repeats a history entry. The next request replaces an entry, and every\n\t// start of the frame, a same-document commit, the frame's removal, and the page's teardown delete\n\t// it, so the map holds at most one entry per attached frame.\n\treadonly #pending: Map<\n\t\tstring,\n\t\t{ readonly url: string; readonly reason: BrowserNavigationReason | undefined }\n\t> = new Map()\n\treadonly #downloads: Map<string, BrowserDownload> = new Map()\n\treadonly #workers: Map<string, BrowserWorker> = new Map()\n\treadonly #popups: Map<string, BrowserPage> = new Map()\n\t// A popup target an attach is initializing, so the attach that arrives second, through discovery\n\t// or through an attachment event, initializes nothing.\n\treadonly #claimed: Set<string> = new Set()\n\t// Each open popup record's observations since it opened, replaced on every change: the\n\t// `Page.windowOpen` reports counted, the popup targets the page began to adopt, and each of those\n\t// targets that concluded, mapped to its page when announced and to undefined when skipped.\n\treadonly #records: Map<\n\t\tsymbol,\n\t\t{\n\t\t\treadonly opened: number\n\t\t\treadonly targets: ReadonlySet<string>\n\t\t\treadonly outcomes: ReadonlyMap<string, BrowserPage | undefined>\n\t\t}\n\t> = new Map()\n\t// Wakes every pending popup settle after a record changes or ends.\n\treadonly #wakes: Set<() => void> = new Set()\n\treadonly #popupManager: BrowserPopupManagerInterface = {\n\t\trecord: this.#recordPopups.bind(this),\n\t}\n\treadonly #openHandler = this.#handleOpen.bind(this)\n\t// A frame with no entry has not changed since the last page-frame document change, whose\n\t// epoch `#floor` holds, so the map holds only the frames of the current document.\n\treadonly #epochs: Map<string, number> = new Map()\n\treadonly #worlds: Map<string, { readonly session: string; readonly context: number }> = new Map()\n\t// A pending creation records its session so a context-cleared event on that session can\n\t// invalidate it before it publishes.\n\treadonly #creating: Map<string, { readonly session: string; readonly promise: Promise<number> }> =\n\t\tnew Map()\n\treadonly #sessionHandlers: Map<\n\t\tstring,\n\t\t{\n\t\t\treadonly destroyed: CDPHandler\n\t\t\treadonly cleared: CDPHandler\n\t\t\treadonly navigated: CDPHandler\n\t\t\treadonly routed: CDPHandler\n\t\t\treadonly detached: CDPHandler\n\t\t\treadonly attached: CDPHandler\n\t\t\treadonly requested: CDPHandler\n\t\t\treadonly started: CDPHandler\n\t\t\treadonly lifecycle: CDPHandler\n\t\t\treadonly stopped: CDPHandler\n\t\t\treadonly target: CDPHandler\n\t\t\treadonly released: CDPHandler\n\t\t}\n\t> = new Map()\n\t// The navigation steps each frame's owning session reports, which the navigation and element\n\t// managers consume; see `#accepts` for the ownership rule.\n\treadonly #steps = new Emitter<BrowserNavigationEventMap>()\n\t// The parent of each frame whose attach, frame tree, or target named one.\n\treadonly #parents: Map<string, string> = new Map()\n\t// The loader of each frame's latest accepted commit, so a stop is a load only for a commit that\n\t// named no loader.\n\treadonly #loaders: Map<string, string | undefined> = new Map()\n\t// The frame of each attach whose domain enable has not settled, keyed by its frame session, so a\n\t// navigation the frame session reports before publication reaches the published record.\n\treadonly #attaching: Map<string, BrowserFrameInfo> = new Map()\n\t#epoch = 0\n\t#floor = 0\n\t#closed = false\n\t#codegen: BrowserCodegen | undefined\n\t#registry: BrowserRegistry | undefined\n\treadonly #codegenStart: BrowserTransition<BrowserCodegen> = new BrowserTransition()\n\t#navigation: Promise<BrowserNavigationResult> | undefined\n\t#closing: Promise<void> | undefined\n\t#releasing: Promise<void> | undefined\n\t#loadEvents: readonly string[] = []\n\t#sameDocument = false\n\t#loader: string | undefined\n\t#loadTimer: ReturnType<typeof setTimeout> | undefined\n\t#loadResolve: (() => void) | undefined\n\t#loadReject: ((error: unknown) => void) | undefined\n\t#loadAbort: { readonly signal: AbortSignal; readonly listener: () => void } | undefined\n\t#responses: BrowserResponse[] | undefined\n\treadonly #navigationResponseHandler = this.#handleNavigationResponse.bind(this)\n\treadonly #destroyHandler = this.#handleDestroy.bind(this)\n\treadonly #loadHandler = this.#handleLoad.bind(this)\n\treadonly #restoreHandler = this.#handleRestore.bind(this)\n\treadonly #dialogHandler = this.#handleDialog.bind(this)\n\treadonly #chooserHandler = this.#handleChooser.bind(this)\n\treadonly #consoleHandler = this.#handleConsole.bind(this)\n\treadonly #errorHandler = this.#handleError.bind(this)\n\treadonly #crashHandler = this.#handleCrash.bind(this)\n\treadonly #downloadHandler = this.#handleDownload.bind(this)\n\treadonly #downloadProgressHandler = this.#handleDownloadProgress.bind(this)\n\n\tconstructor(\n\t\tclient: CDPClientInterface,\n\t\ttargetId: string,\n\t\tsessionId: string,\n\t\twriter?: BrowserWriterInterface,\n\t\turl?: string,\n\t\tframeId?: string,\n\t\tcontextId?: string,\n\t\topener?: BrowserPageInterface,\n\t\toptions?: BrowserPageOptions,\n\t\treference?: BrowserReferenceFunction,\n\t\tready?: Promise<void>,\n\t) {\n\t\tsuper(\n\t\t\tclient,\n\t\t\tsessionId,\n\t\t\tframeId ?? targetId,\n\t\t\turl ?? 'about:blank',\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tfalse,\n\t\t\t() => this.#epochOf(this.id),\n\t\t\t(session, call) => this.#world(this.id, session, call),\n\t\t)\n\t\tconst held = reference === undefined ? undefined : BrowserPage.#track(client)\n\t\tconst holder = held?.get(targetId)\n\t\tif (holder !== undefined && !holder.#closed)\n\t\t\tthrow new BrowserError('Browser target already has a page', 'BROWSER_TARGET_HELD', {\n\t\t\t\ttarget: targetId,\n\t\t\t})\n\t\tthis.#client = client\n\t\tthis.#targetId = targetId\n\t\tthis.#sessionId = sessionId\n\t\tthis.#writer = writer\n\t\tthis.#contextId = contextId\n\t\tthis.#opener = opener\n\t\tthis.#setup = ready ?? Promise.resolve()\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on !== undefined ? { on: options.on } : {}),\n\t\t\t...(options?.error !== undefined ? { error: options.error } : {}),\n\t\t})\n\t\tthis.#reference = reference ?? this.#nextReference.bind(this)\n\t\tthis.#elements = new BrowserElementManager({\n\t\t\tnavigation: this.#epochOf.bind(this),\n\t\t\tsteps: this.#steps,\n\t\t\tpage: this,\n\t\t\tclient,\n\t\t\tsession: sessionId,\n\t\t\tresolve: this.#resolveFrameSession.bind(this),\n\t\t\tworld: this.#world.bind(this),\n\t\t\treference: this.#reference,\n\t\t\tready: this.#ready.bind(this),\n\t\t})\n\t\tthis.#keyboard = new BrowserKeyboard(this)\n\t\tthis.#mouse = new BrowserMouse(this)\n\t\tthis.#touch = new BrowserTouch(this)\n\t\tthis.#client.subscribe('Page.lifecycleEvent', this.#lifecycleHandler, sessionId)\n\t\tthis.#network = new BrowserNetworkManager(this, writer)\n\t\tthis.#navigationManager = new BrowserNavigationManager(\n\t\t\tthis,\n\t\t\tclient,\n\t\t\tsessionId,\n\t\t\t() => this.#loader,\n\t\t\tthis.#steps,\n\t\t\tthis.#parents.get.bind(this.#parents),\n\t\t)\n\t\tthis.#scripts = new BrowserScriptManager(this)\n\t\tthis.#accessibility = new BrowserAccessibility(this)\n\t\tthis.#diagnostics = new BrowserDiagnostics(this, writer)\n\t\tthis.#clock = new BrowserClock(this)\n\t\tthis.#network.emitter.on('request', (request) => this.#emitter.emit('request', request))\n\t\tthis.#network.emitter.on('response', (response) => this.#emitter.emit('response', response))\n\t\tthis.#network.emitter.on('failure', (failure) => this.#emitter.emit('failure', failure))\n\t\tthis.#network.emitter.on('socket', (socket) => this.#emitter.emit('socket', socket))\n\n\t\tthis.#client.subscribe('Target.targetDestroyed', this.#destroyHandler)\n\t\tthis.#watchSession(this.#sessionId)\n\t\tthis.#client.subscribe('Page.javascriptDialogOpening', this.#dialogHandler, this.#sessionId)\n\t\tthis.#client.subscribe('Page.windowOpen', this.#openHandler, this.#sessionId)\n\t\tthis.#client.subscribe('Page.fileChooserOpened', this.#chooserHandler, this.#sessionId)\n\t\tthis.#client.subscribe('Runtime.consoleAPICalled', this.#consoleHandler, this.#sessionId)\n\t\tthis.#client.subscribe('Runtime.exceptionThrown', this.#errorHandler, this.#sessionId)\n\t\tthis.#client.subscribe('Inspector.targetCrashed', this.#crashHandler, this.#sessionId)\n\t\tthis.#client.subscribe('Browser.downloadWillBegin', this.#downloadHandler)\n\t\tthis.#client.subscribe('Browser.downloadProgress', this.#downloadProgressHandler)\n\t\tvoid this.#announcement.promise.catch(() => undefined)\n\t\tvoid this.#setup.then(\n\t\t\t() => {\n\t\t\t\tif (ready === undefined || opener === undefined) this.#announcement.resolve()\n\t\t\t},\n\t\t\t() => this.#unhold(),\n\t\t)\n\t\tif (held === undefined) return\n\t\theld.set(targetId, this)\n\t\tif (!BrowserPage.#discovered.has(client)) {\n\t\t\tBrowserPage.#discovered.add(client)\n\t\t\tvoid client\n\t\t\t\t.send('Target.setDiscoverTargets', { discover: true })\n\t\t\t\t.catch(() => BrowserPage.#discovered.delete(client))\n\t\t}\n\t\tvoid this.#announcement.promise.then(\n\t\t\t() => this.#drain(),\n\t\t\t() => undefined,\n\t\t)\n\t}\n\n\tget emitter(): EmitterInterface<BrowserPageEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget elements(): BrowserElementManagerInterface<BrowserPageElementInterface> {\n\t\treturn this.#elements\n\t}\n\n\tget trusted(): true {\n\t\treturn true\n\t}\n\n\tget keyboard(): BrowserKeyboardInterface {\n\t\treturn this.#keyboard\n\t}\n\n\tget mouse(): BrowserMouseInterface {\n\t\treturn this.#mouse\n\t}\n\n\tget touch(): BrowserTouchInterface {\n\t\treturn this.#touch\n\t}\n\n\t// The page's reading waits for the current document's DOMContentLoaded, as the outline does,\n\t// so a read issued while a navigation loads captures the loaded document.\n\toverride async read(options?: BrowserCallOptions): Promise<BrowserReadingInterface> {\n\t\tawait this.#ready(options)\n\t\treturn await super.read(options)\n\t}\n\n\tasync wait(text: string, options?: BrowserCallOptions): Promise<void> {\n\t\tthis.assert()\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst end = performance.now() + timeout\n\t\twhile (true) {\n\t\t\toptions?.signal?.throwIfAborted()\n\t\t\tconst remaining = Math.max(0, end - performance.now())\n\t\t\tawait this.#ready({ ...options, timeout: remaining })\n\t\t\tconst context = await this.#world(this.id, this.#sessionId, options)\n\t\t\tconst key = `__browserTextWait${++this.#waitSequence}`\n\t\t\ttry {\n\t\t\t\tconst result = await this.send(\n\t\t\t\t\t'Runtime.evaluate',\n\t\t\t\t\t{\n\t\t\t\t\t\texpression: compileTextWaitExpression(text, remaining, key),\n\t\t\t\t\t\tcontextId: context,\n\t\t\t\t\t\treturnByValue: true,\n\t\t\t\t\t\tawaitPromise: true,\n\t\t\t\t\t},\n\t\t\t\t\t{ ...options, timeout: remaining + 1000 },\n\t\t\t\t)\n\t\t\t\tif (readEvaluationResult(result) !== true)\n\t\t\t\t\tthrow new BrowserError('Browser text wait timed out', 'BROWSER_WAIT_TIMEOUT', {\n\t\t\t\t\t\ttext,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t})\n\t\t\t\treturn\n\t\t\t} catch (error) {\n\t\t\t\tif (options?.signal?.aborted === true) {\n\t\t\t\t\tawait this.send(\n\t\t\t\t\t\t'Runtime.evaluate',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\texpression: `globalThis[${JSON.stringify(key)}]?.()`,\n\t\t\t\t\t\t\tcontextId: context,\n\t\t\t\t\t\t\treturnByValue: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ timeout: 1000 },\n\t\t\t\t\t).catch(() => undefined)\n\t\t\t\t\tthrow options.signal.reason\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!isError(error) ||\n\t\t\t\t\t!/execution context was destroyed|cannot find context with specified id/i.test(\n\t\t\t\t\t\terror.message,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tthrow error\n\t\t\t\tthis.#dom = undefined\n\t\t\t\tif (performance.now() >= end)\n\t\t\t\t\tthrow new BrowserError('Browser text wait timed out', 'BROWSER_WAIT_TIMEOUT', {\n\t\t\t\t\t\ttext,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t})\n\t\t\t\tawait this.#parkReadiness({ ...options, timeout: Math.max(0, end - performance.now()) })\n\t\t\t}\n\t\t}\n\t}\n\n\tget network(): BrowserNetworkManagerInterface {\n\t\treturn this.#network\n\t}\n\n\tget registry(): BrowserRegistryInterface {\n\t\tthis.assert()\n\t\tthis.#registry ??= new BrowserRegistry(this, this.#client, this.#sessionId, this.#frameIds)\n\t\treturn this.#registry\n\t}\n\n\tget navigation(): BrowserNavigationManagerInterface {\n\t\treturn this.#navigationManager\n\t}\n\n\tget popups(): BrowserPopupManagerInterface {\n\t\treturn this.#popupManager\n\t}\n\n\tget scripts(): BrowserScriptManagerInterface {\n\t\treturn this.#scripts\n\t}\n\n\tget accessibility(): BrowserAccessibilityInterface {\n\t\treturn this.#accessibility\n\t}\n\n\tget diagnostics(): BrowserDiagnosticsInterface {\n\t\treturn this.#diagnostics\n\t}\n\n\tget clock(): BrowserClockInterface {\n\t\treturn this.#clock\n\t}\n\n\tget opener(): BrowserPageInterface | undefined {\n\t\treturn this.#opener\n\t}\n\n\tget target(): string {\n\t\treturn this.#targetId\n\t}\n\n\tget closed(): boolean {\n\t\treturn this.#closed\n\t}\n\n\tasync navigate(\n\t\turl: string,\n\t\toptions?: BrowserNavigationOptions,\n\t): Promise<BrowserNavigationResult> {\n\t\tthis.assert()\n\t\twhile (this.#navigation !== undefined) {\n\t\t\tawait this.#navigation.catch(() => undefined)\n\t\t}\n\t\tthis.assert()\n\t\tconst navigation = this.#navigate(url, options)\n\t\tthis.#navigation = navigation\n\n\t\ttry {\n\t\t\treturn await navigation\n\t\t} finally {\n\t\t\tif (this.#navigation === navigation) this.#navigation = undefined\n\t\t}\n\t}\n\n\tasync reload(options?: BrowserNavigationOptions): Promise<BrowserNavigationResult> {\n\t\tthis.assert()\n\t\twhile (this.#navigation !== undefined) {\n\t\t\tawait this.#navigation.catch(() => undefined)\n\t\t}\n\t\tthis.assert()\n\t\tconst navigation = this.#reload(options)\n\t\tthis.#navigation = navigation\n\n\t\ttry {\n\t\t\treturn await navigation\n\t\t} finally {\n\t\t\tif (this.#navigation === navigation) this.#navigation = undefined\n\t\t}\n\t}\n\n\tasync back(options?: BrowserNavigationOptions): Promise<BrowserNavigationResult> {\n\t\treturn await this.#history(-1, options)\n\t}\n\n\tasync forward(options?: BrowserNavigationOptions): Promise<BrowserNavigationResult> {\n\t\treturn await this.#history(1, options)\n\t}\n\n\tasync screenshot(options?: BrowserScreenshotOptions): Promise<BrowserScreenshotResult> {\n\t\tthis.assert()\n\t\tconst params: Record<string, unknown> = { ...browserScreenshotToParams(options) }\n\n\t\tif (options?.full === true) {\n\t\t\tconst metrics = await this.send('Page.getLayoutMetrics')\n\t\t\tconst size =\n\t\t\t\tisRecord(metrics) && isRecord(metrics['cssContentSize'])\n\t\t\t\t\t? metrics['cssContentSize']\n\t\t\t\t\t: isRecord(metrics) && isRecord(metrics['contentSize'])\n\t\t\t\t\t\t? metrics['contentSize']\n\t\t\t\t\t\t: undefined\n\t\t\tconst width = size?.['width']\n\t\t\tconst height = size?.['height']\n\t\t\tif (!isFiniteNumber(width) || width <= 0 || !isFiniteNumber(height) || height <= 0) {\n\t\t\t\tthrow new BrowserError('Browser full-page screenshot metrics are malformed')\n\t\t\t}\n\t\t\tparams['clip'] = { x: 0, y: 0, width, height, scale: 1 }\n\t\t\tparams['captureBeyondViewport'] = true\n\t\t}\n\n\t\tif (options?.scale !== undefined) {\n\t\t\tconst ratio = options.scale === 'css' ? 1 : await this.evaluate('devicePixelRatio')\n\t\t\tif (!isFiniteNumber(ratio) || ratio <= 0) {\n\t\t\t\tthrow new BrowserError('Browser screenshot device scale is malformed')\n\t\t\t}\n\t\t\tif (!isRecord(params['clip'])) {\n\t\t\t\tconst metrics = await this.send('Page.getLayoutMetrics')\n\t\t\t\tconst viewport =\n\t\t\t\t\tisRecord(metrics) && isRecord(metrics['cssVisualViewport'])\n\t\t\t\t\t\t? metrics['cssVisualViewport']\n\t\t\t\t\t\t: undefined\n\t\t\t\tif (\n\t\t\t\t\tviewport === undefined ||\n\t\t\t\t\t!isFiniteNumber(viewport['pageX']) ||\n\t\t\t\t\t!isFiniteNumber(viewport['pageY']) ||\n\t\t\t\t\t!isFiniteNumber(viewport['clientWidth']) ||\n\t\t\t\t\tviewport['clientWidth'] <= 0 ||\n\t\t\t\t\t!isFiniteNumber(viewport['clientHeight']) ||\n\t\t\t\t\tviewport['clientHeight'] <= 0\n\t\t\t\t) {\n\t\t\t\t\tthrow new BrowserError('Browser screenshot viewport metrics are malformed')\n\t\t\t\t}\n\t\t\t\tparams['clip'] = {\n\t\t\t\t\tx: viewport['pageX'],\n\t\t\t\t\ty: viewport['pageY'],\n\t\t\t\t\twidth: viewport['clientWidth'],\n\t\t\t\t\theight: viewport['clientHeight'],\n\t\t\t\t\tscale: ratio,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparams['clip']['scale'] = ratio\n\t\t\t}\n\t\t}\n\n\t\tlet token: string | undefined\n\t\tlet transparent = false\n\t\ttry {\n\t\t\tconst masks: BrowserRect[] = []\n\t\t\tfor (const element of options?.mask ?? []) {\n\t\t\t\tconst { points } = await element.quad()\n\t\t\t\tconst xs = points.filter((_value, index) => index % 2 === 0)\n\t\t\t\tconst ys = points.filter((_value, index) => index % 2 !== 0)\n\t\t\t\tconst left = Math.min(...xs)\n\t\t\t\tconst top = Math.min(...ys)\n\t\t\t\tmasks.push([left, top, Math.max(...xs) - left, Math.max(...ys) - top])\n\t\t\t}\n\t\t\tconst preparation = compileScreenshotPreparationExpression(options, masks)\n\t\t\tif (preparation !== undefined) {\n\t\t\t\tconst value = await this.evaluate(preparation)\n\t\t\t\tif (!isString(value)) throw new BrowserError('Browser screenshot preparation failed')\n\t\t\t\ttoken = value\n\t\t\t}\n\t\t\tif (options?.transparent === true) {\n\t\t\t\tawait this.send('Emulation.setDefaultBackgroundColorOverride', {\n\t\t\t\t\tcolor: { r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t})\n\t\t\t\ttransparent = true\n\t\t\t}\n\t\t\tconst result = await this.send('Page.captureScreenshot', params)\n\t\t\tif (!isRecord(result) || !isString(result['data'])) {\n\t\t\t\tthrow new BrowserError('Screenshot failed: no data returned')\n\t\t\t}\n\n\t\t\tconst bytes = decodeBase64(result['data'])\n\t\t\tif (options?.path !== undefined) await this.save(options.path, bytes)\n\t\t\treturn { bytes, path: options?.path }\n\t\t} finally {\n\t\t\tif (transparent) {\n\t\t\t\tawait this.send('Emulation.setDefaultBackgroundColorOverride').catch(() => undefined)\n\t\t\t}\n\t\t\tif (token !== undefined) {\n\t\t\t\tawait this.evaluate(compileScreenshotCleanupExpression(token)).catch(() => undefined)\n\t\t\t}\n\t\t}\n\t}\n\n\tasync pdf(options?: BrowserPDFOptions): Promise<BrowserPDFResult> {\n\t\tthis.assert()\n\t\tconst result = await this.send('Page.printToPDF', browserPDFToParams(options))\n\t\tif (!isRecord(result) || !isString(result['data'])) {\n\t\t\tthrow new BrowserError('PDF failed: no data returned')\n\t\t}\n\t\tconst bytes = decodeBase64(result['data'])\n\t\tif (options?.path !== undefined) await this.save(options.path, bytes)\n\t\treturn { bytes, path: options?.path }\n\t}\n\n\toverride async save(path: string, bytes: Uint8Array): Promise<void> {\n\t\tif (this.#writer === undefined) {\n\t\t\tthrow new BrowserError('Browser page has no configured file writer', undefined, { path })\n\t\t}\n\t\tawait this.#writer.write(path, bytes)\n\t}\n\n\tasync frame(name: string): Promise<BrowserFrameInterface | undefined> {\n\t\tconst frames = await this.frames()\n\t\treturn frames.find((frame) => frame.name === name || frame.url === name)\n\t}\n\n\tasync frames(): Promise<readonly BrowserFrameInterface[]> {\n\t\tthis.assert()\n\t\tconst result = await this.send('Page.getFrameTree')\n\t\tconst frames = readBrowserFrames(result, [...this.#iframes.values()])\n\t\tfor (const { id, parent } of frames) if (parent !== undefined) this.#parents.set(id, parent)\n\t\treturn frames.map((frame) => this.#frame(frame))\n\t}\n\n\tasync snapshot(options?: BrowserSnapshotOptions): Promise<BrowserSnapshotInterface> {\n\t\tthis.assert()\n\t\tconst styles = options?.styles ?? []\n\t\tconst result = await this.send('DOMSnapshot.captureSnapshot', {\n\t\t\tcomputedStyles: [...styles],\n\t\t\tincludePaintOrder: options?.paint ?? false,\n\t\t\tincludeDOMRects: options?.rects ?? false,\n\t\t})\n\t\treturn new BrowserSnapshot(\n\t\t\treadBrowserSnapshot(result, styles, options?.limit ?? BROWSER_SNAPSHOT_NODE_LIMIT),\n\t\t)\n\t}\n\n\tasync codegen(options?: BrowserRecorderOptions): Promise<BrowserCodegenInterface> {\n\t\tthis.assert()\n\t\tconst active = this.#codegenStart.pending\n\t\tif (active !== undefined) return await active\n\t\tif (this.#codegen !== undefined) return this.#codegen\n\n\t\treturn await this.#codegenStart.execute(() => this.#startCodegen(options))\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tconst active = this.#closing\n\t\tif (active !== undefined) return active\n\n\t\tthis.#closed = true\n\t\tconst closing = this.#destroy()\n\t\tthis.#closing = closing\n\t\treturn closing\n\t}\n\n\tclose(): Promise<void> {\n\t\tconst active = this.#closing\n\t\tif (active !== undefined) return active\n\n\t\tif (this.#closed) {\n\t\t\tconst closing = this.#release()\n\t\t\tthis.#closing = closing\n\t\t\treturn closing\n\t\t}\n\n\t\tthis.#closed = true\n\t\tconst closing = this.#close()\n\t\tthis.#closing = closing\n\t\treturn closing\n\t}\n\n\toverride assert(): void {\n\t\tsuper.assert()\n\t\tif (this.#closed) throw new BrowserError('Browser page is closed')\n\t}\n\n\tasync #navigate(\n\t\turl: string,\n\t\toptions?: BrowserNavigationOptions,\n\t): Promise<BrowserNavigationResult> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst signal = options?.signal\n\t\tconst call = { timeout, ...(signal === undefined ? {} : { signal }) }\n\t\tconst watch = this.#watchNavigation()\n\t\tconst condition = options?.condition ?? 'load'\n\t\tconst wait = this.#waitForLoadEvent(condition, timeout, signal)\n\t\tvoid wait.catch(() => undefined)\n\t\tlet loader: string | undefined\n\n\t\t// A load or a completion read that settles in the same tick as an abort leaves the signal as\n\t\t// the only witness, so cancellation is checked after the wait and after the completion read.\n\t\ttry {\n\t\t\tconst result = await this.send('Page.navigate', { url }, call)\n\t\t\tif (isRecord(result) && isString(result['errorText'])) {\n\t\t\t\tthrow new BrowserError(`Navigation failed: ${result['errorText']}`)\n\t\t\t}\n\t\t\tif (isRecord(result) && isString(result['loaderId'])) {\n\t\t\t\tloader = result['loaderId']\n\t\t\t\tthis.#loader = loader\n\t\t\t}\n\t\t\tawait wait\n\t\t\tsignal?.throwIfAborted()\n\t\t\tconst completed = await this.#completeNavigation(watch, loader, call)\n\t\t\tsignal?.throwIfAborted()\n\t\t\treturn completed\n\t\t} catch (error) {\n\t\t\tthis.#clearNavigationWatch(watch)\n\t\t\tthis.#cancelLoad()\n\t\t\tawait this.#stopLoading(Math.min(timeout, BROWSER_STOP_LOADING_TIMEOUT_MS))\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #reload(options?: BrowserNavigationOptions): Promise<BrowserNavigationResult> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst signal = options?.signal\n\t\tconst call = { timeout, ...(signal === undefined ? {} : { signal }) }\n\t\tconst watch = this.#watchNavigation()\n\t\tconst wait = this.#waitForLoadEvent(options?.condition ?? 'load', timeout, signal)\n\t\tvoid wait.catch(() => undefined)\n\n\t\t// Cancellation is checked after the wait and after the completion read, as `#navigate` does.\n\t\ttry {\n\t\t\tawait this.send('Page.reload', undefined, call)\n\t\t\tawait wait\n\t\t\tsignal?.throwIfAborted()\n\t\t\tconst completed = await this.#completeNavigation(watch, undefined, call)\n\t\t\tsignal?.throwIfAborted()\n\t\t\treturn completed\n\t\t} catch (error) {\n\t\t\tthis.#clearNavigationWatch(watch)\n\t\t\tthis.#cancelLoad()\n\t\t\tawait this.#stopLoading(Math.min(timeout, BROWSER_STOP_LOADING_TIMEOUT_MS))\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #history(\n\t\toffset: -1 | 1,\n\t\toptions?: BrowserNavigationOptions,\n\t): Promise<BrowserNavigationResult> {\n\t\tthis.assert()\n\t\toptions?.signal?.throwIfAborted()\n\t\twhile (this.#navigation !== undefined) {\n\t\t\tawait this.#navigation.catch(() => undefined)\n\t\t}\n\t\tthis.assert()\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst navigation = this.#navigateHistory(offset, options)\n\t\tthis.#navigation = navigation\n\n\t\ttry {\n\t\t\treturn await navigation\n\t\t} finally {\n\t\t\tif (this.#navigation === navigation) this.#navigation = undefined\n\t\t}\n\t}\n\n\tasync #navigateHistory(\n\t\toffset: -1 | 1,\n\t\toptions?: BrowserNavigationOptions,\n\t): Promise<BrowserNavigationResult> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst signal = options?.signal\n\t\tconst call = { timeout, ...(signal === undefined ? {} : { signal }) }\n\t\tconst history = await this.send('Page.getNavigationHistory', undefined, call)\n\t\tsignal?.throwIfAborted()\n\t\tif (!isRecord(history) || !isInteger(history['currentIndex']) || !isArray(history['entries'])) {\n\t\t\tthrow new BrowserError('Navigation history is malformed')\n\t\t}\n\t\tconst entry = history['entries'][history['currentIndex'] + offset]\n\t\tif (!isRecord(entry) || !isInteger(entry['id'])) {\n\t\t\treturn { url: this.url, response: undefined, same: false }\n\t\t}\n\n\t\tconst watch = this.#watchNavigation()\n\t\tconst condition = options?.condition ?? 'load'\n\t\tconst wait = this.#waitForLoadEvent(condition, timeout, signal)\n\t\tvoid wait.catch(() => undefined)\n\t\t// A back-forward cache restore commits a document that already loaded, so Chromium fires no\n\t\t// load or DOMContentLoaded event for it and the restore itself settles those two conditions.\n\t\tconst restorable = condition === 'load' || condition === 'domcontentloaded'\n\t\tif (restorable)\n\t\t\tthis.#client.subscribe('Page.frameNavigated', this.#restoreHandler, this.#sessionId)\n\t\t// A restore or load that settles the wait in the same tick as an abort leaves the signal as the\n\t\t// only witness, so cancellation is checked after the wait and after the completion read.\n\t\ttry {\n\t\t\tawait this.send('Page.navigateToHistoryEntry', { entryId: entry['id'] }, call)\n\t\t\tawait wait\n\t\t\tsignal?.throwIfAborted()\n\t\t\tconst result = await this.#completeNavigation(watch, undefined, call)\n\t\t\tsignal?.throwIfAborted()\n\t\t\treturn result\n\t\t} catch (error) {\n\t\t\tthis.#clearNavigationWatch(watch)\n\t\t\tthis.#cancelLoad()\n\t\t\tawait this.#stopLoading(Math.min(timeout, BROWSER_STOP_LOADING_TIMEOUT_MS))\n\t\t\tthrow error\n\t\t} finally {\n\t\t\tif (restorable)\n\t\t\t\tthis.#client.unsubscribe('Page.frameNavigated', this.#restoreHandler, this.#sessionId)\n\t\t}\n\t}\n\n\t#watchNavigation(): BrowserNavigationWatch {\n\t\tconst responses: BrowserResponse[] = []\n\t\tthis.#responses = responses\n\t\tthis.#network.emitter.on('response', this.#navigationResponseHandler)\n\t\treturn { responses }\n\t}\n\n\t#clearNavigationWatch(watch: BrowserNavigationWatch): void {\n\t\tthis.#network.emitter.off('response', this.#navigationResponseHandler)\n\t\tif (this.#responses === watch.responses) this.#responses = undefined\n\t}\n\n\t#navigationResult(\n\t\twatch: BrowserNavigationWatch,\n\t\turl: string,\n\t\tloader?: string,\n\t): BrowserNavigationResult {\n\t\tthis.#clearNavigationWatch(watch)\n\t\tconst response =\n\t\t\tloader === undefined\n\t\t\t\t? watch.responses.findLast((candidate) => candidate.url === url)\n\t\t\t\t: watch.responses.findLast((candidate) => candidate.loader === loader)\n\t\treturn {\n\t\t\turl,\n\t\t\tresponse,\n\t\t\tsame: this.#sameDocument,\n\t\t}\n\t}\n\n\tasync #completeNavigation(\n\t\twatch: BrowserNavigationWatch,\n\t\tloader?: string,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<BrowserNavigationResult> {\n\t\ttry {\n\t\t\tconst currentUrl = await this.evaluate('location.href', options)\n\t\t\tconst resolved = requireBrowserString(currentUrl, 'Navigation URL')\n\t\t\tthis.update(resolved)\n\t\t\treturn this.#navigationResult(watch, resolved, loader)\n\t\t} catch (error) {\n\t\t\tthis.#clearNavigationWatch(watch)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #startCodegen(options?: BrowserRecorderOptions): Promise<BrowserCodegen> {\n\t\tconst codegen = new BrowserCodegen(this.#client, this.#sessionId, options, () =>\n\t\t\t[...this.#frameSessions.values()].map(({ session }) => session),\n\t\t)\n\t\tthis.#codegen = codegen\n\t\ttry {\n\t\t\tawait codegen.start()\n\t\t} catch (error) {\n\t\t\tthis.#codegen = undefined\n\t\t\tawait codegen.destroy()\n\t\t\tthrow error\n\t\t}\n\t\tif (this.#closed) {\n\t\t\tawait codegen.destroy()\n\t\t\tthrow new BrowserError('Browser page is closed')\n\t\t}\n\t\tthis.#codegen = codegen\n\t\treturn codegen\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\tawait this.#release()\n\t\ttry {\n\t\t\tawait this.#client.send(\n\t\t\t\t'Target.detachFromTarget',\n\t\t\t\t{ sessionId: this.#sessionId },\n\t\t\t\tthis.#owner === undefined ? undefined : { session: this.#owner },\n\t\t\t)\n\t\t} catch {\n\t\t\t// The session may already be detached.\n\t\t}\n\t}\n\n\tasync #close(): Promise<void> {\n\t\tawait this.#release()\n\t\ttry {\n\t\t\tawait this.#client.send('Target.closeTarget', { targetId: this.#targetId })\n\t\t} catch {\n\t\t\t// The target may already be closed.\n\t\t}\n\t}\n\n\t#release(): Promise<void> {\n\t\tconst active = this.#releasing\n\t\tif (active !== undefined) return active\n\t\tconst release = this.#releaseResources()\n\t\tthis.#releasing = release\n\t\treturn release\n\t}\n\n\tasync #releaseResources(): Promise<void> {\n\t\tthis.#unhold()\n\t\tthis.#announcement.reject(new BrowserError('Browser session ended'))\n\t\tthis.#client.unsubscribe('Page.lifecycleEvent', this.#lifecycleHandler, this.#sessionId)\n\t\tfor (const id of this.#readiness.keys())\n\t\t\tthis.#settleReadiness(id)?.reject(new BrowserError('Browser session ended'))\n\t\tthis.#cancelLoad()\n\t\tawait this.#registry?.destroy().catch(() => undefined)\n\t\tawait this.#codegenStart.pending?.catch(() => undefined)\n\t\tawait this.#scripts.destroy().catch(() => undefined)\n\t\tawait this.#diagnostics.destroy().catch(() => undefined)\n\t\tawait this.#clock.uninstall().catch(() => undefined)\n\t\tawait this.#network.destroy().catch(() => undefined)\n\n\t\tif (this.#codegen !== undefined) {\n\t\t\ttry {\n\t\t\t\tawait this.#codegen.destroy()\n\t\t\t} catch {\n\t\t\t\t// The recorder's session may already be unavailable.\n\t\t\t}\n\t\t\tthis.#codegen = undefined\n\t\t}\n\n\t\tthis.#advancePage()\n\t\tfor (const session of this.#frameIds.keys()) this.#unwatchSession(session)\n\t\tthis.#frameSessions.clear()\n\t\tthis.#frameIds.clear()\n\t\tthis.#attaching.clear()\n\t\tthis.#iframes.clear()\n\t\tfor (const worker of this.#workers.values()) worker.detach()\n\t\tthis.#workers.clear()\n\t\tthis.#popups.clear()\n\t\tthis.#claimed.clear()\n\t\tthis.#downloads.clear()\n\t\tthis.#client.unsubscribe('Target.targetDestroyed', this.#destroyHandler)\n\t\tthis.#unwatchSession(this.#sessionId)\n\t\tthis.#client.unsubscribe('Page.javascriptDialogOpening', this.#dialogHandler, this.#sessionId)\n\t\tthis.#client.unsubscribe('Page.windowOpen', this.#openHandler, this.#sessionId)\n\t\tthis.#records.clear()\n\t\tthis.#wakePopups()\n\t\tthis.#client.unsubscribe('Page.fileChooserOpened', this.#chooserHandler, this.#sessionId)\n\t\tthis.#client.unsubscribe('Runtime.consoleAPICalled', this.#consoleHandler, this.#sessionId)\n\t\tthis.#client.unsubscribe('Runtime.exceptionThrown', this.#errorHandler, this.#sessionId)\n\t\tthis.#client.unsubscribe('Inspector.targetCrashed', this.#crashHandler, this.#sessionId)\n\t\tthis.#client.unsubscribe('Browser.downloadWillBegin', this.#downloadHandler)\n\t\tthis.#client.unsubscribe('Browser.downloadProgress', this.#downloadProgressHandler)\n\t\tthis.#parents.clear()\n\t\tthis.#loaders.clear()\n\t\tthis.#pending.clear()\n\t\tif (!this.#emitter.destroyed) {\n\t\t\tthis.#emitter.emit('close')\n\t\t\tthis.#emitter.destroy()\n\t\t}\n\t\tthis.#steps.destroy()\n\t}\n\n\t#frame(frame: BrowserFrameInfo): BrowserFrameInterface {\n\t\treturn new BrowserFrame(\n\t\t\tthis.#client,\n\t\t\t(id) => this.#resolveFrameSession(id),\n\t\t\tframe.id,\n\t\t\tframe.url,\n\t\t\tframe.parent,\n\t\t\tframe.name,\n\t\t\ttrue,\n\t\t\t() => this.#epochOf(frame.id),\n\t\t\t(session, call) => this.#world(frame.id, session, call),\n\t\t)\n\t}\n\n\t#epochOf(frame: string): number {\n\t\treturn this.#epochs.get(frame) ?? this.#floor\n\t}\n\n\t#advanceFrame(frame: string): void {\n\t\tthis.#epoch += 1\n\t\tthis.#epochs.set(frame, this.#epoch)\n\t}\n\n\t// A page-frame document change replaces every frame document, so it advances them together.\n\t#advancePage(): void {\n\t\tthis.#dom = undefined\n\t\tthis.#seed = undefined\n\t\tthis.#epoch += 1\n\t\tthis.#floor = this.#epoch\n\t\tthis.#epochs.clear()\n\t\tthis.#worlds.clear()\n\t\tthis.#creating.clear()\n\t}\n\n\t#nextReference(): string {\n\t\treturn `${BROWSER_REFERENCE_PREFIX}${++this.#referenceSequence}`\n\t}\n\n\tasync #ready(options?: BrowserCallOptions): Promise<void> {\n\t\tthis.assert()\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst end = performance.now() + timeout\n\t\tif (this.#loader === undefined && this.#seed === undefined) {\n\t\t\tconst seed = this.#seedReadiness({ timeout: BROWSER_DEFAULT_TIMEOUT_MS })\n\t\t\tthis.#seed = seed\n\t\t\tvoid seed.catch(this.#rejectSeed.bind(this, seed))\n\t\t}\n\t\tif (this.#seed !== undefined) await this.#parkReadiness(options, this.#seed)\n\t\tif (this.#dom !== undefined && this.#dom === (this.#loader ?? 'initial')) return\n\t\tawait this.#parkReadiness({ ...options, timeout: Math.max(0, end - performance.now()) })\n\t}\n\n\t#rejectSeed(seed: Promise<void>): void {\n\t\tif (this.#seed === seed) this.#seed = undefined\n\t}\n\n\t// The seed answers for the document it was issued against: `#floor` changes only when the\n\t// page frame's document changes, so a same-document navigation during the seed keeps its\n\t// answer.\n\tasync #seedReadiness(options?: BrowserCallOptions): Promise<void> {\n\t\tconst document = this.#floor\n\t\tconst context = await this.#world(this.id, this.#sessionId, options)\n\t\tconst result = await this.send(\n\t\t\t'Runtime.evaluate',\n\t\t\t{ expression: 'document.readyState', contextId: context, returnByValue: true },\n\t\t\toptions,\n\t\t)\n\t\tconst state = readEvaluationResult(result)\n\t\tif (document === this.#floor && (state === 'interactive' || state === 'complete'))\n\t\t\tthis.#dom = this.#loader ?? 'initial'\n\t}\n\n\t#parkReadiness(options?: BrowserCallOptions, seed?: Promise<void>): Promise<void> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst deferred = Promise.withResolvers<void>()\n\t\tconst id = Symbol('readiness')\n\t\tconst timer = setTimeout(\n\t\t\t() =>\n\t\t\t\tthis.#settleReadiness(id)?.reject(\n\t\t\t\t\tnew BrowserError('Browser DOM readiness timed out', 'BROWSER_WAIT_TIMEOUT'),\n\t\t\t\t),\n\t\t\ttimeout,\n\t\t)\n\t\tconst signal = options?.signal\n\t\tconst listener = signal === undefined ? undefined : this.#abortReadiness.bind(this, id, signal)\n\t\tthis.#readiness.set(id, {\n\t\t\tresolve: deferred.resolve,\n\t\t\treject: deferred.reject,\n\t\t\ttimer,\n\t\t\tsignal,\n\t\t\tlistener,\n\t\t})\n\t\tif (listener !== undefined) signal?.addEventListener('abort', listener, { once: true })\n\t\tif (seed !== undefined)\n\t\t\tvoid seed.then(\n\t\t\t\t() => this.#settleReadiness(id)?.resolve(),\n\t\t\t\t(error: unknown) => this.#settleReadiness(id)?.reject(error),\n\t\t\t)\n\t\treturn deferred.promise\n\t}\n\n\t#abortReadiness(id: symbol, signal: AbortSignal): void {\n\t\tthis.#settleReadiness(id)?.reject(signal.reason)\n\t}\n\n\t#settleReadiness(id: symbol): BrowserReadinessWait | undefined {\n\t\tconst wait = this.#readiness.get(id)\n\t\tif (wait === undefined) return undefined\n\t\tclearTimeout(wait.timer)\n\t\tif (wait.listener !== undefined) wait.signal?.removeEventListener('abort', wait.listener)\n\t\tthis.#readiness.delete(id)\n\t\treturn wait\n\t}\n\n\t#handleLifecycle(params: Readonly<Record<string, unknown>>): void {\n\t\tif (\n\t\t\tparams['frameId'] !== this.id ||\n\t\t\tparams['name'] !== 'DOMContentLoaded' ||\n\t\t\t!isString(params['loaderId'])\n\t\t)\n\t\t\treturn\n\t\tif (this.#loader !== undefined && params['loaderId'] !== this.#loader) return\n\t\tthis.#dom = this.#loader ?? 'initial'\n\t\tfor (const id of this.#readiness.keys()) this.#settleReadiness(id)?.resolve()\n\t}\n\n\t#world(frame: string, session: string, options?: BrowserCallOptions): Promise<number> {\n\t\tconst cached = this.#worlds.get(frame)\n\t\tif (cached !== undefined) return Promise.resolve(cached.context)\n\t\tconst existing = this.#creating.get(frame)\n\t\tif (existing !== undefined) return existing.promise\n\t\tconst pending: Promise<number> = this.#client\n\t\t\t.send(\n\t\t\t\t'Page.createIsolatedWorld',\n\t\t\t\t{ frameId: frame, worldName: BROWSER_FRAME_WORLD_NAME },\n\t\t\t\t{ session, ...options },\n\t\t\t)\n\t\t\t.then(this.#decodeWorld.bind(this, frame))\n\t\tthis.#creating.set(frame, { session, promise: pending })\n\t\tvoid pending.then(\n\t\t\tthis.#publishWorld.bind(this, frame, session, pending),\n\t\t\tthis.#settleWorld.bind(this, frame, pending),\n\t\t)\n\t\treturn pending\n\t}\n\n\t#decodeWorld(frame: string, world: unknown): number {\n\t\treturn readBrowserWorld(world, frame)\n\t}\n\n\t// Publication requires the creation to be the frame's current one, so an invalidation that\n\t// landed while the request was in flight discards its context.\n\t#publishWorld(frame: string, session: string, pending: Promise<number>, context: number): void {\n\t\tif (this.#creating.get(frame)?.promise === pending && !this.#closed) {\n\t\t\tthis.#worlds.set(frame, { session, context })\n\t\t}\n\t\tthis.#settleWorld(frame, pending)\n\t}\n\n\t#settleWorld(frame: string, pending: Promise<number>): void {\n\t\tif (this.#creating.get(frame)?.promise === pending) this.#creating.delete(frame)\n\t}\n\n\t#resolveSessionHandlers(session: string): {\n\t\treadonly destroyed: CDPHandler\n\t\treadonly cleared: CDPHandler\n\t\treadonly navigated: CDPHandler\n\t\treadonly routed: CDPHandler\n\t\treadonly detached: CDPHandler\n\t\treadonly attached: CDPHandler\n\t\treadonly requested: CDPHandler\n\t\treadonly started: CDPHandler\n\t\treadonly lifecycle: CDPHandler\n\t\treadonly stopped: CDPHandler\n\t\treadonly target: CDPHandler\n\t\treadonly released: CDPHandler\n\t} {\n\t\tconst existing = this.#sessionHandlers.get(session)\n\t\tif (existing !== undefined) return existing\n\t\tconst created = {\n\t\t\tdestroyed: this.#handleContextDestroyed.bind(this, session),\n\t\t\tcleared: this.#handleContextsCleared.bind(this, session),\n\t\t\tnavigated: this.#handleSessionNavigated.bind(this, session),\n\t\t\trouted: this.#handleSessionRouted.bind(this, session),\n\t\t\tdetached: this.#handleFrameDetached.bind(this, session),\n\t\t\tattached: this.#handleFrameAttached.bind(this, session),\n\t\t\trequested: this.#handleRequested.bind(this, session),\n\t\t\tstarted: this.#handleStarted.bind(this, session),\n\t\t\tlifecycle: this.#handleSessionLifecycle.bind(this, session),\n\t\t\tstopped: this.#handleStopped.bind(this, session),\n\t\t\ttarget: this.#handleAttached.bind(this, session),\n\t\t\treleased: this.#handleDetached.bind(this),\n\t\t}\n\t\tthis.#sessionHandlers.set(session, created)\n\t\treturn created\n\t}\n\n\t// Every session the page follows, its own included, reports its frames' steps through the same\n\t// persistent handlers from the moment it is watched until it is unwatched; no action subscribes.\n\t#watchSession(session: string): void {\n\t\tconst handlers = this.#resolveSessionHandlers(session)\n\t\tfor (const [method, handler] of this.#pairSessionHandlers(handlers))\n\t\t\tthis.#client.subscribe(method, handler, session)\n\t}\n\n\t#unwatchSession(session: string): void {\n\t\tconst handlers = this.#resolveSessionHandlers(session)\n\t\tfor (const [method, handler] of this.#pairSessionHandlers(handlers))\n\t\t\tthis.#client.unsubscribe(method, handler, session)\n\t\tthis.#sessionHandlers.delete(session)\n\t}\n\n\t#pairSessionHandlers(handlers: {\n\t\treadonly destroyed: CDPHandler\n\t\treadonly cleared: CDPHandler\n\t\treadonly navigated: CDPHandler\n\t\treadonly routed: CDPHandler\n\t\treadonly detached: CDPHandler\n\t\treadonly attached: CDPHandler\n\t\treadonly requested: CDPHandler\n\t\treadonly started: CDPHandler\n\t\treadonly lifecycle: CDPHandler\n\t\treadonly stopped: CDPHandler\n\t\treadonly target: CDPHandler\n\t\treadonly released: CDPHandler\n\t}): ReadonlyArray<readonly [method: string, handler: CDPHandler]> {\n\t\treturn [\n\t\t\t['Target.attachedToTarget', handlers.target],\n\t\t\t['Target.detachedFromTarget', handlers.released],\n\t\t\t['Page.frameAttached', handlers.attached],\n\t\t\t['Page.frameDetached', handlers.detached],\n\t\t\t['Page.frameRequestedNavigation', handlers.requested],\n\t\t\t['Page.frameStartedNavigating', handlers.started],\n\t\t\t['Page.frameNavigated', handlers.navigated],\n\t\t\t['Page.navigatedWithinDocument', handlers.routed],\n\t\t\t['Page.lifecycleEvent', handlers.lifecycle],\n\t\t\t['Page.frameStoppedLoading', handlers.stopped],\n\t\t\t['Runtime.executionContextDestroyed', handlers.destroyed],\n\t\t\t['Runtime.executionContextsCleared', handlers.cleared],\n\t\t]\n\t}\n\n\tasync #resolveFrameSession(frame: string): Promise<string> {\n\t\tconst owner = this.#frameSessions.get(frame)\n\t\treturn owner === undefined ? this.#sessionId : await owner.attempt\n\t}\n\n\t// A frame session reports its frame's load only with lifecycle events enabled, and a nested\n\t// out-of-process frame attaches only through its parent frame's own auto-attach; a refusal fails\n\t// the enablement. The target waits for the debugger until both are in effect, so the commit and\n\t// the load of the document it holds arrive on this session after the resume.\n\tasync #enableFrameSession(session: string): Promise<string> {\n\t\tawait this.#client.send('Page.enable', undefined, { session })\n\t\tawait this.#codegen?.attach(session)\n\t\tawait this.#client.send('Runtime.enable', undefined, { session })\n\t\tawait this.#client.send('Page.setLifecycleEventsEnabled', { enabled: true }, { session })\n\t\tawait this.#client.send(\n\t\t\t'Target.setAutoAttach',\n\t\t\t{\n\t\t\t\tautoAttach: true,\n\t\t\t\twaitForDebuggerOnStart: true,\n\t\t\t\tflatten: true,\n\t\t\t\tfilter: [{ type: 'iframe' }],\n\t\t\t},\n\t\t\t{ session },\n\t\t)\n\t\tthis.#resumeTarget(session)\n\t\treturn session\n\t}\n\n\t// Every target the page's auto-attach reaches waits for the debugger until the page resumes it;\n\t// a target gone before its resume ends with its detach.\n\t#resumeTarget(session: string): void {\n\t\tvoid this.#client\n\t\t\t.send('Runtime.runIfWaitingForDebugger', undefined, { session })\n\t\t\t.catch(() => undefined)\n\t}\n\n\t// A detach alone leaves a paused target waiting, so a target the page releases runs uninstrumented\n\t// rather than frozen. The wait ends when the resume attempt settles: a reply shows the renderer\n\t// processed the resume before the browser processes the detach that follows, and a refusal, the\n\t// client's timeout, or the connection's close lets the detach go ahead as best-effort cleanup.\n\tasync #releaseTarget(session: string): Promise<void> {\n\t\tawait this.#client\n\t\t\t.send('Runtime.runIfWaitingForDebugger', undefined, { session })\n\t\t\t.catch(() => undefined)\n\t}\n\n\t// A target that names no parent frame is placed by its own frame tree, whose root supplies the\n\t// parent, the URL, and the name; a navigation the session reported since the attach replaced\n\t// `attached` with a URL newer than the tree's snapshot, which the record keeps.\n\tasync #readFrameTree(session: string, attached: BrowserFrameInfo, named: boolean): Promise<void> {\n\t\tif (named) return\n\t\tconst result = await this.#client\n\t\t\t.send('Page.getFrameTree', undefined, { session })\n\t\t\t.catch(() => undefined)\n\t\tconst [root] = readBrowserFrames(result)\n\t\tif (root === undefined || root.id !== attached.id || this.#attaching.get(session) !== attached)\n\t\t\treturn\n\t\tconst parent = root.parent ?? attached.parent\n\t\tif (parent !== undefined) this.#parents.set(attached.id, parent)\n\t\tthis.#attaching.set(session, {\n\t\t\t...attached,\n\t\t\tparent,\n\t\t\turl: root.url,\n\t\t\tname: root.name ?? attached.name,\n\t\t})\n\t}\n\n\tasync #attachWorker(\n\t\tsession: string,\n\t\tid: string,\n\t\turl: string,\n\t\tcategory: BrowserWorkerCategory,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#client.send('Runtime.enable', undefined, { session })\n\t\t\tif (this.#closed) {\n\t\t\t\tawait this.#detachChild(session, this.#sessionId)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.#resumeTarget(session)\n\t\t\tconst worker = new BrowserWorker(this.#client, session, id, url, category)\n\t\t\tthis.#workers.set(id, worker)\n\t\t\tthis.#emitter.emit('worker', worker)\n\t\t} catch {\n\t\t\t// A worker can terminate before its session is enabled.\n\t\t\tawait this.#detachChild(session, this.#sessionId)\n\t\t}\n\t}\n\n\t// Discovery attaches a popup on the browser session, which keeps the popup's session alive after\n\t// its opener closes; a session attached through this page's session would end with it.\n\tasync #discoverPopup(id: string, url: string | undefined): Promise<void> {\n\t\tconst held = this.#holder(id)\n\t\tif (held !== undefined) {\n\t\t\tconst ready = await held.#setup.then(\n\t\t\t\t() => true,\n\t\t\t\t() => false,\n\t\t\t)\n\t\t\tthis.#claimed.delete(id)\n\t\t\tif (ready && this.#holder(id) === held) this.#publish(held)\n\t\t\telse this.#concludePopup(id)\n\t\t\treturn\n\t\t}\n\t\tconst result: unknown = await this.#client\n\t\t\t.send('Target.attachToTarget', { targetId: id, flatten: true })\n\t\t\t.catch(() => undefined)\n\t\t// A popup can close before the attach reaches it.\n\t\tif (!isRecord(result) || !isString(result['sessionId'])) {\n\t\t\tthis.#claimed.delete(id)\n\t\t\tthis.#concludePopup(id)\n\t\t\treturn\n\t\t}\n\t\tawait this.#attachPopup(result['sessionId'], id, url, undefined)\n\t}\n\n\t// `owner` is the session the popup's session was attached through, undefined for the browser\n\t// session; a discovered popup reports no URL before its first commit, so its frame tree does.\n\tasync #attachPopup(\n\t\tsession: string,\n\t\tid: string,\n\t\turl: string | undefined,\n\t\towner: string | undefined,\n\t): Promise<void> {\n\t\tlet popup: BrowserPage | undefined\n\t\tconst setup = Promise.withResolvers<void>()\n\t\ttry {\n\t\t\tawait this.#client.send('Page.enable', undefined, { session })\n\t\t\tawait this.#client.send('Runtime.enable', undefined, { session })\n\t\t\tawait this.#client.send('Page.setLifecycleEventsEnabled', { enabled: true }, { session })\n\t\t\tconst result = await this.#client.send('Page.getFrameTree', undefined, { session })\n\t\t\tconst frame = readBrowserFrames(result)[0]\n\t\t\tif (frame === undefined || this.#closed) {\n\t\t\t\tthis.#concludePopup(id)\n\t\t\t\tawait this.#detachChild(session, owner)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst held = this.#holder(id)\n\t\t\tif (held !== undefined) {\n\t\t\t\tawait this.#detachChild(session, owner)\n\t\t\t\tconst ready = await held.#setup.then(\n\t\t\t\t\t() => true,\n\t\t\t\t\t() => false,\n\t\t\t\t)\n\t\t\t\tif (ready && !this.#closed && this.#holder(id) === held) this.#publish(held)\n\t\t\t\telse this.#concludePopup(id)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tpopup = new BrowserPage(\n\t\t\t\tthis.#client,\n\t\t\t\tid,\n\t\t\t\tsession,\n\t\t\t\tthis.#writer,\n\t\t\t\turl ?? frame.url,\n\t\t\t\tframe.id,\n\t\t\t\tthis.#contextId,\n\t\t\t\tthis,\n\t\t\t\tundefined,\n\t\t\t\tthis.#reference,\n\t\t\t\tsetup.promise,\n\t\t\t)\n\t\t\tpopup.#owner = owner\n\t\t\tawait popup.send('Target.setAutoAttach', {\n\t\t\t\tautoAttach: true,\n\t\t\t\twaitForDebuggerOnStart: true,\n\t\t\t\tflatten: true,\n\t\t\t})\n\t\t\tawait popup.send('Page.setInterceptFileChooserDialog', { enabled: true })\n\t\t\tawait popup.network.start()\n\t\t\tif (this.#closed) throw new BrowserError('Browser page is closed')\n\t\t\tthis.#resumeTarget(session)\n\t\t\tsetup.resolve()\n\t\t\tthis.#publish(popup)\n\t\t} catch (error) {\n\t\t\t// A popup can close before its session initialization completes.\n\t\t\tthis.#concludePopup(id)\n\t\t\tif (popup !== undefined) {\n\t\t\t\tsetup.reject(error)\n\t\t\t\tawait this.#releaseTarget(session)\n\t\t\t\tawait popup.destroy()\n\t\t\t} else await this.#detachChild(session, owner)\n\t\t} finally {\n\t\t\tthis.#claimed.delete(id)\n\t\t}\n\t}\n\n\t// Publishes a page this page opened once this page is published itself, so the observer of this\n\t// page sees it before any page it opened.\n\t#publish(popup: BrowserPage): void {\n\t\tvoid this.#announcement.promise.then(\n\t\t\t() => this.#emitPopup(popup),\n\t\t\t() => this.#emitPopup(popup),\n\t\t)\n\t}\n\n\t// Emits one popup once; a closed popup is never emitted, and a popup this page constructed is\n\t// released when this page closed first.\n\t#emitPopup(popup: BrowserPage): void {\n\t\tconst id = popup.#targetId\n\t\tif (this.#popups.get(id) === popup) return\n\t\tif (popup.#closed) {\n\t\t\tthis.#concludePopup(id)\n\t\t\treturn\n\t\t}\n\t\tif (this.#closed) {\n\t\t\tif (popup.#opener === this) void popup.destroy().catch(() => undefined)\n\t\t\treturn\n\t\t}\n\t\tpopup.#opener ??= this\n\t\tthis.#popups.set(id, popup)\n\t\tpopup.emitter.on('close', () => {\n\t\t\tif (this.#popups.get(id) === popup) this.#popups.delete(id)\n\t\t})\n\t\tthis.#emitter.emit('popup', popup)\n\t\tpopup.#announcement.resolve()\n\t\tthis.#concludePopup(id, popup)\n\t}\n\n\t#recordPopups(): BrowserPopupRecordInterface {\n\t\tthis.assert()\n\t\tconst key = Symbol('popups')\n\t\tthis.#records.set(key, { opened: 0, targets: new Set(), outcomes: new Map() })\n\t\treturn {\n\t\t\tsettle: this.#settlePopups.bind(this, key),\n\t\t\tdestroy: this.#endPopups.bind(this, key),\n\t\t}\n\t}\n\n\t// Parks until as many popup targets adopted since the record opened concluded as\n\t// `Page.windowOpen` reports arrived, or until `timeout`, which ends the wait with the popups\n\t// announced so far.\n\tasync #settlePopups(\n\t\tkey: symbol,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<readonly BrowserPageInterface[]> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\t// The platform deadline takes whole milliseconds.\n\t\tconst deadline = AbortSignal.timeout(Math.ceil(timeout))\n\t\twhile (true) {\n\t\t\toptions?.signal?.throwIfAborted()\n\t\t\tconst record = this.#records.get(key)\n\t\t\tif (record === undefined)\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\tthis.#closed\n\t\t\t\t\t\t? 'Browser popup record ended because the page closed'\n\t\t\t\t\t\t: 'Browser popup record ended',\n\t\t\t\t)\n\t\t\tif (record.opened === 0) return []\n\t\t\tif (record.outcomes.size >= record.opened || deadline.aborted)\n\t\t\t\treturn [...record.outcomes.values()].filter(\n\t\t\t\t\t(popup): popup is BrowserPage => popup !== undefined && popup.#opener === this,\n\t\t\t\t)\n\t\t\tawait this.#parkPopups(deadline, options?.signal)\n\t\t}\n\t}\n\n\t// Resolves on the next change to a popup record or when `deadline` aborts; rejects with the\n\t// signal's reason on abort.\n\tasync #parkPopups(deadline: AbortSignal, signal: AbortSignal | undefined): Promise<void> {\n\t\tconst wake = Promise.withResolvers<void>()\n\t\tconst abort = this.#abandonPopups.bind(this, wake, signal)\n\t\tthis.#wakes.add(wake.resolve)\n\t\tdeadline.addEventListener('abort', abort, { once: true })\n\t\tsignal?.addEventListener('abort', abort, { once: true })\n\t\ttry {\n\t\t\tawait wake.promise\n\t\t} finally {\n\t\t\tthis.#wakes.delete(wake.resolve)\n\t\t\tdeadline.removeEventListener('abort', abort)\n\t\t\tsignal?.removeEventListener('abort', abort)\n\t\t}\n\t}\n\n\t// The caller's abort rejects a parked settle with its reason; the deadline's wakes it.\n\t#abandonPopups(wake: PromiseWithResolvers<void>, signal: AbortSignal | undefined): void {\n\t\tif (signal?.aborted === true) wake.reject(signal.reason)\n\t\telse wake.resolve()\n\t}\n\n\t#endPopups(key: symbol): void {\n\t\tif (this.#records.delete(key)) this.#wakePopups()\n\t}\n\n\t#wakePopups(): void {\n\t\tfor (const wake of [...this.#wakes]) wake()\n\t}\n\n\t// Chromium 141 reports a window this page's document opens on this page's session before it\n\t// answers the input that opened it; a report names no target, so each one counts. Chromium 141\n\t// announces such a window only to discovery, so a page that takes no part in it counts none.\n\t#handleOpen(): void {\n\t\tif (this.#holder(this.#targetId) !== this) return\n\t\tfor (const [key, record] of this.#records)\n\t\t\tthis.#records.set(key, { ...record, opened: record.opened + 1 })\n\t\tthis.#wakePopups()\n\t}\n\n\t// Names a popup target this page begins to adopt in every open popup record.\n\t#expectPopup(id: string): void {\n\t\tfor (const [key, record] of this.#records)\n\t\t\tthis.#records.set(key, { ...record, targets: new Set([...record.targets, id]) })\n\t}\n\n\t// Concludes a popup target in every open record that expects it: announced with its page, or\n\t// skipped without one when it closed or failed its setup first.\n\t#concludePopup(id: string, popup?: BrowserPage): void {\n\t\tfor (const [key, record] of this.#records)\n\t\t\tif (record.targets.has(id) && !record.outcomes.has(id))\n\t\t\t\tthis.#records.set(key, { ...record, outcomes: new Map([...record.outcomes, [id, popup]]) })\n\t\tthis.#wakePopups()\n\t}\n\n\t// Reads the live page that holds a target on this page's connection.\n\t#holder(id: string): BrowserPage | undefined {\n\t\tconst held = BrowserPage.#held.get(this.#client)?.get(id)\n\t\treturn held === undefined || held.#closed ? undefined : held\n\t}\n\n\t#unhold(): void {\n\t\tconst held = BrowserPage.#held.get(this.#client)\n\t\tif (held?.get(this.#targetId) === this) held.delete(this.#targetId)\n\t}\n\n\t// Takes the discovery reports that waited for this page's target.\n\t#drain(): void {\n\t\tconst reports = BrowserPage.#reports.get(this.#client)\n\t\tif (reports === undefined) return\n\t\tfor (const [id, target] of reports) {\n\t\t\tif (target['openerId'] !== this.#targetId) continue\n\t\t\treports.delete(id)\n\t\t\tthis.#discover(target)\n\t\t}\n\t}\n\n\t// A session attached through a page session detaches only through that session, after the page\n\t// releases its target.\n\tasync #detachChild(session: string, owner: string | undefined): Promise<void> {\n\t\tawait this.#releaseTarget(session)\n\t\tawait this.#client\n\t\t\t.send(\n\t\t\t\t'Target.detachFromTarget',\n\t\t\t\t{ sessionId: session },\n\t\t\t\towner === undefined ? undefined : { session: owner },\n\t\t\t)\n\t\t\t.catch(() => undefined)\n\t}\n\n\tasync #stopLoading(timeout: number): Promise<void> {\n\t\ttry {\n\t\t\tawait this.send('Page.stopLoading', undefined, { timeout })\n\t\t} catch {\n\t\t\t// Best-effort only — the original navigation error wins.\n\t\t}\n\t}\n\n\t#handleNavigationResponse(response: BrowserResponse): void {\n\t\tif (response.frame === this.id) this.#responses?.push(response)\n\t}\n\n\t#handleDestroy(params: Readonly<Record<string, unknown>>): void {\n\t\tif (!isString(params['targetId']) || params['targetId'] !== this.#targetId) return\n\t\tthis.#closed = true\n\t\tvoid this.#release().catch(() => undefined)\n\t}\n\n\t#handleLoad(params: Readonly<Record<string, unknown>>): void {\n\t\tif (isString(params['name'])) {\n\t\t\tif (params['name'] === 'networkIdle' && this.#loader !== undefined) {\n\t\t\t\tif (params['loaderId'] === this.#loader) this.#resolveLoad()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tif (this.#loadEvents.includes('Page.navigatedWithinDocument')) {\n\t\t\tconst frame = params['frameId']\n\t\t\tif (isString(frame) && frame === this.id) {\n\t\t\t\tthis.#sameDocument = true\n\t\t\t\tthis.#resolveLoad()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif (this.#loadEvents.includes('Page.frameNavigated')) {\n\t\t\tconst frame = params['frame']\n\t\t\tif (isRecord(frame) && frame['id'] === this.id) this.#resolveLoad()\n\t\t\treturn\n\t\t}\n\t\tif (\n\t\t\tthis.#loadEvents.includes('Page.loadEventFired') ||\n\t\t\tthis.#loadEvents.includes('Page.domContentEventFired')\n\t\t) {\n\t\t\tthis.#resolveLoad()\n\t\t}\n\t}\n\n\t#handleRestore(params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frame']\n\t\tif (params['type'] === 'BackForwardCacheRestore' && isRecord(frame) && frame['id'] === this.id)\n\t\t\tthis.#resolveLoad()\n\t}\n\n\t// Every session that owns a frame names the parent of a frame it attaches; only the page\n\t// session's frames are announced, as before a frame session reported any.\n\t#handleFrameAttached(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tconst parent = params['parentFrameId']\n\t\tif (!isString(frame) || !this.#accepts(session, frame)) return\n\t\tif (isString(parent)) this.#parents.set(frame, parent)\n\t\tif (session !== this.#sessionId) return\n\t\tthis.#emitter.emit(\n\t\t\t'attach',\n\t\t\tnew BrowserFrame(\n\t\t\t\tthis.#client,\n\t\t\t\t(id) => this.#resolveFrameSession(id),\n\t\t\t\tframe,\n\t\t\t\t'about:blank',\n\t\t\t\tisString(parent) ? parent : undefined,\n\t\t\t\tundefined,\n\t\t\t\ttrue,\n\t\t\t\t() => this.#epochOf(frame),\n\t\t\t\t(owner, call) => this.#world(frame, owner, call),\n\t\t\t),\n\t\t)\n\t}\n\n\t#handleFrameNavigated(params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frame']\n\t\tif (!isRecord(frame) || !isString(frame['id']) || !isString(frame['url'])) return\n\t\tif (frame['id'] !== this.id) {\n\t\t\tthis.#advanceFrame(frame['id'])\n\t\t\tthis.#worlds.delete(frame['id'])\n\t\t\tthis.#creating.delete(frame['id'])\n\t\t\treturn\n\t\t}\n\t\tthis.#advancePage()\n\t\tif (isString(frame['loaderId'])) this.#loader = frame['loaderId']\n\t\tif (params['type'] === 'BackForwardCacheRestore') {\n\t\t\tthis.#dom = this.#loader ?? 'initial'\n\t\t\tfor (const id of this.#readiness.keys()) this.#settleReadiness(id)?.resolve()\n\t\t}\n\t\tthis.update(frame['url'])\n\t\tthis.#emitter.emit('navigate', frame['url'], false)\n\t}\n\n\t// A frame session reports its own frame's committed URL, which `Target.attachedToTarget` does\n\t// not carry before the framed document commits.\n\t// The ownership check precedes every change, so a report the page rejects leaves the frame's\n\t// epoch, world, and parent as they were.\n\t#handleSessionNavigated(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frame']\n\t\tif (!isRecord(frame) || !isString(frame['id']) || !isString(frame['url'])) return\n\t\tif (!this.#accepts(session, frame['id'])) return\n\t\tthis.#handleFrameNavigated(params)\n\t\tthis.#updateFrame(session, frame['id'], {\n\t\t\turl: frame['url'],\n\t\t\tname: isString(frame['name']) && frame['name'] !== '' ? frame['name'] : undefined,\n\t\t})\n\t\tif (isString(frame['parentId'])) this.#parents.set(frame['id'], frame['parentId'])\n\t\tconst loader = isString(frame['loaderId']) ? frame['loaderId'] : undefined\n\t\tthis.#loaders.set(frame['id'], loader)\n\t\tthis.#steps.emit('commit', frame['id'], frame['url'], loader, false)\n\t}\n\n\t#handleSessionRouted(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tconst url = params['url']\n\t\tif (!isString(frame) || !this.#accepts(session, frame)) return\n\t\tthis.#pending.delete(frame)\n\t\tthis.#handleSameDocument(params)\n\t\tif (!isString(url)) return\n\t\tthis.#updateFrame(session, frame, { url })\n\t\tthis.#steps.emit('commit', frame, url, undefined, true)\n\t}\n\n\t// The one ownership rule every navigation step passes: the page session reports every frame in\n\t// the page's process and every swap, and a frame session reports the frame it owns and any frame\n\t// no session owns, until another session supersedes it.\n\t#accepts(session: string, frame: string): boolean {\n\t\tif (session === this.#sessionId) return true\n\t\tif (!this.#frameIds.has(session)) return false\n\t\tconst owner = this.#frameSessions.get(frame)?.session\n\t\treturn owner === undefined || owner === session\n\t}\n\n\t// A start the protocol announces with its loader is the step; the request that precedes it in the\n\t// current tab is the step on a host that announces no start, and carries the navigation's reason\n\t// when it is a `BROWSER_NAVIGATION_REASONS` value.\n\t#handleRequested(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tconst url = params['url']\n\t\tif (params['disposition'] !== 'currentTab' || !isString(frame) || !isString(url)) return\n\t\tconst reason = BROWSER_NAVIGATION_REASONS.find((candidate) => candidate === params['reason'])\n\t\tif (session === this.#sessionId || this.#frameIds.has(session))\n\t\t\tthis.#pending.set(frame, { url, reason })\n\t\tif (!this.#accepts(session, frame)) return\n\t\tthis.#steps.emit('request', frame, url, undefined, reason)\n\t}\n\n\t#handleStarted(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tconst url = params['url']\n\t\tconst loader = params['loaderId']\n\t\tif (!isString(frame) || !isString(url) || !isString(loader) || !this.#accepts(session, frame))\n\t\t\treturn\n\t\t// A reload or a history traversal repeats an entry rather than following a request.\n\t\tconst repeated = BROWSER_RELOAD_NAVIGATION_TYPES.some(\n\t\t\t(type) => type === params['navigationType'],\n\t\t)\n\t\t// Every start ends the frame's pending request, and only the start it requested takes its reason.\n\t\tconst requested = this.#pending.get(frame)\n\t\tthis.#pending.delete(frame)\n\t\tthis.#steps.emit(\n\t\t\t'request',\n\t\t\tframe,\n\t\t\turl,\n\t\t\tloader,\n\t\t\t!repeated && requested?.url === url ? requested.reason : undefined,\n\t\t)\n\t}\n\n\t// Enabling lifecycle events replays earlier lifecycle names under a loader of no navigation, so a\n\t// load step carries its loader for the consumer to match.\n\t#handleSessionLifecycle(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tconst loader = params['loaderId']\n\t\tif (params['name'] !== 'load' || !isString(frame) || !this.#accepts(session, frame)) return\n\t\tthis.#steps.emit('load', frame, isString(loader) ? loader : undefined)\n\t}\n\n\t// A stop carries no loader, so it is a load only for a commit that named none.\n\t#handleStopped(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tif (\n\t\t\t!isString(frame) ||\n\t\t\t!this.#loaders.has(frame) ||\n\t\t\tthis.#loaders.get(frame) !== undefined ||\n\t\t\t!this.#accepts(session, frame)\n\t\t)\n\t\t\treturn\n\t\tthis.#steps.emit('load', frame, undefined)\n\t}\n\n\t// Only the frame's owning session describes its document, so an event from a superseded session\n\t// or about a nested frame leaves the record alone. A commit reports the frame's name, which a\n\t// same-document navigation leaves as it was.\n\t#updateFrame(\n\t\tsession: string,\n\t\tframe: string,\n\t\tupdate: Pick<BrowserFrameInfo, 'url'> & Partial<Pick<BrowserFrameInfo, 'name'>>,\n\t): void {\n\t\tif (this.#frameSessions.get(frame)?.session !== session) return\n\t\tconst attaching = this.#attaching.get(session)\n\t\tif (attaching !== undefined) this.#attaching.set(session, { ...attaching, ...update })\n\t\tconst listed = this.#iframes.get(frame)\n\t\tif (listed !== undefined) this.#iframes.set(frame, { ...listed, ...update })\n\t}\n\n\t#handleSameDocument(params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tif (!isString(frame)) return\n\t\tthis.#advanceFrame(frame)\n\t\tif (frame !== this.id || !isString(params['url'])) return\n\t\tthis.update(params['url'])\n\t\tthis.#emitter.emit('navigate', params['url'], true)\n\t}\n\n\t#handleFrameDetached(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\t// The page session is entitled to report any frame's swap or removal, which `#accepts` grants\n\t\t// it; a frame session reports only a frame it owns.\n\t\tif (!isString(frame) || !this.#accepts(session, frame)) return\n\t\tconst swapped = params['reason'] === 'swap'\n\t\tthis.#advanceFrame(frame)\n\t\tthis.#worlds.delete(frame)\n\t\tthis.#creating.delete(frame)\n\t\t// CDP reports a process replacement as `swap`: the frame persists in another renderer, whose\n\t\t// session `Target.attachedToTarget` can have registered before this detach arrives.\n\t\tif (!swapped) {\n\t\t\tthis.#frameSessions.delete(frame)\n\t\t\tthis.#pending.delete(frame)\n\t\t\tthis.#parents.delete(frame)\n\t\t\tthis.#loaders.delete(frame)\n\t\t\tthis.#emitter.emit('detach', frame)\n\t\t}\n\t\tthis.#steps.emit('detach', frame, swapped)\n\t}\n\n\t#handleDialog(params: Readonly<Record<string, unknown>>): void {\n\t\tconst category = params['type']\n\t\tif (\n\t\t\t(category !== 'alert' &&\n\t\t\t\tcategory !== 'confirm' &&\n\t\t\t\tcategory !== 'prompt' &&\n\t\t\t\tcategory !== 'beforeunload') ||\n\t\t\t!isString(params['message'])\n\t\t) {\n\t\t\treturn\n\t\t}\n\t\tthis.#emitter.emit(\n\t\t\t'dialog',\n\t\t\tnew BrowserDialog(\n\t\t\t\tthis,\n\t\t\t\tcategory,\n\t\t\t\tparams['message'],\n\t\t\t\tisString(params['defaultPrompt']) ? params['defaultPrompt'] : '',\n\t\t\t),\n\t\t)\n\t}\n\n\t#handleChooser(params: Readonly<Record<string, unknown>>): void {\n\t\tconst backend = params['backendNodeId']\n\t\tconst mode = params['mode']\n\t\tif (!isInteger(backend)) return\n\t\tthis.#emitter.emit('chooser', new BrowserFileChooser(this, backend, mode === 'selectMultiple'))\n\t}\n\n\t#handleConsole(params: Readonly<Record<string, unknown>>): void {\n\t\tconst message = parseBrowserConsoleMessage(params)\n\t\tif (message !== undefined) this.#emitter.emit('console', message)\n\t}\n\n\t#handleError(params: Readonly<Record<string, unknown>>): void {\n\t\tconst error = parseBrowserPageError(params)\n\t\tif (error !== undefined) this.#emitter.emit('error', error)\n\t}\n\n\t#handleCrash(): void {\n\t\tthis.#emitter.emit('crash')\n\t}\n\n\t#handleDownload(params: Readonly<Record<string, unknown>>): void {\n\t\tconst start = parseBrowserDownloadStart(params)\n\t\tif (start === undefined || (start.frame !== this.id && !this.#frameSessions.has(start.frame))) {\n\t\t\treturn\n\t\t}\n\t\tconst download = new BrowserDownload(\n\t\t\tthis.#client,\n\t\t\tstart.id,\n\t\t\tstart.url,\n\t\t\tstart.name,\n\t\t\tthis.#contextId,\n\t\t)\n\t\tthis.#downloads.set(start.id, download)\n\t\tthis.#emitter.emit('download', download)\n\t}\n\n\t#handleDownloadProgress(params: Readonly<Record<string, unknown>>): void {\n\t\tconst decoded = parseBrowserDownloadProgress(params)\n\t\tif (decoded === undefined) return\n\t\tconst [id, progress] = decoded\n\t\tconst download = this.#downloads.get(id)\n\t\tif (download === undefined) return\n\t\tdownload.update(progress)\n\t\tif (progress.status !== 'pending') this.#downloads.delete(id)\n\t}\n\n\t// Registers a client's discovery routing with its first held page; the end of each connection\n\t// and each later connection leave no held page and no waiting report, and discovery enables\n\t// again.\n\tstatic #track(client: CDPClientInterface): Map<string, BrowserPage> {\n\t\tconst known = BrowserPage.#held.get(client)\n\t\tif (known !== undefined) return known\n\t\tconst held = new Map<string, BrowserPage>()\n\t\tconst reports = new Map<string, Readonly<Record<string, unknown>>>()\n\t\tBrowserPage.#held.set(client, held)\n\t\tBrowserPage.#reports.set(client, reports)\n\t\tclient.subscribe('Target.targetCreated', (params) => BrowserPage.#route(client, params))\n\t\tclient.subscribe('Target.targetDestroyed', (params) => {\n\t\t\tif (isString(params['targetId'])) reports.delete(params['targetId'])\n\t\t})\n\t\tfor (const event of ['connect', 'close', 'drop'] as const)\n\t\t\tclient.emitter.on(event, () => {\n\t\t\t\theld.clear()\n\t\t\t\treports.clear()\n\t\t\t\tBrowserPage.#discovered.delete(client)\n\t\t\t})\n\t\treturn held\n\t}\n\n\t// Chromium 141 reports a `window.open` page only to browser-session discovery, whose `openerId`\n\t// names the page that opened it, and enumerates existing targets when discovery turns on; a\n\t// report whose opener no page holds yet waits for that page.\n\tstatic #route(client: CDPClientInterface, params: Readonly<Record<string, unknown>>): void {\n\t\tconst target = params['targetInfo']\n\t\tif (\n\t\t\t!isRecord(target) ||\n\t\t\ttarget['type'] !== 'page' ||\n\t\t\ttarget['attached'] === true ||\n\t\t\t!isString(target['targetId']) ||\n\t\t\t!isString(target['openerId'])\n\t\t)\n\t\t\treturn\n\t\tconst opener = BrowserPage.#held.get(client)?.get(target['openerId'])\n\t\tif (opener === undefined || opener.#closed) {\n\t\t\tBrowserPage.#reports.get(client)?.set(target['targetId'], target)\n\t\t\treturn\n\t\t}\n\t\topener.#discover(target)\n\t}\n\n\t#discover(target: Readonly<Record<string, unknown>>): void {\n\t\tconst id = target['targetId']\n\t\tconst context = target['browserContextId']\n\t\tif (\n\t\t\t!isString(id) ||\n\t\t\t(this.#contextId !== undefined && isString(context) && context !== this.#contextId)\n\t\t)\n\t\t\treturn\n\t\tif (this.#closed || this.#popups.has(id) || this.#claimed.has(id)) return\n\t\tthis.#claimed.add(id)\n\t\tthis.#expectPopup(id)\n\t\tconst url = target['url']\n\t\tvoid this.#discoverPopup(id, isString(url) && url !== '' ? url : undefined)\n\t}\n\n\t// `owner` is the session that reported the attach: the page session for a page, a worker, or a\n\t// frame the page's process embeds, and a frame session for a frame nested in its frame.\n\t#handleAttached(owner: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst target = params['targetInfo']\n\t\tconst session = params['sessionId']\n\t\tif (!isRecord(target) || !isString(target['targetId']) || !isString(session)) {\n\t\t\treturn\n\t\t}\n\n\t\tconst category = target['type']\n\t\tif (owner !== this.#sessionId && category !== 'iframe') return\n\t\tif (category === 'worker' || category === 'service_worker' || category === 'shared_worker') {\n\t\t\tvoid this.#attachWorker(\n\t\t\t\tsession,\n\t\t\t\ttarget['targetId'],\n\t\t\t\tisString(target['url']) ? target['url'] : '',\n\t\t\t\tcategory,\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tif (category === 'page') {\n\t\t\tconst id = target['targetId']\n\t\t\tif (this.#popups.has(id) || this.#claimed.has(id)) {\n\t\t\t\tvoid this.#detachChild(session, this.#sessionId)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.#claimed.add(id)\n\t\t\tthis.#expectPopup(id)\n\t\t\tvoid this.#attachPopup(\n\t\t\t\tsession,\n\t\t\t\tid,\n\t\t\t\tisString(target['url']) ? target['url'] : 'about:blank',\n\t\t\t\tthis.#sessionId,\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tif (category !== 'iframe') {\n\t\t\tthis.#resumeTarget(session)\n\t\t\treturn\n\t\t}\n\n\t\tconst frame = target['targetId']\n\t\tconst named = isString(target['parentFrameId'])\n\t\tconst parent = isString(target['parentFrameId'])\n\t\t\t? target['parentFrameId']\n\t\t\t: this.#parents.get(frame)\n\t\tif (parent !== undefined) this.#parents.set(frame, parent)\n\t\tconst attached: BrowserFrameInfo = {\n\t\t\tid: frame,\n\t\t\tparent,\n\t\t\tname: undefined,\n\t\t\turl: isString(target['url']) ? target['url'] : 'about:blank',\n\t\t}\n\t\tthis.#attaching.set(session, attached)\n\t\tthis.#worlds.delete(frame)\n\t\tthis.#creating.delete(frame)\n\t\t// A later attach for the same frame supersedes every earlier session, which stops describing\n\t\t// the frame here and keeps no pending record to publish.\n\t\tfor (const [other, owned] of this.#frameIds) {\n\t\t\tif (owned !== frame || other === session) continue\n\t\t\tthis.#attaching.delete(other)\n\t\t\tthis.#frameIds.delete(other)\n\t\t\tthis.#unwatchSession(other)\n\t\t}\n\t\tthis.#watchSession(session)\n\t\tconst attempt = this.#enableFrameSession(session)\n\t\tthis.#frameSessions.set(frame, { session, attempt })\n\t\tthis.#frameIds.set(session, frame)\n\t\tvoid attempt.then(this.#readFrameTree.bind(this, session, attached, named)).then(\n\t\t\t() => {\n\t\t\t\tconst info = this.#attaching.get(session)\n\t\t\t\tthis.#attaching.delete(session)\n\t\t\t\tif (\n\t\t\t\t\tinfo === undefined ||\n\t\t\t\t\tthis.#closed ||\n\t\t\t\t\tthis.#frameSessions.get(frame)?.attempt !== attempt\n\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\tthis.#iframes.set(frame, info)\n\t\t\t\tthis.#emitter.emit('session', this.#frame(info))\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.#attaching.delete(session)\n\t\t\t\tif (this.#frameSessions.get(frame)?.attempt === attempt) this.#frameSessions.delete(frame)\n\t\t\t\tif (this.#frameIds.get(session) === frame) this.#frameIds.delete(session)\n\t\t\t\tthis.#unwatchSession(session)\n\t\t\t\tvoid this.#detachChild(session, owner)\n\t\t\t},\n\t\t)\n\t}\n\n\t#handleDetached(params: Readonly<Record<string, unknown>>): void {\n\t\tconst session = params['sessionId']\n\t\tconst target = params['targetId']\n\t\tif (isString(target)) {\n\t\t\tconst worker = this.#workers.get(target)\n\t\t\tif (worker !== undefined) {\n\t\t\t\tworker.detach()\n\t\t\t\tthis.#workers.delete(target)\n\t\t\t}\n\t\t\tconst popup = this.#popups.get(target)\n\t\t\t// A detached second session of a popup leaves the popup on the session it was published on.\n\t\t\tif (popup !== undefined && popup.#sessionId === session) {\n\t\t\t\tthis.#popups.delete(target)\n\t\t\t\tvoid popup.destroy().catch(() => undefined)\n\t\t\t}\n\t\t}\n\t\tconst frame = isString(target)\n\t\t\t? target\n\t\t\t: isString(session)\n\t\t\t\t? this.#frameIds.get(session)\n\t\t\t\t: undefined\n\t\tconst owner = frame === undefined ? undefined : this.#frameSessions.get(frame)?.session\n\t\t// A superseded session's detach leaves the frame to the session that replaced it.\n\t\tconst superseded = isString(session) && owner !== undefined && owner !== session\n\t\tif (frame !== undefined && !superseded) {\n\t\t\tif (this.#frameSessions.delete(frame)) this.#advanceFrame(frame)\n\t\t\tthis.#pending.delete(frame)\n\t\t\tthis.#iframes.delete(frame)\n\t\t\tthis.#worlds.delete(frame)\n\t\t\tthis.#creating.delete(frame)\n\t\t}\n\t\tif (isString(session) && this.#frameIds.delete(session)) this.#unwatchSession(session)\n\t}\n\n\t#handleContextDestroyed(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst context = params['executionContextId']\n\t\tif (!isInteger(context)) return\n\t\tfor (const [frame, world] of this.#worlds) {\n\t\t\tif (world.session === session && world.context === context) this.#worlds.delete(frame)\n\t\t}\n\t}\n\n\t#handleContextsCleared(session: string): void {\n\t\tfor (const [frame, world] of this.#worlds) {\n\t\t\tif (world.session === session) this.#worlds.delete(frame)\n\t\t}\n\t\tfor (const [frame, pending] of this.#creating) {\n\t\t\tif (pending.session === session) this.#creating.delete(frame)\n\t\t}\n\t}\n\n\t// A signal ends the load wait with its reason, so an abort after `Page.navigate` replied is\n\t// reported as the abort rather than as the navigation timeout.\n\t#waitForLoadEvent(\n\t\tcondition: BrowserWaitUntil,\n\t\ttimeout: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<void> {\n\t\tconst eventName =\n\t\t\tcondition === 'commit'\n\t\t\t\t? 'Page.frameNavigated'\n\t\t\t\t: condition === 'domcontentloaded'\n\t\t\t\t\t? 'Page.domContentEventFired'\n\t\t\t\t\t: condition === 'idle'\n\t\t\t\t\t\t? 'Page.lifecycleEvent'\n\t\t\t\t\t\t: 'Page.loadEventFired'\n\t\tconst deferred = Promise.withResolvers<void>()\n\t\tthis.#sameDocument = false\n\t\tif (condition === 'idle') this.#loader = undefined\n\t\tthis.#loadEvents = [eventName, 'Page.navigatedWithinDocument']\n\t\tthis.#loadResolve = deferred.resolve\n\t\tthis.#loadReject = deferred.reject\n\t\tthis.#loadTimer = setTimeout(() => {\n\t\t\tthis.#rejectLoad(new BrowserError(`Navigation timeout after ${timeout}ms`))\n\t\t}, timeout)\n\t\tfor (const event of this.#loadEvents) {\n\t\t\tthis.#client.subscribe(event, this.#loadHandler, this.#sessionId)\n\t\t}\n\t\tif (signal !== undefined) {\n\t\t\tconst listener = this.#abortLoad.bind(this, signal)\n\t\t\tthis.#loadAbort = { signal, listener }\n\t\t\tsignal.addEventListener('abort', listener, { once: true })\n\t\t}\n\t\treturn deferred.promise\n\t}\n\n\t#abortLoad(signal: AbortSignal): void {\n\t\tthis.#rejectLoad(signal.reason)\n\t}\n\n\t#resolveLoad(): void {\n\t\tconst resolve = this.#loadResolve\n\t\tthis.#clearLoad()\n\t\tresolve?.()\n\t}\n\n\t#rejectLoad(error: unknown): void {\n\t\tconst reject = this.#loadReject\n\t\tthis.#clearLoad()\n\t\treject?.(error)\n\t}\n\n\t#cancelLoad(): void {\n\t\tthis.#rejectLoad(new BrowserError('Navigation cancelled'))\n\t}\n\n\t#clearLoad(): void {\n\t\tif (this.#loadTimer !== undefined) clearTimeout(this.#loadTimer)\n\t\tfor (const event of this.#loadEvents) {\n\t\t\tthis.#client.unsubscribe(event, this.#loadHandler, this.#sessionId)\n\t\t}\n\t\tthis.#loadEvents = []\n\t\tthis.#loadAbort?.signal.removeEventListener('abort', this.#loadAbort.listener)\n\t\tthis.#loadAbort = undefined\n\t\tthis.#loadTimer = undefined\n\t\tthis.#loadResolve = undefined\n\t\tthis.#loadReject = undefined\n\t}\n}\n","import type { BrowserPermissionManagerInterface, CDPClientInterface } from './types.js'\n\n/**\n * Applies permission overrides isolated to one browser context.\n *\n * @example\n * ```ts\n * import { BrowserPermissionManager } from '@orkestrel/browser'\n *\n * const permissions = new BrowserPermissionManager(client)\n * await permissions.grant(['geolocation'], 'https://example.com')\n * await permissions.clear()\n * ```\n */\nexport class BrowserPermissionManager implements BrowserPermissionManagerInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #context: string | undefined\n\n\tconstructor(client: CDPClientInterface, context?: string) {\n\t\tthis.#client = client\n\t\tthis.#context = context\n\t}\n\n\tasync grant(permissions: readonly string[], origin?: string): Promise<void> {\n\t\tawait this.#set(permissions, 'granted', origin)\n\t}\n\n\tasync deny(permissions: readonly string[], origin?: string): Promise<void> {\n\t\tawait this.#set(permissions, 'denied', origin)\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tconst params: Record<string, unknown> = {}\n\t\tif (this.#context !== undefined) params['browserContextId'] = this.#context\n\t\tawait this.#client.send('Browser.resetPermissions', params)\n\t}\n\n\tasync #set(\n\t\tpermissions: readonly string[],\n\t\tsetting: 'granted' | 'denied',\n\t\torigin?: string,\n\t): Promise<void> {\n\t\tfor (const name of permissions) {\n\t\t\tconst params: Record<string, unknown> = {\n\t\t\t\tpermission: { name },\n\t\t\t\tsetting,\n\t\t\t}\n\t\t\tif (origin !== undefined) params['origin'] = origin\n\t\t\tif (this.#context !== undefined) params['browserContextId'] = this.#context\n\t\t\tawait this.#client.send('Browser.setPermission', params)\n\t\t}\n\t}\n}\n","import type {\n\tBrowserCookieInput,\n\tBrowserCookieManagerInterface,\n\tBrowserPagesFunction,\n\tBrowserStorageManagerInterface,\n\tBrowserStorageOptions,\n\tBrowserStorageOrigin,\n\tBrowserStorageState,\n} from './types.js'\nimport {\n\tcompileStorageClearExpression,\n\tcompileStorageReadExpression,\n\tcompileStorageRestoreExpression,\n} from './compilers.js'\nimport { readBrowserStorageOrigin } from './helpers.js'\nimport { BrowserError } from './errors.js'\nimport { attempt } from '@orkestrel/contract'\n\n/**\n * Imports, exports, and clears cookie and web-storage state for one browser context.\n *\n * @example\n * ```ts\n * import { BrowserStorageManager } from '@orkestrel/browser'\n *\n * const storage = new BrowserStorageManager(context.cookies, () => context.pages())\n * const state = await storage.state({ origins: ['https://example.com'] })\n * await storage.restore(state)\n * ```\n */\nexport class BrowserStorageManager implements BrowserStorageManagerInterface {\n\treadonly #cookies: BrowserCookieManagerInterface\n\treadonly #pages: BrowserPagesFunction\n\n\tconstructor(cookies: BrowserCookieManagerInterface, pages: BrowserPagesFunction) {\n\t\tthis.#cookies = cookies\n\t\tthis.#pages = pages\n\t}\n\n\tasync state(options?: BrowserStorageOptions): Promise<BrowserStorageState> {\n\t\tconst pages = this.#pages()\n\t\tconst requested = options?.origins\n\t\tconst origins =\n\t\t\trequested === undefined\n\t\t\t\t? [\n\t\t\t\t\t\t...new Set(\n\t\t\t\t\t\t\tpages.map((page) => this.#origin(page.url)).filter((origin) => origin !== undefined),\n\t\t\t\t\t\t),\n\t\t\t\t\t]\n\t\t\t\t: [...new Set(requested.map((origin) => this.#validate(origin)))]\n\t\tconst storage: BrowserStorageOrigin[] = []\n\n\t\tfor (const origin of origins) {\n\t\t\tconst page = pages.find((candidate) => this.#origin(candidate.url) === origin)\n\t\t\tif (page === undefined) {\n\t\t\t\tthrow new BrowserError('Storage origin has no attached page', undefined, { origin })\n\t\t\t}\n\t\t\tstorage.push(\n\t\t\t\treadBrowserStorageOrigin(await page.evaluate(compileStorageReadExpression()), origin),\n\t\t\t)\n\t\t}\n\n\t\tconst cookies: BrowserCookieInput[] = (await this.#cookies.cookies()).map((cookie) => ({\n\t\t\tname: cookie.name,\n\t\t\tvalue: cookie.value,\n\t\t\tdomain: cookie.domain,\n\t\t\tpath: cookie.path,\n\t\t\texpires: cookie.expires,\n\t\t\thttp: cookie.http,\n\t\t\tsecure: cookie.secure,\n\t\t\t...(cookie.site !== undefined ? { site: cookie.site } : {}),\n\t\t\t...(cookie.partition !== undefined ? { partition: cookie.partition } : {}),\n\t\t}))\n\t\treturn { cookies, origins: storage }\n\t}\n\n\tasync restore(state: BrowserStorageState): Promise<void> {\n\t\tconst pages = this.#pages()\n\t\tfor (const origin of state.origins) {\n\t\t\tconst normalized = this.#validate(origin.origin)\n\t\t\tconst page = pages.find((candidate) => this.#origin(candidate.url) === normalized)\n\t\t\tif (page === undefined) {\n\t\t\t\tthrow new BrowserError('Storage origin has no attached page', undefined, {\n\t\t\t\t\torigin: normalized,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tawait this.#cookies.set(state.cookies)\n\t\tfor (const origin of state.origins) {\n\t\t\tconst normalized = this.#validate(origin.origin)\n\t\t\tconst page = pages.find((candidate) => this.#origin(candidate.url) === normalized)\n\t\t\tif (page === undefined) {\n\t\t\t\tthrow new BrowserError('Storage origin disappeared during restore', undefined, {\n\t\t\t\t\torigin: normalized,\n\t\t\t\t})\n\t\t\t}\n\t\t\tawait page.evaluate(compileStorageRestoreExpression(origin))\n\t\t}\n\t}\n\n\tasync clear(origin?: string): Promise<void> {\n\t\tawait this.#cookies.clear()\n\t\tconst normalized = origin === undefined ? undefined : this.#validate(origin)\n\t\tfor (const page of this.#pages()) {\n\t\t\tif (normalized !== undefined && this.#origin(page.url) !== normalized) continue\n\t\t\tawait page.evaluate(compileStorageClearExpression())\n\t\t}\n\t}\n\n\t#origin(value: string): string | undefined {\n\t\tconst result = attempt(() => new URL(value))\n\t\tif (!result.success) return undefined\n\t\tif (result.value.protocol !== 'http:' && result.value.protocol !== 'https:') return undefined\n\t\treturn result.value.origin\n\t}\n\n\t#validate(value: string): string {\n\t\tconst origin = this.#origin(value)\n\t\tif (origin === undefined) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Browser storage origin must be an absolute HTTP(S) origin',\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\torigin: value,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn origin\n\t}\n}\n","import type {\n\tBrowserContextEventMap,\n\tBrowserContextInterface,\n\tBrowserContextOptions,\n\tBrowserCookieManagerInterface,\n\tBrowserDownloadOptions,\n\tBrowserEmulationManagerInterface,\n\tBrowserEmulationOptions,\n\tBrowserPageEventMap,\n\tBrowserPageInterface,\n\tBrowserPageOptions,\n\tBrowserPermissionManagerInterface,\n\tBrowserStorageManagerInterface,\n\tBrowserViewport,\n\tCDPClientInterface,\n\tCDPTarget,\n\tBrowserWriterInterface,\n} from './types.js'\nimport type { EmitterErrorHandler, EmitterHooks, EmitterInterface } from '@orkestrel/emitter'\nimport { BrowserCookieManager } from './BrowserCookieManager.js'\nimport { BrowserTransition } from './BrowserTransition.js'\nimport { BrowserEmulationManager } from './BrowserEmulationManager.js'\nimport { BrowserPage } from './BrowserPage.js'\nimport { BrowserPermissionManager } from './BrowserPermissionManager.js'\nimport { BrowserStorageManager } from './BrowserStorageManager.js'\nimport { BrowserError } from './errors.js'\nimport { BROWSER_REFERENCE_PREFIX } from './constants.js'\nimport { readBrowserFrames, settleBrowserTeardown, validateBrowserViewport } from './helpers.js'\nimport { instanceOf, isRecord, isString } from '@orkestrel/contract'\nimport { Emitter, extractKeys } from '@orkestrel/emitter'\n\n// === BrowserContext\n\n/**\n * Owns pages and shared state inside one Chromium browser context.\n *\n * @remarks\n * Every page a context constructs holds its target on the client's connection, so `sync` and a\n * popup that discovery reports for the same target yield one page, and the first such page on a\n * connection enables `Target.setDiscoverTargets` for it. The context adopts every popup its pages\n * publish into `pages()` after its opener, and emits `page` once per page; a popup that closed\n * before its adoption completed is not adopted.\n *\n * @example\n * ```ts\n * import { BrowserContext } from '@orkestrel/browser'\n *\n * const context = new BrowserContext(client)\n * const page = await context.create({ url: 'https://example.com' })\n * await context.destroy()\n * ```\n */\nexport class BrowserContext implements BrowserContextInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #id: string | undefined\n\treadonly #viewport: BrowserViewport | undefined\n\treadonly #writer: BrowserWriterInterface | undefined\n\treadonly #downloads: BrowserDownloadOptions | undefined\n\treadonly #emitter: Emitter<BrowserContextEventMap>\n\treadonly #cookies: BrowserCookieManager\n\treadonly #permissions: BrowserPermissionManager\n\treadonly #storage: BrowserStorageManager\n\treadonly #emulation: BrowserEmulationManager\n\treadonly #pages: Map<string, BrowserPage> = new Map()\n\treadonly #creating: Set<Promise<BrowserPage>> = new Set()\n\treadonly #syncing: BrowserTransition = new BrowserTransition()\n\t// The attach by `create` or `sync` in flight for each target, which a popup adoption waits for.\n\treadonly #publishing: Map<string, Promise<void>> = new Map()\n\treadonly #observed: WeakSet<BrowserPage> = new WeakSet()\n\t#shutdown: Promise<void> | undefined\n\t#reference = 0\n\n\tconstructor(\n\t\tclient: CDPClientInterface,\n\t\tid?: string,\n\t\tviewport?: BrowserViewport,\n\t\twriter?: BrowserWriterInterface,\n\t\temulation?: BrowserEmulationOptions,\n\t\tdownloads?: BrowserDownloadOptions,\n\t\toptions?: BrowserContextOptions,\n\t) {\n\t\tthis.#client = client\n\t\tif (viewport !== undefined) validateBrowserViewport(viewport)\n\t\tthis.#id = id\n\t\tthis.#viewport = viewport\n\t\tthis.#writer = writer\n\t\tthis.#downloads = downloads\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on !== undefined ? { on: options.on } : {}),\n\t\t\t...(options?.error !== undefined ? { error: options.error } : {}),\n\t\t})\n\t\tthis.#cookies = new BrowserCookieManager(client, id)\n\t\tthis.#permissions = new BrowserPermissionManager(client, id)\n\t\tthis.#storage = new BrowserStorageManager(this.#cookies, () => this.pages())\n\t\tthis.#emulation = new BrowserEmulationManager(() => this.pages(), emulation)\n\t}\n\n\tget emitter(): EmitterInterface<BrowserContextEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget id(): string | undefined {\n\t\treturn this.#id\n\t}\n\n\tget cookies(): BrowserCookieManagerInterface {\n\t\treturn this.#cookies\n\t}\n\n\tget permissions(): BrowserPermissionManagerInterface {\n\t\treturn this.#permissions\n\t}\n\n\tget storage(): BrowserStorageManagerInterface {\n\t\treturn this.#storage\n\t}\n\n\tget emulation(): BrowserEmulationManagerInterface {\n\t\treturn this.#emulation\n\t}\n\n\tpage(index?: number): BrowserPageInterface | undefined {\n\t\tconst i = index ?? 0\n\t\tconst pages = [...this.#pages.values()]\n\t\treturn i >= 0 && i < pages.length ? pages[i] : undefined\n\t}\n\n\tpages(): readonly BrowserPageInterface[] {\n\t\treturn [...this.#pages.values()]\n\t}\n\n\tasync create(options?: BrowserPageOptions): Promise<BrowserPageInterface> {\n\t\tif (this.#shutdown !== undefined)\n\t\t\tthrow new BrowserError('Browser context is closed', 'BROWSER_CONTEXT_CLOSED')\n\n\t\tconst attempt = this.#create(options)\n\t\tthis.#creating.add(attempt)\n\t\ttry {\n\t\t\treturn await attempt\n\t\t} finally {\n\t\t\tthis.#creating.delete(attempt)\n\t\t}\n\t}\n\n\tasync sync(targets: readonly CDPTarget[]): Promise<void> {\n\t\tlet active = this.#syncing.pending\n\t\twhile (active !== undefined) {\n\t\t\tawait active\n\t\t\tactive = this.#syncing.pending\n\t\t}\n\t\tif (this.#shutdown !== undefined)\n\t\t\tthrow new BrowserError('Browser context is closed', 'BROWSER_CONTEXT_CLOSED')\n\n\t\tawait this.#syncing.execute(() => this.#sync(targets))\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tconst active = this.#shutdown\n\t\tif (active !== undefined) return active\n\n\t\tconst shutdown = this.#destroyResources()\n\t\tthis.#shutdown = shutdown\n\t\treturn shutdown\n\t}\n\n\tclose(): Promise<void> {\n\t\tconst active = this.#shutdown\n\t\tif (active !== undefined) return active\n\n\t\tconst shutdown = this.#closeResources()\n\t\tthis.#shutdown = shutdown\n\t\treturn shutdown\n\t}\n\n\t// === Private helpers\n\n\tasync #create(options?: BrowserPageOptions): Promise<BrowserPage> {\n\t\tif (options?.viewport !== undefined) validateBrowserViewport(options.viewport)\n\t\tconst result: unknown = await this.#client.send('Target.createTarget', {\n\t\t\turl: 'about:blank',\n\t\t\t...(this.#id === undefined ? {} : { browserContextId: this.#id }),\n\t\t})\n\n\t\tif (!isRecord(result) || !isString(result['targetId'])) {\n\t\t\tthrow new BrowserError('Failed to create new browser target')\n\t\t}\n\n\t\tconst targetId = result['targetId']\n\t\tlet page: BrowserPage | undefined\n\t\tconst published = await this.#acquire(targetId)\n\t\tif (published === undefined) return await this.#join(targetId, options)\n\n\t\ttry {\n\t\t\tconst viewport = options?.viewport ?? this.#viewport\n\t\t\tpage = await this.#attach(\n\t\t\t\ttargetId,\n\t\t\t\toptions?.url ?? 'about:blank',\n\t\t\t\tviewport,\n\t\t\t\tpublished.promise,\n\t\t\t\toptions,\n\t\t\t)\n\n\t\t\tif (options?.url !== undefined && options.url !== 'about:blank') {\n\t\t\t\tawait page.navigate(options.url, {\n\t\t\t\t\t...(options.timeout !== undefined ? { timeout: options.timeout } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (this.#shutdown !== undefined) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t'Browser context closed during page creation',\n\t\t\t\t\t'BROWSER_CONTEXT_CLOSED',\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tif (!this.#publish(page)) throw this.#refuse(targetId)\n\t\t\tpublished.resolve()\n\t\t\treturn page\n\t\t} catch (error) {\n\t\t\tif (page !== undefined) {\n\t\t\t\tawait page.close()\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\t// A target another path already holds stays open; the creation joins that path's page.\n\t\t\tif (instanceOf(BrowserError)(error) && error.code === 'BROWSER_TARGET_HELD') {\n\t\t\t\tthis.#unreserve(targetId, published)\n\t\t\t\tconst retry = await this.#acquire(targetId)\n\t\t\t\tif (retry === undefined) return await this.#join(targetId, options)\n\t\t\t\tthis.#unreserve(targetId, retry)\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tawait this.#closeTarget(targetId)\n\t\t\tthrow error\n\t\t} finally {\n\t\t\tthis.#unreserve(targetId, published)\n\t\t}\n\t}\n\n\tasync #sync(targets: readonly CDPTarget[]): Promise<void> {\n\t\tconst pageTargets = targets.filter((target) => target.category === 'page')\n\t\tconst targetIds = new Set(pageTargets.map((target) => target.id))\n\n\t\tfor (const [id, page] of this.#pages) {\n\t\t\tif (targetIds.has(id)) continue\n\t\t\tawait page.destroy()\n\t\t\tthis.#pages.delete(id)\n\t\t}\n\n\t\tfor (const target of pageTargets) {\n\t\t\tif (this.#shutdown !== undefined) continue\n\t\t\tconst published = await this.#acquire(target.id)\n\t\t\tif (published === undefined) continue\n\t\t\ttry {\n\t\t\t\tconst page = await this.#reattach(target.id, target.url, this.#viewport, published.promise)\n\t\t\t\tif (this.#shutdown !== undefined) {\n\t\t\t\t\tawait page.destroy()\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t// A page that closed before its publication settles the reservation as a failure.\n\t\t\t\tif (this.#publish(page)) published.resolve()\n\t\t\t} catch {\n\t\t\t\t// A disappearing or unsupported target, or one a popup attach already holds, does not\n\t\t\t\t// invalidate its siblings.\n\t\t\t} finally {\n\t\t\t\tthis.#unreserve(target.id, published)\n\t\t\t}\n\t\t}\n\t}\n\n\tasync #attach(\n\t\ttargetId: string,\n\t\turl: string,\n\t\tviewport: BrowserViewport | undefined,\n\t\tready: Promise<void>,\n\t\toptions?: BrowserPageOptions,\n\t): Promise<BrowserPage> {\n\t\tlet sessionId: string | undefined\n\t\tlet page: BrowserPage | undefined\n\n\t\ttry {\n\t\t\tsessionId = await this.#openSession(targetId)\n\t\t\tawait this.#enableSession(sessionId)\n\t\t\tconst frameId = await this.#mainFrame(sessionId)\n\t\t\tpage = new BrowserPage(\n\t\t\t\tthis.#client,\n\t\t\t\ttargetId,\n\t\t\t\tsessionId,\n\t\t\t\tthis.#writer,\n\t\t\t\turl,\n\t\t\t\tframeId,\n\t\t\t\tthis.#id,\n\t\t\t\tundefined,\n\t\t\t\toptions,\n\t\t\t\tthis.#nextReference.bind(this),\n\t\t\t\tready,\n\t\t\t)\n\t\t\tthis.#observe(page)\n\t\t\tawait this.#configurePage(page)\n\t\t\tawait this.#emulation.attach(page)\n\t\t\tif (viewport !== undefined) await this.#applyViewport(page, viewport)\n\n\t\t\treturn page\n\t\t} catch (error) {\n\t\t\tif (page !== undefined) await page.destroy().catch(() => undefined)\n\t\t\telse if (sessionId !== undefined) await this.#detachSession(sessionId)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #reattach(\n\t\ttargetId: string,\n\t\turl: string,\n\t\tviewport: BrowserViewport | undefined,\n\t\tready: Promise<void>,\n\t): Promise<BrowserPage> {\n\t\tlet sessionId: string | undefined\n\t\tlet page: BrowserPage | undefined\n\n\t\ttry {\n\t\t\tsessionId = await this.#openSession(targetId)\n\t\t\tawait this.#enableSession(sessionId)\n\t\t\tconst frameId = await this.#mainFrame(sessionId)\n\t\t\tpage = new BrowserPage(\n\t\t\t\tthis.#client,\n\t\t\t\ttargetId,\n\t\t\t\tsessionId,\n\t\t\t\tthis.#writer,\n\t\t\t\turl,\n\t\t\t\tframeId,\n\t\t\t\tthis.#id,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tthis.#nextReference.bind(this),\n\t\t\t\tready,\n\t\t\t)\n\t\t\tthis.#observe(page)\n\t\t\tawait this.#configurePage(page)\n\t\t\tawait this.#emulation.attach(page)\n\t\t\tif (viewport !== undefined) await this.#tryViewport(page, viewport)\n\n\t\t\treturn page\n\t\t} catch (error) {\n\t\t\tif (page !== undefined) await page.destroy().catch(() => undefined)\n\t\t\telse if (sessionId !== undefined) await this.#detachSession(sessionId)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t#nextReference(): string {\n\t\treturn `${BROWSER_REFERENCE_PREFIX}${++this.#reference}`\n\t}\n\n\tasync #destroyResources(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#settle()\n\t\t\tconst failure = await settleBrowserTeardown(\n\t\t\t\t...[...this.#pages.values()].map((page) => () => page.destroy()),\n\t\t\t)\n\t\t\tthis.#pages.clear()\n\t\t\tif (failure !== undefined) throw failure\n\t\t} finally {\n\t\t\tthis.#finish()\n\t\t}\n\t}\n\n\tasync #closeResources(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#settle()\n\t\t\tlet failure = await settleBrowserTeardown(\n\t\t\t\t...[...this.#pages.values()].map((page) => () => page.close()),\n\t\t\t)\n\t\t\tthis.#pages.clear()\n\n\t\t\tconst id = this.#id\n\t\t\tif (id !== undefined) {\n\t\t\t\tconst settled = await settleBrowserTeardown(() =>\n\t\t\t\t\tthis.#client.send('Target.disposeBrowserContext', { browserContextId: id }),\n\t\t\t\t)\n\t\t\t\tfailure ??= settled\n\t\t\t}\n\t\t\tif (failure !== undefined) throw failure\n\t\t} finally {\n\t\t\tthis.#finish()\n\t\t}\n\t}\n\n\tasync #settle(): Promise<void> {\n\t\tawait Promise.allSettled([...this.#creating])\n\t\tawait this.#syncing.pending?.catch(() => undefined)\n\t}\n\n\t// Acquires a target's reservation for `create` or `sync`: after every wait for the current\n\t// reservation to settle, the check for a held page and for a current reservation and the\n\t// installation of this one run as one synchronous step, so a waiter that resumes never installs\n\t// over a reservation another path installed while it waited. Undefined when the context holds\n\t// a page for the target.\n\tasync #acquire(target: string): Promise<PromiseWithResolvers<void> | undefined> {\n\t\tfor (\n\t\t\tlet current = this.#publishing.get(target);\n\t\t\tcurrent !== undefined;\n\t\t\tcurrent = this.#publishing.get(target)\n\t\t)\n\t\t\tawait Promise.allSettled([current])\n\t\treturn this.#pages.has(target) ? undefined : this.#reserve(target)\n\t}\n\n\t// Joins a creation to the page another path published for its target, applying the creation's\n\t// hooks, viewport, and navigation to it; a page that closed first or meanwhile rejects.\n\tasync #join(target: string, options?: BrowserPageOptions): Promise<BrowserPage> {\n\t\tconst page = this.#pages.get(target)\n\t\tif (page === undefined || page.closed) throw this.#refuse(target)\n\t\tconst hooks = options?.on\n\t\tif (hooks !== undefined)\n\t\t\tfor (const event of extractKeys(hooks)) this.#hook(page, event, hooks, options?.error)\n\t\ttry {\n\t\t\tif (options?.viewport !== undefined) await this.#applyViewport(page, options.viewport)\n\t\t\t// A joined page can have left the blank document the target was created at.\n\t\t\tif (options?.url !== undefined) {\n\t\t\t\tawait page.navigate(options.url, {\n\t\t\t\t\t...(options.timeout !== undefined ? { timeout: options.timeout } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (page.closed) throw this.#refuse(target)\n\t\t\tthrow error\n\t\t}\n\t\tif (page.closed || this.#pages.get(target) !== page) throw this.#refuse(target)\n\t\treturn page\n\t}\n\n\t// Registers one creation hook on a joined page, reporting its throw to the creation's own\n\t// `error` handler, as the emitter a creation constructs would, and never to the page's.\n\t#hook<K extends keyof BrowserPageEventMap>(\n\t\tpage: BrowserPage,\n\t\tevent: K,\n\t\thooks: EmitterHooks<BrowserPageEventMap>,\n\t\treport: EmitterErrorHandler | undefined,\n\t): void {\n\t\tconst handler = hooks[event]\n\t\tif (handler === undefined) return\n\t\tpage.emitter.on(event, (...args) => {\n\t\t\ttry {\n\t\t\t\thandler(...args)\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\treport?.(error, String(event))\n\t\t\t\t} catch {\n\t\t\t\t\t// A throwing reporter is swallowed, as the emitter swallows its own.\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\t#refuse(target: string): BrowserError {\n\t\treturn new BrowserError('Browser page closed during creation', 'BROWSER_PAGE_CLOSED', {\n\t\t\ttarget,\n\t\t})\n\t}\n\n\t// Installs a target's reservation, which a popup adoption of a descendant waits for; the page it\n\t// passes as `ready` holds its target until the publication fails. `create` and `sync` install\n\t// one only through `#acquire`; an adoption replaces the current one and waits for it.\n\t#reserve(target: string): PromiseWithResolvers<void> {\n\t\tconst published = Promise.withResolvers<void>()\n\t\tvoid published.promise.catch(() => undefined)\n\t\tthis.#publishing.set(target, published.promise)\n\t\treturn published\n\t}\n\n\t#unreserve(target: string, published: PromiseWithResolvers<void>): void {\n\t\tif (this.#publishing.get(target) === published.promise) this.#publishing.delete(target)\n\t\tpublished.reject(new BrowserError('Browser page was not published'))\n\t}\n\n\t// Publishes a live page once; true if the context holds it afterwards, false for a closed page.\n\t#publish(page: BrowserPage): boolean {\n\t\tif (page.closed) return false\n\t\tif (this.#pages.get(page.target) === page) return true\n\t\tthis.#pages.set(page.target, page)\n\t\tthis.#emitter.emit('page', page)\n\t\treturn true\n\t}\n\n\tasync #openSession(targetId: string): Promise<string> {\n\t\tconst result: unknown = await this.#client.send('Target.attachToTarget', {\n\t\t\ttargetId,\n\t\t\tflatten: true,\n\t\t})\n\t\tif (!isRecord(result) || !isString(result['sessionId'])) {\n\t\t\tthrow new BrowserError('Failed to attach to browser target')\n\t\t}\n\t\treturn result['sessionId']\n\t}\n\n\tasync #enableSession(sessionId: string): Promise<void> {\n\t\tawait this.#client.send('Page.enable', undefined, { session: sessionId })\n\t\tawait this.#client.send('Runtime.enable', undefined, { session: sessionId })\n\t}\n\n\tasync #mainFrame(sessionId: string): Promise<string> {\n\t\tconst result = await this.#client.send('Page.getFrameTree', undefined, { session: sessionId })\n\t\tconst frame = readBrowserFrames(result)[0]\n\t\tif (frame === undefined) throw new BrowserError('Failed to resolve the main browser frame')\n\t\treturn frame.id\n\t}\n\n\tasync #configurePage(page: BrowserPage): Promise<void> {\n\t\tawait page.send('Target.setAutoAttach', {\n\t\t\tautoAttach: true,\n\t\t\twaitForDebuggerOnStart: true,\n\t\t\tflatten: true,\n\t\t})\n\t\tawait page.send('Page.setInterceptFileChooserDialog', { enabled: true })\n\t\tawait page.send('Page.setLifecycleEventsEnabled', { enabled: true })\n\t\tconst download: Record<string, unknown> = {\n\t\t\tbehavior:\n\t\t\t\tthis.#downloads === undefined\n\t\t\t\t\t? 'default'\n\t\t\t\t\t: this.#downloads.named === true\n\t\t\t\t\t\t? 'allowAndName'\n\t\t\t\t\t\t: 'allow',\n\t\t\teventsEnabled: true,\n\t\t}\n\t\tif (this.#id !== undefined) download['browserContextId'] = this.#id\n\t\tif (this.#downloads !== undefined) download['downloadPath'] = this.#downloads.path\n\t\tawait this.#client.send('Browser.setDownloadBehavior', download)\n\t\tawait page.network.start()\n\t}\n\n\tasync #applyViewport(page: BrowserPage, viewport: BrowserViewport): Promise<void> {\n\t\tawait page.send('Emulation.setDeviceMetricsOverride', {\n\t\t\twidth: viewport.width,\n\t\t\theight: viewport.height,\n\t\t\tdeviceScaleFactor: viewport.scale ?? 1,\n\t\t\tmobile: viewport.mobile ?? false,\n\t\t\tscreenOrientation:\n\t\t\t\tviewport.landscape === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: {\n\t\t\t\t\t\t\ttype: viewport.landscape ? 'landscapePrimary' : 'portraitPrimary',\n\t\t\t\t\t\t\tangle: viewport.landscape ? 90 : 0,\n\t\t\t\t\t\t},\n\t\t})\n\t\tawait page.send('Emulation.setTouchEmulationEnabled', { enabled: viewport.touch ?? false })\n\t}\n\n\tasync #tryViewport(page: BrowserPage, viewport: BrowserViewport): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#applyViewport(page, viewport)\n\t\t} catch {\n\t\t\t// Reattached targets may not support viewport emulation.\n\t\t}\n\t}\n\n\tasync #closeTarget(targetId: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#client.send('Target.closeTarget', { targetId })\n\t\t} catch {\n\t\t\t// The target may already be gone.\n\t\t}\n\t}\n\n\tasync #detachSession(sessionId: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#client.send('Target.detachFromTarget', { sessionId })\n\t\t} catch {\n\t\t\t// The session may already be detached.\n\t\t}\n\t}\n\n\t#observe(page: BrowserPage): void {\n\t\tif (this.#observed.has(page)) return\n\t\tthis.#observed.add(page)\n\t\tpage.emitter.on('popup', (popup) => {\n\t\t\tif (this.#shutdown !== undefined) {\n\t\t\t\tvoid popup.destroy().catch(() => undefined)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (instanceOf(BrowserPage)(popup)) {\n\t\t\t\tvoid this.#adoptPopup(popup)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.#emitter.emit('page', popup)\n\t\t})\n\t\tpage.emitter.on('close', () => {\n\t\t\tif (this.#pages.get(page.target) === page) this.#pages.delete(page.target)\n\t\t})\n\t}\n\n\t// An adoption takes over its target's reservation for as long as it runs, after the `create` or\n\t// `sync` reservation it replaced settles; a popup that attach holds is published by it. Each\n\t// adoption waits for its opener's publication, so each `page` event follows its opener's.\n\tasync #adoptPopup(popup: BrowserPage): Promise<void> {\n\t\tthis.#observe(popup)\n\t\tconst predecessor = this.#publishing.get(popup.target)\n\t\tconst published = this.#reserve(popup.target)\n\t\ttry {\n\t\t\tawait Promise.allSettled([this.#publishing.get(popup.opener?.target ?? ''), predecessor])\n\t\t\tif (this.#pages.get(popup.target) === popup) return\n\t\t\tawait this.#emulation.attach(popup)\n\t\t\tif (this.#shutdown !== undefined || popup.closed) {\n\t\t\t\tawait popup.destroy()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.#publish(popup)\n\t\t\tpublished.resolve()\n\t\t} catch {\n\t\t\tawait popup.destroy().catch(() => undefined)\n\t\t} finally {\n\t\t\tthis.#unreserve(popup.target, published)\n\t\t}\n\t}\n\n\t#finish(): void {\n\t\tif (this.#emitter.destroyed) return\n\t\tthis.#emitter.emit('close')\n\t\tthis.#emitter.destroy()\n\t}\n}\n","import type { BrowserHoldInterface } from './types.js'\n\n/**\n * Owns a replay's caller token and releases its admission reservation once.\n *\n * @example\n * ```ts\n * const hold = await toolset.hold('add-kettle')\n * try {\n * \tawait toolset.perform(call, { caller: hold.token, signal })\n * } finally {\n * \thold.destroy()\n * }\n * ```\n */\nexport class BrowserHold implements BrowserHoldInterface {\n\treadonly #name: string\n\treadonly #token = crypto.randomUUID()\n\t#release: (() => void) | undefined\n\n\tconstructor(name: string, release: () => void) {\n\t\tthis.#name = name\n\t\tthis.#release = release\n\t}\n\n\tget name(): string {\n\t\treturn this.#name\n\t}\n\n\tget token(): string {\n\t\treturn this.#token\n\t}\n\n\tdestroy(): void {\n\t\tconst release = this.#release\n\t\tthis.#release = undefined\n\t\trelease?.()\n\t}\n}\n","import type {\n\tBrowserAction,\n\tBrowserJourney,\n\tBrowserJourneyStep,\n\tBrowserJourneyStepInput,\n\tBrowserRecorderEventMap,\n\tBrowserRecorderInterface,\n\tBrowserRecorderOptions,\n\tBrowserToolsetInterface,\n} from '../types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { Emitter } from '@orkestrel/emitter'\nimport {\n\tBROWSER_JOURNEY_ACTIONS,\n\tBROWSER_JOURNEY_NON_STEP_TOOLS,\n\tBROWSER_JOURNEY_STEP_KEYS,\n} from '../constants.js'\nimport { BrowserError } from '../errors.js'\nimport {\n\tbuildBrowserJourney,\n\tcollectBrowserJourneyTextBindings,\n\tderiveBrowserJourneySecret,\n} from '../helpers.js'\n\n/**\n * Records semantic steps from completed toolset actions and omits refused or timed-out actions.\n * @remarks\n * Gaps mark a child frame, a held replay, or an unanswered interruption.\n * @example\n * const recorder = new BrowserRecorder(toolset)\n * await recorder.start()\n * await toolset.perform(call)\n * const steps = await recorder.stop()\n */\nexport class BrowserRecorder implements BrowserRecorderInterface {\n\treadonly #toolset: BrowserToolsetInterface\n\treadonly #emitter: Emitter<BrowserRecorderEventMap>\n\treadonly #action = this.#recordAction.bind(this)\n\treadonly #hold = this.#recordHold.bind(this)\n\t#started = false\n\t#steps: readonly BrowserJourneyStep[] = []\n\t#pending: BrowserAction | undefined\n\n\tconstructor(toolset: BrowserToolsetInterface, options?: BrowserRecorderOptions) {\n\t\tthis.#toolset = toolset\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t\ttoolset.emitter.on('action', this.#action)\n\t\ttoolset.emitter.on('hold', this.#hold)\n\t}\n\n\tget emitter(): EmitterInterface<BrowserRecorderEventMap> {\n\t\treturn this.#emitter\n\t}\n\tget started(): boolean {\n\t\treturn this.#started\n\t}\n\n\tasync start(): Promise<void> {\n\t\tif (this.#emitter.destroyed) throw new BrowserError('The recorder was destroyed')\n\t\tthis.clear()\n\t\tthis.#started = true\n\t\tconst held = this.#toolset.held\n\t\tif (held !== undefined)\n\t\t\tthis.#append({ action: 'unresolved', arguments: {}, gap: `replayed ${held}` })\n\t\tthis.#emitter.emit('start')\n\t}\n\n\tasync stop(): Promise<readonly BrowserJourneyStep[]> {\n\t\tthis.#flushPending()\n\t\tthis.#started = false\n\t\tconst steps = this.steps()\n\t\tthis.#emitter.emit('stop', structuredClone(steps))\n\t\treturn steps\n\t}\n\n\tsteps(): readonly BrowserJourneyStep[] {\n\t\treturn structuredClone(this.#steps)\n\t}\n\n\tjourney(options: { readonly name: string; readonly description: string }): BrowserJourney {\n\t\tconst steps: readonly BrowserJourneyStep[] =\n\t\t\tthis.#pending === undefined\n\t\t\t\t? this.#steps\n\t\t\t\t: [\n\t\t\t\t\t\t...this.#steps,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: `s${this.#steps.length + 1}`,\n\t\t\t\t\t\t\taction: 'unresolved',\n\t\t\t\t\t\t\targuments: {},\n\t\t\t\t\t\t\tgap: `interrupted ${this.#pending.action}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\treturn buildBrowserJourney(steps, options)\n\t}\n\n\tclear(): void {\n\t\tthis.#steps = []\n\t\tthis.#pending = undefined\n\t\tthis.#emitter.emit('clear')\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tthis.#started = false\n\t\tthis.#pending = undefined\n\t\tthis.#toolset.emitter.off('action', this.#action)\n\t\tthis.#toolset.emitter.off('hold', this.#hold)\n\t\tthis.#emitter.destroy()\n\t}\n\n\t#recordAction(action: BrowserAction): void {\n\t\tif (!this.#started || this.#toolset.held !== undefined) return\n\t\tif (this.#pending !== undefined) {\n\t\t\tconst pending = this.#pending\n\t\t\tthis.#pending = undefined\n\t\t\tif (action.action === 'dialog' && action.outcome === 'done') this.#appendAction(pending)\n\t\t\telse\n\t\t\t\tthis.#append({ action: 'unresolved', arguments: {}, gap: `interrupted ${pending.action}` })\n\t\t}\n\t\tif (\n\t\t\tBROWSER_JOURNEY_NON_STEP_TOOLS.includes(action.action) ||\n\t\t\taction.outcome === 'refused' ||\n\t\t\taction.outcome === 'timeout'\n\t\t)\n\t\t\treturn\n\t\tif (action.outcome === 'interrupted') {\n\t\t\tthis.#pending = structuredClone(action)\n\t\t\treturn\n\t\t}\n\t\tthis.#appendAction(action)\n\t}\n\n\t#appendAction(action: BrowserAction): void {\n\t\tif (action.target?.frame !== undefined) {\n\t\t\tthis.#append({ action: 'unresolved', arguments: {}, gap: 'the element is in a child frame' })\n\t\t\treturn\n\t\t}\n\t\tconst args = { ...action.arguments }\n\t\tif (BROWSER_JOURNEY_ACTIONS.some((name) => name === action.action)) {\n\t\t\tfor (const key of BROWSER_JOURNEY_STEP_KEYS) delete args[key]\n\t\t}\n\t\tif (action.action === 'type' && action.secret === true) {\n\t\t\tconst taken = collectBrowserJourneyTextBindings(this.#steps)\n\t\t\targs['text'] = { parameter: deriveBrowserJourneySecret(action.target?.name ?? '', taken) }\n\t\t}\n\t\tthis.#append({\n\t\t\taction: action.action,\n\t\t\targuments: args,\n\t\t\t...(action.target === undefined\n\t\t\t\t? {}\n\t\t\t\t: {\n\t\t\t\t\t\ttarget: {\n\t\t\t\t\t\t\trole: action.target.role,\n\t\t\t\t\t\t\tname: action.target.name,\n\t\t\t\t\t\t\treference: action.target.reference,\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t// A click that opened a popup carries the popup's tab as settlement evidence; only a switch\n\t\t\t// step names a tab.\n\t\t\t...(action.action !== 'switch' || action.tab === undefined ? {} : { tab: action.tab }),\n\t\t})\n\t}\n\n\t#append(step: BrowserJourneyStepInput): void {\n\t\tconst recorded = structuredClone({ ...step, id: `s${this.#steps.length + 1}` })\n\t\tthis.#steps = [...this.#steps, recorded]\n\t\tthis.#emitter.emit('step', structuredClone(recorded))\n\t}\n\n\t#flushPending(): void {\n\t\tif (this.#pending === undefined) return\n\t\tconst pending = this.#pending\n\t\tthis.#pending = undefined\n\t\tthis.#append({ action: 'unresolved', arguments: {}, gap: `interrupted ${pending.action}` })\n\t}\n\n\t#recordHold(name: string): void {\n\t\tif (!this.#started) return\n\t\tthis.#flushPending()\n\t\tthis.#append({ action: 'unresolved', arguments: {}, gap: `replayed ${name}` })\n\t}\n}\n","import type { JSONValue } from '@orkestrel/contract'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tBrowserAction,\n\tBrowserJourney,\n\tBrowserCallOptions,\n\tBrowserConsoleMessage,\n\tBrowserHoldInterface,\n\tBrowserJourneyRevision,\n\tBrowserJourneyStep,\n\tBrowserPageError,\n\tBrowserReplayEventMap,\n\tBrowserReplayInterface,\n\tBrowserReplayOptions,\n\tBrowserRun,\n\tBrowserRunOutcome,\n\tBrowserRunSlot,\n\tBrowserRunStep,\n\tBrowserToolsetInterface,\n\tBrowserViewEventMap,\n} from './types.js'\nimport { isString } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { BROWSER_JOURNEY_ACTIONS, BROWSER_JOURNEY_FORMAT_VERSION } from './constants.js'\nimport { BrowserError, isBrowserError, isBrowserStepError } from './errors.js'\nimport {\n\tderiveBrowserJourneyTrigger,\n\tgenerateBrowserRunId,\n\tresolveBrowserJourneyBinding,\n\tvalidateBrowserJourney,\n} from './helpers.js'\nimport { isBrowserJourneyBinding, isBrowserSecretBinding } from './validators.js'\n/**\n * Prepares and replays a journey under a toolset hold, retaining its executed prefix.\n * @example\n * const replay = new BrowserReplay(toolset, { journey }, { runs })\n * const run = await replay.execute({ signal })\n */\nexport class BrowserReplay implements BrowserReplayInterface {\n\treadonly #toolset: BrowserToolsetInterface\n\treadonly #revision: BrowserJourneyRevision\n\treadonly #options: BrowserReplayOptions | undefined\n\treadonly #emitter: Emitter<BrowserReplayEventMap>\n\n\tconstructor(\n\t\ttoolset: BrowserToolsetInterface,\n\t\trevision: BrowserJourneyRevision,\n\t\toptions?: BrowserReplayOptions,\n\t) {\n\t\tthis.#toolset = toolset\n\t\tthis.#revision = revision\n\t\tthis.#options = options\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t}\n\n\tget emitter(): EmitterInterface<BrowserReplayEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tasync execute(options?: BrowserCallOptions): Promise<BrowserRun> {\n\t\tconst inputs = this.#prepare()\n\t\tconst revision = structuredClone(this.#revision)\n\t\tconst journey = revision.journey\n\t\tif (this.#toolset.emitter.destroyed)\n\t\t\tthrow new BrowserError('The browser session ended', 'BROWSER_TOOLSET_ENDED')\n\t\tconst started = performance.now()\n\t\tconst secret = Object.values(journey.parameters).some((parameter) => parameter.secret === true)\n\t\tconst visible = Object.fromEntries(\n\t\t\tObject.entries(inputs).filter(([name]) => journey.parameters[name]?.secret !== true),\n\t\t)\n\t\tconst steps: BrowserRunStep[] = []\n\t\tconst output: string[] = []\n\t\tconst cleanup: Array<() => void> = []\n\t\tconst observed = new Set<EmitterInterface<BrowserViewEventMap>>()\n\t\tlet hold: BrowserHoldInterface | undefined\n\t\tlet slot: BrowserRunSlot = { id: generateBrowserRunId() }\n\t\tlet outcome: BrowserRunOutcome = 'complete'\n\t\tlet fault: string | undefined\n\t\tlet run: BrowserRun\n\t\ttry {\n\t\t\thold = await this.#toolset.hold(journey.name, options)\n\t\t\toptions?.signal?.throwIfAborted()\n\t\t\tif (this.#options?.runs !== undefined)\n\t\t\t\tslot = await this.#options.runs.open(journey.name, options)\n\t\t\tif (!secret) {\n\t\t\t\tthis.#observe(output, cleanup, observed)\n\t\t\t\tconst select = this.#observe.bind(this, output, cleanup, observed)\n\t\t\t\tthis.#toolset.emitter.on('select', select)\n\t\t\t\tcleanup.push(() => this.#toolset.emitter.off('select', select))\n\t\t\t}\n\t\t\tfor (const [index, step] of journey.steps.entries()) {\n\t\t\t\toptions?.signal?.throwIfAborted()\n\t\t\t\tconst previous = steps.at(-1)\n\t\t\t\tlet recorded = await this.#executeStep(\n\t\t\t\t\tstep,\n\t\t\t\t\tinputs,\n\t\t\t\t\thold.token,\n\t\t\t\t\tprevious?.outcome === 'interrupted',\n\t\t\t\t\tjourney.parameters,\n\t\t\t\t\toptions,\n\t\t\t\t)\n\t\t\t\tsteps.push(recorded)\n\t\t\t\ttry {\n\t\t\t\t\tif (!secret && !options?.signal?.aborted && recorded.outcome !== 'interrupted') {\n\t\t\t\t\t\tconst capture = await this.#capture(slot, step.id, options)\n\t\t\t\t\t\tif (capture !== undefined) {\n\t\t\t\t\t\t\trecorded = { ...recorded, capture }\n\t\t\t\t\t\t\tsteps[steps.length - 1] = recorded\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tthis.#emitter.emit('step', structuredClone(recorded))\n\t\t\t\t}\n\t\t\t\tconst result = recorded\n\t\t\t\tif (options?.signal?.aborted) {\n\t\t\t\t\toutcome = 'aborted'\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tresult.outcome !== 'done' ||\n\t\t\t\t\tresult.stage === 'requested' ||\n\t\t\t\t\tresult.stage === 'committed'\n\t\t\t\t) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tresult.outcome === 'interrupted' &&\n\t\t\t\t\t\tjourney.steps[index + 1]?.action === 'dialog' &&\n\t\t\t\t\t\tresult.stage !== 'requested' &&\n\t\t\t\t\t\tresult.stage !== 'committed'\n\t\t\t\t\t)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\toutcome = 'stopped'\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\toutcome = options?.signal?.aborted ? 'aborted' : 'stopped'\n\t\t\tif (!options?.signal?.aborted) fault = error instanceof Error ? error.message : String(error)\n\t\t} finally {\n\t\t\thold?.destroy()\n\t\t\tfor (const release of cleanup) release()\n\t\t\trun = {\n\t\t\t\tformat: BROWSER_JOURNEY_FORMAT_VERSION,\n\t\t\t\tid: slot.id,\n\t\t\t\tjourney,\n\t\t\t\t...(revision.revision === undefined ? {} : { revision: revision.revision }),\n\t\t\t\tinputs: visible,\n\t\t\t\tsteps,\n\t\t\t\toutcome,\n\t\t\t\t...(secret || !this.#toolset.view.trusted ? {} : { output }),\n\t\t\t\telapsed: performance.now() - started,\n\t\t\t\t...(fault === undefined ? {} : { fault }),\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait this.#write(run)\n\t\t\t} catch (error) {\n\t\t\t\trun = { ...run, fault: error instanceof Error ? error.message : String(error) }\n\t\t\t}\n\t\t}\n\t\treturn run\n\t}\n\n\t#prepare(): Readonly<Record<string, string>> {\n\t\tconst journey = this.#revision.journey\n\t\tconst placement = this.#toolset.native.some((tool) => tool.name === 'navigate') ? 'page' : 'dom'\n\t\ttry {\n\t\t\tvalidateBrowserJourney(journey)\n\t\t} catch (error) {\n\t\t\tif (!isBrowserError(error)) throw error\n\t\t\tthrow new BrowserError(\n\t\t\t\terror.message,\n\t\t\t\terror.code,\n\t\t\t\terror.context ?? { action: 'replay', placement },\n\t\t\t)\n\t\t}\n\t\tconst supplied = this.#options?.inputs ?? {}\n\t\tfor (const name of Object.keys(supplied)) {\n\t\t\tif (!Object.hasOwn(journey.parameters, name))\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Journey ${journey.name} has no parameter named ${JSON.stringify(name)}.`,\n\t\t\t\t\t'BROWSER_JOURNEY_INPUT',\n\t\t\t\t\t{ parameter: name },\n\t\t\t\t)\n\t\t}\n\t\t// The generated module reads `inputs.NAME`, and only an own member for a name\n\t\t// `Object.prototype` carries; an own `undefined` is an omitted input there too.\n\t\tconst values = new Map(\n\t\t\tObject.keys(journey.parameters).map((name): [string, unknown] => [\n\t\t\t\tname,\n\t\t\t\tname in Object.prototype && !Object.hasOwn(supplied, name) ? undefined : supplied[name],\n\t\t\t]),\n\t\t)\n\t\tconst parameters = Object.entries(journey.parameters)\n\t\t// The module checks every required input before any defaulted one, so the refusals agree.\n\t\tfor (const [name, parameter] of parameters) {\n\t\t\tif (parameter.default === undefined && !isString(values.get(name)))\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Journey ${journey.name} needs input ${JSON.stringify(name)}.`,\n\t\t\t\t\t'BROWSER_JOURNEY_INPUT',\n\t\t\t\t\t{ parameter: name },\n\t\t\t\t)\n\t\t}\n\t\tconst inputs: Record<string, string> = {}\n\t\tfor (const [name, parameter] of parameters) {\n\t\t\tconst value = values.get(name)\n\t\t\tif (isString(value)) inputs[name] = value\n\t\t\telse if (value !== undefined)\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Journey ${journey.name} input ${JSON.stringify(name)} is not a string.`,\n\t\t\t\t\t'BROWSER_JOURNEY_INPUT',\n\t\t\t\t\t{ parameter: name },\n\t\t\t\t)\n\t\t\telse if (parameter.default !== undefined) inputs[name] = parameter.default\n\t\t}\n\t\tfor (const step of journey.steps) {\n\t\t\tif (step.action === 'unresolved')\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Step ${step.id} is unresolved: ${step.gap}.`,\n\t\t\t\t\t'BROWSER_JOURNEY_GAP',\n\t\t\t\t\t{ step: step.id },\n\t\t\t\t)\n\t\t\tif (BROWSER_JOURNEY_ACTIONS.some((name) => name === step.action)) {\n\t\t\t\tconst supported =\n\t\t\t\t\t['click', 'type', 'wait'].includes(step.action) ||\n\t\t\t\t\t(step.action === 'dialog'\n\t\t\t\t\t\t? this.#toolset.native.some((tool) => tool.name === 'navigate')\n\t\t\t\t\t\t: step.action === 'switch'\n\t\t\t\t\t\t\t? this.#toolset.tools.tool('switch') !== undefined\n\t\t\t\t\t\t\t: this.#toolset.native.some((tool) => tool.name === step.action))\n\t\t\t\tif (!supported)\n\t\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t\t`Step ${step.id} cannot execute ${step.action} in this placement.`,\n\t\t\t\t\t\t'BROWSER_JOURNEY_PLACEMENT',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstep: step.id,\n\t\t\t\t\t\t\taction: step.action,\n\t\t\t\t\t\t\tplacement,\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\treturn inputs\n\t}\n\n\tasync #executeStep(\n\t\tstep: BrowserJourneyStep,\n\t\tinputs: Readonly<Record<string, string>>,\n\t\tcaller: string,\n\t\tinterrupted: boolean,\n\t\tparameters: BrowserJourney['parameters'],\n\t\toptions?: BrowserCallOptions,\n\t): Promise<BrowserRunStep> {\n\t\tconst started = performance.now()\n\t\tconst args: Record<string, JSONValue> = {}\n\t\tconst native = BROWSER_JOURNEY_ACTIONS.some((name) => name === step.action)\n\t\tfor (const [key, value] of Object.entries(step.arguments)) {\n\t\t\targs[key] =\n\t\t\t\tnative && isBrowserJourneyBinding(value) && !isString(value)\n\t\t\t\t\t? resolveBrowserJourneyBinding(value, inputs)\n\t\t\t\t\t: value\n\t\t}\n\t\tconst secret = isBrowserSecretBinding(step, parameters)\n\t\tlet action: BrowserAction | undefined\n\t\tlet refusal: string | undefined\n\t\ttry {\n\t\t\tif (step.action === 'dialog' && !interrupted)\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Step ${step.id} answers no interrupted action.`,\n\t\t\t\t\t'BROWSER_JOURNEY_DIALOG',\n\t\t\t\t)\n\t\t\taction = await this.#toolset.follow(\n\t\t\t\tstep.id,\n\t\t\t\t{\n\t\t\t\t\taction: step.action,\n\t\t\t\t\targuments: args,\n\t\t\t\t\t...(step.target === undefined\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\ttarget: {\n\t\t\t\t\t\t\t\t\trole: step.target.role,\n\t\t\t\t\t\t\t\t\tname: resolveBrowserJourneyBinding(step.target.name, inputs),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t...(step.tab === undefined ? {} : { tab: step.tab }),\n\t\t\t\t},\n\t\t\t\t{ ...options, caller, secret },\n\t\t\t)\n\t\t} catch (error) {\n\t\t\trefusal = error instanceof Error ? error.message : String(error)\n\t\t\tif (isBrowserStepError(error)) action = error.action\n\t\t}\n\t\tconst recorded: Record<string, JSONValue> = { ...(action?.arguments ?? args) }\n\t\tif (secret) delete recorded['text']\n\t\treturn {\n\t\t\tid: step.id,\n\t\t\taction: step.action,\n\t\t\ttrigger: deriveBrowserJourneyTrigger(step, inputs),\n\t\t\targuments: recorded,\n\t\t\toutcome: action?.outcome ?? 'refused',\n\t\t\t...(action?.stage === undefined ? {} : { stage: action.stage }),\n\t\t\t...(action?.reason === undefined ? {} : { reason: action.reason }),\n\t\t\tresult: action?.receipt ?? refusal ?? '',\n\t\t\telapsed: action?.elapsed ?? performance.now() - started,\n\t\t}\n\t}\n\n\t#observe(\n\t\toutput: string[],\n\t\tcleanup: Array<() => void>,\n\t\tobserved: Set<EmitterInterface<BrowserViewEventMap>>,\n\t): void {\n\t\tconst view = this.#toolset.view\n\t\tconst emitter = view.emitter\n\t\tif (!view.trusted || emitter === undefined || observed.has(emitter)) return\n\t\tobserved.add(emitter)\n\t\tconst console = this.#collectConsole.bind(this, output)\n\t\tconst error = this.#collectError.bind(this, output)\n\t\temitter.on('console', console)\n\t\temitter.on('error', error)\n\t\tcleanup.push(() => {\n\t\t\temitter.off('console', console)\n\t\t\temitter.off('error', error)\n\t\t})\n\t}\n\n\t#collectConsole(output: string[], message: BrowserConsoleMessage): void {\n\t\toutput.push(message.text)\n\t}\n\n\t#collectError(output: string[], error: BrowserPageError): void {\n\t\toutput.push(error.message)\n\t}\n\n\tasync #capture(\n\t\tslot: BrowserRunSlot,\n\t\tid: string,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<string | undefined> {\n\t\tconst view = this.#toolset.view\n\t\tconst runs = this.#options?.runs\n\t\tif (runs === undefined || !view.trusted || view.screenshot === undefined) return undefined\n\t\tconst screenshot = await view.screenshot()\n\t\treturn runs.capture(slot, `${id}.png`, screenshot.bytes, {\n\t\t\t...(options?.signal === undefined ? {} : { signal: options.signal }),\n\t\t})\n\t}\n\n\tasync #write(run: BrowserRun): Promise<void> {\n\t\tif (this.#options?.runs === undefined) return\n\t\tconst signal = AbortSignal.timeout(1_000)\n\t\tconst deadline = Promise.withResolvers<void>()\n\t\tconst abort = deadline.reject.bind(\n\t\t\tundefined,\n\t\t\tnew BrowserError('Writing the run timed out', 'BROWSER_JOURNEY_FILE'),\n\t\t)\n\t\tsignal.addEventListener('abort', abort, { once: true })\n\t\ttry {\n\t\t\tawait Promise.race([\n\t\t\t\tthis.#options.runs.set(structuredClone(run), { signal }),\n\t\t\t\tdeadline.promise,\n\t\t\t])\n\t\t} finally {\n\t\t\tsignal.removeEventListener('abort', abort)\n\t\t}\n\t}\n}\n","import type {\n\tBrowserJourney,\n\tBrowserJourneyRevision,\n\tBrowserJourneyStoreInterface,\n\tBrowserStoreOptions,\n\tBrowserStorePage,\n} from '../types.js'\nimport { BrowserError } from '../errors.js'\nimport {\n\tvalidateBrowserJourney,\n\tvalidateBrowserJourneyName,\n\tvalidateBrowserStorePage,\n} from '../helpers.js'\n\n/**\n * Keeps owned journey snapshots and revision counters across deletion.\n * @example\n * const store = new MemoryBrowserJourneyStore()\n * await store.set(journey)\n */\nexport class MemoryBrowserJourneyStore implements BrowserJourneyStoreInterface {\n\treadonly #journeys = new Map<string, BrowserJourneyRevision>()\n\treadonly #revisions = new Map<string, number>()\n\n\tasync get(\n\t\tname: string,\n\t\toptions?: BrowserStoreOptions,\n\t): Promise<BrowserJourneyRevision | undefined> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\treturn structuredClone(this.#journeys.get(name))\n\t}\n\n\tasync set(\n\t\tjourney: BrowserJourney,\n\t\texpected?: number,\n\t\toptions?: BrowserStoreOptions,\n\t): Promise<BrowserJourneyRevision> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(journey.name)\n\t\tvalidateBrowserJourney(journey)\n\t\tconst previous = this.#revisions.get(journey.name)\n\t\tif (expected !== undefined && expected !== (this.#journeys.get(journey.name)?.revision ?? 0))\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Journey ${journey.name} changed since you read it`,\n\t\t\t\t'BROWSER_JOURNEY_STALE',\n\t\t\t)\n\t\tconst revision = (previous ?? 0) + 1\n\t\tconst saved = structuredClone({ journey, revision })\n\t\tthis.#journeys.set(journey.name, saved)\n\t\tthis.#revisions.set(journey.name, revision)\n\t\treturn structuredClone(saved)\n\t}\n\n\tasync delete(name: string, options?: BrowserStoreOptions): Promise<void> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\tthis.#journeys.delete(name)\n\t}\n\n\tasync list(\n\t\toptions?: BrowserStoreOptions & { readonly offset?: number; readonly limit?: number },\n\t): Promise<BrowserStorePage<BrowserJourneyRevision>> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst entries = [...this.#journeys.entries()]\n\t\t\t.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n\t\t\t.map(([, revision]) => revision)\n\t\tconst offset = options?.offset ?? 0\n\t\tconst limit = options?.limit ?? Math.max(1, entries.length)\n\t\tvalidateBrowserStorePage(offset, limit)\n\t\treturn {\n\t\t\tentries: structuredClone(entries.slice(offset, offset + limit)),\n\t\t\ttruncated: offset + limit < entries.length,\n\t\t\tfaults: [],\n\t\t}\n\t}\n}\n","import type {\n\tBrowserRun,\n\tBrowserRunSlot,\n\tBrowserRunStoreInterface,\n\tBrowserStoreOptions,\n\tBrowserStorePage,\n} from '../types.js'\nimport { BrowserError } from '../errors.js'\nimport {\n\tgenerateBrowserRunId,\n\tvalidateBrowserRun,\n\tvalidateBrowserJourneyName,\n\tvalidateBrowserStorePage,\n} from '../helpers.js'\n\n/**\n * Keeps owned runs under their journey names and producer ids without directories.\n * @example\n * const store = new MemoryBrowserRunStore()\n * const slot = await store.open('add-kettle')\n */\nexport class MemoryBrowserRunStore implements BrowserRunStoreInterface {\n\treadonly #runs = new Map<string, Map<string, BrowserRun>>()\n\treadonly #slots = new Map<string, Set<string>>()\n\treadonly #opened = new WeakMap<BrowserRunSlot, string>()\n\n\tasync open(name: string, options?: BrowserStoreOptions): Promise<BrowserRunSlot> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\tconst slots = this.#slots.get(name) ?? new Set<string>()\n\t\tlet id = generateBrowserRunId()\n\t\twhile (slots.has(id) || this.#runs.get(name)?.has(id)) id = generateBrowserRunId()\n\t\tslots.add(id)\n\t\tthis.#slots.set(name, slots)\n\t\tconst slot = { id }\n\t\tthis.#opened.set(slot, name)\n\t\treturn slot\n\t}\n\n\tasync get(\n\t\tname: string,\n\t\tid: string,\n\t\toptions?: BrowserStoreOptions,\n\t): Promise<BrowserRun | undefined> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\treturn structuredClone(this.#runs.get(name)?.get(id))\n\t}\n\n\tasync set(run: BrowserRun, options?: BrowserStoreOptions): Promise<void> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserRun(run)\n\t\tif (!this.#slots.get(run.journey.name)?.has(run.id))\n\t\t\tthrow new BrowserError('The run was not opened by this store', 'BROWSER_JOURNEY_PATH')\n\t\tconst runs = this.#runs.get(run.journey.name) ?? new Map<string, BrowserRun>()\n\t\truns.set(run.id, structuredClone(run))\n\t\tthis.#runs.set(run.journey.name, runs)\n\t}\n\n\tasync capture(\n\t\tslot: BrowserRunSlot,\n\t\t_name: string,\n\t\t_bytes: Uint8Array,\n\t\toptions?: BrowserStoreOptions,\n\t): Promise<string | undefined> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst journey = this.#opened.get(slot)\n\t\tif (journey === undefined || !this.#slots.get(journey)?.has(slot.id))\n\t\t\tthrow new BrowserError('The run slot was not opened by this store', 'BROWSER_JOURNEY_PATH')\n\t\t// Memory stores own slots but have no directory in which to persist these bytes.\n\t\treturn undefined\n\t}\n\n\tasync delete(name: string, id: string, options?: BrowserStoreOptions): Promise<void> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\tthis.#runs.get(name)?.delete(id)\n\t\tthis.#slots.get(name)?.delete(id)\n\t}\n\n\tasync clear(name: string, options?: BrowserStoreOptions): Promise<number> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\tconst count = this.#slots.get(name)?.size ?? 0\n\t\tthis.#runs.delete(name)\n\t\tthis.#slots.delete(name)\n\t\treturn count\n\t}\n\n\tasync list(\n\t\tname: string,\n\t\toptions?: BrowserStoreOptions & { readonly offset?: number; readonly limit?: number },\n\t): Promise<BrowserStorePage<BrowserRun>> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\tconst entries = [...(this.#runs.get(name)?.values() ?? [])].sort((left, right) =>\n\t\t\tleft.id < right.id ? -1 : left.id > right.id ? 1 : 0,\n\t\t)\n\t\tconst offset = options?.offset ?? 0\n\t\tconst limit = options?.limit ?? Math.max(1, entries.length)\n\t\tvalidateBrowserStorePage(offset, limit)\n\t\treturn {\n\t\t\tentries: structuredClone(entries.slice(offset, offset + limit)),\n\t\t\ttruncated: offset + limit < entries.length,\n\t\t\tfaults: [],\n\t\t}\n\t}\n}\n","import type {\n\tBrowserJourneyRevision,\n\tBrowserJourneyStoreInterface,\n\tBrowserRecorderInterface,\n\tBrowserRecorderOptions,\n\tBrowserReplayInterface,\n\tBrowserReplayOptions,\n\tBrowserRunStoreInterface,\n\tBrowserPageInterface,\n\tBrowserReadingInput,\n\tBrowserReadingInterface,\n\tBrowserSnapshotInput,\n\tBrowserSnapshotInterface,\n\tBrowserToolsetInterface,\n\tBrowserToolsetOptions,\n\tCDPClientInterface,\n\tCDPClientOptions,\n} from './types.js'\nimport { BrowserRecorder } from './recorders/BrowserRecorder.js'\nimport { BrowserReplay } from './BrowserReplay.js'\nimport { MemoryBrowserJourneyStore } from './stores/MemoryBrowserJourneyStore.js'\nimport { MemoryBrowserRunStore } from './stores/MemoryBrowserRunStore.js'\nimport { BrowserReading } from './BrowserReading.js'\nimport { BrowserSnapshot } from './BrowserSnapshot.js'\nimport { BrowserToolset } from './BrowserToolset.js'\nimport { CDPClient } from './CDPClient.js'\n/**\n * Creates a `CDPClientInterface` bound to the given `CDPTransportInterface`.\n *\n * @param options - The transport (and optional timeout) the client uses\n * @returns A {@link CDPClientInterface}\n *\n * @example\n * ```ts\n * import { createCDPClient } from '@orkestrel/browser'\n *\n * const client = createCDPClient({ transport })\n * await client.connect()\n * ```\n */\nexport function createCDPClient(options: CDPClientOptions): CDPClientInterface {\n\treturn new CDPClient(options)\n}\n\n/**\n * Creates a navigable `BrowserSnapshotInterface` over decoded `BrowserSnapshotInput` data.\n *\n * @param input - Captured documents and computed-style names\n * @returns A {@link BrowserSnapshotInterface}\n *\n * @example\n * ```ts\n * import { createBrowserSnapshot, readBrowserSnapshot } from '@orkestrel/browser'\n *\n * const snapshot = createBrowserSnapshot(readBrowserSnapshot(captured, ['display']))\n * snapshot.find({ name: 'main' })\n * ```\n */\nexport function createBrowserSnapshot(input: BrowserSnapshotInput): BrowserSnapshotInterface {\n\treturn new BrowserSnapshot(input)\n}\n\n/**\n * Creates a `BrowserReadingInterface` over a captured document, parsing its HTML one time.\n *\n * @remarks\n * A reading built with a `navigation` source reports `stale` when that source's epoch differs\n * from the `epoch` recorded at capture; a reading built without one never does.\n *\n * @param input - The document URL, title, and HTML, and the optional navigation epoch\n * @returns A {@link BrowserReadingInterface}\n *\n * @example\n * ```ts\n * import { createBrowserReading } from '@orkestrel/browser'\n *\n * const reading = createBrowserReading({\n * \turl: 'https://example.com/',\n * \ttitle: 'Example',\n * \thtml: '<nav>Menu</nav><main><p>Body</p></main>',\n * })\n * reading.text({ distill: false }) // { text: 'Menu\\nBody', offset: 0, total: 9 }\n * ```\n */\nexport function createBrowserReading(input: BrowserReadingInput): BrowserReadingInterface {\n\treturn new BrowserReading(input)\n}\n\n/**\n * Creates a `BrowserToolsetInterface` that publishes the browser vocabulary over one page into a\n * `@orkestrel/tool` manager.\n *\n * @remarks\n * The page is both the toolset's view and its `page` option, so the toolset advertises the seven\n * CDP tools. It registers its tools during `start()`: the generic tools first, then the page\n * tools as their adoption resolves. Its options are described on {@link BrowserToolsetOptions};\n * hand `toolset.tools` to an agent, and publish `toolset.native` to a built-in browser agent.\n *\n * @param page - The page the tools act on first\n * @param options - The manager, page-tool source, context, bound, and schemes; `page` is replaced\n * by the page argument\n * @returns A {@link BrowserToolsetInterface}\n *\n * @example\n * ```ts\n * import { createBrowserToolset } from '@orkestrel/browser'\n *\n * const toolset = createBrowserToolset(page, { context })\n * await toolset.start()\n * const result = await toolset.tools.execute({ id: '1', name: 'look', arguments: { what: 'cart' } })\n * ```\n *\n * @example Drive a page with a small model\n * ```ts\n * import { createAgent } from '@orkestrel/agent'\n * import { createBrowserToolset } from '@orkestrel/browser'\n * import { createBrowser } from '@orkestrel/browser/server'\n * import { createOllama } from '@orkestrel/ollama'\n * import { createToolManager } from '@orkestrel/tool'\n *\n * const system =\n * \t'You control a web browser with tools and must call a tool before you answer. ' +\n * \t'The first message shows the page as look returns it; references such as e4 name its elements. ' +\n * \t'To learn a fact, call read with what set to your question; when its result ends by naming an offset, call read again with that offset. ' +\n * \t'To search, call type with the search box reference, the words, and submit true. ' +\n * \t'To press a button or follow a link, call click with its reference from the latest result. Never invent a reference. ' +\n * \t'If text you expect has not appeared, call wait once. ' +\n * \t'When the task is done, answer in one short sentence.'\n *\n * const browser = createBrowser({ headless: true })\n * await browser.connect()\n * const page = await browser.create({ url: 'https://shop.example.test/' })\n * const toolset = createBrowserToolset(page, { tools: createToolManager() })\n * await toolset.start()\n * toolset.tools.tools().map((tool) => tool.name) // ['look', 'read', 'click', 'type', 'press', 'navigate', 'wait']\n * const seeded = await toolset.tools.execute({\n * \tid: 'seed',\n * \tname: 'look',\n * \targuments: { what: 'the page' },\n * })\n * const view = seeded.success ? String(seeded.value) : seeded.error\n * const agent = createAgent(createOllama({ model: 'qwen3.5:2b-q4_K_M' }), {\n * \tsystem,\n * \ttools: toolset.tools,\n * })\n * agent.context.messages.add({\n * \trole: 'user',\n * \tcontent: `What does the Alpine Kettle cost?\\n\\nThe browser shows this page:\\n${view}`,\n * })\n * const result = await agent.generate()\n * await toolset.destroy()\n * await browser.destroy()\n * ```\n */\nexport function createBrowserToolset(\n\tpage: BrowserPageInterface,\n\toptions?: BrowserToolsetOptions,\n): BrowserToolsetInterface {\n\treturn new BrowserToolset(page, { ...options, page })\n}\n\n/**\n * Creates a recorder over toolset actions.\n * @param toolset - The recording source\n * @param options - Event hooks and observer error handling\n * @returns The recorder\n * @example\n * const recorder = createBrowserRecorder(toolset)\n * await recorder.start()\n */\nexport function createBrowserRecorder(\n\ttoolset: BrowserToolsetInterface,\n\toptions?: BrowserRecorderOptions,\n): BrowserRecorderInterface {\n\treturn new BrowserRecorder(toolset, options)\n}\n\n/**\n * Creates a replay of one journey revision.\n * @param toolset - The toolset that performs the steps\n * @param revision - The journey and optional stored revision\n * @param options - Inputs, run store, and event hooks\n * @returns The replay\n * @example\n * const run = await createBrowserReplay(toolset, { journey }).execute()\n */\nexport function createBrowserReplay(\n\ttoolset: BrowserToolsetInterface,\n\trevision: BrowserJourneyRevision,\n\toptions?: BrowserReplayOptions,\n): BrowserReplayInterface {\n\treturn new BrowserReplay(toolset, revision, options)\n}\n\n/**\n * Creates an in-memory journey store with persistent revision counters.\n * @returns The store\n * @example\n * const store = createMemoryBrowserJourneyStore()\n * await store.set(journey)\n */\nexport function createMemoryBrowserJourneyStore(): BrowserJourneyStoreInterface {\n\treturn new MemoryBrowserJourneyStore()\n}\n\n/**\n * Creates an in-memory run store without capture directories.\n * @returns The store\n * @example\n * const runs = createMemoryBrowserRunStore()\n * await runs.set(run)\n */\nexport function createMemoryBrowserRunStore(): BrowserRunStoreInterface {\n\treturn new MemoryBrowserRunStore()\n}\n","import type {\n\tBrowserJourney,\n\tBrowserJourneyEdit,\n\tBrowserJourneyOptions,\n\tBrowserJourneyRevision,\n\tBrowserJourneyStoreInterface,\n\tBrowserJourneyTarget,\n\tBrowserJourneyToolsetInterface,\n\tBrowserRecorderInterface,\n\tBrowserRun,\n\tBrowserRunStoreInterface,\n\tBrowserToolName,\n\tBrowserToolsetInterface,\n} from './types.js'\nimport type { ToolContext, ToolInterface } from '@orkestrel/tool'\nimport { attempt, isArray, isInteger, isRecord, isString } from '@orkestrel/contract'\nimport { createTool } from '@orkestrel/tool'\nimport {\n\tBROWSER_JOURNEY_EMPTY_LISTING,\n\tBROWSER_JOURNEY_IDLE_REFUSAL,\n\tBROWSER_JOURNEY_NAME_PATTERN,\n\tBROWSER_JOURNEY_READONLY_REFUSAL,\n\tBROWSER_JOURNEY_RECORDING_REFUSAL,\n\tBROWSER_JOURNEY_TOOL_NAMES,\n\tBROWSER_TOOL_COPY,\n} from './constants.js'\nimport { BrowserElementError, BrowserError, isBrowserError } from './errors.js'\nimport { createBrowserRecorder, createBrowserReplay } from './factories.js'\nimport {\n\teditBrowserJourney,\n\treadBrowserToolString,\n\trenderBrowserJourney,\n\trenderBrowserRun,\n\tnormalizeBrowserJourneyReason,\n\trenderBrowserJourneyFault,\n\trequireBrowserReference,\n\tvalidateBrowserToolArguments,\n\tvalidateBrowserJourneyEdit,\n} from './helpers.js'\n\n/**\n * Registers the journey tools `record`, `save`, `journeys`, `edit`, `replay`, and `forget` over a toolset\n * and owns the recording and the active replay.\n *\n * @remarks\n * The journey toolset composes the toolset's public members: `perform` reads the view a receipt\n * carries through `look`, `hold` and `emitter` drive the recorder and the replay, `view` converts\n * an edit's `ref` to a target, and `tools` receives the six tools at construction, which refuses\n * with `BROWSER_TOOLSET_RESERVED` when the manager already holds one of the names. Every refusal\n * is a sentence that names the next call, and a reason inside it is a clause without a directive\n * or a final period.\n *\n * `readonly` refuses `record`, `save`, `edit`, and `forget` before any store access; `replay` still writes\n * its run. The call's signal reaches every store call and every replayed step, and `destroy()`\n * aborts it as well. `save` writes a snapshot before it ends the recording, so a failed or\n * locked write keeps the recorder recording with its steps for the next\n * `save`. An empty snapshot refuses with `BROWSER_JOURNEY_EMPTY` and keeps recording.\n * `edit` accepts an array or its JSON string and names a parse error when the string is invalid.\n * `journeys` joins the listings with one blank line and cuts the result at `limit`\n * characters with a footer that names the next offset. `replay` returns the run's render followed\n * by the view after the run.\n *\n * `destroy()` aborts the active replay and waits for it to finish, stops a recording without\n * saving it, and removes the six tools the manager still holds under the instances it added.\n *\n * @example\n * ```ts\n * import { BrowserJourneyToolset, createMemoryBrowserJourneyStore } from '@orkestrel/browser'\n *\n * const journeys = new BrowserJourneyToolset(toolset, { store: createMemoryBrowserJourneyStore() })\n * await toolset.tools.execute({ id: '1', name: 'record', arguments: { journey: 'add-kettle' } })\n * await journeys.destroy()\n * ```\n */\nexport class BrowserJourneyToolset implements BrowserJourneyToolsetInterface {\n\treadonly #toolset: BrowserToolsetInterface\n\treadonly #store: BrowserJourneyStoreInterface\n\treadonly #runs: BrowserRunStoreInterface | undefined\n\treadonly #readonly: boolean\n\treadonly #limit: number\n\treadonly #lifetime = new AbortController()\n\treadonly #tools: readonly ToolInterface[]\n\t#recorder: BrowserRecorderInterface | undefined\n\t#recording: string | undefined\n\t#saved: string | undefined\n\t#replaying: string | undefined\n\t#replay: Promise<void> | undefined\n\t#destroying: Promise<void> | undefined\n\n\tconstructor(toolset: BrowserToolsetInterface, options: BrowserJourneyOptions) {\n\t\tconst limit = options.limit ?? toolset.limit\n\t\tif (!Number.isSafeInteger(limit) || limit < 1) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The journeys limit must be a positive integer',\n\t\t\t\t'BROWSER_JOURNEY_ARGUMENT',\n\t\t\t\t{\n\t\t\t\t\tlimit,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst held = BROWSER_JOURNEY_TOOL_NAMES.find((name) => toolset.tools.tool(name) !== undefined)\n\t\tif (held !== undefined) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The tool manager already holds a tool named ${held}, a name the browser toolset reserves`,\n\t\t\t\t'BROWSER_TOOLSET_RESERVED',\n\t\t\t\t{ name: held },\n\t\t\t)\n\t\t}\n\t\tthis.#toolset = toolset\n\t\tthis.#store = options.store\n\t\tthis.#runs = options.runs\n\t\tthis.#readonly = options.readonly === true\n\t\tthis.#limit = limit\n\t\tthis.#tools = Object.freeze([\n\t\t\tthis.#create('record', this.#record.bind(this)),\n\t\t\tthis.#create('save', this.#save.bind(this)),\n\t\t\tthis.#create('journeys', this.#journeys.bind(this)),\n\t\t\tthis.#create('edit', this.#edit.bind(this)),\n\t\t\tthis.#create('replay', this.#replayJourney.bind(this)),\n\t\t\tthis.#create('forget', this.#forget.bind(this)),\n\t\t])\n\t\ttoolset.tools.add(this.#tools)\n\t}\n\n\tget recording(): string | undefined {\n\t\treturn this.#recording\n\t}\n\n\tget replaying(): string | undefined {\n\t\treturn this.#replaying\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tthis.#destroying ??= this.#teardown()\n\t\treturn this.#destroying\n\t}\n\n\t#create(\n\t\tname: BrowserToolName,\n\t\thandler: (args: Readonly<Record<string, unknown>>, signal: AbortSignal) => Promise<string>,\n\t): ToolInterface {\n\t\treturn createTool({\n\t\t\t...BROWSER_TOOL_COPY[name],\n\t\t\texecute: this.#execute.bind(this, name, handler),\n\t\t})\n\t}\n\n\t// The one boundary every journey tool runs through: the lifecycle check, the advertised\n\t// parameters, and a signal that `destroy()` also aborts.\n\tasync #execute(\n\t\tname: BrowserToolName,\n\t\thandler: (args: Readonly<Record<string, unknown>>, signal: AbortSignal) => Promise<string>,\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<string> {\n\t\tif (this.#destroying !== undefined) throw this.#ended()\n\t\tvalidateBrowserToolArguments(BROWSER_TOOL_COPY[name], args)\n\t\tconst signal = AbortSignal.any([context.signal, this.#lifetime.signal])\n\t\tsignal.throwIfAborted()\n\t\treturn handler(args, signal)\n\t}\n\n\tasync #record(args: Readonly<Record<string, unknown>>, signal: AbortSignal): Promise<string> {\n\t\tif (this.#readonly)\n\t\t\tthrow new BrowserError(BROWSER_JOURNEY_READONLY_REFUSAL, 'BROWSER_JOURNEY_READONLY')\n\t\tthis.#idleReplay()\n\t\tconst name = readBrowserToolString(args, 'journey')\n\t\tif (this.#recording !== undefined)\n\t\t\tthrow new BrowserError(BROWSER_JOURNEY_RECORDING_REFUSAL, 'BROWSER_JOURNEY_RECORDING')\n\t\tif (!BROWSER_JOURNEY_NAME_PATTERN.test(name)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`${JSON.stringify(name)} is not a journey name; use lowercase words joined by hyphens, such as add-kettle.`,\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'journey' },\n\t\t\t)\n\t\t}\n\t\tthis.#recording = name\n\t\tlet recorder: BrowserRecorderInterface | undefined\n\t\ttry {\n\t\t\tif ((await this.#read(name, signal)) !== undefined) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Journey ${JSON.stringify(name)} is saved already; do not call record for it again. Call journeys to list it, edit to change it, or replay to run it, or answer the user.`,\n\t\t\t\t\t'BROWSER_JOURNEY_SAVED',\n\t\t\t\t\t{ name },\n\t\t\t\t)\n\t\t\t}\n\t\t\tthis.#idleReplay()\n\t\t\tsignal.throwIfAborted()\n\t\t\tif (this.#destroying !== undefined) throw this.#ended()\n\t\t\trecorder = createBrowserRecorder(this.#toolset)\n\t\t\tawait recorder.start()\n\t\t\tsignal.throwIfAborted()\n\t\t\tif (this.#destroying !== undefined) throw this.#ended()\n\t\t\tthis.#recorder = recorder\n\t\t} catch (error) {\n\t\t\tthis.#recording = undefined\n\t\t\tawait recorder?.destroy()\n\t\t\tthrow error\n\t\t}\n\t\treturn `Recording ${name}; each action you take is a step; call save when it is done.\\n\\n${await this.#view(signal)}`\n\t}\n\n\tasync #save(args: Readonly<Record<string, unknown>>, signal: AbortSignal): Promise<string> {\n\t\tif (this.#readonly)\n\t\t\tthrow new BrowserError(BROWSER_JOURNEY_READONLY_REFUSAL, 'BROWSER_JOURNEY_READONLY')\n\t\tconst description = readBrowserToolString(args, 'description')\n\t\tconst recorder = this.#recorder\n\t\tconst name = this.#recording\n\t\tif (recorder === undefined || name === undefined)\n\t\t\tthrow new BrowserError(\n\t\t\t\tthis.#saved === undefined\n\t\t\t\t\t? BROWSER_JOURNEY_IDLE_REFUSAL\n\t\t\t\t\t: `Nothing is recording; ${JSON.stringify(this.#saved)} was saved. Call journeys, edit, or replay.`,\n\t\t\t\t'BROWSER_JOURNEY_RECORDING',\n\t\t\t)\n\t\tconst snapshot = attempt(() => recorder.journey({ name, description }))\n\t\tif (!snapshot.success) {\n\t\t\tif (\n\t\t\t\tisBrowserError(snapshot.error) &&\n\t\t\t\tsnapshot.error.code === 'BROWSER_JOURNEY_INVALID' &&\n\t\t\t\tsnapshot.error.context?.['field'] === 'steps'\n\t\t\t)\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Nothing is recorded for ${name}: the actions before record are not steps. Perform the flow's actions and call save, or answer the user when the task is done.`,\n\t\t\t\t\t'BROWSER_JOURNEY_EMPTY',\n\t\t\t\t\t{ name },\n\t\t\t\t)\n\t\t\tthrow snapshot.error\n\t\t}\n\t\tlet saved: BrowserJourneyRevision\n\t\ttry {\n\t\t\tsaved = await this.#store.set(snapshot.value, 0, { signal })\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) throw error\n\t\t\tif (isBrowserError(error) && error.code === 'BROWSER_JOURNEY_STALE')\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`A journey named \"${name}\" is saved; call journeys, or record another name.`,\n\t\t\t\t\terror.code,\n\t\t\t\t\t{ name },\n\t\t\t\t)\n\t\t\tif (isBrowserError(error) && error.code === 'BROWSER_JOURNEY_LOCKED')\n\t\t\t\tthrow new BrowserError(`Journey ${name} is locked; call save again.`, error.code, { name })\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Saving ${name} failed: ${normalizeBrowserJourneyReason(error)}; call save again.`,\n\t\t\t\tisBrowserError(error) ? error.code : 'BROWSER_JOURNEY_FILE',\n\t\t\t\t{ name },\n\t\t\t)\n\t\t}\n\t\tthis.#saved = name\n\t\tif (this.#recorder === recorder) {\n\t\t\tthis.#recorder = undefined\n\t\t\tthis.#recording = undefined\n\t\t}\n\t\tawait recorder.destroy()\n\t\tconst count = saved.journey.steps.length\n\t\treturn `Saved ${name} with ${count} ${count === 1 ? 'step' : 'steps'}.\\n\\n${renderBrowserJourney(saved.journey)}`\n\t}\n\n\tasync #journeys(args: Readonly<Record<string, unknown>>, signal: AbortSignal): Promise<string> {\n\t\tconst offset = args['offset'] ?? 0\n\t\tif (!isInteger(offset) || offset < 0) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The offset parameter must be a non-negative integer.',\n\t\t\t\t'BROWSER_JOURNEY_ARGUMENT',\n\t\t\t\t{ key: 'offset' },\n\t\t\t)\n\t\t}\n\t\tconst listings: string[] = []\n\t\tconst faults = new Set<string>()\n\t\tlet position = 0\n\t\tfor (;;) {\n\t\t\tconst page = await this.#store.list({ signal, offset: position })\n\t\t\tlistings.push(...page.entries.map((entry) => renderBrowserJourney(entry.journey)))\n\t\t\t// File stores can report the same unreadable path on successive pages.\n\t\t\tfor (const fault of page.faults) {\n\t\t\t\tif (faults.has(fault.name)) continue\n\t\t\t\tfaults.add(fault.name)\n\t\t\t\tlistings.push(renderBrowserJourneyFault(fault))\n\t\t\t}\n\t\t\tconst span = page.entries.length\n\t\t\tposition += span\n\t\t\tif (!page.truncated || span === 0) break\n\t\t}\n\t\tif (listings.length === 0) return BROWSER_JOURNEY_EMPTY_LISTING\n\t\tconst listing = listings.join('\\n\\n')\n\t\tconst start = offset < listing.length ? offset : 0\n\t\tlet end = Math.min(listing.length, start + this.#limit)\n\t\tconst last = listing.charCodeAt(end - 1)\n\t\tif (end < listing.length && last >= 0xd800 && last <= 0xdbff) end -= 1\n\t\t// A limit that cannot hold the next code point would never advance the continuation.\n\t\tif (end === start) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The journeys limit of ${this.#limit} characters cannot hold the next character at offset ${start}; raise the journeys limit.`,\n\t\t\t\t'BROWSER_TOOLSET_LIMIT',\n\t\t\t\t{ limit: this.#limit, offset: start },\n\t\t\t)\n\t\t}\n\t\tconst text = listing.slice(start, end)\n\t\tif (start === 0 && end === listing.length) return text\n\t\treturn `${text}\\n\\n[characters ${start}–${end} of ${listing.length}${end < listing.length ? `; call journeys with offset ${end} for more` : ''}]`\n\t}\n\n\tasync #edit(args: Readonly<Record<string, unknown>>, signal: AbortSignal): Promise<string> {\n\t\tif (this.#readonly)\n\t\t\tthrow new BrowserError(BROWSER_JOURNEY_READONLY_REFUSAL, 'BROWSER_JOURNEY_READONLY')\n\t\tconst name = readBrowserToolString(args, 'journey')\n\t\tlet requests = args['edits']\n\t\tif (isString(requests)) {\n\t\t\tconst text = requests\n\t\t\tconst parsed = attempt<unknown>(() => JSON.parse(text))\n\t\t\tif (!parsed.success)\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`The edits parameter is not valid JSON: ${normalizeBrowserJourneyReason(parsed.error)}; pass an array or a JSON string of the array.`,\n\t\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t\t{ key: 'edits' },\n\t\t\t\t)\n\t\t\trequests = parsed.value\n\t\t}\n\t\tif (!isArray(requests)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The edits parameter must be an array or a JSON string of the array.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{\n\t\t\t\t\tkey: 'edits',\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst revision = await this.#find(name, signal)\n\t\tconst edits = requests.map((request, index) => this.#convert(request, index + 1))\n\t\tlet edited: BrowserJourney\n\t\ttry {\n\t\t\tedited = editBrowserJourney(revision.journey, edits)\n\t\t} catch (error) {\n\t\t\tif (!isBrowserError(error) || error.code !== 'BROWSER_JOURNEY_EDIT') throw error\n\t\t\tthrow new BrowserError(`${error.message}; call journeys.`, error.code, error.context)\n\t\t}\n\t\tlet saved: BrowserJourneyRevision\n\t\ttry {\n\t\t\tsaved = await this.#store.set(edited, revision.revision, { signal })\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) throw error\n\t\t\tconst code = isBrowserError(error) ? error.code : 'BROWSER_JOURNEY_FILE'\n\t\t\tif (code === 'BROWSER_JOURNEY_STALE')\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Journey ${name} changed since you read it; call journeys, then edit again.`,\n\t\t\t\t\tcode,\n\t\t\t\t\t{ name },\n\t\t\t\t)\n\t\t\tif (code === 'BROWSER_JOURNEY_LOCKED')\n\t\t\t\tthrow new BrowserError(`Journey ${name} is locked; call edit again.`, code, { name })\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Editing ${name} failed: ${normalizeBrowserJourneyReason(error)}; call edit again.`,\n\t\t\t\tcode,\n\t\t\t\t{ name },\n\t\t\t)\n\t\t}\n\t\treturn `Edited ${name}.\\n\\n${renderBrowserJourney(saved.journey)}`\n\t}\n\n\tasync #forget(args: Readonly<Record<string, unknown>>, signal: AbortSignal): Promise<string> {\n\t\tif (this.#readonly)\n\t\t\tthrow new BrowserError(BROWSER_JOURNEY_READONLY_REFUSAL, 'BROWSER_JOURNEY_READONLY')\n\t\tthis.#idleReplay()\n\t\tconst name = readBrowserToolString(args, 'journey')\n\t\tif (this.#recording === name)\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Journey ${JSON.stringify(name)} is recording; call save first, or record another name.`,\n\t\t\t\t'BROWSER_JOURNEY_RECORDING',\n\t\t\t\t{ name },\n\t\t\t)\n\t\tawait this.#find(name, signal)\n\t\tthis.#idleReplay()\n\t\tlet count: number\n\t\ttry {\n\t\t\t// Remove runs first so a failed removal leaves the saved name available for a retry.\n\t\t\tcount = (await this.#runs?.clear(name, { signal })) ?? 0\n\t\t\tawait this.#store.delete(name, { signal })\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) throw error\n\t\t\tconst code = isBrowserError(error) ? error.code : 'BROWSER_JOURNEY_FILE'\n\t\t\tif (code === 'BROWSER_JOURNEY_LOCKED')\n\t\t\t\tthrow new BrowserError(`Journey ${name} is locked; call forget again.`, code, { name })\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Forgetting ${name} failed: ${normalizeBrowserJourneyReason(error)}; call forget again.`,\n\t\t\t\tcode,\n\t\t\t\t{ name },\n\t\t\t)\n\t\t}\n\t\tif (this.#saved === name) this.#saved = undefined\n\t\treturn `Forgot ${name} and its ${count} ${count === 1 ? 'run' : 'runs'}; the name is free to record again.`\n\t}\n\n\tasync #replayJourney(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tsignal: AbortSignal,\n\t): Promise<string> {\n\t\tconst name = readBrowserToolString(args, 'journey')\n\t\tconst inputs: Record<string, string> = {}\n\t\tconst given = args['inputs'] ?? {}\n\t\tif (!isRecord(given) || !Object.values(given).every(isString)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The inputs parameter must be an object of strings.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'inputs' },\n\t\t\t)\n\t\t}\n\t\tfor (const [key, value] of Object.entries(given)) if (isString(value)) inputs[key] = value\n\t\tif (this.#recording !== undefined) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Journey ${this.#recording} is recording; call save before you replay another.`,\n\t\t\t\t'BROWSER_JOURNEY_RECORDING',\n\t\t\t\t{ name: this.#recording },\n\t\t\t)\n\t\t}\n\t\tthis.#idleReplay()\n\t\t// The replay claims the toolset before its first await, so a second `replay` is refused\n\t\t// rather than queued behind it.\n\t\tthis.#replaying = name\n\t\tconst finished = Promise.withResolvers<void>()\n\t\tthis.#replay = finished.promise\n\t\ttry {\n\t\t\tconst revision = await this.#find(name, signal)\n\t\t\tlet run: BrowserRun\n\t\t\ttry {\n\t\t\t\trun = await createBrowserReplay(this.#toolset, revision, {\n\t\t\t\t\tinputs,\n\t\t\t\t\t...(this.#runs === undefined ? {} : { runs: this.#runs }),\n\t\t\t\t}).execute({ signal })\n\t\t\t} catch (error) {\n\t\t\t\tthrow this.#prepared(error, revision.journey)\n\t\t\t}\n\t\t\treturn renderBrowserRun(run, signal.aborted ? undefined : await this.#view(signal))\n\t\t} finally {\n\t\t\tthis.#replaying = undefined\n\t\t\tthis.#replay = undefined\n\t\t\tfinished.resolve()\n\t\t}\n\t}\n\n\t// Maps a preparation refusal to its sentence; any other failure keeps its own message.\n\t#prepared(error: unknown, journey: BrowserJourney): unknown {\n\t\tif (!isBrowserError(error)) return error\n\t\tconst name = journey.name\n\t\tswitch (error.code) {\n\t\t\tcase 'BROWSER_JOURNEY_INPUT': {\n\t\t\t\tconst parameter = error.context?.['parameter']\n\t\t\t\tif (!isString(parameter)) return error\n\t\t\t\tif (!Object.hasOwn(journey.parameters, parameter))\n\t\t\t\t\treturn new BrowserError(\n\t\t\t\t\t\t`Journey ${name} has no parameter named ${JSON.stringify(parameter)}; call journeys.`,\n\t\t\t\t\t\terror.code,\n\t\t\t\t\t\terror.context,\n\t\t\t\t\t)\n\t\t\t\treturn new BrowserError(\n\t\t\t\t\t`Journey ${name} needs the input ${JSON.stringify(parameter)}; call replay with inputs.`,\n\t\t\t\t\terror.code,\n\t\t\t\t\terror.context,\n\t\t\t\t)\n\t\t\t}\n\t\t\tcase 'BROWSER_JOURNEY_GAP': {\n\t\t\t\tconst step = journey.steps.find((candidate) => candidate.id === error.context?.['step'])\n\t\t\t\tif (step === undefined) return error\n\t\t\t\treturn new BrowserError(\n\t\t\t\t\t`Journey ${name} has a gap at ${step.id} (${step.gap}); call edit to remove or replace ${step.id}.`,\n\t\t\t\t\terror.code,\n\t\t\t\t\terror.context,\n\t\t\t\t)\n\t\t\t}\n\t\t\tcase 'BROWSER_JOURNEY_PLACEMENT': {\n\t\t\t\tconst id = error.context?.['step']\n\t\t\t\tconst action = error.context?.['action']\n\t\t\t\tconst placement = error.context?.['placement']\n\t\t\t\tif (!isString(id) || !isString(action) || !isString(placement)) return error\n\t\t\t\treturn new BrowserError(\n\t\t\t\t\taction === 'switch'\n\t\t\t\t\t\t? `Journey ${name} cannot run here: ${id} switch needs a browser context; call journeys.`\n\t\t\t\t\t\t: `Journey ${name} cannot run here: ${id} ${action} is not available in a ${placement === 'dom' ? 'page' : 'browser'} toolset; call journeys.`,\n\t\t\t\t\terror.code,\n\t\t\t\t\terror.context,\n\t\t\t\t)\n\t\t\t}\n\t\t\tcase 'BROWSER_JOURNEY_FORMAT':\n\t\t\tcase 'BROWSER_JOURNEY_INVALID':\n\t\t\t\treturn new BrowserError(\n\t\t\t\t\t`Journey ${name} cannot be read: ${normalizeBrowserJourneyReason(error)}; call journeys.`,\n\t\t\t\t\terror.code,\n\t\t\t\t\terror.context,\n\t\t\t\t)\n\t\t\tdefault:\n\t\t\t\treturn error\n\t\t}\n\t}\n\n\t// Converts a wire edit's `ref` to a target from the current view, then checks the edit's own\n\t// shape, so the pure editor receives a typed batch.\n\t#convert(request: unknown, index: number): BrowserJourneyEdit {\n\t\tlet edit = request\n\t\tif (isRecord(request) && request['operation'] === 'add' && isRecord(request['step'])) {\n\t\t\tconst { ref, ...step } = request['step']\n\t\t\tif (ref !== undefined) edit = { ...request, step: { ...step, target: this.#target(ref) } }\n\t\t} else if (isRecord(request) && request['operation'] === 'update') {\n\t\t\tconst { ref, ...update } = request\n\t\t\tif (ref !== undefined) edit = { ...update, target: this.#target(ref) }\n\t\t}\n\t\ttry {\n\t\t\tvalidateBrowserJourneyEdit(edit)\n\t\t} catch (error) {\n\t\t\tconst reason = normalizeBrowserJourneyReason(error)\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Edit ${index} is refused: ${reason.startsWith('its ') ? reason : `it ${reason}`}; call journeys.`,\n\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t\t{ index, reason },\n\t\t\t)\n\t\t}\n\t\treturn edit\n\t}\n\n\t#target(ref: unknown): BrowserJourneyTarget {\n\t\tconst reference = requireBrowserReference(ref)\n\t\tconst element = this.#toolset.view.elements.element(reference)\n\t\tif (element === undefined)\n\t\t\tthrow new BrowserElementError(\n\t\t\t\treference,\n\t\t\t\t'UNKNOWN',\n\t\t\t\t'is not in the current view; call look for fresh refs',\n\t\t\t)\n\t\treturn { role: element.role, name: element.name, reference: element.reference }\n\t}\n\n\tasync #find(name: string, signal: AbortSignal): Promise<BrowserJourneyRevision> {\n\t\tconst revision = BROWSER_JOURNEY_NAME_PATTERN.test(name)\n\t\t\t? await this.#read(name, signal)\n\t\t\t: undefined\n\t\tif (revision === undefined)\n\t\t\tthrow new BrowserError(\n\t\t\t\t`No journey is named ${JSON.stringify(name)}; call journeys.`,\n\t\t\t\t'BROWSER_JOURNEY_MISSING',\n\t\t\t\t{ name },\n\t\t\t)\n\t\treturn revision\n\t}\n\n\tasync #read(name: string, signal: AbortSignal): Promise<BrowserJourneyRevision | undefined> {\n\t\ttry {\n\t\t\treturn await this.#store.get(name, { signal })\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) throw error\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Journey ${name} cannot be read: ${normalizeBrowserJourneyReason(error)}; call journeys.`,\n\t\t\t\tisBrowserError(error) ? error.code : 'BROWSER_JOURNEY_FILE',\n\t\t\t\t{ name },\n\t\t\t)\n\t\t}\n\t}\n\n\t// Reads the view a receipt carries through `look`, so it is cut at the toolset's limit and\n\t// carries the notes of any view move.\n\tasync #view(signal: AbortSignal): Promise<string> {\n\t\tconst performed = await this.#toolset.perform(\n\t\t\t{ id: 'journey', name: 'look', arguments: { what: 'the page' } },\n\t\t\t{ signal },\n\t\t)\n\t\treturn performed.result.success ? String(performed.result.value) : performed.result.error\n\t}\n\n\t#ended(): BrowserError {\n\t\treturn new BrowserError('the browser session ended', 'BROWSER_TOOLSET_ENDED')\n\t}\n\n\tasync #teardown(): Promise<void> {\n\t\tthis.#lifetime.abort(this.#ended())\n\t\tfor (const tool of this.#tools)\n\t\t\tif (this.#toolset.tools.tool(tool.name) === tool) this.#toolset.tools.remove(tool.name)\n\t\tconst recorder = this.#recorder\n\t\tthis.#recorder = undefined\n\t\tthis.#recording = undefined\n\t\tawait recorder?.destroy()\n\t\tawait this.#replay\n\t}\n\n\t#idleReplay(): void {\n\t\tconst active = this.#replaying ?? this.#toolset.held\n\t\tif (active !== undefined)\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The toolset is replaying ${active} until it finishes; call look.`,\n\t\t\t\t'BROWSER_TOOLSET_BUSY',\n\t\t\t)\n\t}\n}\n","import type {\n\tBrowserAction,\n\tBrowserFollowOptions,\n\tBrowserHoldInterface,\n\tBrowserJourneyStepInput,\n\tBrowserJourneyTab,\n\tBrowserJourneyTarget,\n\tBrowserJourneyToolsetInterface,\n\tBrowserToolsetResult,\n\tBrowserCallOptions,\n\tBrowserContextInterface,\n\tBrowserDestination,\n\tBrowserDestinationRelationship,\n\tBrowserDialogInterface,\n\tBrowserElementInterface,\n\tBrowserFrameInterface,\n\tBrowserNavigationRecordInterface,\n\tBrowserPageInterface,\n\tBrowserPopupRecordInterface,\n\tBrowserReadingInterface,\n\tBrowserTab,\n\tBrowserTool,\n\tBrowserToolName,\n\tBrowserToolSourceInterface,\n\tBrowserToolsetEventMap,\n\tBrowserToolsetHandler,\n\tBrowserToolsetInterface,\n\tBrowserToolsetOptions,\n\tBrowserToolsetReason,\n\tBrowserToolsetWatch,\n\tBrowserViewInterface,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tToolCall,\n\tToolContext,\n\tToolInterface,\n\tToolManagerInterface,\n\tToolResult,\n} from '@orkestrel/tool'\nimport {\n\tcloneJSONRecord,\n\tisArray,\n\tisBoolean,\n\tisError,\n\tisFiniteNumber,\n\tisInteger,\n\tisRecord,\n\tisString,\n} from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { BrowserHold } from './BrowserHold.js'\nimport { BrowserJourneyToolset } from './BrowserJourneyToolset.js'\nimport { createTool, createToolManager } from '@orkestrel/tool'\nimport {\n\tBROWSER_JOURNEY_TOOL_NAMES,\n\tBROWSER_OBSERVATION_TOOL_NAMES,\n\tBROWSER_SCHEMES,\n\tBROWSER_TOOL_CAPTURE_MS,\n\tBROWSER_TOOL_CHANGED_NOTE,\n\tBROWSER_TOOL_COPY,\n\tBROWSER_TOOL_CUT_FOOTER,\n\tBROWSER_TOOL_DEADLINE_NOTE,\n\tBROWSER_TOOL_HANDLED_STATUS,\n\tBROWSER_TOOL_LIMIT,\n\tBROWSER_TOOL_NAMES,\n\tBROWSER_TOOL_PENDING_NOTE,\n\tBROWSER_TOOL_NAME_PATTERN,\n\tBROWSER_TOOL_TIMEOUT_LIMIT_MS,\n\tBROWSER_TOOL_TIMEOUT_MS,\n\tBROWSER_TOOL_VIEW_FOOTER,\n\tBROWSER_TYPED_ROLES,\n} from './constants.js'\nimport {\n\tBrowserElementError,\n\tBrowserError,\n\tBrowserStepError,\n\tisBrowserElementError,\n\tisBrowserError,\n} from './errors.js'\nimport { compileSubmitObserverExpression, compileSubmitReadExpression } from './compilers.js'\nimport {\n\tboundBrowserText,\n\tderiveBrowserToolSchema,\n\tnormalizeBrowserKey,\n\treadBrowserToolString,\n\trenderBrowserElement,\n\trenderBrowserReceipt,\n\trenderBrowserToolOutput,\n\trequireBrowserReference,\n\tvalidateBrowserToolArguments,\n} from './helpers.js'\n\n/**\n * Publishes the browser vocabulary as `@orkestrel/tool` tools over one view and adopts the\n * view's own tools beside them.\n *\n * @remarks\n * Every toolset advertises `look`, `read`, `click`, `type`, and `wait`, which need only the\n * `BrowserViewInterface` it is constructed over. With `options.page` it also advertises `press`\n * and `navigate`, stages the `dialog` tool while a dialog is open on the current page, follows a\n * popup the current page opens and returns to the opener when the popup closes, and adopts\n * `page.registry` by default; with `options.context` as well it advertises `tabs` and `switch`.\n * With `options.journeys` the constructor constructs a `BrowserJourneyToolset`, which adds\n * `record`, `save`, `journeys`, `edit`, and `replay` to the manager and reserves those names, and\n * `destroy()` destroys it first. The result that carries the view after a move names the move.\n *\n * Every tool, the page tools included, runs through one boundary. The boundary refuses with\n * `the browser session ended` after `destroy()`, refuses an aborted signal before the tool runs,\n * refuses every tool but `dialog` while a dialog is open, forwards `ToolContext.signal` into every\n * protocol call, refuses a call to a toolset tool that carries a parameter the tool does not\n * advertise, and cuts every returned string and every thrown message at `limit` characters plus\n * a footer; the footer of a cut result that carries a view names `read` as the next call. `look`\n * and `read` read the page, never one element. A page tool's error message and JSON output reach\n * the toolset already cut at `BROWSER_REGISTRY_OUTPUT_LIMIT` (4 096) by the registry, so a\n * `limit` over that shows at most 4 096 characters of either; a page tool's text output reaches\n * the boundary whole.\n *\n * `click`, `type`, `press`, `navigate`, and `switch` are actions: one runs at a time, in call\n * order, and holds the queue until its receipt. A queued action whose signal aborts leaves\n * without sending anything. An action whose receipt returned while its command was still\n * pending, because a dialog opened or a navigation was requested, is awaited by the next action.\n * Every pending step is raced against the page's `dialog` event, so a dialog returns the receipt\n * that names it while the blocked command settles later without a second receipt. Before `click`\n * sends its input and before `type` edits the control, the action opens the page's navigation\n * record for the element's frame, and `press` opens one for the main frame. `click`, `type` with\n * `submit`, and `press` of Enter open the page's popup record beside it: after the navigation\n * settles, the receipt waits under the same deadline for the popups the record's reports name,\n * moves the view to the first one still open with the note `The view moved to a new tab: URL.`,\n * and records that popup's URL and title as the action's `tab`, so the receipt carries the popup's\n * view. A popup the current page announces outside such an action, or during one that did not\n * move to it, moves the view when the page announces it or when the action ends. Before the\n * navigation record opens, `click` and `type` with `submit` install a `submit` observer in the\n * isolated world of the element's document, and `press` in every document one `page.frames()`\n * call lists; an action whose input\n * document cannot be observed is refused with `BROWSER_TOOLSET_OBSERVE` before any input, and a\n * document `press` did not list is not observed. A navigation that starts in the input's frame or\n * an ancestor before the input settles is followed; when the input settles first, each observed\n * submission that kept its default action names its destination frame, and the receipt waits for\n * the navigation the record selects to commit and load under the receipt's deadline; a submission\n * every listener prevented adds no wait. When the reads name no surviving destination and no\n * navigation followed, the receipt's status is `BROWSER_TOOL_HANDLED_STATUS`, which names `wait` as\n * the next call, after a prevented submission, and `no form received the submission` when `type`\n * with `submit`, or a `press` of Enter that an input a form owns received, recorded none. The\n * page placement's `type` with `submit` ends its action with `and submitted the form` when a read\n * recorded a submission, or when the navigation the receipt settled names `formSubmissionGet` or\n * `formSubmissionPost` as its reason, whatever the read answered, and with `and pressed Enter`\n * otherwise. A `read`\n * at an offset at or past its retained reading's end restarts that reading at 0. A receipt that\n * waits for a requested navigation shares one `BROWSER_TOOL_TIMEOUT_MS` deadline between that\n * wait and its view capture, of which `BROWSER_TOOL_CAPTURE_MS` is reserved for the capture. The\n * deadline runs from the moment the receipt starts waiting, after any time the action spent\n * queued and after `navigate`'s own load wait; its timers end with the receipt, and settling the\n * receipt aborts the capture. A capture that the page's change makes stale waits for the page's\n * readiness and reads the view once more inside the same deadline, and reports\n * `BROWSER_TOOL_CHANGED_NOTE` when that read fails too. `type` refuses an element whose role is\n * not in `BROWSER_TYPED_ROLES` before it sends anything, naming `click` as the next call. A `click` on an element whose role is in `BROWSER_TYPED_ROLES`\n * adds `; call type with REF to enter text` to its receipt line. A click\n * or type over a view whose `trusted` is `false` ends its receipt line with ` (untrusted event)`.\n *\n * A page tool is skipped, with `skip` emitted, when its name is reserved (`unresolved` included), when the manager holds\n * its name under a tool the toolset did not add (checked again immediately before each addition),\n * when its name falls outside `BROWSER_TOOL_NAME_PATTERN`, when its parameters or, for a source\n * that supplies `tools()`, its selected registration declare `what` optional, or when that\n * registration is marked `debugging`. The selected registration is the main frame's, then the\n * earlier one. A page tool whose parameters require nothing advertises a required `what`, which\n * is stripped before the tool runs. Every adopted tool is advertised `untrusted`. `destroy()`\n * removes only the tools the manager still holds under the instances the toolset added, never\n * closes a page, and ends only what `options.release` hands over, calling it one time last.\n *\n * @example\n * ```ts\n * import { BrowserToolset } from '@orkestrel/browser'\n *\n * const toolset = new BrowserToolset(page, { page })\n * await toolset.start()\n * const result = await toolset.tools.execute({ id: '1', name: 'look', arguments: { what: 'cart' } })\n * await toolset.destroy()\n * ```\n */\nexport class BrowserToolset implements BrowserToolsetInterface {\n\treadonly #view: BrowserViewInterface\n\treadonly #origin: BrowserPageInterface | undefined\n\treadonly #tools: ToolManagerInterface\n\treadonly #manager: ToolManagerInterface\n\treadonly #source: BrowserToolSourceInterface | undefined\n\treadonly #context: BrowserContextInterface | undefined\n\treadonly #limit: number\n\treadonly #schemes: readonly string[]\n\treadonly #owned: (() => Promise<void> | void) | undefined\n\treadonly #emitter: Emitter<BrowserToolsetEventMap>\n\treadonly #lifetime = new AbortController()\n\treadonly #native: readonly ToolInterface[]\n\treadonly #dialogTool: ToolInterface | undefined\n\treadonly #contextTools: readonly ToolInterface[]\n\treadonly #journeys: BrowserJourneyToolsetInterface | undefined\n\treadonly #added = new Set<ToolInterface>()\n\treadonly #adopted = new Map<string, ToolInterface>()\n\treadonly #watches = new Map<BrowserPageInterface, BrowserToolsetWatch>()\n\treadonly #dialogs = new Map<BrowserPageInterface, BrowserDialogInterface>()\n\treadonly #handlers = new WeakMap<\n\t\tToolInterface,\n\t\t{ readonly handler: BrowserToolsetHandler; readonly clause: string }\n\t>()\n\treadonly #actions = new WeakMap<AbortSignal, Partial<BrowserAction>>()\n\treadonly #invocations = new WeakMap<\n\t\tToolContext,\n\t\t{ readonly handler: BrowserToolsetHandler; readonly clause: string }\n\t>()\n\t#reservation: BrowserHoldInterface | undefined\n\treadonly #holds = new Map<PromiseWithResolvers<void>, BrowserHoldInterface>()\n\treadonly #interrupts = new Map<PromiseWithResolvers<never>, string>()\n\treadonly #notes: string[] = []\n\treadonly #changeHandler = this.#handleChange.bind(this)\n\treadonly #removeHandler = this.#handleRemove.bind(this)\n\treadonly #clearHandler = this.#handleClear.bind(this)\n\t#page: BrowserPageInterface | undefined\n\t#following: BrowserToolSourceInterface | undefined\n\t#reading:\n\t\t| { readonly view: BrowserViewInterface; readonly reading: BrowserReadingInterface }\n\t\t| undefined\n\t#tail: Promise<void> = Promise.resolve()\n\t#pending: Promise<void> | undefined\n\t// Numbers each action, so the observer it installs answers only its own read and removal.\n\t#sequence = 0\n\t#navigating: BrowserPageInterface | undefined\n\t// The popups announced while an action holds a popup record, with their openers; the action\n\t// moves the view itself, and the rest follow when it ends.\n\t#arrivals:\n\t\t| ReadonlyArray<readonly [opener: BrowserPageInterface, popup: BrowserPageInterface]>\n\t\t| undefined\n\t#generation = 0\n\t#started = false\n\t#starting: Promise<void> | undefined\n\t#destroying: Promise<void> | undefined\n\n\tconstructor(view: BrowserViewInterface, options?: BrowserToolsetOptions) {\n\t\tconst limit = options?.limit ?? BROWSER_TOOL_LIMIT\n\t\tif (!isInteger(limit) || limit < 1) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Browser toolset limit must be a positive integer',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{\n\t\t\t\t\tlimit,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (options?.context !== undefined && options.page === undefined) {\n\t\t\tthrow new BrowserError('Browser toolset context requires a page', 'BROWSER_TOOLSET_CONTEXT')\n\t\t}\n\t\tthis.#view = view\n\t\tthis.#origin = options?.page\n\t\tthis.#page = options?.page\n\t\tthis.#tools = options?.tools ?? createToolManager()\n\t\tthis.#manager = new Proxy(this.#tools, { get: this.#readManager.bind(this) })\n\t\tthis.#source = options?.source\n\t\tthis.#context = options?.context\n\t\tthis.#limit = limit\n\t\tthis.#schemes = options?.schemes ?? BROWSER_SCHEMES\n\t\tthis.#owned = options?.release\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t\tconst look = this.#create('look', this.#look.bind(this), BROWSER_TOOL_VIEW_FOOTER)\n\t\tconst read = this.#create('read', this.#read.bind(this), BROWSER_TOOL_CUT_FOOTER)\n\t\tconst click = this.#create('click', this.#click.bind(this), BROWSER_TOOL_VIEW_FOOTER)\n\t\tconst type = this.#create('type', this.#type.bind(this), BROWSER_TOOL_VIEW_FOOTER)\n\t\tconst wait = this.#create('wait', this.#wait.bind(this), BROWSER_TOOL_CUT_FOOTER)\n\t\tthis.#native = Object.freeze(\n\t\t\toptions?.page === undefined\n\t\t\t\t? [look, read, click, type, wait]\n\t\t\t\t: [\n\t\t\t\t\t\tlook,\n\t\t\t\t\t\tread,\n\t\t\t\t\t\tclick,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tthis.#create('press', this.#press.bind(this), BROWSER_TOOL_VIEW_FOOTER),\n\t\t\t\t\t\tthis.#create('navigate', this.#navigate.bind(this), BROWSER_TOOL_VIEW_FOOTER),\n\t\t\t\t\t\twait,\n\t\t\t\t\t],\n\t\t)\n\t\tthis.#dialogTool =\n\t\t\toptions?.page === undefined\n\t\t\t\t? undefined\n\t\t\t\t: this.#create('dialog', this.#dialog.bind(this), BROWSER_TOOL_VIEW_FOOTER)\n\t\tthis.#contextTools = Object.freeze(\n\t\t\toptions?.context === undefined\n\t\t\t\t? []\n\t\t\t\t: [\n\t\t\t\t\t\tthis.#create('tabs', this.#tabs.bind(this), BROWSER_TOOL_CUT_FOOTER),\n\t\t\t\t\t\tthis.#create('switch', this.#switch.bind(this), BROWSER_TOOL_VIEW_FOOTER),\n\t\t\t\t\t],\n\t\t)\n\t\tthis.#journeys =\n\t\t\toptions?.journeys === undefined\n\t\t\t\t? undefined\n\t\t\t\t: new BrowserJourneyToolset(this, {\n\t\t\t\t\t\t...options.journeys,\n\t\t\t\t\t\tlimit: options.journeys.limit ?? limit,\n\t\t\t\t\t})\n\t}\n\n\tget emitter(): EmitterInterface<BrowserToolsetEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget tools(): ToolManagerInterface {\n\t\treturn this.#manager\n\t}\n\n\tget limit(): number {\n\t\treturn this.#limit\n\t}\n\n\t#readManager(target: ToolManagerInterface, key: string | symbol): unknown {\n\t\tif (key === 'execute') return this.#performManaged.bind(this)\n\t\tconst value: unknown = Reflect.get(target, key, target)\n\t\treturn typeof value === 'function' ? value.bind(target) : value\n\t}\n\n\t#performManaged(call: ToolCall, context?: ToolContext): Promise<ToolResult>\n\t#performManaged(calls: readonly ToolCall[], context?: ToolContext): Promise<readonly ToolResult[]>\n\tasync #performManaged(\n\t\tcalls: ToolCall | readonly ToolCall[],\n\t\tcontext?: ToolContext,\n\t): Promise<ToolResult | readonly ToolResult[]> {\n\t\tif (isArray(calls))\n\t\t\treturn Promise.all(calls.map(async (call) => (await this.perform(call, context)).result))\n\t\treturn (await this.perform(calls, context)).result\n\t}\n\n\tget native(): readonly ToolInterface[] {\n\t\treturn this.#native\n\t}\n\n\tget view(): BrowserViewInterface {\n\t\treturn this.#cursor\n\t}\n\n\tget held(): string | undefined {\n\t\treturn this.#reservation?.name\n\t}\n\n\tasync perform(call: ToolCall, context?: ToolContext): Promise<BrowserToolsetResult> {\n\t\tconst tool = this.#tools.tool(call.name)\n\t\tconst entry =\n\t\t\t(context === undefined ? undefined : this.#invocations.get(context)) ??\n\t\t\t(tool === undefined ? undefined : this.#handlers.get(tool))\n\t\tif (entry === undefined || context?.signal.aborted === true) {\n\t\t\tconst result = await this.#tools.execute(call, context)\n\t\t\tconst secret =\n\t\t\t\tcall.name === 'type' && call.arguments['secret'] === true\n\t\t\t\t\t? call.arguments['text']\n\t\t\t\t\t: undefined\n\t\t\treturn {\n\t\t\t\tresult: result.success\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tvalue: isString(result.value)\n\t\t\t\t\t\t\t\t? this.#boundReceipt(result.value, secret)\n\t\t\t\t\t\t\t\t: result.value,\n\t\t\t\t\t\t}\n\t\t\t\t\t: { ...result, error: this.#boundReceipt(result.error, secret) },\n\t\t\t}\n\t\t}\n\t\tconst signal = AbortSignal.any([\n\t\t\tcontext?.signal ?? new AbortController().signal,\n\t\t\tthis.#lifetime.signal,\n\t\t])\n\t\tconst started = performance.now()\n\t\tconst acting = !BROWSER_OBSERVATION_TOOL_NAMES.includes(call.name)\n\t\tlet result: ToolResult\n\t\tlet fault: unknown\n\t\ttry {\n\t\t\tif (acting) {\n\t\t\t\tconst secret = call.name === 'type' && call.arguments['secret'] === true\n\t\t\t\tthis.#actions.set(signal, {\n\t\t\t\t\taction: call.name,\n\t\t\t\t\targuments: cloneJSONRecord(\n\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\tObject.entries(call.arguments).filter(([key]) => !secret || key !== 'text'),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t\t...(secret ? { secret: true } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst value = await this.#execute(call.name, entry.clause, entry.handler, call.arguments, {\n\t\t\t\t...context,\n\t\t\t\tsignal,\n\t\t\t})\n\t\t\tresult = { id: call.id, name: call.name, success: true, value }\n\t\t} catch (error) {\n\t\t\tfault = error\n\t\t\tresult = {\n\t\t\t\tid: call.id,\n\t\t\t\tname: call.name,\n\t\t\t\tsuccess: false,\n\t\t\t\terror: isError(error) ? error.message : String(error),\n\t\t\t}\n\t\t}\n\t\tconst state = this.#actions.get(signal)\n\t\tthis.#actions.delete(signal)\n\t\tconst action: BrowserAction | undefined =\n\t\t\tstate?.arguments === undefined\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\t...state,\n\t\t\t\t\t\taction: call.name,\n\t\t\t\t\t\targuments: state.arguments,\n\t\t\t\t\t\toutcome: result.success ? (state.outcome ?? 'done') : 'refused',\n\t\t\t\t\t\treceipt: result.success ? (state.receipt ?? String(result.value)) : result.error,\n\t\t\t\t\t\telapsed: performance.now() - started,\n\t\t\t\t\t}\n\t\tif (action !== undefined) this.#emitter.emit('action', action)\n\t\treturn {\n\t\t\tresult,\n\t\t\t...(action === undefined ? {} : { action }),\n\t\t\t...(result.success ? {} : { fault }),\n\t\t}\n\t}\n\n\tasync hold(name: string, options?: BrowserCallOptions): Promise<BrowserHoldInterface> {\n\t\tthis.#live()\n\t\tconst signal = AbortSignal.any([\n\t\t\toptions?.signal ?? new AbortController().signal,\n\t\t\tthis.#lifetime.signal,\n\t\t])\n\t\tsignal.throwIfAborted()\n\t\tthis.#holdable()\n\t\tconst released = Promise.withResolvers<void>()\n\t\tconst hold = new BrowserHold(name, this.#releaseHold.bind(this, released))\n\t\tconst earlier = [...this.#holds.keys()]\n\t\tthis.#holds.set(released, hold)\n\t\ttry {\n\t\t\tif (earlier.length > 0)\n\t\t\t\tawait this.#race(Promise.all(earlier.map((entry) => entry.promise)), '', signal)\n\t\t\tconst turn = await this.#acquire(signal, false, true)\n\t\t\ttry {\n\t\t\t\tsignal.throwIfAborted()\n\t\t\t\tthis.#reservation = hold\n\t\t\t\tthis.#emitter.emit('hold', name)\n\t\t\t\treturn hold\n\t\t\t} finally {\n\t\t\t\tturn.resolve()\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thold.destroy()\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync follow(\n\t\tid: string,\n\t\tstep: BrowserJourneyStepInput,\n\t\toptions?: BrowserFollowOptions,\n\t): Promise<BrowserAction> {\n\t\tconst context: ToolContext = {\n\t\t\tsignal: options?.signal ?? new AbortController().signal,\n\t\t\t...(options?.caller === undefined ? {} : { caller: options.caller }),\n\t\t}\n\t\tlet args: Readonly<Record<string, unknown>> = step.arguments\n\t\tif ((step.action === 'click' || step.action === 'type') && step.target !== undefined)\n\t\t\targs = { ...args, ref: await this.#resolveTarget(id, step.target, options) }\n\t\tif (step.action === 'type' && options?.secret === true) args = { ...args, secret: true }\n\t\t// Without a context the manager refuses `switch` itself, as it refuses any unadvertised step.\n\t\tif (step.action === 'switch' && step.tab !== undefined && this.#context !== undefined)\n\t\t\targs = { ...args, tab: await this.#resolveTab(id, step.tab, options) }\n\t\tconst performed = await this.perform({ id, name: step.action, arguments: args }, context)\n\t\tconst action = performed.action\n\t\tif (action === undefined)\n\t\t\tthrow new BrowserError(\n\t\t\t\t`${id}: ${performed.result.success ? String(performed.result.value) : performed.result.error}`,\n\t\t\t)\n\t\tif (\n\t\t\t(action.outcome !== 'done' && action.outcome !== 'interrupted') ||\n\t\t\taction.stage === 'requested' ||\n\t\t\taction.stage === 'committed'\n\t\t)\n\t\t\tthrow new BrowserStepError(id, action)\n\t\treturn action\n\t}\n\n\tasync tabs(options?: BrowserCallOptions): Promise<readonly BrowserTab[]> {\n\t\tthis.#live()\n\t\tconst signal = AbortSignal.any([\n\t\t\toptions?.signal ?? new AbortController().signal,\n\t\t\tthis.#lifetime.signal,\n\t\t])\n\t\tsignal.throwIfAborted()\n\t\tthis.#refuseDialog()\n\t\t// A dialog that opens while the titles are read never interrupts the listing, because the\n\t\t// interruption is a receipt and this result is data.\n\t\treturn this.#list(signal, false)\n\t}\n\n\tstart(options?: BrowserCallOptions): Promise<void> {\n\t\tif (this.#destroying !== undefined) return Promise.reject(this.#ended())\n\t\tif (this.#starting === undefined) {\n\t\t\t// The startup runs in a continuation, so the shared promise exists before any listener\n\t\t\t// the startup triggers can call `start()` again.\n\t\t\tconst starting = Promise.resolve().then(this.#begin.bind(this, options))\n\t\t\tthis.#starting = starting\n\t\t\tvoid starting.catch(this.#forget.bind(this, starting))\n\t\t}\n\t\treturn this.#starting\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tthis.#destroying ??= this.#teardown()\n\t\treturn this.#destroying\n\t}\n\n\tget #cursor(): BrowserViewInterface {\n\t\treturn this.#page ?? this.#view\n\t}\n\n\t#create(name: BrowserToolName, handler: BrowserToolsetHandler, clause: string): ToolInterface {\n\t\tconst validated = this.#validate.bind(this, name, handler)\n\t\tconst tool = createTool({\n\t\t\t...BROWSER_TOOL_COPY[name],\n\t\t\texecute: this.#dispatch.bind(this, name, validated, clause),\n\t\t})\n\t\tthis.#handlers.set(tool, { handler: validated, clause })\n\t\treturn tool\n\t}\n\n\tasync #dispatch(\n\t\tname: string,\n\t\thandler: BrowserToolsetHandler,\n\t\tclause: string,\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<unknown> {\n\t\tthis.#live()\n\t\tif (name !== 'type' || args['secret'] !== true) context.signal.throwIfAborted()\n\t\tconst invocation = { ...context }\n\t\tthis.#invocations.set(invocation, { handler, clause })\n\t\tconst performed = await this.perform({ id: '', name, arguments: args }, invocation)\n\t\tif (!performed.result.success) throw performed.fault ?? new BrowserError(performed.result.error)\n\t\treturn performed.result.value\n\t}\n\n\t#admit(category: 'observation' | 'action', caller: unknown): void {\n\t\tconst hold = this.#reservation ?? this.#holds.values().next().value\n\t\tif (hold !== undefined && caller !== hold.token && category !== 'observation')\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The toolset is replaying ${hold.name} until it finishes; call look.`,\n\t\t\t\t'BROWSER_TOOLSET_BUSY',\n\t\t\t)\n\t}\n\n\t#holdable(): void {\n\t\tconst dialog = this.#page === undefined ? undefined : this.#dialogs.get(this.#page)\n\t\tif (dialog !== undefined || this.#pending !== undefined)\n\t\t\tthrow new BrowserError(\n\t\t\t\tdialog === undefined\n\t\t\t\t\t? BROWSER_TOOL_PENDING_NOTE\n\t\t\t\t\t: renderBrowserReceipt({ action: '', dialog }),\n\t\t\t\t'BROWSER_TOOLSET_DIALOG',\n\t\t\t)\n\t}\n\n\t#releaseHold(released: PromiseWithResolvers<void>): void {\n\t\tconst hold = this.#holds.get(released)\n\t\tthis.#holds.delete(released)\n\t\treleased.resolve()\n\t\tif (hold !== undefined && this.#reservation === hold) {\n\t\t\tthis.#reservation = undefined\n\t\t\tthis.#emitter.emit('release', hold.name)\n\t\t}\n\t}\n\n\t// Refuses a parameter the tool does not advertise before its handler reads any argument.\n\t#validate(\n\t\tname: BrowserToolName,\n\t\thandler: BrowserToolsetHandler,\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tvalidateBrowserToolArguments(BROWSER_TOOL_COPY[name], args)\n\t\treturn handler(args, context)\n\t}\n\n\t// Every await is followed by a lifecycle check, so a `destroy()` that ran meanwhile leaves\n\t// nothing registered.\n\tasync #begin(options?: BrowserCallOptions): Promise<void> {\n\t\tthis.#live()\n\t\tconst conflict = BROWSER_TOOL_NAMES.find((name) => {\n\t\t\tconst held = this.#tools.tool(name)\n\t\t\treturn held !== undefined && !this.#added.has(held)\n\t\t})\n\t\tif (conflict !== undefined) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The tool manager already holds a tool named ${conflict}, a name the browser toolset reserves`,\n\t\t\t\t'BROWSER_TOOLSET_RESERVED',\n\t\t\t\t{ name: conflict },\n\t\t\t)\n\t\t}\n\t\tconst page = this.#page\n\t\ttry {\n\t\t\tthis.#listen(this.#source ?? page?.registry)\n\t\t\tif (this.#source === undefined && page !== undefined) await page.registry.start(options)\n\t\t\tthis.#live()\n\t\t\tif (page !== undefined) await this.#watch(page)\n\t\t\tthis.#live()\n\t\t} catch (error) {\n\t\t\tthis.#listen(undefined)\n\t\t\tif (page !== undefined) await this.#unwatch(page)\n\t\t\tthrow error\n\t\t}\n\t\tthis.#tools.emitter.on('remove', this.#removeHandler)\n\t\tthis.#tools.emitter.on('clear', this.#clearHandler)\n\t\tthis.#started = true\n\t\tfor (const tool of [...this.#native, ...this.#contextTools]) {\n\t\t\tthis.#add(tool)\n\t\t\tthis.#live()\n\t\t}\n\t\tthis.#stage()\n\t\tawait this.#adopt()\n\t\tthis.#live()\n\t}\n\n\t// The one boundary every tool runs through; a handler returns its body and a footer the\n\t// boundary appends after cutting the body, and `clause` closes the footer of a cut body.\n\tasync #execute(\n\t\tname: string,\n\t\tclause: string,\n\t\thandler: BrowserToolsetHandler,\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<string> {\n\t\tif (this.#destroying !== undefined) throw this.#ended()\n\t\tconst signal = context.signal\n\t\tconst secret = name === 'type' && args['secret'] === true ? args['text'] : undefined\n\t\ttry {\n\t\t\tsignal.throwIfAborted()\n\t\t\tthis.#admit(\n\t\t\t\tBROWSER_OBSERVATION_TOOL_NAMES.includes(name) || name === 'wait' ? 'observation' : 'action',\n\t\t\t\tcontext.caller,\n\t\t\t)\n\t\t\tif (name !== 'dialog') this.#refuseDialog()\n\t\t\tconst [content, suffix] = await handler(args, { ...context, signal })\n\t\t\tconst body = this.#boundReceipt(content, secret)\n\t\t\tconst footer = this.#boundReceipt(suffix, secret)\n\t\t\t// A cancellation that lands while the handler finishes wins over its result.\n\t\t\tsignal.throwIfAborted()\n\t\t\tconst state = this.#actions.get(signal)\n\t\t\tif (state !== undefined)\n\t\t\t\tthis.#actions.set(signal, {\n\t\t\t\t\t...state,\n\t\t\t\t\treceipt: boundBrowserText(body.split('\\n\\n')[0] ?? body, this.#limit, clause),\n\t\t\t\t})\n\t\t\treturn `${this.#boundReceipt(`${this.#drain()}${body}`, secret, clause)}${footer}`\n\t\t} catch (error) {\n\t\t\tconst original = isError(error) ? error.message : String(error)\n\t\t\tconst message = this.#boundReceipt(original, secret)\n\t\t\tif (context.signal.aborted && error === context.signal.reason && message === original)\n\t\t\t\tthrow error\n\t\t\tif (isBrowserError(error) && error.code === 'BROWSER_TOOLSET_RECEIPT') {\n\t\t\t\tthis.#actions.set(signal, { ...this.#actions.get(signal), outcome: 'interrupted' })\n\t\t\t\treturn this.#boundReceipt(`${this.#drain()}${message}`, secret, BROWSER_TOOL_CUT_FOOTER)\n\t\t\t}\n\t\t\tif (message === original && message.length <= this.#limit) throw error\n\t\t\tthrow new BrowserError(\n\t\t\t\tboundBrowserText(message, this.#limit, BROWSER_TOOL_CUT_FOOTER),\n\t\t\t\tisBrowserError(error) ? error.code : undefined,\n\t\t\t\tisBrowserError(error) ? error.context : undefined,\n\t\t\t)\n\t\t}\n\t}\n\n\t// Redacts before splitting or clipping, which could otherwise retain only part of a secret.\n\t#boundReceipt(message: string, secret: unknown, clause?: string): string {\n\t\tif (isString(secret) && secret.length > 0) {\n\t\t\tmessage = message\n\t\t\t\t.replaceAll(JSON.stringify(secret), '[redacted]')\n\t\t\t\t.replaceAll(secret, '[redacted]')\n\t\t}\n\t\treturn clause === undefined ? message : boundBrowserText(message, this.#limit, clause)\n\t}\n\n\tasync #look(\n\t\t_args: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\t// The outline carries the signal, so an abort rejects with its own pending protocol\n\t\t// entry's reason rather than a toolset-level copy of it.\n\t\tconst outline = await this.#race(this.#cursor.elements.outline({ signal: context.signal }), '')\n\t\treturn [outline.text, '']\n\t}\n\n\tasync #read(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst offset = args['offset'] ?? 0\n\t\tif (!isInteger(offset) || offset < 0) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The offset parameter must be a non-negative integer.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'offset' },\n\t\t\t)\n\t\t}\n\t\tconst view = this.#cursor\n\t\tconst retained = this.#reading\n\t\tlet reading = retained?.reading\n\t\t// A continuation reuses the capture it continues; a changed view or a navigation recaptures.\n\t\t// The slice restarts at 0 after a recapture and at an offset at or past the retained\n\t\t// reading's end, so the footer shows the reset.\n\t\tif (\n\t\t\toffset === 0 ||\n\t\t\tretained === undefined ||\n\t\t\treading === undefined ||\n\t\t\tretained.view !== view ||\n\t\t\treading.stale\n\t\t) {\n\t\t\treading = await this.#race(view.read({ signal: context.signal }), '', context.signal)\n\t\t\tthis.#reading = { view, reading }\n\t\t}\n\t\tconst start =\n\t\t\treading === retained?.reading && offset < reading.markdown({ offset: 0, limit: 1 }).total\n\t\t\t\t? offset\n\t\t\t\t: 0\n\t\t// A move note shares the limit with the slice, so the continuation offset counts only the\n\t\t// reading characters this result carries.\n\t\tconst note = boundBrowserText(\n\t\t\tthis.#drain(),\n\t\t\tMath.max(1, this.#limit - 1),\n\t\t\tBROWSER_TOOL_CUT_FOOTER,\n\t\t)\n\t\tconst room = this.#limit - note.length\n\t\tconst slice =\n\t\t\troom < 1\n\t\t\t\t? { text: '', offset: start, total: reading.markdown({ offset: 0 }).total }\n\t\t\t\t: reading.markdown({ offset: start, limit: room })\n\t\t// A limit that cannot hold the next code point would never advance the continuation.\n\t\tif (note === '' && slice.text === '' && slice.offset < slice.total) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The read limit of ${this.#limit} characters cannot hold the next character at offset ${start}; raise the toolset limit.`,\n\t\t\t\t'BROWSER_TOOLSET_LIMIT',\n\t\t\t\t{ limit: this.#limit, offset: start },\n\t\t\t)\n\t\t}\n\t\tconst end = slice.offset + slice.text.length\n\t\tconst more = end < slice.total\n\t\tif (start === 0 && !more) return [`${note}${slice.text}`, '']\n\t\treturn [\n\t\t\t`${note}${slice.text}`,\n\t\t\t`\\n\\n[characters ${start}–${end} of ${slice.total}${more ? `; call read with offset ${end} for more` : ''}]`,\n\t\t]\n\t}\n\n\tasync #click(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst turn = await this.#acquire(context.signal)\n\t\tconst observation = { token: (this.#sequence += 1), frames: new Set<BrowserFrameInterface>() }\n\t\tlet record: BrowserNavigationRecordInterface | undefined\n\t\tlet popups: BrowserPopupRecordInterface | undefined\n\t\ttry {\n\t\t\tconst element = this.#element(args['ref'], context.signal)\n\t\t\tconst action = BROWSER_TYPED_ROLES.has(element.role)\n\t\t\t\t? `Clicked ${renderBrowserElement(element)}; call type with ${element.reference} to enter text`\n\t\t\t\t: `Clicked ${renderBrowserElement(element)}`\n\t\t\tconst page = this.#page\n\t\t\tif (page !== undefined) {\n\t\t\t\tconst frame = this.#resolveFrame(page, element.reference)\n\t\t\t\tawait this.#observe(\n\t\t\t\t\tawait this.#locate(page, frame, context.signal),\n\t\t\t\t\tframe,\n\t\t\t\t\tobservation,\n\t\t\t\t\tcontext.signal,\n\t\t\t\t)\n\t\t\t\trecord = page.navigation.record(frame)\n\t\t\t\tpopups = this.#recordPopups(page)\n\t\t\t}\n\t\t\treturn [\n\t\t\t\tawait this.#settle(\n\t\t\t\t\telement.click({ signal: context.signal }),\n\t\t\t\t\taction,\n\t\t\t\t\tcontext.signal,\n\t\t\t\t\tthis.#view.trusted,\n\t\t\t\t\trecord,\n\t\t\t\t\tpopups,\n\t\t\t\t\tobservation,\n\t\t\t\t),\n\t\t\t\t'',\n\t\t\t]\n\t\t} finally {\n\t\t\trecord?.destroy()\n\t\t\tpopups?.destroy()\n\t\t\tthis.#flushArrivals()\n\t\t\ttry {\n\t\t\t\tawait this.#unobserve(observation, context.signal)\n\t\t\t} finally {\n\t\t\t\tturn.resolve()\n\t\t\t}\n\t\t}\n\t}\n\n\tasync #type(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst text = readBrowserToolString(args, 'text')\n\t\tconst submit = args['submit']\n\t\tconst secret = args['secret']\n\t\tif (secret !== undefined && !isBoolean(secret))\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The secret parameter must be a boolean.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'secret' },\n\t\t\t)\n\t\tif (submit !== undefined && !isBoolean(submit)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The submit parameter must be a boolean.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'submit' },\n\t\t\t)\n\t\t}\n\n\t\tconst turn = await this.#acquire(context.signal)\n\t\tconst observation = { token: (this.#sequence += 1), frames: new Set<BrowserFrameInterface>() }\n\t\tlet record: BrowserNavigationRecordInterface | undefined\n\t\tlet popups: BrowserPopupRecordInterface | undefined\n\t\ttry {\n\t\t\tconst element = this.#element(args['ref'], context.signal)\n\t\t\t// The role the latest capture recorded decides, so a control that takes no text is\n\t\t\t// refused before any protocol command reaches it.\n\t\t\tif (!BROWSER_TYPED_ROLES.has(element.role)) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Element ${renderBrowserElement(element)} takes no text; call click for ${/^[aeiou]/i.test(element.role) ? 'an' : 'a'} ${element.role}.`,\n\t\t\t\t\t'BROWSER_TOOLSET_ROLE',\n\t\t\t\t\t{ reference: element.reference, role: element.role },\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst chosen = `Selected ${secret === true ? 'a secret' : JSON.stringify(text)} in ${renderBrowserElement(element)} (programmatic)`\n\t\t\tconst typed = `Typed ${secret === true ? 'a secret' : JSON.stringify(text)} into ${renderBrowserElement(element)}`\n\t\t\t// The observer and the record precede the edit, because the inserted text or the chosen\n\t\t\t// option can run a handler that submits the form.\n\t\t\tconst page = this.#page\n\t\t\tif (page !== undefined) {\n\t\t\t\tconst frame = this.#resolveFrame(page, element.reference)\n\t\t\t\tif (submit === true)\n\t\t\t\t\tawait this.#observe(\n\t\t\t\t\t\tawait this.#locate(page, frame, context.signal),\n\t\t\t\t\t\tframe,\n\t\t\t\t\t\tobservation,\n\t\t\t\t\t\tcontext.signal,\n\t\t\t\t\t)\n\t\t\t\trecord = page.navigation.record(frame)\n\t\t\t\tif (submit === true) popups = this.#recordPopups(page)\n\t\t\t}\n\t\t\t// A combobox or listbox role names a select element or a text input with suggestions;\n\t\t\t// the receipt names the path taken, and a dialog mid-edit names the path attempted.\n\t\t\tconst choosing = element.role === 'combobox' || element.role === 'listbox'\n\t\t\tconst edit = choosing\n\t\t\t\t? this.#choose(element, text, context.signal)\n\t\t\t\t: element.fill(text, { signal: context.signal }).then(() => false)\n\t\t\t// The edit is the first input, so a navigation it starts wins the race as a click's does:\n\t\t\t// the unfinished edit stays the queue barrier, and no submission is sent through the\n\t\t\t// reference that navigation replaces.\n\t\t\tconst attempted = choosing ? chosen : typed\n\t\t\tconst started = record?.wait({ signal: context.signal }).then(\n\t\t\t\t() => undefined,\n\t\t\t\t() => new Promise<undefined>(() => undefined),\n\t\t\t)\n\t\t\tconst selected = await this.#command(\n\t\t\t\tstarted === undefined ? edit : Promise.race([started, edit]),\n\t\t\t\tattempted,\n\t\t\t\tedit,\n\t\t\t)\n\t\t\tif (selected === undefined)\n\t\t\t\treturn [\n\t\t\t\t\tawait this.#settle(\n\t\t\t\t\t\tedit.then(() => undefined),\n\t\t\t\t\t\tattempted,\n\t\t\t\t\t\tcontext.signal,\n\t\t\t\t\t\tthis.#view.trusted,\n\t\t\t\t\t\trecord,\n\t\t\t\t\t\tpopups,\n\t\t\t\t\t\tobservation,\n\t\t\t\t\t),\n\t\t\t\t\t'',\n\t\t\t\t]\n\t\t\tconst action = selected ? chosen : typed\n\t\t\tif (submit !== true) {\n\t\t\t\treturn [\n\t\t\t\t\tawait this.#settle(Promise.resolve(), action, context.signal, this.#view.trusted, record),\n\t\t\t\t\t'',\n\t\t\t\t]\n\t\t\t}\n\t\t\t// The page placement submits with a trusted Enter, so its receipt names the submission\n\t\t\t// only when the observer recorded one; the DOM placement calls `requestSubmit()`.\n\t\t\treturn [\n\t\t\t\tawait this.#settle(\n\t\t\t\t\telement.submit({ signal: context.signal }),\n\t\t\t\t\tpage === undefined ? `${action} and submitted the form` : `${action} and pressed Enter`,\n\t\t\t\t\tcontext.signal,\n\t\t\t\t\tthis.#view.trusted,\n\t\t\t\t\trecord,\n\t\t\t\t\tpopups,\n\t\t\t\t\tobservation,\n\t\t\t\t\tpage === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: { explicit: true, action: `${action} and submitted the form` },\n\t\t\t\t),\n\t\t\t\t'',\n\t\t\t]\n\t\t} finally {\n\t\t\trecord?.destroy()\n\t\t\tpopups?.destroy()\n\t\t\tthis.#flushArrivals()\n\t\t\ttry {\n\t\t\t\tawait this.#unobserve(observation, context.signal)\n\t\t\t} finally {\n\t\t\t\tturn.resolve()\n\t\t\t}\n\t\t}\n\t}\n\n\tasync #press(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst key = normalizeBrowserKey(readBrowserToolString(args, 'key'))\n\t\tconst turn = await this.#acquire(context.signal)\n\t\tconst observation = { token: (this.#sequence += 1), frames: new Set<BrowserFrameInterface>() }\n\t\tlet record: BrowserNavigationRecordInterface | undefined\n\t\tlet popups: BrowserPopupRecordInterface | undefined\n\t\ttry {\n\t\t\tconst page = this.#paged()\n\t\t\t// The focused document receives the keys, so every document one census lists is observed,\n\t\t\t// and only the main frame's must install.\n\t\t\tconst frames = await this.#race(page.frames(), '', context.signal)\n\t\t\tawait this.#observe(frames, page.id, observation, context.signal)\n\t\t\trecord = page.navigation.record(page.id)\n\t\t\tif (key === 'Enter') popups = this.#recordPopups(page)\n\t\t\t// The keyboard takes no signal and sends each release without one, so the signal is\n\t\t\t// checked before the first key goes down.\n\t\t\tcontext.signal.throwIfAborted()\n\t\t\tconst action = `Pressed ${key}`\n\t\t\treturn [\n\t\t\t\tawait this.#settle(\n\t\t\t\t\tpage.keyboard.press(key),\n\t\t\t\t\taction,\n\t\t\t\t\tcontext.signal,\n\t\t\t\t\ttrue,\n\t\t\t\t\trecord,\n\t\t\t\t\tpopups,\n\t\t\t\t\tobservation,\n\t\t\t\t\tkey === 'Enter' ? { explicit: false, action } : undefined,\n\t\t\t\t),\n\t\t\t\t'',\n\t\t\t]\n\t\t} finally {\n\t\t\trecord?.destroy()\n\t\t\tpopups?.destroy()\n\t\t\tthis.#flushArrivals()\n\t\t\ttry {\n\t\t\t\tawait this.#unobserve(observation, context.signal)\n\t\t\t} finally {\n\t\t\t\tturn.resolve()\n\t\t\t}\n\t\t}\n\t}\n\n\tasync #navigate(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst url = readBrowserToolString(args, 'url')\n\t\tconst parsed = URL.canParse(url) ? new URL(url) : undefined\n\t\tif (parsed === undefined) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Navigation refused: ${JSON.stringify(url)} is not an absolute URL.`,\n\t\t\t\t'BROWSER_TOOLSET_SCHEME',\n\t\t\t\t{ url },\n\t\t\t)\n\t\t}\n\t\tif (!this.#schemes.includes(parsed.protocol)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Navigation refused: the ${parsed.protocol} scheme is not allowed; use ${this.#schemes.join(' or ')}.`,\n\t\t\t\t'BROWSER_TOOLSET_SCHEME',\n\t\t\t\t{ url },\n\t\t\t)\n\t\t}\n\t\tconst turn = await this.#acquire(context.signal)\n\t\tconst page = this.#paged()\n\t\tthis.#navigating = page\n\t\tconst record = page.navigation.record(page.id)\n\t\ttry {\n\t\t\t// The page's load wait rejects with the signal's reason after its cleanup, so the\n\t\t\t// command stays the queue's barrier until that cleanup settles.\n\t\t\tconst navigation = page.navigate(url, { condition: 'load', signal: context.signal })\n\t\t\tconst result = await this.#command(navigation, `Navigating to ${url}`, navigation)\n\t\t\tconst settled = await record.settle({ signal: context.signal, timeout: 0 })\n\t\t\tthis.#actions.set(context.signal, {\n\t\t\t\t...this.#actions.get(context.signal),\n\t\t\t\tstage: 'loaded',\n\t\t\t\t...(settled?.reason === undefined ? {} : { reason: settled.reason }),\n\t\t\t})\n\t\t\tconst action = `Navigated to ${result.url}`\n\t\t\treturn [\n\t\t\t\trenderBrowserReceipt({ action, view: await this.#capture(action, context.signal) }),\n\t\t\t\t'',\n\t\t\t]\n\t\t} finally {\n\t\t\tif (this.#navigating === page) this.#navigating = undefined\n\t\t\trecord.destroy()\n\t\t\tturn.resolve()\n\t\t}\n\t}\n\n\tasync #wait(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst text = readBrowserToolString(args, 'text')\n\t\tconst seconds = args['timeout']\n\t\tif (seconds !== undefined && (!isFiniteNumber(seconds) || seconds <= 0)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The timeout parameter must be a positive number of seconds.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'timeout' },\n\t\t\t)\n\t\t}\n\t\tconst timeout = Math.min(\n\t\t\tseconds === undefined ? BROWSER_TOOL_TIMEOUT_MS : Math.ceil(seconds * 1000),\n\t\t\tBROWSER_TOOL_TIMEOUT_LIMIT_MS,\n\t\t)\n\t\tconst quoted = JSON.stringify(text)\n\t\ttry {\n\t\t\tawait this.#race(\n\t\t\t\tthis.#cursor.wait(text, { timeout, signal: context.signal }),\n\t\t\t\t`Waited for ${quoted}`,\n\t\t\t\tcontext.signal,\n\t\t\t)\n\t\t\treturn [`${quoted} is on the page.`, '']\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\t!context.signal.aborted &&\n\t\t\t\tisBrowserError(error) &&\n\t\t\t\terror.code === 'BROWSER_WAIT_TIMEOUT'\n\t\t\t) {\n\t\t\t\tthis.#actions.set(context.signal, {\n\t\t\t\t\t...this.#actions.get(context.signal),\n\t\t\t\t\toutcome: 'timeout',\n\t\t\t\t})\n\t\t\t\treturn [`${quoted} did not appear within ${timeout / 1000} s.`, '']\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #dialog(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst accept = args['accept']\n\t\tconst text = args['text']\n\t\tif (!isBoolean(accept)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The accept parameter must be a boolean.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'accept' },\n\t\t\t)\n\t\t}\n\t\tif (text !== undefined && !isString(text)) {\n\t\t\tthrow new BrowserError('The text parameter must be a string.', 'BROWSER_TOOLSET_ARGUMENT', {\n\t\t\t\tkey: 'text',\n\t\t\t})\n\t\t}\n\t\tconst turn = await this.#acquire(context.signal, true)\n\t\ttry {\n\t\t\tconst page = this.#paged()\n\t\t\tconst dialog = this.#dialogs.get(page)\n\t\t\tif (dialog === undefined) {\n\t\t\t\tthrow new BrowserError('No dialog is open; call look.', 'BROWSER_TOOLSET_DIALOG')\n\t\t\t}\n\t\t\tcontext.signal.throwIfAborted()\n\t\t\tif (accept) await dialog.accept(text)\n\t\t\telse await dialog.dismiss()\n\t\t\tif (this.#dialogs.get(page) === dialog) this.#dialogs.delete(page)\n\t\t\tthis.#stage()\n\t\t\tconst action = `${accept ? 'Accepted' : 'Dismissed'} the ${dialog.category} dialog ${JSON.stringify(dialog.message)}`\n\t\t\treturn [\n\t\t\t\trenderBrowserReceipt({ action, view: await this.#capture(action, context.signal) }),\n\t\t\t\t'',\n\t\t\t]\n\t\t} finally {\n\t\t\tturn.resolve()\n\t\t}\n\t}\n\n\tasync #tabs(\n\t\t_args: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst tabs = await this.#list(context.signal, true)\n\t\treturn [\n\t\t\ttabs\n\t\t\t\t.map(\n\t\t\t\t\t(tab) =>\n\t\t\t\t\t\t`${tab.id} ${JSON.stringify(tab.title)} ${tab.url}${tab.current ? ' (current)' : ''}`,\n\t\t\t\t)\n\t\t\t\t.join('\\n'),\n\t\t\t'',\n\t\t]\n\t}\n\n\tasync #switch(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst tab = readBrowserToolString(args, 'tab')\n\t\tconst turn = await this.#acquire(context.signal)\n\t\ttry {\n\t\t\tconst pages = this.#context?.pages() ?? []\n\t\t\tconst match = /^t?([1-9]\\d*)$/i.exec(tab.trim())\n\t\t\tconst page = match === null ? undefined : pages[Number(match[1]) - 1]\n\t\t\tif (page === undefined) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Tab ${JSON.stringify(tab)} is not open; call tabs.`,\n\t\t\t\t\t'BROWSER_TOOLSET_TAB',\n\t\t\t\t\t{ tab },\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst action = `Switched to t${pages.indexOf(page) + 1} ${page.url}`\n\t\t\tthis.#actions.set(context.signal, {\n\t\t\t\t...this.#actions.get(context.signal),\n\t\t\t\ttab: { url: page.url, title: await page.title({ signal: context.signal }) },\n\t\t\t})\n\t\t\tawait this.#select(page)\n\t\t\tconst front = page.send('Page.bringToFront', undefined, { signal: context.signal })\n\t\t\tawait this.#command(front, action, front)\n\t\t\treturn [\n\t\t\t\trenderBrowserReceipt({ action, view: await this.#capture(action, context.signal) }),\n\t\t\t\t'',\n\t\t\t]\n\t\t} finally {\n\t\t\tturn.resolve()\n\t\t}\n\t}\n\n\tasync #invoke(\n\t\ttool: ToolInterface,\n\t\tsynthetic: boolean,\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst turn = await this.#acquire(context.signal)\n\t\ttry {\n\t\t\tconst input = synthetic\n\t\t\t\t? Object.fromEntries(Object.entries(args).filter(([key]) => key !== 'what'))\n\t\t\t\t: args\n\t\t\tconst command = Promise.resolve(tool.execute(input, context))\n\t\t\tconst output = await this.#command(command, `Called ${tool.name}`, command, context.signal)\n\t\t\treturn [renderBrowserToolOutput(output), '']\n\t\t} finally {\n\t\t\tturn.resolve()\n\t\t}\n\t}\n\n\t// Lists the context's tabs; `interruptible` lets a dialog that opens meanwhile end the `tabs`\n\t// tool with its receipt.\n\t#list(signal: AbortSignal, interruptible: boolean): Promise<readonly BrowserTab[]> {\n\t\tconst pages = this.#context?.pages() ?? []\n\t\treturn this.#race(\n\t\t\tPromise.all(pages.map((page, index) => this.#tab(page, index, signal))),\n\t\t\t'',\n\t\t\tsignal,\n\t\t\tinterruptible,\n\t\t)\n\t}\n\n\tasync #tab(page: BrowserPageInterface, index: number, signal: AbortSignal): Promise<BrowserTab> {\n\t\tconst title = await page\n\t\t\t.title({ signal, timeout: BROWSER_TOOL_TIMEOUT_MS })\n\t\t\t.catch((error: unknown) => {\n\t\t\t\t// A tab that does not answer its title is still listed.\n\t\t\t\tif (signal.aborted) throw error\n\t\t\t\treturn ''\n\t\t\t})\n\t\treturn { id: `t${index + 1}`, title, url: page.url, current: page === this.#page }\n\t}\n\n\t// Refuses while a dialog is open on the current page, naming the dialog.\n\t#refuseDialog(): void {\n\t\tconst dialog = this.#page === undefined ? undefined : this.#dialogs.get(this.#page)\n\t\tif (dialog !== undefined)\n\t\t\tthrow new BrowserError(renderBrowserReceipt({ action: '', dialog }), 'BROWSER_TOOLSET_DIALOG')\n\t}\n\n\tasync #choose(\n\t\telement: BrowserElementInterface,\n\t\ttext: string,\n\t\tsignal: AbortSignal,\n\t): Promise<boolean> {\n\t\ttry {\n\t\t\tawait element.select([text], { signal })\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\t// The combobox role also names a text input with a suggestion list, which the select\n\t\t\t// function refuses and which takes typed text instead.\n\t\t\tif (!isBrowserError(error) || !error.message.includes('not a select control')) throw error\n\t\t}\n\t\tawait element.fill(text, { signal })\n\t\treturn false\n\t}\n\n\t#element(value: unknown, signal: AbortSignal): BrowserElementInterface {\n\t\tconst reference = requireBrowserReference(value)\n\t\tconst element = this.#cursor.elements.element(reference)\n\t\tif (element === undefined) {\n\t\t\tthrow new BrowserElementError(\n\t\t\t\treference,\n\t\t\t\t'UNKNOWN',\n\t\t\t\t'is not in the current view; call look for fresh refs',\n\t\t\t)\n\t\t}\n\t\tconst frame = this.#page === undefined ? undefined : this.#resolveFrame(this.#page, reference)\n\t\tthis.#actions.set(signal, {\n\t\t\t...this.#actions.get(signal),\n\t\t\ttarget: {\n\t\t\t\trole: element.role,\n\t\t\t\tname: element.name,\n\t\t\t\treference: element.reference,\n\t\t\t\t...(frame === undefined || frame === this.#page?.id ? {} : { frame }),\n\t\t\t},\n\t\t})\n\t\treturn element\n\t}\n\n\t#paged(): BrowserPageInterface {\n\t\tif (this.#page === undefined) {\n\t\t\tthrow new BrowserError('This view has no page', 'BROWSER_TOOLSET_PAGE')\n\t\t}\n\t\treturn this.#page\n\t}\n\n\t// Waits for the action queue and for a command an earlier receipt left pending.\n\tasync #acquire(\n\t\tsignal: AbortSignal,\n\t\tanswer = false,\n\t\tholding = false,\n\t): Promise<PromiseWithResolvers<void>> {\n\t\tconst previous = this.#tail\n\t\tconst turn = Promise.withResolvers<void>()\n\t\tthis.#tail = previous.then(() => turn.promise)\n\t\ttry {\n\t\t\tawait this.#race(previous, '', signal, !answer)\n\t\t\tif (holding) this.#holdable()\n\t\t\tconst pending = this.#pending\n\t\t\tif (!answer && pending !== undefined) await this.#race(pending, '', signal, !answer)\n\t\t\tif (!answer && this.#pending === pending) this.#pending = undefined\n\t\t} catch (error) {\n\t\t\tturn.resolve()\n\t\t\tif (isBrowserError(error) && error.code === 'BROWSER_TOOLSET_RECEIPT') {\n\t\t\t\tthrow new BrowserError(error.message, 'BROWSER_TOOLSET_DIALOG')\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t\treturn turn\n\t}\n\n\t// Races an action's command against the start of a navigation in its frame or an ancestor, then\n\t// bounds the settlement of the navigation the action started and the view capture by one\n\t// deadline, of which the capture keeps `BROWSER_TOOL_CAPTURE_MS` for itself. A command that settles\n\t// first leaves a form submission's navigation to start later, so the observation's reads name the\n\t// destinations the record also waits for under the same deadline. The record selects and follows\n\t// the navigation; this method holds no frame, session, loader, or request state. `enter` marks an\n\t// action that pressed Enter to submit: `explicit` when the model asked for the submission whatever\n\t// the Enter's target, and the `action` line that replaces the attempt when a read recorded a\n\t// submission, or when the settled navigation's reason names a form submission, which a form in a\n\t// document the observer does not cover can start; a navigation with another reason or none does\n\t// not prove one. A popup the input opened is part of the settlement: after the navigation, the\n\t// popup record waits within the same bound for the popups its reports name, and the view moves to\n\t// the first open one before the capture, so the receipt carries the popup's view and the move.\n\tasync #settle(\n\t\tcommand: Promise<void>,\n\t\taction: string,\n\t\tsignal: AbortSignal,\n\t\ttrusted: boolean,\n\t\trecord?: BrowserNavigationRecordInterface,\n\t\tpopups?: BrowserPopupRecordInterface,\n\t\tobservation?: { readonly token: number; readonly frames: Set<BrowserFrameInterface> },\n\t\tenter?: { readonly explicit: boolean; readonly action: string },\n\t): Promise<string> {\n\t\tlet deadline: number | undefined\n\t\ttry {\n\t\t\t// A wait that ends without a start leaves the command to decide the race.\n\t\t\tconst started = record?.wait({ signal }).then(\n\t\t\t\t() => true,\n\t\t\t\t() => new Promise<boolean>(() => undefined),\n\t\t\t)\n\t\t\tconst input = command.then(() => false)\n\t\t\tconst first = await this.#command(\n\t\t\t\tstarted === undefined ? input : Promise.race([started, input]),\n\t\t\t\taction,\n\t\t\t\tcommand,\n\t\t\t)\n\t\t\tdeadline = performance.now() + BROWSER_TOOL_TIMEOUT_MS\n\t\t\tconst bound = deadline - BROWSER_TOOL_CAPTURE_MS\n\t\t\tif (first) this.#parkInput(command)\n\t\t\tconst submissions =\n\t\t\t\tfirst || observation === undefined\n\t\t\t\t\t? { destinations: [], prevented: false, submitted: undefined, implicit: false }\n\t\t\t\t\t: await this.#readSubmissions(observation, action, signal, bound)\n\t\t\tconst settled =\n\t\t\t\trecord === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: await this.#race(\n\t\t\t\t\t\t\trecord.settle({\n\t\t\t\t\t\t\t\tdestinations: submissions.destinations,\n\t\t\t\t\t\t\t\ttimeout: Math.max(0, bound - performance.now()),\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\taction,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t)\n\t\t\tsignal.throwIfAborted()\n\t\t\tconst opened =\n\t\t\t\tpopups === undefined\n\t\t\t\t\t? []\n\t\t\t\t\t: await this.#race(\n\t\t\t\t\t\t\tpopups.settle({ timeout: Math.max(0, bound - performance.now()), signal }),\n\t\t\t\t\t\t\taction,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t)\n\t\t\tsignal.throwIfAborted()\n\t\t\tconst popup = opened.find((page) => !page.closed)\n\t\t\tif (popup !== undefined) await this.#followPopup(popup, action, signal, bound)\n\t\t\tif (settled !== undefined)\n\t\t\t\tthis.#actions.set(signal, {\n\t\t\t\t\t...this.#actions.get(signal),\n\t\t\t\t\tstage: settled.stage,\n\t\t\t\t\t...(settled.reason === undefined ? {} : { reason: settled.reason }),\n\t\t\t\t})\n\t\t\t// Without a surviving destination and a navigation, the observer names what became of the\n\t\t\t// submission: a listener handled it, or no form received the Enter the action asked for.\n\t\t\tconst unmoved = settled === undefined && submissions.destinations.length === 0\n\t\t\tconst status =\n\t\t\t\tsettled?.stage === 'committed'\n\t\t\t\t\t? `the page is still loading ${settled.url}`\n\t\t\t\t\t: settled?.stage === 'requested'\n\t\t\t\t\t\t? `it requested ${settled.url} and the page did not change`\n\t\t\t\t\t\t: unmoved && submissions.prevented\n\t\t\t\t\t\t\t? BROWSER_TOOL_HANDLED_STATUS\n\t\t\t\t\t\t\t: unmoved &&\n\t\t\t\t\t\t\t\t submissions.submitted === false &&\n\t\t\t\t\t\t\t\t (enter?.explicit === true || (enter !== undefined && submissions.implicit))\n\t\t\t\t\t\t\t\t? 'no form received the submission'\n\t\t\t\t\t\t\t\t: undefined\n\t\t\tconst line =\n\t\t\t\tenter !== undefined &&\n\t\t\t\t(submissions.submitted === true ||\n\t\t\t\t\tsettled?.reason === 'formSubmissionGet' ||\n\t\t\t\t\tsettled?.reason === 'formSubmissionPost')\n\t\t\t\t\t? enter.action\n\t\t\t\t\t: action\n\t\t\treturn renderBrowserReceipt({\n\t\t\t\taction: line,\n\t\t\t\ttrusted,\n\t\t\t\t...(status === undefined ? {} : { status }),\n\t\t\t\tview: await this.#capture(line, signal, deadline),\n\t\t\t})\n\t\t} finally {\n\t\t\trecord?.destroy()\n\t\t\tif (observation !== undefined) await this.#unobserve(observation, signal, deadline)\n\t\t}\n\t}\n\n\t// Opens the popup record of an action into `page`; until the action ends, a popup the page\n\t// announces waits for the action, which moves the view itself.\n\t#recordPopups(page: BrowserPageInterface): BrowserPopupRecordInterface {\n\t\tconst popups = page.popups.record()\n\t\tthis.#arrivals = []\n\t\treturn popups\n\t}\n\n\t// Hands the popups announced during the action to the popup handler once the action ends, which\n\t// moves the view to none the action already moved it past.\n\t#flushArrivals(): void {\n\t\tconst arrivals = this.#arrivals ?? []\n\t\tthis.#arrivals = undefined\n\t\tfor (const [opener, popup] of arrivals) this.#handlePopup(opener, popup)\n\t}\n\n\t// Moves the view to a popup the action opened and records it as the action's tab; a title the\n\t// popup cannot answer within `bound` is empty.\n\tasync #followPopup(\n\t\tpopup: BrowserPageInterface,\n\t\taction: string,\n\t\tsignal: AbortSignal,\n\t\tbound: number,\n\t): Promise<void> {\n\t\tconst title = await this.#bounded(\n\t\t\tpopup.title({ signal }).catch((error: unknown) => {\n\t\t\t\tif (signal.aborted) throw error\n\t\t\t\treturn ''\n\t\t\t}),\n\t\t\tbound,\n\t\t\taction,\n\t\t\tsignal,\n\t\t)\n\t\tthis.#actions.set(signal, {\n\t\t\t...this.#actions.get(signal),\n\t\t\ttab: { url: popup.url, title: title ?? '' },\n\t\t})\n\t\tawait this.#select(popup, `The view moved to a new tab: ${popup.url}.`)\n\t}\n\n\t// Races a command that carries the signal itself; a dialog leaves it pending for the next\n\t// action to await.\n\tasync #command<T>(\n\t\tstep: Promise<T>,\n\t\taction: string,\n\t\tcommand: Promise<unknown>,\n\t\tsignal?: AbortSignal,\n\t): Promise<T> {\n\t\ttry {\n\t\t\treturn await this.#race(step, action, signal)\n\t\t} catch (error) {\n\t\t\tif (isBrowserError(error) && error.code === 'BROWSER_TOOLSET_RECEIPT')\n\t\t\t\tthis.#parkInput(command)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t#parkInput(command: Promise<unknown>): void {\n\t\tconst pending = command.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined,\n\t\t)\n\t\tthis.#pending = pending\n\t\tvoid pending.then(() => {\n\t\t\tif (this.#pending === pending) this.#pending = undefined\n\t\t})\n\t}\n\n\t// Returns the frame whose document receives an input on the referenced element: the frame the\n\t// element manager recorded for it, or the main frame.\n\t// Returns the reference of the one element of the current view that carries the target's role\n\t// and exact name; the stored reference and selector are evidence a developer reads, never a lookup.\n\tasync #resolveTarget(\n\t\tid: string,\n\t\ttarget: BrowserJourneyTarget,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<string> {\n\t\tconst name = target.name\n\t\tif (!isString(name))\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Step ${id} binds its target name to parameter ${JSON.stringify(name.parameter)}; pass the name itself.`,\n\t\t\t\t'BROWSER_JOURNEY_INPUT',\n\t\t\t\t{ step: id, parameter: name.parameter },\n\t\t\t)\n\t\tconst matches = await this.#cursor.elements.find(\n\t\t\t{ role: target.role, name, exact: true },\n\t\t\toptions,\n\t\t)\n\t\tconst [element] = matches\n\t\tif (matches.length === 1 && element !== undefined) return element.reference\n\t\tthrow new BrowserError(\n\t\t\t`Step ${id} names ${target.role} ${JSON.stringify(name)}, which ${matches.length === 0 ? 'no element carries' : `${matches.length} elements carry`}; call edit to remove or replace ${id}.`,\n\t\t\tmatches.length === 0 ? 'BROWSER_JOURNEY_TARGET' : 'BROWSER_JOURNEY_AMBIGUOUS',\n\t\t)\n\t}\n\n\t// Returns the id of the one open tab that carries the step's URL and title.\n\tasync #resolveTab(\n\t\tid: string,\n\t\ttab: BrowserJourneyTab,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<string> {\n\t\tconst matches = (await this.tabs(options)).filter(\n\t\t\t(candidate) => candidate.title === tab.title && candidate.url === tab.url,\n\t\t)\n\t\tconst [match] = matches\n\t\tif (matches.length === 1 && match !== undefined) return match.id\n\t\tthrow new BrowserError(\n\t\t\t`${id}: The tab ${JSON.stringify(tab.title)} at ${tab.url} ${matches.length === 0 ? 'is not open' : 'is ambiguous'}; call tabs.`,\n\t\t\tmatches.length === 0 ? 'BROWSER_JOURNEY_TARGET' : 'BROWSER_JOURNEY_AMBIGUOUS',\n\t\t)\n\t}\n\n\t#resolveFrame(page: BrowserPageInterface, reference: string): string {\n\t\treturn page.elements.element(reference)?.frame ?? page.id\n\t}\n\n\t// Lists the document of `frame` as one census lists it, whose isolated world the observer runs\n\t// in, or none.\n\tasync #locate(\n\t\tpage: BrowserPageInterface,\n\t\tframe: string,\n\t\tsignal: AbortSignal,\n\t): Promise<readonly BrowserFrameInterface[]> {\n\t\tconst frames = await this.#race(page.frames(), '', signal)\n\t\treturn frames.filter((candidate) => candidate.id === frame)\n\t}\n\n\t// Installs the observer the action's token owns in each of `frames` concurrently; the action owns\n\t// a document from the moment its installation is sent, so every exit removes it. The document of\n\t// `required` receives the input and must install, or the action is refused before any input;\n\t// another document's failure leaves it unobserved.\n\tasync #observe(\n\t\tframes: readonly BrowserFrameInterface[],\n\t\trequired: string,\n\t\tobservation: { readonly token: number; readonly frames: Set<BrowserFrameInterface> },\n\t\tsignal: AbortSignal,\n\t): Promise<void> {\n\t\tconst installs = frames.map((frame) => {\n\t\t\tobservation.frames.add(frame)\n\t\t\treturn this.#install(frame, observation.token, signal)\n\t\t})\n\t\tconst installed = await this.#race(Promise.all(installs), '', signal)\n\t\tif (!frames.some((frame, index) => frame.id === required && installed[index] === true))\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The action was not sent: frame ${required}, which receives the input, could not be observed for a form submission; call look.`,\n\t\t\t\t'BROWSER_TOOLSET_OBSERVE',\n\t\t\t\t{ frame: required },\n\t\t\t)\n\t}\n\n\tasync #install(\n\t\tframe: BrowserFrameInterface,\n\t\ttoken: number,\n\t\tsignal: AbortSignal,\n\t): Promise<boolean> {\n\t\ttry {\n\t\t\tawait frame.evaluate(compileSubmitObserverExpression(token), { signal })\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) throw error\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Reads every document the action still owns within `bound` and returns the destination of each\n\t// surviving submission, whether a listener prevented one, and whether an Enter reached an input\n\t// a form owns. `submitted` is true when any read recorded a submission, false when every\n\t// document answered and none did, and undefined otherwise; a read that fails or runs out of time\n\t// adds nothing, because the record already holds any navigation the input started in its frame\n\t// or an ancestor.\n\tasync #readSubmissions(\n\t\tobservation: { readonly token: number; readonly frames: Set<BrowserFrameInterface> },\n\t\taction: string,\n\t\tsignal: AbortSignal,\n\t\tbound: number,\n\t): Promise<{\n\t\treadonly destinations: readonly BrowserDestination[]\n\t\treadonly prevented: boolean\n\t\treadonly submitted: boolean | undefined\n\t\treadonly implicit: boolean\n\t}> {\n\t\tconst reads = await Promise.all(\n\t\t\t[...observation.frames].map((frame) =>\n\t\t\t\tthis.#readSubmission(frame, observation, action, signal, bound),\n\t\t\t),\n\t\t)\n\t\tconst answered = reads.flatMap((read) => (read === undefined ? [] : [read]))\n\t\treturn {\n\t\t\tdestinations: answered.flatMap((read) => read.destinations),\n\t\t\tprevented: answered.some((read) => read.prevented),\n\t\t\tsubmitted: answered.some((read) => read.submitted)\n\t\t\t\t? true\n\t\t\t\t: answered.length > 0 && answered.length === reads.length\n\t\t\t\t\t? false\n\t\t\t\t\t: undefined,\n\t\t\timplicit: answered.some((read) => read.implicit),\n\t\t}\n\t}\n\n\t// Returns undefined for a read that failed, ran out of time, found no observer to read, or\n\t// answered a record whose members are not the read's types, which leaves the outcome unknown.\n\tasync #readSubmission(\n\t\tframe: BrowserFrameInterface,\n\t\tobservation: { readonly token: number; readonly frames: Set<BrowserFrameInterface> },\n\t\taction: string,\n\t\tsignal: AbortSignal,\n\t\tbound: number,\n\t): Promise<\n\t\t| {\n\t\t\t\treadonly destinations: readonly BrowserDestination[]\n\t\t\t\treadonly prevented: boolean\n\t\t\t\treadonly submitted: boolean\n\t\t\t\treadonly implicit: boolean\n\t\t }\n\t\t| undefined\n\t> {\n\t\ttry {\n\t\t\tconst read = await this.#bounded(\n\t\t\t\tframe.evaluate(compileSubmitReadExpression(observation.token), { signal }),\n\t\t\t\tbound,\n\t\t\t\taction,\n\t\t\t\tsignal,\n\t\t\t)\n\t\t\t// A read that answered removed the observer, or found none to remove.\n\t\t\tif (read !== undefined) observation.frames.delete(frame)\n\t\t\tif (!isRecord(read)) return undefined\n\t\t\tconst { destinations, prevented, submitted, implicit } = read\n\t\t\tif (\n\t\t\t\t!isArray(destinations) ||\n\t\t\t\t!destinations.every(isString) ||\n\t\t\t\t!isBoolean(prevented) ||\n\t\t\t\t!isBoolean(submitted) ||\n\t\t\t\t!isBoolean(implicit)\n\t\t\t)\n\t\t\t\treturn undefined\n\t\t\treturn {\n\t\t\t\tdestinations: destinations\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t(relationship): relationship is BrowserDestinationRelationship =>\n\t\t\t\t\t\t\trelationship === 'self' || relationship === 'parent' || relationship === 'top',\n\t\t\t\t\t)\n\t\t\t\t\t.map((relationship) => ({ frame: frame.id, relationship })),\n\t\t\t\tprevented,\n\t\t\t\tsubmitted,\n\t\t\t\timplicit,\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (signal.aborted || (isBrowserError(error) && error.code === 'BROWSER_TOOLSET_RECEIPT')) {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\t}\n\n\t// Sends the removal of every observer the action still owns, without the action's signal, and\n\t// awaits it within the receipt's remaining deadline, or `BROWSER_TOOL_CAPTURE_MS` before the receipt\n\t// started one, unless the action's signal aborts the wait with its reason. A JavaScript dialog\n\t// blocks every evaluation until it is answered, and an aborted action ends at once, so neither\n\t// waits for the removal to land. The token keeps a late removal\n\t// from touching a later action's observer, and a replaced document took its observer with it.\n\tasync #unobserve(\n\t\tobservation: { readonly token: number; readonly frames: Set<BrowserFrameInterface> },\n\t\tsignal: AbortSignal,\n\t\tdeadline?: number,\n\t): Promise<void> {\n\t\tconst frames = [...observation.frames]\n\t\tobservation.frames.clear()\n\t\tif (frames.length === 0) return\n\t\tconst removal = Promise.allSettled(\n\t\t\tframes.map((frame) =>\n\t\t\t\tframe.evaluate(compileSubmitReadExpression(observation.token), {\n\t\t\t\t\ttimeout: BROWSER_TOOL_CAPTURE_MS,\n\t\t\t\t}),\n\t\t\t),\n\t\t)\n\t\tif (signal.aborted || (this.#page !== undefined && this.#dialogs.has(this.#page))) return\n\t\tawait this.#bounded(\n\t\t\tremoval,\n\t\t\tdeadline ?? performance.now() + BROWSER_TOOL_CAPTURE_MS,\n\t\t\t'',\n\t\t\tsignal,\n\t\t).catch((error: unknown) => {\n\t\t\tif (signal.aborted) throw error\n\t\t})\n\t}\n\n\t// Settles with the step, or rejects with the receipt naming a dialog that opens on the view\n\t// first, or with the signal's reason.\n\tasync #race<T>(\n\t\tstep: Promise<T>,\n\t\taction: string,\n\t\tsignal?: AbortSignal,\n\t\tinterruptible = true,\n\t): Promise<T> {\n\t\tconst interrupt = Promise.withResolvers<never>()\n\t\tconst abort = signal === undefined ? undefined : this.#abandon.bind(this, interrupt, signal)\n\t\tif (interruptible) this.#interrupts.set(interrupt, action)\n\t\tif (abort !== undefined) signal?.addEventListener('abort', abort, { once: true })\n\t\tif (signal?.aborted === true) interrupt.reject(signal.reason)\n\t\tconst dialog = this.#page === undefined ? undefined : this.#dialogs.get(this.#page)\n\t\tif (interruptible && dialog !== undefined) this.#interrupt(dialog)\n\t\ttry {\n\t\t\treturn await Promise.race([step, interrupt.promise])\n\t\t} finally {\n\t\t\tthis.#interrupts.delete(interrupt)\n\t\t\tif (abort !== undefined) signal?.removeEventListener('abort', abort)\n\t\t}\n\t}\n\n\t#abandon(interrupt: PromiseWithResolvers<never>, signal: AbortSignal): void {\n\t\tinterrupt.reject(signal.reason)\n\t}\n\n\t#interrupt(dialog: BrowserDialogInterface): void {\n\t\tfor (const [interrupt, action] of this.#interrupts) {\n\t\t\tinterrupt.reject(\n\t\t\t\tnew BrowserError(renderBrowserReceipt({ action, dialog }), 'BROWSER_TOOLSET_RECEIPT'),\n\t\t\t)\n\t\t}\n\t}\n\n\t// Races a step against a deadline inside the dialog and abort race; the deadline's timer is\n\t// cleared whenever that race settles, whichever branch wins.\n\tasync #bounded<T>(\n\t\tstep: Promise<T>,\n\t\tdeadline: number,\n\t\taction: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<T | undefined> {\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined\n\t\tconst lapse = new Promise<undefined>((resolve) => {\n\t\t\ttimer = setTimeout(resolve, Math.max(0, deadline - performance.now()), undefined)\n\t\t})\n\t\ttry {\n\t\t\treturn await this.#race(Promise.race([step, lapse]), action, signal)\n\t\t} finally {\n\t\t\tclearTimeout(timer)\n\t\t}\n\t}\n\n\t// Captures the view a receipt carries within the receipt's deadline; a capture that fails or\n\t// runs out of time is reported in the receipt, because the action it follows already\n\t// happened. An abort or a dialog still ends the receipt.\n\tasync #capture(\n\t\taction: string,\n\t\tsignal: AbortSignal,\n\t\tdeadline = performance.now() + BROWSER_TOOL_TIMEOUT_MS,\n\t): Promise<string> {\n\t\tif (deadline - performance.now() < 1) return BROWSER_TOOL_DEADLINE_NOTE\n\t\t// The capture belongs to the receipt: settling the receipt aborts it, so no readiness wait\n\t\t// or protocol call outlives the receipt. The deadline alone ends the capture; the outline's\n\t\t// own timeout sits past it, so a capture that runs out always reports the deadline note.\n\t\t// The outline carries the caller's signal, so an abort rejects with its pending protocol\n\t\t// entry's reason.\n\t\tconst receipt = new AbortController()\n\t\tconst options = {\n\t\t\tsignal: AbortSignal.any([signal, receipt.signal]),\n\t\t\ttimeout: BROWSER_TOOL_TIMEOUT_MS,\n\t\t}\n\t\ttry {\n\t\t\tconst outline = await this.#bounded(this.#cursor.elements.outline(options), deadline, action)\n\t\t\treturn outline === undefined ? BROWSER_TOOL_DEADLINE_NOTE : outline.text\n\t\t} catch (error) {\n\t\t\tif (signal.aborted || (isBrowserError(error) && error.code === 'BROWSER_TOOLSET_RECEIPT')) {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tif (!isBrowserElementError(error) || error.context?.['reason'] !== 'GONE') {\n\t\t\t\treturn `(The view could not be read: ${isError(error) ? error.message : String(error)}; call look.)`\n\t\t\t}\n\t\t\t// A navigation replaced the document mid-capture; the outline waits for the replacing\n\t\t\t// document's readiness before it reads once more, inside the same deadline.\n\t\t\ttry {\n\t\t\t\tconst outline = await this.#bounded(\n\t\t\t\t\tthis.#cursor.elements.outline(options),\n\t\t\t\t\tdeadline,\n\t\t\t\t\taction,\n\t\t\t\t)\n\t\t\t\treturn outline === undefined ? BROWSER_TOOL_DEADLINE_NOTE : outline.text\n\t\t\t} catch (retry) {\n\t\t\t\tif (signal.aborted || (isBrowserError(retry) && retry.code === 'BROWSER_TOOLSET_RECEIPT')) {\n\t\t\t\t\tthrow retry\n\t\t\t\t}\n\t\t\t\treturn BROWSER_TOOL_CHANGED_NOTE\n\t\t\t}\n\t\t} finally {\n\t\t\treceipt.abort(new BrowserError('the receipt settled', 'BROWSER_TOOLSET_SETTLED'))\n\t\t}\n\t}\n\n\t// Returns the pending move notes as a block that leads the next result, and forgets them.\n\t#drain(): string {\n\t\tconst notes = this.#notes.splice(0)\n\t\treturn notes.length === 0 ? '' : `${notes.join(' ')}\\n\\n`\n\t}\n\n\t// A failed startup lets a later `start()` try again, unless `destroy()` ended the toolset.\n\t#forget(starting: Promise<void>): void {\n\t\tif (this.#starting === starting && this.#destroying === undefined) this.#starting = undefined\n\t}\n\n\t#live(): void {\n\t\tif (this.#destroying !== undefined) throw this.#ended()\n\t}\n\n\t#ended(): BrowserError {\n\t\treturn new BrowserError('the browser session ended', 'BROWSER_TOOLSET_ENDED')\n\t}\n\n\t#current(generation: number, source: BrowserToolSourceInterface): boolean {\n\t\treturn (\n\t\t\tgeneration === this.#generation &&\n\t\t\tthis.#destroying === undefined &&\n\t\t\tsource === this.#following\n\t\t)\n\t}\n\n\t#add(tool: ToolInterface): void {\n\t\tthis.#added.add(tool)\n\t\tthis.#tools.add(tool)\n\t}\n\n\t#withdraw(tool: ToolInterface): void {\n\t\tif (this.#tools.tool(tool.name) === tool) this.#tools.remove(tool.name)\n\t\tthis.#added.delete(tool)\n\t}\n\n\t// Advertises `dialog` while the current page has an open dialog and the manager holds no other\n\t// tool under the name.\n\t#stage(): void {\n\t\tconst staged = this.#dialogTool\n\t\tif (staged === undefined || !this.#started || this.#destroying !== undefined) return\n\t\tconst open = this.#page !== undefined && this.#dialogs.has(this.#page)\n\t\tconst held = this.#tools.tool('dialog')\n\t\tif (open && held === undefined) this.#add(staged)\n\t\telse if (!open && held === staged) this.#withdraw(staged)\n\t}\n\n\t#listen(source: BrowserToolSourceInterface | undefined): void {\n\t\tthis.#following?.emitter.off('change', this.#changeHandler)\n\t\tthis.#following = source\n\t\tsource?.emitter.on('change', this.#changeHandler)\n\t}\n\n\tasync #select(page: BrowserPageInterface, note?: string): Promise<void> {\n\t\tif (this.#destroying !== undefined) return\n\t\tthis.#page = page\n\t\tthis.#generation += 1\n\t\tif (note !== undefined) this.#notes.push(note)\n\t\tthis.#stage()\n\t\tthis.#emitter.emit('select', page)\n\t\tif (this.#source === undefined) {\n\t\t\tfor (const tool of this.#adopted.values()) this.#withdraw(tool)\n\t\t\tthis.#adopted.clear()\n\t\t}\n\t\ttry {\n\t\t\tawait this.#watch(page)\n\t\t\tif (this.#source === undefined && this.#page === page) {\n\t\t\t\tthis.#listen(page.registry)\n\t\t\t\tawait page.registry.start()\n\t\t\t}\n\t\t} catch {\n\t\t\t// A page that closes while the view moves to it refuses the subscriptions; its close\n\t\t\t// event returns the view.\n\t\t\treturn\n\t\t}\n\t\tawait this.#adopt()\n\t}\n\n\t// Re-checks the lifecycle, the generation, and the source after every synchronous emission,\n\t// because a manager or toolset listener can re-enter.\n\tasync #adopt(): Promise<void> {\n\t\tconst source = this.#following\n\t\tif (source === undefined || this.#destroying !== undefined || !this.#started) return\n\t\tthis.#generation += 1\n\t\tconst generation = this.#generation\n\t\tlet adopted: readonly ToolInterface[]\n\t\ttry {\n\t\t\tadopted = await source.adopt()\n\t\t} catch {\n\t\t\t// A source whose page closed refuses to project; the page tools of its last projection\n\t\t\t// stay until the next change or move replaces them.\n\t\t\treturn\n\t\t}\n\t\tif (!this.#current(generation, source)) return\n\t\tconst census = source.tools?.()\n\t\tconst reasons = new Map<string, BrowserToolsetReason>()\n\t\tconst kept = new Map<\n\t\t\tstring,\n\t\t\t{ readonly tool: ToolInterface; readonly parameters: Readonly<Record<string, unknown>> }\n\t\t>()\n\t\tfor (const name of (census ?? []).map((tool) => tool.name)) {\n\t\t\tconst reason = reasons.has(name) ? undefined : this.#reason(name, census)\n\t\t\tif (reason !== undefined) reasons.set(name, reason)\n\t\t}\n\t\tfor (const tool of adopted) {\n\t\t\tif (reasons.has(tool.name) || kept.has(tool.name)) continue\n\t\t\tconst parameters = deriveBrowserToolSchema(tool.parameters)\n\t\t\tconst reason =\n\t\t\t\tthis.#reason(tool.name, census) ?? (parameters === undefined ? 'schema' : undefined)\n\t\t\tif (reason !== undefined) reasons.set(tool.name, reason)\n\t\t\telse if (parameters !== undefined) kept.set(tool.name, { tool, parameters })\n\t\t}\n\t\tfor (const [name, tool] of [...this.#adopted]) {\n\t\t\tif (kept.has(name)) continue\n\t\t\tthis.#adopted.delete(name)\n\t\t\tthis.#withdraw(tool)\n\t\t\tif (!this.#current(generation, source)) return\n\t\t}\n\t\tfor (const [name, { tool, parameters }] of kept) {\n\t\t\tconst held = this.#tools.tool(name)\n\t\t\tif (held !== undefined && !this.#added.has(held)) {\n\t\t\t\treasons.set(name, 'held')\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst handler = this.#invoke.bind(this, tool, parameters !== tool.parameters)\n\t\t\tconst wrapper = createTool({\n\t\t\t\tname,\n\t\t\t\t...(tool.title === undefined ? {} : { title: tool.title }),\n\t\t\t\t...(tool.description === undefined ? {} : { description: tool.description }),\n\t\t\t\t...(tool.summary === undefined ? {} : { summary: tool.summary }),\n\t\t\t\tparameters,\n\t\t\t\tannotations: { ...tool.annotations, untrusted: true },\n\t\t\t\texecute: this.#dispatch.bind(this, name, handler, BROWSER_TOOL_CUT_FOOTER),\n\t\t\t})\n\t\t\tthis.#handlers.set(wrapper, {\n\t\t\t\thandler,\n\t\t\t\tclause: BROWSER_TOOL_CUT_FOOTER,\n\t\t\t})\n\t\t\tthis.#adopted.set(name, wrapper)\n\t\t\tthis.#add(wrapper)\n\t\t\tif (!this.#current(generation, source)) return\n\t\t\tthis.#emitter.emit('adopt', wrapper)\n\t\t\tif (!this.#current(generation, source)) return\n\t\t}\n\t\tfor (const [name, reason] of reasons) {\n\t\t\tthis.#emitter.emit('skip', name, reason)\n\t\t\tif (!this.#current(generation, source)) return\n\t\t}\n\t}\n\n\t// Decides a skip by name, then by the registration the source selects for the name: the\n\t// current page's frame, then the earlier registration.\n\t#reason(\n\t\tname: string,\n\t\tcensus: readonly BrowserTool[] | undefined,\n\t): BrowserToolsetReason | undefined {\n\t\tif (\n\t\t\tname === 'unresolved' ||\n\t\t\tBROWSER_TOOL_NAMES.some((reserved) => reserved === name) ||\n\t\t\t(this.#journeys !== undefined &&\n\t\t\t\tBROWSER_JOURNEY_TOOL_NAMES.some((reserved) => reserved === name))\n\t\t)\n\t\t\treturn 'reserved'\n\t\tconst held = this.#tools.tool(name)\n\t\tif (held !== undefined && !this.#added.has(held)) return 'held'\n\t\tif (!BROWSER_TOOL_NAME_PATTERN.test(name)) return 'pattern'\n\t\tconst registrations = census?.filter((tool) => tool.name === name) ?? []\n\t\tconst selected = registrations.find((tool) => tool.frame === this.#page?.id) ?? registrations[0]\n\t\tif (selected === undefined) return undefined\n\t\tif (deriveBrowserToolSchema(selected.schema) === undefined) return 'schema'\n\t\tif (selected.annotation.debugging === true) return 'debugging'\n\t\treturn undefined\n\t}\n\n\tasync #watch(page: BrowserPageInterface): Promise<void> {\n\t\tif (this.#watches.has(page)) return\n\t\tconst watch: BrowserToolsetWatch = {\n\t\t\tdialog: this.#handleDialog.bind(this, page),\n\t\t\tpopup: this.#handlePopup.bind(this, page),\n\t\t\tclose: this.#handleClose.bind(this, page),\n\t\t\tclosed: this.#handleClosed.bind(this, page),\n\t\t}\n\t\tthis.#watches.set(page, watch)\n\t\tpage.emitter.on('dialog', watch.dialog)\n\t\tpage.emitter.on('popup', watch.popup)\n\t\tpage.emitter.on('close', watch.close)\n\t\tawait page.subscribe('Page.javascriptDialogClosed', watch.closed)\n\t\t// A watch removed while its subscriptions were landing releases what landed after.\n\t\tif (this.#watches.get(page) !== watch) await this.#release(page, watch)\n\t}\n\n\tasync #unwatch(page: BrowserPageInterface): Promise<void> {\n\t\tconst watch = this.#watches.get(page)\n\t\tif (watch === undefined) return\n\t\tthis.#watches.delete(page)\n\t\tawait this.#release(page, watch)\n\t}\n\n\tasync #release(page: BrowserPageInterface, watch: BrowserToolsetWatch): Promise<void> {\n\t\tpage.emitter.off('dialog', watch.dialog)\n\t\tpage.emitter.off('popup', watch.popup)\n\t\tpage.emitter.off('close', watch.close)\n\t\tawait page.unsubscribe('Page.javascriptDialogClosed', watch.closed)\n\t}\n\n\tasync #teardown(): Promise<void> {\n\t\t// The journey toolset goes first, so its replay releases its hold and writes its run while\n\t\t// the emitter and the manager still stand.\n\t\tawait this.#journeys?.destroy()\n\t\tthis.#reservation?.destroy()\n\t\tthis.#generation += 1\n\t\tthis.#lifetime.abort(this.#ended())\n\t\tthis.#listen(undefined)\n\t\tfor (const tool of [...this.#added]) this.#withdraw(tool)\n\t\tthis.#tools.emitter.off('remove', this.#removeHandler)\n\t\tthis.#tools.emitter.off('clear', this.#clearHandler)\n\t\tawait Promise.all([...this.#watches.keys()].map((page) => this.#unwatch(page)))\n\t\tthis.#dialogs.clear()\n\t\tthis.#adopted.clear()\n\t\tthis.#reading = undefined\n\t\tthis.#emitter.destroy()\n\t\tawait this.#owned?.()\n\t}\n\n\t#handleChange(): void {\n\t\tvoid this.#adopt()\n\t}\n\n\t#handleRemove(tool: ToolInterface): void {\n\t\tthis.#added.delete(tool)\n\t\tif (this.#adopted.get(tool.name) === tool) this.#adopted.delete(tool.name)\n\t}\n\n\t#handleClear(tools: readonly ToolInterface[]): void {\n\t\tfor (const tool of tools) this.#handleRemove(tool)\n\t}\n\n\t#handleDialog(page: BrowserPageInterface, dialog: BrowserDialogInterface): void {\n\t\tif (this.#navigating === page && dialog.category === 'beforeunload') {\n\t\t\t// `navigate` leaves the page at the model's request, so it answers the leave prompt; a\n\t\t\t// failed answer stages the dialog like any other.\n\t\t\tvoid dialog.accept().catch(this.#record.bind(this, page, dialog))\n\t\t\treturn\n\t\t}\n\t\tthis.#record(page, dialog)\n\t}\n\n\t#record(page: BrowserPageInterface, dialog: BrowserDialogInterface): void {\n\t\tthis.#dialogs.set(page, dialog)\n\t\tif (page !== this.#page) return\n\t\tthis.#stage()\n\t\tthis.#interrupt(dialog)\n\t}\n\n\t#handleClosed(page: BrowserPageInterface): void {\n\t\tthis.#dialogs.delete(page)\n\t\tif (page === this.#page) this.#stage()\n\t}\n\n\t// Follows a popup opened outside an action; one announced during an action that holds a popup\n\t// record waits for that action, and once the view moved to it, its opener is no longer the view.\n\t#handlePopup(opener: BrowserPageInterface, popup: BrowserPageInterface): void {\n\t\tif (opener !== this.#page || popup.closed) return\n\t\tif (this.#arrivals !== undefined) {\n\t\t\tthis.#arrivals = [...this.#arrivals, [opener, popup]]\n\t\t\treturn\n\t\t}\n\t\tvoid this.#select(popup, `The view moved to a new tab: ${popup.url}.`)\n\t}\n\n\t#handleClose(page: BrowserPageInterface): void {\n\t\tvoid this.#unwatch(page)\n\t\tthis.#dialogs.delete(page)\n\t\tconst origin = this.#origin\n\t\tif (page !== this.#page || origin === undefined || page === origin) return\n\t\tconst opener = page.opener\n\t\tconst target = opener !== undefined && !opener.closed ? opener : origin\n\t\tvoid this.#select(target, `The tab ${page.url} closed; the view returned to ${target.url}.`)\n\t}\n}\n"],"mappings":";;;;;;;;AAmBA,IAAa,eAAe;;AAG5B,IAAa,gBAAkD,OAAO,OAAO;CAC5E,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAA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,WAAW,MAAM;CACvB;CAEA,cAAc,MAAkC;EAC/C,KAAK,SAAS,OAAO,IAAI;EACzB,IAAI,SAAS,KAAK,OAAO,KAAK,OAAO;CACtC;CAIA,aAAa,QAA8B,OAAmC;EAC7E,IAAI,WAAW,KAAK,SAAS,MAAM,QAAQ;EAC3C,IAAI,KAAK,cAAc,KAAA,GAAW;GACjC,KAAK,YAAY,CAAC,GAAG,KAAK,WAAW,CAAC,QAAQ,KAAK,CAAC;GACpD;EACD;EACA,KAAU,QAAQ,OAAO,gCAAgC,MAAM,IAAI,EAAE;CACtE;CAEA,aAAa,MAAkC;EAC9C,KAAU,SAAS,IAAI;EACvB,KAAK,SAAS,OAAO,IAAI;EACzB,MAAM,SAAS,KAAK;EACpB,IAAI,SAAS,KAAK,SAAS,WAAW,KAAA,KAAa,SAAS,QAAQ;EACpE,MAAM,SAAS,KAAK;EACpB,MAAM,SAAS,WAAW,KAAA,KAAa,CAAC,OAAO,SAAS,SAAS;EACjE,KAAU,QAAQ,QAAQ,WAAW,KAAK,IAAI,gCAAgC,OAAO,IAAI,EAAE;CAC5F;AACD"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["isString","isInstance","attempt","isRecord","isString","isRecord","isString","isInteger","isBoolean","isFiniteNumber","parseJSONAs","isArray","attempt","parseEnum","parseArray","isString","isArray","isRecord","attempt","isInteger","isFiniteNumber","isBoolean","parseArray","parseEnum","isFunction","isJSONValue","isString","isArray","isRecord","Emitter","parseJSON","isRecord","isInteger","isString","isFiniteNumber","isRecord","Emitter","isRecord","isString","isInteger","isArray","createHTML","renderMarkdown","htmlToMarkdown","renderText","isRecord","isArray","isString","isError","isNumber","isInteger","isInteger","isRecord","isArray","isString","Emitter","createTool","isRecord","isString","isArray","isInteger","isString","Emitter","isRecord","isString","isRecord","isString","isInteger","isString","Emitter","Emitter","isRecord","isString","attempt","isFiniteNumber","isString","isInteger","Emitter","isError","isRecord","isFiniteNumber","isString","isInteger","isArray","attempt","Emitter","isRecord","isString","instanceOf","extractKeys","Emitter","Emitter","isString","createTool","attempt","isInteger","isString","isArray","isRecord","isInteger","createToolManager","Emitter","isArray","isString","cloneJSONRecord","isError","createTool","isBoolean","isFiniteNumber","isRecord"],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/validators.ts","../../../src/core/parsers.ts","../../../src/core/helpers.ts","../../../src/core/compilers.ts","../../../src/core/BrowserTransition.ts","../../../src/core/CDPClient.ts","../../../src/core/BrowserAccessibility.ts","../../../src/core/BrowserClock.ts","../../../src/core/BrowserCoverage.ts","../../../src/core/BrowserCookieManager.ts","../../../src/core/BrowserEmulationManager.ts","../../../src/core/recorders/BrowserCodegen.ts","../../../src/core/BrowserReading.ts","../../../src/core/elements/BrowserPageElement.ts","../../../src/core/elements/BrowserElementManager.ts","../../../src/core/BrowserRegistry.ts","../../../src/core/BrowserPerformance.ts","../../../src/core/BrowserProfiler.ts","../../../src/core/BrowserTracing.ts","../../../src/core/BrowserDiagnostics.ts","../../../src/core/BrowserDialog.ts","../../../src/core/BrowserDownload.ts","../../../src/core/BrowserHandle.ts","../../../src/core/BrowserFrame.ts","../../../src/core/BrowserFileChooser.ts","../../../src/core/BrowserKeyboard.ts","../../../src/core/BrowserMouse.ts","../../../src/core/BrowserTouch.ts","../../../src/core/BrowserHARManager.ts","../../../src/core/BrowserRoute.ts","../../../src/core/BrowserWebSocket.ts","../../../src/core/BrowserNetworkManager.ts","../../../src/core/BrowserNavigationRecord.ts","../../../src/core/BrowserNavigationManager.ts","../../../src/core/BrowserScriptManager.ts","../../../src/core/BrowserSnapshot.ts","../../../src/core/BrowserWorker.ts","../../../src/core/BrowserPage.ts","../../../src/core/BrowserPermissionManager.ts","../../../src/core/BrowserStorageManager.ts","../../../src/core/BrowserContext.ts","../../../src/core/BrowserHold.ts","../../../src/core/recorders/BrowserRecorder.ts","../../../src/core/BrowserReplay.ts","../../../src/core/stores/MemoryBrowserJourneyStore.ts","../../../src/core/stores/MemoryBrowserRunStore.ts","../../../src/core/factories.ts","../../../src/core/BrowserJourneyToolset.ts","../../../src/core/BrowserToolset.ts"],"sourcesContent":["import type { ToolDefinition } from '@orkestrel/tool'\nimport type {\n\tBrowserElementRefusal,\n\tBrowserJourney,\n\tBrowserMouseButton,\n\tBrowserNavigationReason,\n\tBrowserNavigationStage,\n\tBrowserStepOutcome,\n\tBrowserToolName,\n} from './types.js'\n\n// === Base64\n//\n// The lookup table is written out rather than computed from BASE64_CHARS at module scope:\n// constants.ts holds data, and a module-scope callback here is a placement violation the fleet\n// policy sweep rejects. Entry n of the table is BASE64_CHARS[n], and the whole-alphabet\n// round-trip in tests/src/core/helpers.test.ts fails on any single-entry disagreement.\n\n/** Holds the index-ordered base64 alphabet used to build {@link BASE64_LOOKUP}. */\nexport const BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\n\n/** Maps each base64 character to its 6-bit value, derived from {@link BASE64_CHARS}. */\nexport const BASE64_LOOKUP: Readonly<Record<string, number>> = Object.freeze({\n\tA: 0,\n\tB: 1,\n\tC: 2,\n\tD: 3,\n\tE: 4,\n\tF: 5,\n\tG: 6,\n\tH: 7,\n\tI: 8,\n\tJ: 9,\n\tK: 10,\n\tL: 11,\n\tM: 12,\n\tN: 13,\n\tO: 14,\n\tP: 15,\n\tQ: 16,\n\tR: 17,\n\tS: 18,\n\tT: 19,\n\tU: 20,\n\tV: 21,\n\tW: 22,\n\tX: 23,\n\tY: 24,\n\tZ: 25,\n\ta: 26,\n\tb: 27,\n\tc: 28,\n\td: 29,\n\te: 30,\n\tf: 31,\n\tg: 32,\n\th: 33,\n\ti: 34,\n\tj: 35,\n\tk: 36,\n\tl: 37,\n\tm: 38,\n\tn: 39,\n\to: 40,\n\tp: 41,\n\tq: 42,\n\tr: 43,\n\ts: 44,\n\tt: 45,\n\tu: 46,\n\tv: 47,\n\tw: 48,\n\tx: 49,\n\ty: 50,\n\tz: 51,\n\t'0': 52,\n\t'1': 53,\n\t'2': 54,\n\t'3': 55,\n\t'4': 56,\n\t'5': 57,\n\t'6': 58,\n\t'7': 59,\n\t'8': 60,\n\t'9': 61,\n\t'+': 62,\n\t'/': 63,\n})\n\n// === Browser\n\n/**\n * Sets the default timeout for browser connection, requests, and navigation, `30_000`\n * milliseconds.\n */\nexport const BROWSER_DEFAULT_TIMEOUT_MS = 30_000\n\n/**\n * Caps the serialized-character length for an `evaluate()`/`read()` result at `2_500_000`,\n * enforced in-page before the result is returned to CDP.\n *\n * @remarks\n * This counts UTF-16 string length (`String#length`), not transport bytes —\n * the actual CDP frame is UTF-8 encoded (up to 3 bytes/char for common\n * multibyte content) and carries additional JSON/CDP framing overhead on top\n * of the raw content. A `Runtime.evaluate` result above this size, once\n * framed as a CDP JSON response, overflows the native WebSocket inbound frame\n * limit and closes the whole CDP connection — a page-level failure with no\n * clean error. The limit is set well under the observed ~3-4MB transport\n * ceiling (rather than at it) to leave headroom for the length-vs-bytes gap\n * and framing overhead. The cap is enforced by stringifying the candidate\n * result in-page and throwing a recognizable sentinel error (see\n * {@link BROWSER_RESULT_LIMIT_SENTINEL_PREFIX}) before the oversized frame is\n * ever produced, so the caller gets a coded error instead of a dropped\n * connection.\n */\nexport const BROWSER_RESULT_LIMIT = 2_500_000\n\n/**\n * Names the distinctive prefix for the in-page result-limit sentinel error,\n * `'[[ORKESTREL_BROWSER_RESULT_LIMIT]]'`, immediately followed by the serialized length.\n *\n * @remarks\n * Deliberately unlikely to appear in a page's own thrown error text (unlike\n * a plain `BROWSER_RESULT_LIMIT: ` label), so {@link BROWSER_RESULT_LIMIT_PATTERN}\n * can distinguish the guard's own throw from a page error that merely\n * mentions similar text.\n */\nexport const BROWSER_RESULT_LIMIT_SENTINEL_PREFIX = '[[ORKESTREL_BROWSER_RESULT_LIMIT]]'\n\n/**\n * Matches the in-page result-limit sentinel error message, anchored immediately after the\n * `Error:` (optionally `Uncaught Error:`) prefix Chromium prepends to a thrown error's\n * description, `/^(?:Uncaught )?Error: \\[\\[ORKESTREL_BROWSER_RESULT_LIMIT\\]\\](\\d+)/`.\n *\n * @remarks\n * The anchor matches the guard's own throw only at the start of the message, rather than\n * wherever the substring happens to occur.\n */\nexport const BROWSER_RESULT_LIMIT_PATTERN = new RegExp(\n\t`^(?:Uncaught )?Error: \\\\[\\\\[ORKESTREL_BROWSER_RESULT_LIMIT\\\\]\\\\](\\\\d+)`,\n)\n\n/**\n * Sets the default maximum node count accepted from a decoded CDP DOM snapshot, `100_000`.\n */\nexport const BROWSER_SNAPSHOT_NODE_LIMIT = 100_000\n\n/** Names the isolated world used for iframe evaluation, `'__orkestrelBrowserFrame'`. */\nexport const BROWSER_FRAME_WORLD_NAME = '__orkestrelBrowserFrame'\n\n/** Sets the number of animation frames whose element bounds must agree before trusted input. */\nexport const BROWSER_STABLE_FRAME_COUNT = 2\n\n/** Maps a canonical modifier name to its CDP Input modifier bit value. */\nexport const BROWSER_KEY_MODIFIERS: Readonly<Record<string, number>> = Object.freeze({\n\tAlt: 1,\n\tControl: 2,\n\tMeta: 4,\n\tShift: 8,\n})\n\n/** Maps each public mouse button to its CDP Input pressed-button bit value. */\nexport const BROWSER_MOUSE_BUTTON_MASKS: Readonly<Record<BrowserMouseButton, number>> =\n\tObject.freeze({\n\t\tleft: 1,\n\t\tright: 2,\n\t\tmiddle: 4,\n\t\tback: 8,\n\t\tforward: 16,\n\t})\n\n/**\n * Names the tool identity embedded in HAR 1.2 documents.\n *\n * @remarks\n * `version` is this package's own released version. A parity test in\n * `tests/src/core/BrowserHARManager.test.ts` compares it against the manifest,\n * so the archive stamp cannot drift away from the release that wrote it.\n */\nexport const BROWSER_HAR_CREATOR = Object.freeze({\n\tname: '@orkestrel/browser',\n\tversion: '0.0.21',\n})\n\n/** Names the attribute that tags temporary screenshot styles and masks. */\nexport const BROWSER_SCREENSHOT_ATTRIBUTE = 'data-orkestrel-screenshot'\n\n/**\n * Lists every CDP `Page.ClientNavigationReason` value a page accepts as a navigation's reason, as\n * of Chromium 141; a page reads any other reason as undefined.\n */\nexport const BROWSER_NAVIGATION_REASONS: readonly BrowserNavigationReason[] = Object.freeze([\n\t'anchorClick',\n\t'formSubmissionGet',\n\t'formSubmissionPost',\n\t'httpHeaderRefresh',\n\t'initialFrameNavigation',\n\t'metaTagRefresh',\n\t'other',\n\t'pageBlockInterstitial',\n\t'reload',\n\t'scriptInitiated',\n])\n\n/**\n * Lists the CDP `Page.frameStartedNavigating` `navigationType` values that repeat or restore a\n * history entry rather than follow a request, as of Chromium 141.\n */\nexport const BROWSER_RELOAD_NAVIGATION_TYPES: readonly string[] = Object.freeze([\n\t'reload',\n\t'reloadBypassingCache',\n\t'restore',\n\t'restoreWithPost',\n\t'historySameDocument',\n\t'historyDifferentDocument',\n])\n\n/**\n * Names the isolated-world property that holds the `submit` observer an action installs before\n * its input, `'__orkestrelSubmit'`.\n */\nexport const BROWSER_SUBMIT_KEY = '__orkestrelSubmit'\n\n/**\n * Bounds the best-effort `Page.stopLoading` call issued after a failed `navigate()` at `1_000`\n * milliseconds.\n *\n * @remarks\n * A wedged renderer can make the underlying CDP call hang for the full\n * per-call timeout; capping it to a small fixed bound keeps a navigate\n * failure's total latency close to the original timeout instead of doubling\n * it. Best-effort only — never masks the original navigate error.\n */\nexport const BROWSER_STOP_LOADING_TIMEOUT_MS = 1_000\n\n/** Sets the default viewport width, `1280` pixels. */\nexport const BROWSER_DEFAULT_VIEWPORT_WIDTH = 1280\n\n/** Sets the default viewport height, `720` pixels. */\nexport const BROWSER_DEFAULT_VIEWPORT_HEIGHT = 720\n\n// === Browser codegen\n\n/**\n * Names the CDP runtime binding the codegen recorder script calls into,\n * `'__orkestrelBrowserCodegen'`.\n */\nexport const BROWSER_CODEGEN_BINDING_NAME = '__orkestrelBrowserCodegen'\n\n/**\n * Holds the self-contained document listener installed before a frame resumes.\n * Password input carries a marker; only Enter carries a key. Node indices are local to a document.\n */\nexport const BROWSER_CODEGEN_SOURCE = `(() => {\n\tconst binding = '__orkestrelBrowserCodegen'\n\twindow[binding + '__state']?.controller.abort()\n\tconst state = { controller: new AbortController(), nodes: [], indices: new WeakMap() }\n\twindow[binding + '__state'] = state\n\tfor (const event of ['click', 'input', 'change', 'keydown', 'focusout', 'submit', 'contextmenu', 'drop']) {\n\t\tdocument.addEventListener(event, (event) => {\n\t\t\tif (!event.isTrusted || typeof window[binding] !== 'function') return\n\t\t\tif (event.type === 'keydown' && event.key !== 'Enter') return\n\t\t\tconst element = event.composedPath()[0]\n\t\t\tif (!(element instanceof Element)) return\n\t\t\tlet index = state.indices.get(element)\n\t\t\tif (index === undefined) {\n\t\t\t\tindex = state.nodes.push(element) - 1\n\t\t\t\tstate.indices.set(element, index)\n\t\t\t}\n\t\t\tconst control = element.tagName === 'SELECT' ? (element.multiple ? 'multiple' : 'select')\n\t\t\t\t: element.tagName === 'OPTION' ? 'option'\n\t\t\t\t: element.tagName === 'INPUT' && element.type === 'password' ? 'password'\n\t\t\t\t: element.tagName === 'TEXTAREA' || element.isContentEditable ||\n\t\t\t\t\t(element.tagName === 'INPUT' && ['text', 'search', 'url', 'tel', 'email', 'number'].includes(element.type)) ? 'text' : 'other'\n\t\t\tconst payload = { event: event.type, index, top: window === window.top && element.ownerDocument === document, control, form: !!element.form }\n\t\t\tif (event.type === 'click') payload.detail = event.detail\n\t\t\tif (event.type === 'keydown') payload.key = 'Enter'\n\t\t\tif (event.type === 'input' && control === 'password') payload.secret = true\n\t\t\tif (event.type === 'input' && control === 'text') payload.value = element.isContentEditable ? element.textContent || '' : element.value\n\t\t\tif (event.type === 'change' && control === 'select') {\n\t\t\t\tpayload.value = element.value\n\t\t\t\tpayload.roundtrip = Array.from(element.options).find(option => option.value === element.value) === element.selectedOptions[0]\n\t\t\t}\n\t\t\tif (element.getRootNode() !== document) {\n\t\t\t\tpayload.event = 'unsupported'\n\t\t\t\tpayload.gap = 'the element is in a shadow root'\n\t\t\t} else if (event.type === 'contextmenu' || event.type === 'drop' || (event.type === 'click' && (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) && !['select', 'multiple', 'option'].includes(control))) {\n\t\t\t\tpayload.event = 'unsupported'\n\t\t\t\tpayload.gap = 'an unsupported gesture'\n\t\t\t}\n\t\t\twindow[binding](JSON.stringify(payload.event === 'unsupported' ? { event: payload.event, index, top: payload.top, control, form: payload.form, gap: payload.gap } : payload))\n\t\t}, { capture: true, signal: state.controller.signal })\n\t}\n})()`\n\n/** Identifies the CDP method-not-found response when WebMCP is absent. */\nexport const BROWSER_REGISTRY_ABSENT_CODE = -32601\n\n/** Bounds adopted tool JSON output and error messages to 4096 UTF-16 code units. */\nexport const BROWSER_REGISTRY_OUTPUT_LIMIT = 4096\n/** Prefixes stable element references within a browser context. */\nexport const BROWSER_REFERENCE_PREFIX = 'e'\n\n/** Bounds the default number of actionable elements in an outline. */\nexport const BROWSER_OUTLINE_LIMIT = 150\n\n/** Names accessibility roles that receive actionable outline references. */\nexport const BROWSER_INTERACTIVE_ROLES: ReadonlySet<string> = Object.freeze(\n\tnew Set([\n\t\t'button',\n\t\t'link',\n\t\t'textbox',\n\t\t'searchbox',\n\t\t'combobox',\n\t\t'listbox',\n\t\t'option',\n\t\t'checkbox',\n\t\t'radio',\n\t\t'switch',\n\t\t'slider',\n\t\t'spinbutton',\n\t\t'menuitem',\n\t\t'menuitemcheckbox',\n\t\t'menuitemradio',\n\t\t'tab',\n\t\t'treeitem',\n\t\t'DisclosureTriangle',\n\t\t'PopUpButton',\n\t\t'ColorWell',\n\t\t'Date',\n\t\t'DateTime',\n\t\t'Time',\n\t\t'InputTime',\n\t\t'Iframe',\n\t]),\n)\n\n/**\n * Maps the first line of each refusal the compiled element functions throw, without its `Error: `\n * prefix, to the reason and the one-line detail an element action reports it with.\n *\n * @remarks\n * `compileActionabilityFunction` throws the detached, not-visible, disabled, not-editable, and\n * pointer-event refusals; `compileSelectFunction` throws the text-control, select-control, and\n * missing-option refusals.\n */\nexport const BROWSER_ELEMENT_REFUSALS: ReadonlyMap<string, BrowserElementRefusal> = Object.freeze(\n\tnew Map<string, BrowserElementRefusal>([\n\t\t['Element is detached', { reason: 'GONE', detail: undefined }],\n\t\t['Element is not visible', { reason: 'HIDDEN', detail: 'is not visible' }],\n\t\t['Element is disabled', { reason: 'DISABLED', detail: 'is disabled' }],\n\t\t['Element is not editable', { reason: 'UNKNOWN', detail: 'is not editable' }],\n\t\t[\n\t\t\t'Element does not receive pointer events',\n\t\t\t{ reason: 'OCCLUDED', detail: 'does not receive pointer events' },\n\t\t],\n\t\t['Element is not a text control', { reason: 'UNKNOWN', detail: 'is not a text control' }],\n\t\t['Element is not a select control', { reason: 'UNKNOWN', detail: 'is not a select control' }],\n\t\t['Select option was not found', { reason: 'UNKNOWN', detail: 'has no such option' }],\n\t]),\n)\n\n/** Names accessibility roles whose own rows add no outline content. */\nexport const BROWSER_OUTLINE_OMITTED_ROLES: ReadonlySet<string> = Object.freeze(\n\tnew Set(['none', 'generic', 'InlineTextBox', 'RootWebArea', 'WebArea']),\n)\n\n/** Names accessibility roles rendered as text without an actionable reference. */\nexport const BROWSER_TEXT_ROLES: ReadonlySet<string> = Object.freeze(\n\tnew Set(['heading', 'StaticText']),\n)\n\n// === Browser toolset\n\n/**\n * Bounds each tool result and error message at `4_000` UTF-16 code units before its footer.\n *\n * @remarks\n * A page tool's error message and JSON output reach the toolset already cut at\n * {@link BROWSER_REGISTRY_OUTPUT_LIMIT}, so a toolset limit over that shows at most\n * `4_096` characters of either.\n */\nexport const BROWSER_TOOL_LIMIT = 4_000\n\n/**\n * Sets the `wait` tool's default and an action receipt's bound on a requested navigation,\n * `5_000` milliseconds.\n *\n * @remarks\n * The receipt's bound runs from the moment the receipt starts waiting for the requested\n * navigation, so the time an action spent queued and the load wait of an explicit `navigate`\n * precede it.\n */\nexport const BROWSER_TOOL_TIMEOUT_MS = 5_000\n\n/**\n * Reserves `1_000` milliseconds of an action receipt's `BROWSER_TOOL_TIMEOUT_MS` deadline for the\n * view capture, so a receipt whose navigation wait reaches its bound still carries the view.\n */\nexport const BROWSER_TOOL_CAPTURE_MS = 1_000\n\n/**\n * Holds the note an action receipt carries in place of the view when the receipt's deadline\n * passed before the view could be captured.\n */\nexport const BROWSER_TOOL_DEADLINE_NOTE =\n\t'(The view could not be read before the deadline; call look.)'\n\n/**\n * Holds the status an action receipt carries after a submission a page listener prevented, with no\n * navigation after it, naming `wait` as the next call because the page's outcome can arrive later.\n */\nexport const BROWSER_TOOL_HANDLED_STATUS =\n\t'the page handled the submission without navigating; call wait for the text you expect'\n\n/** Holds the refusal for a hold requested while an earlier input remains pending. */\nexport const BROWSER_TOOL_PENDING_NOTE = 'An earlier input is still pending; call look.'\n\n/** Names the tools that observe the view without recording an action. */\nexport const BROWSER_OBSERVATION_TOOL_NAMES: readonly string[] = Object.freeze([\n\t'look',\n\t'read',\n\t'tabs',\n])\n\n/**\n * Holds the note an action receipt carries in place of the view when the page changed under the\n * capture twice: once after the action, and again during the one retry that follows the page's\n * readiness.\n */\nexport const BROWSER_TOOL_CHANGED_NOTE =\n\t'(The page changed before the view could be read; call look.)'\n\n/**\n * Holds the clause that ends the footer of a cut result that carries no view: a read note, a tab\n * list, a wait, a page tool's output, or an error message.\n */\nexport const BROWSER_TOOL_CUT_FOOTER = 'the rest was cut'\n\n/**\n * Holds the clause that ends the footer of a cut result that carries a view, the result of\n * `look` and of every action, and names `read` as the call that returns the page's text.\n */\nexport const BROWSER_TOOL_VIEW_FOOTER = \"the rest was cut; call read for the page's text\"\n\n/**\n * Names the accessibility roles the `type` tool writes to: `textbox`, `searchbox`, and\n * `spinbutton` take typed text, and `combobox` and `listbox` take a select control's option\n * or, for a text input with suggestions, typed text.\n *\n * @remarks\n * The set names the roles the tool admits, not every element that accepts text: an element\n * with another explicit role can still accept text through its element contract. Chromium\n * 141.0.7390.37 reports a `contenteditable` region without an explicit role as `generic`, which\n * the outline gives no reference.\n */\nexport const BROWSER_TYPED_ROLES: ReadonlySet<string> = Object.freeze(\n\tnew Set(['textbox', 'searchbox', 'spinbutton', 'combobox', 'listbox']),\n)\n\n/** Caps the `wait` tool's `timeout` parameter at `30_000` milliseconds. */\nexport const BROWSER_TOOL_TIMEOUT_LIMIT_MS = 30_000\n\n/**\n * Names every tool the browser toolset reserves: `look`, `read`, `click`, `type`, `press`,\n * `navigate`, `wait`, `dialog`, `tabs`, and `switch`.\n */\nexport const BROWSER_TOOL_NAMES: readonly BrowserToolName[] = Object.freeze([\n\t'look',\n\t'read',\n\t'click',\n\t'type',\n\t'press',\n\t'navigate',\n\t'wait',\n\t'dialog',\n\t'tabs',\n\t'switch',\n])\n\n/**\n * Matches a page tool name the toolset can advertise: 1 to 64 ASCII letters, digits,\n * underscores, and hyphens.\n *\n * @remarks\n * The pattern is the narrowest of the tool-name rules of the providers the fleet targets. The\n * Anthropic Messages API tool definition requires a `name` matching `^[a-zA-Z0-9_-]{1,64}$`, and\n * the OpenAI function-calling definition requires a function `name` of letters, digits,\n * underscores, and dashes, at most 64 characters long. The WebMCP specification draft allows a\n * period and up to 128 code points (the guide's \"Declared conformance gaps\" section), so a page tool\n * named `a.b` or one longer than 64 characters is skipped with the reason `pattern`.\n */\nexport const BROWSER_TOOL_NAME_PATTERN = /^[A-Za-z0-9_-]{1,64}$/\n\n/** Names the URL schemes the `navigate` tool accepts by default: `http:` and `https:`. */\nexport const BROWSER_SCHEMES: readonly string[] = Object.freeze(['http:', 'https:'])\n\n/**\n * Holds the advertised definition of each reserved tool: its description, its JSON Schema\n * parameters, and its annotations.\n *\n * @remarks\n * Every tool description is at most 25 words and says what the tool shows or does, and for\n * `look` and `read` when to call it; every parameter description is at most 100 characters.\n * Every tool declares at least one required parameter, because the streamed tool-call parser of\n * Ollama 0.34.4 rejects a call to a tool that declares no parameter. `look` takes `what` alone\n * and `read` takes `what` and `offset`; neither is scoped to an element, and an element's own\n * reading is `BrowserElementInterface.read`. `look`, `read`, and `journeys` annotate `pure` and\n * `untrusted`, `wait` and `tabs` annotate `pure`, and the rest carry no annotation. `type` takes\n * `secret` beside `ref`, `text`, and `submit`. The journey tools `record`, `save`, `journeys`,\n * `edit`, and `replay` are advertised only by a toolset constructed with `journeys`.\n */\nexport const BROWSER_TOOL_COPY: Readonly<Record<BrowserToolName, ToolDefinition>> = Object.freeze({\n\tlook: Object.freeze({\n\t\tname: 'look',\n\t\tdescription:\n\t\t\t\"Shows the page's text and the elements you can act on, each with a reference like e4. Call it first and after the page changes.\",\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\twhat: Object.freeze({ type: 'string', description: 'What you want to find or act on.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['what']),\n\t\t}),\n\t\tannotations: Object.freeze({ pure: true, untrusted: true }),\n\t}),\n\tread: Object.freeze({\n\t\tname: 'read',\n\t\tdescription:\n\t\t\t\"Reads the page's text for what you name. Call it to learn a fact; continue with the offset a cut result names.\",\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\twhat: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'What you want to learn from the page.',\n\t\t\t\t}),\n\t\t\t\toffset: Object.freeze({\n\t\t\t\t\ttype: 'integer',\n\t\t\t\t\tdescription: 'The character to continue from, as the last reply names. Default: 0.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['what']),\n\t\t}),\n\t\tannotations: Object.freeze({ pure: true, untrusted: true }),\n\t}),\n\tclick: Object.freeze({\n\t\tname: 'click',\n\t\tdescription: 'Clicks the element with that reference.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tref: Object.freeze({ type: 'string', description: 'The reference, such as e4.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['ref']),\n\t\t}),\n\t}),\n\ttype: Object.freeze({\n\t\tname: 'type',\n\t\tdescription:\n\t\t\t'Types into the text control with that reference; set submit to true to submit its form.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tref: Object.freeze({ type: 'string', description: 'The reference, such as e4.' }),\n\t\t\t\ttext: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The text to type or the option to choose.',\n\t\t\t\t}),\n\t\t\t\tsubmit: Object.freeze({\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdescription: 'True to submit its form after typing.',\n\t\t\t\t}),\n\t\t\t\tsecret: Object.freeze({\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdescription: 'True to keep the text out of the receipt, such as a password.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['ref', 'text']),\n\t\t}),\n\t}),\n\tpress: Object.freeze({\n\t\tname: 'press',\n\t\tdescription: 'Presses that key or chord, such as Enter or Control+a.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tkey: Object.freeze({ type: 'string', description: 'The key or chord, such as Enter.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['key']),\n\t\t}),\n\t}),\n\tnavigate: Object.freeze({\n\t\tname: 'navigate',\n\t\tdescription: 'Opens that absolute web address in the current tab.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\turl: Object.freeze({ type: 'string', description: 'The absolute http or https address.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['url']),\n\t\t}),\n\t}),\n\twait: Object.freeze({\n\t\tname: 'wait',\n\t\tdescription: 'Waits for that text to appear on the page.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\ttext: Object.freeze({ type: 'string', description: 'The text to wait for.' }),\n\t\t\t\ttimeout: Object.freeze({\n\t\t\t\t\ttype: 'integer',\n\t\t\t\t\tdescription: 'The most seconds to wait, at most 30. Default: 5.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['text']),\n\t\t}),\n\t\tannotations: Object.freeze({ pure: true }),\n\t}),\n\tdialog: Object.freeze({\n\t\tname: 'dialog',\n\t\tdescription: 'Accepts or dismisses the open dialog.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\taccept: Object.freeze({\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdescription: 'True to accept the dialog; false to dismiss it.',\n\t\t\t\t}),\n\t\t\t\ttext: Object.freeze({ type: 'string', description: 'The answer to a prompt dialog.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['accept']),\n\t\t}),\n\t}),\n\ttabs: Object.freeze({\n\t\tname: 'tabs',\n\t\tdescription: 'Lists the open tabs; the current one is marked.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\twhat: Object.freeze({ type: 'string', description: 'What you are looking for.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['what']),\n\t\t}),\n\t\tannotations: Object.freeze({ pure: true }),\n\t}),\n\tswitch: Object.freeze({\n\t\tname: 'switch',\n\t\tdescription: 'Switches to a tab from tabs, such as t2.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\ttab: Object.freeze({ type: 'string', description: 'The tab, such as t2.' }),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['tab']),\n\t\t}),\n\t}),\n\trecord: Object.freeze({\n\t\tname: 'record',\n\t\tdescription:\n\t\t\t'Starts recording your next actions as a journey with that name; call save when it is done.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tjourney: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The journey name: lowercase words joined by hyphens, such as add-kettle.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['journey']),\n\t\t}),\n\t}),\n\tsave: Object.freeze({\n\t\tname: 'save',\n\t\tdescription:\n\t\t\t'Stops recording and saves the journey; describe what it achieves in one sentence.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tdescription: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'What the journey achieves, in one sentence.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['description']),\n\t\t}),\n\t}),\n\tjourneys: Object.freeze({\n\t\tname: 'journeys',\n\t\tdescription: 'Lists the saved journeys with their steps and the parameters each one takes.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\twhat: Object.freeze({ type: 'string', description: 'What you are looking for.' }),\n\t\t\t\toffset: Object.freeze({\n\t\t\t\t\ttype: 'integer',\n\t\t\t\t\tdescription: 'The character to continue from, as the last reply names. Default: 0.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['what']),\n\t\t}),\n\t\tannotations: Object.freeze({ pure: true, untrusted: true }),\n\t}),\n\tedit: Object.freeze({\n\t\tname: 'edit',\n\t\tdescription:\n\t\t\t'Changes a saved journey: add, remove, or update steps by their ids from journeys, or declare a parameter.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tjourney: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The journey name, such as add-kettle.',\n\t\t\t\t}),\n\t\t\t\tedits: Object.freeze({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'The changes, as an array or a JSON string of the array, applied in order; one invalid change refuses them all.',\n\t\t\t\t\tanyOf: Object.freeze([\n\t\t\t\t\t\tObject.freeze({\n\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\titems: Object.freeze({\n\t\t\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\t\t\tproperties: Object.freeze({\n\t\t\t\t\t\t\t\t\toperation: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tenum: Object.freeze(['add', 'remove', 'update', 'declare']),\n\t\t\t\t\t\t\t\t\t\tdescription: 'What the change does.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tid: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The step to remove or update, such as s3.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tstep: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The step to add: its action, its arguments, and ref or tab.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tbefore: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The step to add it before, such as s3.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tafter: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The step to add it after, such as s3.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tref: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The element the added or updated step acts on, such as e4.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\targuments: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The arguments to change, merged by key.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tname: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The parameter to declare, such as email.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tparameter: Object.freeze({\n\t\t\t\t\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\t\t\t\t\tdescription: 'The parameter: its default, or secret set to true.',\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\trequired: Object.freeze(['operation']),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tObject.freeze({ type: 'string' }),\n\t\t\t\t\t]),\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['journey', 'edits']),\n\t\t}),\n\t}),\n\treplay: Object.freeze({\n\t\tname: 'replay',\n\t\tdescription: \"Replays a saved journey step by step; give each parameter's value under inputs.\",\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tjourney: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The journey name, such as add-kettle.',\n\t\t\t\t}),\n\t\t\t\tinputs: Object.freeze({\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\tdescription: \"Each parameter's value by its name.\",\n\t\t\t\t\tadditionalProperties: Object.freeze({ type: 'string' }),\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['journey']),\n\t\t}),\n\t}),\n\tforget: Object.freeze({\n\t\tname: 'forget',\n\t\tdescription: 'Removes a saved journey and all its runs; the name is free to record again.',\n\t\tparameters: Object.freeze({\n\t\t\ttype: 'object',\n\t\t\tproperties: Object.freeze({\n\t\t\t\tjourney: Object.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The journey name, such as add-kettle.',\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trequired: Object.freeze(['journey']),\n\t\t}),\n\t}),\n})\n\n// === Browser journeys\n\n/**\n * Matches a journey name: lowercase letters and digits in words joined by single hyphens, at most\n * 64 characters, and never a Windows reserved device name.\n *\n * @remarks\n * A journey's name is its directory under the store's root, so the pattern refuses `con`, `prn`,\n * `aux`, `nul`, `com1` to `com9`, and `lpt1` to `lpt9`, which a Windows host refuses as a path\n * segment.\n */\nexport const BROWSER_JOURNEY_NAME_PATTERN =\n\t/^(?=.{1,64}$)(?!(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$)[a-z0-9]+(?:-[a-z0-9]+)*$/\n\n/** Matches a journey parameter name: a lowercase letter followed by letters and digits. */\nexport const BROWSER_JOURNEY_PARAMETER_PATTERN = /^[a-z][a-zA-Z0-9]*$/\n\n/** Matches a run id containing an ISO timestamp with hyphenated time and a hexadecimal suffix. */\nexport const BROWSER_RUN_ID_PATTERN = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}\\.\\d{3}Z-[a-f0-9]{4}$/\n\n/** Holds the journey and run file format this package writes and reads, `1`. */\nexport const BROWSER_JOURNEY_FORMAT_VERSION: BrowserJourney['format'] = 1\n\n/**\n * Names the native actions a journey step can hold: `click`, `type`, `press`, `navigate`, `wait`,\n * `dialog`, and `switch`.\n *\n * @remarks\n * A step's action is one of these, an adopted page tool's name, or `unresolved`.\n */\nexport const BROWSER_JOURNEY_ACTIONS: readonly BrowserToolName[] = Object.freeze([\n\t'click',\n\t'type',\n\t'press',\n\t'navigate',\n\t'wait',\n\t'dialog',\n\t'switch',\n])\n\n/**\n * Lists every outcome a `BrowserAction` and a run step carry: `done`, `refused`, `timeout`, and\n * `interrupted`.\n */\nexport const BROWSER_ACTION_OUTCOMES: readonly BrowserStepOutcome[] = Object.freeze([\n\t'done',\n\t'refused',\n\t'timeout',\n\t'interrupted',\n])\n\n/**\n * Lists every navigation stage a `BrowserAction` and a run step carry: `requested`, `committed`,\n * and `loaded`.\n */\nexport const BROWSER_ACTION_STAGES: readonly BrowserNavigationStage[] = Object.freeze([\n\t'requested',\n\t'committed',\n\t'loaded',\n])\n\n/** Holds the result the `journeys` tool returns when no journey is saved. */\nexport const BROWSER_JOURNEY_EMPTY_LISTING = 'No journeys are saved; call record to start one.'\n\n/**\n * Names the journey tools a toolset constructed with `journeys` registers and reserves: `record`,\n * `save`, `journeys`, `edit`, `replay`, and `forget`.\n */\nexport const BROWSER_JOURNEY_TOOL_NAMES: readonly BrowserToolName[] = Object.freeze([\n\t'record',\n\t'save',\n\t'journeys',\n\t'edit',\n\t'replay',\n\t'forget',\n])\n\n/** Names observation and journey tools that cannot become journey steps. */\nexport const BROWSER_JOURNEY_NON_STEP_TOOLS: readonly string[] = Object.freeze([\n\t...BROWSER_OBSERVATION_TOOL_NAMES,\n\t...BROWSER_JOURNEY_TOOL_NAMES,\n])\n\n/** Names native tool arguments represented by journey targets, tabs, or secret bindings. */\nexport const BROWSER_JOURNEY_STEP_KEYS: readonly string[] = Object.freeze(['ref', 'tab', 'secret'])\n\n/** Holds the refusal `record`, `save`, `edit`, and `forget` return when the journeys are read-only. */\nexport const BROWSER_JOURNEY_READONLY_REFUSAL = 'The journeys are read-only; call replay.'\n\n/** Holds the refusal `record` returns while another journey is recording. */\nexport const BROWSER_JOURNEY_RECORDING_REFUSAL = 'A journey is recording; call save first.'\n\n/** Holds the refusal `save` returns when no journey is recording. */\nexport const BROWSER_JOURNEY_IDLE_REFUSAL =\n\t'No journey is recording, so nothing can be saved; answer the user. A journey holds only the actions after record, so call record before them.'\n","import type { BrowserAction, BrowserElementReason, BrowserElementSubject } from './types.js'\nimport { isInstance, isString } from '@orkestrel/contract'\n\n// === Browser errors\n\n/**\n * Represents the base error for all browser automation operations, carrying the code\n * `BROWSER_ERROR` and a `context` record.\n *\n * @remarks\n * A caller branches in a `catch` on the `code` rather than parsing message strings.\n */\nexport class BrowserError extends Error {\n\treadonly code: string\n\treadonly context: Readonly<Record<string, unknown>> | undefined\n\n\tconstructor(\n\t\tmessage: string,\n\t\tcode = 'BROWSER_ERROR',\n\t\tcontext?: Readonly<Record<string, unknown>>,\n\t) {\n\t\tsuper(message)\n\t\tthis.name = 'BrowserError'\n\t\tthis.code = code\n\t\tthis.context = context\n\t}\n}\n\n/**\n * Reports a refused element operation with a reason and, for `GONE`, the refresh directive.\n *\n * @remarks\n * The message names the element and the detail on one line. It ends with\n * `; call look for fresh refs.` for `GONE` alone, because only a changed page makes a fresh\n * reference the remedy; every other reason ends the message with a period, and a caller whose\n * refusal a fresh reference does fix names that remedy in its detail.\n */\nexport class BrowserElementError extends BrowserError {\n\tconstructor(\n\t\treference: string | BrowserElementSubject,\n\t\treason: BrowserElementReason,\n\t\tdetail?: string,\n\t) {\n\t\tconst subject = isString(reference) ? `Element ${reference}` : reference.subject\n\t\tconst text =\n\t\t\tdetail ??\n\t\t\t(reason === 'GONE'\n\t\t\t\t? 'is gone because the page changed'\n\t\t\t\t: reason === 'UNTRUSTED'\n\t\t\t\t\t? 'needs a trusted event'\n\t\t\t\t\t: reason.toLowerCase())\n\t\tsuper(\n\t\t\t`${subject} ${text}${reason === 'GONE' ? '; call look for fresh refs.' : '.'}`,\n\t\t\t'BROWSER_ELEMENT_ERROR',\n\t\t\tisString(reference) ? { reference, reason } : { subject: reference.subject, reason },\n\t\t)\n\t\tthis.name = 'BrowserElementError'\n\t}\n}\n\n/**\n * Checks whether a value is an element refusal.\n * @param value - Caught value\n * @returns True if the value is an element error; false otherwise\n */\nexport function isBrowserElementError(value: unknown): value is BrowserElementError {\n\treturn isInstance(value, BrowserElementError)\n}\n\n/**\n * Reports a journey step whose action did not complete, under the code `BROWSER_STEP_ERROR`, with\n * the performed action in `action`.\n *\n * @remarks\n * The message is `ID: RECEIPT`, where `ID` is the step's id and `RECEIPT` the action's receipt, and\n * `context` names the step under `step`. A caller reads the outcome, stage, reason, receipt, and\n * elapsed time from `action` rather than from the message.\n */\nexport class BrowserStepError extends BrowserError {\n\treadonly action: BrowserAction\n\n\tconstructor(id: string, action: BrowserAction) {\n\t\tsuper(`${id}: ${action.receipt}`, 'BROWSER_STEP_ERROR', { step: id })\n\t\tthis.name = 'BrowserStepError'\n\t\tthis.action = action\n\t}\n}\n\n/**\n * Checks whether a value is a journey step error.\n * @param value - Caught value\n * @returns True if the value is a step error; false otherwise\n */\nexport function isBrowserStepError(value: unknown): value is BrowserStepError {\n\treturn isInstance(value, BrowserStepError)\n}\n\n/**\n * Reports that a CDP request received an error response from the remote endpoint, under the\n * code `BROWSER_CDP_ERROR`, with the `method`, the CDP `code`, the `message`, and any `data`\n * in its context.\n *\n * @remarks\n * Branch on the protocol-level error in `context` instead of parsing the message string.\n */\nexport class CDPError extends BrowserError {\n\tconstructor(message: string, context?: Readonly<Record<string, unknown>>) {\n\t\tsuper(message, 'BROWSER_CDP_ERROR', context)\n\t\tthis.name = 'CDPError'\n\t}\n}\n\n/**\n * Reports that a CDP request could not be sent or completed because the client was not in a\n * connectable state — not connected, closed while connecting, or the connection dropped\n * mid-request — under the code `BROWSER_CDP_CONNECTION_ERROR`.\n */\nexport class CDPConnectionError extends BrowserError {\n\tconstructor(message: string, context?: Readonly<Record<string, unknown>>) {\n\t\tsuper(message, 'BROWSER_CDP_CONNECTION_ERROR', context)\n\t\tthis.name = 'CDPConnectionError'\n\t}\n}\n\n/**\n * Reports that a pending CDP request was not answered within its timeout window, under the\n * code `BROWSER_CDP_TIMEOUT_ERROR`.\n */\nexport class CDPTimeoutError extends BrowserError {\n\tconstructor(message: string, context?: Readonly<Record<string, unknown>>) {\n\t\tsuper(message, 'BROWSER_CDP_TIMEOUT_ERROR', context)\n\t\tthis.name = 'CDPTimeoutError'\n\t}\n}\n\n/**\n * Reports that an `evaluate()`/`read()` result exceeded {@link BROWSER_RESULT_LIMIT} and\n * was rejected in-page before it could overflow the CDP transport frame, under the code\n * `BROWSER_RESULT_LIMIT_ERROR`.\n */\nexport class BrowserResultLimitError extends BrowserError {\n\tconstructor(message: string, context?: Readonly<Record<string, unknown>>) {\n\t\tsuper(message, 'BROWSER_RESULT_LIMIT_ERROR', context)\n\t\tthis.name = 'BrowserResultLimitError'\n\t}\n}\n\n// === Browser type guards\n\n/**\n * Narrows an unknown value to a `BrowserError`.\n *\n * @param value - Value to check\n * @returns True if value is a BrowserError instance; false otherwise\n */\nexport function isBrowserError(value: unknown): value is BrowserError {\n\treturn isInstance(value, BrowserError)\n}\n\n/**\n * Narrows an unknown value to a `CDPError`.\n *\n * @param value - Value to check\n * @returns True if value is a CDPError instance; false otherwise\n */\nexport function isCDPError(value: unknown): value is CDPError {\n\treturn isInstance(value, CDPError)\n}\n\n/**\n * Narrows an unknown value to a `CDPConnectionError`.\n *\n * @param value - Value to check\n * @returns True if value is a CDPConnectionError instance; false otherwise\n */\nexport function isCDPConnectionError(value: unknown): value is CDPConnectionError {\n\treturn isInstance(value, CDPConnectionError)\n}\n\n/**\n * Narrows an unknown value to a `CDPTimeoutError`.\n *\n * @param value - Value to check\n * @returns True if value is a CDPTimeoutError instance; false otherwise\n */\nexport function isCDPTimeoutError(value: unknown): value is CDPTimeoutError {\n\treturn isInstance(value, CDPTimeoutError)\n}\n\n/**\n * Narrows an unknown value to a `BrowserResultLimitError`.\n *\n * @param value - Value to check\n * @returns True if value is a BrowserResultLimitError instance; false otherwise\n */\nexport function isBrowserResultLimitError(value: unknown): value is BrowserResultLimitError {\n\treturn isInstance(value, BrowserResultLimitError)\n}\n\n/**\n * Reports that a CDP connection, discovery, or launch attempt failed, under the code\n * `BROWSER_CONNECTION_ERROR`.\n */\nexport class BrowserConnectionError extends BrowserError {\n\tconstructor(message: string, context?: Readonly<Record<string, unknown>>) {\n\t\tsuper(message, 'BROWSER_CONNECTION_ERROR', context)\n\t\tthis.name = 'BrowserConnectionError'\n\t}\n}\n\n/**\n * Narrows an unknown value to a `BrowserConnectionError`.\n *\n * @param value - Value to check\n * @returns True if value is a BrowserConnectionError instance; false otherwise\n */\nexport function isBrowserConnectionError(value: unknown): value is BrowserConnectionError {\n\treturn isInstance(value, BrowserConnectionError)\n}\n","import type {\n\tBrowserJourneyBinding,\n\tBrowserJourneyTarget,\n\tBrowserJourneyTab,\n\tBrowserJourneyValidationContext,\n} from './types.js'\nimport { attempt, isRecord, isString } from '@orkestrel/contract'\nimport { BROWSER_JOURNEY_PARAMETER_PATTERN } from './constants.js'\n\n/**\n * Checks whether a validation context identifies a parameter, step, and field.\n * @param value - Candidate error context\n * @returns True if the binding coordinates are strings; false otherwise\n * @example\n * isBrowserJourneyValidationContext({ parameter: 'email', step: 's4', field: 'text' })\n */\nexport function isBrowserJourneyValidationContext(\n\tvalue: unknown,\n): value is BrowserJourneyValidationContext {\n\tconst result = attempt(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisString(value['parameter']) &&\n\t\t\tisString(value['step']) &&\n\t\t\tisString(value['field']),\n\t)\n\treturn result.success && result.value\n}\n\n/**\n * Checks whether a native string argument is a literal or a parameter binding.\n * @param value - Candidate argument\n * @returns True if the binding has the declared shape; false otherwise\n */\nexport function isBrowserJourneyBinding(value: unknown): value is BrowserJourneyBinding {\n\tconst result = attempt(\n\t\t() =>\n\t\t\tisString(value) ||\n\t\t\t(isRecord(value) &&\n\t\t\t\tObject.keys(value).length === 1 &&\n\t\t\t\tisString(value['parameter']) &&\n\t\t\t\tBROWSER_JOURNEY_PARAMETER_PATTERN.test(value['parameter'])),\n\t)\n\treturn result.success && result.value\n}\n\n/**\n * Checks whether a target carries its role, name, and optional evidence.\n * @param value - Candidate target\n * @returns True if the target has the declared shape; false otherwise\n */\nexport function isBrowserJourneyTarget(value: unknown): value is BrowserJourneyTarget {\n\tconst result = attempt(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tObject.keys(value).every((key) => ['role', 'name', 'css', 'reference'].includes(key)) &&\n\t\t\tisString(value['role']) &&\n\t\t\tvalue['role'].length > 0 &&\n\t\t\tisBrowserJourneyBinding(value['name']) &&\n\t\t\t(value['css'] === undefined || isString(value['css'])) &&\n\t\t\t(value['reference'] === undefined || isString(value['reference'])),\n\t)\n\treturn result.success && result.value\n}\n\n/**\n * Checks whether a tab carries its portable URL and title.\n * @param value - Candidate tab\n * @returns True if both fields are strings; false otherwise\n */\nexport function isBrowserJourneyTab(value: unknown): value is BrowserJourneyTab {\n\tconst result = attempt(\n\t\t() => isRecord(value) && isString(value['url']) && isString(value['title']),\n\t)\n\treturn result.success && result.value\n}\n\n/**\n * Checks whether a step binds a declared secret through type.text.\n * @param step - Candidate step\n * @param parameters - Candidate parameter declarations\n * @returns True if the text binds a declared secret on a type action; false otherwise\n */\nexport function isBrowserSecretBinding(\n\tstep: unknown,\n\tparameters: unknown,\n): step is {\n\treadonly action: 'type'\n\treadonly arguments: { readonly text: { readonly parameter: string } }\n} {\n\tconst result = attempt(() => {\n\t\tif (\n\t\t\t!isRecord(step) ||\n\t\t\tstep['action'] !== 'type' ||\n\t\t\t!isRecord(step['arguments']) ||\n\t\t\t!isRecord(parameters)\n\t\t)\n\t\t\treturn false\n\t\tconst binding = step['arguments']['text']\n\t\tif (!isBrowserJourneyBinding(binding) || isString(binding)) return false\n\t\tconst parameter = parameters[binding.parameter]\n\t\treturn isRecord(parameter) && parameter['secret'] === true\n\t})\n\treturn result.success && result.value\n}\n","import type {\n\tBrowserJourney,\n\tBrowserJourneyEdit,\n\tBrowserRun,\n\tBrowserTool,\n\tBrowserToolRemoval,\n\tBrowserInvocation,\n\tBrowserInvocationResult,\n\tBrowserBindingCall,\n\tBrowserCodegenGesture,\n\tBrowserConsoleMessage,\n\tBrowserCookiePartition,\n\tBrowserDownloadProgress,\n\tBrowserDownloadStart,\n\tBrowserPageError,\n\tBrowserRect,\n\tBrowserRequest,\n\tBrowserRequestFailure,\n\tBrowserResponse,\n\tBrowserSecurity,\n\tBrowserTiming,\n\tBrowserTimingRange,\n\tBrowserWebSocketFrame,\n} from './types.js'\nimport {\n\tattempt,\n\tisArray,\n\tisBoolean,\n\tisFiniteNumber,\n\tisInteger,\n\tisRecord,\n\tisString,\n\tparseArray,\n\tparseEnum,\n\tparseJSONAs,\n} from '@orkestrel/contract'\nimport {\n\tvalidateBrowserJourney,\n\tvalidateBrowserJourneyEdit,\n\tvalidateBrowserRun,\n\treadBrowserAXValue,\n\treadBrowserHeaders,\n\treadBrowserRemoteValue,\n\treadBrowserStack,\n} from './helpers.js'\n\n/**\n * Coerces a WebMCP `Tool` object to its browser-domain representation.\n * @param value - Unknown protocol tool\n * @returns The decoded tool, or undefined when required fields are malformed\n */\nexport function parseBrowserTool(value: unknown): BrowserTool | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['name']) ||\n\t\t!isString(value['description']) ||\n\t\t!isString(value['frameId'])\n\t)\n\t\treturn undefined\n\tconst hints = isRecord(value['annotations']) ? value['annotations'] : {}\n\treturn {\n\t\tname: value['name'],\n\t\tdescription: value['description'],\n\t\tframe: value['frameId'],\n\t\tschema: isRecord(value['inputSchema']) ? value['inputSchema'] : undefined,\n\t\tnode: isInteger(value['backendNodeId']) ? value['backendNodeId'] : undefined,\n\t\tannotation: {\n\t\t\t...(isBoolean(hints['readOnly']) ? { readOnly: hints['readOnly'] } : {}),\n\t\t\t...(isBoolean(hints['untrustedContent'])\n\t\t\t\t? { untrustedContent: hints['untrustedContent'] }\n\t\t\t\t: {}),\n\t\t\t...(isBoolean(hints['consequential']) ? { consequential: hints['consequential'] } : {}),\n\t\t\t...(isBoolean(hints['debugging']) ? { debugging: hints['debugging'] } : {}),\n\t\t\t...(isBoolean(hints['autosubmit']) ? { autosubmit: hints['autosubmit'] } : {}),\n\t\t},\n\t}\n}\n\n/**\n * Coerces a WebMCP `RemovedTool` object to its document and name key.\n * @param value - Unknown protocol removal\n * @returns The decoded key, or undefined when malformed\n */\nexport function parseBrowserRemoval(value: unknown): BrowserToolRemoval | undefined {\n\tif (!isRecord(value) || !isString(value['name']) || !isString(value['frameId'])) return undefined\n\treturn { frame: value['frameId'], name: value['name'] }\n}\n\n/**\n * Coerces a WebMCP `toolInvoked` event without parsing its authored input text.\n * @param value - Unknown event parameters\n * @returns The invocation, or undefined when malformed\n */\nexport function parseBrowserInvocation(value: unknown): BrowserInvocation | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['invocationId']) ||\n\t\t!isString(value['toolName']) ||\n\t\t!isString(value['frameId']) ||\n\t\t!isString(value['input'])\n\t)\n\t\treturn undefined\n\treturn {\n\t\tid: value['invocationId'],\n\t\ttool: value['toolName'],\n\t\tframe: value['frameId'],\n\t\tinput: value['input'],\n\t}\n}\n\n/**\n * Coerces a WebMCP `toolResponded` event, preserving output and terminal status.\n * @param value - Unknown event parameters\n * @returns The result, or undefined when required fields are malformed\n */\nexport function parseBrowserInvocationResult(value: unknown): BrowserInvocationResult | undefined {\n\tif (!isRecord(value) || !isString(value['invocationId']) || !isString(value['status']))\n\t\treturn undefined\n\tconst exception = isRecord(value['exception']) ? value['exception'] : undefined\n\treturn {\n\t\tid: value['invocationId'],\n\t\tstatus: value['status'],\n\t\toutput: value['output'],\n\t\terror: isString(value['errorText'])\n\t\t\t? value['errorText']\n\t\t\t: isString(exception?.['description'])\n\t\t\t\t? exception['description']\n\t\t\t\t: undefined,\n\t}\n}\n\n/**\n * Coerces one `Network.requestWillBeSent` or `Fetch.requestPaused` event to a\n * `BrowserRequest`, or `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Request or undefined\n */\nexport function parseBrowserRequest(value: unknown): BrowserRequest | undefined {\n\tif (!isRecord(value) || !isString(value['requestId']) || !isRecord(value['request'])) {\n\t\treturn undefined\n\t}\n\tconst request = value['request']\n\tif (!isString(request['url']) || !isString(request['method'])) {\n\t\treturn undefined\n\t}\n\tconst timestamp = isFiniteNumber(value['timestamp']) ? value['timestamp'] : undefined\n\tconst walltime = isFiniteNumber(value['wallTime']) ? value['wallTime'] : undefined\n\treturn {\n\t\tid: value['requestId'],\n\t\tloader: isString(value['loaderId']) ? value['loaderId'] : undefined,\n\t\tframe: isString(value['frameId']) ? value['frameId'] : undefined,\n\t\turl: request['url'],\n\t\tmethod: request['method'],\n\t\theaders: readBrowserHeaders(request['headers']),\n\t\tpost: isString(request['postData']) ? request['postData'] : undefined,\n\t\tresource: isString(value['type'])\n\t\t\t? value['type']\n\t\t\t: isString(value['resourceType'])\n\t\t\t\t? value['resourceType']\n\t\t\t\t: undefined,\n\t\ttimestamp,\n\t\twalltime,\n\t\tredirect: parseBrowserResponseRecord(\n\t\t\tvalue['redirectResponse'],\n\t\t\tvalue['requestId'],\n\t\t\tisString(value['loaderId']) ? value['loaderId'] : '',\n\t\t\tisString(value['frameId']) ? value['frameId'] : undefined,\n\t\t\ttimestamp ?? 0,\n\t\t),\n\t}\n}\n\n/**\n * Coerces one `Network.responseReceived` event to a `BrowserResponse`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Response or undefined\n */\nexport function parseBrowserResponse(value: unknown): BrowserResponse | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['requestId']) ||\n\t\t!isString(value['loaderId']) ||\n\t\t!isFiniteNumber(value['timestamp'])\n\t) {\n\t\treturn undefined\n\t}\n\treturn parseBrowserResponseRecord(\n\t\tvalue['response'],\n\t\tvalue['requestId'],\n\t\tvalue['loaderId'],\n\t\tisString(value['frameId']) ? value['frameId'] : undefined,\n\t\tvalue['timestamp'],\n\t)\n}\n\n/**\n * Coerces one Chromium response object plus its event identity to a\n * `BrowserResponse`, or `undefined` off-shape.\n *\n * @param value - Unknown response object\n * @param id - Request id\n * @param loader - Loader id\n * @param frame - Optional frame id\n * @param timestamp - Monotonic event timestamp\n * @returns Response or undefined\n */\nexport function parseBrowserResponseRecord(\n\tvalue: unknown,\n\tid: string,\n\tloader: string,\n\tframe: string | undefined,\n\ttimestamp: number,\n): BrowserResponse | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['url']) ||\n\t\t!isFiniteNumber(value['status']) ||\n\t\t!isString(value['statusText']) ||\n\t\t!isString(value['mimeType']) ||\n\t\t!isString(value['protocol']) ||\n\t\t!isFiniteNumber(timestamp)\n\t) {\n\t\treturn undefined\n\t}\n\treturn {\n\t\tid,\n\t\tloader,\n\t\tframe,\n\t\turl: value['url'],\n\t\tstatus: value['status'],\n\t\tphrase: value['statusText'],\n\t\theaders: readBrowserHeaders(value['headers']),\n\t\tmime: value['mimeType'],\n\t\tprotocol: value['protocol'],\n\t\taddress: isString(value['remoteIPAddress']) ? value['remoteIPAddress'] : undefined,\n\t\tport: isFiniteNumber(value['remotePort']) ? value['remotePort'] : undefined,\n\t\tcached: value['fromDiskCache'] === true || value['fromPrefetchCache'] === true,\n\t\tworker: value['fromServiceWorker'] === true,\n\t\ttimestamp,\n\t\ttiming: parseBrowserTiming(value['timing']),\n\t\tsecurity: parseBrowserSecurity(value['securityDetails']),\n\t}\n}\n\n/**\n * Coerces Chromium response timing to a `BrowserTiming`, or `undefined`\n * off-shape.\n *\n * @param value - Unknown timing object\n * @returns Timing or undefined\n */\nexport function parseBrowserTiming(value: unknown): BrowserTiming | undefined {\n\tif (!isRecord(value) || !isFiniteNumber(value['requestTime']) || value['requestTime'] < 0) {\n\t\treturn undefined\n\t}\n\tconst receive = value['receiveHeadersEnd']\n\treturn {\n\t\trequest: value['requestTime'],\n\t\tproxy: parseBrowserTimingRange(value, 'proxyStart', 'proxyEnd'),\n\t\tdns: parseBrowserTimingRange(value, 'dnsStart', 'dnsEnd'),\n\t\tconnect: parseBrowserTimingRange(value, 'connectStart', 'connectEnd'),\n\t\tssl: parseBrowserTimingRange(value, 'sslStart', 'sslEnd'),\n\t\tsend: parseBrowserTimingRange(value, 'sendStart', 'sendEnd'),\n\t\treceive: isFiniteNumber(receive) && receive >= 0 ? receive : undefined,\n\t}\n}\n\n/**\n * Coerces one named start/end pair of Chromium network timing to a\n * `BrowserTimingRange`, or `undefined` off-shape.\n *\n * @param value - Unknown timing object\n * @param start - Start field\n * @param end - End field\n * @returns Timing range or undefined\n */\nexport function parseBrowserTimingRange(\n\tvalue: unknown,\n\tstart: string,\n\tend: string,\n): BrowserTimingRange | undefined {\n\tif (!isRecord(value)) return undefined\n\tconst startValue = value[start]\n\tconst endValue = value[end]\n\tif (\n\t\t!isFiniteNumber(startValue) ||\n\t\tstartValue < 0 ||\n\t\t!isFiniteNumber(endValue) ||\n\t\tendValue < startValue\n\t) {\n\t\treturn undefined\n\t}\n\treturn { start: startValue, end: endValue }\n}\n\n/**\n * Coerces Chromium TLS security details to a `BrowserSecurity`, or `undefined`\n * off-shape.\n *\n * @param value - Unknown security details\n * @returns Security metadata or undefined\n */\nexport function parseBrowserSecurity(value: unknown): BrowserSecurity | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['protocol']) ||\n\t\t!isString(value['issuer']) ||\n\t\t!isFiniteNumber(value['validFrom']) ||\n\t\t!isFiniteNumber(value['validTo']) ||\n\t\tvalue['validTo'] < value['validFrom']\n\t) {\n\t\treturn undefined\n\t}\n\treturn {\n\t\tprotocol: value['protocol'],\n\t\tissuer: value['issuer'],\n\t\tfrom: value['validFrom'],\n\t\tto: value['validTo'],\n\t}\n}\n\n/**\n * Coerces one `Network.loadingFailed` event to a `BrowserRequestFailure`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Failure or undefined\n */\nexport function parseBrowserRequestFailure(value: unknown): BrowserRequestFailure | undefined {\n\tif (!isRecord(value) || !isString(value['requestId']) || !isString(value['errorText'])) {\n\t\treturn undefined\n\t}\n\treturn {\n\t\tid: value['requestId'],\n\t\terror: value['errorText'],\n\t\tcancelled: value['canceled'] === true,\n\t\tblocked: isString(value['blockedReason']) ? value['blockedReason'] : undefined,\n\t}\n}\n\n/**\n * Coerces one WebSocket frame event to a `BrowserWebSocketFrame`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Frame or undefined\n */\nexport function parseBrowserWebSocketFrame(value: unknown): BrowserWebSocketFrame | undefined {\n\tif (!isRecord(value) || !isRecord(value['response']) || !isFiniteNumber(value['timestamp'])) {\n\t\treturn undefined\n\t}\n\tconst frame = value['response']\n\tif (!isInteger(frame['opcode']) || frame['opcode'] < 0 || !isString(frame['payloadData'])) {\n\t\treturn undefined\n\t}\n\treturn {\n\t\topcode: frame['opcode'],\n\t\tdata: frame['payloadData'],\n\t\tmasked: frame['mask'] === true,\n\t\ttimestamp: value['timestamp'],\n\t}\n}\n\n/**\n * Coerces one Runtime binding invocation to a `BrowserBindingCall`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown `Runtime.bindingCalled` parameters\n * @returns Valid call or undefined\n */\nexport function parseBrowserBindingCall(value: unknown): BrowserBindingCall | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['name']) ||\n\t\t!isString(value['payload']) ||\n\t\t!isInteger(value['executionContextId'])\n\t) {\n\t\treturn undefined\n\t}\n\tconst payload = parseJSONAs(value['payload'], isRecord)\n\tif (\n\t\tpayload === undefined ||\n\t\t!isString(payload['id']) ||\n\t\t!isString(payload['name']) ||\n\t\t!isArray(payload['args']) ||\n\t\tpayload['name'] !== value['name']\n\t) {\n\t\treturn undefined\n\t}\n\treturn {\n\t\tid: payload['id'],\n\t\tname: payload['name'],\n\t\targs: payload['args'],\n\t\tcontext: value['executionContextId'],\n\t}\n}\n\n/**\n * Coerces a string-valued Accessibility-domain AXValue to a string, or\n * `undefined` off-shape.\n *\n * @param value - Unknown AX value\n * @returns String or undefined\n */\nexport function parseBrowserAXString(value: unknown): string | undefined {\n\tconst decoded = readBrowserAXValue(value)\n\treturn isString(decoded) ? decoded : undefined\n}\n\n/**\n * Coerces an optional Chromium cookie partition key to a\n * `BrowserCookiePartition`, or `undefined` off-shape.\n *\n * @param value - Unknown partition value\n * @returns Partition key or undefined\n */\nexport function parseBrowserCookiePartition(value: unknown): BrowserCookiePartition | undefined {\n\tif (!isRecord(value) || !isString(value['topLevelSite'])) return undefined\n\treturn {\n\t\tsite: value['topLevelSite'],\n\t\t...(isBoolean(value['hasCrossSiteAncestor'])\n\t\t\t? { ancestor: value['hasCrossSiteAncestor'] }\n\t\t\t: {}),\n\t}\n}\n\n/**\n * Coerces one `Runtime.consoleAPICalled` event to a `BrowserConsoleMessage`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Console message or undefined\n */\nexport function parseBrowserConsoleMessage(value: unknown): BrowserConsoleMessage | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['type']) ||\n\t\t!isFiniteNumber(value['timestamp']) ||\n\t\t!isArray(value['args'])\n\t) {\n\t\treturn undefined\n\t}\n\tconst values = value['args'].map(readBrowserRemoteValue)\n\treturn {\n\t\tlevel: value['type'],\n\t\ttext: values\n\t\t\t.map((entry) => {\n\t\t\t\tif (isString(entry)) return entry\n\t\t\t\tconst serialized = attempt<unknown>(() => JSON.stringify(entry))\n\t\t\t\treturn serialized.success && isString(serialized.value) ? serialized.value : String(entry)\n\t\t\t})\n\t\t\t.join(' '),\n\t\tvalues,\n\t\ttimestamp: value['timestamp'],\n\t\tstack: readBrowserStack(value['stackTrace']),\n\t}\n}\n\n/**\n * Coerces one `Runtime.exceptionThrown` event to a `BrowserPageError`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Page error or undefined\n */\nexport function parseBrowserPageError(value: unknown): BrowserPageError | undefined {\n\tif (!isRecord(value) || !isRecord(value['exceptionDetails'])) return undefined\n\tconst details = value['exceptionDetails']\n\tconst timestamp = isFiniteNumber(value['timestamp']) ? value['timestamp'] : Date.now()\n\tconst exception = readBrowserRemoteValue(details['exception'])\n\tconst message = isString(exception)\n\t\t? exception\n\t\t: isString(details['text'])\n\t\t\t? details['text']\n\t\t\t: 'Uncaught page exception'\n\treturn {\n\t\tmessage,\n\t\tstack: readBrowserStack(details['stackTrace']),\n\t\ttimestamp,\n\t}\n}\n\n/**\n * Coerces one `Browser.downloadWillBegin` event to a `BrowserDownloadStart`, or\n * `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Download start or undefined\n */\nexport function parseBrowserDownloadStart(value: unknown): BrowserDownloadStart | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['guid']) ||\n\t\t!isString(value['url']) ||\n\t\t!isString(value['suggestedFilename']) ||\n\t\t!isString(value['frameId'])\n\t) {\n\t\treturn undefined\n\t}\n\treturn {\n\t\tid: value['guid'],\n\t\turl: value['url'],\n\t\tname: value['suggestedFilename'],\n\t\tframe: value['frameId'],\n\t}\n}\n\n/**\n * Coerces one `Browser.downloadProgress` event to a `BrowserDownloadProgress`,\n * or `undefined` off-shape.\n *\n * @param value - Unknown event parameters\n * @returns Download id and progress, or undefined\n */\nexport function parseBrowserDownloadProgress(\n\tvalue: unknown,\n): readonly [id: string, progress: BrowserDownloadProgress] | undefined {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['guid']) ||\n\t\t!isFiniteNumber(value['receivedBytes']) ||\n\t\tvalue['receivedBytes'] < 0 ||\n\t\t!isFiniteNumber(value['totalBytes']) ||\n\t\tvalue['totalBytes'] < 0\n\t) {\n\t\treturn undefined\n\t}\n\tconst state = parseEnum(value['state'], ['completed', 'canceled', 'inProgress'])\n\tconst status =\n\t\tstate === 'completed'\n\t\t\t? 'complete'\n\t\t\t: state === 'canceled'\n\t\t\t\t? 'aborted'\n\t\t\t\t: state === 'inProgress'\n\t\t\t\t\t? 'pending'\n\t\t\t\t\t: undefined\n\tif (status === undefined) return undefined\n\treturn [\n\t\tvalue['guid'],\n\t\t{\n\t\t\tstatus,\n\t\t\treceived: value['receivedBytes'],\n\t\t\ttotal: value['totalBytes'],\n\t\t\t...(isString(value['filePath']) ? { path: value['filePath'] } : {}),\n\t\t},\n\t]\n}\n\n/**\n * Parses a sanitized document gesture, refusing malformed or secret-bearing payloads.\n * @param payload - The runtime binding's JSON string\n * @returns The gesture, or undefined for an invalid payload\n * @example\n * parseCodegenActionPayload('invalid') // undefined\n */\nexport function parseCodegenActionPayload(payload: unknown): BrowserCodegenGesture | undefined {\n\tif (!isString(payload)) return undefined\n\tconst value = parseJSONAs(payload, isRecord)\n\tif (value === undefined) return undefined\n\tconst event = parseEnum(value['event'], [\n\t\t'click',\n\t\t'input',\n\t\t'change',\n\t\t'keydown',\n\t\t'focusout',\n\t\t'submit',\n\t\t'unsupported',\n\t])\n\tconst control = parseEnum(value['control'], [\n\t\t'text',\n\t\t'password',\n\t\t'select',\n\t\t'multiple',\n\t\t'option',\n\t\t'other',\n\t])\n\tconst index = value['index']\n\tconst top = value['top']\n\tconst form = value['form']\n\tif (\n\t\tevent === undefined ||\n\t\tcontrol === undefined ||\n\t\t!isInteger(index) ||\n\t\tindex < 0 ||\n\t\t!Number.isSafeInteger(index) ||\n\t\t!isBoolean(top) ||\n\t\t!isBoolean(form)\n\t)\n\t\treturn undefined\n\tif (\n\t\tObject.keys(value).some(\n\t\t\t(key) =>\n\t\t\t\t![\n\t\t\t\t\t'event',\n\t\t\t\t\t'control',\n\t\t\t\t\t'index',\n\t\t\t\t\t'top',\n\t\t\t\t\t'form',\n\t\t\t\t\t'detail',\n\t\t\t\t\t'key',\n\t\t\t\t\t'value',\n\t\t\t\t\t'secret',\n\t\t\t\t\t'roundtrip',\n\t\t\t\t\t'gap',\n\t\t\t\t].includes(key),\n\t\t)\n\t)\n\t\treturn undefined\n\tif ('key' in value && (event !== 'keydown' || value['key'] !== 'Enter')) return undefined\n\tif (event === 'keydown' && value['key'] !== 'Enter') return undefined\n\tif (\n\t\t'detail' in value &&\n\t\t(!isInteger(value['detail']) || value['detail'] < 0 || event !== 'click')\n\t)\n\t\treturn undefined\n\tif (event === 'click' && !isInteger(value['detail'])) return undefined\n\tif (\n\t\t'value' in value &&\n\t\t(!isString(value['value']) ||\n\t\t\t!((event === 'input' && control === 'text') || (event === 'change' && control === 'select')))\n\t)\n\t\treturn undefined\n\tif (\n\t\t'secret' in value &&\n\t\t(value['secret'] !== true || control !== 'password' || event !== 'input')\n\t)\n\t\treturn undefined\n\tif (event === 'input' && control === 'password' && value['secret'] !== true) return undefined\n\tif (event === 'input' && control === 'text' && !isString(value['value'])) return undefined\n\tif (\n\t\t'roundtrip' in value &&\n\t\t(event !== 'change' || control !== 'select' || !isBoolean(value['roundtrip']))\n\t)\n\t\treturn undefined\n\tif (\n\t\tevent === 'change' &&\n\t\tcontrol === 'select' &&\n\t\t(!isString(value['value']) || !isBoolean(value['roundtrip']))\n\t)\n\t\treturn undefined\n\tif ('gap' in value && (event !== 'unsupported' || !isString(value['gap']))) return undefined\n\tif (event === 'unsupported' && !isString(value['gap'])) return undefined\n\treturn {\n\t\tevent,\n\t\tcontrol,\n\t\tindex,\n\t\ttop,\n\t\tform,\n\t\t...(isInteger(value['detail']) ? { detail: value['detail'] } : {}),\n\t\t...(value['key'] === 'Enter' ? { key: 'Enter' } : {}),\n\t\t...(isString(value['value']) ? { value: value['value'] } : {}),\n\t\t...(value['secret'] === true ? { secret: true } : {}),\n\t\t...(isBoolean(value['roundtrip']) ? { roundtrip: value['roundtrip'] } : {}),\n\t\t...(isString(value['gap']) ? { gap: value['gap'] } : {}),\n\t}\n}\n\n/**\n * Coerces an unknown value to an all-number array, or `undefined` off-shape.\n *\n * @param value - Candidate value\n * @returns The number array, or undefined\n */\nexport function parseNumberArray(value: unknown): readonly number[] | undefined {\n\treturn parseArray(value, isFiniteNumber)\n}\n\n/**\n * Coerces one CDP snapshot string-table index to its string, or `undefined`\n * off-shape.\n *\n * @param strings - Snapshot string table\n * @param index - Candidate string index\n * @returns The resolved string, or undefined\n */\nexport function parseSnapshotString(\n\tstrings: readonly string[],\n\tindex: unknown,\n): string | undefined {\n\tif (!isInteger(index)) return undefined\n\treturn strings[index]\n}\n\n/**\n * Coerces a four-number CSS-pixel rectangle to a `BrowserRect`, or `undefined` off-shape.\n *\n * @param value - Candidate four-number array\n * @returns A rectangle, or undefined\n */\nexport function parseBrowserRect(value: unknown): BrowserRect | undefined {\n\tconst numbers = parseNumberArray(value)\n\tif (numbers === undefined || numbers.length !== 4) return undefined\n\tconst x = numbers[0]\n\tconst y = numbers[1]\n\tconst width = numbers[2]\n\tconst height = numbers[3]\n\tif (x === undefined || y === undefined || width === undefined || height === undefined) {\n\t\treturn undefined\n\t}\n\treturn [x, y, width, height]\n}\n/**\n * Parses the supported element-reference spellings into their canonical form.\n * @param value - Reference supplied by a caller\n * @returns Canonical reference, or undefined for an invalid spelling\n */\nexport function parseBrowserReference(value: string): string | undefined {\n\tconst match =\n\t\t/^(?:e([1-9]\\d*)|([1-9]\\d*)|\\[e([1-9]\\d*)\\]|ref=e([1-9]\\d*)|\\[ref=e([1-9]\\d*)\\])$/i.exec(value)\n\tconst number = match?.slice(1).find((part) => part !== undefined)\n\treturn number === undefined ? undefined : `e${number}`\n}\n\n/**\n * Parses a journey without throwing when validation fails.\n * @param value - Candidate journey\n * @returns The validated value, or undefined\n */\nexport function parseBrowserJourney(value: unknown): BrowserJourney | undefined {\n\tconst result = attempt(() => {\n\t\tvalidateBrowserJourney(value)\n\t\treturn value\n\t})\n\treturn result.success ? result.value : undefined\n}\n\n/**\n * Parses an edit without throwing when its structure fails validation.\n * @param value - Candidate edit\n * @returns The validated value, or undefined\n */\nexport function parseBrowserJourneyEdit(value: unknown): BrowserJourneyEdit | undefined {\n\tconst result = attempt(() => {\n\t\tvalidateBrowserJourneyEdit(value)\n\t\treturn value\n\t})\n\treturn result.success ? result.value : undefined\n}\n\n/**\n * Parses a run without throwing when validation fails.\n * @param value - Candidate run\n * @returns The validated value, or undefined\n */\nexport function parseBrowserRun(value: unknown): BrowserRun | undefined {\n\tconst result = attempt(() => {\n\t\tvalidateBrowserRun(value)\n\t\treturn value\n\t})\n\treturn result.success ? result.value : undefined\n}\n","import type {\n\tBrowserJourney,\n\tBrowserStoreFault,\n\tBrowserJourneyEdit,\n\tBrowserJourneyParameter,\n\tBrowserJourneyStep,\n\tBrowserJourneyStepInput,\n\tBrowserRun,\n\tBrowserElementQuery,\n\tBrowserOutline,\n\tBrowserOutlineNode,\n\tBrowserChord,\n\tBrowserCookie,\n\tBrowserCookieInput,\n\tBrowserContextOptions,\n\tBrowserCoverageRange,\n\tBrowserDocument,\n\tBrowserEmulationOptions,\n\tBrowserFrameInfo,\n\tBrowserFunctionCoverage,\n\tBrowserHAR,\n\tBrowserHAREntry,\n\tBrowserHARPending,\n\tBrowserHARValue,\n\tBrowserLayout,\n\tBrowserMetric,\n\tBrowserOperationOptions,\n\tBrowserAccessibilityOptions,\n\tBrowserAccessibilitySnapshot,\n\tBrowserAXNode,\n\tBrowserKey,\n\tBrowserNode,\n\tBrowserNodePredicate,\n\tBrowserNodeQuery,\n\tBrowserProfile,\n\tBrowserProfileFrame,\n\tBrowserProfileNode,\n\tBrowserMouseButton,\n\tBrowserPoint,\n\tBrowserPDFOptions,\n\tBrowserMedia,\n\tBrowserRequest,\n\tBrowserRouteQuery,\n\tBrowserQuad,\n\tBrowserReadResult,\n\tBrowserReceipt,\n\tBrowserElementInterface,\n\tBrowserSnapshotInput,\n\tBrowserScriptCoverage,\n\tBrowserScreenshotOptions,\n\tBrowserStorageEntry,\n\tBrowserStorageOrigin,\n\tBrowserStreamChunk,\n\tBrowserStackFrame,\n\tBrowserStyleCoverage,\n\tBrowserTeardownFunction,\n\tBrowserViewport,\n} from './types.js'\nimport type { ToolDefinition } from '@orkestrel/tool'\nimport {\n\tattempt,\n\tisArray,\n\tisBoolean,\n\tisFiniteNumber,\n\tisFunction,\n\tisInteger,\n\tisJSONValue,\n\tisRecord,\n\tisString,\n\tparseArray,\n\tparseEnum,\n} from '@orkestrel/contract'\nimport {\n\tBROWSER_TOOL_COPY,\n\tBROWSER_ACTION_OUTCOMES,\n\tBROWSER_ACTION_STAGES,\n\tBROWSER_NAVIGATION_REASONS,\n\tBROWSER_JOURNEY_ACTIONS,\n\tBROWSER_JOURNEY_NON_STEP_TOOLS,\n\tBROWSER_JOURNEY_STEP_KEYS,\n\tBROWSER_RUN_ID_PATTERN,\n\tBROWSER_JOURNEY_FORMAT_VERSION,\n\tBROWSER_JOURNEY_NAME_PATTERN,\n\tBROWSER_JOURNEY_PARAMETER_PATTERN,\n\tBASE64_CHARS,\n\tBROWSER_OUTLINE_OMITTED_ROLES,\n\tBASE64_LOOKUP,\n\tBROWSER_RESULT_LIMIT,\n\tBROWSER_REGISTRY_OUTPUT_LIMIT,\n\tBROWSER_RESULT_LIMIT_PATTERN,\n\tBROWSER_SNAPSHOT_NODE_LIMIT,\n\tBROWSER_KEY_MODIFIERS,\n\tBROWSER_MOUSE_BUTTON_MASKS,\n} from './constants.js'\nimport {\n\tisBrowserJourneyBinding,\n\tisBrowserJourneyValidationContext,\n\tisBrowserJourneyTarget,\n\tisBrowserJourneyTab,\n\tisBrowserSecretBinding,\n} from './validators.js'\nimport {\n\tBrowserElementError,\n\tBrowserError,\n\tBrowserResultLimitError,\n\tisBrowserError,\n} from './errors.js'\nimport {\n\tparseBrowserAXString,\n\tparseBrowserCookiePartition,\n\tparseBrowserRect,\n\tparseBrowserReference,\n\tparseNumberArray,\n\tparseSnapshotString,\n} from './parsers.js'\n\n/**\n * Normalizes an accessible name for display and matching.\n * @param value - Accessible name\n * @returns Trimmed name with collapsed whitespace\n */\nexport function normalizeBrowserName(value: string): string {\n\treturn value.trim().replace(/\\s+/g, ' ')\n}\n\n/**\n * Filters document-order outline rows by accessibility role and name.\n * @param nodes - Captured rows\n * @param query - Role and name constraints, with whole, case-sensitive matching when exact is true\n * @returns Matching rows in their original order\n */\nexport function filterBrowserOutline(\n\tnodes: readonly BrowserOutlineNode[],\n\tquery: BrowserElementQuery,\n): readonly BrowserOutlineNode[] {\n\treturn nodes.filter(\n\t\t(node) =>\n\t\t\t!node.ignored &&\n\t\t\t!BROWSER_OUTLINE_OMITTED_ROLES.has(node.role ?? '') &&\n\t\t\t(query.role === undefined || node.role === query.role) &&\n\t\t\t(query.name === undefined ||\n\t\t\t\t(query.exact === true\n\t\t\t\t\t? normalizeBrowserName(node.name ?? '') === normalizeBrowserName(query.name)\n\t\t\t\t\t: normalizeBrowserName(node.name ?? '')\n\t\t\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t\t\t.includes(normalizeBrowserName(query.name).toLowerCase()))),\n\t)\n}\n\n/**\n * Renders document-order text and referenced elements with a bounded element count.\n * @param url - Document address\n * @param title - Document title\n * @param nodes - Ordered accessibility rows\n * @param limit - Maximum referenced rows to include\n * @returns Outline text and element counts\n */\nexport function renderBrowserOutline(\n\turl: string,\n\ttitle: string,\n\tnodes: readonly BrowserOutlineNode[],\n\tlimit: number,\n): BrowserOutline {\n\tconst rows = [`page ${JSON.stringify(title)} ${url}`]\n\tconst sessions = new Map<string, Map<string, BrowserOutlineNode>>()\n\tfor (const node of nodes) {\n\t\tlet parents = sessions.get(node.session)\n\t\tif (parents === undefined) {\n\t\t\tparents = new Map<string, BrowserOutlineNode>()\n\t\t\tsessions.set(node.session, parents)\n\t\t}\n\t\tif (!parents.has(node.id)) parents.set(node.id, node)\n\t}\n\tlet count = 0\n\tlet total = 0\n\tfor (const node of nodes) {\n\t\tif (node.ignored || BROWSER_OUTLINE_OMITTED_ROLES.has(node.role ?? '')) continue\n\t\tconst name = normalizeBrowserName(node.name ?? '')\n\t\tif (node.role === 'heading') {\n\t\t\trows.push(`# ${name}`)\n\t\t\tcontinue\n\t\t}\n\t\tif (node.role === 'StaticText') {\n\t\t\tconst parent =\n\t\t\t\tnode.parent === undefined ? undefined : sessions.get(node.session)?.get(node.parent)\n\t\t\tif (name !== '' && name !== normalizeBrowserName(parent?.name ?? '')) rows.push(name)\n\t\t\tcontinue\n\t\t}\n\t\tif (node.reference === undefined) continue\n\t\ttotal += 1\n\t\tif (count >= limit) continue\n\t\tcount += 1\n\t\tlet row = `${node.reference} ${node.role ?? 'unknown'} ${JSON.stringify(name)}`\n\t\tif (node.value !== undefined && node.value !== '')\n\t\t\trow += ` value=${JSON.stringify(String(node.value))}`\n\t\tif (node.properties['checked'] === true || node.properties['checked'] === 'true')\n\t\t\trow += ' [checked]'\n\t\tif (node.properties['disabled'] === true) row += ' [disabled]'\n\t\tif (node.tool !== undefined) row += ` [tool=${node.tool}]`\n\t\trows.push(row)\n\t}\n\trows.push(`(${count} of ${total} elements)`)\n\treturn { url, title, text: rows.join('\\n'), count, total }\n}\n\n/**\n * Composes a frame-local point with its ancestor frame offsets.\n * @param point - Local point\n * @param offsets - Frame rectangles' origins, ordered from child to parent\n * @returns Validated page point\n */\nexport function composeBrowserPoint(\n\tpoint: BrowserPoint,\n\toffsets: readonly BrowserPoint[],\n): BrowserPoint {\n\tvalidateBrowserPoint(point)\n\tlet x = point.x\n\tlet y = point.y\n\tfor (const offset of offsets) {\n\t\tvalidateBrowserPoint(offset)\n\t\tx += offset.x\n\t\ty += offset.y\n\t}\n\tconst result = { x, y }\n\tvalidateBrowserPoint(result)\n\treturn result\n}\n\n/**\n * Normalizes named keys and modifier aliases before trusted keyboard input.\n * @param value - Key or modifier chord\n * @returns Canonical key chord\n * @throws Thrown when a key or modifier is unsupported, listing accepted names.\n */\nexport function normalizeBrowserKey(value: string): string {\n\tconst accepted = [\n\t\t'Backspace',\n\t\t'Tab',\n\t\t'Enter',\n\t\t'Shift',\n\t\t'Control',\n\t\t'Alt',\n\t\t'Escape',\n\t\t'Space',\n\t\t'PageUp',\n\t\t'PageDown',\n\t\t'End',\n\t\t'Home',\n\t\t'ArrowLeft',\n\t\t'ArrowUp',\n\t\t'ArrowRight',\n\t\t'ArrowDown',\n\t\t'Delete',\n\t\t'Meta',\n\t]\n\tconst aliases: Readonly<Record<string, string>> = {\n\t\treturn: 'Enter',\n\t\tesc: 'Escape',\n\t\tctrl: 'Control',\n\t\tcmd: 'Meta',\n\t\tcommand: 'Meta',\n\t}\n\tconst parts = value.split('+')\n\tconst normalized = parts.map(\n\t\t(part) =>\n\t\t\taliases[part.toLowerCase()] ??\n\t\t\taccepted.find((name) => name.toLowerCase() === part.toLowerCase()) ??\n\t\t\tpart,\n\t)\n\ttry {\n\t\tconst chord = extractBrowserChord(normalized.join('+'))\n\t\tkeyToBrowserInput(chord.key)\n\t\tif (parts.some((part) => part === '')) throw new BrowserError('Empty key')\n\t\treturn normalized.join('+')\n\t} catch {\n\t\tthrow new BrowserError(\n\t\t\t`Unknown browser key ${JSON.stringify(value)}. Accepted names: ${accepted.join(', ')}, a single character, and modifier chords such as Control+a.`,\n\t\t)\n\t}\n}\n\n/**\n * Renders tool strings unchanged, content-array text blocks joined, and other values as bounded JSON.\n * @param value - Untrusted tool output\n * @returns Rendered output; non-serializable values receive a bounded diagnostic\n */\nexport function renderBrowserToolOutput(value: unknown): string {\n\tif (isString(value)) return value\n\tif (isArray(value) && value.every((block) => isRecord(block) && isString(block['type']))) {\n\t\treturn value\n\t\t\t.filter(isRecord)\n\t\t\t.filter((block) => block['type'] === 'text' && isString(block['text']))\n\t\t\t.map((block) => block['text'])\n\t\t\t.join('\\n')\n\t}\n\tconst rendered = attempt(() => JSON.stringify(value))\n\treturn (\n\t\trendered.success ? (rendered.value ?? String(value)) : '[Unserializable tool output]'\n\t).slice(0, BROWSER_REGISTRY_OUTPUT_LIMIT)\n}\n\n/**\n * Derives the advertised input schema from an authored one, adding a required `what` parameter when the schema requires nothing.\n * @param schema - Authored input schema, or undefined for a parameterless tool\n * @returns An advertised schema, or undefined when the authored `what` parameter is optional\n * @remarks The caller strips only a synthetic `what` parameter before invoking the page tool.\n */\nexport function deriveBrowserToolSchema(\n\tschema: Readonly<Record<string, unknown>> | undefined,\n): Readonly<Record<string, unknown>> | undefined {\n\tconst properties = isRecord(schema?.['properties']) ? schema['properties'] : {}\n\tconst required = isArray(schema?.['required']) ? schema['required'].filter(isString) : []\n\tif (Object.hasOwn(properties, 'what') && !required.includes('what')) return undefined\n\tif (required.length > 0) return schema\n\treturn {\n\t\t...schema,\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\t...properties,\n\t\t\twhat: { type: 'string', description: 'Describe the purpose of this action.' },\n\t\t},\n\t\trequired: ['what'],\n\t}\n}\n\n/**\n * Bounds a tool string at a character limit, appending a footer that names the cut and the\n * caller's closing clause.\n *\n * @remarks\n * A string within the limit returns unchanged. A longer one keeps its first `limit` UTF-16 code\n * units, one fewer when the last would split a surrogate pair (so a limit of 1 before a pair keeps\n * nothing), followed by `\\n[characters 0–END of TOTAL; FOOTER]`. The footer has no default, so\n * every caller states what the cut result's reader does next: the toolset passes\n * `BROWSER_TOOL_VIEW_FOOTER` for a result that carries a view and `BROWSER_TOOL_CUT_FOOTER` for\n * any other.\n *\n * @param text - The page-authored or composed string\n * @param limit - The most characters kept before the footer, a positive integer\n * @param footer - The clause that closes the footer after the character range\n * @returns The string, cut and footed when it exceeds the limit\n * @throws Thrown when `limit` is not a positive integer.\n *\n * @example\n * ```ts\n * import { boundBrowserText } from '@orkestrel/browser'\n *\n * boundBrowserText('abcdef', 4, 'the rest was cut') // 'abcd\\n[characters 0–4 of 6; the rest was cut]'\n * boundBrowserText('abc', 4, 'the rest was cut') // 'abc'\n * ```\n */\nexport function boundBrowserText(text: string, limit: number, footer: string): string {\n\tif (!isInteger(limit) || limit < 1) {\n\t\tthrow new BrowserError('Browser tool limit must be a positive integer', undefined, { limit })\n\t}\n\tif (text.length <= limit) return text\n\tconst last = text.charCodeAt(limit - 1)\n\tconst end = last >= 0xd800 && last <= 0xdbff ? limit - 1 : limit\n\treturn `${text.slice(0, end)}\\n[characters 0–${end} of ${text.length}; ${footer}]`\n}\n\n/**\n * Refuses a tool call that carries a parameter its definition does not advertise, naming the\n * parameters the tool takes.\n *\n * @param definition - The advertised tool definition whose `parameters.properties` names the\n * accepted keys\n * @param args - The arguments a model supplied\n * @throws Thrown as a `BrowserError` coded `BROWSER_TOOLSET_ARGUMENT`, with the refused key in its\n * context, when an argument key is not an advertised parameter.\n *\n * @example\n * ```ts\n * import { BROWSER_TOOL_COPY, validateBrowserToolArguments } from '@orkestrel/browser'\n *\n * validateBrowserToolArguments(BROWSER_TOOL_COPY.look, { what: 'cart', ref: 'e1' })\n * // throws 'The look tool takes no ref parameter; call look with what.'\n * ```\n */\nexport function validateBrowserToolArguments(\n\tdefinition: ToolDefinition,\n\targs: Readonly<Record<string, unknown>>,\n): void {\n\tconst properties = definition.parameters?.['properties']\n\tconst keys = isRecord(properties) ? Object.keys(properties) : []\n\tconst key = Object.keys(args).find((candidate) => !keys.includes(candidate))\n\tif (key === undefined) return\n\tconst accepted = new Intl.ListFormat('en', { type: 'conjunction' }).format(keys)\n\tthrow new BrowserError(\n\t\t`The ${definition.name} tool takes no ${key} parameter; call ${definition.name} with ${accepted}.`,\n\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t{ key },\n\t)\n}\n\n/**\n * Renders an element as its outline row reads: reference, role, and quoted name.\n *\n * @param element - The referenced element\n * @returns The element's reference, role, and JSON-quoted name\n *\n * @example\n * ```ts\n * import { renderBrowserElement } from '@orkestrel/browser'\n *\n * const element = page.elements.element('e4')\n * if (element !== undefined) renderBrowserElement(element) // 'e4 button \"Place order\"'\n * ```\n */\nexport function renderBrowserElement(element: BrowserElementInterface): string {\n\treturn `${element.reference} ${element.role} ${JSON.stringify(element.name)}`\n}\n\n/**\n * Requires a tool argument to be an element reference in any spelling `parseBrowserReference`\n * accepts, and returns its canonical form.\n *\n * @param value - The argument a model supplied\n * @returns The canonical reference, such as `e12`\n * @throws Thrown as a `BrowserElementError` with reason `UNKNOWN` when the value is not a\n * reference, naming `look` as the next call.\n *\n * @example\n * ```ts\n * import { requireBrowserReference } from '@orkestrel/browser'\n *\n * requireBrowserReference('[ref=e12]') // 'e12'\n * ```\n */\nexport function requireBrowserReference(value: unknown): string {\n\tconst reference = isString(value) ? parseBrowserReference(value) : undefined\n\tif (reference === undefined)\n\t\tthrow new BrowserElementError(\n\t\t\t{ subject: `Reference ${JSON.stringify(value)}` },\n\t\t\t'UNKNOWN',\n\t\t\t'is not a reference such as e12; call look for fresh refs',\n\t\t)\n\treturn reference\n}\n\n/**\n * Reads a required string argument from a tool call.\n *\n * @param args - The arguments a model supplied\n * @param key - The parameter name\n * @returns The string the argument holds\n * @throws Thrown as a `BrowserError` coded `BROWSER_TOOLSET_ARGUMENT` when the argument is not a\n * string.\n *\n * @example\n * ```ts\n * import { readBrowserToolString } from '@orkestrel/browser'\n *\n * readBrowserToolString({ url: 'https://example.com/' }, 'url') // 'https://example.com/'\n * ```\n */\nexport function readBrowserToolString(\n\targs: Readonly<Record<string, unknown>>,\n\tkey: string,\n): string {\n\tconst value = args[key]\n\tif (!isString(value))\n\t\tthrow new BrowserError(`The ${key} parameter must be a string.`, 'BROWSER_TOOLSET_ARGUMENT', {\n\t\t\tkey,\n\t\t})\n\treturn value\n}\n\n/**\n * Renders a tool receipt: the action and its status on one line, the interrupting dialog, then\n * a blank line and the fresh view.\n *\n * @remarks\n * The status joins the action with a semicolon, and a period closes the line. A dialog adds\n * `A CATEGORY dialog is open: \"MESSAGE\"; call dialog.`, with `An` before `alert`. An empty\n * action with no status leaves the dialog sentence, or the view, alone. A `trusted` of `false`\n * ends the line with ` (untrusted event)`.\n *\n * @param receipt - The action, status, dialog, and view\n * @returns The receipt text\n *\n * @example\n * ```ts\n * import { renderBrowserReceipt } from '@orkestrel/browser'\n *\n * renderBrowserReceipt({\n * \taction: 'Clicked e7 button \"Delete\"',\n * \tdialog: { category: 'confirm', message: 'Delete the draft?' },\n * })\n * // 'Clicked e7 button \"Delete\". A confirm dialog is open: \"Delete the draft?\"; call dialog.'\n * ```\n */\nexport function renderBrowserReceipt(receipt: BrowserReceipt): string {\n\tconst sentences: string[] = []\n\tif (receipt.action !== '' || receipt.status !== undefined)\n\t\tsentences.push(\n\t\t\t`${[receipt.action, receipt.status].filter((part) => part !== undefined && part !== '').join('; ')}.`,\n\t\t)\n\tif (receipt.dialog !== undefined)\n\t\tsentences.push(\n\t\t\t`${receipt.dialog.category === 'alert' ? 'An' : 'A'} ${receipt.dialog.category} dialog is open: ${JSON.stringify(receipt.dialog.message)}; call dialog.`,\n\t\t)\n\tconst line = `${sentences.join(' ')}${receipt.trusted === false ? ' (untrusted event)' : ''}`\n\tif (receipt.view === undefined) return line\n\treturn line === '' ? receipt.view : `${line}\\n\\n${receipt.view}`\n}\n\n/**\n * Decodes a base64-encoded string into raw bytes.\n *\n * @remarks\n * Pure JS implementation — no `Buffer`, no `atob` (DOM-only) — so it runs\n * identically in Node and browser environments. Whitespace and `=` padding\n * are ignored; invalid characters are skipped.\n *\n * @param text - Base64-encoded input string\n * @returns Decoded bytes\n *\n * @example\n * ```ts\n * decodeBase64('aGVsbG8=') // Uint8Array [104, 101, 108, 108, 111]\n * ```\n */\nexport function decodeBase64(text: string): Uint8Array {\n\tconst clean = text.replace(/[^A-Za-z0-9+/]/g, '')\n\tconst bytes: number[] = []\n\n\tlet buffer = 0\n\tlet bits = 0\n\n\tfor (const char of clean) {\n\t\tconst value = BASE64_LOOKUP[char]\n\t\tif (value === undefined) continue\n\n\t\tbuffer = (buffer << 6) | value\n\t\tbits += 6\n\n\t\tif (bits >= 8) {\n\t\t\tbits -= 8\n\t\t\tbytes.push((buffer >> bits) & 0xff)\n\t\t}\n\t}\n\n\treturn new Uint8Array(bytes)\n}\n\n/**\n * Encodes raw bytes as base64 without relying on Node or DOM globals.\n *\n * @param bytes - Raw input bytes\n * @returns Base64 text\n */\nexport function encodeBase64(bytes: Uint8Array): string {\n\tlet result = ''\n\tfor (let index = 0; index < bytes.length; index += 3) {\n\t\tconst first = bytes[index]\n\t\tconst second = bytes[index + 1]\n\t\tconst third = bytes[index + 2]\n\t\tif (first === undefined) break\n\t\tconst value = (first << 16) | ((second ?? 0) << 8) | (third ?? 0)\n\t\tresult += BASE64_CHARS[(value >> 18) & 63] ?? ''\n\t\tresult += BASE64_CHARS[(value >> 12) & 63] ?? ''\n\t\tresult += second === undefined ? '=' : (BASE64_CHARS[(value >> 6) & 63] ?? '')\n\t\tresult += third === undefined ? '=' : (BASE64_CHARS[value & 63] ?? '')\n\t}\n\treturn result\n}\n\n/** Encodes UTF-8 text as bytes. */\nexport function textToBytes(value: string): Uint8Array {\n\treturn new TextEncoder().encode(value)\n}\n\n/** Decodes UTF-8 bytes as text. */\nexport function bytesToText(value: Uint8Array): string {\n\treturn new TextDecoder().decode(value)\n}\n\n/**\n * Converts a header record to Fetch-domain name/value entries.\n *\n * @param headers - Header record\n * @returns Protocol header entries\n */\nexport function browserHeadersToProtocol(\n\theaders: Readonly<Record<string, string>>,\n): ReadonlyArray<Readonly<Record<string, string>>> {\n\treturn Object.entries(headers).map(([name, value]) => ({ name, value }))\n}\n\n/**\n * Decodes a Chromium Headers object into string values, skipping every entry that is neither a\n * string nor a finite number.\n *\n * @param value - Unknown headers\n * @returns Frozen-compatible header record\n */\nexport function readBrowserHeaders(value: unknown): Readonly<Record<string, string>> {\n\tif (!isRecord(value)) return {}\n\tconst headers: Record<string, string> = {}\n\tfor (const [name, entry] of Object.entries(value)) {\n\t\tif (isString(entry) || isFiniteNumber(entry)) headers[name] = String(entry)\n\t}\n\treturn headers\n}\n\n/**\n * Builds a standards-shaped HAR 1.2 entry from one observed exchange.\n *\n * @param pending - Request and optional response captured by the recorder\n * @param duration - Whole exchange duration in milliseconds\n * @param body - Optional decoded response body\n * @param error - Optional request failure description\n * @returns HAR 1.2 entry\n */\nexport function createBrowserHAREntry(\n\tpending: BrowserHARPending,\n\tduration: number,\n\tbody?: Uint8Array,\n\terror?: string,\n): BrowserHAREntry {\n\tconst response = pending.response\n\tconst requestHeaders: BrowserHARValue[] = Object.entries(pending.request.headers).map(\n\t\t([name, value]) => ({ name, value }),\n\t)\n\tconst responseHeaders: BrowserHARValue[] =\n\t\tresponse === undefined\n\t\t\t? []\n\t\t\t: Object.entries(response.headers).map(([name, value]) => ({ name, value }))\n\tconst query: BrowserHARValue[] = []\n\tif (URL.canParse(pending.request.url)) {\n\t\tfor (const [name, value] of new URL(pending.request.url).searchParams) {\n\t\t\tquery.push({ name, value })\n\t\t}\n\t}\n\tconst post = pending.request.post\n\tconst requestMime =\n\t\tObject.entries(pending.request.headers).find(\n\t\t\t([name]) => name.toLowerCase() === 'content-type',\n\t\t)?.[1] ?? 'application/octet-stream'\n\tconst redirect =\n\t\tresponse === undefined\n\t\t\t? ''\n\t\t\t: (Object.entries(response.headers).find(\n\t\t\t\t\t([name]) => name.toLowerCase() === 'location',\n\t\t\t\t)?.[1] ?? '')\n\tconst timing = response?.timing\n\tconst dns = timing?.dns === undefined ? -1 : Math.max(0, timing.dns.end - timing.dns.start)\n\tconst connect =\n\t\ttiming?.connect === undefined ? -1 : Math.max(0, timing.connect.end - timing.connect.start)\n\tconst send = timing?.send === undefined ? 0 : Math.max(0, timing.send.end - timing.send.start)\n\tconst wait =\n\t\ttiming?.receive === undefined\n\t\t\t? Math.max(0, duration)\n\t\t\t: Math.max(0, timing.receive - (timing.send?.end ?? 0))\n\tconst ssl = timing?.ssl === undefined ? -1 : Math.max(0, timing.ssl.end - timing.ssl.start)\n\tconst text = body === undefined ? undefined : encodeBase64(body)\n\tconst size = body?.byteLength ?? (response === undefined ? 0 : -1)\n\n\treturn {\n\t\tstartedDateTime: new Date(pending.started).toISOString(),\n\t\ttime: Math.max(0, duration),\n\t\trequest: {\n\t\t\tmethod: pending.request.method,\n\t\t\turl: pending.request.url,\n\t\t\thttpVersion: response?.protocol ?? 'HTTP/0.0',\n\t\t\tcookies: [],\n\t\t\theaders: requestHeaders,\n\t\t\tqueryString: query,\n\t\t\t...(post !== undefined\n\t\t\t\t? {\n\t\t\t\t\t\tpostData: {\n\t\t\t\t\t\t\tmimeType: requestMime,\n\t\t\t\t\t\t\ttext: post,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\theadersSize: -1,\n\t\t\tbodySize: post === undefined ? 0 : textToBytes(post).byteLength,\n\t\t},\n\t\tresponse: {\n\t\t\tstatus: response?.status ?? 0,\n\t\t\tstatusText: response?.phrase ?? error ?? 'Request failed',\n\t\t\thttpVersion: response?.protocol ?? 'HTTP/0.0',\n\t\t\tcookies: [],\n\t\t\theaders: responseHeaders,\n\t\t\tcontent: {\n\t\t\t\tsize,\n\t\t\t\tmimeType: response?.mime ?? 'application/octet-stream',\n\t\t\t\t...(text !== undefined ? { text, encoding: 'base64' } : {}),\n\t\t\t},\n\t\t\tredirectURL: redirect,\n\t\t\theadersSize: -1,\n\t\t\tbodySize: size,\n\t\t},\n\t\tcache: {},\n\t\ttimings: {\n\t\t\tblocked: -1,\n\t\t\tdns,\n\t\t\tconnect,\n\t\t\tsend,\n\t\t\twait,\n\t\t\treceive: Math.max(0, duration - wait - send),\n\t\t\tssl,\n\t\t},\n\t}\n}\n\n/**\n * Converts HAR name/value headers into a Fetch-domain header record.\n *\n * @param headers - HAR header entries\n * @returns Header record with later duplicate names replacing earlier values\n */\nexport function browserHARHeadersToRecord(\n\theaders: readonly BrowserHARValue[],\n): Readonly<Record<string, string>> {\n\tconst result: Record<string, string> = {}\n\tfor (const header of headers) {\n\t\tObject.defineProperty(result, header.name, {\n\t\t\tvalue: header.value,\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\twritable: true,\n\t\t})\n\t}\n\treturn result\n}\n\n/**\n * Validates the HAR 1.2 fields required for deterministic replay.\n *\n * @param value - Candidate archive\n */\nexport function validateBrowserHAR(value: unknown): asserts value is BrowserHAR {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isRecord(value['log']) ||\n\t\tvalue['log']['version'] !== '1.2' ||\n\t\t!isRecord(value['log']['creator']) ||\n\t\t!isString(value['log']['creator']['name']) ||\n\t\t!isString(value['log']['creator']['version']) ||\n\t\t!isArray(value['log']['entries'])\n\t) {\n\t\tthrow new BrowserError('Browser HAR document is malformed')\n\t}\n\tfor (const [index, entry] of value['log']['entries'].entries()) {\n\t\tif (\n\t\t\t!isRecord(entry) ||\n\t\t\t!isString(entry['startedDateTime']) ||\n\t\t\t!isFiniteNumber(Date.parse(entry['startedDateTime'])) ||\n\t\t\t!isFiniteNumber(entry['time']) ||\n\t\t\tentry['time'] < 0 ||\n\t\t\t!isRecord(entry['request']) ||\n\t\t\t!isString(entry['request']['url']) ||\n\t\t\t!URL.canParse(entry['request']['url']) ||\n\t\t\t!isString(entry['request']['method']) ||\n\t\t\t!isString(entry['request']['httpVersion']) ||\n\t\t\t!isArray(entry['request']['cookies']) ||\n\t\t\t!isArray(entry['request']['headers']) ||\n\t\t\t!isArray(entry['request']['queryString']) ||\n\t\t\t!isInteger(entry['request']['headersSize']) ||\n\t\t\tentry['request']['headersSize'] < -1 ||\n\t\t\t!isInteger(entry['request']['bodySize']) ||\n\t\t\tentry['request']['bodySize'] < -1 ||\n\t\t\t!isRecord(entry['response']) ||\n\t\t\t!isInteger(entry['response']['status']) ||\n\t\t\tentry['response']['status'] < 0 ||\n\t\t\tentry['response']['status'] > 999 ||\n\t\t\t!isString(entry['response']['statusText']) ||\n\t\t\t!isString(entry['response']['httpVersion']) ||\n\t\t\t!isArray(entry['response']['cookies']) ||\n\t\t\t!isArray(entry['response']['headers']) ||\n\t\t\t!isRecord(entry['response']['content']) ||\n\t\t\t!isString(entry['response']['redirectURL']) ||\n\t\t\t!isInteger(entry['response']['headersSize']) ||\n\t\t\tentry['response']['headersSize'] < -1 ||\n\t\t\t!isInteger(entry['response']['bodySize']) ||\n\t\t\tentry['response']['bodySize'] < -1 ||\n\t\t\t!isRecord(entry['cache']) ||\n\t\t\t!isRecord(entry['timings'])\n\t\t) {\n\t\t\tthrow new BrowserError('Browser HAR entry is malformed', undefined, { index })\n\t\t}\n\t\tfor (const [cookieIndex, cookie] of entry['request']['cookies'].entries()) {\n\t\t\tif (\n\t\t\t\t!isRecord(cookie) ||\n\t\t\t\t!isString(cookie['name']) ||\n\t\t\t\t!isString(cookie['value']) ||\n\t\t\t\t(cookie['path'] !== undefined && !isString(cookie['path'])) ||\n\t\t\t\t(cookie['domain'] !== undefined && !isString(cookie['domain'])) ||\n\t\t\t\t(cookie['expires'] !== undefined && !isString(cookie['expires'])) ||\n\t\t\t\t(cookie['httpOnly'] !== undefined && !isBoolean(cookie['httpOnly'])) ||\n\t\t\t\t(cookie['secure'] !== undefined && !isBoolean(cookie['secure']))\n\t\t\t) {\n\t\t\t\tthrow new BrowserError('Browser HAR request cookie is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\tcookie: cookieIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tfor (const [headerIndex, header] of entry['request']['headers'].entries()) {\n\t\t\tif (!isRecord(header) || !isString(header['name']) || !isString(header['value'])) {\n\t\t\t\tthrow new BrowserError('Browser HAR request header is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\theader: headerIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tfor (const [queryIndex, query] of entry['request']['queryString'].entries()) {\n\t\t\tif (!isRecord(query) || !isString(query['name']) || !isString(query['value'])) {\n\t\t\t\tthrow new BrowserError('Browser HAR query value is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\tquery: queryIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tconst post = entry['request']['postData']\n\t\tif (\n\t\t\tpost !== undefined &&\n\t\t\t(!isRecord(post) || !isString(post['mimeType']) || !isString(post['text']))\n\t\t) {\n\t\t\tthrow new BrowserError('Browser HAR request body is malformed', undefined, { index })\n\t\t}\n\t\tfor (const [cookieIndex, cookie] of entry['response']['cookies'].entries()) {\n\t\t\tif (\n\t\t\t\t!isRecord(cookie) ||\n\t\t\t\t!isString(cookie['name']) ||\n\t\t\t\t!isString(cookie['value']) ||\n\t\t\t\t(cookie['path'] !== undefined && !isString(cookie['path'])) ||\n\t\t\t\t(cookie['domain'] !== undefined && !isString(cookie['domain'])) ||\n\t\t\t\t(cookie['expires'] !== undefined && !isString(cookie['expires'])) ||\n\t\t\t\t(cookie['httpOnly'] !== undefined && !isBoolean(cookie['httpOnly'])) ||\n\t\t\t\t(cookie['secure'] !== undefined && !isBoolean(cookie['secure']))\n\t\t\t) {\n\t\t\t\tthrow new BrowserError('Browser HAR response cookie is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\tcookie: cookieIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tfor (const [headerIndex, header] of entry['response']['headers'].entries()) {\n\t\t\tif (!isRecord(header) || !isString(header['name']) || !isString(header['value'])) {\n\t\t\t\tthrow new BrowserError('Browser HAR response header is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\theader: headerIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tconst text = entry['response']['content']['text']\n\t\tconst encoding = entry['response']['content']['encoding']\n\t\tif (\n\t\t\t!isInteger(entry['response']['content']['size']) ||\n\t\t\tentry['response']['content']['size'] < -1 ||\n\t\t\t!isString(entry['response']['content']['mimeType']) ||\n\t\t\t(text !== undefined && !isString(text)) ||\n\t\t\t(encoding !== undefined && encoding !== 'base64') ||\n\t\t\t(encoding === 'base64' &&\n\t\t\t\t(text === undefined ||\n\t\t\t\t\t!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(text)))\n\t\t) {\n\t\t\tthrow new BrowserError('Browser HAR response content is malformed', undefined, { index })\n\t\t}\n\t\tfor (const name of ['blocked', 'dns', 'connect', 'send', 'wait', 'receive', 'ssl']) {\n\t\t\tconst timing = entry['timings'][name]\n\t\t\tif (!isFiniteNumber(timing) || timing < -1) {\n\t\t\t\tthrow new BrowserError('Browser HAR timing is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\ttiming: name,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Matches a request against route criteria.\n *\n * @param request - Observed request\n * @param query - Match criteria\n * @returns True if every supplied criterion matches; false otherwise\n */\nexport function matchesBrowserRoute(request: BrowserRequest, query: BrowserRouteQuery): boolean {\n\tif (query.method !== undefined && request.method !== query.method) return false\n\tif (query.resource !== undefined && request.resource !== query.resource) return false\n\tif (query.url === undefined) return true\n\treturn matchesBrowserURL(request.url, query.url)\n}\n\n/**\n * Matches a URL using Chromium-style `*` and `**` glob segments.\n *\n * @param url - Candidate URL\n * @param pattern - Glob pattern\n * @returns True if the whole URL matches; false otherwise\n */\nexport function matchesBrowserURL(url: string, pattern: string): boolean {\n\tconst source = pattern\n\t\t.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\t\t.replace(/\\*\\*/g, '[[DOUBLE_STAR]]')\n\t\t.replace(/\\*/g, '[^/]*')\n\t\t.replace(/\\[\\[DOUBLE_STAR\\]\\]/g, '.*')\n\treturn new RegExp(`^${source}$`).test(url)\n}\n\n/**\n * Decodes the `Page.addScriptToEvaluateOnNewDocument` result, throwing a `BrowserError`\n * off-shape.\n *\n * @param value - Unknown protocol result\n * @returns Script identifier\n */\nexport function readBrowserScriptIdentifier(value: unknown): string {\n\tif (!isRecord(value) || !isString(value['identifier'])) {\n\t\tthrow new BrowserError('Browser init script identifier is malformed')\n\t}\n\treturn value['identifier']\n}\n\n/**\n * Validates viewport input coordinates.\n *\n * @param point - Candidate point\n */\nexport function validateBrowserPoint(point: BrowserPoint): void {\n\tif (!isFiniteNumber(point.x) || !isFiniteNumber(point.y)) {\n\t\tthrow new BrowserError('Browser input coordinates must be finite', undefined, { point })\n\t}\n}\n\n/**\n * Validates the bounded delay, count, and steps of one trusted-input operation.\n *\n * @remarks\n * The parameter is `BrowserOperationOptions`, so one validator answers for a\n * mouse click, a mouse drag, and keyboard entry alike.\n *\n * @param options - Candidate input options\n */\nexport function validateBrowserInputOptions(options?: BrowserOperationOptions): void {\n\tif (options?.delay !== undefined && (!isFiniteNumber(options.delay) || options.delay < 0)) {\n\t\tthrow new BrowserError('Browser input delay must be non-negative and finite', undefined, {\n\t\t\tdelay: options.delay,\n\t\t})\n\t}\n\tif (options?.count !== undefined && (!isInteger(options.count) || options.count <= 0)) {\n\t\tthrow new BrowserError('Browser click count must be a positive integer', undefined, {\n\t\t\tcount: options.count,\n\t\t})\n\t}\n\tif (options?.steps !== undefined && (!isInteger(options.steps) || options.steps <= 0)) {\n\t\tthrow new BrowserError('Browser drag steps must be a positive integer', undefined, {\n\t\t\tsteps: options.steps,\n\t\t})\n\t}\n}\n\n/**\n * Validates a public browser timeout before protocol work begins.\n *\n * @param timeout - Timeout in milliseconds\n */\nexport function validateBrowserTimeout(timeout: number): void {\n\tif (!isFiniteNumber(timeout) || timeout < 0) {\n\t\tthrow new BrowserError('Browser timeout must be a non-negative finite number', undefined, {\n\t\t\ttimeout,\n\t\t})\n\t}\n}\n\n/**\n * Validates Chromium viewport metrics.\n *\n * @param viewport - Public viewport configuration\n */\nexport function validateBrowserViewport(viewport: BrowserViewport): void {\n\tif (\n\t\t!isInteger(viewport.width) ||\n\t\tviewport.width <= 0 ||\n\t\t!isInteger(viewport.height) ||\n\t\tviewport.height <= 0\n\t) {\n\t\tthrow new BrowserError('Browser viewport dimensions must be positive integers', undefined, {\n\t\t\tviewport,\n\t\t})\n\t}\n\tif (viewport.scale !== undefined && (!isFiniteNumber(viewport.scale) || viewport.scale <= 0)) {\n\t\tthrow new BrowserError('Browser viewport scale must be positive and finite', undefined, {\n\t\t\tscale: viewport.scale,\n\t\t})\n\t}\n}\n\n/**\n * Validates context emulation boundaries before partial application.\n *\n * @param options - Public emulation configuration\n */\nexport function validateBrowserEmulationOptions(options: BrowserEmulationOptions): void {\n\tif (options.viewport !== undefined) validateBrowserViewport(options.viewport)\n\tif (options.user !== undefined && options.user.value.length === 0) {\n\t\tthrow new BrowserError('Browser user agent cannot be empty')\n\t}\n\tif (options.locale !== undefined && options.locale.length === 0) {\n\t\tthrow new BrowserError('Browser locale cannot be empty')\n\t}\n\tif (options.timezone !== undefined && options.timezone.length === 0) {\n\t\tthrow new BrowserError('Browser timezone cannot be empty')\n\t}\n\tif (options.geolocation !== undefined) {\n\t\tconst location = options.geolocation\n\t\tif (\n\t\t\t!isFiniteNumber(location.latitude) ||\n\t\t\tlocation.latitude < -90 ||\n\t\t\tlocation.latitude > 90 ||\n\t\t\t!isFiniteNumber(location.longitude) ||\n\t\t\tlocation.longitude < -180 ||\n\t\t\tlocation.longitude > 180 ||\n\t\t\t(location.accuracy !== undefined &&\n\t\t\t\t(!isFiniteNumber(location.accuracy) || location.accuracy < 0))\n\t\t) {\n\t\t\tthrow new BrowserError('Browser geolocation is outside valid coordinate bounds', undefined, {\n\t\t\t\tlocation,\n\t\t\t})\n\t\t}\n\t}\n\tfor (const name of Object.keys(options.headers ?? {})) {\n\t\tif (name.length === 0) throw new BrowserError('Browser header name cannot be empty')\n\t}\n}\n\n/**\n * Validates isolated-context options before creating remote state.\n *\n * @param options - Public context configuration\n */\nexport function validateBrowserContextOptions(options?: BrowserContextOptions): void {\n\tif (options === undefined) return\n\tif (options.emulation !== undefined) validateBrowserEmulationOptions(options.emulation)\n\tif (options.proxy !== undefined) {\n\t\tif (options.proxy.server.length === 0) {\n\t\t\tthrow new BrowserError('Browser proxy server cannot be empty')\n\t\t}\n\t\tif (options.proxy.bypass?.some((entry) => entry.length === 0) === true) {\n\t\t\tthrow new BrowserError('Browser proxy bypass entries cannot be empty')\n\t\t}\n\t}\n\tfor (const origin of options.origins ?? []) {\n\t\tconst result = attempt(() => new URL(origin))\n\t\tif (!result.success) {\n\t\t\tthrow new BrowserError('Browser context origin must be valid', undefined, { origin })\n\t\t}\n\t\tconst url = result.value\n\t\tif (\n\t\t\t(url.protocol !== 'http:' && url.protocol !== 'https:') ||\n\t\t\turl.origin !== origin.replace(/\\/$/, '')\n\t\t) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Browser context origin must be an absolute HTTP(S) origin',\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\torigin,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t}\n\tif (options.downloads !== undefined && options.downloads.path.length === 0) {\n\t\tthrow new BrowserError('Browser download path cannot be empty')\n\t}\n}\n\n/**\n * Validates Accessibility-domain snapshot bounds.\n *\n * @param options - Public accessibility snapshot options\n */\nexport function validateBrowserAccessibilityOptions(options?: BrowserAccessibilityOptions): void {\n\tif (options?.root !== undefined && (!isInteger(options.root) || options.root <= 0)) {\n\t\tthrow new BrowserError('Browser accessibility root must be a positive integer', undefined, {\n\t\t\troot: options.root,\n\t\t})\n\t}\n\tif (options?.depth !== undefined && (!isInteger(options.depth) || options.depth < 0)) {\n\t\tthrow new BrowserError(\n\t\t\t'Browser accessibility depth must be a non-negative integer',\n\t\t\tundefined,\n\t\t\t{ depth: options.depth },\n\t\t)\n\t}\n}\n\n/**\n * Validates and compiles Page.printToPDF parameters.\n *\n * @param options - Public PDF options\n * @returns Protocol parameter record\n */\nexport function browserPDFToParams(options?: BrowserPDFOptions): Readonly<Record<string, unknown>> {\n\tconst params: Record<string, unknown> = {\n\t\tlandscape: options?.landscape ?? false,\n\t\tprintBackground: options?.background ?? false,\n\t\tdisplayHeaderFooter: options?.header !== undefined || options?.footer !== undefined,\n\t\tgenerateTaggedPDF: options?.tagged ?? false,\n\t\tgenerateDocumentOutline: options?.outline ?? false,\n\t}\n\tif (options?.scale !== undefined) {\n\t\tvalidateBrowserRange(options.scale, 'PDF scale', 0.1, 2)\n\t\tparams['scale'] = options.scale\n\t}\n\tif (options?.width !== undefined) {\n\t\tvalidateBrowserRange(options.width, 'PDF width', 0, Number.MAX_VALUE, false)\n\t\tparams['paperWidth'] = options.width\n\t}\n\tif (options?.height !== undefined) {\n\t\tvalidateBrowserRange(options.height, 'PDF height', 0, Number.MAX_VALUE, false)\n\t\tparams['paperHeight'] = options.height\n\t}\n\tif (options?.ranges !== undefined) params['pageRanges'] = options.ranges\n\tif (options?.header !== undefined) params['headerTemplate'] = options.header\n\tif (options?.footer !== undefined) params['footerTemplate'] = options.footer\n\tfor (const [name, value] of Object.entries(options?.margin ?? {})) {\n\t\tif (!isFiniteNumber(value)) continue\n\t\tvalidateBrowserRange(value, `PDF ${name} margin`, 0, Number.MAX_VALUE)\n\t\tparams[`margin${name[0]?.toUpperCase()}${name.slice(1)}`] = value\n\t}\n\treturn params\n}\n\n/**\n * Validates and compiles basic Page.captureScreenshot parameters.\n *\n * @param options - Public screenshot options\n * @returns Protocol parameter record\n */\nexport function browserScreenshotToParams(\n\toptions?: BrowserScreenshotOptions,\n): Readonly<Record<string, unknown>> {\n\tconst format = options?.format ?? 'png'\n\tif (options?.quality !== undefined) {\n\t\tif (format !== 'jpeg') {\n\t\t\tthrow new BrowserError('Browser screenshot quality is only valid for JPEG')\n\t\t}\n\t\tif (!isInteger(options.quality) || options.quality < 0 || options.quality > 100) {\n\t\t\tthrow new BrowserError('Browser screenshot quality must be an integer from 0 to 100')\n\t\t}\n\t}\n\tif (options?.full === true && options.clip !== undefined) {\n\t\tthrow new BrowserError('Browser screenshot cannot combine full-page and clip capture')\n\t}\n\tconst params: Record<string, unknown> = {\n\t\tformat,\n\t\tfromSurface: true,\n\t}\n\tif (options?.quality !== undefined) params['quality'] = options.quality\n\tif (options?.clip !== undefined) {\n\t\tconst [x, y, width, height] = options.clip\n\t\tvalidateBrowserRange(x, 'Screenshot clip x', -Number.MAX_VALUE, Number.MAX_VALUE)\n\t\tvalidateBrowserRange(y, 'Screenshot clip y', -Number.MAX_VALUE, Number.MAX_VALUE)\n\t\tvalidateBrowserRange(width, 'Screenshot clip width', 0, Number.MAX_VALUE, false)\n\t\tvalidateBrowserRange(height, 'Screenshot clip height', 0, Number.MAX_VALUE, false)\n\t\tparams['clip'] = { x, y, width, height, scale: 1 }\n\t\tparams['captureBeyondViewport'] = true\n\t}\n\treturn params\n}\n\n/**\n * Validates a finite numeric range.\n *\n * @param value - Candidate number\n * @param field - Diagnostic field\n * @param minimum - Inclusive lower bound\n * @param maximum - Inclusive upper bound\n * @param inclusive - Whether the lower bound is inclusive\n */\nexport function validateBrowserRange(\n\tvalue: number,\n\tfield: string,\n\tminimum: number,\n\tmaximum: number,\n\tinclusive = true,\n): void {\n\tif (\n\t\t!isFiniteNumber(value) ||\n\t\t(inclusive ? value < minimum : value <= minimum) ||\n\t\tvalue > maximum\n\t) {\n\t\tthrow new BrowserError(`${field} is outside its valid range`, undefined, {\n\t\t\tvalue,\n\t\t\tminimum,\n\t\t\tmaximum,\n\t\t\tinclusive,\n\t\t})\n\t}\n}\n\n/**\n * Decodes Accessibility-domain nodes into a flat serializable tree, throwing a `BrowserError`\n * off-shape.\n *\n * @param value - Unknown full or partial AX-tree result\n * @returns Valid accessibility snapshot\n */\nexport function readBrowserAccessibility(value: unknown): BrowserAccessibilitySnapshot {\n\tif (!isRecord(value) || !isArray(value['nodes'])) {\n\t\tthrow new BrowserError('Browser accessibility tree is malformed')\n\t}\n\tconst nodes: BrowserAXNode[] = []\n\tfor (const [index, candidate] of value['nodes'].entries()) {\n\t\tif (!isRecord(candidate) || !isString(candidate['nodeId'])) {\n\t\t\tthrow new BrowserError('Browser accessibility node is malformed', undefined, { index })\n\t\t}\n\t\tconst children = isArray(candidate['childIds']) ? candidate['childIds'].filter(isString) : []\n\t\tconst properties: Record<string, unknown> = {}\n\t\tif (isArray(candidate['properties'])) {\n\t\t\tfor (const property of candidate['properties']) {\n\t\t\t\tif (!isRecord(property) || !isString(property['name'])) continue\n\t\t\t\tproperties[property['name']] = readBrowserAXValue(property['value'])\n\t\t\t}\n\t\t}\n\t\tnodes.push({\n\t\t\tid: candidate['nodeId'],\n\t\t\tparent: isString(candidate['parentId']) ? candidate['parentId'] : undefined,\n\t\t\tchildren,\n\t\t\tbackend: isInteger(candidate['backendDOMNodeId']) ? candidate['backendDOMNodeId'] : undefined,\n\t\t\tframe: isString(candidate['frameId']) ? candidate['frameId'] : undefined,\n\t\t\tignored: candidate['ignored'] === true,\n\t\t\trole: parseBrowserAXString(candidate['role']),\n\t\t\tname: parseBrowserAXString(candidate['name']),\n\t\t\tdescription: parseBrowserAXString(candidate['description']),\n\t\t\tvalue: readBrowserAXValue(candidate['value']),\n\t\t\tproperties,\n\t\t})\n\t}\n\treturn {\n\t\troots: nodes.filter((node) => node.parent === undefined).map((node) => node.id),\n\t\tnodes,\n\t}\n}\n\n/**\n * Decodes an Accessibility-domain AXValue, or `undefined` when the record carries none.\n *\n * @param value - Unknown AX value\n * @returns Underlying value\n */\nexport function readBrowserAXValue(value: unknown): unknown {\n\treturn isRecord(value) && 'value' in value ? value['value'] : undefined\n}\n\n/**\n * Concatenates byte chunks without Node-specific buffers.\n *\n * @param chunks - Byte arrays in source order\n * @returns Combined bytes\n */\nexport function concatBytes(chunks: readonly Uint8Array[]): Uint8Array {\n\tconst count = chunks.reduce((total, chunk) => total + chunk.byteLength, 0)\n\tconst result = new Uint8Array(count)\n\tlet offset = 0\n\tfor (const chunk of chunks) {\n\t\tresult.set(chunk, offset)\n\t\toffset += chunk.byteLength\n\t}\n\treturn result\n}\n\n/**\n * Decodes one `IO.read` response, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown protocol result\n * @returns Valid stream chunk\n */\nexport function readBrowserStreamChunk(value: unknown): BrowserStreamChunk {\n\tif (!isRecord(value) || !isString(value['data'])) {\n\t\tthrow new BrowserError('Browser IO stream chunk is malformed')\n\t}\n\treturn {\n\t\tbytes:\n\t\t\tvalue['base64Encoded'] === true ? decodeBase64(value['data']) : textToBytes(value['data']),\n\t\teof: value['eof'] === true,\n\t}\n}\n\n/**\n * Decodes JavaScript precise coverage, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown `Profiler.takePreciseCoverage` result\n * @returns Script coverage\n */\nexport function readBrowserScriptCoverage(value: unknown): readonly BrowserScriptCoverage[] {\n\tif (!isRecord(value) || !isArray(value['result'])) {\n\t\tthrow new BrowserError('Browser JavaScript coverage is malformed')\n\t}\n\treturn value['result'].map((script, index) => {\n\t\tif (\n\t\t\t!isRecord(script) ||\n\t\t\t!isString(script['scriptId']) ||\n\t\t\t!isString(script['url']) ||\n\t\t\t!isArray(script['functions'])\n\t\t) {\n\t\t\tthrow new BrowserError('Browser script coverage entry is malformed', undefined, { index })\n\t\t}\n\t\tconst functions: BrowserFunctionCoverage[] = script['functions'].map((entry, functionIndex) => {\n\t\t\tif (!isRecord(entry) || !isString(entry['functionName']) || !isArray(entry['ranges'])) {\n\t\t\t\tthrow new BrowserError('Browser function coverage entry is malformed', undefined, {\n\t\t\t\t\tindex,\n\t\t\t\t\tfunction: functionIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tname: entry['functionName'],\n\t\t\t\tranges: readBrowserCoverageRanges(entry['ranges'], index),\n\t\t\t\tblock: entry['isBlockCoverage'] === true,\n\t\t\t}\n\t\t})\n\t\treturn {\n\t\t\tid: script['scriptId'],\n\t\t\turl: script['url'],\n\t\t\tfunctions,\n\t\t}\n\t})\n}\n\n/**\n * Decodes CSS rule usage, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown `CSS.stopRuleUsageTracking` result\n * @returns Stylesheet coverage\n */\nexport function readBrowserStyleCoverage(value: unknown): readonly BrowserStyleCoverage[] {\n\tif (!isRecord(value) || !isArray(value['ruleUsage'])) {\n\t\tthrow new BrowserError('Browser CSS coverage is malformed')\n\t}\n\tconst styles = new Map<string, BrowserCoverageRange[]>()\n\tfor (const [index, entry] of value['ruleUsage'].entries()) {\n\t\tif (\n\t\t\t!isRecord(entry) ||\n\t\t\t!isString(entry['styleSheetId']) ||\n\t\t\t!isInteger(entry['startOffset']) ||\n\t\t\tentry['startOffset'] < 0 ||\n\t\t\t!isInteger(entry['endOffset']) ||\n\t\t\tentry['endOffset'] < entry['startOffset']\n\t\t) {\n\t\t\tthrow new BrowserError('Browser CSS coverage entry is malformed', undefined, { index })\n\t\t}\n\t\tconst ranges = styles.get(entry['styleSheetId']) ?? []\n\t\tranges.push({\n\t\t\tstart: entry['startOffset'],\n\t\t\tend: entry['endOffset'],\n\t\t\tcount: entry['used'] === true ? 1 : 0,\n\t\t})\n\t\tstyles.set(entry['styleSheetId'], ranges)\n\t}\n\treturn [...styles].map(([id, ranges]) => ({ id, ranges }))\n}\n\n/**\n * Decodes and normalizes coverage ranges, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown ranges\n * @param script - Script index for diagnostics\n * @returns Valid ranges\n */\nexport function readBrowserCoverageRanges(\n\tvalue: unknown,\n\tscript: number,\n): readonly BrowserCoverageRange[] {\n\tif (!isArray(value)) {\n\t\tthrow new BrowserError('Browser coverage ranges are malformed', undefined, { script })\n\t}\n\treturn value.map((range, index) => {\n\t\tif (\n\t\t\t!isRecord(range) ||\n\t\t\t!isInteger(range['startOffset']) ||\n\t\t\trange['startOffset'] < 0 ||\n\t\t\t!isInteger(range['endOffset']) ||\n\t\t\trange['endOffset'] < range['startOffset'] ||\n\t\t\t!isInteger(range['count']) ||\n\t\t\trange['count'] < 0\n\t\t) {\n\t\t\tthrow new BrowserError('Browser coverage range is malformed', undefined, {\n\t\t\t\tscript,\n\t\t\t\tindex,\n\t\t\t})\n\t\t}\n\t\treturn {\n\t\t\tstart: range['startOffset'],\n\t\t\tend: range['endOffset'],\n\t\t\tcount: range['count'],\n\t\t}\n\t})\n}\n\n/**\n * Decodes Performance-domain metrics, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown metrics result\n * @returns Valid metrics\n */\nexport function readBrowserMetrics(value: unknown): readonly BrowserMetric[] {\n\tif (!isRecord(value) || !isArray(value['metrics'])) {\n\t\tthrow new BrowserError('Browser performance metrics are malformed')\n\t}\n\treturn value['metrics'].map((metric, index) => {\n\t\tif (!isRecord(metric) || !isString(metric['name']) || !isFiniteNumber(metric['value'])) {\n\t\t\tthrow new BrowserError('Browser performance metric is malformed', undefined, { index })\n\t\t}\n\t\treturn { name: metric['name'], value: metric['value'] }\n\t})\n}\n\n/**\n * Decodes one CPU profile, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown `Profiler.stop` result\n * @returns Valid profile\n */\nexport function readBrowserProfile(value: unknown): BrowserProfile {\n\tif (!isRecord(value) || !isRecord(value['profile'])) {\n\t\tthrow new BrowserError('Browser CPU profile is malformed')\n\t}\n\tconst profile = value['profile']\n\tif (\n\t\t!isFiniteNumber(profile['startTime']) ||\n\t\t!isFiniteNumber(profile['endTime']) ||\n\t\tprofile['endTime'] < profile['startTime'] ||\n\t\t!isArray(profile['nodes'])\n\t) {\n\t\tthrow new BrowserError('Browser CPU profile metadata is malformed')\n\t}\n\tconst nodes: BrowserProfileNode[] = profile['nodes'].map((node, index) => {\n\t\tif (\n\t\t\t!isRecord(node) ||\n\t\t\t!isInteger(node['id']) ||\n\t\t\tnode['id'] < 0 ||\n\t\t\t(node['hitCount'] !== undefined && (!isInteger(node['hitCount']) || node['hitCount'] < 0))\n\t\t) {\n\t\t\tthrow new BrowserError('Browser CPU profile node is malformed', undefined, { index })\n\t\t}\n\t\tconst children = node['children'] === undefined ? [] : parseArray(node['children'], isInteger)\n\t\tif (children === undefined || children.some((child) => child < 0)) {\n\t\t\tthrow new BrowserError('Browser CPU profile node is malformed', undefined, { index })\n\t\t}\n\t\treturn {\n\t\t\tid: node['id'],\n\t\t\tframe: readBrowserProfileFrame(node['callFrame'], index),\n\t\t\thit: isInteger(node['hitCount']) ? node['hitCount'] : undefined,\n\t\t\tchildren,\n\t\t}\n\t})\n\tconst samples = profile['samples'] === undefined ? [] : parseArray(profile['samples'], isInteger)\n\tif (samples === undefined || samples.some((sample) => sample < 0)) {\n\t\tthrow new BrowserError('Browser CPU profile samples are malformed')\n\t}\n\tconst deltas =\n\t\tprofile['timeDeltas'] === undefined ? [] : parseArray(profile['timeDeltas'], isFiniteNumber)\n\tif (deltas === undefined || deltas.some((delta) => delta < 0)) {\n\t\tthrow new BrowserError('Browser CPU profile deltas are malformed')\n\t}\n\treturn {\n\t\tstart: profile['startTime'],\n\t\tend: profile['endTime'],\n\t\tnodes,\n\t\tsamples,\n\t\tdeltas,\n\t}\n}\n\n/**\n * Decodes a CPU profile call frame, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown call frame\n * @param node - Node index for diagnostics\n * @returns Valid call frame\n */\nexport function readBrowserProfileFrame(value: unknown, node: number): BrowserProfileFrame {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['functionName']) ||\n\t\t!isString(value['scriptId']) ||\n\t\t!isString(value['url']) ||\n\t\t!isInteger(value['lineNumber']) ||\n\t\t!isInteger(value['columnNumber'])\n\t) {\n\t\tthrow new BrowserError('Browser CPU profile call frame is malformed', undefined, { node })\n\t}\n\treturn {\n\t\tfunction: value['functionName'],\n\t\tscript: value['scriptId'],\n\t\turl: value['url'],\n\t\tline: value['lineNumber'],\n\t\tcolumn: value['columnNumber'],\n\t}\n}\n\n/**\n * Converts a typed cookie input into Chromium protocol fields.\n *\n * @param cookie - Validated public cookie input\n * @returns Protocol cookie record\n */\nexport function cookieToProtocol(cookie: BrowserCookieInput): Readonly<Record<string, unknown>> {\n\tif (cookie.name.length === 0) throw new BrowserError('Browser cookie name cannot be empty')\n\tif (cookie.url === undefined && (cookie.domain === undefined || cookie.path === undefined)) {\n\t\tthrow new BrowserError('Browser cookie requires either url or domain with path', undefined, {\n\t\t\tname: cookie.name,\n\t\t})\n\t}\n\tif (cookie.url !== undefined && !URL.canParse(cookie.url)) {\n\t\tthrow new BrowserError('Browser cookie URL must be valid', undefined, {\n\t\t\tname: cookie.name,\n\t\t\turl: cookie.url,\n\t\t})\n\t}\n\tif (cookie.expires !== undefined && !isFiniteNumber(cookie.expires)) {\n\t\tthrow new BrowserError('Browser cookie expiry must be finite', undefined, {\n\t\t\tname: cookie.name,\n\t\t\texpires: cookie.expires,\n\t\t})\n\t}\n\tconst result: Record<string, unknown> = {\n\t\tname: cookie.name,\n\t\tvalue: cookie.value,\n\t}\n\tif (cookie.url !== undefined) result['url'] = cookie.url\n\tif (cookie.domain !== undefined) result['domain'] = cookie.domain\n\tif (cookie.path !== undefined) result['path'] = cookie.path\n\tif (cookie.expires !== undefined) result['expires'] = cookie.expires\n\tif (cookie.http !== undefined) result['httpOnly'] = cookie.http\n\tif (cookie.secure !== undefined) result['secure'] = cookie.secure\n\tif (cookie.site !== undefined) result['sameSite'] = cookie.site\n\tif (cookie.priority !== undefined) result['priority'] = cookie.priority\n\tif (cookie.partition !== undefined) {\n\t\tresult['partitionKey'] = {\n\t\t\ttopLevelSite: cookie.partition.site,\n\t\t\thasCrossSiteAncestor: cookie.partition.ancestor ?? false,\n\t\t}\n\t}\n\treturn result\n}\n\n/**\n * Decodes the cookies `Storage.getCookies` returns, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown protocol result\n * @returns Valid cookies\n */\nexport function readBrowserCookies(value: unknown): readonly BrowserCookie[] {\n\tif (!isRecord(value) || !isArray(value['cookies'])) {\n\t\tthrow new BrowserError('Browser cookie result is malformed')\n\t}\n\treturn value['cookies'].map((candidate, index) => readBrowserCookie(candidate, index))\n}\n\n/**\n * Decodes one Chromium cookie, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown cookie record\n * @param index - Source array position for diagnostics\n * @returns Valid cookie\n */\nexport function readBrowserCookie(value: unknown, index: number): BrowserCookie {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isString(value['name']) ||\n\t\t!isString(value['value']) ||\n\t\t!isString(value['domain']) ||\n\t\t!isString(value['path']) ||\n\t\t!isFiniteNumber(value['expires']) ||\n\t\t!isBoolean(value['httpOnly']) ||\n\t\t!isBoolean(value['secure'])\n\t) {\n\t\tthrow new BrowserError('Browser cookie is malformed', undefined, { index })\n\t}\n\tconst sameSite = parseEnum(value['sameSite'], ['Strict', 'Lax', 'None'])\n\tif (value['sameSite'] !== undefined && sameSite === undefined) {\n\t\tthrow new BrowserError('Browser cookie same-site policy is malformed', undefined, { index })\n\t}\n\treturn {\n\t\tname: value['name'],\n\t\tvalue: value['value'],\n\t\tdomain: value['domain'],\n\t\tpath: value['path'],\n\t\texpires: value['expires'],\n\t\thttp: value['httpOnly'],\n\t\tsecure: value['secure'],\n\t\tsite: sameSite,\n\t\tpartition: parseBrowserCookiePartition(value['partitionKey']),\n\t}\n}\n\n/**\n * Matches a decoded cookie against one request URL.\n *\n * @param cookie - Decoded context cookie\n * @param value - Candidate absolute URL\n * @returns True if domain, path, and secure constraints match; false otherwise\n */\nexport function matchesBrowserCookieURL(cookie: BrowserCookie, value: string): boolean {\n\tconst result = attempt(() => new URL(value))\n\tif (!result.success) {\n\t\tthrow new BrowserError('Browser cookie URL must be valid', undefined, { url: value })\n\t}\n\tconst url = result.value\n\tconst domain = cookie.domain.startsWith('.') ? cookie.domain.slice(1) : cookie.domain\n\tconst domainMatches = url.hostname === domain || url.hostname.endsWith(`.${domain}`)\n\tconst pathMatches =\n\t\turl.pathname === cookie.path ||\n\t\t(url.pathname.startsWith(cookie.path) &&\n\t\t\t(cookie.path.endsWith('/') || url.pathname[cookie.path.length] === '/'))\n\tconst secureMatches = !cookie.secure || url.protocol === 'https:' || url.protocol === 'wss:'\n\treturn domainMatches && pathMatches && secureMatches\n}\n\n/**\n * Decodes one in-page web-storage snapshot, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown evaluation result\n * @param origin - Origin represented by the result\n * @returns Valid origin storage\n */\nexport function readBrowserStorageOrigin(value: unknown, origin: string): BrowserStorageOrigin {\n\tif (!isRecord(value))\n\t\tthrow new BrowserError('Browser storage result is malformed', undefined, { origin })\n\treturn {\n\t\torigin,\n\t\tlocal: readBrowserStorageEntries(value['local'], origin, 'local'),\n\t\tsession: readBrowserStorageEntries(value['session'], origin, 'session'),\n\t}\n}\n\n/**\n * Decodes a list of web-storage entries, throwing a `BrowserError` off-shape.\n *\n * @param value - Unknown entry list\n * @param origin - Origin used for diagnostics\n * @param storage - Storage family used for diagnostics\n * @returns Valid key/value entries\n */\nexport function readBrowserStorageEntries(\n\tvalue: unknown,\n\torigin: string,\n\tstorage: 'local' | 'session',\n): readonly BrowserStorageEntry[] {\n\tif (!isArray(value)) {\n\t\tthrow new BrowserError('Browser storage entries are malformed', undefined, { origin, storage })\n\t}\n\treturn value.map((entry, index) => {\n\t\tif (!isRecord(entry) || !isString(entry['name']) || !isString(entry['value'])) {\n\t\t\tthrow new BrowserError('Browser storage entry is malformed', undefined, {\n\t\t\t\torigin,\n\t\t\t\tstorage,\n\t\t\t\tindex,\n\t\t\t})\n\t\t}\n\t\treturn { name: entry['name'], value: entry['value'] }\n\t})\n}\n\n/**\n * Converts typed media preferences to Chromium emulated media features.\n *\n * @param media - Public media configuration\n * @returns Protocol feature records\n */\nexport function mediaToFeatures(\n\tmedia: BrowserMedia,\n): ReadonlyArray<Readonly<Record<string, string>>> {\n\tconst features: Array<Readonly<Record<string, string>>> = []\n\tif (media.scheme !== undefined) {\n\t\tfeatures.push({ name: 'prefers-color-scheme', value: media.scheme })\n\t}\n\tif (media.contrast !== undefined) {\n\t\tfeatures.push({ name: 'prefers-contrast', value: media.contrast })\n\t}\n\tif (media.motion !== undefined) {\n\t\tfeatures.push({ name: 'prefers-reduced-motion', value: media.motion })\n\t}\n\tif (media.colors !== undefined) {\n\t\tfeatures.push({ name: 'forced-colors', value: media.colors })\n\t}\n\treturn features\n}\n\n/**\n * Decodes a Chromium runtime stack trace, skipping every off-shape call frame.\n *\n * @param value - Unknown stack trace or call-frame list\n * @returns Valid stack frames\n */\nexport function readBrowserStack(value: unknown): readonly BrowserStackFrame[] {\n\tconst frames = isRecord(value) ? value['callFrames'] : value\n\tif (!isArray(frames)) return []\n\tconst stack: BrowserStackFrame[] = []\n\tfor (const frame of frames) {\n\t\tif (\n\t\t\t!isRecord(frame) ||\n\t\t\t!isString(frame['url']) ||\n\t\t\t!isString(frame['functionName']) ||\n\t\t\t!isInteger(frame['lineNumber']) ||\n\t\t\t!isInteger(frame['columnNumber'])\n\t\t) {\n\t\t\tcontinue\n\t\t}\n\t\tstack.push({\n\t\t\turl: frame['url'],\n\t\t\tfunction: frame['functionName'],\n\t\t\tline: frame['lineNumber'],\n\t\t\tcolumn: frame['columnNumber'],\n\t\t})\n\t}\n\treturn stack\n}\n\n/**\n * Decodes a Runtime remote object's printable value, falling back to its unserializable form\n * and then its description, or `undefined` when it carries none.\n *\n * @param value - Unknown remote object\n * @returns By-value data or a description\n */\nexport function readBrowserRemoteValue(value: unknown): unknown {\n\tif (!isRecord(value)) return undefined\n\tif ('value' in value) return value['value']\n\tif (isString(value['unserializableValue'])) return value['unserializableValue']\n\tif (isString(value['description'])) return value['description']\n\treturn undefined\n}\n\n/**\n * Decodes one CDP `Runtime.evaluate` result, throwing a `BrowserError` on a failed evaluation\n * and a `BrowserResultLimitError` past the guarded result size.\n *\n * @param value - Unknown CDP result\n * @returns The returned by-value payload, or undefined\n */\nexport function readEvaluationResult(value: unknown): unknown {\n\tif (!isRecord(value)) return undefined\n\n\tif (isRecord(value['exceptionDetails'])) {\n\t\tconst details = value['exceptionDetails']\n\t\tif (isRecord(details['exception']) && isString(details['exception']['description'])) {\n\t\t\tconst description = details['exception']['description']\n\t\t\tconst limitMatch = BROWSER_RESULT_LIMIT_PATTERN.exec(description)\n\t\t\tif (limitMatch !== null) {\n\t\t\t\tthrow new BrowserResultLimitError('Evaluation result exceeds BROWSER_RESULT_LIMIT', {\n\t\t\t\t\tlength: Number(limitMatch[1]),\n\t\t\t\t\tlimit: BROWSER_RESULT_LIMIT,\n\t\t\t\t})\n\t\t\t}\n\t\t\tthrow new BrowserError(description)\n\t\t}\n\t\tthrow new BrowserError('JavaScript evaluation failed')\n\t}\n\n\tconst remoteObject = value['result']\n\tif (!isRecord(remoteObject)) return undefined\n\treturn 'value' in remoteObject ? remoteObject['value'] : undefined\n}\n\n/**\n * Requires an evaluated browser value to be a string.\n *\n * @param value - Candidate evaluated value\n * @param field - Human-readable field name used in the error\n * @returns The narrowed string\n */\nexport function requireBrowserString(value: unknown, field: string): string {\n\tif (isString(value)) return value\n\tthrow new BrowserError(`${field} failed: no string value returned`)\n}\n\n/**\n * Reads the execution context id from a CDP `Page.createIsolatedWorld` reply.\n *\n * @param value - Unknown CDP result\n * @param frame - The frame id the world was created for, which the error context names\n * @returns The execution context id of the created world\n * @throws Thrown when the reply carries no integer `executionContextId`.\n */\nexport function readBrowserWorld(value: unknown, frame: string): number {\n\tif (isRecord(value) && isInteger(value['executionContextId'])) {\n\t\treturn value['executionContextId']\n\t}\n\tthrow new BrowserError('Failed to create frame execution context', undefined, { frame })\n}\n\n/**\n * Extracts one bounded slice of a projected text, cutting after a line break where one fits.\n *\n * @remarks\n * `offset` and `limit` count UTF-16 code units. A slice whose window reaches the end of the text\n * holds the rest of it. Otherwise the slice ends after the last line break inside\n * `offset` to `offset + limit` that lies past `offset`, and at `offset + limit` when none does. A\n * hard cut that would end on the high half of a surrogate pair ends one unit earlier, so a limit\n * of 1 before a pair yields an empty slice rather than a lone surrogate. An `offset` at or past\n * the end yields an empty slice.\n *\n * @param text - The whole projection\n * @param offset - The index the slice starts at. Default: `0`\n * @param limit - The most characters the slice holds. Default: unbounded\n * @returns The slice, its start, and the length of the whole text\n * @throws Thrown when `offset` is not a non-negative integer or `limit` is not a positive integer.\n *\n * @example\n * ```ts\n * import { extractBrowserSlice } from '@orkestrel/browser'\n *\n * extractBrowserSlice('alpha\\nbeta\\ngamma', 0, 12) // { text: 'alpha\\nbeta\\n', offset: 0, total: 16 }\n * ```\n */\nexport function extractBrowserSlice(text: string, offset = 0, limit?: number): BrowserReadResult {\n\tif (!isInteger(offset) || offset < 0) {\n\t\tthrow new BrowserError('Browser read offset must be a non-negative integer', undefined, {\n\t\t\toffset,\n\t\t})\n\t}\n\tif (limit !== undefined && (!isInteger(limit) || limit < 1)) {\n\t\tthrow new BrowserError('Browser read limit must be a positive integer', undefined, { limit })\n\t}\n\tconst total = text.length\n\tif (limit === undefined || offset + limit >= total) {\n\t\treturn { text: text.slice(offset), offset, total }\n\t}\n\tconst window = text.slice(offset, offset + limit)\n\tconst line = window.lastIndexOf('\\n')\n\tif (line > 0) return { text: window.slice(0, line + 1), offset, total }\n\tconst last = window.charCodeAt(limit - 1)\n\tconst next = text.charCodeAt(offset + limit)\n\tconst split = last >= 0xd800 && last <= 0xdbff && next >= 0xdc00 && next <= 0xdfff\n\treturn { text: split ? window.slice(0, -1) : window, offset, total }\n}\n\n/**\n * Decodes a flattened CDP `Page.getFrameTree` result into depth-first frame metadata, skipping\n * every off-shape frame, then appends each attached out-of-process iframe target the tree does\n * not list.\n *\n * @param value - Unknown CDP result\n * @param targets - Attached iframe targets, each described as a frame\n * @returns Frame metadata in depth-first, main-frame-first order, then the unlisted targets\n */\nexport function readBrowserFrames(\n\tvalue: unknown,\n\ttargets: readonly BrowserFrameInfo[] = [],\n): readonly BrowserFrameInfo[] {\n\tconst frames: BrowserFrameInfo[] = []\n\tconst stack: Array<Readonly<Record<string, unknown>>> =\n\t\tisRecord(value) && isRecord(value['frameTree']) ? [value['frameTree']] : []\n\n\twhile (stack.length > 0) {\n\t\tconst node = stack.pop()\n\t\tif (node === undefined) break\n\t\tconst frame = node['frame']\n\n\t\tif (isRecord(frame) && isString(frame['id']) && isString(frame['url'])) {\n\t\t\tframes.push({\n\t\t\t\tid: frame['id'],\n\t\t\t\tparent: isString(frame['parentId']) ? frame['parentId'] : undefined,\n\t\t\t\tname: isString(frame['name']) && frame['name'] !== '' ? frame['name'] : undefined,\n\t\t\t\turl: frame['url'],\n\t\t\t})\n\t\t}\n\n\t\tconst children = node['childFrames']\n\t\tif (!isArray(children)) continue\n\t\tfor (let index = children.length - 1; index >= 0; index -= 1) {\n\t\t\tconst child = children[index]\n\t\t\tif (isRecord(child)) stack.push(child)\n\t\t}\n\t}\n\n\tfor (const target of targets) {\n\t\tif (!frames.some((frame) => frame.id === target.id)) frames.push(target)\n\t}\n\treturn frames\n}\n\n/**\n * Decodes the first `DOM.getContentQuads` quad and its center, throwing a `BrowserError`\n * off-shape.\n *\n * @param value - Unknown CDP result\n * @returns Decoded quad\n */\nexport function readBrowserQuad(value: unknown): BrowserQuad {\n\tif (!isRecord(value) || !isArray(value['quads'])) {\n\t\tthrow new BrowserError('Element has no content quad')\n\t}\n\tconst points = parseNumberArray(value['quads'][0])\n\tif (points === undefined || points.length !== 8) {\n\t\tthrow new BrowserError('Element has a malformed content quad')\n\t}\n\tconst x1 = points[0]\n\tconst y1 = points[1]\n\tconst x2 = points[2]\n\tconst y2 = points[3]\n\tconst x3 = points[4]\n\tconst y3 = points[5]\n\tconst x4 = points[6]\n\tconst y4 = points[7]\n\tif (\n\t\tx1 === undefined ||\n\t\ty1 === undefined ||\n\t\tx2 === undefined ||\n\t\ty2 === undefined ||\n\t\tx3 === undefined ||\n\t\ty3 === undefined ||\n\t\tx4 === undefined ||\n\t\ty4 === undefined\n\t) {\n\t\tthrow new BrowserError('Element has a malformed content quad')\n\t}\n\treturn {\n\t\tpoints: [x1, y1, x2, y2, x3, y3, x4, y4],\n\t\tcenter: {\n\t\t\tx: (x1 + x2 + x3 + x4) / 4,\n\t\t\ty: (y1 + y2 + y3 + y4) / 4,\n\t\t},\n\t}\n}\n\n/**\n * Extracts a keyboard chord such as `Control+Shift+P` into its parts, throwing a\n * `BrowserError` on an empty chord or an unsupported modifier.\n *\n * @param value - Chord source\n * @returns Canonical modifiers and terminal key\n * @throws Thrown when the chord is empty or names an unsupported modifier.\n */\nexport function extractBrowserChord(value: string): BrowserChord {\n\tconst parts = value.split('+').filter((part) => part.length > 0)\n\tconst key = parts.pop()\n\tif (key === undefined) throw new BrowserError('Browser key chord is empty')\n\tconst modifiers = parts.map((modifier) => {\n\t\tswitch (modifier) {\n\t\t\tcase 'Ctrl':\n\t\t\t\treturn 'Control'\n\t\t\tcase 'Cmd':\n\t\t\tcase 'Command':\n\t\t\t\treturn 'Meta'\n\t\t\tdefault:\n\t\t\t\treturn modifier\n\t\t}\n\t})\n\tfor (const modifier of modifiers) {\n\t\tif (BROWSER_KEY_MODIFIERS[modifier] === undefined) {\n\t\t\tthrow new BrowserError(`Unsupported browser key modifier: ${modifier}`)\n\t\t}\n\t}\n\treturn { modifiers, key }\n}\n\n/**\n * Computes the CDP Input modifier bitmask.\n *\n * @param modifiers - Canonical modifier names\n * @returns Combined CDP modifier mask\n */\nexport function computeBrowserModifiers(modifiers: readonly string[]): number {\n\tlet mask = 0\n\tfor (const modifier of modifiers) mask |= BROWSER_KEY_MODIFIERS[modifier] ?? 0\n\treturn mask\n}\n\n/**\n * Computes the CDP Input pressed-button bitmask.\n *\n * @param buttons - Pressed public mouse buttons\n * @returns Combined CDP pressed-button mask\n */\nexport function computeBrowserButtons(buttons: readonly BrowserMouseButton[]): number {\n\tlet mask = 0\n\tfor (const button of buttons) mask |= BROWSER_MOUSE_BUTTON_MASKS[button]\n\treturn mask\n}\n\n/**\n * Normalizes one key to CDP keyboard event data.\n *\n * @param value - Key value or canonical key name\n * @returns Normalized key data\n */\nexport function keyToBrowserInput(value: string): BrowserKey {\n\tconst named: Readonly<Record<string, BrowserKey>> = {\n\t\tBackspace: { key: 'Backspace', code: 'Backspace', text: undefined, number: 8 },\n\t\tTab: { key: 'Tab', code: 'Tab', text: '\\t', number: 9 },\n\t\tEnter: { key: 'Enter', code: 'Enter', text: '\\r', number: 13 },\n\t\tShift: { key: 'Shift', code: 'ShiftLeft', text: undefined, number: 16 },\n\t\tControl: { key: 'Control', code: 'ControlLeft', text: undefined, number: 17 },\n\t\tAlt: { key: 'Alt', code: 'AltLeft', text: undefined, number: 18 },\n\t\tEscape: { key: 'Escape', code: 'Escape', text: undefined, number: 27 },\n\t\tSpace: { key: ' ', code: 'Space', text: ' ', number: 32 },\n\t\tPageUp: { key: 'PageUp', code: 'PageUp', text: undefined, number: 33 },\n\t\tPageDown: { key: 'PageDown', code: 'PageDown', text: undefined, number: 34 },\n\t\tEnd: { key: 'End', code: 'End', text: undefined, number: 35 },\n\t\tHome: { key: 'Home', code: 'Home', text: undefined, number: 36 },\n\t\tArrowLeft: { key: 'ArrowLeft', code: 'ArrowLeft', text: undefined, number: 37 },\n\t\tArrowUp: { key: 'ArrowUp', code: 'ArrowUp', text: undefined, number: 38 },\n\t\tArrowRight: { key: 'ArrowRight', code: 'ArrowRight', text: undefined, number: 39 },\n\t\tArrowDown: { key: 'ArrowDown', code: 'ArrowDown', text: undefined, number: 40 },\n\t\tDelete: { key: 'Delete', code: 'Delete', text: undefined, number: 46 },\n\t\tMeta: { key: 'Meta', code: 'MetaLeft', text: undefined, number: 91 },\n\t}\n\tconst matched = named[value]\n\tif (matched !== undefined) return matched\n\tif ([...value].length !== 1) throw new BrowserError(`Unsupported browser key: ${value}`)\n\tconst character = [...value][0]\n\tif (character === undefined) throw new BrowserError('Browser key is empty')\n\tconst upper = character.toUpperCase()\n\tconst letter = /^[A-Z]$/.test(upper)\n\tconst digit = /^[0-9]$/.test(character)\n\treturn {\n\t\tkey: character,\n\t\tcode: letter ? `Key${upper}` : digit ? `Digit${character}` : '',\n\t\ttext: character,\n\t\tnumber: upper.charCodeAt(0),\n\t}\n}\n\n/**\n * Decodes CDP snapshot sparse string data into a node-index map, skipping every off-shape\n * entry.\n *\n * @param value - Sparse `{ index, value }` record\n * @param strings - Snapshot string table\n * @returns Node-index to string map\n */\nexport function readRareStringData(\n\tvalue: unknown,\n\tstrings: readonly string[],\n): ReadonlyMap<number, string> {\n\tconst decoded = new Map<number, string>()\n\tif (!isRecord(value)) return decoded\n\tconst indexes = parseNumberArray(value['index'])\n\tconst values = parseNumberArray(value['value'])\n\tif (indexes === undefined || values === undefined) return decoded\n\n\tfor (let index = 0; index < indexes.length; index += 1) {\n\t\tconst node = indexes[index]\n\t\tconst text = parseSnapshotString(strings, values[index])\n\t\tif (node !== undefined && text !== undefined) decoded.set(node, text)\n\t}\n\treturn decoded\n}\n\n/**\n * Decodes CDP snapshot sparse boolean data into a set of node indexes, skipping every\n * off-shape entry.\n *\n * @param value - Sparse `{ index }` record\n * @returns Set of node indexes whose value is true\n */\nexport function readRareBooleanData(value: unknown): ReadonlySet<number> {\n\tif (!isRecord(value)) return new Set()\n\treturn new Set(parseNumberArray(value['index']) ?? [])\n}\n\n/**\n * Decodes CDP snapshot sparse integer data into a node-index map, skipping every off-shape\n * entry.\n *\n * @param value - Sparse `{ index, value }` record\n * @returns Node-index to integer map\n */\nexport function readRareIntegerData(value: unknown): ReadonlyMap<number, number> {\n\tconst decoded = new Map<number, number>()\n\tif (!isRecord(value)) return decoded\n\tconst indexes = parseNumberArray(value['index'])\n\tconst values = parseNumberArray(value['value'])\n\tif (indexes === undefined || values === undefined) return decoded\n\n\tfor (let index = 0; index < indexes.length; index += 1) {\n\t\tconst node = indexes[index]\n\t\tconst integer = values[index]\n\t\tif (node !== undefined && integer !== undefined) decoded.set(node, integer)\n\t}\n\treturn decoded\n}\n\n/**\n * Decodes flattened CDP node attributes into a frozen record, skipping every off-shape pair.\n *\n * @param value - Candidate string-index array\n * @param strings - Snapshot string table\n * @returns Frozen attribute record\n */\nexport function readBrowserAttributes(\n\tvalue: unknown,\n\tstrings: readonly string[],\n): Readonly<Record<string, string>> {\n\tconst indexes = parseNumberArray(value)\n\tconst attributes: Record<string, string> = {}\n\tif (indexes === undefined) return Object.freeze(attributes)\n\n\tfor (let index = 0; index < indexes.length; index += 2) {\n\t\tconst name = parseSnapshotString(strings, indexes[index])\n\t\tconst attribute = parseSnapshotString(strings, indexes[index + 1])\n\t\tif (name !== undefined && attribute !== undefined) attributes[name] = attribute\n\t}\n\treturn Object.freeze(attributes)\n}\n\n/**\n * Decodes a CDP `DOMSnapshot.captureSnapshot` result into a serializable\n * `BrowserSnapshotInput`, throwing a `BrowserError` off-shape and a `BrowserResultLimitError`\n * past the configured node limit.\n *\n * @param value - Unknown CDP result\n * @param styles - Requested computed-style names, in protocol order\n * @param limit - Maximum accepted node count\n * @returns A typed serializable browser snapshot\n */\nexport function readBrowserSnapshot(\n\tvalue: unknown,\n\tstyles: readonly string[] = [],\n\tlimit = BROWSER_SNAPSHOT_NODE_LIMIT,\n): BrowserSnapshotInput {\n\tif (!isInteger(limit) || limit < 0) {\n\t\tthrow new BrowserError('Browser snapshot limit must be a non-negative integer', undefined, {\n\t\t\tlimit,\n\t\t})\n\t}\n\tif (!isRecord(value) || !isArray(value['strings']) || !isArray(value['documents'])) {\n\t\tthrow new BrowserError('Malformed DOMSnapshot.captureSnapshot result')\n\t}\n\tconst strings = parseArray(value['strings'], isString)\n\tif (strings === undefined) {\n\t\tthrow new BrowserError('Malformed DOMSnapshot string table')\n\t}\n\tlet count = 0\n\tfor (const document of value['documents']) {\n\t\tif (!isRecord(document) || !isRecord(document['nodes'])) continue\n\t\tcount += parseNumberArray(document['nodes']['nodeType'])?.length ?? 0\n\t}\n\tif (count > limit) {\n\t\tthrow new BrowserResultLimitError('DOM snapshot exceeds the configured node limit', {\n\t\t\tlength: count,\n\t\t\tlimit,\n\t\t})\n\t}\n\n\tconst documents: BrowserDocument[] = []\n\tfor (let documentIndex = 0; documentIndex < value['documents'].length; documentIndex += 1) {\n\t\tconst rawDocument = value['documents'][documentIndex]\n\t\tif (!isRecord(rawDocument) || !isRecord(rawDocument['nodes'])) {\n\t\t\tthrow new BrowserError('Malformed DOM snapshot document', undefined, {\n\t\t\t\tdocument: documentIndex,\n\t\t\t})\n\t\t}\n\n\t\tconst rawNodes = rawDocument['nodes']\n\t\tconst frame = parseSnapshotString(strings, rawDocument['frameId'])\n\t\tconst url = parseSnapshotString(strings, rawDocument['documentURL'])\n\t\tconst title =\n\t\t\trawDocument['title'] === -1 ? '' : parseSnapshotString(strings, rawDocument['title'])\n\t\tif (frame === undefined || url === undefined || title === undefined) {\n\t\t\tthrow new BrowserError('Malformed DOM snapshot document metadata', undefined, {\n\t\t\t\tdocument: documentIndex,\n\t\t\t})\n\t\t}\n\t\tconst types = parseNumberArray(rawNodes['nodeType'])\n\t\tconst names = parseNumberArray(rawNodes['nodeName'])\n\t\tconst values = parseNumberArray(rawNodes['nodeValue'])\n\t\tif (types === undefined || names === undefined || values === undefined) {\n\t\t\tthrow new BrowserError('Malformed DOM snapshot node table', undefined, {\n\t\t\t\tdocument: documentIndex,\n\t\t\t})\n\t\t}\n\n\t\tconst parents = parseNumberArray(rawNodes['parentIndex']) ?? []\n\t\tconst ids = parseNumberArray(rawNodes['backendNodeId']) ?? []\n\t\tconst rawAttributes = isArray(rawNodes['attributes']) ? rawNodes['attributes'] : []\n\t\tconst texts = readRareStringData(rawNodes['textValue'], strings)\n\t\tconst inputs = readRareStringData(rawNodes['inputValue'], strings)\n\t\tconst checked = readRareBooleanData(rawNodes['inputChecked'])\n\t\tconst selected = readRareBooleanData(rawNodes['optionSelected'])\n\t\tconst clickable = readRareBooleanData(rawNodes['isClickable'])\n\t\tconst shadows = readRareStringData(rawNodes['shadowRootType'], strings)\n\t\tconst contents = readRareIntegerData(rawNodes['contentDocumentIndex'])\n\t\tconst pseudos = readRareStringData(rawNodes['pseudoType'], strings)\n\t\tconst sources = readRareStringData(rawNodes['currentSourceURL'], strings)\n\t\tconst origins = readRareStringData(rawNodes['originURL'], strings)\n\t\tconst layouts = new Map<number, BrowserLayout>()\n\n\t\tif (isRecord(rawDocument['layout'])) {\n\t\t\tconst rawLayout = rawDocument['layout']\n\t\t\tconst nodeIndexes = parseNumberArray(rawLayout['nodeIndex']) ?? []\n\t\t\tconst rawStyles = isArray(rawLayout['styles']) ? rawLayout['styles'] : []\n\t\t\tconst rawBounds = isArray(rawLayout['bounds']) ? rawLayout['bounds'] : []\n\t\t\tconst rawTexts = parseNumberArray(rawLayout['text']) ?? []\n\t\t\tconst paints = parseNumberArray(rawLayout['paintOrders']) ?? []\n\t\t\tconst rawOffsets = isArray(rawLayout['offsetRects']) ? rawLayout['offsetRects'] : []\n\t\t\tconst rawScrolls = isArray(rawLayout['scrollRects']) ? rawLayout['scrollRects'] : []\n\t\t\tconst rawClients = isArray(rawLayout['clientRects']) ? rawLayout['clientRects'] : []\n\n\t\t\tfor (let layoutIndex = 0; layoutIndex < nodeIndexes.length; layoutIndex += 1) {\n\t\t\t\tconst nodeIndex = nodeIndexes[layoutIndex]\n\t\t\t\tif (nodeIndex === undefined) continue\n\t\t\t\tconst styleIndexes = parseNumberArray(rawStyles[layoutIndex]) ?? []\n\t\t\t\tconst computed: Record<string, string> = {}\n\t\t\t\tfor (let styleIndex = 0; styleIndex < styles.length; styleIndex += 1) {\n\t\t\t\t\tconst name = styles[styleIndex]\n\t\t\t\t\tconst style = parseSnapshotString(strings, styleIndexes[styleIndex])\n\t\t\t\t\tif (name !== undefined && style !== undefined) computed[name] = style\n\t\t\t\t}\n\t\t\t\tlayouts.set(nodeIndex, {\n\t\t\t\t\tbounds: parseBrowserRect(rawBounds[layoutIndex]),\n\t\t\t\t\tstyles: Object.freeze(computed),\n\t\t\t\t\ttext: parseSnapshotString(strings, rawTexts[layoutIndex]),\n\t\t\t\t\tpaint: paints[layoutIndex],\n\t\t\t\t\toffset: parseBrowserRect(rawOffsets[layoutIndex]),\n\t\t\t\t\tscroll: parseBrowserRect(rawScrolls[layoutIndex]),\n\t\t\t\t\tclient: parseBrowserRect(rawClients[layoutIndex]),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tconst nodes: BrowserNode[] = []\n\t\tfor (let nodeIndex = 0; nodeIndex < types.length; nodeIndex += 1) {\n\t\t\tconst category = types[nodeIndex]\n\t\t\tconst name = parseSnapshotString(strings, names[nodeIndex])\n\t\t\tconst nodeValue =\n\t\t\t\tvalues[nodeIndex] === -1 ? '' : parseSnapshotString(strings, values[nodeIndex])\n\t\t\tif (category === undefined || name === undefined || nodeValue === undefined) {\n\t\t\t\tthrow new BrowserError('Malformed DOM snapshot node', undefined, {\n\t\t\t\t\tdocument: documentIndex,\n\t\t\t\t\tindex: nodeIndex,\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst parent = parents[nodeIndex]\n\t\t\tnodes.push({\n\t\t\t\tdocument: documentIndex,\n\t\t\t\tframe,\n\t\t\t\tindex: nodeIndex,\n\t\t\t\tid: ids[nodeIndex],\n\t\t\t\tparent: parent === undefined || parent < 0 ? undefined : parent,\n\t\t\t\tcategory,\n\t\t\t\tname,\n\t\t\t\tvalue: nodeValue,\n\t\t\t\tattributes: readBrowserAttributes(rawAttributes[nodeIndex], strings),\n\t\t\t\ttext: texts.get(nodeIndex),\n\t\t\t\tinput: inputs.get(nodeIndex),\n\t\t\t\tchecked: checked.has(nodeIndex) ? true : undefined,\n\t\t\t\tselected: selected.has(nodeIndex) ? true : undefined,\n\t\t\t\tclickable: clickable.has(nodeIndex) ? true : undefined,\n\t\t\t\tshadow: shadows.get(nodeIndex),\n\t\t\t\tcontent: contents.get(nodeIndex),\n\t\t\t\tpseudo: pseudos.get(nodeIndex),\n\t\t\t\tsource: sources.get(nodeIndex),\n\t\t\t\torigin: origins.get(nodeIndex),\n\t\t\t\tlayout: layouts.get(nodeIndex),\n\t\t\t})\n\t\t}\n\n\t\tdocuments.push({\n\t\t\tindex: documentIndex,\n\t\t\tframe,\n\t\t\turl,\n\t\t\ttitle,\n\t\t\tnodes,\n\t\t\tscroll: [\n\t\t\t\tisFiniteNumber(rawDocument['scrollOffsetX']) ? rawDocument['scrollOffsetX'] : undefined,\n\t\t\t\tisFiniteNumber(rawDocument['scrollOffsetY']) ? rawDocument['scrollOffsetY'] : undefined,\n\t\t\t],\n\t\t\twidth: isFiniteNumber(rawDocument['contentWidth']) ? rawDocument['contentWidth'] : undefined,\n\t\t\theight: isFiniteNumber(rawDocument['contentHeight'])\n\t\t\t\t? rawDocument['contentHeight']\n\t\t\t\t: undefined,\n\t\t})\n\t}\n\n\treturn { documents, styles: [...styles] }\n}\n\n/**\n * Tests whether a browser-node matcher is a declarative query rather than a predicate.\n *\n * @param value - Browser-node query or predicate\n * @returns True if the matcher is a declarative query; false otherwise\n *\n * @example\n * ```ts\n * import { isBrowserNodeQuery } from '@orkestrel/browser'\n *\n * isBrowserNodeQuery({ name: 'main' }) // true\n * isBrowserNodeQuery(() => true) // false\n * ```\n */\nexport function isBrowserNodeQuery(\n\tvalue: BrowserNodeQuery | BrowserNodePredicate,\n): value is BrowserNodeQuery {\n\treturn !isFunction(value)\n}\n\n/**\n * Tests a captured node against a declarative query.\n *\n * @param node - Captured browser node\n * @param query - Fields every candidate must satisfy\n * @returns True if the node matches; false otherwise\n */\nexport function matchesBrowserNode(node: BrowserNode, query: BrowserNodeQuery): boolean {\n\tif (query.name !== undefined && node.name.toLowerCase() !== query.name.toLowerCase()) return false\n\tif (\n\t\tquery.text !== undefined &&\n\t\t!node.value.includes(query.text) &&\n\t\tnode.text?.includes(query.text) !== true\n\t) {\n\t\treturn false\n\t}\n\tif (query.frame !== undefined && node.frame !== query.frame) return false\n\tif (query.clickable !== undefined && (node.clickable === true) !== query.clickable) return false\n\tif (query.visible !== undefined && isBrowserNodeVisible(node) !== query.visible) return false\n\tif (query.attributes !== undefined) {\n\t\tfor (const [name, value] of Object.entries(query.attributes)) {\n\t\t\tif (node.attributes[name] !== value) return false\n\t\t}\n\t}\n\treturn true\n}\n\n/**\n * Tests whether a captured node has a non-empty rendered layout box.\n *\n * @param node - Captured browser node\n * @returns True if the snapshot reports a visible layout box; false otherwise\n */\nexport function isBrowserNodeVisible(node: BrowserNode): boolean {\n\tconst bounds = node.layout?.bounds\n\treturn bounds !== undefined && bounds[2] > 0 && bounds[3] > 0\n}\n\n/**\n * Awaits every teardown step in order and returns the first failure.\n *\n * @remarks\n * A teardown runs every step even after one of them fails, so a later release\n * is never skipped by an earlier fault, and the failure the caller reports is\n * the first one. The failure is returned rather than thrown, so the caller\n * keeps the cleanup that must still run after the steps and decides where the\n * throw belongs. A step may throw any value, `undefined` and `null` included,\n * so the first throw is retained by a separate flag rather than by testing the\n * retained value.\n *\n * @param steps - The teardown steps, in the order they must run\n * @returns The value the first failing step threw, or undefined when no step threw\n *\n * @example\n * ```ts\n * import { settleBrowserTeardown } from '@orkestrel/browser'\n *\n * const failure = await settleBrowserTeardown(\n * \t() => client.close(),\n * \t() => transport.close(),\n * )\n * if (failure !== undefined) throw failure\n * ```\n */\nexport async function settleBrowserTeardown(\n\t...steps: readonly BrowserTeardownFunction[]\n): Promise<unknown> {\n\tlet failure: unknown\n\tlet settled = false\n\tfor (const step of steps) {\n\t\ttry {\n\t\t\tawait step()\n\t\t} catch (error) {\n\t\t\tif (!settled) {\n\t\t\t\tfailure = error\n\t\t\t\tsettled = true\n\t\t\t}\n\t\t}\n\t}\n\treturn failure\n}\n\n/**\n * Collects parameter uses from native arguments and target names, keeping page arguments literal.\n * @param steps - Validated steps\n * @returns Parameter names mapped to their action and field paths\n */\nexport function collectBrowserJourneyBindings(\n\tsteps: readonly BrowserJourneyStepInput[],\n): ReadonlyMap<string, readonly string[]> {\n\tconst bindings = new Map<string, string[]>()\n\tfor (const step of steps) {\n\t\tif (!BROWSER_JOURNEY_ACTIONS.some((action) => action === step.action)) continue\n\t\tconst fields = Object.entries(step.arguments)\n\t\tif (step.target !== undefined) fields.push(['target.name', step.target.name])\n\t\tfor (const [field, value] of fields) {\n\t\t\tif (!isString(value) && isBrowserJourneyBinding(value)) {\n\t\t\t\tbindings.set(value.parameter, [\n\t\t\t\t\t...(bindings.get(value.parameter) ?? []),\n\t\t\t\t\t`${step.action}.${field}`,\n\t\t\t\t])\n\t\t\t}\n\t\t}\n\t}\n\treturn bindings\n}\n\n/**\n * Applies an ordered edit batch to a copy and validates its nonempty result and final bindings.\n * @param journey - Valid journey to edit\n * @param edits - Edits in application order\n * @returns The edited journey, with unbound parameters removed\n * @throws BrowserError - Thrown with BROWSER_JOURNEY_EDIT, a one-based index, and a reason clause when the batch fails\n */\nexport function editBrowserJourney(\n\tjourney: BrowserJourney,\n\tedits: readonly BrowserJourneyEdit[],\n): BrowserJourney {\n\tvalidateBrowserJourney(journey)\n\tconst steps = [...journey.steps]\n\tlet parameters = { ...journey.parameters }\n\tlet next = journey.next\n\tlet index = 0\n\tlet removal = 0\n\tconst declarations = new Map<string, number>()\n\tconst origins = new Map<string, number>()\n\tconst secrets = new Map<string, number>()\n\ttry {\n\t\tfor (const edit of edits) {\n\t\t\tindex += 1\n\t\t\tvalidateBrowserJourneyEdit(edit)\n\t\t\tswitch (edit.operation) {\n\t\t\t\tcase 'add': {\n\t\t\t\t\tconst anchor = edit.before ?? edit.after\n\t\t\t\t\tconst position =\n\t\t\t\t\t\tanchor === undefined ? steps.length : steps.findIndex((step) => step.id === anchor)\n\t\t\t\t\tif (position < 0) throw new BrowserError(`names unknown anchor \"${anchor}\"`)\n\t\t\t\t\tconst step = { ...edit.step, id: `s${next}` }\n\t\t\t\t\tnext += 1\n\t\t\t\t\tif (!Number.isSafeInteger(next))\n\t\t\t\t\t\tthrow new BrowserError('Invariant 2 (ids): has an invalid next counter')\n\t\t\t\t\tfor (const field of [...Object.keys(step.arguments), 'target.name'])\n\t\t\t\t\t\torigins.set(step.id + '.' + field, index)\n\t\t\t\t\tsteps.splice(position + (edit.after === undefined ? 0 : 1), 0, step)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'remove':\n\t\t\t\tcase 'update': {\n\t\t\t\t\tconst position = steps.findIndex((step) => step.id === edit.id)\n\t\t\t\t\tconst step = steps[position]\n\t\t\t\t\tif (step === undefined) throw new BrowserError(`names unknown step \"${edit.id}\"`)\n\t\t\t\t\tif (edit.operation === 'remove') {\n\t\t\t\t\t\tsteps.splice(position, 1)\n\t\t\t\t\t\tremoval = index\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst updated = {\n\t\t\t\t\t\t\t...step,\n\t\t\t\t\t\t\targuments: { ...step.arguments, ...edit.arguments },\n\t\t\t\t\t\t\t...(edit.target === undefined ? {} : { target: edit.target }),\n\t\t\t\t\t\t\t...(edit.tab === undefined ? {} : { tab: edit.tab }),\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalidateBrowserJourneyStep(updated)\n\t\t\t\t\t\tconst fields = [\n\t\t\t\t\t\t\t...Object.entries(edit.arguments ?? {}),\n\t\t\t\t\t\t\t...(edit.target === undefined ? [] : [['target.name', edit.target.name]]),\n\t\t\t\t\t\t]\n\t\t\t\t\t\tfor (const [field, value] of fields) {\n\t\t\t\t\t\t\tif (!isString(field)) continue\n\t\t\t\t\t\t\tconst previous = field === 'target.name' ? step.target?.name : step.arguments[field]\n\t\t\t\t\t\t\tif (JSON.stringify(previous) !== JSON.stringify(value))\n\t\t\t\t\t\t\t\torigins.set(step.id + '.' + field, index)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsteps[position] = updated\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'declare':\n\t\t\t\t\tif (edit.parameter.secret !== parameters[edit.name]?.secret) secrets.set(edit.name, index)\n\t\t\t\t\tparameters = { ...parameters, [edit.name]: edit.parameter }\n\t\t\t\t\tdeclarations.set(edit.name, index)\n\t\t\t}\n\t\t}\n\t\tif (steps.length === 0) {\n\t\t\tindex = removal\n\t\t\tthrow new BrowserError('removes the last step')\n\t\t}\n\t\tconst bindings = collectBrowserJourneyBindings(steps)\n\t\tfor (const [name, declaration] of declarations) {\n\t\t\tif (!bindings.has(name)) {\n\t\t\t\tindex = declaration\n\t\t\t\tthrow new BrowserError(`declares \"${name}\" but no step binds it`)\n\t\t\t}\n\t\t}\n\t\tparameters = Object.fromEntries(\n\t\t\tObject.entries(parameters).filter(([name]) => bindings.has(name)),\n\t\t)\n\t\tconst candidate = { ...journey, steps, parameters, next }\n\t\ttry {\n\t\t\tvalidateBrowserJourney(candidate)\n\t\t} catch (error) {\n\t\t\tif (isBrowserError(error) && isBrowserJourneyValidationContext(error.context)) {\n\t\t\t\tconst { parameter, step, field } = error.context\n\t\t\t\tindex = Math.max(origins.get(step + '.' + field) ?? 0, secrets.get(parameter) ?? 0)\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t\treturn structuredClone(candidate)\n\t} catch (error) {\n\t\tconst reason = normalizeBrowserJourneyReason(error)\n\t\tthrow new BrowserError(\n\t\t\t`Edit ${index} is refused: ${reason.startsWith('its ') ? reason : `it ${reason}`}`,\n\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t{\n\t\t\t\tindex,\n\t\t\t\treason,\n\t\t\t},\n\t\t)\n\t}\n}\n\n/**\n * Checks a journey name before store access.\n * @param name - Journey name\n * @throws BrowserError - Thrown with BROWSER_JOURNEY_PATH when the name is invalid\n * @example\n * validateBrowserJourneyName('add-kettle')\n */\nexport function validateBrowserJourneyName(name: string): void {\n\tif (!BROWSER_JOURNEY_NAME_PATTERN.test(name))\n\t\tthrow new BrowserError(`Refused journey name: ${name}`, 'BROWSER_JOURNEY_PATH')\n}\n\n/**\n * Checks the offset and limit of a store page.\n * @param offset - Nonnegative safe integer offset\n * @param limit - Positive safe integer limit\n * @throws BrowserError - Thrown with BROWSER_JOURNEY_ARGUMENT when either bound is invalid\n * @example\n * validateBrowserStorePage(0, 10)\n */\nexport function validateBrowserStorePage(offset: number, limit: number): void {\n\tif (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(limit) || limit < 1)\n\t\tthrow new BrowserError(\n\t\t\t'Paging requires a nonnegative integer offset and a positive integer limit',\n\t\t\t'BROWSER_JOURNEY_ARGUMENT',\n\t\t)\n}\n\n/**\n * Normalizes a failure to its first paragraph without an invariant label, directive, or final period.\n * @param error - Failure or reason text\n * @returns Reason clause\n * @example\n * normalizeBrowserJourneyReason(new Error('Invariant 4 (bindings): has an invalid binding.'))\n */\nexport function normalizeBrowserJourneyReason(error: unknown): string {\n\treturn renderBrowserRunResult(error instanceof Error ? error.message : String(error))\n\t\t.replace(/^Invariant \\d+ \\([^)]*\\): /, '')\n\t\t.replace(/\\.+$/, '')\n}\n\n/**\n * Renders an unreadable journey from its name and path-free reason.\n * @param fault - Structured store fault\n * @returns Listing fault line\n * @example\n * renderBrowserJourneyFault({ name: 'add-kettle', reason: 'Malformed journey revision' })\n */\nexport function renderBrowserJourneyFault(fault: BrowserStoreFault): string {\n\treturn `${fault.name} cannot be read: ${fault.reason}`\n}\n\n/**\n * Resolves a native string binding from supplied inputs.\n * @param value - Literal or parameter binding\n * @param inputs - Parameter values\n * @returns Literal text or the bound value\n * @throws BrowserError - Thrown when a binding has no input or the argument is malformed\n */\nexport function resolveBrowserJourneyBinding(\n\tvalue: unknown,\n\tinputs: Readonly<Record<string, string>>,\n): string {\n\tif (isString(value)) return value\n\tif (\n\t\tisBrowserJourneyBinding(value) &&\n\t\t!isString(value) &&\n\t\tObject.hasOwn(inputs, value.parameter)\n\t) {\n\t\tconst input = inputs[value.parameter]\n\t\tif (input !== undefined) return input\n\t}\n\tthrow new BrowserError('A journey binding has no value', 'BROWSER_JOURNEY_INPUT')\n}\n\n/**\n * Renders a journey with its parameter declarations and stable step ids.\n * @param journey - Valid journey\n * @returns The listing text without a trailing newline\n */\nexport function renderBrowserJourney(journey: BrowserJourney): string {\n\tvalidateBrowserJourney(journey)\n\tconst parameters = Object.entries(journey.parameters)\n\tconst defaults = Object.fromEntries(\n\t\tparameters.map(([name, parameter]) => [name, parameter.default ?? name]),\n\t)\n\tconst heading = `${journey.name} ${JSON.stringify(journey.description)}${parameters.length === 0 ? '' : ` (parameters: ${parameters.map(([name, parameter]) => `${name}${parameter.secret === true ? ' (secret)' : ''}`).join(', ')})`}`\n\tconst lines = journey.steps.map((step) => {\n\t\tconst name =\n\t\t\tstep.target === undefined\n\t\t\t\t? ''\n\t\t\t\t: `${step.target.role} ${JSON.stringify(resolveBrowserJourneyBinding(step.target.name, defaults))}${isString(step.target.name) ? '' : ` as ${step.target.name.parameter}`}`\n\t\tconst field = step.action === 'navigate' ? 'url' : step.action === 'press' ? 'key' : 'text'\n\t\tconst binding = step.arguments[field]\n\t\tconst text = isBrowserJourneyBinding(binding)\n\t\t\t? resolveBrowserJourneyBinding(binding, defaults)\n\t\t\t: ''\n\t\tconst suffix =\n\t\t\t!isString(binding) && isBrowserJourneyBinding(binding) ? ` as ${binding.parameter}` : ''\n\t\tswitch (step.action) {\n\t\t\tcase 'navigate':\n\t\t\t\treturn `${step.id} navigate ${text}${suffix}`\n\t\t\tcase 'click':\n\t\t\t\treturn `${step.id} click ${name}`\n\t\t\tcase 'type': {\n\t\t\t\tconst secret = isBrowserSecretBinding(step, journey.parameters)\n\t\t\t\treturn `${step.id} type ${secret ? '(secret)' : JSON.stringify(text)}${suffix} into ${name}${step.arguments['submit'] === true ? ', submit' : ''}`\n\t\t\t}\n\t\t\tcase 'press':\n\t\t\t\treturn `${step.id} press ${text}${suffix}`\n\t\t\tcase 'wait':\n\t\t\t\treturn `${step.id} wait ${JSON.stringify(text)}${suffix}`\n\t\t\tcase 'dialog':\n\t\t\t\treturn `${step.id} dialog ${step.arguments['accept'] === true ? 'accept' : 'dismiss'}${binding === undefined ? '' : ` ${JSON.stringify(text)}${suffix}`}`\n\t\t\tcase 'switch':\n\t\t\t\treturn `${step.id} switch ${JSON.stringify(step.tab?.title)} ${step.tab?.url}`\n\t\t\tcase 'unresolved':\n\t\t\t\treturn `${step.id} unresolved: ${step.gap}`\n\t\t\tdefault:\n\t\t\t\treturn `${step.id} ${step.action} ${JSON.stringify(step.arguments)}`\n\t\t}\n\t})\n\treturn [heading, ...lines].join('\\n')\n}\n\n/**\n * Derives the trigger text a run records for an action.\n * @param step - Valid step\n * @param inputs - Resolved parameter values; default: an empty record\n * @returns The action's trigger in the journey vocabulary\n */\nexport function deriveBrowserJourneyTrigger(\n\tstep: BrowserJourneyStepInput,\n\tinputs: Readonly<Record<string, string>> = {},\n): string {\n\tswitch (step.action) {\n\t\tcase 'click':\n\t\tcase 'type':\n\t\t\treturn resolveBrowserJourneyBinding(step.target?.name, inputs)\n\t\tcase 'press':\n\t\t\treturn resolveBrowserJourneyBinding(step.arguments['key'], inputs)\n\t\tcase 'navigate':\n\t\t\treturn resolveBrowserJourneyBinding(step.arguments['url'], inputs)\n\t\tcase 'wait':\n\t\t\treturn resolveBrowserJourneyBinding(step.arguments['text'], inputs)\n\t\tcase 'switch':\n\t\t\treturn step.tab?.title ?? ''\n\t\tcase 'dialog':\n\t\t\treturn step.arguments['accept'] === true ? 'accept' : 'dismiss'\n\t\tdefault:\n\t\t\treturn step.action\n\t}\n}\n\n/**\n * Collects the parameter names a native `type` step's `text` binds.\n *\n * @remarks\n * The names are the bindings `collectBrowserJourneyBindings` reports under `type.text`, so a page\n * tool's literal `text` argument binds no name. A recorder reads them as the names a derived\n * secret parameter cannot take.\n *\n * @param steps - Recorded steps\n * @returns Each bound name once, in the order `collectBrowserJourneyBindings` reports it\n */\nexport function collectBrowserJourneyTextBindings(\n\tsteps: readonly BrowserJourneyStepInput[],\n): readonly string[] {\n\treturn [...collectBrowserJourneyBindings(steps)]\n\t\t.filter(([, fields]) => fields.includes('type.text'))\n\t\t.map(([name]) => name)\n}\n\n/**\n * Derives an unused lower camel case secret parameter name from an accessible name.\n * @param name - Accessible name of the control\n * @param taken - Already declared names; default: an empty collection\n * @returns The derived name, or the first unused secretN fallback\n */\nexport function deriveBrowserJourneySecret(name: string, taken: readonly string[] = []): string {\n\tconst words = name\n\t\t.replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n\t\t.replace(/([A-Z])([A-Z][a-z])/g, '$1 $2')\n\t\t.split(/[^\\p{L}\\p{N}]+/u)\n\t\t.filter((word) => word.length > 0)\n\tconst candidate = words\n\t\t.map((word, index) =>\n\t\t\tindex === 0\n\t\t\t\t? word.toLowerCase()\n\t\t\t\t: `${word.charAt(0).toUpperCase()}${word.slice(1).toLowerCase()}`,\n\t\t)\n\t\t.join('')\n\tif (BROWSER_JOURNEY_PARAMETER_PATTERN.test(candidate) && !taken.includes(candidate))\n\t\treturn candidate\n\tlet count = 1\n\twhile (taken.includes(`secret${count}`)) count += 1\n\treturn `secret${count}`\n}\n\n/**\n * Generates a run id from an ISO timestamp and a cryptographic hexadecimal suffix.\n * @returns An ISO timestamp with hyphens replacing colons, followed by four hexadecimal digits\n */\nexport function generateBrowserRunId(): string {\n\tconst suffix = Array.from(crypto.getRandomValues(new Uint8Array(2)), (byte) =>\n\t\tbyte.toString(16).padStart(2, '0'),\n\t).join('')\n\treturn `${new Date().toISOString().replace(/:/g, '-')}-${suffix}`\n}\n\n/**\n * Renders a step receipt without its tool directive or appended view.\n * @param result - Step receipt or refusal\n * @returns A receipt line with directives outside quoted text removed\n */\nexport function renderBrowserRunResult(result: string): string {\n\tconst receipt = result.split('\\n\\n')[0] ?? ''\n\treturn receipt\n\t\t.split('\\n')\n\t\t.map((line) => {\n\t\t\tlet quoted = false\n\t\t\tlet escaped = false\n\t\t\tfor (let index = 0; index < line.length; index += 1) {\n\t\t\t\tconst character = line[index]\n\t\t\t\tif (escaped) {\n\t\t\t\t\tescaped = false\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (character === '\\\\' && quoted) {\n\t\t\t\t\tescaped = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (character === '\"') quoted = !quoted\n\t\t\t\tif (!quoted && line.startsWith('; call ', index))\n\t\t\t\t\treturn `${line.slice(0, index).replace(/\\.+$/, '')}.`\n\t\t\t}\n\t\t\treturn line\n\t\t})\n\t\t.join(' ')\n}\n\n/**\n * Renders a run heading and its receipts, followed by the supplied final view.\n * @param run - Run to render\n * @param view - Final view from the caller; omitted when unavailable\n * @returns The replay result without a trailing newline\n */\nexport function renderBrowserRun(run: BrowserRun, view?: string): string {\n\tconst last = run.steps.at(-1)\n\tconst next = run.journey.steps[run.steps.length]\n\tconst at =\n\t\trun.outcome === 'aborted' && last?.outcome === 'done'\n\t\t\t? (next?.id ?? last.id)\n\t\t\t: (last?.id ?? next?.id ?? 's1')\n\tconst reason = renderBrowserRunResult(last?.result ?? 'no step completed').replace(/\\.+$/, '')\n\tconst heading =\n\t\trun.outcome === 'complete'\n\t\t\t? `Replayed ${run.journey.name}: ${run.steps.length} of ${run.journey.steps.length} steps.`\n\t\t\t: run.outcome === 'stopped'\n\t\t\t\t? `Replay of ${run.journey.name} stopped at ${at} of ${run.journey.steps.length}: ${reason}.`\n\t\t\t\t: `Replay of ${run.journey.name} aborted at ${at} of ${run.journey.steps.length}.`\n\tconst lines = [\n\t\theading,\n\t\t...run.steps.map((step) => `${step.id} ${renderBrowserRunResult(step.result)}`),\n\t].join('\\n')\n\treturn view === undefined || view === '' ? lines : `${lines}\\n\\n${view}`\n}\n\n/**\n * Validates a parameter declaration, including the secret-default exclusion.\n * @param value - Candidate declaration\n * @throws BrowserError - Thrown when invariant 5 or the declaration shape fails\n */\nexport function validateBrowserJourneyParameter(\n\tvalue: unknown,\n): asserts value is BrowserJourneyParameter {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!isJSONValue(value) ||\n\t\tObject.keys(value).some((key) => key !== 'default' && key !== 'secret') ||\n\t\t(value['default'] !== undefined && !isString(value['default'])) ||\n\t\t(value['secret'] !== undefined && !isBoolean(value['secret']))\n\t) {\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 5 (secrets): has a malformed parameter declaration',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\t}\n\tif (value['secret'] === true && value['default'] !== undefined)\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 5 (secrets): declares a secret with a default',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n}\n\n/**\n * Validates one step independently of ids and parameter declarations.\n * @param value - Candidate step\n * @throws BrowserError - Thrown when the action, target, tab, arguments, or JSON shape fails\n */\nexport function validateBrowserJourneyStep(\n\tvalue: unknown,\n): asserts value is BrowserJourneyStepInput {\n\tif (\n\t\t!isJSONValue(value) ||\n\t\t!isRecord(value) ||\n\t\t!isString(value['action']) ||\n\t\t!isRecord(value['arguments'])\n\t)\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 6 (JSON round trip): has a malformed step',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tconst action = value['action']\n\tif (action.length === 0 || BROWSER_JOURNEY_NON_STEP_TOOLS.includes(action))\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 7 (actions): uses an observation or journey tool as a step',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tconst native = BROWSER_JOURNEY_ACTIONS.some((name) => name === action)\n\tconst targeted = action === 'click' || action === 'type'\n\tif (\n\t\t(targeted ? !isBrowserJourneyTarget(value['target']) : value['target'] !== undefined) ||\n\t\t(action === 'switch' ? !isBrowserJourneyTab(value['tab']) : value['tab'] !== undefined)\n\t)\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 3 (targets and tabs): has an incompatible target or tab',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tconst args = value['arguments']\n\tif (native && ('ref' in args || 'tab' in args))\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 3 (targets and tabs): carries ref or tab in native arguments',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tif (\n\t\taction === 'unresolved'\n\t\t\t? !isString(value['gap']) || value['gap'].length === 0\n\t\t\t: value['gap'] !== undefined\n\t)\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 7 (actions): has an incompatible gap',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tif (!native) return\n\tconst name = BROWSER_JOURNEY_ACTIONS.find((candidate) => candidate === action)\n\tif (name === undefined) return\n\tconst schema = BROWSER_TOOL_COPY[name].parameters\n\tconst properties = schema?.['properties']\n\tconst required = schema?.['required']\n\tconst fields = isRecord(properties)\n\t\t? Object.entries(properties).filter(([key]) => !BROWSER_JOURNEY_STEP_KEYS.includes(key))\n\t\t: []\n\tif (\n\t\tObject.keys(args).some((key) => !fields.some(([field]) => field === key)) ||\n\t\tfields.some(([key, property]) => {\n\t\t\tconst argument = args[key]\n\t\t\tif (argument === undefined) return isArray(required) && required.includes(key)\n\t\t\tif (!isRecord(property)) return true\n\t\t\tswitch (property['type']) {\n\t\t\t\tcase 'string':\n\t\t\t\t\treturn !isBrowserJourneyBinding(argument)\n\t\t\t\tcase 'boolean':\n\t\t\t\t\treturn !isBoolean(argument)\n\t\t\t\tcase 'integer':\n\t\t\t\t\treturn !isInteger(argument)\n\t\t\t\tcase 'number':\n\t\t\t\t\treturn !isFiniteNumber(argument)\n\t\t\t\tdefault:\n\t\t\t\t\treturn true\n\t\t\t}\n\t\t})\n\t)\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 7 (actions): has malformed native arguments',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n}\n\n/**\n * Validates the journey format and its name, nonempty steps, ids, bindings, secrets, JSON, and actions.\n * @param value - Candidate journey\n * @throws BrowserError - Thrown with BROWSER_JOURNEY_FORMAT for an unknown format, or BROWSER_JOURNEY_INVALID naming the failed invariant\n */\nexport function validateBrowserJourney(value: unknown): asserts value is BrowserJourney {\n\tif (!isJSONValue(value) || !isRecord(value))\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 6 (JSON round trip): is not a JSON record',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tif (value['format'] !== BROWSER_JOURNEY_FORMAT_VERSION)\n\t\tthrow new BrowserError('Has an unknown journey format', 'BROWSER_JOURNEY_FORMAT')\n\tif (!isString(value['name']) || !BROWSER_JOURNEY_NAME_PATTERN.test(value['name']))\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 1 (name): has an invalid journey name',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tif (!isString(value['description']) || !isArray(value['steps']) || !isRecord(value['parameters']))\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 6 (JSON round trip): has malformed journey fields',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tif (value['steps'].length === 0)\n\t\tthrow new BrowserError('Invariant 2 (ids): has no steps', 'BROWSER_JOURNEY_INVALID', {\n\t\t\tfield: 'steps',\n\t\t})\n\tif (!Number.isSafeInteger(value['next']) || !isFiniteNumber(value['next']) || value['next'] < 1)\n\t\tthrow new BrowserError(\n\t\t\t'Invariant 2 (ids): has an invalid next counter',\n\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t)\n\tconst ids = new Set<string>()\n\tconst steps: BrowserJourneyStep[] = []\n\tfor (const step of value['steps']) {\n\t\tvalidateBrowserJourneyStep(step)\n\t\tif (\n\t\t\t!('id' in step) ||\n\t\t\t!isString(step.id) ||\n\t\t\t!/^s[1-9]\\d*$/.test(step.id) ||\n\t\t\t!Number.isSafeInteger(Number(step.id.slice(1))) ||\n\t\t\tNumber(step.id.slice(1)) >= value['next'] ||\n\t\t\tids.has(step.id)\n\t\t)\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Invariant 2 (ids): repeats an id or exceeds the next counter',\n\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t)\n\t\tids.add(step.id)\n\t\tsteps.push({ ...step, id: step.id })\n\t}\n\tconst bindings = collectBrowserJourneyBindings(steps)\n\tfor (const [name, parameter] of Object.entries(value['parameters'])) {\n\t\tif (!BROWSER_JOURNEY_PARAMETER_PATTERN.test(name))\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Invariant 4 (bindings): has an invalid parameter name',\n\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t)\n\t\tvalidateBrowserJourneyParameter(parameter)\n\t\tif (!bindings.has(name))\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Invariant 4 (bindings): declares \"${name}\" but no step binds it`,\n\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t)\n\t}\n\tfor (const name of bindings.keys()) {\n\t\tconst declared = Object.hasOwn(value['parameters'], name)\n\t\tconst parameter = value['parameters'][name]\n\t\tif (declared) validateBrowserJourneyParameter(parameter)\n\t\tfor (const step of steps) {\n\t\t\tconst fields = collectBrowserJourneyBindings([step]).get(name) ?? []\n\t\t\tfor (const binding of fields) {\n\t\t\t\tconst field = binding.slice(step.action.length + 1)\n\t\t\t\tconst context = { parameter: name, step: step.id, field }\n\t\t\t\tif (!declared)\n\t\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t\t`Invariant 4 (bindings): binds undeclared parameter \"${name}\"`,\n\t\t\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t)\n\t\t\t\tif (\n\t\t\t\t\tisRecord(parameter) &&\n\t\t\t\t\tparameter['secret'] === true &&\n\t\t\t\t\t(step.action !== 'type' || field !== 'text')\n\t\t\t\t)\n\t\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t\t`Invariant 5 (secrets): binds secret \"${name}\" outside type.text`,\n\t\t\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Validates an edit structure and names the operation and field in each refusal.\n * @param value - Candidate edit\n * @throws BrowserError - Thrown when the operation or its fields are malformed\n */\nexport function validateBrowserJourneyEdit(value: unknown): asserts value is BrowserJourneyEdit {\n\tif (!isRecord(value))\n\t\tthrow new BrowserError('has no edit object with an \"operation\" field', 'BROWSER_JOURNEY_EDIT')\n\tconst operation = value['operation']\n\tconst fields =\n\t\toperation === 'add'\n\t\t\t? ['operation', 'step', 'before', 'after']\n\t\t\t: operation === 'remove'\n\t\t\t\t? ['operation', 'id']\n\t\t\t\t: operation === 'update'\n\t\t\t\t\t? ['operation', 'id', 'arguments', 'target', 'tab']\n\t\t\t\t\t: operation === 'declare'\n\t\t\t\t\t\t? ['operation', 'name', 'parameter']\n\t\t\t\t\t\t: undefined\n\tif (fields === undefined)\n\t\tthrow new BrowserError(\n\t\t\t'names no operation among add, update, remove, and declare',\n\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t)\n\tfor (const [field, content] of Object.entries(value)) {\n\t\tif (!fields.includes(field))\n\t\t\tthrow new BrowserError(\n\t\t\t\t`its \"${operation}\" carries an unknown field ${JSON.stringify(field)}`,\n\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t)\n\t\tif (!isJSONValue(content))\n\t\t\tthrow new BrowserError(\n\t\t\t\t`its \"${operation}\" has non-JSON content in ${JSON.stringify(field)}`,\n\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t)\n\t}\n\tswitch (operation) {\n\t\tcase 'add':\n\t\t\tif (value['before'] !== undefined && value['after'] !== undefined)\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t'its \"add\" carries both \"before\" and \"after\"',\n\t\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t\t)\n\t\t\tfor (const field of ['before', 'after']) {\n\t\t\t\tif (value[field] !== undefined && (!isString(value[field]) || value[field].length === 0))\n\t\t\t\t\tthrow new BrowserError(`its \"add\" has no step id in \"${field}\"`, 'BROWSER_JOURNEY_EDIT')\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tvalidateBrowserJourneyStep(value['step'])\n\t\t\t} catch (error) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`its \"add\" has an invalid \"step\": ${normalizeBrowserJourneyReason(error)}`,\n\t\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif ('id' in value['step'])\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t'its \"add\" supplies \"step.id\", which is assigned automatically',\n\t\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t\t)\n\t\t\treturn\n\t\tcase 'remove':\n\t\t\tif (!isString(value['id']) || value['id'].length === 0)\n\t\t\t\tthrow new BrowserError('its \"remove\" names no step in \"id\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\treturn\n\t\tcase 'update':\n\t\t\tif (!isString(value['id']) || value['id'].length === 0)\n\t\t\t\tthrow new BrowserError('its \"update\" names no step in \"id\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\tif (value['arguments'] !== undefined && !isRecord(value['arguments']))\n\t\t\t\tthrow new BrowserError('its \"update\" has no object in \"arguments\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\tif (value['target'] !== undefined && !isBrowserJourneyTarget(value['target']))\n\t\t\t\tthrow new BrowserError('its \"update\" has an invalid \"target\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\tif (value['tab'] !== undefined && !isBrowserJourneyTab(value['tab']))\n\t\t\t\tthrow new BrowserError('its \"update\" has an invalid \"tab\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\treturn\n\t\tcase 'declare':\n\t\t\tif (!isString(value['name']) || value['name'].length === 0)\n\t\t\t\tthrow new BrowserError('its \"declare\" has no \"name\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\tif (!BROWSER_JOURNEY_PARAMETER_PATTERN.test(value['name']))\n\t\t\t\tthrow new BrowserError('its \"declare\" has an invalid \"name\"', 'BROWSER_JOURNEY_EDIT')\n\t\t\ttry {\n\t\t\t\tvalidateBrowserJourneyParameter(value['parameter'])\n\t\t\t} catch (error) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`its \"declare\" has an invalid \"parameter\": ${normalizeBrowserJourneyReason(error)}`,\n\t\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn\n\t}\n}\n\n/**\n * Validates a persisted run and the journey it carries.\n * @param value - Candidate run\n * @throws BrowserError - Thrown when the format, run fields, or embedded journey fails validation\n */\nexport function validateBrowserRun(value: unknown): asserts value is BrowserRun {\n\tif (!isJSONValue(value) || !isRecord(value))\n\t\tthrow new BrowserError('Run is not a JSON record', 'BROWSER_JOURNEY_INVALID')\n\tif (value['format'] !== BROWSER_JOURNEY_FORMAT_VERSION)\n\t\tthrow new BrowserError('Has an unknown run format', 'BROWSER_JOURNEY_FORMAT')\n\tvalidateBrowserJourney(value['journey'])\n\tconst journey = value['journey']\n\tif (\n\t\t!isString(value['id']) ||\n\t\t!BROWSER_RUN_ID_PATTERN.test(value['id']) ||\n\t\t!isRecord(value['inputs']) ||\n\t\t!Object.values(value['inputs']).every(isString) ||\n\t\t!isArray(value['steps']) ||\n\t\tparseEnum(value['outcome'], ['complete', 'stopped', 'aborted']) === undefined ||\n\t\t!isFiniteNumber(value['elapsed']) ||\n\t\tvalue['elapsed'] < 0 ||\n\t\t(value['revision'] !== undefined &&\n\t\t\t(!isFiniteNumber(value['revision']) ||\n\t\t\t\t!Number.isSafeInteger(value['revision']) ||\n\t\t\t\tvalue['revision'] < 1)) ||\n\t\t(value['fault'] !== undefined && !isString(value['fault'])) ||\n\t\t(value['output'] !== undefined &&\n\t\t\t(!isArray(value['output']) || !value['output'].every(isString)))\n\t)\n\t\tthrow new BrowserError('Run has malformed fields', 'BROWSER_JOURNEY_INVALID')\n\tfor (const [index, step] of value['steps'].entries()) {\n\t\tconst source = journey.steps[index]\n\t\tif (\n\t\t\t!isRecord(step) ||\n\t\t\tsource === undefined ||\n\t\t\tstep['id'] !== source.id ||\n\t\t\tstep['action'] !== source.action ||\n\t\t\t!isString(step['trigger']) ||\n\t\t\t!isRecord(step['arguments']) ||\n\t\t\t!isString(step['result']) ||\n\t\t\t!isFiniteNumber(step['elapsed']) ||\n\t\t\tstep['elapsed'] < 0 ||\n\t\t\tparseEnum(step['outcome'], BROWSER_ACTION_OUTCOMES) === undefined ||\n\t\t\t(step['capture'] !== undefined && !isString(step['capture'])) ||\n\t\t\t(step['stage'] !== undefined &&\n\t\t\t\tparseEnum(step['stage'], BROWSER_ACTION_STAGES) === undefined) ||\n\t\t\t(step['reason'] !== undefined &&\n\t\t\t\tparseEnum(step['reason'], BROWSER_NAVIGATION_REASONS) === undefined)\n\t\t)\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Run has a malformed step or is not a journey prefix',\n\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t)\n\t}\n\tfor (const [name, parameter] of Object.entries(journey.parameters)) {\n\t\tif (\n\t\t\tparameter.secret === true &&\n\t\t\t(Object.hasOwn(value['inputs'], name) ||\n\t\t\t\tvalue['output'] !== undefined ||\n\t\t\t\tvalue['steps'].some((step) => isRecord(step) && step['capture'] !== undefined))\n\t\t)\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Invariant 5 (secrets): run retains secret inputs, output, or captures',\n\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t)\n\t}\n\tif (Object.keys(value['inputs']).some((name) => !Object.hasOwn(journey.parameters, name)))\n\t\tthrow new BrowserError('Run has an unknown input', 'BROWSER_JOURNEY_INVALID')\n\tif (\n\t\tvalue['outcome'] === 'complete' &&\n\t\t(value['steps'].length !== journey.steps.length ||\n\t\t\tvalue['steps'].some((step, index) => {\n\t\t\t\tif (!isRecord(step)) return true\n\t\t\t\tconst following = journey.steps[index + 1]\n\t\t\t\treturn (\n\t\t\t\t\t(step['outcome'] !== 'done' &&\n\t\t\t\t\t\t!(step['outcome'] === 'interrupted' && following?.action === 'dialog')) ||\n\t\t\t\t\t(step['stage'] !== undefined && step['stage'] !== 'loaded')\n\t\t\t\t)\n\t\t\t}))\n\t)\n\t\tthrow new BrowserError('Run completion does not match its steps', 'BROWSER_JOURNEY_INVALID')\n\tfor (const [index, source] of journey.steps.entries()) {\n\t\tconst step = value['steps'][index]\n\t\tif (\n\t\t\tisBrowserSecretBinding(source, journey.parameters) &&\n\t\t\tisRecord(step) &&\n\t\t\tisRecord(step['arguments']) &&\n\t\t\tObject.hasOwn(step['arguments'], 'text')\n\t\t)\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Invariant 5 (secrets): run retains secret type.text',\n\t\t\t\t'BROWSER_JOURNEY_INVALID',\n\t\t\t)\n\t}\n}\n\n/**\n * Builds a validated journey from recorded steps and declares their secret bindings.\n * @param steps - Recorded steps in order\n * @param options - Journey name and description\n * @returns An owned journey with its next id and secret declarations\n * @throws BrowserError - Thrown when the assembled journey fails validation\n */\nexport function buildBrowserJourney(\n\tsteps: readonly BrowserJourneyStep[],\n\toptions: Pick<BrowserJourney, 'name' | 'description'>,\n): BrowserJourney {\n\tconst parameters: Record<string, BrowserJourneyParameter> = {}\n\tfor (const step of steps) {\n\t\tconst binding = step.arguments['text']\n\t\tif (\n\t\t\tisBrowserJourneyBinding(binding) &&\n\t\t\t!isString(binding) &&\n\t\t\tisBrowserSecretBinding(step, { [binding.parameter]: { secret: true } })\n\t\t)\n\t\t\tparameters[binding.parameter] = { secret: true }\n\t}\n\tconst journey: BrowserJourney = {\n\t\tformat: BROWSER_JOURNEY_FORMAT_VERSION,\n\t\t...options,\n\t\tparameters,\n\t\tnext: steps.length + 1,\n\t\tsteps: structuredClone(steps),\n\t}\n\tvalidateBrowserJourney(journey)\n\treturn journey\n}\n","import type {\n\tBrowserActionabilityOptions,\n\tBrowserCodegenLanguage,\n\tBrowserCodegenScript,\n\tBrowserJourney,\n\tBrowserRect,\n\tBrowserScreenshotOptions,\n\tBrowserStorageOrigin,\n} from './types.js'\nimport type { JSONValue } from '@orkestrel/contract'\nimport { isArray, isRecord, isString } from '@orkestrel/contract'\nimport {\n\tBROWSER_JOURNEY_ACTIONS,\n\tBROWSER_RESULT_LIMIT_SENTINEL_PREFIX,\n\tBROWSER_SCREENSHOT_ATTRIBUTE,\n\tBROWSER_STABLE_FRAME_COUNT,\n\tBROWSER_SUBMIT_KEY,\n} from './constants.js'\nimport { validateBrowserJourney } from './helpers.js'\nimport { isBrowserSecretBinding } from './validators.js'\n\n/**\n * Compiles a mutation-driven wait with one deadline and explicit disconnect ownership.\n * @param deadline - Maximum time in milliseconds\n * @param key - Isolated-world property owning this observer\n * @param predicate - Optional expression checked immediately and after each mutation batch\n * @returns Promise expression resolving true on a match or change, false at the deadline\n */\nexport function compileQueryWaitExpression(\n\tdeadline: number,\n\tkey: string,\n\tpredicate?: string,\n): string {\n\treturn `new Promise((resolve) => {\n\tlet frame\n\tlet timer\n\tlet observer\n\tconst finish = (value) => {\n\t\tobserver?.disconnect()\n\t\tif (frame !== undefined) cancelAnimationFrame(frame)\n\t\tclearTimeout(timer)\n\t\tdelete globalThis[${JSON.stringify(key)}]\n\t\tresolve(value)\n\t}\n\tconst check = () => {\n\t\tframe = undefined\n\t\tif (${predicate ?? 'true'}) finish(true)\n\t}\n\tglobalThis[${JSON.stringify(key)}] = () => finish(false)\n\tobserver = new MutationObserver(() => {\n\t\tif (frame === undefined) frame = requestAnimationFrame(check)\n\t})\n\tobserver.observe(document, { childList: true, attributes: true, characterData: true, subtree: true })\n\ttimer = setTimeout(() => finish(false), ${JSON.stringify(deadline)})\n\t${predicate === undefined ? '' : 'check()'}\n})`\n}\n\n/**\n * Compiles a visible-text wait coalesced by animation frames.\n * @param text - Text to find in the main document body\n * @param deadline - Maximum time in milliseconds\n * @param key - Isolated-world property owning this observer\n * @returns Mutation-driven promise expression with one deadline\n */\nexport function compileTextWaitExpression(text: string, deadline: number, key: string): string {\n\treturn compileQueryWaitExpression(\n\t\tdeadline,\n\t\tkey,\n\t\t`(document.body?.innerText ?? '').includes(${JSON.stringify(text)})`,\n\t)\n}\n\n/**\n * Compiles text selection or select-option assignment against the resolved element.\n * @param values - Option values or labels; absence selects the text control's contents\n * @returns Function declaration for an isolated-world element call\n */\nexport function compileSelectFunction(values?: readonly string[]): string {\n\tif (values === undefined)\n\t\treturn `function() {\n\tif (this.isContentEditable) {\n\t\tthis.ownerDocument.getSelection().selectAllChildren(this)\n\t\treturn true\n\t}\n\tif (typeof this.select !== 'function') throw new Error('Element is not a text control')\n\tthis.select()\n\treturn true\n}`\n\treturn `function() {\n\tif (!(this instanceof HTMLSelectElement)) throw new Error('Element is not a select control')\n\tconst values = ${JSON.stringify(values)}\n\tconst selected = values.map((value) => [...this.options].find((option) => option.value === value) ?? [...this.options].find((option) => option.label === value))\n\tif (selected.some((option) => option === undefined)) throw new Error('Select option was not found')\n\tfor (const option of this.options) option.selected = selected.includes(option)\n\tthis.dispatchEvent(new Event('input', { bubbles: true }))\n\tthis.dispatchEvent(new Event('change', { bubbles: true }))\n\treturn true\n}`\n}\n\n/**\n * Compiles the descendant hit check for a resolved element.\n * @returns Function declaration accepting the resolved covering node\n */\nexport function compileHitFunction(): string {\n\treturn `function(target) {\n\t\twhile (target && target.nodeType !== 9) {\n\t\t\tif (target === this) return true\n\t\t\ttarget = target instanceof ShadowRoot ? target.host : target.parentNode\n\t\t}\n\t\treturn false\n\t}`\n}\n\n/**\n * Compiles the installation of a capture-phase `submit` observer owned by `token` on the window of\n * the world it runs in.\n *\n * @remarks\n * The observer records every `submit` event the window sees from installation until\n * {@link compileSubmitReadExpression} with the same `token` reads and removes it, under\n * {@link BROWSER_SUBMIT_KEY}, and replaces an observer an earlier installation left in place,\n * whatever its token. A capture-phase `keydown` listener beside it records whether an Enter's\n * target is an `input` a form owns, before any handler of the page can move the focus. A listener\n * of an isolated world observes the events the page's own scripts dispatch, because both worlds\n * share one DOM.\n *\n * @param token - The integer that identifies the action owning the observer\n * @returns Expression source that resolves `true`\n */\nexport function compileSubmitObserverExpression(token: number): string {\n\tconst key = JSON.stringify(BROWSER_SUBMIT_KEY)\n\treturn `(() => {\n\tconst token = ${JSON.stringify(token)}\n\tconst previous = globalThis[${key}]\n\tif (previous !== undefined) {\n\t\tremoveEventListener('submit', previous.listener, true)\n\t\tremoveEventListener('keydown', previous.keys, true)\n\t}\n\tconst state = { token, events: [], implicit: false, listener: undefined, keys: undefined }\n\tstate.listener = (event) => { state.events.push(event) }\n\tstate.keys = (event) => {\n\t\tconst target = event.target ?? null\n\t\tif (event.key === 'Enter' && target?.localName === 'input' && (target.form ?? null) !== null) state.implicit = true\n\t}\n\tglobalThis[${key}] = state\n\taddEventListener('submit', state.listener, true)\n\taddEventListener('keydown', state.keys, true)\n\treturn true\n})()`\n}\n\n/**\n * Compiles the read of the `submit` observer {@link compileSubmitObserverExpression} installs for\n * `token`, removing the observer.\n *\n * @remarks\n * The read resolves an object of four members:\n * - `destinations` — without repeats and in the order first recorded, the relationship of the\n * destination of every recorded `submit` that kept its default action: `self` for a target\n * that is empty or `_self`, `parent` for `_parent`, and `top` for `_top`. The target is the one\n * the submitter, the form, or the document's `base` element names. A prevented submission, one\n * whose method is `dialog`, and one aimed at another browsing context add nothing.\n * - `prevented` — true when a listener prevented any recorded `submit`; false otherwise\n * - `submitted` — true when the observer recorded any `submit`; false otherwise\n * - `implicit` — true when the observer recorded an Enter whose target is an `input` a form owns,\n * the control whose Enter submits that form implicitly; false otherwise. The target is recorded\n * in the capture phase, so a handler that moves the focus afterwards does not change it.\n *\n * Every listener of an event has run by the time the input that fired it settles, so\n * `defaultPrevented` is final by then. The read resolves `null` and removes nothing when no\n * observer of `token` is installed, so a delayed read of an earlier action leaves a later\n * action's observer in place.\n *\n * @param token - The integer that identifies the action owning the observer\n * @returns Expression source that resolves `{ destinations, prevented, submitted, implicit }`, or\n * `null`\n */\nexport function compileSubmitReadExpression(token: number): string {\n\tconst key = JSON.stringify(BROWSER_SUBMIT_KEY)\n\treturn `(() => {\n\tconst token = ${JSON.stringify(token)}\n\tconst state = globalThis[${key}]\n\tif (state === undefined || state.token !== token) return null\n\tdelete globalThis[${key}]\n\tremoveEventListener('submit', state.listener, true)\n\tremoveEventListener('keydown', state.keys, true)\n\tconst destinations = { '': 'self', _self: 'self', _parent: 'parent', _top: 'top' }\n\tconst found = []\n\tfor (const event of state.events) {\n\t\tif (event.defaultPrevented) continue\n\t\tconst submitter = event.submitter ?? null\n\t\tconst form = event.target\n\t\tconst method = (submitter?.getAttribute('formmethod') ?? form.getAttribute('method') ?? '').toLowerCase()\n\t\tconst target = (submitter?.getAttribute('formtarget') ?? form.getAttribute('target') ?? document.querySelector('base[target]')?.getAttribute('target') ?? '').toLowerCase()\n\t\tconst destination = Object.hasOwn(destinations, target) ? destinations[target] : undefined\n\t\tif (method !== 'dialog' && destination !== undefined && !found.includes(destination)) found.push(destination)\n\t}\n\treturn {\n\t\tdestinations: found,\n\t\tprevented: state.events.some((event) => event.defaultPrevented),\n\t\tsubmitted: state.events.length > 0,\n\t\timplicit: state.implicit,\n\t}\n})()`\n}\n\n/**\n * Compiles the page-side promise facade for one Runtime binding.\n *\n * @param name - Binding identifier\n * @returns Self-installing script source\n */\nexport function compileBrowserBindingSource(name: string): string {\n\tconst binding = JSON.stringify(name)\n\tconst state = JSON.stringify(`__orkestrelBinding_${name}`)\n\treturn `(() => {\n\tconst name = ${binding}\n\tconst key = ${state}\n\tif (globalThis[key]) return\n\tconst send = globalThis[name]\n\tif (typeof send !== 'function') throw new Error('Browser binding transport is unavailable')\n\tconst pending = new Map()\n\tlet sequence = 0\n\tglobalThis[key] = {\n\t\tresolve(id, success, value) {\n\t\t\tconst entry = pending.get(id)\n\t\t\tif (!entry) return\n\t\t\tpending.delete(id)\n\t\t\tif (success) entry.resolve(value)\n\t\t\telse entry.reject(new Error(String(value)))\n\t\t},\n\t}\n\tglobalThis[name] = (...args) => new Promise((resolve, reject) => {\n\t\tsequence += 1\n\t\tconst id = String(sequence)\n\t\tpending.set(id, { resolve, reject })\n\t\tsend(JSON.stringify({ id, name, args }))\n\t})\n})()`\n}\n\n/**\n * Compiles delivery of a host binding result to one execution context.\n *\n * @param name - Binding identifier\n * @param id - Call identifier\n * @param success - Resolve rather than reject\n * @param value - Serializable result or error\n * @returns Runtime expression\n */\nexport function compileBrowserBindingResult(\n\tname: string,\n\tid: string,\n\tsuccess: boolean,\n\tvalue: unknown,\n): string {\n\treturn `globalThis[${JSON.stringify(`__orkestrelBinding_${name}`)}]?.resolve(${JSON.stringify(id)}, ${JSON.stringify(success)}, ${JSON.stringify(value)})`\n}\n\n/**\n * Compiles current-document cleanup for one page-side host binding facade.\n *\n * @param name - Binding identifier\n * @returns Runtime cleanup expression\n */\nexport function compileBrowserBindingCleanup(name: string): string {\n\treturn `(() => {\n\tdelete globalThis[${JSON.stringify(name)}]\n\tdelete globalThis[${JSON.stringify(`__orkestrelBinding_${name}`)}]\n\treturn true\n})()`\n}\n\n/**\n * Compiles temporary animation, caret, and mask setup for a screenshot.\n *\n * @param options - Screenshot controls\n * @param masks - Viewport rectangles to cover, resolved from the masked elements\n * @returns Setup expression or undefined when no preparation is required\n */\nexport function compileScreenshotPreparationExpression(\n\toptions?: BrowserScreenshotOptions,\n\tmasks: readonly BrowserRect[] = [],\n): string | undefined {\n\tif (options?.animations !== false && options?.caret !== false && masks.length === 0) {\n\t\treturn undefined\n\t}\n\treturn `(() => {\n\tconst attribute = ${JSON.stringify(BROWSER_SCREENSHOT_ATTRIBUTE)}\n\tconst sequence = (globalThis.__orkestrelScreenshotSequence ?? 0) + 1\n\tglobalThis.__orkestrelScreenshotSequence = sequence\n\tconst token = String(sequence)\n\tif (${JSON.stringify(options?.animations === false || options?.caret === false)}) {\n\t\tconst style = document.createElement('style')\n\t\tstyle.setAttribute(attribute, token)\n\t\tstyle.textContent = ${JSON.stringify(\n\t\t\t`${options?.animations === false ? '*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}' : ''}${options?.caret === false ? '*{caret-color:transparent!important}' : ''}`,\n\t\t)}\n\t\tdocument.documentElement.appendChild(style)\n\t}\n\tconst rects = ${JSON.stringify(masks)}\n\tfor (const [left, top, width, height] of rects) {\n\t\tconst mask = document.createElement('div')\n\t\tmask.setAttribute(attribute, token)\n\t\tmask.style.cssText = 'position:fixed;pointer-events:none;z-index:2147483647;' +\n\t\t\t'left:' + left + 'px;top:' + top + 'px;width:' + width + 'px;height:' + height + 'px;' +\n\t\t\t'background:' + ${JSON.stringify(options?.color ?? '#ff00ff')}\n\t\tdocument.documentElement.appendChild(mask)\n\t}\n\treturn token\n})()`\n}\n\n/**\n * Compiles cleanup for temporary screenshot styles and masks.\n *\n * @param token - Preparation token\n * @returns Cleanup expression\n */\nexport function compileScreenshotCleanupExpression(token: string): string {\n\treturn `(() => {\n\tconst attribute = ${JSON.stringify(BROWSER_SCREENSHOT_ATTRIBUTE)}\n\tfor (const element of document.querySelectorAll('[' + attribute + ']')) {\n\t\tif (element.getAttribute(attribute) === ${JSON.stringify(token)}) element.remove()\n\t}\n\treturn true\n})()`\n}\n\n/**\n * Compiles an expression that serializes local and session storage.\n *\n * @returns In-page storage expression\n */\nexport function compileStorageReadExpression(): string {\n\treturn `({\n\tlocal: Array.from({ length: localStorage.length }, (_, index) => {\n\t\tconst name = localStorage.key(index)\n\t\treturn { name, value: name === null ? '' : localStorage.getItem(name) ?? '' }\n\t}),\n\tsession: Array.from({ length: sessionStorage.length }, (_, index) => {\n\t\tconst name = sessionStorage.key(index)\n\t\treturn { name, value: name === null ? '' : sessionStorage.getItem(name) ?? '' }\n\t}),\n})`\n}\n\n/**\n * Compiles an expression that restores one origin's web storage.\n *\n * @param origin - Storage values to restore\n * @returns In-page restore expression\n */\nexport function compileStorageRestoreExpression(origin: BrowserStorageOrigin): string {\n\treturn `(() => {\n\tconst state = ${JSON.stringify({ local: origin.local, session: origin.session })}\n\tlocalStorage.clear()\n\tsessionStorage.clear()\n\tfor (const entry of state.local) localStorage.setItem(entry.name, entry.value)\n\tfor (const entry of state.session) sessionStorage.setItem(entry.name, entry.value)\n\treturn true\n})()`\n}\n\n/**\n * Compiles an expression that clears local and session storage.\n *\n * @returns In-page clear expression\n */\nexport function compileStorageClearExpression(): string {\n\treturn `(() => {\n\tlocalStorage.clear()\n\tsessionStorage.clear()\n\treturn true\n})()`\n}\n\n/**\n * Compiles a `Runtime.evaluate` expression so the in-page code stringifies its own result and\n * throws a recognizable sentinel error before an oversized result would overflow the CDP\n * transport frame.\n *\n * @remarks\n * A result whose `JSON.stringify` length exceeds `limit` throws\n * `Error('BROWSER_RESULT_LIMIT: <length>')` inside the page instead of being\n * returned — the caller maps that sentinel to a coded\n * {@link BrowserResultLimitError}. A non-serializable result (`undefined`,\n * a function, a symbol) makes `JSON.stringify` return `undefined`, so the\n * length check is skipped and today's undefined-passthrough behavior is\n * unchanged.\n *\n * The expression is placed on its own line inside the wrapper (rather than\n * inline with the guard code) so a trailing `//` line comment in the\n * expression cannot swallow the closing guard syntax that follows it.\n *\n * @param expression - The candidate JavaScript expression to evaluate\n * @param limit - Maximum serialized-character length (see {@link BROWSER_RESULT_LIMIT})\n * @returns The wrapped, guarded expression\n */\nexport function compileGuardedEvaluateExpression(expression: string, limit: number): string {\n\treturn `(() => { const r = (\n${expression}\n); const s = JSON.stringify(r); if (typeof s === 'string' && s.length > ${limit}) throw new Error(${JSON.stringify(BROWSER_RESULT_LIMIT_SENTINEL_PREFIX)} + s.length); return r })()`\n}\n\n/**\n * Compiles the in-page function that reads the document's URL, title, and serialized HTML.\n *\n * @remarks\n * The declaration takes no arguments and returns `{ url, title, html }` from `location.href`,\n * `document.title`, and `document.documentElement.outerHTML`, with `html` empty for a document\n * that has no root element. Call it inside {@link compileGuardedEvaluateExpression} to bound the\n * result under {@link BROWSER_RESULT_LIMIT}.\n *\n * @returns A function declaration source\n */\nexport function compileReadFunction(): string {\n\treturn `function() {\n\tconst root = document.documentElement\n\treturn { url: location.href, title: document.title, html: root ? root.outerHTML : '' }\n}`\n}\n\n/**\n * Compiles a JSON value into the JavaScript literal a generated journey module carries.\n *\n * @remarks\n * A string takes single quotes, an object key that is an identifier stays bare, and an own\n * `__proto__` key compiles to a computed key so the literal keeps it as an own property. An object\n * whose only member is a `parameter` string that `bindings` names compiles to the expression\n * `bindings` maps that name to; without `bindings`, every value compiles literally.\n *\n * @param value - The JSON value to compile\n * @param bindings - The expression each parameter's binding compiles to, by parameter name\n * @returns Expression source that evaluates to the value\n * @example\n * ```ts\n * compileBrowserJourneyValue({ text: { parameter: 'email' }, submit: true }, new Map([['email', 'inputs.email']]))\n * // \"{ text: inputs.email, submit: true }\"\n * ```\n */\nexport function compileBrowserJourneyValue(\n\tvalue: JSONValue,\n\tbindings?: ReadonlyMap<string, string>,\n): string {\n\tif (isString(value))\n\t\treturn `'${JSON.stringify(value)\n\t\t\t.slice(1, -1)\n\t\t\t.replace(/\\\\\"|'/g, (escape) => (escape === \"'\" ? \"\\\\'\" : '\"'))}'`\n\tif (isArray(value))\n\t\treturn `[${value.map((member) => compileBrowserJourneyValue(member, bindings)).join(', ')}]`\n\tif (!isRecord(value)) return JSON.stringify(value)\n\tconst entries = Object.entries(value)\n\tconst parameter = value['parameter']\n\tconst expression =\n\t\tentries.length === 1 && isString(parameter) ? bindings?.get(parameter) : undefined\n\tif (expression !== undefined) return expression\n\tif (entries.length === 0) return '{}'\n\tconst members = entries.map(([key, member]) => {\n\t\tconst name =\n\t\t\tkey === '__proto__'\n\t\t\t\t? `['__proto__']`\n\t\t\t\t: /^[A-Za-z_$][\\w$]*$/.test(key)\n\t\t\t\t\t? key\n\t\t\t\t\t: compileBrowserJourneyValue(key)\n\t\treturn `${name}: ${compileBrowserJourneyValue(member, bindings)}`\n\t})\n\treturn `{ ${members.join(', ')} }`\n}\n\n/**\n * Compiles a journey into a standalone module that performs each step through the `follow`\n * method of a toolset the module constructs on the page. The module checks its inputs before any\n * step.\n *\n * @remarks\n * The module imports only `@orkestrel/browser` and exports `execute(page, inputs)`, which starts\n * the toolset, performs the steps in order, and destroys the toolset in `finally`.\n * - A parameter with a default compiles to an optional input that falls back to the default; a\n * secret and a parameter without a default compile to a required input, and `inputs` then takes\n * no default. `execute` takes no `inputs` when the journey declares no parameter.\n * - A step passes its action, its arguments, and its target's role and name or its tab's URL and\n * title as literals, with each native binding replaced by its input; a page tool's arguments\n * stay literal. A `type` step whose text binds a secret passes `{ secret: true }`.\n * - `execute` checks its inputs before the toolset starts, as replay refuses them at preparation:\n * an input that names no parameter throws `Error('NAME: no parameter has that name')`, then a\n * required parameter whose input is not a string throws `Error('NAME: the input is missing')`,\n * then a defaulted parameter whose input is neither `undefined` nor a string throws\n * `Error('NAME: the input is not a string')`. A journey without parameters compiles no check. A\n * journey with a required parameter reads `inputs ?? {}` and `inputs?.NAME` in its required\n * checks, so `execute(page)` without inputs reports the first required parameter as missing\n * before a defaulted check reads `inputs.NAME`; a journey whose parameters all have defaults\n * reads `inputs`, which defaults to `{}`.\n * - A journey with a gap compiles to an unconditional throw naming the first gap after the input\n * checks and before the toolset starts, as replay refuses a gap at preparation; each gap step\n * compiles to a comment at its position, with its line terminators escaped, and is listed in\n * `gaps`.\n *\n * The JavaScript module is the TypeScript module without the type import and the annotations.\n * `options.language` selects `'javascript'` or `'typescript'`. Default: `'javascript'`.\n *\n * @param journey - The journey to compile\n * @param options - The target language\n * @returns The module source and the gap step ids in step order\n * @throws BrowserError - Thrown with `BROWSER_JOURNEY_FORMAT` or `BROWSER_JOURNEY_INVALID` when the\n * journey fails validation, before any source is compiled\n * @example\n * ```ts\n * const script = compileBrowserJourney(journey, { language: 'typescript' })\n * // script.source begins with the two `@orkestrel/browser` imports; script.gaps lists the gap ids\n * ```\n */\nexport function compileBrowserJourney(\n\tjourney: BrowserJourney,\n\toptions?: { readonly language?: BrowserCodegenLanguage },\n): BrowserCodegenScript {\n\tvalidateBrowserJourney(journey)\n\tconst typed = options?.language === 'typescript'\n\tconst parameters = Object.entries(journey.parameters)\n\tconst defaulted = parameters.flatMap(([name, parameter]) =>\n\t\tparameter.default === undefined\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tfallback: parameter.default,\n\t\t\t\t\t\t// An inherited member such as `toString` is not an input, so only an own property counts.\n\t\t\t\t\t\tread:\n\t\t\t\t\t\t\tname in Object.prototype\n\t\t\t\t\t\t\t\t? `(Object.hasOwn(inputs, '${name}') ? inputs.${name} : undefined)`\n\t\t\t\t\t\t\t\t: `inputs.${name}`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t)\n\tconst bindings = new Map([\n\t\t...parameters.map(([name]): [string, string] => [name, `inputs.${name}`]),\n\t\t...defaulted.map(({ name, fallback, read }): [string, string] => [\n\t\t\tname,\n\t\t\t`${read} ?? ${compileBrowserJourneyValue(fallback)}`,\n\t\t]),\n\t])\n\tconst shape = parameters\n\t\t.map(\n\t\t\t([name, parameter]) =>\n\t\t\t\t`readonly ${name}${parameter.default === undefined ? '' : '?'}: string`,\n\t\t)\n\t\t.join('; ')\n\tconst required = parameters.filter(([, parameter]) => parameter.default === undefined)\n\tconst inputs =\n\t\tparameters.length === 0\n\t\t\t? ''\n\t\t\t: `, inputs${typed ? `: { ${shape} }` : ''}${required.length === 0 ? ' = {}' : ''}`\n\t// A module with a required parameter declares no `inputs` default, so its checks tolerate an absent object.\n\tconst supplied = required.length === 0 ? 'inputs' : 'inputs ?? {}'\n\tconst preflight =\n\t\tparameters.length === 0\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t`\\tfor (const name of Object.keys(${supplied})) if (!${compileBrowserJourneyValue(parameters.map(([name]) => name))}.includes(name)) throw new Error(name + ': no parameter has that name')`,\n\t\t\t\t\t...required.map(\n\t\t\t\t\t\t([name]) =>\n\t\t\t\t\t\t\t`\\tif (typeof inputs?.${name} !== 'string') throw new Error(${compileBrowserJourneyValue(`${name}: the input is missing`)})`,\n\t\t\t\t\t),\n\t\t\t\t\t// The required checks run first, so `inputs` is an object by the time a defaulted check reads it.\n\t\t\t\t\t...defaulted.map(\n\t\t\t\t\t\t({ name, read }) =>\n\t\t\t\t\t\t\t`\\tif (${read} !== undefined && typeof ${read} !== 'string') throw new Error(${compileBrowserJourneyValue(`${name}: the input is not a string`)})`,\n\t\t\t\t\t),\n\t\t\t\t]\n\tconst gap = journey.steps.find((step) => step.action === 'unresolved')\n\tconst statements = journey.steps.map((step) => {\n\t\tif (step.action === 'unresolved')\n\t\t\treturn `\\t\\t// ${step.id}: ${step.gap ?? ''}; handle it here`.replace(\n\t\t\t\t/[\\n\\r\\u2028\\u2029]/gu,\n\t\t\t\t(terminator) => `\\\\u${terminator.charCodeAt(0).toString(16).padStart(4, '0')}`,\n\t\t\t)\n\t\tconst secret = isBrowserSecretBinding(step, journey.parameters)\n\t\tconst call: JSONValue = {\n\t\t\taction: step.action,\n\t\t\targuments: step.arguments,\n\t\t\t...(step.target === undefined\n\t\t\t\t? {}\n\t\t\t\t: { target: { role: step.target.role, name: step.target.name } }),\n\t\t\t...(step.tab === undefined ? {} : { tab: { url: step.tab.url, title: step.tab.title } }),\n\t\t}\n\t\tconst native = BROWSER_JOURNEY_ACTIONS.some((action) => action === step.action)\n\t\treturn `\\t\\tawait toolset.follow(${compileBrowserJourneyValue(step.id)}, ${compileBrowserJourneyValue(call, native ? bindings : undefined)}${secret ? ', { secret: true }' : ''})`\n\t})\n\tconst source = [\n\t\t...(typed ? [`import type { BrowserPageInterface } from '@orkestrel/browser'`] : []),\n\t\t`import { createBrowserToolset } from '@orkestrel/browser'`,\n\t\t'',\n\t\t`export async function execute(page${typed ? ': BrowserPageInterface' : ''}${inputs})${typed ? ': Promise<void>' : ''} {`,\n\t\t...preflight,\n\t\t...(gap === undefined\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t`\\tthrow new Error(${compileBrowserJourneyValue(`${gap.id}: ${gap.gap ?? ''}; handle it here`)})`,\n\t\t\t\t]),\n\t\t'\\tconst toolset = createBrowserToolset(page)',\n\t\t'\\tawait toolset.start()',\n\t\t'\\ttry {',\n\t\t...statements,\n\t\t'\\t} finally {',\n\t\t'\\t\\tawait toolset.destroy()',\n\t\t'\\t}',\n\t\t'}',\n\t\t'',\n\t].join('\\n')\n\treturn {\n\t\tsource,\n\t\tgaps: journey.steps.filter((step) => step.action === 'unresolved').map((step) => step.id),\n\t}\n}\n\n/**\n * Compiles the element-side actionability pass used before trusted input.\n *\n * @param options - Checks required for the action\n * @returns Async `Runtime.callFunctionOn` function declaration\n */\nexport function compileActionabilityFunction(options: BrowserActionabilityOptions): string {\n\t// Visible means a rendered, non-collapsed box; `style` and `rect` are in scope at the interpolation site.\n\tconst VISIBILITY_SOURCE =\n\t\t\"style.display !== 'none' && style.visibility !== 'hidden' && style.visibility !== 'collapse' && rect.width > 0 && rect.height > 0\"\n\treturn `async function() {\n\tif (!(this instanceof Element) || !this.isConnected) throw new Error('Element is detached')\n\tthis.scrollIntoView({ block: 'center', inline: 'center', behavior: 'instant' })\n\tconst visible = () => {\n\t\tconst style = getComputedStyle(this)\n\t\tconst rect = this.getBoundingClientRect()\n\t\treturn ${VISIBILITY_SOURCE}\n\t}\n\tif (${JSON.stringify(options.visible === true)} && !visible()) throw new Error('Element is not visible')\n\tif (${JSON.stringify(options.enabled === true)} && this.matches(':disabled')) throw new Error('Element is disabled')\n\tif (${JSON.stringify(options.editable === true)} && (this.matches('[readonly]') || (!this.isContentEditable && !('value' in this)))) throw new Error('Element is not editable')\n\tlet previous\n\tfor (let index = 0; index < ${BROWSER_STABLE_FRAME_COUNT}; index += 1) {\n\t\tawait new Promise((resolve) => requestAnimationFrame(resolve))\n\t\tconst rect = this.getBoundingClientRect()\n\t\tconst current = [rect.x, rect.y, rect.width, rect.height]\n\t\tif (${JSON.stringify(options.stable === true)} && previous && current.some((value, part) => value !== previous[part])) {\n\t\t\tindex = 0\n\t\t}\n\t\tprevious = current\n\t}\n\tif (${JSON.stringify(options.events === true)}) {\n\t\tconst rect = this.getBoundingClientRect()\n\t\tconst position = ${JSON.stringify(options.position)}\n\t\tconst x = rect.x + (position?.x ?? rect.width / 2)\n\t\tconst y = rect.y + (position?.y ?? rect.height / 2)\n\t\tconst target = this.ownerDocument.elementFromPoint(x, y)\n\t\tif (target !== this && !this.contains(target)) throw new Error('Element does not receive pointer events')\n\t}\n\treturn true\n}`\n}\n","import type { BrowserTransitionFunction, BrowserTransitionInterface } from './types.js'\n\n/**\n * Runs one asynchronous transition at a time, shared by every caller that joins it.\n *\n * @remarks\n * An entity with a lifecycle runs the same guard around every transition: take\n * the promise already in flight when one exists, otherwise start the work, hold\n * its promise, and release the field afterwards only when it is still this\n * run's. Holding that guard in one place keeps the identity check — the part a\n * hand-written copy drops — identical at every site. The entry guards stay with\n * each entity, because what makes a transition unnecessary is the entity's own\n * state.\n *\n * @example\n * ```ts\n * import { BrowserTransition } from '@orkestrel/browser'\n *\n * const starting = new BrowserTransition()\n * await starting.execute(() => transport.start())\n * const joined = starting.pending // the in-flight promise, or undefined\n * ```\n */\nexport class BrowserTransition<T = void> implements BrowserTransitionInterface<T> {\n\t#pending: Promise<T> | undefined\n\n\tget pending(): Promise<T> | undefined {\n\t\treturn this.#pending\n\t}\n\n\tasync execute(work: BrowserTransitionFunction<T>): Promise<T> {\n\t\tconst active = this.#pending\n\t\tif (active !== undefined) return await active\n\n\t\tconst started = work()\n\t\tthis.#pending = started\n\t\ttry {\n\t\t\treturn await started\n\t\t} finally {\n\t\t\tif (this.#pending === started) this.#pending = undefined\n\t\t}\n\t}\n}\n","import type {\n\tCDPClientEventMap,\n\tCDPClientInterface,\n\tCDPClientOptions,\n\tCDPHandler,\n\tCDPSendOptions,\n\tCDPTransportInterface,\n} from './types.js'\nimport type { EmitterErrorHandler, EmitterInterface } from '@orkestrel/emitter'\nimport { BrowserTransition } from './BrowserTransition.js'\nimport { BROWSER_DEFAULT_TIMEOUT_MS } from './constants.js'\nimport { CDPConnectionError, CDPError, CDPTimeoutError } from './errors.js'\nimport { Emitter } from '@orkestrel/emitter'\nimport { isInteger, isRecord, isString, parseJSON } from '@orkestrel/contract'\n\n// === CDPClient\n\n/**\n * Provides a lightweight Chrome DevTools Protocol client over a {@link CDPTransportInterface}.\n *\n * @remarks\n * Sends JSON-RPC messages over the injected transport and dispatches\n * responses and events. The transport owns the connection itself\n * (WebSocket, pipe, or any other duplex channel); this class owns only\n * the JSON-RPC framing and id/session correlation.\n *\n * Supports session-scoped event subscriptions: a subscription registered\n * without a session id receives the event whatever session carries it, and a\n * session-scoped subscription receives only its own session's events.\n *\n * @example\n * ```ts\n * import { CDPClient } from '@orkestrel/browser'\n *\n * const client = new CDPClient({ transport })\n * await client.connect()\n * const targets = await client.send('Target.getTargets')\n * await client.close()\n * ```\n */\nexport class CDPClient implements CDPClientInterface {\n\treadonly #emitter: Emitter<CDPClientEventMap>\n\treadonly #transport: CDPTransportInterface\n\t#messageId = 0\n\treadonly #pending: Map<\n\t\tnumber,\n\t\t{\n\t\t\tmethod: string\n\t\t\tresolve: (value: unknown) => void\n\t\t\treject: (reason: unknown) => void\n\t\t\ttimer: ReturnType<typeof setTimeout>\n\t\t\tsignal: AbortSignal | undefined\n\t\t\tlistener: (() => void) | undefined\n\t\t}\n\t> = new Map()\n\treadonly #subscriptions: Map<string | undefined, Map<string, Set<CDPHandler>>> = new Map()\n\t#connected = false\n\t#active = false\n\t#wired = false\n\treadonly #timeout: number\n\treadonly #error: EmitterErrorHandler | undefined\n\treadonly #connecting: BrowserTransition = new BrowserTransition()\n\treadonly #closing: BrowserTransition = new BrowserTransition()\n\t#closeRequested = false\n\t// Set while this client is the one closing the transport, so the transport\n\t// `close` a teardown produces reports `close` rather than `drop`.\n\t#expected = false\n\n\tconstructor(options: CDPClientOptions) {\n\t\tthis.#transport = options.transport\n\t\tthis.#timeout = options.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tthis.#error = options.error\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options.on !== undefined ? { on: options.on } : {}),\n\t\t\t...(options.error !== undefined ? { error: options.error } : {}),\n\t\t})\n\t}\n\n\tget emitter(): EmitterInterface<CDPClientEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget connected(): boolean {\n\t\treturn this.#connected\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tconst closing = this.#closing.pending\n\t\tif (closing !== undefined) await closing\n\t\tif (this.#connected) return\n\t\tconst active = this.#connecting.pending\n\t\tif (active !== undefined) return await active\n\n\t\tthis.#closeRequested = false\n\t\tthis.#expected = false\n\t\tawait this.#connecting.execute(() => this.#connect())\n\t}\n\n\t/**\n\t * Closes the transport and re-establishes a fresh connection.\n\t *\n\t * @remarks\n\t * Client-level subscriptions (`subscribe`/`unsubscribe` registrations)\n\t * survive `close()` and remain active after the reconnect — only pending\n\t * in-flight requests are rejected. This lets a caller reconnect a dropped\n\t * transport without re-registering every handler.\n\t */\n\tasync reconnect(): Promise<void> {\n\t\tawait this.close()\n\t\tawait this.connect()\n\t}\n\n\tasync send(\n\t\tmethod: string,\n\t\tparams?: Readonly<Record<string, unknown>>,\n\t\toptions?: CDPSendOptions,\n\t): Promise<unknown> {\n\t\tif (!this.#connected) {\n\t\t\tthrow new CDPConnectionError('CDP client is not connected', { method })\n\t\t}\n\t\tif (options?.signal?.aborted === true) throw options.signal.reason\n\n\t\tconst id = this.#nextId()\n\t\tconst message: Record<string, unknown> = { id, method }\n\n\t\tif (params !== undefined) {\n\t\t\tmessage['params'] = params\n\t\t}\n\t\tif (options?.session !== undefined) {\n\t\t\tmessage['sessionId'] = options.session\n\t\t}\n\n\t\tconst serialized = JSON.stringify(message)\n\t\tconst effectiveTimeout = options?.timeout ?? this.#timeout\n\t\tconst signal = options?.signal\n\n\t\treturn new Promise<unknown>((resolve, reject) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tthis.#settle(id)?.reject(\n\t\t\t\t\tnew CDPTimeoutError(`CDP request timed out: ${method}`, {\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\ttimeout: effectiveTimeout,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}, effectiveTimeout)\n\t\t\tconst listener = signal === undefined ? undefined : this.#abort(id, signal)\n\t\t\tthis.#pending.set(id, { method, resolve, reject, timer, signal, listener })\n\t\t\tif (listener !== undefined) signal?.addEventListener('abort', listener, { once: true })\n\n\t\t\tthis.#transport.send(serialized).catch((thrown: unknown) => {\n\t\t\t\tthis.#settle(id)?.reject(thrown)\n\t\t\t})\n\t\t})\n\t}\n\n\tsubscribe(method: string, handler: CDPHandler, session?: string): void {\n\t\tlet methods = this.#subscriptions.get(session)\n\t\tif (methods === undefined) {\n\t\t\tmethods = new Map()\n\t\t\tthis.#subscriptions.set(session, methods)\n\t\t}\n\t\tlet handlers = methods.get(method)\n\t\tif (handlers === undefined) {\n\t\t\thandlers = new Set()\n\t\t\tmethods.set(method, handlers)\n\t\t}\n\t\thandlers.add(handler)\n\t}\n\n\tunsubscribe(method: string, handler: CDPHandler, session?: string): void {\n\t\tconst methods = this.#subscriptions.get(session)\n\t\tif (methods === undefined) return\n\t\tconst handlers = methods.get(method)\n\t\tif (handlers !== undefined) {\n\t\t\thandlers.delete(handler)\n\t\t\tif (handlers.size === 0) methods.delete(method)\n\t\t}\n\t\tif (methods.size === 0) this.#subscriptions.delete(session)\n\t}\n\n\t/**\n\t * Closes the transport and rejects all pending requests.\n\t *\n\t * @remarks\n\t * Subscriptions registered through `subscribe()` are client-level\n\t * registrations, not connection-level state — they survive `close()`\n\t * (and a subsequent `reconnect()`/`connect()`) and keep firing once the\n\t * transport is active again. Only pending requests are rejected here.\n\t * If `close()` is called while `connect()` is still awaiting\n\t * `transport.start()`, the in-flight connect is rejected and the\n\t * transport is closed deterministically once `start()` resolves.\n\t */\n\tasync close(): Promise<void> {\n\t\tawait this.#closing.execute(() => this.#close())\n\t}\n\n\t// === Private helpers\n\n\tasync #connect(): Promise<void> {\n\t\tif (!this.#wired) {\n\t\t\tthis.#transport.emitter.on('message', (data) => this.#onMessage(data))\n\t\t\tthis.#transport.emitter.on('close', () => this.#onClose())\n\t\t\tthis.#transport.emitter.on('error', (error) => this.#onError(error))\n\t\t\tthis.#wired = true\n\t\t}\n\n\t\tawait this.#transport.start()\n\t\tthis.#active = true\n\n\t\tif (this.#closeRequested) {\n\t\t\tthis.#closeRequested = false\n\t\t\tthis.#expected = true\n\t\t\ttry {\n\t\t\t\tawait this.#transport.close()\n\t\t\t} finally {\n\t\t\t\tthis.#active = false\n\t\t\t}\n\t\t\tthis.#emitter.emit('close')\n\t\t\tthrow new CDPConnectionError('CDP client was closed while connecting', {\n\t\t\t\tmethod: 'connect',\n\t\t\t})\n\t\t}\n\n\t\tthis.#connected = true\n\t\tthis.#emitter.emit('connect')\n\t}\n\n\tasync #close(): Promise<void> {\n\t\tconst connecting = this.#connecting.pending\n\t\tif (connecting !== undefined) {\n\t\t\tthis.#closeRequested = true\n\t\t\tawait connecting.catch(() => undefined)\n\t\t\t// The in-flight attempt may have already flipped #connected to\n\t\t\t// true before observing #closeRequested (race between the\n\t\t\t// attempt's final steps and #closeRequested being set here).\n\t\t\t// Fall through to the normal connected-close path instead of\n\t\t\t// returning early, or the close would be silently lost.\n\t\t}\n\n\t\tif (!this.#connected && !this.#active) return\n\n\t\tthis.#connected = false\n\n\t\t// Reject all pending requests\n\t\tfor (const [id, entry] of this.#pending) {\n\t\t\tthis.#settle(id)?.reject(\n\t\t\t\tnew CDPConnectionError('CDP connection closed', { method: entry.method }),\n\t\t\t)\n\t\t}\n\n\t\tthis.#expected = true\n\t\ttry {\n\t\t\tawait this.#transport.close()\n\t\t} finally {\n\t\t\tthis.#active = false\n\t\t}\n\t\tthis.#emitter.emit('close')\n\t}\n\n\t// A settled or already-removed entry makes the returned listener a no-op.\n\t#abort(id: number, signal: AbortSignal): () => void {\n\t\treturn () => {\n\t\t\tthis.#settle(id)?.reject(signal.reason)\n\t\t}\n\t}\n\n\t// Takes one request out of flight: the entry leaves the map, its timer stops, and the abort\n\t// listener it holds on the caller's signal is released, so every settlement path leaves the\n\t// signal as it found it. The caller resolves or rejects the returned entry.\n\t#settle(\n\t\tid: number,\n\t):\n\t\t| { method: string; resolve: (value: unknown) => void; reject: (reason: unknown) => void }\n\t\t| undefined {\n\t\tconst entry = this.#pending.get(id)\n\t\tif (entry === undefined) return undefined\n\t\tthis.#pending.delete(id)\n\t\tclearTimeout(entry.timer)\n\t\tif (entry.listener !== undefined) entry.signal?.removeEventListener('abort', entry.listener)\n\t\treturn entry\n\t}\n\n\t#nextId(): number {\n\t\tthis.#messageId += 1\n\t\treturn this.#messageId\n\t}\n\n\t#onClose(): void {\n\t\tthis.#connected = false\n\t\tthis.#active = false\n\n\t\t// Reject all pending requests\n\t\tfor (const [id, entry] of this.#pending) {\n\t\t\tthis.#settle(id)?.reject(\n\t\t\t\tnew CDPConnectionError('CDP connection closed', { method: entry.method }),\n\t\t\t)\n\t\t}\n\t\tif (!this.#expected) this.#emitter.emit('drop')\n\t}\n\n\t#onError(error: unknown): void {\n\t\tthis.#connected = false\n\t\tfor (const [id, entry] of this.#pending) {\n\t\t\tthis.#settle(id)?.reject(\n\t\t\t\tnew CDPConnectionError(`CDP connection failed: ${String(error)}`, {\n\t\t\t\t\tmethod: entry.method,\n\t\t\t\t\terror,\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t\tthis.#emitter.emit('error', error)\n\t}\n\n\t#onMessage(data: string): void {\n\t\tconst parsed = parseJSON(data)\n\t\tif (!isRecord(parsed)) return\n\n\t\t// Response to a pending request\n\t\tif (isInteger(parsed['id'])) {\n\t\t\tconst id = parsed['id']\n\t\t\tconst entry = this.#settle(id)\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst errorValue = parsed['error']\n\t\t\t\tif (isRecord(errorValue)) {\n\t\t\t\t\tconst message = isString(errorValue['message']) ? errorValue['message'] : 'CDP error'\n\t\t\t\t\tconst context: Record<string, unknown> = { method: entry.method }\n\t\t\t\t\tif ('code' in errorValue) context['code'] = errorValue['code']\n\t\t\t\t\tcontext['message'] = message\n\t\t\t\t\tif ('data' in errorValue) context['data'] = errorValue['data']\n\t\t\t\t\tentry.reject(new CDPError(message, context))\n\t\t\t\t} else {\n\t\t\t\t\tentry.resolve('result' in parsed ? parsed['result'] : undefined)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\t// CDP event\n\t\tif (isString(parsed['method'])) {\n\t\t\tconst method = parsed['method']\n\t\t\tconst rawParams = parsed['params']\n\t\t\tconst params: Readonly<Record<string, unknown>> = isRecord(rawParams)\n\t\t\t\t? rawParams\n\t\t\t\t: Object.freeze({})\n\n\t\t\tconst global = this.#subscriptions.get(undefined)?.get(method)\n\t\t\tif (global !== undefined) this.#dispatch(global, method, params)\n\n\t\t\tconst session = parsed['sessionId']\n\t\t\tif (isString(session)) {\n\t\t\t\tconst scoped = this.#subscriptions.get(session)?.get(method)\n\t\t\t\tif (scoped !== undefined) this.#dispatch(scoped, method, params)\n\t\t\t}\n\t\t}\n\t}\n\n\t#dispatch(\n\t\thandlers: ReadonlySet<CDPHandler>,\n\t\tmethod: string,\n\t\tparams: Readonly<Record<string, unknown>>,\n\t): void {\n\t\tfor (const handler of [...handlers]) {\n\t\t\ttry {\n\t\t\t\thandler(params)\n\t\t\t} catch (thrown) {\n\t\t\t\t// One observer must not prevent sibling observers from receiving the\n\t\t\t\t// event, so the throw is reported rather than propagated.\n\t\t\t\tthis.#error?.(thrown, method)\n\t\t\t}\n\t\t}\n\t}\n}\n","import type {\n\tBrowserAccessibilityInterface,\n\tBrowserAccessibilityOptions,\n\tBrowserAccessibilitySnapshot,\n\tBrowserFrameInterface,\n} from './types.js'\nimport { readBrowserAccessibility, validateBrowserAccessibilityOptions } from './helpers.js'\n\n/**\n * Captures Chromium Accessibility-domain snapshots for one page.\n *\n * @example\n * ```ts\n * import { BrowserAccessibility } from '@orkestrel/browser'\n *\n * const accessibility = new BrowserAccessibility(page)\n * const tree = await accessibility.snapshot({ depth: 3 }) // { roots, nodes }\n * ```\n */\nexport class BrowserAccessibility implements BrowserAccessibilityInterface {\n\treadonly #frame: BrowserFrameInterface\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tasync snapshot(options?: BrowserAccessibilityOptions): Promise<BrowserAccessibilitySnapshot> {\n\t\tvalidateBrowserAccessibilityOptions(options)\n\t\tawait this.#frame.send('Accessibility.enable')\n\t\ttry {\n\t\t\tconst result =\n\t\t\t\toptions?.root === undefined\n\t\t\t\t\t? await this.#frame.send('Accessibility.getFullAXTree', {\n\t\t\t\t\t\t\tdepth: options?.depth,\n\t\t\t\t\t\t\tframeId: this.#frame.id,\n\t\t\t\t\t\t})\n\t\t\t\t\t: await this.#frame.send('Accessibility.getPartialAXTree', {\n\t\t\t\t\t\t\tbackendNodeId: options.root,\n\t\t\t\t\t\t\tfetchRelatives: true,\n\t\t\t\t\t\t})\n\t\t\treturn readBrowserAccessibility(result)\n\t\t} finally {\n\t\t\tawait this.#frame.send('Accessibility.disable').catch(() => undefined)\n\t\t}\n\t}\n}\n","import type { BrowserClockInterface, BrowserFrameInterface } from './types.js'\nimport { BROWSER_DEFAULT_TIMEOUT_MS } from './constants.js'\nimport { BrowserError } from './errors.js'\nimport { settleBrowserTeardown } from './helpers.js'\nimport { isFiniteNumber } from '@orkestrel/contract'\n\n/**\n * Controls the Chromium virtual-time budget for deterministic page timers.\n *\n * @example\n * ```ts\n * import { BrowserClock } from '@orkestrel/browser'\n *\n * const clock = new BrowserClock(page)\n * await clock.install(Date.UTC(2026, 0, 1))\n * await clock.advance(5_000)\n * await clock.uninstall()\n * ```\n */\nexport class BrowserClock implements BrowserClockInterface {\n\treadonly #frame: BrowserFrameInterface\n\t#installed = false\n\t#advancing = false\n\t#budgetResolve: (() => void) | undefined\n\treadonly #budgetHandler = this.#handleBudget.bind(this)\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tget installed(): boolean {\n\t\treturn this.#installed\n\t}\n\n\tasync install(time = Date.now()): Promise<void> {\n\t\tif (this.#installed) throw new BrowserError('Browser clock is already installed')\n\t\tif (!isFiniteNumber(time) || time < 0) {\n\t\t\tthrow new BrowserError('Browser clock time must be a non-negative finite epoch', undefined, {\n\t\t\t\ttime,\n\t\t\t})\n\t\t}\n\t\tawait this.#frame.send('Emulation.setVirtualTimePolicy', {\n\t\t\tpolicy: 'pause',\n\t\t\tinitialVirtualTime: time / 1000,\n\t\t})\n\t\tthis.#installed = true\n\t}\n\n\tasync pause(): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#idle()\n\t\tawait this.#frame.send('Emulation.setVirtualTimePolicy', { policy: 'pause' })\n\t}\n\n\tasync resume(): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#idle()\n\t\tawait this.#frame.send('Emulation.setVirtualTimePolicy', {\n\t\t\tpolicy: 'advance',\n\t\t\tmaxVirtualTimeTaskStarvationCount: 10_000,\n\t\t})\n\t}\n\n\tasync advance(ms: number): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#idle()\n\t\tif (!isFiniteNumber(ms) || ms < 0) {\n\t\t\tthrow new BrowserError('Browser clock advance must be non-negative and finite', undefined, {\n\t\t\t\tms,\n\t\t\t})\n\t\t}\n\t\tif (ms === 0) {\n\t\t\tawait this.pause()\n\t\t\treturn\n\t\t}\n\t\tconst deferred = Promise.withResolvers<void>()\n\t\tthis.#advancing = true\n\t\tthis.#budgetResolve = deferred.resolve\n\t\ttry {\n\t\t\tawait this.#frame.subscribe('Emulation.virtualTimeBudgetExpired', this.#budgetHandler)\n\t\t} catch (error) {\n\t\t\tthis.#budgetResolve = undefined\n\t\t\tthis.#advancing = false\n\t\t\tthrow error\n\t\t}\n\t\tconst timer = setTimeout(() => {\n\t\t\tdeferred.reject(new BrowserError('Browser virtual-time budget timed out'))\n\t\t}, BROWSER_DEFAULT_TIMEOUT_MS)\n\t\tlet failure: unknown\n\t\ttry {\n\t\t\tawait this.#frame.send('Emulation.setVirtualTimePolicy', {\n\t\t\t\tpolicy: 'advance',\n\t\t\t\tbudget: ms,\n\t\t\t\tmaxVirtualTimeTaskStarvationCount: 10_000,\n\t\t\t})\n\t\t\tawait deferred.promise\n\t\t} catch (error) {\n\t\t\tfailure = error\n\t\t} finally {\n\t\t\tclearTimeout(timer)\n\t\t\tthis.#budgetResolve = undefined\n\t\t\tconst settled = await settleBrowserTeardown(\n\t\t\t\t() => this.#frame.unsubscribe('Emulation.virtualTimeBudgetExpired', this.#budgetHandler),\n\t\t\t\t() => this.#frame.send('Emulation.setVirtualTimePolicy', { policy: 'pause' }),\n\t\t\t)\n\t\t\tfailure ??= settled\n\t\t\tthis.#advancing = false\n\t\t}\n\t\tif (failure !== undefined) throw failure\n\t}\n\n\tasync uninstall(): Promise<void> {\n\t\tif (!this.#installed) return\n\t\tthis.#idle()\n\t\tawait this.#frame.send('Emulation.setVirtualTimePolicy', {\n\t\t\tpolicy: 'advance',\n\t\t\tmaxVirtualTimeTaskStarvationCount: 10_000,\n\t\t})\n\t\tthis.#installed = false\n\t}\n\n\t#assert(): void {\n\t\tif (!this.#installed) throw new BrowserError('Browser clock is not installed')\n\t}\n\n\t#idle(): void {\n\t\tif (this.#advancing) throw new BrowserError('Browser clock advance is already active')\n\t}\n\n\t#handleBudget(): void {\n\t\tthis.#budgetResolve?.()\n\t}\n}\n","import type {\n\tBrowserCoverageInterface,\n\tBrowserCoverageOptions,\n\tBrowserCoverageResult,\n\tBrowserFrameInterface,\n} from './types.js'\nimport {\n\treadBrowserScriptCoverage,\n\treadBrowserStyleCoverage,\n\tsettleBrowserTeardown,\n} from './helpers.js'\nimport { BrowserError } from './errors.js'\n\n/**\n * Collects JavaScript precise coverage and CSS rule usage for one page target.\n *\n * @example\n * ```ts\n * import { BrowserCoverage } from '@orkestrel/browser'\n *\n * const coverage = new BrowserCoverage(page)\n * await coverage.start({ javascript: true, css: true })\n * const usage = await coverage.stop() // { scripts, styles }\n * ```\n */\nexport class BrowserCoverage implements BrowserCoverageInterface {\n\treadonly #frame: BrowserFrameInterface\n\t#active = false\n\t#options: BrowserCoverageOptions | undefined\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tget active(): boolean {\n\t\treturn this.#active\n\t}\n\n\tasync start(options?: BrowserCoverageOptions): Promise<void> {\n\t\tif (this.#active) throw new BrowserError('Browser coverage is already active')\n\t\tconst javascript = options?.javascript ?? true\n\t\tconst css = options?.css ?? true\n\t\tif (!javascript && !css) {\n\t\t\tthrow new BrowserError('Browser coverage requires JavaScript, CSS, or both')\n\t\t}\n\t\tlet profiler = false\n\t\tlet precise = false\n\t\tlet dom = false\n\t\tlet styles = false\n\t\tlet rules = false\n\t\ttry {\n\t\t\tif (javascript) {\n\t\t\t\tawait this.#frame.send('Profiler.enable')\n\t\t\t\tprofiler = true\n\t\t\t\tawait this.#frame.send('Profiler.startPreciseCoverage', {\n\t\t\t\t\tcallCount: true,\n\t\t\t\t\tdetailed: options?.detailed ?? true,\n\t\t\t\t\tallowTriggeredUpdates: false,\n\t\t\t\t})\n\t\t\t\tprecise = true\n\t\t\t}\n\t\t\tif (css) {\n\t\t\t\tawait this.#frame.send('DOM.enable')\n\t\t\t\tdom = true\n\t\t\t\tawait this.#frame.send('CSS.enable')\n\t\t\t\tstyles = true\n\t\t\t\tawait this.#frame.send('CSS.startRuleUsageTracking')\n\t\t\t\trules = true\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (rules) {\n\t\t\t\tawait this.#frame.send('CSS.stopRuleUsageTracking').catch(() => undefined)\n\t\t\t}\n\t\t\tif (styles) await this.#frame.send('CSS.disable').catch(() => undefined)\n\t\t\tif (dom) await this.#frame.send('DOM.disable').catch(() => undefined)\n\t\t\tif (precise) {\n\t\t\t\tawait this.#frame.send('Profiler.stopPreciseCoverage').catch(() => undefined)\n\t\t\t}\n\t\t\tif (profiler) await this.#frame.send('Profiler.disable').catch(() => undefined)\n\t\t\tthrow error\n\t\t}\n\t\tthis.#options = options\n\t\tthis.#active = true\n\t}\n\n\tasync stop(): Promise<BrowserCoverageResult> {\n\t\tif (!this.#active) throw new BrowserError('Browser coverage is not active')\n\t\tthis.#active = false\n\t\tconst javascript = this.#options?.javascript ?? true\n\t\tconst css = this.#options?.css ?? true\n\t\tlet scripts: BrowserCoverageResult['scripts'] = []\n\t\tlet styles: BrowserCoverageResult['styles'] = []\n\t\tconst failure = await settleBrowserTeardown(\n\t\t\tasync () => {\n\t\t\t\tif (javascript) scripts = await this.#stopJavaScript()\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tif (css) styles = await this.#stopCSS()\n\t\t\t},\n\t\t)\n\t\tthis.#options = undefined\n\t\tif (failure !== undefined) throw failure\n\t\treturn { scripts, styles }\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tif (!this.#active) return\n\t\tawait this.stop().catch(() => undefined)\n\t}\n\n\tasync #stopJavaScript(): Promise<BrowserCoverageResult['scripts']> {\n\t\tlet result: unknown\n\t\tconst failure = await settleBrowserTeardown(\n\t\t\tasync () => {\n\t\t\t\tresult = await this.#frame.send('Profiler.takePreciseCoverage')\n\t\t\t},\n\t\t\t() => this.#frame.send('Profiler.stopPreciseCoverage'),\n\t\t\t() => this.#frame.send('Profiler.disable'),\n\t\t)\n\t\tif (failure !== undefined) throw failure\n\t\treturn readBrowserScriptCoverage(result)\n\t}\n\n\tasync #stopCSS(): Promise<BrowserCoverageResult['styles']> {\n\t\tlet result: unknown\n\t\tconst failure = await settleBrowserTeardown(\n\t\t\tasync () => {\n\t\t\t\tresult = await this.#frame.send('CSS.stopRuleUsageTracking')\n\t\t\t},\n\t\t\t() => this.#frame.send('CSS.disable'),\n\t\t\t() => this.#frame.send('DOM.disable'),\n\t\t)\n\t\tif (failure !== undefined) throw failure\n\t\treturn readBrowserStyleCoverage(result)\n\t}\n}\n","import type {\n\tBrowserCookie,\n\tBrowserCookieFilter,\n\tBrowserCookieInput,\n\tBrowserCookieManagerInterface,\n\tCDPClientInterface,\n} from './types.js'\nimport { cookieToProtocol, matchesBrowserCookieURL, readBrowserCookies } from './helpers.js'\nimport { isRecord } from '@orkestrel/contract'\nimport { BrowserError } from './errors.js'\n\n/**\n * Performs cookie operations isolated to one browser context.\n *\n * @example\n * ```ts\n * import { BrowserCookieManager } from '@orkestrel/browser'\n *\n * const cookies = new BrowserCookieManager(client)\n * await cookies.set([{ name: 'session', value: 'value', url: 'https://example.com/' }])\n * const current = await cookies.cookies(['https://example.com/'])\n * ```\n */\nexport class BrowserCookieManager implements BrowserCookieManagerInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #context: string | undefined\n\n\tconstructor(client: CDPClientInterface, context?: string) {\n\t\tthis.#client = client\n\t\tthis.#context = context\n\t}\n\n\tasync cookies(urls?: readonly string[]): Promise<readonly BrowserCookie[]> {\n\t\tconst params: Record<string, unknown> = {}\n\t\tif (this.#context !== undefined) params['browserContextId'] = this.#context\n\t\tconst result = await this.#client.send('Storage.getCookies', params)\n\t\tconst cookies = readBrowserCookies(result)\n\t\tif (urls === undefined || urls.length === 0) return cookies\n\n\t\treturn cookies.filter((cookie) => urls.some((value) => matchesBrowserCookieURL(cookie, value)))\n\t}\n\n\tasync set(cookies: readonly BrowserCookieInput[]): Promise<void> {\n\t\tif (cookies.length === 0) return\n\t\tconst params: Record<string, unknown> = {\n\t\t\tcookies: cookies.map(cookieToProtocol),\n\t\t}\n\t\tif (this.#context !== undefined) params['browserContextId'] = this.#context\n\t\tawait this.#client.send('Storage.setCookies', params)\n\t}\n\n\tasync clear(filter?: BrowserCookieFilter): Promise<void> {\n\t\tconst params: Record<string, unknown> = {}\n\t\tif (this.#context !== undefined) params['browserContextId'] = this.#context\n\t\tif (filter === undefined) {\n\t\t\tawait this.#client.send('Storage.clearCookies', params)\n\t\t\treturn\n\t\t}\n\n\t\tconst retained = (await this.cookies()).filter((cookie) => {\n\t\t\tif (filter.name !== undefined && cookie.name !== filter.name) return true\n\t\t\tif (filter.domain !== undefined && cookie.domain !== filter.domain) return true\n\t\t\tif (filter.path !== undefined && cookie.path !== filter.path) return true\n\t\t\treturn false\n\t\t})\n\t\tawait this.#client.send('Storage.clearCookies', params)\n\t\tif (retained.length === 0) return\n\t\tconst cookies = retained.map((cookie) =>\n\t\t\tcookieToProtocol({\n\t\t\t\tname: cookie.name,\n\t\t\t\tvalue: cookie.value,\n\t\t\t\tdomain: cookie.domain,\n\t\t\t\tpath: cookie.path,\n\t\t\t\texpires: cookie.expires,\n\t\t\t\thttp: cookie.http,\n\t\t\t\tsecure: cookie.secure,\n\t\t\t\t...(cookie.site !== undefined ? { site: cookie.site } : {}),\n\t\t\t\t...(cookie.partition !== undefined ? { partition: cookie.partition } : {}),\n\t\t\t}),\n\t\t)\n\t\tconst restore: Record<string, unknown> = { cookies }\n\t\tif (this.#context !== undefined) restore['browserContextId'] = this.#context\n\t\tconst result = await this.#client.send('Storage.setCookies', restore)\n\t\tif (result !== undefined && !isRecord(result)) {\n\t\t\tthrow new BrowserError('Browser cookie restore returned a malformed result')\n\t\t}\n\t}\n}\n","import type {\n\tBrowserEmulationManagerInterface,\n\tBrowserEmulationOptions,\n\tBrowserPageInterface,\n\tBrowserPagesFunction,\n} from './types.js'\nimport { mediaToFeatures, validateBrowserEmulationOptions } from './helpers.js'\n\n/**\n * Applies rendering, identity, location, and network emulation for context pages.\n *\n * @example\n * ```ts\n * import { BrowserEmulationManager } from '@orkestrel/browser'\n *\n * const emulation = new BrowserEmulationManager(() => context.pages())\n * await emulation.apply({ locale: 'en-US', media: { scheme: 'dark' } })\n * await emulation.clear()\n * ```\n */\nexport class BrowserEmulationManager implements BrowserEmulationManagerInterface {\n\treadonly #pages: BrowserPagesFunction\n\t#options: BrowserEmulationOptions | undefined\n\n\tconstructor(pages: BrowserPagesFunction, options?: BrowserEmulationOptions) {\n\t\tif (options !== undefined) validateBrowserEmulationOptions(options)\n\t\tthis.#pages = pages\n\t\tthis.#options = options\n\t}\n\n\tasync apply(options: BrowserEmulationOptions): Promise<void> {\n\t\tvalidateBrowserEmulationOptions(options)\n\t\tconst previous = this.#options\n\t\tconst changed: BrowserPageInterface[] = []\n\t\ttry {\n\t\t\tfor (const page of this.#pages()) {\n\t\t\t\tchanged.push(page)\n\t\t\t\tif (previous !== undefined) await this.#clearPage(page, previous)\n\t\t\t\tawait this.#configurePage(page, options)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfor (const page of changed.reverse()) {\n\t\t\t\tawait this.#clearPage(page, options).catch(() => undefined)\n\t\t\t\tif (previous !== undefined) {\n\t\t\t\t\tawait this.#configurePage(page, previous).catch(() => undefined)\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t\tthis.#options = options\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tconst previous = this.#options\n\t\tif (previous === undefined) return\n\t\tconst changed: BrowserPageInterface[] = []\n\t\ttry {\n\t\t\tfor (const page of this.#pages()) {\n\t\t\t\tchanged.push(page)\n\t\t\t\tawait this.#clearPage(page, previous)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfor (const page of changed.reverse()) {\n\t\t\t\tawait this.#clearPage(page, previous).catch(() => undefined)\n\t\t\t\tawait this.#configurePage(page, previous).catch(() => undefined)\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t\tthis.#options = undefined\n\t}\n\n\tasync attach(page: BrowserPageInterface): Promise<void> {\n\t\tconst options = this.#options\n\t\tif (options === undefined) return\n\t\ttry {\n\t\t\tawait this.#configurePage(page, options)\n\t\t} catch (error) {\n\t\t\tawait this.#clearPage(page, options).catch(() => undefined)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #configurePage(\n\t\tpage: BrowserPageInterface,\n\t\toptions: BrowserEmulationOptions,\n\t): Promise<void> {\n\t\tif (options.viewport !== undefined) {\n\t\t\tawait page.send('Emulation.setDeviceMetricsOverride', {\n\t\t\t\twidth: options.viewport.width,\n\t\t\t\theight: options.viewport.height,\n\t\t\t\tdeviceScaleFactor: options.viewport.scale ?? 1,\n\t\t\t\tmobile: options.viewport.mobile ?? false,\n\t\t\t\tscreenOrientation:\n\t\t\t\t\toptions.viewport.landscape === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\ttype: options.viewport.landscape ? 'landscapePrimary' : 'portraitPrimary',\n\t\t\t\t\t\t\t\tangle: options.viewport.landscape ? 90 : 0,\n\t\t\t\t\t\t\t},\n\t\t\t})\n\t\t\tawait page.send('Emulation.setTouchEmulationEnabled', {\n\t\t\t\tenabled: options.viewport.touch ?? false,\n\t\t\t})\n\t\t}\n\t\tif (options.user !== undefined) {\n\t\t\tawait page.send('Emulation.setUserAgentOverride', {\n\t\t\t\tuserAgent: options.user.value,\n\t\t\t\tacceptLanguage: options.user.language,\n\t\t\t\tplatform: options.user.platform,\n\t\t\t})\n\t\t}\n\t\tif (options.locale !== undefined) {\n\t\t\tawait page.send('Emulation.setLocaleOverride', { locale: options.locale })\n\t\t}\n\t\tif (options.timezone !== undefined) {\n\t\t\tawait page.send('Emulation.setTimezoneOverride', { timezoneId: options.timezone })\n\t\t}\n\t\tif (options.geolocation !== undefined) {\n\t\t\tawait page.send('Emulation.setGeolocationOverride', {\n\t\t\t\tlatitude: options.geolocation.latitude,\n\t\t\t\tlongitude: options.geolocation.longitude,\n\t\t\t\taccuracy: options.geolocation.accuracy,\n\t\t\t})\n\t\t}\n\t\tif (options.media !== undefined) {\n\t\t\tawait page.send('Emulation.setEmulatedMedia', {\n\t\t\t\tmedia: options.media.output ?? '',\n\t\t\t\tfeatures: mediaToFeatures(options.media),\n\t\t\t})\n\t\t}\n\t\tif (options.offline !== undefined) {\n\t\t\tawait page.network.offline(options.offline)\n\t\t}\n\t\tif (options.headers !== undefined) {\n\t\t\tawait page.network.headers(options.headers)\n\t\t}\n\t\tif (options.credentials !== undefined) {\n\t\t\tawait page.network.credentials(options.credentials)\n\t\t}\n\t}\n\n\tasync #clearPage(page: BrowserPageInterface, options: BrowserEmulationOptions): Promise<void> {\n\t\tif (options.viewport !== undefined) {\n\t\t\tawait page.send('Emulation.clearDeviceMetricsOverride')\n\t\t\tawait page.send('Emulation.setTouchEmulationEnabled', { enabled: false })\n\t\t}\n\t\tif (options.user !== undefined) {\n\t\t\tawait page.send('Emulation.setUserAgentOverride', { userAgent: '' })\n\t\t}\n\t\tif (options.locale !== undefined) {\n\t\t\tawait page.send('Emulation.setLocaleOverride', { locale: '' })\n\t\t}\n\t\tif (options.timezone !== undefined) {\n\t\t\tawait page.send('Emulation.setTimezoneOverride', { timezoneId: '' })\n\t\t}\n\t\tif (options.geolocation !== undefined) {\n\t\t\tawait page.send('Emulation.clearGeolocationOverride')\n\t\t}\n\t\tif (options.media !== undefined) {\n\t\t\tawait page.send('Emulation.setEmulatedMedia', { media: '', features: [] })\n\t\t}\n\t\tif (options.offline !== undefined) {\n\t\t\tawait page.network.offline(false)\n\t\t}\n\t\tif (options.headers !== undefined) {\n\t\t\tawait page.network.headers({})\n\t\t}\n\t\tif (options.credentials !== undefined) await page.network.credentials(undefined)\n\t}\n}\n","import type {\n\tBrowserCodegenGesture,\n\tBrowserCodegenInterface,\n\tBrowserCodegenLanguage,\n\tBrowserCodegenScript,\n\tBrowserJourney,\n\tBrowserJourneyStep,\n\tBrowserJourneyStepInput,\n\tBrowserJourneyTarget,\n\tBrowserRecorderEventMap,\n\tBrowserRecorderOptions,\n\tCDPClientInterface,\n\tCDPHandler,\n} from '../types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { isArray, isInteger, isRecord, isString } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { BrowserTransition } from '../BrowserTransition.js'\nimport {\n\tBROWSER_CODEGEN_BINDING_NAME,\n\tBROWSER_CODEGEN_SOURCE,\n\tBROWSER_INTERACTIVE_ROLES,\n} from '../constants.js'\nimport { compileBrowserJourney } from '../compilers.js'\nimport { BrowserError } from '../errors.js'\nimport {\n\tbuildBrowserJourney,\n\tcollectBrowserJourneyTextBindings,\n\tderiveBrowserJourneySecret,\n\treadBrowserAXValue,\n\treadBrowserFrames,\n} from '../helpers.js'\nimport { parseCodegenActionPayload } from '../parsers.js'\n\n/**\n * Records semantic page gestures and compiles them into a journey module.\n * @example\n * const recorder = await page.codegen()\n * await recorder.stop()\n * const script = recorder.script({ name: \"add-note\", description: \"Add a note\" })\n */\nexport class BrowserCodegen implements BrowserCodegenInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #session: string\n\treadonly #frames: (() => readonly string[]) | undefined\n\treadonly #emitter: Emitter<BrowserRecorderEventMap>\n\treadonly #starting = new BrowserTransition()\n\treadonly #stopping = new BrowserTransition<readonly BrowserJourneyStep[]>()\n\treadonly #sessions = new Map<\n\t\tstring,\n\t\t{\n\t\t\treadonly handlers: ReadonlyArray<readonly [string, CDPHandler]>\n\t\t\treadonly contexts: Set<number>\n\t\t\treadonly attempt: Promise<void>\n\t\t}\n\t>()\n\treadonly #scripts = new Map<string, string>()\n\t#started = false\n\t#shutdown: Promise<void> | undefined\n\t#queue: Promise<void> = Promise.resolve()\n\t#steps: readonly BrowserJourneyStep[] = []\n\t#pending: { readonly key: string; readonly step: BrowserJourneyStepInput } | undefined\n\t#enter: string | undefined\n\t#epoch = 0\n\t#frame: string | undefined\n\n\tconstructor(\n\t\tclient: CDPClientInterface,\n\t\tsession: string,\n\t\toptions?: BrowserRecorderOptions,\n\t\tframes?: () => readonly string[],\n\t) {\n\t\tthis.#client = client\n\t\tthis.#session = session\n\t\tthis.#frames = frames\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t}\n\tget emitter(): EmitterInterface<BrowserRecorderEventMap> {\n\t\treturn this.#emitter\n\t}\n\tget started(): boolean {\n\t\treturn this.#started\n\t}\n\n\tasync start(): Promise<void> {\n\t\tif (this.#shutdown !== undefined || this.#emitter.destroyed)\n\t\t\tthrow new BrowserError('The recorder was destroyed')\n\t\tawait this.#stopping.pending\n\t\tif (this.#starting.pending !== undefined) return await this.#starting.pending\n\t\tif (this.#started) return\n\t\tawait this.#starting.execute(async () => {\n\t\t\tthis.clear()\n\t\t\ttry {\n\t\t\t\tawait this.#install(this.#session)\n\t\t\t\tawait Promise.all((this.#frames?.() ?? []).map((session) => this.#install(session)))\n\t\t\t\tthis.#started = true\n\t\t\t\tthis.#emitter.emit('start')\n\t\t\t} catch (error) {\n\t\t\t\tawait this.#remove()\n\t\t\t\tthrow error\n\t\t\t}\n\t\t})\n\t}\n\t/**\n\t * Installs recording on an attached frame before its owner resumes it.\n\t * @param session - The attached frame session\n\t * @returns Completion of listener installation\n\t */\n\tasync attach(session: string): Promise<void> {\n\t\tif (\n\t\t\t(!this.#started && this.#starting.pending === undefined) ||\n\t\t\tthis.#stopping.pending !== undefined ||\n\t\t\tthis.#shutdown !== undefined\n\t\t)\n\t\t\treturn\n\t\tawait this.#install(session)\n\t}\n\tasync stop(): Promise<readonly BrowserJourneyStep[]> {\n\t\tawait this.#starting.pending?.catch(() => undefined)\n\t\tif (this.#stopping.pending !== undefined) return await this.#stopping.pending\n\t\tif (!this.#started) return this.steps()\n\t\treturn await this.#stopping.execute(async () => {\n\t\t\tawait this.#remove()\n\t\t\tawait this.#queue\n\t\t\tthis.#flush()\n\t\t\tthis.#enter = undefined\n\t\t\tthis.#started = false\n\t\t\tconst steps = this.steps()\n\t\t\tthis.#emitter.emit('stop', structuredClone(steps))\n\t\t\treturn steps\n\t\t})\n\t}\n\tsteps(): readonly BrowserJourneyStep[] {\n\t\treturn structuredClone(this.#steps)\n\t}\n\tjourney(options: { readonly name: string; readonly description: string }): BrowserJourney {\n\t\treturn buildBrowserJourney(this.#steps, options)\n\t}\n\tscript(options: {\n\t\treadonly name: string\n\t\treadonly description: string\n\t\treadonly language?: BrowserCodegenLanguage\n\t}): BrowserCodegenScript {\n\t\treturn compileBrowserJourney(\n\t\t\tthis.journey({ name: options.name, description: options.description }),\n\t\t\toptions.language === undefined ? {} : { language: options.language },\n\t\t)\n\t}\n\tclear(): void {\n\t\tthis.#epoch += 1\n\t\tthis.#steps = []\n\t\tthis.#pending = undefined\n\t\tthis.#enter = undefined\n\t\tthis.#emitter.emit('clear')\n\t}\n\tasync destroy(): Promise<void> {\n\t\tif (this.#shutdown !== undefined) return await this.#shutdown\n\t\tthis.#shutdown = this.#destroy()\n\t\tawait this.#shutdown\n\t}\n\tasync #destroy(): Promise<void> {\n\t\tawait this.stop()\n\t\tthis.clear()\n\t\tthis.#emitter.destroy()\n\t}\n\tasync #install(session: string): Promise<void> {\n\t\tconst active = this.#sessions.get(session)\n\t\tif (active !== undefined) return await active.attempt\n\t\tconst handlers: ReadonlyArray<readonly [string, CDPHandler]> = [\n\t\t\t['Runtime.bindingCalled', this.#binding.bind(this, session)],\n\t\t\t['Page.frameNavigated', this.#navigation.bind(this, session)],\n\t\t\t['Page.navigatedWithinDocument', this.#navigation.bind(this, session)],\n\t\t\t['Page.javascriptDialogClosed', this.#dialog.bind(this)],\n\t\t]\n\t\tfor (const [method, handler] of handlers) this.#client.subscribe(method, handler, session)\n\t\tconst attempt = this.#inject(session)\n\t\tthis.#sessions.set(session, { handlers, contexts: new Set(), attempt })\n\t\tawait attempt\n\t}\n\tasync #inject(session: string): Promise<void> {\n\t\tawait this.#client.send('Page.enable', undefined, { session })\n\t\tif (session === this.#session) {\n\t\t\tconst tree = await this.#client.send('Page.getFrameTree', undefined, { session })\n\t\t\tthis.#frame = readBrowserFrames(tree).find((frame) => frame.parent === undefined)?.id\n\t\t\tif (this.#frame === undefined) throw new BrowserError('The recorder requires a main frame')\n\t\t}\n\t\tawait this.#client.send('Runtime.enable', undefined, { session })\n\t\tawait this.#client.send(\n\t\t\t'Runtime.addBinding',\n\t\t\t{ name: BROWSER_CODEGEN_BINDING_NAME },\n\t\t\t{ session },\n\t\t)\n\t\tconst result = await this.#client.send(\n\t\t\t'Page.addScriptToEvaluateOnNewDocument',\n\t\t\t{ source: BROWSER_CODEGEN_SOURCE, runImmediately: true },\n\t\t\t{ session },\n\t\t)\n\t\tif (isRecord(result) && isString(result['identifier']))\n\t\t\tthis.#scripts.set(session, result['identifier'])\n\t\tif (session === this.#session)\n\t\t\tawait this.#client.send(\n\t\t\t\t'Runtime.evaluate',\n\t\t\t\t{ expression: BROWSER_CODEGEN_SOURCE },\n\t\t\t\t{ session },\n\t\t\t)\n\t}\n\tasync #remove(): Promise<void> {\n\t\tawait Promise.all(\n\t\t\t[...this.#sessions].map(async ([session, entry]) => {\n\t\t\t\tawait entry.attempt.catch(() => undefined)\n\t\t\t\tconst identifier = this.#scripts.get(session)\n\t\t\t\tif (identifier !== undefined)\n\t\t\t\t\tawait this.#client\n\t\t\t\t\t\t.send('Page.removeScriptToEvaluateOnNewDocument', { identifier }, { session })\n\t\t\t\t\t\t.catch(() => undefined)\n\t\t\t\t// Removing the binding acknowledges reports already sent by this renderer.\n\t\t\t\tawait this.#client\n\t\t\t\t\t.send('Runtime.removeBinding', { name: BROWSER_CODEGEN_BINDING_NAME }, { session })\n\t\t\t\t\t.catch(() => undefined)\n\t\t\t\tfor (const [method, handler] of entry.handlers)\n\t\t\t\t\tthis.#client.unsubscribe(method, handler, session)\n\t\t\t\tconst expression = `window[${JSON.stringify(BROWSER_CODEGEN_BINDING_NAME + '__state')}]?.controller.abort()`\n\t\t\t\tawait Promise.all(\n\t\t\t\t\t[undefined, ...entry.contexts].map(async (contextId) => {\n\t\t\t\t\t\tawait this.#client\n\t\t\t\t\t\t\t.send(\n\t\t\t\t\t\t\t\t'Runtime.evaluate',\n\t\t\t\t\t\t\t\t{ expression, ...(contextId === undefined ? {} : { contextId }) },\n\t\t\t\t\t\t\t\t{ session },\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.catch(() => undefined)\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}),\n\t\t)\n\t\tthis.#sessions.clear()\n\t\tthis.#scripts.clear()\n\t}\n\t#binding(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tif (params['name'] !== BROWSER_CODEGEN_BINDING_NAME) return\n\t\tconst gesture = parseCodegenActionPayload(params['payload'])\n\t\tconst context = params['executionContextId']\n\t\tif (gesture === undefined || !isInteger(context) || context < 1) return\n\t\tthis.#sessions.get(session)?.contexts.add(context)\n\t\tconst key = `${session}:${context}:${gesture.index}`\n\t\tconst document = `${session}:${context}`\n\t\tconst epoch = this.#epoch\n\t\t// Start the lookup while the node still exists; serialize only the projection.\n\t\tconst target =\n\t\t\tgesture.top && gesture.event !== 'submit' && gesture.event !== 'focusout'\n\t\t\t\t? this.#target(session, context, gesture.index).catch(() => undefined)\n\t\t\t\t: Promise.resolve(undefined)\n\t\tthis.#queue = this.#queue.then(async () => {\n\t\t\tconst resolved = await target\n\t\t\tif (epoch !== this.#epoch) return\n\t\t\tthis.#project(gesture, key, document, resolved)\n\t\t})\n\t}\n\tasync #target(\n\t\tsession: string,\n\t\tcontextId: number,\n\t\tindex: number,\n\t): Promise<BrowserJourneyTarget | undefined> {\n\t\tconst result = await this.#client.send(\n\t\t\t'Runtime.evaluate',\n\t\t\t{\n\t\t\t\texpression: `window[${JSON.stringify(BROWSER_CODEGEN_BINDING_NAME + '__state')}].nodes[${index}]`,\n\t\t\t\tcontextId,\n\t\t\t},\n\t\t\t{ session },\n\t\t)\n\t\tif (!isRecord(result) || !isRecord(result['result']) || !isString(result['result']['objectId']))\n\t\t\treturn undefined\n\t\tconst objectId = result['result']['objectId']\n\t\ttry {\n\t\t\tconst tree = await this.#client.send(\n\t\t\t\t'Accessibility.getPartialAXTree',\n\t\t\t\t{ objectId, fetchRelatives: true },\n\t\t\t\t{ session },\n\t\t\t)\n\t\t\tif (!isRecord(tree) || !isArray(tree['nodes'])) return undefined\n\t\t\tfor (const node of tree['nodes']) {\n\t\t\t\tif (!isRecord(node) || node['ignored'] === true) continue\n\t\t\t\tconst role = readBrowserAXValue(node['role'])\n\t\t\t\tconst name = readBrowserAXValue(node['name'])\n\t\t\t\tif (isString(role) && BROWSER_INTERACTIVE_ROLES.has(role) && isString(name))\n\t\t\t\t\treturn { role, name }\n\t\t\t}\n\t\t\treturn undefined\n\t\t} finally {\n\t\t\tawait this.#client\n\t\t\t\t.send('Runtime.releaseObject', { objectId }, { session })\n\t\t\t\t.catch(() => undefined)\n\t\t}\n\t}\n\t#project(\n\t\tgesture: BrowserCodegenGesture,\n\t\tkey: string,\n\t\tdocument: string,\n\t\ttarget: BrowserJourneyTarget | undefined,\n\t): void {\n\t\tif (gesture.event === 'submit') {\n\t\t\tthis.#enter = undefined\n\t\t\tthis.#flush()\n\t\t\treturn\n\t\t}\n\t\tif (gesture.event === 'focusout') {\n\t\t\tif (this.#pending?.key === key) this.#flush()\n\t\t\tthis.#enter = undefined\n\t\t\treturn\n\t\t}\n\t\tif (\n\t\t\tgesture.event === 'change' &&\n\t\t\t(gesture.control === 'text' || gesture.control === 'password')\n\t\t)\n\t\t\treturn\n\t\tif (gesture.event === 'input' && ['select', 'multiple', 'option'].includes(gesture.control))\n\t\t\treturn\n\t\tif (gesture.event === 'click' && ['select', 'multiple', 'option'].includes(gesture.control))\n\t\t\treturn\n\t\tif (gesture.event === 'click' && gesture.detail === 0 && this.#enter === document) return\n\t\tif (!gesture.top) {\n\t\t\tthis.#gap('the element is in a child frame')\n\t\t\treturn\n\t\t}\n\t\tif (gesture.event === 'unsupported') {\n\t\t\tthis.#gap(gesture.gap ?? 'an unsupported gesture')\n\t\t\treturn\n\t\t}\n\t\tif (gesture.event === 'keydown') {\n\t\t\tif (this.#pending?.key === key && this.#pending.step.action === 'type') {\n\t\t\t\tif (gesture.form)\n\t\t\t\t\tthis.#pending = {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tstep: {\n\t\t\t\t\t\t\t...this.#pending.step,\n\t\t\t\t\t\t\targuments: { ...this.#pending.step.arguments, submit: true },\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\tthis.#flush()\n\t\t\t\tif (!gesture.form) this.#append({ action: 'press', arguments: { key: 'Enter' } })\n\t\t\t} else {\n\t\t\t\tthis.#flush()\n\t\t\t\tthis.#append({ action: 'press', arguments: { key: 'Enter' } })\n\t\t\t}\n\t\t\tthis.#enter = gesture.form ? document : undefined\n\t\t\treturn\n\t\t}\n\t\tthis.#enter = undefined\n\t\tif (gesture.event === 'change' && gesture.control === 'multiple') {\n\t\t\tthis.#gap('a multiple selection')\n\t\t\treturn\n\t\t}\n\t\tif (gesture.event === 'change' && gesture.control === 'select' && !gesture.roundtrip) {\n\t\t\tthis.#gap('the option does not round-trip')\n\t\t\treturn\n\t\t}\n\t\tif (target === undefined) {\n\t\t\tthis.#gap('the element has no portable accessible target')\n\t\t\treturn\n\t\t}\n\t\tif (gesture.event === 'click') {\n\t\t\tthis.#flush()\n\t\t\tconst step = { action: 'click', arguments: {}, target }\n\t\t\tif (gesture.control === 'text' || gesture.control === 'password')\n\t\t\t\tthis.#pending = { key, step }\n\t\t\telse this.#append(step)\n\t\t\treturn\n\t\t}\n\t\tif (\n\t\t\tgesture.event === 'input' &&\n\t\t\t(gesture.control === 'text' || gesture.control === 'password')\n\t\t) {\n\t\t\tif (this.#pending?.key !== key) this.#flush()\n\t\t\tlet text = gesture.secret ? this.#pending?.step.arguments['text'] : gesture.value\n\t\t\tif (gesture.secret && !isRecord(text)) {\n\t\t\t\tconst taken = collectBrowserJourneyTextBindings(this.#steps)\n\t\t\t\ttext = {\n\t\t\t\t\tparameter: deriveBrowserJourneySecret(isString(target.name) ? target.name : '', taken),\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.#pending = { key, step: { action: 'type', arguments: { text: text ?? '' }, target } }\n\t\t\treturn\n\t\t}\n\t\tif (gesture.event === 'change' && gesture.control === 'select') {\n\t\t\tthis.#flush()\n\t\t\tthis.#append({ action: 'type', arguments: { text: gesture.value ?? '' }, target })\n\t\t\treturn\n\t\t}\n\t\tthis.#gap('an unsupported gesture')\n\t}\n\t#append(step: BrowserJourneyStepInput): void {\n\t\tconst recorded = structuredClone({ ...step, id: `s${this.#steps.length + 1}` })\n\t\tthis.#steps = [...this.#steps, recorded]\n\t\tthis.#emitter.emit('step', structuredClone(recorded))\n\t}\n\t#flush(): void {\n\t\tif (this.#pending === undefined) return\n\t\tconst pending = this.#pending\n\t\tthis.#pending = undefined\n\t\tthis.#append(pending.step)\n\t}\n\t#gap(gap: string): void {\n\t\tthis.#flush()\n\t\tthis.#append({ action: 'unresolved', arguments: {}, gap })\n\t}\n\t#navigation(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tif (session !== this.#session) return\n\t\tconst id = params['frameId']\n\t\tif (isString(id) && id !== this.#frame) return\n\t\tconst frame = params['frame']\n\t\tif (isRecord(frame) && 'parentId' in frame) return\n\t\tif (isRecord(frame) && isString(frame['id'])) this.#frame = frame['id']\n\t\tconst epoch = this.#epoch\n\t\tthis.#queue = this.#queue.then(() => {\n\t\t\tif (epoch === this.#epoch) {\n\t\t\t\tthis.#flush()\n\t\t\t\tthis.#enter = undefined\n\t\t\t}\n\t\t})\n\t}\n\t#dialog(): void {\n\t\tconst epoch = this.#epoch\n\t\tthis.#queue = this.#queue.then(() => {\n\t\t\tif (epoch === this.#epoch) this.#gap('a native dialog answer')\n\t\t})\n\t}\n}\n","import type {\n\tBrowserEpochFunction,\n\tBrowserReadOptions,\n\tBrowserReadResult,\n\tBrowserReadingInput,\n\tBrowserReadingInterface,\n} from './types.js'\nimport type { HTMLInterface } from '@orkestrel/html'\nimport { extractBrowserSlice } from './helpers.js'\nimport { createHTML, renderText } from '@orkestrel/html'\nimport { htmlToMarkdown, renderMarkdown } from '@orkestrel/markdown'\n\n/**\n * Represents one captured document, parsed one time and projected to Markdown or plain text in\n * bounded slices.\n *\n * @example\n * ```ts\n * import { BrowserReading } from '@orkestrel/browser'\n *\n * const reading = new BrowserReading({\n * \turl: 'https://example.com/',\n * \ttitle: 'Example',\n * \thtml: '<nav>Menu</nav><main><p>Body</p></main>',\n * })\n * reading.markdown() // { text: 'Body', offset: 0, total: 4 }\n * ```\n */\nexport class BrowserReading implements BrowserReadingInterface {\n\treadonly #url: string\n\treadonly #title: string\n\treadonly #html: HTMLInterface\n\treadonly #epoch: number | undefined\n\treadonly #navigation: BrowserEpochFunction | undefined\n\t// A projection reads only the immutable handle, so each one is computed once per mode.\n\treadonly #markdowns: Map<boolean, string> = new Map()\n\treadonly #texts: Map<boolean, string> = new Map()\n\t#distilled: HTMLInterface | undefined\n\n\tconstructor(input: BrowserReadingInput) {\n\t\tthis.#url = input.url\n\t\tthis.#title = input.title\n\t\tthis.#html = createHTML(input.html)\n\t\tthis.#navigation = input.navigation\n\t\tthis.#epoch = input.epoch ?? input.navigation?.()\n\t}\n\n\tget url(): string {\n\t\treturn this.#url\n\t}\n\n\tget title(): string {\n\t\treturn this.#title\n\t}\n\n\tget html(): HTMLInterface {\n\t\treturn this.#html\n\t}\n\n\tget stale(): boolean {\n\t\treturn this.#navigation !== undefined && this.#navigation() !== this.#epoch\n\t}\n\n\tmarkdown(options?: BrowserReadOptions): BrowserReadResult {\n\t\tconst distill = options?.distill ?? true\n\t\tlet text = this.#markdowns.get(distill)\n\t\tif (text === undefined) {\n\t\t\ttext = renderMarkdown(htmlToMarkdown(this.#source(distill).document))\n\t\t\tthis.#markdowns.set(distill, text)\n\t\t}\n\t\treturn extractBrowserSlice(text, options?.offset, options?.limit)\n\t}\n\n\ttext(options?: BrowserReadOptions): BrowserReadResult {\n\t\tconst distill = options?.distill ?? true\n\t\tlet text = this.#texts.get(distill)\n\t\tif (text === undefined) {\n\t\t\ttext = renderText(this.#source(distill).document)\n\t\t\tthis.#texts.set(distill, text)\n\t\t}\n\t\treturn extractBrowserSlice(text, options?.offset, options?.limit)\n\t}\n\n\t#source(distill: boolean): HTMLInterface {\n\t\tif (!distill) return this.#html\n\t\tthis.#distilled ??= this.#html.distill({ base: this.#url })\n\t\treturn this.#distilled\n\t}\n}\n","import type {\n\tBrowserCallOptions,\n\tBrowserElementInput,\n\tBrowserElementGeometry,\n\tBrowserPageElementInterface,\n\tBrowserPoint,\n\tBrowserQuad,\n\tBrowserReadingInterface,\n\tBrowserScreenshotOptions,\n\tBrowserScreenshotResult,\n} from '../types.js'\nimport { BrowserReading } from '../BrowserReading.js'\nimport { BrowserElementError, isBrowserElementError } from '../errors.js'\nimport { BROWSER_ELEMENT_REFUSALS, BROWSER_RESULT_LIMIT } from '../constants.js'\nimport {\n\tcompileActionabilityFunction,\n\tcompileGuardedEvaluateExpression,\n\tcompileHitFunction,\n\tcompileReadFunction,\n\tcompileSelectFunction,\n} from '../compilers.js'\nimport {\n\tcomputeBrowserButtons,\n\tcomputeBrowserModifiers,\n\textractBrowserChord,\n\tkeyToBrowserInput,\n\tnormalizeBrowserKey,\n\tnormalizeBrowserName,\n\treadBrowserQuad,\n\treadEvaluationResult,\n\trequireBrowserString,\n} from '../helpers.js'\nimport { isArray, isError, isInteger, isNumber, isRecord, isString } from '@orkestrel/contract'\n\n/**\n * Drives a referenced DOM element through its document's isolated world and the page input stream.\n * @example\n * ```ts\n * const element = page.elements.element('e1')\n * await element?.click()\n * ```\n */\nexport class BrowserPageElement implements BrowserPageElementInterface {\n\treadonly #input: BrowserElementInput\n\n\tconstructor(input: BrowserElementInput) {\n\t\tthis.#input = input\n\t}\n\n\tget reference(): string {\n\t\treturn this.#input.node.reference\n\t}\n\n\tget frame(): string {\n\t\treturn this.#input.frame\n\t}\n\n\tget role(): string {\n\t\treturn this.#input.description().role ?? 'unknown'\n\t}\n\n\tget name(): string {\n\t\treturn normalizeBrowserName(this.#input.description().name ?? '')\n\t}\n\n\tasync click(options?: BrowserCallOptions): Promise<void> {\n\t\tconst point = await this.#pointer(options)\n\t\tawait this.#pair(point, point, options)\n\t}\n\n\tasync fill(value: string, options?: BrowserCallOptions): Promise<void> {\n\t\tawait this.focus(options)\n\t\tawait this.#call(\n\t\t\tcompileActionabilityFunction({ visible: true, enabled: true, editable: true }),\n\t\t\toptions,\n\t\t)\n\t\tawait this.#call(compileSelectFunction(), options)\n\t\tthis.#assert(options)\n\t\tawait this.#input.page.send('Input.insertText', { text: value }, options)\n\t}\n\n\tasync select(values: readonly string[], options?: BrowserCallOptions): Promise<void> {\n\t\tawait this.#call(compileActionabilityFunction({ visible: true, enabled: true }), options)\n\t\tawait this.#call(compileSelectFunction(values), options)\n\t}\n\n\tasync focus(options?: BrowserCallOptions): Promise<void> {\n\t\tthis.#assert(options)\n\t\tconst resolved = await this.#resolve(options)\n\t\ttry {\n\t\t\tawait this.#input.client.send(\n\t\t\t\t'DOM.focus',\n\t\t\t\t{ backendNodeId: this.#input.backend },\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthis.#failure(options, error)\n\t\t} finally {\n\t\t\tawait this.#release(resolved.object)\n\t\t}\n\t}\n\n\tasync read(options?: BrowserCallOptions): Promise<BrowserReadingInterface> {\n\t\tconst epoch = this.#epoch()\n\t\tconst capture = await this.#call(\n\t\t\t`function() {\n\t\tconst capture = (${compileReadFunction()})()\n\t\tcapture.html = this.outerHTML\n\t\treturn ${compileGuardedEvaluateExpression('capture', BROWSER_RESULT_LIMIT)}\n\t}`,\n\t\t\toptions,\n\t\t)\n\t\tif (!isRecord(capture))\n\t\t\tthrow new BrowserElementError(this.reference, 'UNKNOWN', 'returned an invalid reading')\n\t\treturn new BrowserReading({\n\t\t\turl: requireBrowserString(capture['url'], 'Element URL'),\n\t\t\ttitle: requireBrowserString(capture['title'], 'Element title'),\n\t\t\thtml: requireBrowserString(capture['html'], 'Element HTML'),\n\t\t\tepoch,\n\t\t\tnavigation: this.#epoch.bind(this),\n\t\t})\n\t}\n\n\tasync hover(options?: BrowserCallOptions): Promise<void> {\n\t\tconst point = await this.#pointer(options)\n\t\tawait this.#input.page.send(\n\t\t\t'Input.dispatchMouseEvent',\n\t\t\t{ type: 'mouseMoved', ...point, buttons: 0 },\n\t\t\toptions,\n\t\t)\n\t}\n\n\tasync press(value: string, options?: BrowserCallOptions): Promise<void> {\n\t\tconst chord = extractBrowserChord(normalizeBrowserKey(value))\n\t\tconst key = keyToBrowserInput(chord.key)\n\t\tconst modifiers = computeBrowserModifiers(chord.modifiers)\n\t\tawait this.focus(options)\n\t\tthis.#assert(options)\n\t\tconst params = {\n\t\t\tkey: key.key,\n\t\t\tcode: key.code,\n\t\t\twindowsVirtualKeyCode: key.number,\n\t\t\tnativeVirtualKeyCode: key.number,\n\t\t\tmodifiers,\n\t\t}\n\t\ttry {\n\t\t\tawait this.#input.page.send(\n\t\t\t\t'Input.dispatchKeyEvent',\n\t\t\t\t{\n\t\t\t\t\ttype: 'keyDown',\n\t\t\t\t\t...params,\n\t\t\t\t\ttext: modifiers === 0 || modifiers === 8 ? key.text : undefined,\n\t\t\t\t},\n\t\t\t\toptions,\n\t\t\t)\n\t\t} finally {\n\t\t\tawait this.#input.page.send(\n\t\t\t\t'Input.dispatchKeyEvent',\n\t\t\t\t{ type: 'keyUp', ...params },\n\t\t\t\toptions?.timeout === undefined ? undefined : { timeout: options.timeout },\n\t\t\t)\n\t\t}\n\t\toptions?.signal?.throwIfAborted()\n\t}\n\n\tasync submit(options?: BrowserCallOptions): Promise<void> {\n\t\t// A trusted Enter on the focused control runs the form's implicit submission.\n\t\tawait this.press('Enter', options)\n\t}\n\n\tasync upload(files: readonly string[], options?: BrowserCallOptions): Promise<void> {\n\t\tconst resolved = await this.#resolve(options)\n\t\ttry {\n\t\t\tawait this.#input.client.send(\n\t\t\t\t'DOM.setFileInputFiles',\n\t\t\t\t{ backendNodeId: this.#input.backend, files },\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t} finally {\n\t\t\tawait this.#release(resolved.object)\n\t\t}\n\t}\n\n\tasync drag(target: BrowserPageElementInterface, options?: BrowserCallOptions): Promise<void> {\n\t\tconst start = await this.#pointer(options)\n\t\tconst end = (await target.quad(options)).center\n\t\tawait this.#pair(start, end, options)\n\t}\n\n\tasync quad(options?: BrowserCallOptions): Promise<BrowserQuad> {\n\t\treturn (await this.#geometry(options)).page\n\t}\n\n\tasync #geometry(options?: BrowserCallOptions): Promise<BrowserElementGeometry> {\n\t\tthis.#assert(options)\n\t\tconst result = await this.#input.client\n\t\t\t.send(\n\t\t\t\t'DOM.getContentQuads',\n\t\t\t\t{ backendNodeId: this.#input.backend },\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t\t.catch(this.#failure.bind(this, options))\n\t\tif (!isRecord(result) || !isArray(result['quads']) || result['quads'].length === 0)\n\t\t\tthrow new BrowserElementError(this.reference, 'HIDDEN')\n\t\tconst quad = readBrowserQuad(result)\n\t\t// The frame owners' box models are read here, so a collected owner reaches the classifier too.\n\t\tconst center = await this.#input\n\t\t\t.point(this.#input.frame, quad.center, options)\n\t\t\t.catch(this.#failure.bind(this, options))\n\t\tconst x = center.x - quad.center.x\n\t\tconst y = center.y - quad.center.y\n\t\treturn {\n\t\t\tlocal: quad,\n\t\t\tpage: {\n\t\t\t\tpoints: [\n\t\t\t\t\tquad.points[0] + x,\n\t\t\t\t\tquad.points[1] + y,\n\t\t\t\t\tquad.points[2] + x,\n\t\t\t\t\tquad.points[3] + y,\n\t\t\t\t\tquad.points[4] + x,\n\t\t\t\t\tquad.points[5] + y,\n\t\t\t\t\tquad.points[6] + x,\n\t\t\t\t\tquad.points[7] + y,\n\t\t\t\t],\n\t\t\t\tcenter,\n\t\t\t},\n\t\t}\n\t}\n\n\tasync screenshot(options?: BrowserScreenshotOptions): Promise<BrowserScreenshotResult> {\n\t\tconst quad = await this.quad()\n\t\tconst scroll = await this.#scroll(this.#input.session)\n\t\tconst xs = quad.points.filter((_value, index) => index % 2 === 0)\n\t\tconst ys = quad.points.filter((_value, index) => index % 2 !== 0)\n\t\tconst x = Math.min(...xs)\n\t\tconst y = Math.min(...ys)\n\t\treturn await this.#input.page.screenshot({\n\t\t\t...options,\n\t\t\tfull: false,\n\t\t\tclip: [x + scroll.x, y + scroll.y, Math.max(...xs) - x, Math.max(...ys) - y],\n\t\t})\n\t}\n\n\t#assert(options?: BrowserCallOptions): void {\n\t\toptions?.signal?.throwIfAborted()\n\t\tif (!this.#input.current())\n\t\t\tthrow new BrowserElementError(this.reference, 'GONE', 'is gone because the page changed')\n\t\tthis.#input.page.assert()\n\t}\n\n\t#epoch(): number {\n\t\treturn this.#input.navigation(this.#input.frame)\n\t}\n\n\tasync #resolve(\n\t\toptions?: BrowserCallOptions,\n\t\tbackend = this.#input.backend,\n\t): Promise<{ readonly object: string; readonly context: number }> {\n\t\tthis.#assert(options)\n\t\tconst context = await this.#input.world(this.#input.frame, this.#input.node.session, options)\n\t\ttry {\n\t\t\tconst result = await this.#input.client.send(\n\t\t\t\t'DOM.resolveNode',\n\t\t\t\t{ backendNodeId: backend, executionContextId: context },\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t\tif (\n\t\t\t\t!isRecord(result) ||\n\t\t\t\t!isRecord(result['object']) ||\n\t\t\t\t!isString(result['object']['objectId'])\n\t\t\t)\n\t\t\t\tthrow new BrowserElementError(this.reference, 'GONE')\n\t\t\tthis.#assert(options)\n\t\t\treturn { object: result['object']['objectId'], context }\n\t\t} catch {\n\t\t\toptions?.signal?.throwIfAborted()\n\t\t\tthrow new BrowserElementError(this.reference, 'GONE')\n\t\t}\n\t}\n\n\tasync #call(\n\t\tdeclaration: string,\n\t\toptions?: BrowserCallOptions,\n\t\ttarget?: number,\n\t): Promise<unknown> {\n\t\tconst resolved = await this.#resolve(options)\n\t\tlet hit: { readonly object: string; readonly context: number } | undefined\n\t\ttry {\n\t\t\tif (target !== undefined) hit = await this.#resolve(options, target)\n\t\t\tconst result = await this.#input.client.send(\n\t\t\t\t'Runtime.callFunctionOn',\n\t\t\t\t{\n\t\t\t\t\tfunctionDeclaration: `function(element, target) { return (${declaration}).call(element, target) }`,\n\t\t\t\t\texecutionContextId: resolved.context,\n\t\t\t\t\targuments: [\n\t\t\t\t\t\t{ objectId: resolved.object },\n\t\t\t\t\t\t...(hit === undefined ? [] : [{ objectId: hit.object }]),\n\t\t\t\t\t],\n\t\t\t\t\treturnByValue: true,\n\t\t\t\t\tawaitPromise: true,\n\t\t\t\t},\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t\tthis.#assert(options)\n\t\t\treturn readEvaluationResult(result)\n\t\t} catch (error) {\n\t\t\tthis.#failure(options, error)\n\t\t} finally {\n\t\t\tawait this.#release(resolved.object)\n\t\t\tif (hit !== undefined) await this.#release(hit.object)\n\t\t}\n\t}\n\n\t#failure(options: BrowserCallOptions | undefined, error: unknown): never {\n\t\toptions?.signal?.throwIfAborted()\n\t\tif (isBrowserElementError(error)) throw error\n\t\t// An in-page refusal carries the page's stack after its first line; only that line reaches\n\t\t// the refusal.\n\t\tconst message = (isError(error) ? error.message : String(error)).split('\\n', 1)[0] ?? ''\n\t\tconst known = BROWSER_ELEMENT_REFUSALS.get(message.replace(/^Error: /, ''))\n\t\tif (known !== undefined)\n\t\t\tthrow new BrowserElementError(this.reference, known.reason, known.detail)\n\t\tconst reason = /layout object|not visible/i.test(message)\n\t\t\t? 'HIDDEN'\n\t\t\t: /disabled/i.test(message)\n\t\t\t\t? 'DISABLED'\n\t\t\t\t: /detached|Could not find node|No node with given id|No node found for given backend id|not found|context/i.test(\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t )\n\t\t\t\t\t? 'GONE'\n\t\t\t\t\t: undefined\n\t\tif (reason === undefined) throw error\n\t\tthrow new BrowserElementError(this.reference, reason, reason === 'GONE' ? undefined : message)\n\t}\n\n\tasync #scroll(session: string, options?: BrowserCallOptions): Promise<BrowserPoint> {\n\t\tconst result = await this.#input.client.send(\n\t\t\t'Page.getLayoutMetrics',\n\t\t\t{},\n\t\t\t{ session, ...options },\n\t\t)\n\t\tconst viewport = isRecord(result)\n\t\t\t? (result['cssLayoutViewport'] ?? result['cssVisualViewport'])\n\t\t\t: undefined\n\t\treturn {\n\t\t\tx: isRecord(viewport) && isNumber(viewport['pageX']) ? viewport['pageX'] : 0,\n\t\t\ty: isRecord(viewport) && isNumber(viewport['pageY']) ? viewport['pageY'] : 0,\n\t\t}\n\t}\n\n\tasync #release(object: string): Promise<void> {\n\t\tawait this.#input.client\n\t\t\t.send(\n\t\t\t\t'Runtime.releaseObject',\n\t\t\t\t{ objectId: object },\n\t\t\t\t{ session: this.#input.node.session, timeout: 1000 },\n\t\t\t)\n\t\t\t.catch(() => undefined)\n\t}\n\n\tasync #pointer(options?: BrowserCallOptions): Promise<BrowserPoint> {\n\t\tthis.#assert(options)\n\t\tawait this.#input.client\n\t\t\t.send(\n\t\t\t\t'DOM.scrollIntoViewIfNeeded',\n\t\t\t\t{ backendNodeId: this.#input.backend },\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t\t.catch(this.#failure.bind(this, options))\n\t\tawait this.#call(\n\t\t\tcompileActionabilityFunction({ visible: true, enabled: true, stable: true }),\n\t\t\toptions,\n\t\t)\n\t\tconst geometry = await this.#geometry(options)\n\t\tconst point = geometry.page.center\n\t\tconst local = geometry.local.center\n\t\tconst scroll = await this.#scroll(this.#input.node.session, options)\n\t\tconst hit = await this.#input.client.send(\n\t\t\t'DOM.getNodeForLocation',\n\t\t\t{ x: Math.round(local.x + scroll.x), y: Math.round(local.y + scroll.y) },\n\t\t\t{ session: this.#input.node.session, ...options },\n\t\t)\n\t\tif (\n\t\t\t!isRecord(hit) ||\n\t\t\t!isInteger(hit['backendNodeId']) ||\n\t\t\t(hit['frameId'] !== undefined && hit['frameId'] !== this.#input.frame)\n\t\t)\n\t\t\tthrow new BrowserElementError(this.reference, 'OCCLUDED')\n\t\tif (\n\t\t\thit['backendNodeId'] !== this.#input.backend &&\n\t\t\t(await this.#call(compileHitFunction(), options, hit['backendNodeId'])) !== true\n\t\t) {\n\t\t\tconst described = await this.#input.client.send(\n\t\t\t\t'DOM.describeNode',\n\t\t\t\t{ backendNodeId: hit['backendNodeId'] },\n\t\t\t\t{ session: this.#input.node.session, ...options },\n\t\t\t)\n\t\t\tconst node =\n\t\t\t\tisRecord(described) && isRecord(described['node']) ? described['node'] : undefined\n\t\t\tlet name = isString(node?.['nodeName']) ? node['nodeName'].toLowerCase() : 'element'\n\t\t\tconst attributes = node?.['attributes']\n\t\t\tif (isArray(attributes)) {\n\t\t\t\tconst id = attributes[attributes.indexOf('id') + 1]\n\t\t\t\tconst classes = attributes[attributes.indexOf('class') + 1]\n\t\t\t\tif (attributes.includes('id') && isString(id) && id !== '') name += `#${id}`\n\t\t\t\telse if (attributes.includes('class') && isString(classes) && classes.trim() !== '')\n\t\t\t\t\tname += `.${classes.trim().split(/\\s+/).join('.')}`\n\t\t\t}\n\t\t\tthrow new BrowserElementError(this.reference, 'OCCLUDED', `is covered by ${name}`)\n\t\t}\n\t\treturn point\n\t}\n\n\tasync #pair(start: BrowserPoint, end: BrowserPoint, options?: BrowserCallOptions): Promise<void> {\n\t\tthis.#assert(options)\n\t\ttry {\n\t\t\tawait this.#input.page.send(\n\t\t\t\t'Input.dispatchMouseEvent',\n\t\t\t\t{\n\t\t\t\t\ttype: 'mousePressed',\n\t\t\t\t\t...start,\n\t\t\t\t\tbutton: 'left',\n\t\t\t\t\tbuttons: computeBrowserButtons(['left']),\n\t\t\t\t\tclickCount: 1,\n\t\t\t\t},\n\t\t\t\toptions,\n\t\t\t)\n\t\t\tif (start.x !== end.x || start.y !== end.y)\n\t\t\t\tawait this.#input.page.send(\n\t\t\t\t\t'Input.dispatchMouseEvent',\n\t\t\t\t\t{ type: 'mouseMoved', ...end, button: 'left', buttons: computeBrowserButtons(['left']) },\n\t\t\t\t\toptions,\n\t\t\t\t)\n\t\t} finally {\n\t\t\tawait this.#input.page.send(\n\t\t\t\t'Input.dispatchMouseEvent',\n\t\t\t\t{ type: 'mouseReleased', ...end, button: 'left', buttons: 0, clickCount: 1 },\n\t\t\t\toptions?.timeout === undefined ? undefined : { timeout: options.timeout },\n\t\t\t)\n\t\t}\n\t\toptions?.signal?.throwIfAborted()\n\t}\n}\n","import type {\n\tBrowserAXNode,\n\tBrowserCallOptions,\n\tBrowserElementManagerInput,\n\tBrowserElementManagerInterface,\n\tBrowserElementQuery,\n\tBrowserElementWaitOptions,\n\tBrowserOutline,\n\tBrowserOutlineNode,\n\tBrowserOutlineOptions,\n\tBrowserPageElementInterface,\n\tBrowserPoint,\n} from '../types.js'\nimport { BrowserPageElement } from './BrowserPageElement.js'\nimport { BrowserElementError, BrowserError } from '../errors.js'\nimport {\n\tBROWSER_DEFAULT_TIMEOUT_MS,\n\tBROWSER_OUTLINE_LIMIT,\n\tBROWSER_INTERACTIVE_ROLES,\n} from '../constants.js'\nimport { compileQueryWaitExpression } from '../compilers.js'\nimport {\n\tcomposeBrowserPoint,\n\tfilterBrowserOutline,\n\treadBrowserAccessibility,\n\treadBrowserQuad,\n\treadEvaluationResult,\n\trenderBrowserOutline,\n\trequireBrowserString,\n\tvalidateBrowserTimeout,\n} from '../helpers.js'\nimport { parseBrowserReference } from '../parsers.js'\nimport { isArray, isInteger, isRecord, isString } from '@orkestrel/contract'\n\n/**\n * Captures accessibility trees and binds stable references to their owning frame sessions.\n *\n * @remarks\n * A reference is dropped when the page reports its frame's document replaced or detached through\n * `input.steps`, which carries only the steps of each frame's owning session.\n * @example\n * ```ts\n * const outline = await page.elements.outline()\n * const matches = await page.elements.find({ role: 'button', name: 'save' })\n * await matches[0]?.click()\n * ```\n */\nexport class BrowserElementManager implements BrowserElementManagerInterface<BrowserPageElementInterface> {\n\treadonly #input: BrowserElementManagerInput\n\treadonly #records = new Map<\n\t\tstring,\n\t\t{ readonly node: BrowserOutlineNode; readonly element: BrowserPageElement }\n\t>()\n\treadonly #owners = new Map<\n\t\tstring,\n\t\t{ readonly frame: string; readonly session: string; readonly backend: number }\n\t>()\n\treadonly #lifetime = new AbortController()\n\t#sequence = 0\n\treadonly #generations = new Map<string, number>()\n\t// Counts every generation step across all frames, so a capture can tell whether any frame it\n\t// reads navigated while it ran.\n\t#changes = 0\n\treadonly #queries = new Map<string, Promise<readonly BrowserOutlineNode[]>>()\n\treadonly #navigationHandler = this.#navigate.bind(this)\n\treadonly #commitHandler = this.#commit.bind(this)\n\treadonly #detachHandler = this.#detach.bind(this)\n\treadonly #closeHandler = this.#close.bind(this)\n\n\tconstructor(input: BrowserElementManagerInput) {\n\t\tthis.#input = input\n\t\tinput.page.emitter.on('navigate', this.#navigationHandler)\n\t\tinput.steps.on('commit', this.#commitHandler)\n\t\tinput.steps.on('detach', this.#detachHandler)\n\t\tinput.page.emitter.on('close', this.#closeHandler)\n\t}\n\n\tasync outline(options?: BrowserOutlineOptions): Promise<BrowserOutline> {\n\t\tconst limit = options?.limit ?? BROWSER_OUTLINE_LIMIT\n\t\tif (!isInteger(limit) || limit < 0)\n\t\t\tthrow new BrowserError('Outline limit must be a nonnegative integer')\n\t\tawait this.#input.ready(options)\n\t\tconst epoch = this.#generation(this.#input.page.id)\n\t\tconst changes = this.#changes\n\t\ttry {\n\t\t\tconst rows = await this.#capture(options)\n\t\t\tconst context = await this.#input.world(this.#input.page.id, this.#input.session, options)\n\t\t\tconst result = await this.#input.client.send(\n\t\t\t\t'Runtime.evaluate',\n\t\t\t\t{ expression: 'document.title', contextId: context, returnByValue: true },\n\t\t\t\t{ session: this.#input.session, ...options },\n\t\t\t)\n\t\t\tthis.#assertCapture(this.#input.page.id, epoch)\n\t\t\treturn renderBrowserOutline(\n\t\t\t\tthis.#input.page.url,\n\t\t\t\trequireBrowserString(readEvaluationResult(result), 'Document title'),\n\t\t\t\tthis.#within(rows, options?.within),\n\t\t\t\tlimit,\n\t\t\t)\n\t\t} catch (error) {\n\t\t\t// A navigation destroys the contexts, nodes, and sessions the capture was reading, so a\n\t\t\t// rejection that follows one reports the change rather than the protocol failure.\n\t\t\tif (options?.signal?.aborted === true || this.#changes === changes) throw error\n\t\t\tthis.#lifetime.signal.throwIfAborted()\n\t\t\tthrow new BrowserElementError({ subject: 'outline' }, 'GONE')\n\t\t}\n\t}\n\n\t/** A CSS query searches the page's main-frame document; use the accessibility outline for in-process child documents. */\n\tasync find(\n\t\tquery: BrowserElementQuery,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<readonly BrowserPageElementInterface[]> {\n\t\tawait this.#input.ready(options)\n\t\tconst epoch = this.#generation(this.#input.page.id)\n\t\tconst rows = this.#within(await this.#capture(options), query.within)\n\t\tlet matches = filterBrowserOutline(rows, query)\n\t\tif (query.css !== undefined) {\n\t\t\tconst session = this.#input.session\n\t\t\tconst previous = this.#queries.get(session) ?? Promise.resolve([])\n\t\t\tconst pending = previous.catch(() => []).then(this.#css.bind(this, query, epoch, options))\n\t\t\tthis.#queries.set(session, pending)\n\t\t\ttry {\n\t\t\t\tconst selected = await pending\n\t\t\t\tconst keys = new Set(selected.map((node) => `${node.session}:${node.backend}`))\n\t\t\t\tif (query.role === undefined && query.name === undefined) matches = selected\n\t\t\t\telse matches = matches.filter((node) => keys.has(`${node.session}:${node.backend}`))\n\t\t\t} finally {\n\t\t\t\tif (this.#queries.get(session) === pending) this.#queries.delete(session)\n\t\t\t}\n\t\t}\n\t\tthis.#assertCapture(this.#input.page.id, epoch)\n\t\treturn matches.flatMap((node) => {\n\t\t\tconst entry = this.#records.get(`${node.session}:${node.backend}`)\n\t\t\treturn entry === undefined ? [] : [entry.element]\n\t\t})\n\t}\n\n\tasync #css(\n\t\tquery: BrowserElementQuery,\n\t\tepoch: number,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<readonly BrowserOutlineNode[]> {\n\t\tconst frame = this.#input.page.id\n\t\tconst session = this.#input.session\n\t\tthis.#assertCapture(frame, epoch)\n\t\tconst scope = query.within === undefined ? undefined : this.#record(query.within)\n\t\tif (scope !== undefined && scope.node.frame !== frame) return []\n\t\tlet document = await this.#input.client.send('DOM.getDocument', {}, { session, ...options })\n\t\tif (scope !== undefined)\n\t\t\tdocument = await this.#input.client.send(\n\t\t\t\t'DOM.pushNodesByBackendIdsToFrontend',\n\t\t\t\t{ backendNodeIds: [scope.node.backend] },\n\t\t\t\t{ session, ...options },\n\t\t\t)\n\t\tconst root =\n\t\t\tisRecord(document) && isRecord(document['root'])\n\t\t\t\t? document['root']['nodeId']\n\t\t\t\t: isRecord(document) && isArray(document['nodeIds'])\n\t\t\t\t\t? document['nodeIds'][0]\n\t\t\t\t\t: undefined\n\t\tif (!isInteger(root)) throw new BrowserElementError({ subject: 'document' }, 'GONE')\n\t\tconst result = await this.#input.client.send(\n\t\t\t'DOM.querySelectorAll',\n\t\t\t{ nodeId: root, selector: query.css },\n\t\t\t{ session, ...options },\n\t\t)\n\t\tif (!isRecord(result) || !isArray(result['nodeIds']))\n\t\t\tthrow new BrowserError('CSS query result is malformed')\n\t\tconst rows: BrowserOutlineNode[] = []\n\t\tfor (const nodeId of result['nodeIds']) {\n\t\t\tif (!isInteger(nodeId)) continue\n\t\t\tconst described = await this.#input.client.send(\n\t\t\t\t'DOM.describeNode',\n\t\t\t\t{ nodeId },\n\t\t\t\t{ session, ...options },\n\t\t\t)\n\t\t\tif (\n\t\t\t\t!isRecord(described) ||\n\t\t\t\t!isRecord(described['node']) ||\n\t\t\t\t!isInteger(described['node']['backendNodeId'])\n\t\t\t)\n\t\t\t\tcontinue\n\t\t\tconst backend = described['node']['backendNodeId']\n\t\t\tthis.#assertCapture(frame, epoch)\n\t\t\tconst existing = this.#records.get(`${session}:${backend}`)\n\t\t\tif (existing !== undefined) rows.push(existing.node)\n\t\t\telse\n\t\t\t\trows.push(\n\t\t\t\t\tthis.#bind(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: `${session}:${backend}`,\n\t\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t\t\tbackend,\n\t\t\t\t\t\t\tframe,\n\t\t\t\t\t\t\tignored: false,\n\t\t\t\t\t\t\trole: 'generic',\n\t\t\t\t\t\t\tname: '',\n\t\t\t\t\t\t\tdescription: undefined,\n\t\t\t\t\t\t\tvalue: undefined,\n\t\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tframe,\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t}\n\t\treturn rows\n\t}\n\n\tasync wait(\n\t\tquery: BrowserElementQuery,\n\t\toptions?: BrowserElementWaitOptions,\n\t): Promise<readonly BrowserPageElementInterface[]> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst end = performance.now() + timeout\n\t\tconst signal =\n\t\t\toptions?.signal === undefined\n\t\t\t\t? this.#lifetime.signal\n\t\t\t\t: AbortSignal.any([options.signal, this.#lifetime.signal])\n\t\twhile (true) {\n\t\t\tsignal.throwIfAborted()\n\t\t\tconst remaining = Math.max(0, end - performance.now())\n\t\t\tconst call = { timeout: remaining, signal }\n\t\t\tawait this.#input.ready(call)\n\t\t\tconst frame = this.#scopeFrame(query.within)\n\t\t\tconst session = await this.#input.resolve(frame)\n\t\t\tconst context = await this.#input.world(frame, session, call)\n\t\t\tconst key = `__browserQueryWait${++this.#sequence}`\n\t\t\t// Arm before capturing so mutations during find are retained by the pending promise.\n\t\t\tconst pending = this.#input.client\n\t\t\t\t.send(\n\t\t\t\t\t'Runtime.evaluate',\n\t\t\t\t\t{\n\t\t\t\t\t\texpression: compileQueryWaitExpression(remaining, key),\n\t\t\t\t\t\tcontextId: context,\n\t\t\t\t\t\treturnByValue: true,\n\t\t\t\t\t\tawaitPromise: true,\n\t\t\t\t\t},\n\t\t\t\t\t{ session, timeout: remaining + 1000, signal },\n\t\t\t\t)\n\t\t\t\t.then(\n\t\t\t\t\t(result) => ({ result }),\n\t\t\t\t\t(error: unknown) => ({ error }),\n\t\t\t\t)\n\t\t\ttry {\n\t\t\t\tconst found = await this.find(query, call)\n\t\t\t\tif (options?.absent === true ? found.length === 0 : found.length > 0) return found\n\t\t\t\tconst outcome = await pending\n\t\t\t\tif ('error' in outcome) throw outcome.error\n\t\t\t\tif (readEvaluationResult(outcome.result) !== true || performance.now() >= end)\n\t\t\t\t\tthrow new BrowserError('Element wait timed out', 'BROWSER_WAIT_TIMEOUT')\n\t\t\t} finally {\n\t\t\t\tawait this.#input.client\n\t\t\t\t\t.send(\n\t\t\t\t\t\t'Runtime.evaluate',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\texpression: `globalThis[${JSON.stringify(key)}]?.()`,\n\t\t\t\t\t\t\tcontextId: context,\n\t\t\t\t\t\t\treturnByValue: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ session, timeout: 1000 },\n\t\t\t\t\t)\n\t\t\t\t\t.catch(() => undefined)\n\t\t\t}\n\t\t}\n\t}\n\n\telement(reference: string): BrowserPageElementInterface | undefined {\n\t\tconst canonical = parseBrowserReference(reference)\n\t\treturn [...this.#records.values()].find((entry) => entry.node.reference === canonical)?.element\n\t}\n\n\telements(): readonly BrowserPageElementInterface[] {\n\t\treturn [...this.#records.values()].map((entry) => entry.element)\n\t}\n\n\tclear(): void {\n\t\tthis.#changes += 1\n\t\tfor (const [frame, epoch] of this.#generations) this.#generations.set(frame, epoch + 1)\n\t\tthis.#records.clear()\n\t\tthis.#owners.clear()\n\t}\n\n\tasync #capture(options?: BrowserCallOptions): Promise<readonly BrowserOutlineNode[]> {\n\t\tthis.#input.page.assert()\n\t\tconst rows = await this.#tree(this.#input.page.id, this.#input.session, new Set(), options)\n\t\treturn rows\n\t}\n\n\tasync #tree(\n\t\tframe: string,\n\t\tsession: string,\n\t\tvisited: Set<string>,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<readonly BrowserOutlineNode[]> {\n\t\tif (visited.has(frame)) return []\n\t\tvisited.add(frame)\n\t\tconst epoch = this.#generation(frame)\n\t\tawait this.#input.client.send('Accessibility.enable', undefined, { session, ...options })\n\t\tthis.#assertCapture(frame, epoch)\n\t\tconst snapshot = readBrowserAccessibility(\n\t\t\tawait this.#input.client.send(\n\t\t\t\t'Accessibility.getFullAXTree',\n\t\t\t\t{ frameId: frame },\n\t\t\t\t{ session, ...options },\n\t\t\t),\n\t\t)\n\t\tthis.#assertCapture(frame, epoch)\n\t\tconst nodes = new Map(snapshot.nodes.map((node) => [node.id, node]))\n\t\tconst stack = [...snapshot.roots].reverse()\n\t\tconst seen = new Set<string>()\n\t\tconst rows: BrowserOutlineNode[] = []\n\t\twhile (stack.length > 0) {\n\t\t\tthis.#assertCapture(frame, epoch)\n\t\t\toptions?.signal?.throwIfAborted()\n\t\t\tconst id = stack.pop()\n\t\t\tconst node = id === undefined ? undefined : nodes.get(id)\n\t\t\tif (node === undefined || seen.has(node.id)) continue\n\t\t\tseen.add(node.id)\n\t\t\trows.push(this.#bind(node, frame, session))\n\t\t\tif (node.role === 'Iframe' && node.backend !== undefined) {\n\t\t\t\tconst described = await this.#input.client.send(\n\t\t\t\t\t'DOM.describeNode',\n\t\t\t\t\t{ backendNodeId: node.backend },\n\t\t\t\t\t{ session, ...options },\n\t\t\t\t)\n\t\t\t\tconst child =\n\t\t\t\t\tisRecord(described) && isRecord(described['node'])\n\t\t\t\t\t\t? described['node']['frameId']\n\t\t\t\t\t\t: undefined\n\t\t\t\tthis.#assertCapture(frame, epoch)\n\t\t\t\tif (isString(child)) {\n\t\t\t\t\tthis.#owners.set(child, { frame, session, backend: node.backend })\n\t\t\t\t\tconst childSession = await this.#input.resolve(child)\n\t\t\t\t\trows.push(...(await this.#tree(child, childSession, visited, options)))\n\t\t\t\t}\n\t\t\t}\n\t\t\tstack.push(...[...node.children].reverse())\n\t\t}\n\t\tthis.#assertCapture(frame, epoch)\n\t\treturn rows\n\t}\n\n\t#generation(frame: string): number {\n\t\tconst epoch = this.#generations.get(frame) ?? 0\n\t\tthis.#generations.set(frame, epoch)\n\t\treturn epoch\n\t}\n\n\t#assertCapture(frame: string, epoch: number): void {\n\t\tthis.#lifetime.signal.throwIfAborted()\n\t\tif (this.#generation(frame) !== epoch)\n\t\t\tthrow new BrowserElementError({ subject: 'outline' }, 'GONE')\n\t}\n\n\t#bind(node: BrowserAXNode, frame: string, session: string, css = false): BrowserOutlineNode {\n\t\tconst backend = node.backend\n\t\tconst tool =\n\t\t\tbackend === undefined\n\t\t\t\t? undefined\n\t\t\t\t: this.#input.page.registry\n\t\t\t\t\t\t.tools()\n\t\t\t\t\t\t.find((candidate) => candidate.frame === frame && candidate.node === backend)?.name\n\t\tif (\n\t\t\tbackend === undefined ||\n\t\t\t(!css &&\n\t\t\t\t(node.ignored || (tool === undefined && !BROWSER_INTERACTIVE_ROLES.has(node.role ?? ''))))\n\t\t)\n\t\t\treturn { ...node, frame, session, reference: undefined }\n\t\tconst key = `${session}:${backend}`\n\t\tconst existing = this.#records.get(key)\n\t\tif (existing !== undefined) {\n\t\t\tconst row = {\n\t\t\t\t...node,\n\t\t\t\tframe,\n\t\t\t\tsession,\n\t\t\t\treference: existing.node.reference,\n\t\t\t\t...(tool === undefined ? {} : { tool }),\n\t\t\t}\n\t\t\tthis.#records.set(key, { node: row, element: existing.element })\n\t\t\treturn row\n\t\t}\n\t\tconst reference = this.#input.reference()\n\t\tconst row = { ...node, frame, session, reference, ...(tool === undefined ? {} : { tool }) }\n\t\tconst element = new BrowserPageElement({\n\t\t\t...this.#input,\n\t\t\tdescription: this.#description.bind(this, key, row),\n\t\t\tnode: row,\n\t\t\tbackend,\n\t\t\tframe,\n\t\t\tcurrent: this.#current.bind(this, key, reference),\n\t\t\tpoint: this.#point.bind(this),\n\t\t})\n\t\tthis.#records.set(key, { node: row, element })\n\t\treturn row\n\t}\n\n\t#current(key: string, reference: string): boolean {\n\t\treturn this.#records.get(key)?.node.reference === reference\n\t}\n\n\t#description(key: string, fallback: BrowserOutlineNode): BrowserOutlineNode {\n\t\tconst current = this.#records.get(key)?.node\n\t\treturn current !== undefined && current.reference === fallback.reference ? current : fallback\n\t}\n\n\t#scopeFrame(reference?: string): string {\n\t\tif (reference === undefined) return this.#input.page.id\n\t\tconst scope = this.#record(reference).node\n\t\tfor (const [frame, owner] of this.#owners) {\n\t\t\tif (owner.session === scope.session && owner.backend === scope.backend) return frame\n\t\t}\n\t\treturn scope.frame ?? this.#input.page.id\n\t}\n\n\t#record(reference: string): {\n\t\treadonly node: BrowserOutlineNode\n\t\treadonly element: BrowserPageElement\n\t} {\n\t\tconst canonical = parseBrowserReference(reference)\n\t\tconst entry = [...this.#records.values()].find((record) => record.node.reference === canonical)\n\t\tif (entry === undefined) throw new BrowserElementError(reference, 'GONE')\n\t\treturn entry\n\t}\n\n\t#within(rows: readonly BrowserOutlineNode[], reference?: string): readonly BrowserOutlineNode[] {\n\t\tif (reference === undefined) return rows\n\t\tconst scope = this.#record(reference).node\n\t\tconst key = `${scope.session}:${scope.backend}`\n\t\tconst included = new Set<string>()\n\t\tconst frames = new Set<string>()\n\t\treturn rows.filter((node) => {\n\t\t\tif (\n\t\t\t\t`${node.session}:${node.backend}` !== key &&\n\t\t\t\t!included.has(`${node.session}:${node.id}`) &&\n\t\t\t\t!included.has(`${node.session}:${node.parent}`) &&\n\t\t\t\t!frames.has(node.frame ?? '')\n\t\t\t)\n\t\t\t\treturn false\n\t\t\tincluded.add(`${node.session}:${node.id}`)\n\t\t\tfor (const [frame, owner] of this.#owners) {\n\t\t\t\tif (owner.session === node.session && owner.backend === node.backend) frames.add(frame)\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t}\n\n\tasync #point(\n\t\tframe: string,\n\t\tpoint: BrowserPoint,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<BrowserPoint> {\n\t\tconst offsets: BrowserPoint[] = []\n\t\tconst visited = new Set<string>()\n\t\tlet current = frame\n\t\twhile (current !== this.#input.page.id && !visited.has(current)) {\n\t\t\tvisited.add(current)\n\t\t\tconst owner = this.#owners.get(current)\n\t\t\tif (owner === undefined) throw new BrowserElementError({ subject: 'frame' }, 'GONE')\n\t\t\tconst session = await this.#input.resolve(current)\n\t\t\tif (session !== owner.session) {\n\t\t\t\tconst result = await this.#input.client.send(\n\t\t\t\t\t'DOM.getBoxModel',\n\t\t\t\t\t{ backendNodeId: owner.backend },\n\t\t\t\t\t{ session: owner.session, ...options },\n\t\t\t\t)\n\t\t\t\tconst content =\n\t\t\t\t\tisRecord(result) && isRecord(result['model']) ? result['model']['content'] : undefined\n\t\t\t\tconst quad = readBrowserQuad({ quads: [content] })\n\t\t\t\toffsets.push({ x: quad.points[0], y: quad.points[1] })\n\t\t\t}\n\t\t\tcurrent = owner.frame\n\t\t}\n\t\treturn composeBrowserPoint(point, offsets)\n\t}\n\n\t#navigate(_url: string, same: boolean): void {\n\t\tif (!same) this.clear()\n\t}\n\n\t#commit(frame: string, _url: string, _loader: string | undefined, same: boolean): void {\n\t\tif (!same) this.#drop(frame)\n\t}\n\n\t// A swap leaves the frame in another renderer, and its references with the document it left.\n\t#detach(frame: string): void {\n\t\tthis.#drop(frame)\n\t}\n\n\t#drop(frame: string): void {\n\t\tif (frame === this.#input.page.id) return\n\t\tthis.#changes += 1\n\t\tthis.#generations.set(frame, this.#generation(frame) + 1)\n\t\tfor (const [key, record] of this.#records)\n\t\t\tif (record.node.frame === frame) this.#records.delete(key)\n\t\tthis.#owners.delete(frame)\n\t}\n\n\t#close(): void {\n\t\tthis.clear()\n\t\tthis.#lifetime.abort(new BrowserError('Browser session ended'))\n\t\tthis.#input.page.emitter.off('navigate', this.#navigationHandler)\n\t\tthis.#input.steps.off('commit', this.#commitHandler)\n\t\tthis.#input.steps.off('detach', this.#detachHandler)\n\t\tthis.#input.page.emitter.off('close', this.#closeHandler)\n\t}\n}\n","import type {\n\tBrowserCallOptions,\n\tBrowserFrameInterface,\n\tBrowserInvocationResult,\n\tBrowserPageInterface,\n\tBrowserRegistryEventMap,\n\tBrowserRegistryInterface,\n\tBrowserRegistryOptions,\n\tBrowserRegistryPending,\n\tBrowserTool,\n\tCDPClientInterface,\n\tCDPHandler,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport type { ToolAnnotations, ToolContext, ToolInterface } from '@orkestrel/tool'\nimport { isArray, isRecord, isString } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { createTool } from '@orkestrel/tool'\nimport { BrowserTransition } from './BrowserTransition.js'\nimport {\n\tBROWSER_DEFAULT_TIMEOUT_MS,\n\tBROWSER_REGISTRY_ABSENT_CODE,\n\tBROWSER_REGISTRY_OUTPUT_LIMIT,\n} from './constants.js'\nimport { BrowserError, isCDPError } from './errors.js'\nimport {\n\trenderBrowserToolOutput,\n\tderiveBrowserToolSchema,\n\tvalidateBrowserTimeout,\n} from './helpers.js'\nimport {\n\tparseBrowserTool,\n\tparseBrowserRemoval,\n\tparseBrowserInvocation,\n\tparseBrowserInvocationResult,\n} from './parsers.js'\n\n/**\n * Mirrors the experimental WebMCP domain across a page's attached sessions.\n * @remarks The page owns the live session-to-frame map; protocol subscriptions use stable session ids.\n * @example\n * ```ts\n * const registry = page.registry\n * if (await registry.start()) {\n * const tools = await registry.adopt()\n * }\n * ```\n */\nexport class BrowserRegistry implements BrowserRegistryInterface {\n\treadonly #page: BrowserPageInterface\n\treadonly #client: CDPClientInterface\n\treadonly #session: string\n\treadonly #frames: ReadonlyMap<string, string>\n\treadonly #emitter: Emitter<BrowserRegistryEventMap>\n\treadonly #tools = new Map<string, BrowserTool>()\n\treadonly #owners = new Map<string, string>()\n\treadonly #subscriptions = new Map<string, ReadonlyMap<string, CDPHandler>>()\n\treadonly #enabled = new Set<string>()\n\treadonly #enabling = new Map<string, Promise<boolean>>()\n\treadonly #pending = new Set<BrowserRegistryPending>()\n\treadonly #awaiting = new Set<BrowserRegistryPending>()\n\treadonly #identifiers = new Map<BrowserRegistryPending, string>()\n\treadonly #responses = new Map<string, Map<string, BrowserInvocationResult>>()\n\treadonly #starting = new BrowserTransition<boolean>()\n\t#destroying: Promise<void> | undefined\n\treadonly #sessionHandler = this.#attach.bind(this)\n\treadonly #navigateHandler = this.#navigate.bind(this)\n\treadonly #detachHandler = this.#invalidate.bind(this)\n\n\tconstructor(\n\t\tpage: BrowserPageInterface,\n\t\tclient: CDPClientInterface,\n\t\tsession: string,\n\t\tframes: ReadonlyMap<string, string> = new Map(),\n\t\toptions?: BrowserRegistryOptions,\n\t) {\n\t\tthis.#page = page\n\t\tthis.#client = client\n\t\tthis.#session = session\n\t\tthis.#frames = frames\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t}\n\n\tget emitter(): EmitterInterface<BrowserRegistryEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tasync start(options?: BrowserCallOptions): Promise<boolean> {\n\t\tthis.#assert()\n\t\toptions?.signal?.throwIfAborted()\n\t\treturn await this.#starting.execute(() => this.#start(options))\n\t}\n\n\ttool(name: string, frame?: string): BrowserTool | undefined {\n\t\tif (frame !== undefined) return this.#tools.get(JSON.stringify([frame, name]))\n\t\tconst main = this.#tools.get(JSON.stringify([this.#page.id, name]))\n\t\treturn main ?? this.tools().find((tool) => tool.name === name)\n\t}\n\n\ttools(): readonly BrowserTool[] {\n\t\treturn [...this.#tools.values()]\n\t}\n\n\tasync adopt(): Promise<readonly ToolInterface[]> {\n\t\tthis.#assert()\n\t\tconst adopted: ToolInterface[] = []\n\t\tfor (const tool of this.tools()) {\n\t\t\tif (this.tool(tool.name) !== tool) continue\n\t\t\tconst parameters = deriveBrowserToolSchema(tool.schema)\n\t\t\tif (parameters === undefined) continue\n\t\t\tconst annotations: ToolAnnotations = {\n\t\t\t\tuntrusted: true,\n\t\t\t\t...(tool.annotation.readOnly === undefined ? {} : { pure: tool.annotation.readOnly }),\n\t\t\t\t...(tool.annotation.consequential === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { consequential: tool.annotation.consequential }),\n\t\t\t}\n\t\t\tadopted.push(\n\t\t\t\tcreateTool({\n\t\t\t\t\tname: tool.name,\n\t\t\t\t\tdescription: tool.description,\n\t\t\t\t\tparameters,\n\t\t\t\t\tannotations,\n\t\t\t\t\texecute: this.#executeAdopted.bind(this, tool, parameters !== tool.schema),\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t\treturn adopted\n\t}\n\n\tasync execute(\n\t\ttool: BrowserTool,\n\t\tinput: Readonly<Record<string, unknown>>,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<BrowserInvocationResult> {\n\t\tthis.#assert()\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst session = this.#owners.get(tool.frame)\n\t\tif (\n\t\t\tsession === undefined ||\n\t\t\t!this.#enabled.has(session) ||\n\t\t\tthis.tool(tool.name, tool.frame) === undefined\n\t\t) {\n\t\t\tthrow new BrowserError('Browser tool is not registered in an enabled frame')\n\t\t}\n\t\tconst deferred = Promise.withResolvers<BrowserInvocationResult>()\n\t\tconst pending: BrowserRegistryPending = {\n\t\t\tframe: tool.frame,\n\t\t\tsession,\n\t\t\tsignal: options?.signal,\n\t\t\tcontroller: new AbortController(),\n\t\t\ttimer: setTimeout(() => this.#expire(pending), timeout),\n\t\t\tresolve: deferred.resolve,\n\t\t\treject: deferred.reject,\n\t\t}\n\t\tthis.#pending.add(pending)\n\t\tpending.signal?.addEventListener('abort', () => this.#abort(pending), {\n\t\t\tonce: true,\n\t\t\tsignal: pending.controller.signal,\n\t\t})\n\t\tvoid this.#invoke(pending, tool, input, timeout)\n\t\treturn await deferred.promise\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tthis.#destroying ??= this.#destroy()\n\t\treturn this.#destroying\n\t}\n\n\t#assert(): void {\n\t\tif (this.#destroying !== undefined) throw new BrowserError('Browser registry is destroyed')\n\t\tthis.#page.assert()\n\t}\n\n\tasync #start(options?: BrowserCallOptions): Promise<boolean> {\n\t\tthis.#page.emitter.on('session', this.#sessionHandler)\n\t\tthis.#page.emitter.on('navigate', this.#navigateHandler)\n\t\tthis.#page.emitter.on('detach', this.#detachHandler)\n\t\ttry {\n\t\t\tif (!(await this.#enable(this.#session, options))) {\n\t\t\t\tthis.#unwatch()\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tthis.#assert()\n\t\t\tfor (const session of this.#frames.keys()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.#enable(session, options)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (options?.signal?.aborted === true) throw error\n\t\t\t\t\tthis.#invalidateSession(session)\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.#assert()\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\tthis.#unwatch()\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t#unwatch(): void {\n\t\tthis.#page.emitter.off('session', this.#sessionHandler)\n\t\tthis.#page.emitter.off('navigate', this.#navigateHandler)\n\t\tthis.#page.emitter.off('detach', this.#detachHandler)\n\t}\n\n\tasync #enable(session: string, options?: BrowserCallOptions): Promise<boolean> {\n\t\tif (this.#destroying !== undefined) throw new BrowserError('Browser registry is destroyed')\n\t\tif (this.#enabled.has(session)) return true\n\t\tconst active = this.#enabling.get(session)\n\t\tif (active !== undefined) return await active\n\t\tconst subscriptions = new Map<string, CDPHandler>()\n\t\tsubscriptions.set('WebMCP.toolsAdded', this.#add.bind(this, session))\n\t\tsubscriptions.set('WebMCP.toolsRemoved', this.#remove.bind(this))\n\t\tsubscriptions.set('WebMCP.toolInvoked', this.#invoked.bind(this))\n\t\tsubscriptions.set('WebMCP.toolResponded', this.#respond.bind(this, session))\n\t\tsubscriptions.set('Page.frameNavigated', this.#navigated.bind(this))\n\t\tsubscriptions.set('Page.frameDetached', this.#detached.bind(this))\n\t\tthis.#subscriptions.set(session, subscriptions)\n\t\tfor (const [method, handler] of subscriptions) this.#client.subscribe(method, handler, session)\n\t\tconst enabling = this.#activate(session, options)\n\t\tthis.#enabling.set(session, enabling)\n\t\ttry {\n\t\t\treturn await enabling\n\t\t} finally {\n\t\t\tthis.#enabling.delete(session)\n\t\t}\n\t}\n\n\tasync #activate(session: string, options?: BrowserCallOptions): Promise<boolean> {\n\t\ttry {\n\t\t\tawait this.#client.send('WebMCP.enable', undefined, { ...options, session })\n\t\t\tthis.#enabled.add(session)\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\tthis.#unsubscribe(session)\n\t\t\tthis.#invalidateSession(session)\n\t\t\tif (isCDPError(error) && error.context?.['code'] === BROWSER_REGISTRY_ABSENT_CODE)\n\t\t\t\treturn false\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t#invalidateSession(session: string): void {\n\t\tfor (const [frame, owner] of this.#owners) if (owner === session) this.#invalidate(frame)\n\t}\n\n\t#unsubscribe(session: string): void {\n\t\tfor (const [method, handler] of this.#subscriptions.get(session) ?? [])\n\t\t\tthis.#client.unsubscribe(method, handler, session)\n\t\tthis.#subscriptions.delete(session)\n\t}\n\n\t#attach(frame: BrowserFrameInterface): void {\n\t\tif (this.#destroying !== undefined || !this.#enabled.has(this.#session)) return\n\t\tfor (const [session, id] of this.#frames) {\n\t\t\tif (id === frame.id) {\n\t\t\t\tvoid this.#enable(session).catch(() => this.#invalidate(frame.id))\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\t#navigate(_url: string, same: boolean): void {\n\t\tif (same) return\n\t\tfor (const frame of new Set([...this.tools(), ...this.#pending].map((entry) => entry.frame)))\n\t\t\tthis.#invalidate(frame)\n\t}\n\n\t#navigated(params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frame']\n\t\tif (isRecord(frame) && isString(frame['id'])) this.#invalidate(frame['id'])\n\t}\n\n\t#detached(params: Readonly<Record<string, unknown>>): void {\n\t\tif (isString(params['frameId'])) this.#invalidate(params['frameId'])\n\t}\n\n\t#invalidate(frame: string): void {\n\t\tlet removed = false\n\t\tfor (const [key, tool] of this.#tools) {\n\t\t\tif (tool.frame === frame) {\n\t\t\t\tthis.#tools.delete(key)\n\t\t\t\tremoved = true\n\t\t\t}\n\t\t}\n\t\tthis.#owners.delete(frame)\n\t\tfor (const pending of this.#pending) {\n\t\t\tif (pending.frame === frame)\n\t\t\t\tthis.#reject(pending, new BrowserError('Browser tool frame was invalidated'))\n\t\t}\n\t\tif (removed) this.#emitter.emit('change')\n\t}\n\n\t#add(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tif (!isArray(params['tools'])) return\n\t\tfor (const value of params['tools']) {\n\t\t\tconst tool = parseBrowserTool(value)\n\t\t\tif (tool === undefined) continue\n\t\t\tthis.#tools.set(JSON.stringify([tool.frame, tool.name]), tool)\n\t\t\tthis.#owners.set(tool.frame, session)\n\t\t}\n\t\tthis.#emitter.emit('change')\n\t}\n\n\t#remove(params: Readonly<Record<string, unknown>>): void {\n\t\tif (!isArray(params['tools'])) return\n\t\tfor (const value of params['tools']) {\n\t\t\tconst key = parseBrowserRemoval(value)\n\t\t\tif (key !== undefined) this.#tools.delete(JSON.stringify([key.frame, key.name]))\n\t\t}\n\t\tthis.#emitter.emit('change')\n\t}\n\n\t#invoked(params: Readonly<Record<string, unknown>>): void {\n\t\tconst invocation = parseBrowserInvocation(params)\n\t\tif (invocation !== undefined) this.#emitter.emit('invoke', invocation)\n\t}\n\n\t#respond(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst result = parseBrowserInvocationResult(params)\n\t\tif (result === undefined) return\n\t\tconst pending = [...this.#pending].find(\n\t\t\t(entry) => entry.session === session && this.#identifiers.get(entry) === result.id,\n\t\t)\n\t\tif (pending !== undefined) {\n\t\t\tthis.#release(pending)\n\t\t\tpending.resolve(result)\n\t\t} else if ([...this.#awaiting].some((entry) => entry.session === session)) {\n\t\t\tconst responses = this.#responses.get(session) ?? new Map<string, BrowserInvocationResult>()\n\t\t\tresponses.set(result.id, result)\n\t\t\tthis.#responses.set(session, responses)\n\t\t}\n\t\tthis.#emitter.emit('respond', result)\n\t}\n\n\tasync #invoke(\n\t\tpending: BrowserRegistryPending,\n\t\ttool: BrowserTool,\n\t\tinput: Readonly<Record<string, unknown>>,\n\t\ttimeout: number,\n\t): Promise<void> {\n\t\tthis.#awaiting.add(pending)\n\t\ttry {\n\t\t\t// Abort must not discard the reply: its id is needed to cancel the remote invocation.\n\t\t\tconst reply = await this.#client.send(\n\t\t\t\t'WebMCP.invokeTool',\n\t\t\t\t{ frameId: tool.frame, toolName: tool.name, input },\n\t\t\t\t{ session: pending.session, timeout },\n\t\t\t)\n\t\t\tif (!isRecord(reply) || !isString(reply['invocationId']))\n\t\t\t\tthrow new BrowserError('WebMCP invocation reply has no invocationId')\n\t\t\tconst id = reply['invocationId']\n\t\t\t// A settled entry with a reply means the deadline or abort won the race; cancel remotely.\n\t\t\tif (pending.signal?.aborted === true || !this.#pending.has(pending)) {\n\t\t\t\tthis.#abortInvocation(pending.session, id)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.#identifiers.set(pending, id)\n\t\t\tconst result = this.#responses.get(pending.session)?.get(id)\n\t\t\tthis.#responses.get(pending.session)?.delete(id)\n\t\t\tif (result !== undefined) {\n\t\t\t\tthis.#release(pending)\n\t\t\t\tpending.resolve(result)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthis.#reject(pending, error)\n\t\t} finally {\n\t\t\tthis.#awaiting.delete(pending)\n\t\t\tif (![...this.#awaiting].some((entry) => entry.session === pending.session))\n\t\t\t\tthis.#responses.delete(pending.session)\n\t\t}\n\t}\n\n\t#expire(pending: BrowserRegistryPending): void {\n\t\tconst id = this.#identifiers.get(pending)\n\t\tif (id !== undefined) this.#abortInvocation(pending.session, id)\n\t\tthis.#reject(pending, new BrowserError('Browser tool invocation timed out'))\n\t}\n\n\t#abort(pending: BrowserRegistryPending): void {\n\t\tconst id = this.#identifiers.get(pending)\n\t\tif (id !== undefined) this.#abortInvocation(pending.session, id)\n\t\tthis.#reject(pending, pending.signal?.reason)\n\t}\n\n\t#abortInvocation(session: string, id: string): void {\n\t\tvoid this.#client\n\t\t\t.send('WebMCP.cancelInvocation', { invocationId: id }, { session })\n\t\t\t.catch(() => undefined)\n\t}\n\n\t#release(pending: BrowserRegistryPending): void {\n\t\tclearTimeout(pending.timer)\n\t\tpending.controller.abort()\n\t\tthis.#pending.delete(pending)\n\t\tthis.#identifiers.delete(pending)\n\t}\n\n\t#reject(pending: BrowserRegistryPending, error: unknown): void {\n\t\tif (!this.#pending.has(pending)) return\n\t\tthis.#release(pending)\n\t\tpending.reject(error)\n\t}\n\n\tasync #executeAdopted(\n\t\ttool: BrowserTool,\n\t\tsynthetic: boolean,\n\t\tinput: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<string> {\n\t\tconst parameters = synthetic\n\t\t\t? Object.fromEntries(Object.entries(input).filter(([key]) => key !== 'what'))\n\t\t\t: input\n\t\tconst result = await this.execute(tool, parameters, { signal: context.signal })\n\t\tif (result.status !== 'Completed')\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Browser tool ${result.status}: ${result.error ?? 'No error description'}`.slice(\n\t\t\t\t\t0,\n\t\t\t\t\tBROWSER_REGISTRY_OUTPUT_LIMIT,\n\t\t\t\t),\n\t\t\t)\n\t\treturn renderBrowserToolOutput(result.output)\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\tthis.#unwatch()\n\t\tfor (const session of [...this.#subscriptions.keys()]) this.#unsubscribe(session)\n\t\tfor (const pending of [...this.#pending])\n\t\t\tthis.#reject(pending, new BrowserError('Browser registry is destroyed'))\n\t\tthis.#tools.clear()\n\t\tthis.#owners.clear()\n\t\tthis.#responses.clear()\n\t\tawait Promise.allSettled(this.#enabling.values())\n\t\tawait Promise.allSettled(\n\t\t\t[...this.#enabled].map((session) =>\n\t\t\t\tthis.#client.send('WebMCP.disable', undefined, { session }),\n\t\t\t),\n\t\t)\n\t\tthis.#enabled.clear()\n\t\tthis.#emitter.destroy()\n\t}\n}\n","import type { BrowserFrameInterface, BrowserMetric, BrowserPerformanceInterface } from './types.js'\nimport { readBrowserMetrics } from './helpers.js'\n\n/**\n * Reads Performance-domain metrics for one frame.\n *\n * @example\n * ```ts\n * import { BrowserPerformance } from '@orkestrel/browser'\n *\n * const performance = new BrowserPerformance(page)\n * const metrics = await performance.metrics() // readonly BrowserMetric[]\n * ```\n */\nexport class BrowserPerformance implements BrowserPerformanceInterface {\n\treadonly #frame: BrowserFrameInterface\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tasync metrics(): Promise<readonly BrowserMetric[]> {\n\t\tawait this.#frame.send('Performance.enable')\n\t\ttry {\n\t\t\treturn readBrowserMetrics(await this.#frame.send('Performance.getMetrics'))\n\t\t} finally {\n\t\t\tawait this.#frame.send('Performance.disable').catch(() => undefined)\n\t\t}\n\t}\n}\n","import type { BrowserFrameInterface, BrowserProfile, BrowserProfilerInterface } from './types.js'\nimport { readBrowserProfile } from './helpers.js'\nimport { BrowserError } from './errors.js'\nimport { isInteger } from '@orkestrel/contract'\n\n/**\n * Records sampled JavaScript CPU profiles over one frame's Profiler domain.\n *\n * @example\n * ```ts\n * import { BrowserProfiler } from '@orkestrel/browser'\n *\n * const profiler = new BrowserProfiler(page)\n * await profiler.start(100)\n * const profile = await profiler.stop() // { start, end, nodes, samples, deltas }\n * ```\n */\nexport class BrowserProfiler implements BrowserProfilerInterface {\n\treadonly #frame: BrowserFrameInterface\n\t#active = false\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tget active(): boolean {\n\t\treturn this.#active\n\t}\n\n\tasync start(interval?: number): Promise<void> {\n\t\tif (this.#active) throw new BrowserError('Browser CPU profiling is already active')\n\t\tif (interval !== undefined) {\n\t\t\tif (!isInteger(interval) || interval <= 0) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t'Browser CPU sampling interval must be a positive integer',\n\t\t\t\t\tundefined,\n\t\t\t\t\t{\n\t\t\t\t\t\tinterval,\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\tawait this.#frame.send('Profiler.setSamplingInterval', { interval })\n\t\t}\n\t\tawait this.#frame.send('Profiler.enable')\n\t\ttry {\n\t\t\tawait this.#frame.send('Profiler.start')\n\t\t\tthis.#active = true\n\t\t} catch (error) {\n\t\t\tawait this.#frame.send('Profiler.disable').catch(() => undefined)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync stop(): Promise<BrowserProfile> {\n\t\tif (!this.#active) throw new BrowserError('Browser CPU profiling is not active')\n\t\tthis.#active = false\n\t\tlet result: unknown\n\t\ttry {\n\t\t\tresult = await this.#frame.send('Profiler.stop')\n\t\t} finally {\n\t\t\tawait this.#frame.send('Profiler.disable').catch(() => undefined)\n\t\t}\n\t\treturn readBrowserProfile(result)\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tif (!this.#active) return\n\t\tawait this.stop().catch(() => undefined)\n\t}\n}\n","import type {\n\tBrowserFrameInterface,\n\tBrowserTracingInterface,\n\tBrowserTracingOptions,\n\tBrowserTracingResult,\n\tBrowserWriterInterface,\n} from './types.js'\nimport { BROWSER_DEFAULT_TIMEOUT_MS } from './constants.js'\nimport { concatBytes, readBrowserStreamChunk } from './helpers.js'\nimport { BrowserError } from './errors.js'\nimport { isString } from '@orkestrel/contract'\n\n/**\n * Captures Chromium traces streamed through the IO domain.\n *\n * @example\n * ```ts\n * import { BrowserTracing } from '@orkestrel/browser'\n *\n * const tracing = new BrowserTracing(page)\n * await tracing.start({ screenshots: true })\n * const trace = await tracing.stop() // { bytes, path }\n * ```\n */\nexport class BrowserTracing implements BrowserTracingInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #writer: BrowserWriterInterface | undefined\n\t#active = false\n\t#options: BrowserTracingOptions | undefined\n\t#completion: PromiseWithResolvers<string> | undefined\n\treadonly #completeHandler = this.#handleComplete.bind(this)\n\n\tconstructor(frame: BrowserFrameInterface, writer?: BrowserWriterInterface) {\n\t\tthis.#frame = frame\n\t\tthis.#writer = writer\n\t}\n\n\tget active(): boolean {\n\t\treturn this.#active\n\t}\n\n\tasync start(options?: BrowserTracingOptions): Promise<void> {\n\t\tif (this.#active) throw new BrowserError('Browser tracing is already active')\n\t\tconst categories = [...(options?.categories ?? ['devtools.timeline', 'v8.execute'])]\n\t\tif (options?.screenshots === true) {\n\t\t\tcategories.push('disabled-by-default-devtools.screenshot')\n\t\t}\n\t\tif (options?.sampling === true) {\n\t\t\tcategories.push('disabled-by-default-v8.cpu_profiler')\n\t\t}\n\t\tthis.#options = options\n\t\tthis.#completion = Promise.withResolvers<string>()\n\t\ttry {\n\t\t\tawait this.#frame.subscribe('Tracing.tracingComplete', this.#completeHandler)\n\t\t\tawait this.#frame.send('Tracing.start', {\n\t\t\t\ttransferMode: 'ReturnAsStream',\n\t\t\t\ttraceConfig: {\n\t\t\t\t\tincludedCategories: categories,\n\t\t\t\t},\n\t\t\t})\n\t\t\tthis.#active = true\n\t\t} catch (error) {\n\t\t\tawait this.#frame\n\t\t\t\t.unsubscribe('Tracing.tracingComplete', this.#completeHandler)\n\t\t\t\t.catch(() => undefined)\n\t\t\tthis.#options = undefined\n\t\t\tthis.#completion = undefined\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync stop(): Promise<BrowserTracingResult> {\n\t\tif (!this.#active || this.#completion === undefined) {\n\t\t\tthrow new BrowserError('Browser tracing is not active')\n\t\t}\n\t\tconst completion = this.#completion\n\t\tconst options = this.#options\n\t\tthis.#active = false\n\t\tlet stream: string | undefined\n\t\tconst chunks: Uint8Array[] = []\n\t\ttry {\n\t\t\tawait this.#frame.send('Tracing.end')\n\t\t\tstream = await this.#wait(completion.promise)\n\t\t\twhile (true) {\n\t\t\t\tconst chunk = readBrowserStreamChunk(await this.#frame.send('IO.read', { handle: stream }))\n\t\t\t\tchunks.push(chunk.bytes)\n\t\t\t\tif (chunk.eof) break\n\t\t\t}\n\t\t} finally {\n\t\t\tif (stream !== undefined) {\n\t\t\t\tawait this.#frame.send('IO.close', { handle: stream }).catch(() => undefined)\n\t\t\t}\n\t\t\tawait this.#frame\n\t\t\t\t.unsubscribe('Tracing.tracingComplete', this.#completeHandler)\n\t\t\t\t.catch(() => undefined)\n\t\t\tthis.#options = undefined\n\t\t\tthis.#completion = undefined\n\t\t}\n\t\tconst bytes = concatBytes(chunks)\n\t\tif (options?.path !== undefined) {\n\t\t\tif (this.#writer === undefined) {\n\t\t\t\tthrow new BrowserError('Browser trace path requires a configured writer')\n\t\t\t}\n\t\t\tawait this.#writer.write(options.path, bytes)\n\t\t}\n\t\treturn { bytes, path: options?.path }\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tif (!this.#active) return\n\t\tawait this.stop().catch(() => undefined)\n\t}\n\n\tasync #wait(promise: Promise<string>): Promise<string> {\n\t\tconst deferred = Promise.withResolvers<string>()\n\t\tconst timer = setTimeout(() => {\n\t\t\tdeferred.reject(new BrowserError('Browser trace completion timed out'))\n\t\t}, BROWSER_DEFAULT_TIMEOUT_MS)\n\t\tvoid promise.then(deferred.resolve, deferred.reject)\n\t\ttry {\n\t\t\treturn await deferred.promise\n\t\t} finally {\n\t\t\tclearTimeout(timer)\n\t\t}\n\t}\n\n\t#handleComplete(params: Readonly<Record<string, unknown>>): void {\n\t\tconst completion = this.#completion\n\t\tif (completion === undefined) return\n\t\tif (isString(params['stream'])) completion.resolve(params['stream'])\n\t\telse completion.reject(new BrowserError('Browser trace did not return an IO stream'))\n\t}\n}\n","import type {\n\tBrowserCoverageInterface,\n\tBrowserDiagnosticsInterface,\n\tBrowserFrameInterface,\n\tBrowserPerformanceInterface,\n\tBrowserProfilerInterface,\n\tBrowserTracingInterface,\n\tBrowserWriterInterface,\n} from './types.js'\nimport { BrowserCoverage } from './BrowserCoverage.js'\nimport { BrowserPerformance } from './BrowserPerformance.js'\nimport { BrowserProfiler } from './BrowserProfiler.js'\nimport { BrowserTracing } from './BrowserTracing.js'\n\n/**\n * Groups the tracing, coverage, performance, and profiler classes beneath one page.\n *\n * @example\n * ```ts\n * import { BrowserDiagnostics } from '@orkestrel/browser'\n *\n * const diagnostics = new BrowserDiagnostics(page)\n * const metrics = await diagnostics.performance.metrics()\n * await diagnostics.destroy()\n * ```\n */\nexport class BrowserDiagnostics implements BrowserDiagnosticsInterface {\n\treadonly #tracing: BrowserTracing\n\treadonly #coverage: BrowserCoverage\n\treadonly #performance: BrowserPerformance\n\treadonly #profiler: BrowserProfiler\n\n\tconstructor(frame: BrowserFrameInterface, writer?: BrowserWriterInterface) {\n\t\tthis.#tracing = new BrowserTracing(frame, writer)\n\t\tthis.#coverage = new BrowserCoverage(frame)\n\t\tthis.#performance = new BrowserPerformance(frame)\n\t\tthis.#profiler = new BrowserProfiler(frame)\n\t}\n\n\tget tracing(): BrowserTracingInterface {\n\t\treturn this.#tracing\n\t}\n\n\tget coverage(): BrowserCoverageInterface {\n\t\treturn this.#coverage\n\t}\n\n\tget performance(): BrowserPerformanceInterface {\n\t\treturn this.#performance\n\t}\n\n\tget profiler(): BrowserProfilerInterface {\n\t\treturn this.#profiler\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tawait this.#tracing.destroy()\n\t\tawait this.#coverage.destroy()\n\t\tawait this.#profiler.destroy()\n\t}\n}\n","import type {\n\tBrowserDialogCategory,\n\tBrowserDialogInterface,\n\tBrowserFrameInterface,\n} from './types.js'\nimport { BrowserError } from './errors.js'\n\n/**\n * Represents one JavaScript dialog awaiting a user decision.\n */\nexport class BrowserDialog implements BrowserDialogInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #category: BrowserDialogCategory\n\treadonly #message: string\n\treadonly #default: string\n\t#handled = false\n\t#handling = false\n\n\tconstructor(\n\t\tframe: BrowserFrameInterface,\n\t\tcategory: BrowserDialogCategory,\n\t\tmessage: string,\n\t\tvalue: string,\n\t) {\n\t\tthis.#frame = frame\n\t\tthis.#category = category\n\t\tthis.#message = message\n\t\tthis.#default = value\n\t}\n\n\tget category(): BrowserDialogCategory {\n\t\treturn this.#category\n\t}\n\n\tget message(): string {\n\t\treturn this.#message\n\t}\n\n\tget default(): string {\n\t\treturn this.#default\n\t}\n\n\tasync accept(value?: string): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('Page.handleJavaScriptDialog', {\n\t\t\t\taccept: true,\n\t\t\t\tpromptText: value,\n\t\t\t})\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\tasync dismiss(): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('Page.handleJavaScriptDialog', { accept: false })\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\t#assert(): void {\n\t\tif (this.#handled || this.#handling) {\n\t\t\tthrow new BrowserError('Browser dialog is already handled')\n\t\t}\n\t}\n}\n","import type {\n\tBrowserDownloadEventMap,\n\tBrowserDownloadInterface,\n\tBrowserDownloadProgress,\n\tBrowserDownloadStatus,\n\tCDPClientInterface,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { Emitter } from '@orkestrel/emitter'\n\n/**\n * Represents one Chromium download and its progress lifecycle.\n */\nexport class BrowserDownload implements BrowserDownloadInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #context: string | undefined\n\treadonly #emitter: Emitter<BrowserDownloadEventMap>\n\treadonly #id: string\n\treadonly #url: string\n\treadonly #name: string\n\t#status: BrowserDownloadStatus = 'pending'\n\t#received = 0\n\t#total = 0\n\t#path: string | undefined\n\n\tconstructor(client: CDPClientInterface, id: string, url: string, name: string, context?: string) {\n\t\tthis.#client = client\n\t\tthis.#context = context\n\t\tthis.#id = id\n\t\tthis.#url = url\n\t\tthis.#name = name\n\t\tthis.#emitter = new Emitter()\n\t}\n\n\tget emitter(): EmitterInterface<BrowserDownloadEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget url(): string {\n\t\treturn this.#url\n\t}\n\n\tget name(): string {\n\t\treturn this.#name\n\t}\n\n\tget status(): BrowserDownloadStatus {\n\t\treturn this.#status\n\t}\n\n\tget received(): number {\n\t\treturn this.#received\n\t}\n\n\tget total(): number {\n\t\treturn this.#total\n\t}\n\n\tget path(): string | undefined {\n\t\treturn this.#path\n\t}\n\n\tasync abort(): Promise<void> {\n\t\tif (this.#status !== 'pending') return\n\t\tconst params: Record<string, unknown> = { guid: this.#id }\n\t\tif (this.#context !== undefined) params['browserContextId'] = this.#context\n\t\tawait this.#client.send('Browser.cancelDownload', params)\n\t}\n\n\tupdate(progress: BrowserDownloadProgress): void {\n\t\tif (this.#status !== 'pending') return\n\t\tthis.#received = progress.received\n\t\tthis.#total = progress.total\n\t\tthis.#path = progress.path\n\t\tthis.#emitter.emit('progress', this.#received, this.#total)\n\t\tif (progress.status === 'complete') {\n\t\t\tthis.#status = 'complete'\n\t\t\tthis.#emitter.emit('complete', this.#path)\n\t\t\tthis.#emitter.destroy()\n\t\t} else if (progress.status === 'aborted') {\n\t\t\tthis.#status = 'aborted'\n\t\t\tthis.#emitter.emit('abort')\n\t\t\tthis.#emitter.destroy()\n\t\t}\n\t}\n}\n","import type { BrowserCallOptions, BrowserHandleInterface, CDPClientInterface } from './types.js'\nimport { BrowserError } from './errors.js'\nimport { readEvaluationResult } from './helpers.js'\nimport { isRecord, isString } from '@orkestrel/contract'\n\n/**\n * Represents one retained remote object in a frame execution context.\n */\nexport class BrowserHandle implements BrowserHandleInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #session: string\n\treadonly #id: string\n\t#disposed = false\n\n\tconstructor(client: CDPClientInterface, session: string, id: string) {\n\t\tthis.#client = client\n\t\tthis.#session = session\n\t\tthis.#id = id\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tasync value(options?: BrowserCallOptions): Promise<unknown> {\n\t\treturn await this.call('function() { return this }', undefined, options)\n\t}\n\n\tasync call(\n\t\tdeclaration: string,\n\t\targs?: readonly unknown[],\n\t\toptions?: BrowserCallOptions,\n\t): Promise<unknown> {\n\t\tthis.#assert()\n\t\tconst result = await this.#client.send(\n\t\t\t'Runtime.callFunctionOn',\n\t\t\t{\n\t\t\t\tobjectId: this.#id,\n\t\t\t\tfunctionDeclaration: declaration,\n\t\t\t\targuments: args?.map((value) => ({ value })),\n\t\t\t\tawaitPromise: true,\n\t\t\t\treturnByValue: true,\n\t\t\t},\n\t\t\t{ session: this.#session, ...options },\n\t\t)\n\t\treturn readEvaluationResult(result)\n\t}\n\n\tasync property(\n\t\tname: string,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<BrowserHandleInterface | undefined> {\n\t\tthis.#assert()\n\t\tconst result = await this.#client.send(\n\t\t\t'Runtime.callFunctionOn',\n\t\t\t{\n\t\t\t\tobjectId: this.#id,\n\t\t\t\tfunctionDeclaration: 'function(name) { return this[name] }',\n\t\t\t\targuments: [{ value: name }],\n\t\t\t\tawaitPromise: true,\n\t\t\t\treturnByValue: false,\n\t\t\t},\n\t\t\t{ session: this.#session, ...options },\n\t\t)\n\t\tif (!isRecord(result) || !isRecord(result['result'])) return undefined\n\t\tconst id = result['result']['objectId']\n\t\treturn isString(id) ? new BrowserHandle(this.#client, this.#session, id) : undefined\n\t}\n\n\tasync properties(options?: BrowserCallOptions): Promise<Readonly<Record<string, unknown>>> {\n\t\tconst value = await this.call(\n\t\t\t'function() { const values = {}; for (const key of Object.keys(this)) values[key] = this[key]; return values }',\n\t\t\tundefined,\n\t\t\toptions,\n\t\t)\n\t\tif (!isRecord(value)) {\n\t\t\tthrow new BrowserError('Browser handle properties did not resolve to an object')\n\t\t}\n\t\treturn value\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\tif (this.#disposed) return\n\t\tthis.#disposed = true\n\t\tif (!this.#client.connected) return\n\t\ttry {\n\t\t\tawait this.#client.send(\n\t\t\t\t'Runtime.releaseObject',\n\t\t\t\t{ objectId: this.#id },\n\t\t\t\t{\n\t\t\t\t\tsession: this.#session,\n\t\t\t\t},\n\t\t\t)\n\t\t} catch {\n\t\t\t// The execution context may already be gone.\n\t\t}\n\t}\n\n\t#assert(): void {\n\t\tif (this.#disposed) throw new BrowserError('Browser handle is disposed')\n\t\tif (!this.#client.connected) throw new BrowserError('Browser handle is disconnected')\n\t}\n}\n","import type {\n\tBrowserEpochFunction,\n\tBrowserFrameInterface,\n\tBrowserHandleInterface,\n\tBrowserReadingInterface,\n\tBrowserCallOptions,\n\tBrowserSessionFunction,\n\tBrowserWorldFunction,\n\tCDPHandler,\n\tCDPClientInterface,\n} from './types.js'\nimport { BrowserHandle } from './BrowserHandle.js'\nimport { BrowserReading } from './BrowserReading.js'\nimport { BROWSER_FRAME_WORLD_NAME, BROWSER_RESULT_LIMIT } from './constants.js'\nimport { compileGuardedEvaluateExpression, compileReadFunction } from './compilers.js'\nimport { readBrowserWorld, readEvaluationResult, requireBrowserString } from './helpers.js'\nimport { BrowserError } from './errors.js'\nimport { isRecord, isString } from '@orkestrel/contract'\n\n/**\n * Represents one attached document frame, evaluated through its own CDP execution world.\n *\n * @remarks\n * The optional `epoch` constructor parameter reads the frame's navigation counter, which lets\n * `read()` mark a reading stale after a later navigation. The optional `world` parameter\n * resolves a cached isolated-world context, which lets a page share one world across reads.\n * A standalone frame built with neither returns readings whose `stale` stays `false`, because\n * no navigation counter is available to it, and creates a fresh world for each read.\n *\n * @example\n * ```ts\n * import { BrowserFrame } from '@orkestrel/browser'\n *\n * const frame = new BrowserFrame(client, 'session-1', 'frame-1', 'https://example.com')\n * const title = await frame.title()\n * const reading = await frame.read()\n * ```\n */\nexport class BrowserFrame implements BrowserFrameInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #session: string | BrowserSessionFunction\n\treadonly #id: string\n\treadonly #parent: string | undefined\n\treadonly #name: string | undefined\n\treadonly #isolated: boolean\n\treadonly #epoch: BrowserEpochFunction | undefined\n\treadonly #world: BrowserWorldFunction | undefined\n\t#url: string\n\n\tconstructor(\n\t\tclient: CDPClientInterface,\n\t\tsession: string | BrowserSessionFunction,\n\t\tid: string,\n\t\turl: string,\n\t\tparent?: string,\n\t\tname?: string,\n\t\tisolated = true,\n\t\tepoch?: BrowserEpochFunction,\n\t\tworld?: BrowserWorldFunction,\n\t) {\n\t\tthis.#client = client\n\t\tthis.#session = session\n\t\tthis.#id = id\n\t\tthis.#url = url\n\t\tthis.#parent = parent\n\t\tthis.#name = name\n\t\tthis.#isolated = isolated\n\t\tthis.#epoch = epoch\n\t\tthis.#world = world\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget parent(): string | undefined {\n\t\treturn this.#parent\n\t}\n\n\tget name(): string | undefined {\n\t\treturn this.#name\n\t}\n\n\tget url(): string {\n\t\treturn this.#url\n\t}\n\n\tasync title(options?: BrowserCallOptions): Promise<string> {\n\t\tthis.assert()\n\t\tconst result = await this.#evaluate('document.title', options)\n\t\treturn requireBrowserString(result, 'Document title')\n\t}\n\n\tasync read(options?: BrowserCallOptions): Promise<BrowserReadingInterface> {\n\t\tthis.assert()\n\t\t// The epoch is sampled before the capture is issued, so a navigation that lands while the\n\t\t// evaluation is in flight leaves the reading stale rather than current.\n\t\tconst epoch = this.#epoch?.()\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst session = await this.#sessionId()\n\t\tconst context =\n\t\t\tthis.#world === undefined\n\t\t\t\t? await this.#create(session, options)\n\t\t\t\t: await this.#world(session, options)\n\t\tconst result = await this.#client.send(\n\t\t\t'Runtime.evaluate',\n\t\t\t{\n\t\t\t\texpression: compileGuardedEvaluateExpression(\n\t\t\t\t\t`(${compileReadFunction()})()`,\n\t\t\t\t\tBROWSER_RESULT_LIMIT,\n\t\t\t\t),\n\t\t\t\treturnByValue: true,\n\t\t\t\tawaitPromise: true,\n\t\t\t\tcontextId: context,\n\t\t\t},\n\t\t\t{ session, ...options },\n\t\t)\n\t\tconst capture = readEvaluationResult(result)\n\t\tif (\n\t\t\t!isRecord(capture) ||\n\t\t\t!isString(capture['url']) ||\n\t\t\t!isString(capture['title']) ||\n\t\t\t!isString(capture['html'])\n\t\t) {\n\t\t\tthrow new BrowserError('Browser read capture is malformed', undefined, { frame: this.#id })\n\t\t}\n\t\t// A capture that a navigation overtook must not regress the frame URL the navigation set.\n\t\tif (this.#epoch === undefined || this.#epoch() === epoch) this.#url = capture['url']\n\t\treturn new BrowserReading({\n\t\t\turl: capture['url'],\n\t\t\ttitle: capture['title'],\n\t\t\thtml: capture['html'],\n\t\t\t...(epoch === undefined || this.#epoch === undefined\n\t\t\t\t? {}\n\t\t\t\t: { epoch, navigation: this.#epoch }),\n\t\t})\n\t}\n\n\tasync evaluate(expression: string, options?: BrowserCallOptions): Promise<unknown> {\n\t\tthis.assert()\n\t\treturn await this.#evaluate(\n\t\t\tcompileGuardedEvaluateExpression(expression, BROWSER_RESULT_LIMIT),\n\t\t\toptions,\n\t\t)\n\t}\n\n\tasync handle(expression: string, options?: BrowserCallOptions): Promise<BrowserHandleInterface> {\n\t\tthis.assert()\n\t\tconst session = await this.#sessionId()\n\t\tconst params: Record<string, unknown> = {\n\t\t\texpression,\n\t\t\treturnByValue: false,\n\t\t\tawaitPromise: true,\n\t\t}\n\t\tconst context = await this.#context(session, options)\n\t\tif (context !== undefined) params['contextId'] = context\n\t\tconst result = await this.#client.send('Runtime.evaluate', params, {\n\t\t\tsession,\n\t\t\t...options,\n\t\t})\n\t\tif (\n\t\t\t!isRecord(result) ||\n\t\t\t!isRecord(result['result']) ||\n\t\t\t!isString(result['result']['objectId'])\n\t\t) {\n\t\t\tthrow new BrowserError('Browser expression did not resolve to an object handle', undefined, {\n\t\t\t\tframe: this.#id,\n\t\t\t})\n\t\t}\n\t\treturn new BrowserHandle(this.#client, session, result['result']['objectId'])\n\t}\n\n\tasync send(\n\t\tmethod: string,\n\t\tparams?: Readonly<Record<string, unknown>>,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<unknown> {\n\t\tthis.assert()\n\t\treturn await this.#client.send(method, params, {\n\t\t\tsession: await this.#sessionId(),\n\t\t\t...options,\n\t\t})\n\t}\n\n\tasync subscribe(method: string, handler: CDPHandler): Promise<void> {\n\t\tthis.assert()\n\t\tthis.#client.subscribe(method, handler, await this.#sessionId())\n\t}\n\n\tasync unsubscribe(method: string, handler: CDPHandler): Promise<void> {\n\t\tthis.#client.unsubscribe(method, handler, await this.#sessionId())\n\t}\n\n\tasync save(path: string, _bytes: Uint8Array): Promise<void> {\n\t\t// Frames satisfy the persistence contract, but only top-level pages receive a writer.\n\t\tthrow new BrowserError('Browser frame has no configured file writer', undefined, { path })\n\t}\n\n\tassert(): void {\n\t\tif (!this.#client.connected) {\n\t\t\tthrow new BrowserError('Browser frame is disconnected', undefined, { frame: this.#id })\n\t\t}\n\t}\n\n\tupdate(url: string): void {\n\t\tthis.#url = url\n\t}\n\n\tasync #evaluate(expression: string, options?: BrowserCallOptions): Promise<unknown> {\n\t\tconst session = await this.#sessionId()\n\t\tconst params: Record<string, unknown> = {\n\t\t\texpression,\n\t\t\treturnByValue: true,\n\t\t\tawaitPromise: true,\n\t\t}\n\n\t\tconst context = await this.#context(session, options)\n\t\tif (context !== undefined) params['contextId'] = context\n\n\t\tconst result = await this.#client.send('Runtime.evaluate', params, {\n\t\t\tsession,\n\t\t\t...options,\n\t\t})\n\t\treturn readEvaluationResult(result)\n\t}\n\n\tasync #context(session: string, options?: BrowserCallOptions): Promise<number | undefined> {\n\t\tif (!this.#isolated) return undefined\n\t\tif (this.#world !== undefined) return await this.#world(session, options)\n\t\treturn await this.#create(session, options)\n\t}\n\n\tasync #create(session: string, options?: BrowserCallOptions): Promise<number> {\n\t\tconst world = await this.#client.send(\n\t\t\t'Page.createIsolatedWorld',\n\t\t\t{ frameId: this.#id, worldName: BROWSER_FRAME_WORLD_NAME },\n\t\t\t{ session, ...options },\n\t\t)\n\t\treturn readBrowserWorld(world, this.#id)\n\t}\n\n\tasync #sessionId(): Promise<string> {\n\t\tif (isString(this.#session)) return this.#session\n\t\treturn await this.#session(this.#id)\n\t}\n}\n","import type { BrowserFileChooserInterface, BrowserFrameInterface } from './types.js'\nimport { BrowserError } from './errors.js'\n\n/**\n * Represents one intercepted file input selection.\n */\nexport class BrowserFileChooser implements BrowserFileChooserInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #backend: number\n\treadonly #multiple: boolean\n\t#handled = false\n\t#handling = false\n\n\tconstructor(frame: BrowserFrameInterface, backend: number, multiple: boolean) {\n\t\tthis.#frame = frame\n\t\tthis.#backend = backend\n\t\tthis.#multiple = multiple\n\t}\n\n\tget multiple(): boolean {\n\t\treturn this.#multiple\n\t}\n\n\tasync upload(files: readonly string[]): Promise<void> {\n\t\tthis.#assert()\n\t\tif (!this.#multiple && files.length > 1) {\n\t\t\tthrow new BrowserError('Single file chooser cannot accept multiple files')\n\t\t}\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('DOM.setFileInputFiles', {\n\t\t\t\tbackendNodeId: this.#backend,\n\t\t\t\tfiles: [...files],\n\t\t\t})\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\tasync dismiss(): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('DOM.setFileInputFiles', {\n\t\t\t\tbackendNodeId: this.#backend,\n\t\t\t\tfiles: [],\n\t\t\t})\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\t#assert(): void {\n\t\tif (this.#handled || this.#handling) {\n\t\t\tthrow new BrowserError('Browser file chooser is already handled')\n\t\t}\n\t}\n}\n","import type {\n\tBrowserFrameInterface,\n\tBrowserInputOptions,\n\tBrowserKeyboardInterface,\n} from './types.js'\nimport {\n\tcomputeBrowserModifiers,\n\textractBrowserChord,\n\tkeyToBrowserInput,\n\tvalidateBrowserInputOptions,\n} from './helpers.js'\n\n/**\n * Sends trusted keyboard input through Chromium's CDP Input domain.\n *\n * @example\n * ```ts\n * import { BrowserKeyboard } from '@orkestrel/browser'\n *\n * const keyboard = new BrowserKeyboard(page)\n * await keyboard.type('orkestrel', { delay: 10 })\n * await keyboard.press('Control+Enter')\n * ```\n */\nexport class BrowserKeyboard implements BrowserKeyboardInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #modifiers = new Set<string>()\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tasync down(value: string): Promise<void> {\n\t\tconst key = keyToBrowserInput(value)\n\t\tconst modifier = ['Alt', 'Control', 'Meta', 'Shift'].includes(key.key)\n\t\tconst modifiers = computeBrowserModifiers([...this.#modifiers, ...(modifier ? [key.key] : [])])\n\t\tconst text = modifiers === 0 || modifiers === 8 ? key.text : undefined\n\t\tawait this.#frame.send('Input.dispatchKeyEvent', {\n\t\t\ttype: 'keyDown',\n\t\t\tkey: key.key,\n\t\t\tcode: key.code,\n\t\t\ttext,\n\t\t\tunmodifiedText: key.text,\n\t\t\twindowsVirtualKeyCode: key.number,\n\t\t\tnativeVirtualKeyCode: key.number,\n\t\t\tmodifiers,\n\t\t})\n\t\tif (modifier) this.#modifiers.add(key.key)\n\t}\n\n\tasync up(value: string): Promise<void> {\n\t\tconst key = keyToBrowserInput(value)\n\t\ttry {\n\t\t\tawait this.#frame.send('Input.dispatchKeyEvent', {\n\t\t\t\ttype: 'keyUp',\n\t\t\t\tkey: key.key,\n\t\t\t\tcode: key.code,\n\t\t\t\twindowsVirtualKeyCode: key.number,\n\t\t\t\tnativeVirtualKeyCode: key.number,\n\t\t\t\tmodifiers: computeBrowserModifiers([...this.#modifiers]),\n\t\t\t})\n\t\t} finally {\n\t\t\tthis.#modifiers.delete(key.key)\n\t\t}\n\t}\n\n\tasync press(value: string, options?: BrowserInputOptions): Promise<void> {\n\t\tvalidateBrowserInputOptions(options)\n\t\tconst chord = extractBrowserChord(value)\n\t\tfor (const modifier of chord.modifiers) await this.down(modifier)\n\t\ttry {\n\t\t\tawait this.down(chord.key)\n\t\t\tif (options?.delay !== undefined && options.delay > 0) {\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, options.delay))\n\t\t\t}\n\t\t\tawait this.up(chord.key)\n\t\t} finally {\n\t\t\tfor (const modifier of [...chord.modifiers].reverse()) await this.up(modifier)\n\t\t}\n\t}\n\n\tasync type(value: string, options?: BrowserInputOptions): Promise<void> {\n\t\tvalidateBrowserInputOptions(options)\n\t\tfor (const character of value) {\n\t\t\tawait this.down(character)\n\t\t\tawait this.up(character)\n\t\t\tif (options?.delay !== undefined && options.delay > 0) {\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, options.delay))\n\t\t\t}\n\t\t}\n\t}\n\n\tasync insert(value: string): Promise<void> {\n\t\tawait this.#frame.send('Input.insertText', { text: value })\n\t}\n}\n","import type {\n\tBrowserClickOptions,\n\tBrowserDragOptions,\n\tBrowserFrameInterface,\n\tBrowserMouseButton,\n\tBrowserMouseInterface,\n\tBrowserPoint,\n} from './types.js'\nimport {\n\tcomputeBrowserButtons,\n\tvalidateBrowserInputOptions,\n\tvalidateBrowserPoint,\n} from './helpers.js'\n\n/**\n * Sends trusted mouse input through Chromium's CDP Input domain.\n *\n * @example\n * ```ts\n * import { BrowserMouse } from '@orkestrel/browser'\n *\n * const mouse = new BrowserMouse(page)\n * await mouse.click({ x: 50, y: 20 }, { button: 'left', count: 2 })\n * await mouse.drag({ x: 10, y: 10 }, { x: 90, y: 90 }, { steps: 20 })\n * ```\n */\nexport class BrowserMouse implements BrowserMouseInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #buttons = new Set<BrowserMouseButton>()\n\t#point: BrowserPoint = { x: 0, y: 0 }\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tasync move(point: BrowserPoint): Promise<void> {\n\t\tvalidateBrowserPoint(point)\n\t\tthis.#point = point\n\t\tawait this.#frame.send('Input.dispatchMouseEvent', {\n\t\t\ttype: 'mouseMoved',\n\t\t\tx: point.x,\n\t\t\ty: point.y,\n\t\t\tbutton: 'none',\n\t\t\tbuttons: computeBrowserButtons([...this.#buttons]),\n\t\t})\n\t}\n\n\tasync down(button: BrowserMouseButton = 'left', count = 1): Promise<void> {\n\t\tvalidateBrowserInputOptions({ count })\n\t\tconst buttons = new Set(this.#buttons)\n\t\tbuttons.add(button)\n\t\tawait this.#frame.send('Input.dispatchMouseEvent', {\n\t\t\ttype: 'mousePressed',\n\t\t\tx: this.#point.x,\n\t\t\ty: this.#point.y,\n\t\t\tbutton,\n\t\t\tbuttons: computeBrowserButtons([...buttons]),\n\t\t\tclickCount: count,\n\t\t})\n\t\tthis.#buttons.add(button)\n\t}\n\n\tasync up(button: BrowserMouseButton = 'left', count = 1): Promise<void> {\n\t\tvalidateBrowserInputOptions({ count })\n\t\tconst buttons = new Set(this.#buttons)\n\t\tbuttons.delete(button)\n\t\ttry {\n\t\t\tawait this.#frame.send('Input.dispatchMouseEvent', {\n\t\t\t\ttype: 'mouseReleased',\n\t\t\t\tx: this.#point.x,\n\t\t\t\ty: this.#point.y,\n\t\t\t\tbutton,\n\t\t\t\tbuttons: computeBrowserButtons([...buttons]),\n\t\t\t\tclickCount: count,\n\t\t\t})\n\t\t} finally {\n\t\t\tthis.#buttons.delete(button)\n\t\t}\n\t}\n\n\tasync click(point: BrowserPoint, options?: BrowserClickOptions): Promise<void> {\n\t\tvalidateBrowserInputOptions(options)\n\t\tconst button = options?.button ?? 'left'\n\t\tconst count = options?.count ?? 1\n\t\tawait this.move(point)\n\t\tawait this.down(button, count)\n\t\tif (options?.delay !== undefined && options.delay > 0) {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, options.delay))\n\t\t}\n\t\tawait this.up(button, count)\n\t}\n\n\tasync drag(start: BrowserPoint, end: BrowserPoint, options?: BrowserDragOptions): Promise<void> {\n\t\tvalidateBrowserInputOptions(options)\n\t\tvalidateBrowserPoint(start)\n\t\tvalidateBrowserPoint(end)\n\t\tconst steps = options?.steps ?? 10\n\t\tawait this.move(start)\n\t\tawait this.down(options?.button ?? 'left', 1)\n\t\ttry {\n\t\t\tfor (let step = 1; step <= steps; step += 1) {\n\t\t\t\tawait this.move({\n\t\t\t\t\tx: start.x + ((end.x - start.x) * step) / steps,\n\t\t\t\t\ty: start.y + ((end.y - start.y) * step) / steps,\n\t\t\t\t})\n\t\t\t\tif (options?.delay !== undefined && options.delay > 0) {\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, options.delay))\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tawait this.up(options?.button ?? 'left', 1)\n\t\t}\n\t}\n\n\tasync wheel(delta: BrowserPoint): Promise<void> {\n\t\tvalidateBrowserPoint(delta)\n\t\tawait this.#frame.send('Input.dispatchMouseEvent', {\n\t\t\ttype: 'mouseWheel',\n\t\t\tx: this.#point.x,\n\t\t\ty: this.#point.y,\n\t\t\tdeltaX: delta.x,\n\t\t\tdeltaY: delta.y,\n\t\t\tbuttons: computeBrowserButtons([...this.#buttons]),\n\t\t})\n\t}\n}\n","import type { BrowserFrameInterface, BrowserPoint, BrowserTouchInterface } from './types.js'\nimport { validateBrowserPoint } from './helpers.js'\n\n/**\n * Sends trusted touch input through Chromium's CDP Input domain.\n *\n * @example\n * ```ts\n * import { BrowserTouch } from '@orkestrel/browser'\n *\n * const touch = new BrowserTouch(page)\n * await touch.tap({ x: 120, y: 240 })\n * ```\n */\nexport class BrowserTouch implements BrowserTouchInterface {\n\treadonly #frame: BrowserFrameInterface\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tasync tap(point: BrowserPoint): Promise<void> {\n\t\tvalidateBrowserPoint(point)\n\t\tconst touch = { x: point.x, y: point.y }\n\t\tawait this.#frame.send('Input.dispatchTouchEvent', {\n\t\t\ttype: 'touchStart',\n\t\t\ttouchPoints: [touch],\n\t\t})\n\t\ttry {\n\t\t\tawait this.#frame.send('Input.dispatchTouchEvent', {\n\t\t\t\ttype: 'touchEnd',\n\t\t\t\ttouchPoints: [],\n\t\t\t})\n\t\t} catch (error) {\n\t\t\tawait this.#frame\n\t\t\t\t.send('Input.dispatchTouchEvent', {\n\t\t\t\t\ttype: 'touchCancel',\n\t\t\t\t\ttouchPoints: [],\n\t\t\t\t})\n\t\t\t\t.catch(() => undefined)\n\t\t\tthrow error\n\t\t}\n\t}\n}\n","import type {\n\tBrowserHAR,\n\tBrowserHAREntry,\n\tBrowserHARManagerInterface,\n\tBrowserHAROptions,\n\tBrowserHARPending,\n\tBrowserHARReplayOptions,\n\tBrowserNetworkManagerInterface,\n\tBrowserRequest,\n\tBrowserRequestFailure,\n\tBrowserResponse,\n\tBrowserRouteHandler,\n\tBrowserWriterInterface,\n} from './types.js'\nimport { BROWSER_HAR_CREATOR } from './constants.js'\nimport {\n\tbrowserHARHeadersToRecord,\n\tcreateBrowserHAREntry,\n\tdecodeBase64,\n\ttextToBytes,\n\tvalidateBrowserHAR,\n} from './helpers.js'\nimport { BrowserError } from './errors.js'\n\n/**\n * Records and replays HTTP archives over one page network manager.\n *\n * @example\n * ```ts\n * import { BrowserHARManager } from '@orkestrel/browser'\n *\n * const har = new BrowserHARManager(page.network)\n * await har.start({ content: true })\n * const archive = await har.stop() // { log: { version: '1.2', creator, entries } }\n * ```\n */\nexport class BrowserHARManager implements BrowserHARManagerInterface {\n\treadonly #network: BrowserNetworkManagerInterface\n\treadonly #writer: BrowserWriterInterface | undefined\n\treadonly #pending: Map<string, BrowserHARPending> = new Map()\n\treadonly #entries: BrowserHAREntry[] = []\n\treadonly #tasks: Set<Promise<void>> = new Set()\n\t#options: BrowserHAROptions | undefined\n\t#recording = false\n\t#failure: unknown\n\t#archive: BrowserHAR | undefined\n\t#fallback = false\n\treadonly #requestHandler = this.#handleRequest.bind(this)\n\treadonly #responseHandler = this.#handleResponse.bind(this)\n\treadonly #failureHandler = this.#handleFailure.bind(this)\n\treadonly #finishHandler = this.#handleFinish.bind(this)\n\treadonly #replayHandler: BrowserRouteHandler = this.#handleReplay.bind(this)\n\n\tconstructor(network: BrowserNetworkManagerInterface, writer?: BrowserWriterInterface) {\n\t\tthis.#network = network\n\t\tthis.#writer = writer\n\t}\n\n\tget recording(): boolean {\n\t\treturn this.#recording\n\t}\n\n\tasync start(options?: BrowserHAROptions): Promise<void> {\n\t\tif (this.#recording) return\n\t\tthis.#options = options\n\t\tthis.#entries.length = 0\n\t\tthis.#pending.clear()\n\t\tthis.#failure = undefined\n\t\tthis.#network.emitter.on('request', this.#requestHandler)\n\t\tthis.#network.emitter.on('response', this.#responseHandler)\n\t\tthis.#network.emitter.on('failure', this.#failureHandler)\n\t\tthis.#network.emitter.on('finish', this.#finishHandler)\n\t\tthis.#recording = true\n\t\ttry {\n\t\t\tawait this.#network.start()\n\t\t} catch (error) {\n\t\t\tthis.#recording = false\n\t\t\tthis.#network.emitter.off('request', this.#requestHandler)\n\t\t\tthis.#network.emitter.off('response', this.#responseHandler)\n\t\t\tthis.#network.emitter.off('failure', this.#failureHandler)\n\t\t\tthis.#network.emitter.off('finish', this.#finishHandler)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync stop(): Promise<BrowserHAR> {\n\t\tif (this.#recording) {\n\t\t\tthis.#recording = false\n\t\t\tthis.#network.emitter.off('request', this.#requestHandler)\n\t\t\tthis.#network.emitter.off('response', this.#responseHandler)\n\t\t\tthis.#network.emitter.off('failure', this.#failureHandler)\n\t\t\tthis.#network.emitter.off('finish', this.#finishHandler)\n\t\t\tawait Promise.allSettled([...this.#tasks])\n\t\t\tfor (const id of [...this.#pending.keys()]) {\n\t\t\t\tconst pending = this.#pending.get(id)\n\t\t\t\tif (pending === undefined) continue\n\t\t\t\tthis.#pending.delete(id)\n\t\t\t\tthis.#entries.push(\n\t\t\t\t\tcreateBrowserHAREntry(\n\t\t\t\t\t\tpending,\n\t\t\t\t\t\tMath.max(0, Date.now() - pending.started),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t'Request was incomplete when recording stopped',\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tif (this.#failure !== undefined) {\n\t\t\tthrow new BrowserError('Browser HAR recording failed', 'BROWSER_HAR_ERROR', {\n\t\t\t\terror: this.#failure,\n\t\t\t})\n\t\t}\n\t\tconst har: BrowserHAR = {\n\t\t\tlog: {\n\t\t\t\tversion: '1.2',\n\t\t\t\tcreator: BROWSER_HAR_CREATOR,\n\t\t\t\tentries: [...this.#entries],\n\t\t\t},\n\t\t}\n\t\tif (this.#options?.path !== undefined) {\n\t\t\tif (this.#writer === undefined) {\n\t\t\t\tthrow new BrowserError('Browser HAR path requires a configured writer')\n\t\t\t}\n\t\t\tawait this.#writer.write(this.#options.path, textToBytes(JSON.stringify(har, undefined, 2)))\n\t\t}\n\t\treturn har\n\t}\n\n\tasync replay(har: BrowserHAR, options?: BrowserHARReplayOptions): Promise<void> {\n\t\tvalidateBrowserHAR(har)\n\t\tif (this.#archive !== undefined) await this.#network.unroute(this.#replayHandler)\n\t\tthis.#archive = har\n\t\tthis.#fallback = options?.fallback === true\n\t\ttry {\n\t\t\tawait this.#network.route({}, this.#replayHandler)\n\t\t} catch (error) {\n\t\t\tthis.#archive = undefined\n\t\t\tthis.#fallback = false\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tif (this.#recording) await this.stop()\n\t\tconst replaying = this.#archive !== undefined\n\t\tthis.#archive = undefined\n\t\tthis.#fallback = false\n\t\tif (replaying) await this.#network.unroute(this.#replayHandler)\n\t\tthis.#entries.length = 0\n\t\tthis.#pending.clear()\n\t}\n\n\t#handleRequest(request: BrowserRequest): void {\n\t\tif (!this.#recording) return\n\t\tthis.#pending.set(request.id, {\n\t\t\trequest,\n\t\t\tstarted: request.walltime === undefined ? Date.now() : request.walltime * 1000,\n\t\t\tresponse: undefined,\n\t\t})\n\t}\n\n\t#handleResponse(response: BrowserResponse): void {\n\t\tconst pending = this.#pending.get(response.id)\n\t\tif (pending === undefined) return\n\t\tthis.#pending.set(response.id, {\n\t\t\trequest: pending.request,\n\t\t\tstarted: pending.started,\n\t\t\tresponse,\n\t\t})\n\t}\n\n\t#handleFailure(failure: BrowserRequestFailure): void {\n\t\tconst pending = this.#pending.get(failure.id)\n\t\tif (pending === undefined) return\n\t\tthis.#pending.delete(failure.id)\n\t\tthis.#entries.push(\n\t\t\tcreateBrowserHAREntry(\n\t\t\t\tpending,\n\t\t\t\tMath.max(0, Date.now() - pending.started),\n\t\t\t\tundefined,\n\t\t\t\tfailure.error,\n\t\t\t),\n\t\t)\n\t}\n\n\t#handleFinish(id: string): void {\n\t\tthis.#track(this.#complete(id))\n\t}\n\n\tasync #handleReplay(route: Parameters<BrowserRouteHandler>[0]): Promise<void> {\n\t\tconst entry = this.#archive?.log.entries.find(\n\t\t\t(candidate) =>\n\t\t\t\tcandidate.request.url === route.request.url &&\n\t\t\t\tcandidate.request.method === route.request.method,\n\t\t)\n\t\tif (entry === undefined || entry.response.status === 0) {\n\t\t\tif (this.#fallback) await route.continue()\n\t\t\telse await route.abort('Failed')\n\t\t\treturn\n\t\t}\n\t\tconst body =\n\t\t\tentry.response.content.text === undefined\n\t\t\t\t? undefined\n\t\t\t\t: entry.response.content.encoding === 'base64'\n\t\t\t\t\t? decodeBase64(entry.response.content.text)\n\t\t\t\t\t: entry.response.content.text\n\t\tawait route.fulfill({\n\t\t\tstatus: entry.response.status,\n\t\t\tphrase: entry.response.statusText,\n\t\t\theaders: browserHARHeadersToRecord(entry.response.headers),\n\t\t\t...(body !== undefined ? { body } : {}),\n\t\t})\n\t}\n\n\tasync #complete(id: string): Promise<void> {\n\t\tconst pending = this.#pending.get(id)\n\t\tif (pending === undefined) return\n\t\tthis.#pending.delete(id)\n\t\tlet body: Uint8Array | undefined\n\t\tif (this.#options?.content === true && pending.response !== undefined) {\n\t\t\ttry {\n\t\t\t\tbody = await this.#network.body(id)\n\t\t\t} catch {\n\t\t\t\t// Some redirects, cached resources, and protocol errors have no retrievable body.\n\t\t\t}\n\t\t}\n\t\tthis.#entries.push(\n\t\t\tcreateBrowserHAREntry(pending, Math.max(0, Date.now() - pending.started), body),\n\t\t)\n\t}\n\n\t#track(task: Promise<void>): void {\n\t\tthis.#tasks.add(task)\n\t\tvoid task\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tif (this.#failure === undefined) this.#failure = error\n\t\t\t})\n\t\t\t.finally(() => this.#tasks.delete(task))\n\t}\n}\n","import type {\n\tBrowserFrameInterface,\n\tBrowserRequest,\n\tBrowserRouteContinueOptions,\n\tBrowserRouteFulfillOptions,\n\tBrowserRouteInterface,\n} from './types.js'\nimport { browserHeadersToProtocol, encodeBase64, textToBytes } from './helpers.js'\nimport { BrowserError } from './errors.js'\nimport { isInteger, isString } from '@orkestrel/contract'\n\n/**\n * Represents one paused request that can be aborted, continued, or fulfilled exactly once.\n */\nexport class BrowserRoute implements BrowserRouteInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #id: string\n\treadonly #request: BrowserRequest\n\t#handled = false\n\t#handling = false\n\n\tconstructor(frame: BrowserFrameInterface, id: string, request: BrowserRequest) {\n\t\tthis.#frame = frame\n\t\tthis.#id = id\n\t\tthis.#request = request\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget request(): BrowserRequest {\n\t\treturn this.#request\n\t}\n\n\tget handled(): boolean {\n\t\treturn this.#handled\n\t}\n\n\tasync abort(reason = 'Failed'): Promise<void> {\n\t\tthis.#assert()\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('Fetch.failRequest', {\n\t\t\t\trequestId: this.#id,\n\t\t\t\terrorReason: reason,\n\t\t\t})\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\tasync continue(options?: BrowserRouteContinueOptions): Promise<void> {\n\t\tthis.#assert()\n\t\tconst params: Record<string, unknown> = { requestId: this.#id }\n\t\tif (options?.url !== undefined) params['url'] = options.url\n\t\tif (options?.method !== undefined) params['method'] = options.method\n\t\tif (options?.headers !== undefined) {\n\t\t\tparams['headers'] = browserHeadersToProtocol(options.headers)\n\t\t}\n\t\tif (options?.post !== undefined) {\n\t\t\tparams['postData'] = encodeBase64(textToBytes(options.post))\n\t\t}\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('Fetch.continueRequest', params)\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\tasync fulfill(options: BrowserRouteFulfillOptions): Promise<void> {\n\t\tthis.#assert()\n\t\tconst status = options.status ?? 200\n\t\tif (!isInteger(status) || status < 100 || status > 999) {\n\t\t\tthrow new BrowserError('Browser route status must be an integer from 100 to 999', undefined, {\n\t\t\t\tstatus,\n\t\t\t})\n\t\t}\n\t\tconst params: Record<string, unknown> = {\n\t\t\trequestId: this.#id,\n\t\t\tresponseCode: status,\n\t\t}\n\t\tif (options.phrase !== undefined) params['responsePhrase'] = options.phrase\n\t\tif (options.headers !== undefined) {\n\t\t\tparams['responseHeaders'] = browserHeadersToProtocol(options.headers)\n\t\t}\n\t\tif (options.body !== undefined) {\n\t\t\tparams['body'] = encodeBase64(\n\t\t\t\tisString(options.body) ? textToBytes(options.body) : options.body,\n\t\t\t)\n\t\t}\n\t\tthis.#handling = true\n\t\ttry {\n\t\t\tawait this.#frame.send('Fetch.fulfillRequest', params)\n\t\t\tthis.#handled = true\n\t\t} finally {\n\t\t\tthis.#handling = false\n\t\t}\n\t}\n\n\t#assert(): void {\n\t\tif (this.#handled || this.#handling) throw new BrowserError('Browser route is already handled')\n\t}\n}\n","import type {\n\tBrowserWebSocketEventMap,\n\tBrowserWebSocketFrame,\n\tBrowserWebSocketInterface,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { Emitter } from '@orkestrel/emitter'\n\n/**\n * Represents an observable WebSocket connection reconstructed from Network-domain events.\n *\n * @example\n * ```ts\n * import { BrowserWebSocket } from '@orkestrel/browser'\n *\n * const socket = new BrowserWebSocket('request-1', 'wss://example.com/live')\n * socket.emitter.on('receive', (frame) => log(frame.data))\n * ```\n */\nexport class BrowserWebSocket implements BrowserWebSocketInterface {\n\treadonly #emitter: Emitter<BrowserWebSocketEventMap>\n\treadonly #id: string\n\treadonly #url: string\n\t#closed = false\n\n\tconstructor(id: string, url: string) {\n\t\tthis.#id = id\n\t\tthis.#url = url\n\t\tthis.#emitter = new Emitter()\n\t}\n\n\tget emitter(): EmitterInterface<BrowserWebSocketEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget url(): string {\n\t\treturn this.#url\n\t}\n\n\treceive(frame: BrowserWebSocketFrame): void {\n\t\tif (!this.#closed) this.#emitter.emit('receive', frame)\n\t}\n\n\ttransmit(frame: BrowserWebSocketFrame): void {\n\t\tif (!this.#closed) this.#emitter.emit('transmit', frame)\n\t}\n\n\tfail(message: string): void {\n\t\tif (!this.#closed) this.#emitter.emit('error', message)\n\t}\n\n\tclose(timestamp: number): void {\n\t\tif (this.#closed) return\n\t\tthis.#closed = true\n\t\tthis.#emitter.emit('close', timestamp)\n\t\tthis.#emitter.destroy()\n\t}\n}\n","import type {\n\tBrowserCredentials,\n\tBrowserFrameInterface,\n\tBrowserHARManagerInterface,\n\tBrowserNetworkEventMap,\n\tBrowserNetworkManagerInterface,\n\tBrowserRouteDefinition,\n\tBrowserRouteHandler,\n\tBrowserRouteQuery,\n\tBrowserWriterInterface,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { BrowserTransition } from './BrowserTransition.js'\nimport { BrowserHARManager } from './BrowserHARManager.js'\nimport { BrowserRoute } from './BrowserRoute.js'\nimport { BrowserWebSocket } from './BrowserWebSocket.js'\nimport {\n\tbytesToText,\n\tdecodeBase64,\n\tmatchesBrowserRoute,\n\tsettleBrowserTeardown,\n\ttextToBytes,\n} from './helpers.js'\nimport {\n\tparseBrowserRequest,\n\tparseBrowserRequestFailure,\n\tparseBrowserResponse,\n\tparseBrowserWebSocketFrame,\n} from './parsers.js'\nimport { BrowserError } from './errors.js'\nimport { attempt, isFiniteNumber, isRecord, isString } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\n\n/**\n * Drives the page-scoped Network and Fetch domain lifecycle.\n *\n * @example\n * ```ts\n * import { BrowserNetworkManager } from '@orkestrel/browser'\n *\n * const network = new BrowserNetworkManager(page)\n * await network.start()\n * network.emitter.on('response', (response) => log(response.status))\n * await network.destroy()\n * ```\n */\nexport class BrowserNetworkManager implements BrowserNetworkManagerInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #emitter: Emitter<BrowserNetworkEventMap>\n\treadonly #har: BrowserHARManager\n\treadonly #routes: BrowserRouteDefinition[] = []\n\treadonly #sockets: Map<string, BrowserWebSocket> = new Map()\n\t#credentials: BrowserCredentials | undefined\n\t#started = false\n\t#intercepting = false\n\t#destroyed = false\n\treadonly #starting: BrowserTransition = new BrowserTransition()\n\treadonly #requestHandler = this.#handleRequest.bind(this)\n\treadonly #responseHandler = this.#handleResponse.bind(this)\n\treadonly #failureHandler = this.#handleFailure.bind(this)\n\treadonly #finishHandler = this.#handleFinish.bind(this)\n\treadonly #pausedHandler = this.#handlePause.bind(this)\n\treadonly #authHandler = this.#handleAuth.bind(this)\n\treadonly #socketHandler = this.#handleSocket.bind(this)\n\treadonly #socketReceiveHandler = this.#handleSocketReceive.bind(this)\n\treadonly #socketTransmitHandler = this.#handleSocketTransmit.bind(this)\n\treadonly #socketErrorHandler = this.#handleSocketError.bind(this)\n\treadonly #socketCloseHandler = this.#handleSocketClose.bind(this)\n\n\tconstructor(frame: BrowserFrameInterface, writer?: BrowserWriterInterface) {\n\t\tthis.#frame = frame\n\t\tthis.#emitter = new Emitter()\n\t\tthis.#har = new BrowserHARManager(this, writer)\n\t}\n\n\tget emitter(): EmitterInterface<BrowserNetworkEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget har(): BrowserHARManagerInterface {\n\t\treturn this.#har\n\t}\n\n\tasync start(): Promise<void> {\n\t\tif (this.#destroyed) throw new BrowserError('Browser network manager is destroyed')\n\t\tif (this.#started) return\n\t\tconst active = this.#starting.pending\n\t\tif (active !== undefined) {\n\t\t\tawait active\n\t\t\treturn\n\t\t}\n\t\tawait this.#starting.execute(() => this.#start())\n\t}\n\n\tasync body(id: string): Promise<Uint8Array> {\n\t\tawait this.start()\n\t\tconst result = await this.#frame.send('Network.getResponseBody', { requestId: id })\n\t\tif (!isRecord(result) || !isString(result['body'])) {\n\t\t\tthrow new BrowserError('Browser response body is malformed', undefined, { id })\n\t\t}\n\t\treturn result['base64Encoded'] === true\n\t\t\t? decodeBase64(result['body'])\n\t\t\t: textToBytes(result['body'])\n\t}\n\n\tasync text(id: string): Promise<string> {\n\t\treturn bytesToText(await this.body(id))\n\t}\n\n\tasync json(id: string): Promise<unknown> {\n\t\tconst text = await this.text(id)\n\t\tconst result = attempt<unknown>(() => JSON.parse(text))\n\t\tif (result.success) return result.value\n\t\tthrow new BrowserError('Browser response body is not valid JSON', 'BROWSER_JSON_ERROR', {\n\t\t\tid,\n\t\t\terror: result.error,\n\t\t})\n\t}\n\n\tasync route(query: BrowserRouteQuery, handler: BrowserRouteHandler): Promise<void> {\n\t\tawait this.start()\n\t\tconst definition = { query, handler }\n\t\tthis.#routes.push(definition)\n\t\ttry {\n\t\t\tawait this.#configure()\n\t\t} catch (error) {\n\t\t\tthis.#routes.splice(this.#routes.indexOf(definition), 1)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync unroute(handler?: BrowserRouteHandler): Promise<void> {\n\t\tif (handler === undefined) {\n\t\t\tthis.#routes.length = 0\n\t\t} else {\n\t\t\tfor (let index = this.#routes.length - 1; index >= 0; index -= 1) {\n\t\t\t\tif (this.#routes[index]?.handler === handler) this.#routes.splice(index, 1)\n\t\t\t}\n\t\t}\n\t\tif (this.#started && !this.#destroyed) await this.#configure()\n\t}\n\n\tasync headers(headers: Readonly<Record<string, string>>): Promise<void> {\n\t\tawait this.start()\n\t\tawait this.#frame.send('Network.setExtraHTTPHeaders', { headers })\n\t}\n\n\tasync offline(offline: boolean): Promise<void> {\n\t\tawait this.start()\n\t\tawait this.#frame.send('Network.emulateNetworkConditions', {\n\t\t\toffline,\n\t\t\tlatency: 0,\n\t\t\tdownloadThroughput: -1,\n\t\t\tuploadThroughput: -1,\n\t\t})\n\t}\n\n\tasync credentials(credentials?: BrowserCredentials): Promise<void> {\n\t\tawait this.start()\n\t\tconst previous = this.#credentials\n\t\tthis.#credentials = credentials\n\t\ttry {\n\t\t\tawait this.#configure()\n\t\t} catch (error) {\n\t\t\tthis.#credentials = previous\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tif (this.#destroyed) return\n\t\tthis.#destroyed = true\n\t\tconst failure = await settleBrowserTeardown(\n\t\t\t() => this.#har.clear(),\n\t\t\tasync () => {\n\t\t\t\tif (this.#intercepting) await this.#frame.send('Fetch.disable')\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tif (this.#started) await this.#frame.send('Network.disable')\n\t\t\t},\n\t\t\t() => this.#unsubscribe(),\n\t\t)\n\t\tfor (const socket of this.#sockets.values()) socket.close(Date.now() / 1000)\n\t\tthis.#sockets.clear()\n\t\tthis.#routes.length = 0\n\t\tthis.#emitter.destroy()\n\t\tif (failure !== undefined) throw failure\n\t}\n\n\t#handleRequest(params: Readonly<Record<string, unknown>>): void {\n\t\tconst request = parseBrowserRequest(params)\n\t\tif (request !== undefined) this.#emitter.emit('request', request)\n\t}\n\n\t#handleResponse(params: Readonly<Record<string, unknown>>): void {\n\t\tconst response = parseBrowserResponse(params)\n\t\tif (response !== undefined) this.#emitter.emit('response', response)\n\t}\n\n\t#handleFailure(params: Readonly<Record<string, unknown>>): void {\n\t\tconst failure = parseBrowserRequestFailure(params)\n\t\tif (failure !== undefined) this.#emitter.emit('failure', failure)\n\t}\n\n\t#handleFinish(params: Readonly<Record<string, unknown>>): void {\n\t\tif (isString(params['requestId'])) this.#emitter.emit('finish', params['requestId'])\n\t}\n\n\t#handlePause(params: Readonly<Record<string, unknown>>): void {\n\t\tvoid this.#route(params).catch(() => undefined)\n\t}\n\n\t#handleAuth(params: Readonly<Record<string, unknown>>): void {\n\t\tvoid this.#authenticate(params).catch(() => undefined)\n\t}\n\n\t#handleSocket(params: Readonly<Record<string, unknown>>): void {\n\t\tif (!isString(params['requestId']) || !isString(params['url'])) return\n\t\tconst socket = new BrowserWebSocket(params['requestId'], params['url'])\n\t\tthis.#sockets.set(socket.id, socket)\n\t\tthis.#emitter.emit('socket', socket)\n\t}\n\n\t#handleSocketReceive(params: Readonly<Record<string, unknown>>): void {\n\t\tconst socket = isString(params['requestId'])\n\t\t\t? this.#sockets.get(params['requestId'])\n\t\t\t: undefined\n\t\tconst frame = parseBrowserWebSocketFrame(params)\n\t\tif (socket !== undefined && frame !== undefined) socket.receive(frame)\n\t}\n\n\t#handleSocketTransmit(params: Readonly<Record<string, unknown>>): void {\n\t\tconst socket = isString(params['requestId'])\n\t\t\t? this.#sockets.get(params['requestId'])\n\t\t\t: undefined\n\t\tconst frame = parseBrowserWebSocketFrame(params)\n\t\tif (socket !== undefined && frame !== undefined) socket.transmit(frame)\n\t}\n\n\t#handleSocketError(params: Readonly<Record<string, unknown>>): void {\n\t\tconst socket = isString(params['requestId'])\n\t\t\t? this.#sockets.get(params['requestId'])\n\t\t\t: undefined\n\t\tif (socket !== undefined && isString(params['errorMessage']))\n\t\t\tsocket.fail(params['errorMessage'])\n\t}\n\n\t#handleSocketClose(params: Readonly<Record<string, unknown>>): void {\n\t\tif (!isString(params['requestId'])) return\n\t\tconst socket = this.#sockets.get(params['requestId'])\n\t\tif (socket === undefined) return\n\t\tthis.#sockets.delete(params['requestId'])\n\t\tsocket.close(isFiniteNumber(params['timestamp']) ? params['timestamp'] : Date.now() / 1000)\n\t}\n\n\tasync #start(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#subscribe()\n\t\t\tawait this.#frame.send('Network.enable')\n\t\t\tthis.#started = true\n\t\t\tawait this.#configure()\n\t\t} catch (error) {\n\t\t\tthis.#started = false\n\t\t\tthis.#intercepting = false\n\t\t\tawait this.#frame.send('Fetch.disable').catch(() => undefined)\n\t\t\tawait this.#frame.send('Network.disable').catch(() => undefined)\n\t\t\tawait this.#unsubscribe().catch(() => undefined)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #configure(): Promise<void> {\n\t\tconst enabled = this.#routes.length > 0 || this.#credentials !== undefined\n\t\tif (!enabled) {\n\t\t\tif (this.#intercepting) {\n\t\t\t\tawait this.#frame.send('Fetch.disable')\n\t\t\t\tthis.#intercepting = false\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tawait this.#frame.send('Fetch.enable', {\n\t\t\tpatterns: this.#routes.map((definition) => ({\n\t\t\t\turlPattern: definition.query.url ?? '*',\n\t\t\t\tresourceType: definition.query.resource,\n\t\t\t\trequestStage: 'Request',\n\t\t\t})),\n\t\t\thandleAuthRequests: this.#credentials !== undefined,\n\t\t})\n\t\tthis.#intercepting = true\n\t}\n\n\tasync #route(params: Readonly<Record<string, unknown>>): Promise<void> {\n\t\tconst request = parseBrowserRequest(params)\n\t\tif (request === undefined) {\n\t\t\tif (isString(params['requestId'])) {\n\t\t\t\tawait this.#frame.send('Fetch.failRequest', {\n\t\t\t\t\trequestId: params['requestId'],\n\t\t\t\t\terrorReason: 'Failed',\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tconst definition = this.#routes.find((candidate) =>\n\t\t\tmatchesBrowserRoute(request, candidate.query),\n\t\t)\n\t\tif (definition === undefined) {\n\t\t\tawait this.#frame.send('Fetch.continueRequest', { requestId: request.id })\n\t\t\treturn\n\t\t}\n\t\tconst route = new BrowserRoute(this.#frame, request.id, request)\n\t\ttry {\n\t\t\tawait definition.handler(route)\n\t\t\tif (!route.handled) await route.continue()\n\t\t} catch {\n\t\t\tif (!route.handled) await route.abort('Failed').catch(() => undefined)\n\t\t}\n\t}\n\n\tasync #authenticate(params: Readonly<Record<string, unknown>>): Promise<void> {\n\t\tconst id = params['requestId']\n\t\tif (!isString(id)) return\n\t\tconst credentials = this.#credentials\n\t\tawait this.#frame.send('Fetch.continueWithAuth', {\n\t\t\trequestId: id,\n\t\t\tauthChallengeResponse:\n\t\t\t\tcredentials === undefined\n\t\t\t\t\t? { response: 'Default' }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tresponse: 'ProvideCredentials',\n\t\t\t\t\t\t\tusername: credentials.username,\n\t\t\t\t\t\t\tpassword: credentials.password,\n\t\t\t\t\t\t},\n\t\t})\n\t}\n\n\tasync #subscribe(): Promise<void> {\n\t\tawait this.#frame.subscribe('Network.requestWillBeSent', this.#requestHandler)\n\t\tawait this.#frame.subscribe('Network.responseReceived', this.#responseHandler)\n\t\tawait this.#frame.subscribe('Network.loadingFailed', this.#failureHandler)\n\t\tawait this.#frame.subscribe('Network.loadingFinished', this.#finishHandler)\n\t\tawait this.#frame.subscribe('Fetch.requestPaused', this.#pausedHandler)\n\t\tawait this.#frame.subscribe('Fetch.authRequired', this.#authHandler)\n\t\tawait this.#frame.subscribe('Network.webSocketCreated', this.#socketHandler)\n\t\tawait this.#frame.subscribe('Network.webSocketFrameReceived', this.#socketReceiveHandler)\n\t\tawait this.#frame.subscribe('Network.webSocketFrameSent', this.#socketTransmitHandler)\n\t\tawait this.#frame.subscribe('Network.webSocketFrameError', this.#socketErrorHandler)\n\t\tawait this.#frame.subscribe('Network.webSocketClosed', this.#socketCloseHandler)\n\t}\n\n\tasync #unsubscribe(): Promise<void> {\n\t\tawait this.#frame.unsubscribe('Network.requestWillBeSent', this.#requestHandler)\n\t\tawait this.#frame.unsubscribe('Network.responseReceived', this.#responseHandler)\n\t\tawait this.#frame.unsubscribe('Network.loadingFailed', this.#failureHandler)\n\t\tawait this.#frame.unsubscribe('Network.loadingFinished', this.#finishHandler)\n\t\tawait this.#frame.unsubscribe('Fetch.requestPaused', this.#pausedHandler)\n\t\tawait this.#frame.unsubscribe('Fetch.authRequired', this.#authHandler)\n\t\tawait this.#frame.unsubscribe('Network.webSocketCreated', this.#socketHandler)\n\t\tawait this.#frame.unsubscribe('Network.webSocketFrameReceived', this.#socketReceiveHandler)\n\t\tawait this.#frame.unsubscribe('Network.webSocketFrameSent', this.#socketTransmitHandler)\n\t\tawait this.#frame.unsubscribe('Network.webSocketFrameError', this.#socketErrorHandler)\n\t\tawait this.#frame.unsubscribe('Network.webSocketClosed', this.#socketCloseHandler)\n\t}\n}\n","import type {\n\tBrowserCallOptions,\n\tBrowserDestination,\n\tBrowserNavigationEventMap,\n\tBrowserNavigationReason,\n\tBrowserNavigationRecordInterface,\n\tBrowserSettlementOptions,\n\tBrowserSettlementResult,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { BROWSER_DEFAULT_TIMEOUT_MS } from './constants.js'\nimport { BrowserError } from './errors.js'\nimport { validateBrowserTimeout } from './helpers.js'\n\n/**\n * Records the navigation steps a page accepts after it opens and settles the navigation an input\n * into one frame started.\n *\n * @remarks\n * `BrowserNavigationManager.record` constructs it over the page's navigation steps, the main\n * frame's id, and a lookup of the parent the page last recorded for a frame, which returns\n * `undefined` for a frame whose parent the page cannot name. `lifetime` aborts when the page\n * closes, with the error the record's pending waits reject with.\n *\n * @example\n * ```ts\n * const record = page.navigation.record(element.frame)\n * await element.click()\n * const settled = await record.settle({ destinations, timeout: 4_000 })\n * record.destroy()\n * ```\n */\nexport class BrowserNavigationRecord implements BrowserNavigationRecordInterface {\n\treadonly #steps: EmitterInterface<BrowserNavigationEventMap>\n\treadonly #main: string\n\treadonly #parent: (frame: string) => string | undefined\n\treadonly #frame: string\n\treadonly #lifetime: AbortSignal\n\t// Every step accepted since the record opened, in arrival order, so a settlement that learns its\n\t// destinations after the input selects among the steps that preceded it.\n\treadonly #log: Array<\n\t\t| {\n\t\t\t\treadonly event: 'request'\n\t\t\t\treadonly frame: string\n\t\t\t\treadonly url: string\n\t\t\t\treadonly loader: string | undefined\n\t\t\t\treadonly reason: BrowserNavigationReason | undefined\n\t\t }\n\t\t| {\n\t\t\t\treadonly event: 'commit'\n\t\t\t\treadonly frame: string\n\t\t\t\treadonly url: string\n\t\t\t\treadonly loader: string | undefined\n\t\t\t\treadonly same: boolean\n\t\t }\n\t\t| { readonly event: 'load'; readonly frame: string; readonly loader: string | undefined }\n\t\t| { readonly event: 'detach'; readonly frame: string; readonly swapped: boolean }\n\t> = []\n\treadonly #waits = new Map<\n\t\tsymbol,\n\t\t{\n\t\t\treadonly timer: ReturnType<typeof setTimeout>\n\t\t\treadonly signal: AbortSignal | undefined\n\t\t\treadonly listener: (() => void) | undefined\n\t\t\treadonly resolve: () => void\n\t\t\treadonly reject: (error: unknown) => void\n\t\t}\n\t>()\n\treadonly #settlements = new Map<\n\t\tsymbol,\n\t\t{\n\t\t\treadonly frames: ReadonlySet<string>\n\t\t\treadonly any: boolean\n\t\t\treadonly timer: ReturnType<typeof setTimeout>\n\t\t\treadonly signal: AbortSignal | undefined\n\t\t\treadonly listener: (() => void) | undefined\n\t\t\treadonly resolve: (result: BrowserSettlementResult | undefined) => void\n\t\t\treadonly reject: (error: unknown) => void\n\t\t}\n\t>()\n\t#ended: { readonly reason: unknown } | undefined\n\treadonly #requestHandler = this.#handleRequest.bind(this)\n\treadonly #commitHandler = this.#handleCommit.bind(this)\n\treadonly #loadHandler = this.#handleLoad.bind(this)\n\treadonly #detachHandler = this.#handleDetach.bind(this)\n\treadonly #closeHandler = this.#handleClose.bind(this)\n\n\tconstructor(\n\t\tsteps: EmitterInterface<BrowserNavigationEventMap>,\n\t\tmain: string,\n\t\tparent: (frame: string) => string | undefined,\n\t\tframe: string,\n\t\tlifetime: AbortSignal,\n\t) {\n\t\tthis.#steps = steps\n\t\tthis.#main = main\n\t\tthis.#parent = parent\n\t\tthis.#frame = frame\n\t\tthis.#lifetime = lifetime\n\t\tif (lifetime.aborted) {\n\t\t\tthis.#ended = { reason: lifetime.reason }\n\t\t\treturn\n\t\t}\n\t\tsteps.on('request', this.#requestHandler)\n\t\tsteps.on('commit', this.#commitHandler)\n\t\tsteps.on('load', this.#loadHandler)\n\t\tsteps.on('detach', this.#detachHandler)\n\t\tlifetime.addEventListener('abort', this.#closeHandler, { once: true })\n\t}\n\n\tasync wait(options?: BrowserCallOptions): Promise<void> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst signal = options?.signal\n\t\tif (this.#ended !== undefined) throw this.#ended.reason\n\t\tif (signal?.aborted === true) throw signal.reason\n\t\tif (this.#started()) return\n\t\tconst deferred = Promise.withResolvers<void>()\n\t\tconst id = Symbol('wait')\n\t\tconst listener = signal === undefined ? undefined : this.#abortWait.bind(this, id, signal)\n\t\tif (listener !== undefined) signal?.addEventListener('abort', listener, { once: true })\n\t\tthis.#waits.set(id, {\n\t\t\ttimer: setTimeout(this.#expireWait.bind(this, id, timeout), timeout),\n\t\t\tsignal,\n\t\t\tlistener,\n\t\t\tresolve: deferred.resolve,\n\t\t\treject: deferred.reject,\n\t\t})\n\t\treturn await deferred.promise\n\t}\n\n\tasync settle(options?: BrowserSettlementOptions): Promise<BrowserSettlementResult | undefined> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst signal = options?.signal\n\t\tif (this.#ended !== undefined) throw this.#ended.reason\n\t\tif (signal?.aborted === true) throw signal.reason\n\t\tconst destinations = options?.destinations ?? []\n\t\tconst [frames, any] = this.#resolveFrames(destinations)\n\t\tconst selection = this.#select(frames, any)\n\t\t// Without a destination, a navigation that has not started when the settlement begins was not\n\t\t// the input's.\n\t\tif (selection.done || (selection.result === undefined && destinations.length === 0))\n\t\t\treturn selection.result\n\t\tconst deferred = Promise.withResolvers<BrowserSettlementResult | undefined>()\n\t\tconst id = Symbol('settle')\n\t\tconst listener = signal === undefined ? undefined : this.#abortSettlement.bind(this, id, signal)\n\t\tif (listener !== undefined) signal?.addEventListener('abort', listener, { once: true })\n\t\tthis.#settlements.set(id, {\n\t\t\tframes,\n\t\t\tany,\n\t\t\ttimer: setTimeout(this.#expireSettlement.bind(this, id), timeout),\n\t\t\tsignal,\n\t\t\tlistener,\n\t\t\tresolve: deferred.resolve,\n\t\t\treject: deferred.reject,\n\t\t})\n\t\treturn await deferred.promise\n\t}\n\n\tdestroy(): void {\n\t\tthis.#end(new BrowserError('Browser navigation record ended'))\n\t}\n\n\t#end(reason: unknown): void {\n\t\tif (this.#ended !== undefined) return\n\t\tthis.#ended = { reason }\n\t\tthis.#steps.off('request', this.#requestHandler)\n\t\tthis.#steps.off('commit', this.#commitHandler)\n\t\tthis.#steps.off('load', this.#loadHandler)\n\t\tthis.#steps.off('detach', this.#detachHandler)\n\t\tthis.#lifetime.removeEventListener('abort', this.#closeHandler)\n\t\tfor (const id of [...this.#waits.keys()]) this.#releaseWait(id)?.reject(reason)\n\t\tfor (const id of [...this.#settlements.keys()]) this.#releaseSettlement(id)?.reject(reason)\n\t}\n\n\t// The record's frame and every ancestor the page names, and the main frame, which is every\n\t// frame's ancestor.\n\t#collectAncestors(): Set<string> {\n\t\tconst frames = new Set<string>([this.#main])\n\t\tlet current: string | undefined = this.#frame\n\t\twhile (current !== undefined && !frames.has(current)) {\n\t\t\tframes.add(current)\n\t\t\tcurrent = this.#parent(current)\n\t\t}\n\t\tframes.add(this.#frame)\n\t\treturn frames\n\t}\n\n\t// Resolves each destination to the frame it names; a parent the page cannot name makes every\n\t// frame eligible, and never stands for the main frame.\n\t#resolveFrames(\n\t\tdestinations: readonly BrowserDestination[],\n\t): readonly [frames: ReadonlySet<string>, any: boolean] {\n\t\tconst frames = this.#collectAncestors()\n\t\tlet any = false\n\t\tfor (const { frame, relationship } of destinations) {\n\t\t\tif (relationship === 'top') frames.add(this.#main)\n\t\t\telse if (relationship === 'self') frames.add(frame)\n\t\t\telse if (frame === this.#main) frames.add(this.#main)\n\t\t\telse {\n\t\t\t\tconst parent = this.#parent(frame)\n\t\t\t\tif (parent === undefined) any = true\n\t\t\t\telse frames.add(parent)\n\t\t\t}\n\t\t}\n\t\treturn [frames, any]\n\t}\n\n\t#started(): boolean {\n\t\tconst frames = this.#collectAncestors()\n\t\treturn this.#log.some((step) => step.event === 'request' && frames.has(step.frame))\n\t}\n\n\t// Replays the log against the eligible frames: the earliest eligible start, superseded by a\n\t// later start in its frame before the commit; the commit that carries its loader, or the\n\t// frame's first commit when either loader is unknown; and the load of the commit's loader, or a\n\t// same-document commit. `done` reports a completed navigation or a selected frame that detached.\n\t#select(\n\t\tframes: ReadonlySet<string>,\n\t\tany: boolean,\n\t): { readonly done: boolean; readonly result: BrowserSettlementResult | undefined } {\n\t\tlet start:\n\t\t\t| {\n\t\t\t\t\treadonly frame: string\n\t\t\t\t\treadonly url: string\n\t\t\t\t\treadonly loader: string | undefined\n\t\t\t\t\treadonly reason: BrowserNavigationReason | undefined\n\t\t\t }\n\t\t\t| undefined\n\t\tlet commit: { readonly url: string; readonly loader: string | undefined } | undefined\n\t\tfor (const step of this.#log) {\n\t\t\tif (step.event === 'request') {\n\t\t\t\tif (\n\t\t\t\t\tstart === undefined\n\t\t\t\t\t\t? any || frames.has(step.frame)\n\t\t\t\t\t\t: step.frame === start.frame && commit === undefined\n\t\t\t\t)\n\t\t\t\t\tstart = step\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (start === undefined || step.frame !== start.frame) continue\n\t\t\tif (step.event === 'detach') {\n\t\t\t\tif (!step.swapped) return { done: true, result: this.#stage(start, commit, false) }\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (step.event === 'commit') {\n\t\t\t\tif (commit !== undefined) continue\n\t\t\t\tif (step.same)\n\t\t\t\t\treturn { done: true, result: { url: step.url, stage: 'loaded', reason: start.reason } }\n\t\t\t\tif (start.loader === undefined || step.loader === undefined || step.loader === start.loader)\n\t\t\t\t\tcommit = step\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (commit !== undefined && step.loader === commit.loader)\n\t\t\t\treturn { done: true, result: this.#stage(start, commit, true) }\n\t\t}\n\t\treturn { done: false, result: this.#stage(start, commit, false) }\n\t}\n\n\t#stage(\n\t\tstart:\n\t\t\t| { readonly url: string; readonly reason: BrowserNavigationReason | undefined }\n\t\t\t| undefined,\n\t\tcommit: { readonly url: string } | undefined,\n\t\tloaded: boolean,\n\t): BrowserSettlementResult | undefined {\n\t\tif (start === undefined) return undefined\n\t\tif (commit === undefined) return { url: start.url, stage: 'requested', reason: start.reason }\n\t\treturn { url: commit.url, stage: loaded ? 'loaded' : 'committed', reason: start.reason }\n\t}\n\n\t#wake(): void {\n\t\tif (this.#waits.size > 0 && this.#started())\n\t\t\tfor (const id of [...this.#waits.keys()]) this.#resolveWait(id)\n\t\tfor (const [id, settlement] of [...this.#settlements]) {\n\t\t\tconst selection = this.#select(settlement.frames, settlement.any)\n\t\t\tif (selection.done) this.#resolveSettlement(id, selection.result)\n\t\t}\n\t}\n\n\t// The resolution waits one microtask, so a cancellation that lands in the same turn as the step\n\t// that completed the wait wins with its reason.\n\t#resolveWait(id: symbol): void {\n\t\tconst wait = this.#releaseWait(id)\n\t\tif (wait !== undefined) queueMicrotask(this.#finishWait.bind(this, wait))\n\t}\n\n\t#finishWait(wait: {\n\t\treadonly signal: AbortSignal | undefined\n\t\treadonly resolve: () => void\n\t\treadonly reject: (error: unknown) => void\n\t}): void {\n\t\tif (wait.signal?.aborted === true) wait.reject(wait.signal.reason)\n\t\telse wait.resolve()\n\t}\n\n\t#resolveSettlement(id: symbol, result: BrowserSettlementResult | undefined): void {\n\t\tconst settlement = this.#releaseSettlement(id)\n\t\tif (settlement !== undefined)\n\t\t\tqueueMicrotask(this.#finishSettlement.bind(this, settlement, result))\n\t}\n\n\t#finishSettlement(\n\t\tsettlement: {\n\t\t\treadonly signal: AbortSignal | undefined\n\t\t\treadonly resolve: (result: BrowserSettlementResult | undefined) => void\n\t\t\treadonly reject: (error: unknown) => void\n\t\t},\n\t\tresult: BrowserSettlementResult | undefined,\n\t): void {\n\t\tif (settlement.signal?.aborted === true) settlement.reject(settlement.signal.reason)\n\t\telse settlement.resolve(result)\n\t}\n\n\t#expireWait(id: symbol, timeout: number): void {\n\t\tthis.#releaseWait(id)?.reject(\n\t\t\tnew BrowserError('Browser navigation wait timed out', 'BROWSER_NAVIGATION_TIMEOUT', {\n\t\t\t\tframe: this.#frame,\n\t\t\t\ttimeout,\n\t\t\t}),\n\t\t)\n\t}\n\n\t#expireSettlement(id: symbol): void {\n\t\tconst settlement = this.#settlements.get(id)\n\t\tif (settlement === undefined) return\n\t\tthis.#resolveSettlement(id, this.#select(settlement.frames, settlement.any).result)\n\t}\n\n\t#abortWait(id: symbol, signal: AbortSignal): void {\n\t\tthis.#releaseWait(id)?.reject(signal.reason)\n\t}\n\n\t#abortSettlement(id: symbol, signal: AbortSignal): void {\n\t\tthis.#releaseSettlement(id)?.reject(signal.reason)\n\t}\n\n\t#releaseWait(id: symbol):\n\t\t| {\n\t\t\t\treadonly signal: AbortSignal | undefined\n\t\t\t\treadonly resolve: () => void\n\t\t\t\treadonly reject: (error: unknown) => void\n\t\t }\n\t\t| undefined {\n\t\tconst wait = this.#waits.get(id)\n\t\tif (wait === undefined) return undefined\n\t\tclearTimeout(wait.timer)\n\t\tif (wait.listener !== undefined) wait.signal?.removeEventListener('abort', wait.listener)\n\t\tthis.#waits.delete(id)\n\t\treturn wait\n\t}\n\n\t#releaseSettlement(id: symbol):\n\t\t| {\n\t\t\t\treadonly signal: AbortSignal | undefined\n\t\t\t\treadonly resolve: (result: BrowserSettlementResult | undefined) => void\n\t\t\t\treadonly reject: (error: unknown) => void\n\t\t }\n\t\t| undefined {\n\t\tconst settlement = this.#settlements.get(id)\n\t\tif (settlement === undefined) return undefined\n\t\tclearTimeout(settlement.timer)\n\t\tif (settlement.listener !== undefined)\n\t\t\tsettlement.signal?.removeEventListener('abort', settlement.listener)\n\t\tthis.#settlements.delete(id)\n\t\treturn settlement\n\t}\n\n\t#handleRequest(\n\t\tframe: string,\n\t\turl: string,\n\t\tloader: string | undefined,\n\t\treason: BrowserNavigationReason | undefined,\n\t): void {\n\t\tthis.#log.push({ event: 'request', frame, url, loader, reason })\n\t\tthis.#wake()\n\t}\n\n\t#handleCommit(frame: string, url: string, loader: string | undefined, same: boolean): void {\n\t\tthis.#log.push({ event: 'commit', frame, url, loader, same })\n\t\tthis.#wake()\n\t}\n\n\t#handleLoad(frame: string, loader: string | undefined): void {\n\t\tthis.#log.push({ event: 'load', frame, loader })\n\t\tthis.#wake()\n\t}\n\n\t#handleDetach(frame: string, swapped: boolean): void {\n\t\tthis.#log.push({ event: 'detach', frame, swapped })\n\t\tthis.#wake()\n\t}\n\n\t#handleClose(): void {\n\t\tthis.#end(this.#lifetime.reason)\n\t}\n}\n","import type {\n\tBrowserCallOptions,\n\tBrowserLoaderFunction,\n\tBrowserNavigationEventMap,\n\tBrowserNavigationManagerInterface,\n\tBrowserNavigationRecordInterface,\n\tBrowserNavigationWait,\n\tBrowserPageInterface,\n\tCDPClientInterface,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { BrowserNavigationRecord } from './BrowserNavigationRecord.js'\nimport { BROWSER_DEFAULT_TIMEOUT_MS } from './constants.js'\nimport { matchesBrowserURL, validateBrowserTimeout } from './helpers.js'\nimport { BrowserError } from './errors.js'\nimport { isString } from '@orkestrel/contract'\n\n/**\n * Parks URL-pattern and network-idle waits on page events and abort signals, and opens the records\n * that settle the navigation an input starts.\n *\n * @remarks\n * `steps` carries the navigation steps the page accepts from the session that owns each frame,\n * and `parent` returns the parent the page last recorded for a frame, or `undefined` when the\n * page cannot name it. A record opened here rejects its pending waits with the page-closed error\n * when the page closes.\n *\n * @example\n * ```ts\n * import { BrowserNavigationManager } from '@orkestrel/browser'\n *\n * const navigation = new BrowserNavigationManager(page, client, 'session-1', () => loader, steps, parent)\n * const url = await navigation.wait('https://example.com/checkout', { timeout: 5_000 })\n * await navigation.idle({ signal: AbortSignal.timeout(10_000) })\n * const record = navigation.record(page.id)\n * ```\n */\nexport class BrowserNavigationManager implements BrowserNavigationManagerInterface {\n\treadonly #page: BrowserPageInterface\n\treadonly #client: CDPClientInterface\n\treadonly #session: string\n\treadonly #loader: BrowserLoaderFunction\n\treadonly #steps: EmitterInterface<BrowserNavigationEventMap>\n\treadonly #parent: (frame: string) => string | undefined\n\t// Aborts with the page-closed error when the page closes, which ends every record.\n\treadonly #lifetime = new AbortController()\n\treadonly #waits: Map<symbol, BrowserNavigationWait> = new Map()\n\treadonly #navigateHandler = this.#handleNavigate.bind(this)\n\treadonly #lifecycleHandler = this.#handleLifecycle.bind(this)\n\treadonly #closeHandler = this.#handleClose.bind(this)\n\n\tconstructor(\n\t\tpage: BrowserPageInterface,\n\t\tclient: CDPClientInterface,\n\t\tsession: string,\n\t\tloader: BrowserLoaderFunction,\n\t\tsteps: EmitterInterface<BrowserNavigationEventMap>,\n\t\tparent: (frame: string) => string | undefined,\n\t) {\n\t\tthis.#page = page\n\t\tthis.#client = client\n\t\tthis.#session = session\n\t\tthis.#loader = loader\n\t\tthis.#steps = steps\n\t\tthis.#parent = parent\n\t\tthis.#page.emitter.on('navigate', this.#navigateHandler)\n\t\tthis.#page.emitter.on('close', this.#closeHandler)\n\t\tthis.#client.subscribe('Page.lifecycleEvent', this.#lifecycleHandler, this.#session)\n\t}\n\n\tasync wait(pattern: string, options?: BrowserCallOptions): Promise<string> {\n\t\tconst timeout = this.#timeout(options)\n\t\tif (options?.signal?.aborted === true) throw options.signal.reason\n\t\tif (matchesBrowserURL(this.#page.url, pattern)) return this.#page.url\n\t\treturn await this.#park(pattern, timeout, options?.signal)\n\t}\n\n\tasync idle(options?: BrowserCallOptions): Promise<void> {\n\t\tconst timeout = this.#timeout(options)\n\t\tif (options?.signal?.aborted === true) throw options.signal.reason\n\t\tawait this.#park(undefined, timeout, options?.signal)\n\t}\n\n\trecord(frame: string): BrowserNavigationRecordInterface {\n\t\tthis.#page.assert()\n\t\treturn new BrowserNavigationRecord(\n\t\t\tthis.#steps,\n\t\t\tthis.#page.id,\n\t\t\tthis.#parent,\n\t\t\tframe,\n\t\t\tthis.#lifetime.signal,\n\t\t)\n\t}\n\n\t#park(pattern: string | undefined, timeout: number, signal?: AbortSignal): Promise<string> {\n\t\tconst deferred = Promise.withResolvers<string>()\n\t\tconst id = Symbol(pattern ?? 'idle')\n\t\tconst timer = setTimeout(() => {\n\t\t\tthis.#settle(id)\n\t\t\tdeferred.reject(\n\t\t\t\tnew BrowserError(\n\t\t\t\t\tpattern === undefined\n\t\t\t\t\t\t? 'Browser network idle wait timed out'\n\t\t\t\t\t\t: 'Browser URL wait timed out',\n\t\t\t\t\t'BROWSER_NAVIGATION_TIMEOUT',\n\t\t\t\t\t{ pattern, timeout },\n\t\t\t\t),\n\t\t\t)\n\t\t}, timeout)\n\t\tconst listener = signal === undefined ? undefined : this.#abort(id, signal, deferred.reject)\n\t\tif (listener !== undefined) signal?.addEventListener('abort', listener, { once: true })\n\t\tthis.#waits.set(id, {\n\t\t\tpattern,\n\t\t\ttimer,\n\t\t\tsignal,\n\t\t\tlistener,\n\t\t\tresolve: deferred.resolve,\n\t\t\treject: deferred.reject,\n\t\t})\n\t\treturn deferred.promise\n\t}\n\n\t#abort(id: symbol, signal: AbortSignal, reject: (error: unknown) => void): () => void {\n\t\treturn () => {\n\t\t\tthis.#settle(id)\n\t\t\treject(signal.reason)\n\t\t}\n\t}\n\n\t#settle(id: symbol): BrowserNavigationWait | undefined {\n\t\tconst wait = this.#waits.get(id)\n\t\tif (wait === undefined) return undefined\n\t\tclearTimeout(wait.timer)\n\t\tif (wait.listener !== undefined) wait.signal?.removeEventListener('abort', wait.listener)\n\t\tthis.#waits.delete(id)\n\t\treturn wait\n\t}\n\n\t#handleNavigate(url: string): void {\n\t\tfor (const [id, wait] of this.#waits) {\n\t\t\tif (wait.pattern === undefined || !matchesBrowserURL(url, wait.pattern)) continue\n\t\t\tthis.#settle(id)?.resolve(url)\n\t\t}\n\t}\n\n\t#handleLifecycle(params: Readonly<Record<string, unknown>>): void {\n\t\tconst loader = this.#loader()\n\t\tif (params['name'] !== 'networkIdle' || !isString(params['loaderId'])) return\n\t\tif (loader === undefined || params['loaderId'] !== loader) return\n\t\tfor (const [id, wait] of this.#waits) {\n\t\t\tif (wait.pattern !== undefined) continue\n\t\t\tthis.#settle(id)?.resolve(this.#page.url)\n\t\t}\n\t}\n\n\t#handleClose(): void {\n\t\tthis.#client.unsubscribe('Page.lifecycleEvent', this.#lifecycleHandler, this.#session)\n\t\tconst closed = new BrowserError('Browser navigation wait ended because the page closed')\n\t\tfor (const id of [...this.#waits.keys()]) this.#settle(id)?.reject(closed)\n\t\tthis.#lifetime.abort(closed)\n\t}\n\n\t#timeout(options?: BrowserCallOptions): number {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\treturn timeout\n\t}\n}\n","import type {\n\tBrowserBindingHandler,\n\tBrowserFrameInterface,\n\tBrowserScriptEntry,\n\tBrowserScriptManagerInterface,\n} from './types.js'\nimport {\n\tcompileBrowserBindingCleanup,\n\tcompileBrowserBindingResult,\n\tcompileBrowserBindingSource,\n} from './compilers.js'\nimport { readBrowserScriptIdentifier } from './helpers.js'\nimport { parseBrowserBindingCall } from './parsers.js'\nimport { BrowserError } from './errors.js'\n\n/**\n * Installs new-document scripts and promise-based host functions for one page.\n *\n * @example\n * ```ts\n * import { BrowserScriptManager } from '@orkestrel/browser'\n *\n * const scripts = new BrowserScriptManager(page)\n * const id = await scripts.add('window.__ready = true')\n * await scripts.remove(id)\n * ```\n */\nexport class BrowserScriptManager implements BrowserScriptManagerInterface {\n\treadonly #frame: BrowserFrameInterface\n\treadonly #bindings: Map<string, BrowserBindingHandler> = new Map()\n\treadonly #scripts: Map<string, BrowserScriptEntry> = new Map()\n\t#subscribed = false\n\t#destroyed = false\n\treadonly #bindingHandler = this.#handleBinding.bind(this)\n\n\tconstructor(frame: BrowserFrameInterface) {\n\t\tthis.#frame = frame\n\t}\n\n\tasync add(source: string): Promise<string> {\n\t\tthis.#assert()\n\t\tconst result = await this.#frame.send('Page.addScriptToEvaluateOnNewDocument', { source })\n\t\tconst id = readBrowserScriptIdentifier(result)\n\t\tthis.#scripts.set(id, { source, binding: undefined })\n\t\ttry {\n\t\t\tawait this.#frame.evaluate(`(() => { ${source}\\n })()`)\n\t\t\treturn id\n\t\t} catch (error) {\n\t\t\tawait this.#frame\n\t\t\t\t.send('Page.removeScriptToEvaluateOnNewDocument', { identifier: id })\n\t\t\t\t.catch(() => undefined)\n\t\t\tthis.#scripts.delete(id)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync remove(id: string): Promise<void> {\n\t\tthis.#assert()\n\t\tif (!this.#scripts.has(id)) return\n\t\tawait this.#frame.send('Page.removeScriptToEvaluateOnNewDocument', { identifier: id })\n\t\tthis.#scripts.delete(id)\n\t}\n\n\tasync expose(name: string, handler: BrowserBindingHandler): Promise<void> {\n\t\tthis.#assert()\n\t\tif (!/^[$A-Z_a-z][$\\w]*$/.test(name)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Browser binding name must be a valid JavaScript identifier',\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tname,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (this.#bindings.has(name)) {\n\t\t\tthrow new BrowserError('Browser binding already exists', undefined, { name })\n\t\t}\n\t\tconst subscribed = this.#subscribed\n\t\tif (!subscribed) {\n\t\t\tawait this.#frame.subscribe('Runtime.bindingCalled', this.#bindingHandler)\n\t\t\tthis.#subscribed = true\n\t\t}\n\t\tlet added = false\n\t\ttry {\n\t\t\tawait this.#frame.send('Runtime.addBinding', { name })\n\t\t\tadded = true\n\t\t\tconst id = await this.add(compileBrowserBindingSource(name))\n\t\t\tconst entry = this.#scripts.get(id)\n\t\t\tif (entry === undefined) {\n\t\t\t\tthrow new BrowserError('Browser binding script registration was lost', undefined, {\n\t\t\t\t\tname,\n\t\t\t\t})\n\t\t\t}\n\t\t\tthis.#scripts.set(id, { source: entry.source, binding: name })\n\t\t\tthis.#bindings.set(name, handler)\n\t\t} catch (error) {\n\t\t\tif (added) {\n\t\t\t\tawait this.#frame.send('Runtime.removeBinding', { name }).catch(() => undefined)\n\t\t\t}\n\t\t\tif (!subscribed && this.#bindings.size === 0) {\n\t\t\t\tawait this.#frame\n\t\t\t\t\t.unsubscribe('Runtime.bindingCalled', this.#bindingHandler)\n\t\t\t\t\t.catch(() => undefined)\n\t\t\t\tthis.#subscribed = false\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync revoke(name: string): Promise<void> {\n\t\tthis.#assert()\n\t\tif (!this.#bindings.has(name)) return\n\t\tfor (const [id, entry] of this.#scripts) {\n\t\t\tif (entry.binding !== name) continue\n\t\t\tawait this.#frame.send('Page.removeScriptToEvaluateOnNewDocument', { identifier: id })\n\t\t\tthis.#scripts.delete(id)\n\t\t}\n\t\tawait this.#frame.evaluate(compileBrowserBindingCleanup(name))\n\t\tawait this.#frame.send('Runtime.removeBinding', { name })\n\t\tthis.#bindings.delete(name)\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tif (this.#destroyed) return\n\t\tfor (const name of [...this.#bindings.keys()]) {\n\t\t\tawait this.revoke(name).catch(() => undefined)\n\t\t}\n\t\tfor (const id of [...this.#scripts.keys()]) {\n\t\t\tawait this.remove(id).catch(() => undefined)\n\t\t}\n\t\tif (this.#subscribed) {\n\t\t\tawait this.#frame\n\t\t\t\t.unsubscribe('Runtime.bindingCalled', this.#bindingHandler)\n\t\t\t\t.catch(() => undefined)\n\t\t}\n\t\tthis.#subscribed = false\n\t\tthis.#destroyed = true\n\t}\n\n\tasync #call(params: Readonly<Record<string, unknown>>): Promise<void> {\n\t\tconst call = parseBrowserBindingCall(params)\n\t\tif (call === undefined) return\n\t\tconst handler = this.#bindings.get(call.name)\n\t\tif (handler === undefined) return\n\t\ttry {\n\t\t\tconst value = await handler(...call.args)\n\t\t\tawait this.#frame.send('Runtime.evaluate', {\n\t\t\t\texpression: compileBrowserBindingResult(call.name, call.id, true, value),\n\t\t\t\tcontextId: call.context,\n\t\t\t\tawaitPromise: true,\n\t\t\t})\n\t\t} catch (error) {\n\t\t\tawait this.#frame.send('Runtime.evaluate', {\n\t\t\t\texpression: compileBrowserBindingResult(call.name, call.id, false, String(error)),\n\t\t\t\tcontextId: call.context,\n\t\t\t\tawaitPromise: true,\n\t\t\t})\n\t\t}\n\t}\n\n\t#handleBinding(params: Readonly<Record<string, unknown>>): void {\n\t\tvoid this.#call(params).catch(() => undefined)\n\t}\n\n\t#assert(): void {\n\t\tif (this.#destroyed) throw new BrowserError('Browser script manager is destroyed')\n\t}\n}\n","import type {\n\tBrowserDocument,\n\tBrowserNode,\n\tBrowserNodePredicate,\n\tBrowserNodeQuery,\n\tBrowserSiblingRelation,\n\tBrowserSnapshotInput,\n\tBrowserSnapshotInterface,\n\tBrowserWalkOptions,\n} from './types.js'\nimport { isInteger } from '@orkestrel/contract'\nimport { BrowserError } from './errors.js'\nimport { isBrowserNodeQuery, matchesBrowserNode } from './helpers.js'\n\n/**\n * Represents a navigable, serializable browser DOM snapshot.\n *\n * @example\n * ```ts\n * import { BrowserSnapshot } from '@orkestrel/browser'\n *\n * const snapshot = new BrowserSnapshot({ documents, styles: ['display'] })\n * const main = snapshot.find({ name: 'main', visible: true })\n * ```\n */\nexport class BrowserSnapshot implements BrowserSnapshotInterface {\n\t// Documents are fixed and frozen at construction, so the derived owner index cannot go stale.\n\t#owners: ReadonlyMap<number, BrowserNode> | undefined\n\treadonly documents: readonly BrowserDocument[]\n\treadonly styles: readonly string[]\n\n\tconstructor(input: BrowserSnapshotInput) {\n\t\tthis.documents = Object.freeze([...input.documents])\n\t\tthis.styles = Object.freeze([...input.styles])\n\t}\n\n\twalk(options?: BrowserWalkOptions): Generator<BrowserNode, void, unknown> {\n\t\treturn options?.order === 'breadth' ? this.#breadth(options.root) : this.#depth(options?.root)\n\t}\n\n\t*descendants(node: BrowserNode): Generator<BrowserNode, void, unknown> {\n\t\tlet first = true\n\t\tfor (const descendant of this.#depth(node)) {\n\t\t\tif (first) {\n\t\t\t\tfirst = false\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tyield descendant\n\t\t}\n\t}\n\n\tdocument(node: BrowserNode): BrowserDocument | undefined {\n\t\treturn this.documents.find((document) => document.index === node.document)\n\t}\n\n\tchildren(node: BrowserNode): readonly BrowserNode[] {\n\t\tconst document = this.document(node)\n\t\tif (document === undefined) return []\n\t\tconst children = document.nodes.filter((candidate) => candidate.parent === node.index)\n\t\tif (node.content === undefined) return children\n\t\tconst content = this.documents.find((candidate) => candidate.index === node.content)\n\t\tif (content === undefined) return children\n\t\treturn [...children, ...content.nodes.filter((candidate) => candidate.parent === undefined)]\n\t}\n\n\tparent(node: BrowserNode): BrowserNode | undefined {\n\t\tconst document = this.document(node)\n\t\tif (document === undefined) return undefined\n\t\treturn node.parent === undefined ? this.#owner(node.document) : document.nodes[node.parent]\n\t}\n\n\tsiblings(node: BrowserNode, relation?: BrowserSiblingRelation): readonly BrowserNode[] {\n\t\tconst candidates = this.#candidates(node)\n\t\tconst index = candidates.findIndex(\n\t\t\t(candidate) => candidate.document === node.document && candidate.index === node.index,\n\t\t)\n\t\tif (relation === 'preceding') return index < 0 ? [] : candidates.slice(0, index)\n\t\tif (relation === 'following') return index < 0 ? [] : candidates.slice(index + 1)\n\t\treturn candidates.filter(\n\t\t\t(candidate) => candidate.document !== node.document || candidate.index !== node.index,\n\t\t)\n\t}\n\n\tancestors(node: BrowserNode): readonly BrowserNode[] {\n\t\tconst ancestors: BrowserNode[] = []\n\t\tconst visited = new Set<string>()\n\t\tlet current = node\n\n\t\twhile (true) {\n\t\t\tconst parent = this.parent(current)\n\t\t\tif (parent === undefined) break\n\t\t\tconst identity = this.#identity(parent)\n\t\t\tif (visited.has(identity)) break\n\t\t\tvisited.add(identity)\n\t\t\tancestors.push(parent)\n\t\t\tcurrent = parent\n\t\t}\n\t\treturn ancestors\n\t}\n\n\tcommon(first: BrowserNode, second: BrowserNode): BrowserNode | undefined {\n\t\tconst firstAncestors = this.#chain(first)\n\t\tconst secondAncestors = this.#chain(second)\n\t\tconst identities = new Set(firstAncestors.map((node) => this.#identity(node)))\n\t\treturn secondAncestors.find((node) => identities.has(this.#identity(node)))\n\t}\n\n\tdistance(first: BrowserNode, second: BrowserNode): number | undefined {\n\t\tconst common = this.common(first, second)\n\t\tif (common === undefined) return undefined\n\t\tconst identity = this.#identity(common)\n\t\tconst firstDistance = this.#chain(first).findIndex((node) => this.#identity(node) === identity)\n\t\tconst secondDistance = this.#chain(second).findIndex(\n\t\t\t(node) => this.#identity(node) === identity,\n\t\t)\n\t\tif (firstDistance < 0 || secondDistance < 0) return undefined\n\t\treturn firstDistance + secondDistance\n\t}\n\n\tfind(query: BrowserNodeQuery | BrowserNodePredicate): BrowserNode | undefined {\n\t\tfor (const node of this.walk()) {\n\t\t\tif (this.#match(node, query)) return node\n\t\t}\n\t\treturn undefined\n\t}\n\n\tfilter(query: BrowserNodeQuery | BrowserNodePredicate, limit?: number): readonly BrowserNode[] {\n\t\tif (limit !== undefined && (!isInteger(limit) || limit < 0)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Browser node result limit must be a non-negative integer',\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tlimit,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (limit === 0) return []\n\t\tconst found: BrowserNode[] = []\n\t\tfor (const node of this.walk()) {\n\t\t\tif (!this.#match(node, query)) continue\n\t\t\tfound.push(node)\n\t\t\tif (limit !== undefined && found.length >= limit) break\n\t\t}\n\t\treturn found\n\t}\n\n\tclosest(\n\t\tnode: BrowserNode,\n\t\tquery: BrowserNodeQuery | BrowserNodePredicate,\n\t): BrowserNode | undefined {\n\t\tif (this.#match(node, query)) return node\n\t\tfor (const ancestor of this.ancestors(node)) {\n\t\t\tif (this.#match(ancestor, query)) return ancestor\n\t\t}\n\t\treturn undefined\n\t}\n\n\tpath(node: BrowserNode): string {\n\t\tconst document = this.document(node)\n\t\tif (document === undefined) return `document:${node.document} > node:${node.index}`\n\t\tconst chain = [...this.ancestors(node)].reverse()\n\t\tchain.push(node)\n\t\tconst segments: string[] = []\n\n\t\tfor (const current of chain) {\n\t\t\tif (current.category !== 1) {\n\t\t\t\tsegments.push(`${current.name.toLowerCase()}:${current.index}`)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlet ordinal = 1\n\t\t\tif (current.parent !== undefined) {\n\t\t\t\tconst owner = this.document(current)\n\t\t\t\tfor (const sibling of owner?.nodes ?? []) {\n\t\t\t\t\tif (sibling.index >= current.index) break\n\t\t\t\t\tif (sibling.parent === current.parent && sibling.name === current.name) ordinal += 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tsegments.push(`${current.name.toLowerCase()}:${ordinal}`)\n\t\t}\n\n\t\treturn `frame(${JSON.stringify(document.frame)}) > ${segments.join(' > ')}`\n\t}\n\n\t#roots(): readonly BrowserNode[] {\n\t\tconst roots: BrowserNode[] = []\n\t\tfor (const document of this.documents) {\n\t\t\troots.push(...document.nodes.filter((node) => node.parent === undefined))\n\t\t}\n\t\tfor (const document of this.documents) roots.push(...document.nodes)\n\t\treturn roots\n\t}\n\n\t#owner(document: number): BrowserNode | undefined {\n\t\tconst owners = this.#owners\n\t\tif (owners !== undefined) return owners.get(document)\n\t\tconst index = new Map<number, BrowserNode>()\n\t\tfor (const node of this.walk()) {\n\t\t\tif (node.content !== undefined && !index.has(node.content)) index.set(node.content, node)\n\t\t}\n\t\tthis.#owners = index\n\t\treturn index.get(document)\n\t}\n\n\t*#depth(root?: BrowserNode): Generator<BrowserNode, void, unknown> {\n\t\tconst visited = new Set<string>()\n\t\tfor (const seed of root === undefined ? this.#roots() : [root]) {\n\t\t\tconst stack: BrowserNode[] = [seed]\n\t\t\twhile (stack.length > 0) {\n\t\t\t\tconst node = stack.pop()\n\t\t\t\tif (node === undefined) break\n\t\t\t\tconst identity = this.#identity(node)\n\t\t\t\tif (visited.has(identity)) continue\n\t\t\t\tvisited.add(identity)\n\t\t\t\tyield node\n\n\t\t\t\tconst children = this.children(node)\n\t\t\t\tfor (let index = children.length - 1; index >= 0; index -= 1) {\n\t\t\t\t\tconst child = children[index]\n\t\t\t\t\tif (child !== undefined) stack.push(child)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t*#breadth(root?: BrowserNode): Generator<BrowserNode, void, unknown> {\n\t\tconst visited = new Set<string>()\n\t\tfor (const seed of root === undefined ? this.#roots() : [root]) {\n\t\t\tconst queue: BrowserNode[] = [seed]\n\t\t\tlet cursor = 0\n\t\t\twhile (cursor < queue.length) {\n\t\t\t\tconst node = queue[cursor]\n\t\t\t\tcursor += 1\n\t\t\t\tif (node === undefined) continue\n\t\t\t\tconst identity = this.#identity(node)\n\t\t\t\tif (visited.has(identity)) continue\n\t\t\t\tvisited.add(identity)\n\t\t\t\tyield node\n\t\t\t\tqueue.push(...this.children(node))\n\t\t\t}\n\t\t}\n\t}\n\n\t#candidates(node: BrowserNode): readonly BrowserNode[] {\n\t\tconst parent = this.parent(node)\n\t\treturn parent === undefined\n\t\t\t? (this.document(node)?.nodes.filter((candidate) => candidate.parent === undefined) ?? [])\n\t\t\t: this.children(parent)\n\t}\n\n\t#chain(node: BrowserNode): readonly BrowserNode[] {\n\t\treturn [node, ...this.ancestors(node)]\n\t}\n\n\t#match(node: BrowserNode, query: BrowserNodeQuery | BrowserNodePredicate): boolean {\n\t\treturn isBrowserNodeQuery(query) ? matchesBrowserNode(node, query) : query(node)\n\t}\n\n\t#identity(node: BrowserNode): string {\n\t\treturn `${node.document}:${node.index}`\n\t}\n}\n","import type {\n\tBrowserCallOptions,\n\tBrowserWorkerCategory,\n\tBrowserWorkerInterface,\n\tCDPClientInterface,\n} from './types.js'\nimport { BROWSER_RESULT_LIMIT } from './constants.js'\nimport { compileGuardedEvaluateExpression } from './compilers.js'\nimport { readEvaluationResult } from './helpers.js'\nimport { BrowserError } from './errors.js'\n\n/**\n * Represents a dedicated, shared, or service worker attached through a flattened target session.\n */\nexport class BrowserWorker implements BrowserWorkerInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #session: string\n\treadonly #id: string\n\treadonly #url: string\n\treadonly #category: BrowserWorkerCategory\n\t#closed = false\n\n\tconstructor(\n\t\tclient: CDPClientInterface,\n\t\tsession: string,\n\t\tid: string,\n\t\turl: string,\n\t\tcategory: BrowserWorkerCategory,\n\t) {\n\t\tthis.#client = client\n\t\tthis.#session = session\n\t\tthis.#id = id\n\t\tthis.#url = url\n\t\tthis.#category = category\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget url(): string {\n\t\treturn this.#url\n\t}\n\n\tget category(): BrowserWorkerCategory {\n\t\treturn this.#category\n\t}\n\n\tasync evaluate(expression: string, options?: BrowserCallOptions): Promise<unknown> {\n\t\tthis.#assert()\n\t\treturn readEvaluationResult(\n\t\t\tawait this.#client.send(\n\t\t\t\t'Runtime.evaluate',\n\t\t\t\t{\n\t\t\t\t\texpression: compileGuardedEvaluateExpression(expression, BROWSER_RESULT_LIMIT),\n\t\t\t\t\treturnByValue: true,\n\t\t\t\t\tawaitPromise: true,\n\t\t\t\t},\n\t\t\t\t{ session: this.#session, ...options },\n\t\t\t),\n\t\t)\n\t}\n\n\tasync send(\n\t\tmethod: string,\n\t\tparams?: Readonly<Record<string, unknown>>,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<unknown> {\n\t\tthis.#assert()\n\t\treturn await this.#client.send(method, params, { session: this.#session, ...options })\n\t}\n\n\tdetach(): void {\n\t\tthis.#closed = true\n\t}\n\n\tasync close(): Promise<void> {\n\t\tif (this.#closed) return\n\t\tthis.#closed = true\n\t\ttry {\n\t\t\tawait this.#client.send('Target.closeTarget', { targetId: this.#id })\n\t\t} catch {\n\t\t\t// The worker may already have terminated.\n\t\t}\n\t}\n\n\t#assert(): void {\n\t\tif (this.#closed) throw new BrowserError('Browser worker is closed')\n\t\tif (!this.#client.connected) throw new BrowserError('Browser worker is disconnected')\n\t}\n}\n","import type {\n\tBrowserElementManagerInterface,\n\tBrowserPageElementInterface,\n\tBrowserReadinessWait,\n\tBrowserReferenceFunction,\n\tBrowserCallOptions,\n\tBrowserCodegenInterface,\n\tBrowserRecorderOptions,\n\tBrowserClockInterface,\n\tBrowserDiagnosticsInterface,\n\tBrowserFrameInfo,\n\tBrowserFrameInterface,\n\tBrowserKeyboardInterface,\n\tBrowserMouseInterface,\n\tBrowserNavigationEventMap,\n\tBrowserNavigationReason,\n\tBrowserNavigationOptions,\n\tBrowserNavigationManagerInterface,\n\tBrowserNavigationResult,\n\tBrowserNavigationWatch,\n\tBrowserNetworkManagerInterface,\n\tBrowserPDFOptions,\n\tBrowserPDFResult,\n\tBrowserPageInterface,\n\tBrowserPageEventMap,\n\tBrowserPageOptions,\n\tBrowserPopupManagerInterface,\n\tBrowserPopupRecordInterface,\n\tBrowserReadingInterface,\n\tBrowserRect,\n\tBrowserRegistryInterface,\n\tBrowserResponse,\n\tBrowserScreenshotOptions,\n\tBrowserScreenshotResult,\n\tBrowserScriptManagerInterface,\n\tBrowserSnapshotInterface,\n\tBrowserSnapshotOptions,\n\tBrowserTouchInterface,\n\tBrowserWaitUntil,\n\tBrowserWorkerCategory,\n\tBrowserAccessibilityInterface,\n\tCDPClientInterface,\n\tCDPHandler,\n\tBrowserWriterInterface,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { BrowserCodegen } from './recorders/BrowserCodegen.js'\nimport { BrowserElementManager } from './elements/BrowserElementManager.js'\nimport { BrowserRegistry } from './BrowserRegistry.js'\nimport { BrowserTransition } from './BrowserTransition.js'\nimport { BrowserAccessibility } from './BrowserAccessibility.js'\nimport { BrowserClock } from './BrowserClock.js'\nimport { BrowserDiagnostics } from './BrowserDiagnostics.js'\nimport { BrowserDialog } from './BrowserDialog.js'\nimport { BrowserDownload } from './BrowserDownload.js'\nimport { BrowserFrame } from './BrowserFrame.js'\nimport { BrowserFileChooser } from './BrowserFileChooser.js'\nimport { BrowserKeyboard } from './BrowserKeyboard.js'\nimport { BrowserMouse } from './BrowserMouse.js'\nimport { BrowserTouch } from './BrowserTouch.js'\nimport { BrowserNetworkManager } from './BrowserNetworkManager.js'\nimport { BrowserNavigationManager } from './BrowserNavigationManager.js'\nimport { BrowserScriptManager } from './BrowserScriptManager.js'\nimport { BrowserSnapshot } from './BrowserSnapshot.js'\nimport { BrowserWorker } from './BrowserWorker.js'\nimport { BrowserError } from './errors.js'\nimport {\n\tBROWSER_DEFAULT_TIMEOUT_MS,\n\tBROWSER_NAVIGATION_REASONS,\n\tBROWSER_RELOAD_NAVIGATION_TYPES,\n\tBROWSER_REFERENCE_PREFIX,\n\tBROWSER_FRAME_WORLD_NAME,\n\tBROWSER_SNAPSHOT_NODE_LIMIT,\n\tBROWSER_STOP_LOADING_TIMEOUT_MS,\n} from './constants.js'\nimport {\n\tcompileTextWaitExpression,\n\tcompileScreenshotCleanupExpression,\n\tcompileScreenshotPreparationExpression,\n} from './compilers.js'\nimport {\n\tdecodeBase64,\n\treadBrowserSnapshot,\n\tbrowserPDFToParams,\n\tbrowserScreenshotToParams,\n\treadBrowserFrames,\n\treadBrowserWorld,\n\treadEvaluationResult,\n\trequireBrowserString,\n\tvalidateBrowserTimeout,\n} from './helpers.js'\nimport {\n\tparseBrowserConsoleMessage,\n\tparseBrowserDownloadProgress,\n\tparseBrowserDownloadStart,\n\tparseBrowserPageError,\n} from './parsers.js'\nimport {\n\tisArray,\n\tisError,\n\tisFiniteNumber,\n\tisInteger,\n\tisRecord,\n\tisString,\n} from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\n\n/**\n * Represents a top-level browser page, including its target lifecycle and child frames.\n *\n * @remarks\n * Only a page constructed with a `reference` function, as `BrowserContext` constructs every page,\n * takes part in target ownership and discovery. Such a page holds its target on the client's\n * current connection until it closes, its connection ends, or the `ready` promise its constructing\n * path passes rejects: constructing a second such page for a target a live page holds throws\n * `BROWSER_TARGET_HELD`, and the first such page on a connection enables\n * `Target.setDiscoverTargets` for it. A page constructed without `ready`, with or without an\n * `opener`, is complete as constructed; `ready` is the constructing path's completion, and a\n * popup a page constructs is complete when that page emits it.\n *\n * A page publishes each page it opens through `popup` once, never a closed one, and only after it\n * is complete itself. An unattached page target that discovery reports with this page as\n * `openerId`, live or before this page existed, is attached on the browser session, so the popup\n * outlives its opener; an attachment on this page's session is taken as it arrives; a target\n * another page holds is published as that page after its `ready` resolves, while it still holds\n * the target; and the second session for one target is detached. A page detaches its own session\n * through the session it was attached through.\n *\n * @example\n * ```ts\n * import { BrowserPage } from '@orkestrel/browser'\n *\n * const page = new BrowserPage(client, 'target-1', 'session-1')\n * await page.navigate('https://example.com')\n * const shot = await page.screenshot({ format: 'png' })\n * await page.close()\n * ```\n */\nexport class BrowserPage extends BrowserFrame implements BrowserPageInterface {\n\t// Per client, the pages that hold a target on its current connection and the discovery reports\n\t// whose opener no held page is yet; the end of a connection and a new one clear both.\n\tstatic readonly #held: WeakMap<CDPClientInterface, Map<string, BrowserPage>> = new WeakMap()\n\tstatic readonly #reports: WeakMap<\n\t\tCDPClientInterface,\n\t\tMap<string, Readonly<Record<string, unknown>>>\n\t> = new WeakMap()\n\tstatic readonly #discovered: WeakSet<CDPClientInterface> = new WeakSet()\n\treadonly #client: CDPClientInterface\n\treadonly #targetId: string\n\treadonly #sessionId: string\n\treadonly #writer: BrowserWriterInterface | undefined\n\treadonly #contextId: string | undefined\n\t#opener: BrowserPageInterface | undefined\n\t// The session this page's session was attached through; undefined for the browser session.\n\t#owner: string | undefined\n\t// Settles when the path that constructed this page completes it, or rejects when that path fails:\n\t// for a context page, when the context publishes it; for a popup, when its setup finishes; for a\n\t// page constructed without `ready`, at once.\n\treadonly #setup: Promise<void>\n\t// Resolves when this page is published, which a popup this page publishes and a discovery report\n\t// waiting for this page wait for; rejects when the page releases.\n\treadonly #announcement = Promise.withResolvers<void>()\n\treadonly #emitter: Emitter<BrowserPageEventMap>\n\treadonly #elements: BrowserElementManager\n\treadonly #keyboard: BrowserKeyboard\n\treadonly #mouse: BrowserMouse\n\treadonly #touch: BrowserTouch\n\treadonly #reference: BrowserReferenceFunction\n\treadonly #readiness = new Map<symbol, BrowserReadinessWait>()\n\t#referenceSequence = 0\n\t#waitSequence = 0\n\t#dom: string | undefined\n\t#seed: Promise<void> | undefined\n\treadonly #lifecycleHandler = this.#handleLifecycle.bind(this)\n\treadonly #network: BrowserNetworkManager\n\treadonly #navigationManager: BrowserNavigationManager\n\treadonly #scripts: BrowserScriptManager\n\treadonly #accessibility: BrowserAccessibility\n\treadonly #diagnostics: BrowserDiagnostics\n\treadonly #clock: BrowserClock\n\t// Each frame has one owning session, whose attempt settles to that session once its domains enable.\n\treadonly #frameSessions: Map<\n\t\tstring,\n\t\t{ readonly session: string; readonly attempt: Promise<string> }\n\t> = new Map()\n\treadonly #frameIds: Map<string, string> = new Map()\n\treadonly #iframes: Map<string, BrowserFrameInfo> = new Map()\n\t// The latest current-tab request per frame that no start has taken yet, from any session the\n\t// page knows, because the document that initiates a navigation reports the request even when\n\t// another session owns the navigating frame; the owning session's start for the same URL takes\n\t// its reason unless it repeats a history entry. The next request replaces an entry, and every\n\t// start of the frame, a same-document commit, the frame's removal, and the page's teardown delete\n\t// it, so the map holds at most one entry per attached frame.\n\treadonly #pending: Map<\n\t\tstring,\n\t\t{ readonly url: string; readonly reason: BrowserNavigationReason | undefined }\n\t> = new Map()\n\treadonly #downloads: Map<string, BrowserDownload> = new Map()\n\treadonly #workers: Map<string, BrowserWorker> = new Map()\n\treadonly #popups: Map<string, BrowserPage> = new Map()\n\t// A popup target an attach is initializing, so the attach that arrives second, through discovery\n\t// or through an attachment event, initializes nothing.\n\treadonly #claimed: Set<string> = new Set()\n\t// Each open popup record's observations since it opened, replaced on every change: the\n\t// `Page.windowOpen` reports counted, the popup targets the page began to adopt, and each of those\n\t// targets that concluded, mapped to its page when announced and to undefined when skipped.\n\treadonly #records: Map<\n\t\tsymbol,\n\t\t{\n\t\t\treadonly opened: number\n\t\t\treadonly targets: ReadonlySet<string>\n\t\t\treadonly outcomes: ReadonlyMap<string, BrowserPage | undefined>\n\t\t}\n\t> = new Map()\n\t// Wakes every pending popup settle after a record changes or ends.\n\treadonly #wakes: Set<() => void> = new Set()\n\treadonly #popupManager: BrowserPopupManagerInterface = {\n\t\trecord: this.#recordPopups.bind(this),\n\t}\n\treadonly #openHandler = this.#handleOpen.bind(this)\n\t// A frame with no entry has not changed since the last page-frame document change, whose\n\t// epoch `#floor` holds, so the map holds only the frames of the current document.\n\treadonly #epochs: Map<string, number> = new Map()\n\treadonly #worlds: Map<string, { readonly session: string; readonly context: number }> = new Map()\n\t// A pending creation records its session so a context-cleared event on that session can\n\t// invalidate it before it publishes.\n\treadonly #creating: Map<string, { readonly session: string; readonly promise: Promise<number> }> =\n\t\tnew Map()\n\treadonly #sessionHandlers: Map<\n\t\tstring,\n\t\t{\n\t\t\treadonly destroyed: CDPHandler\n\t\t\treadonly cleared: CDPHandler\n\t\t\treadonly navigated: CDPHandler\n\t\t\treadonly routed: CDPHandler\n\t\t\treadonly detached: CDPHandler\n\t\t\treadonly attached: CDPHandler\n\t\t\treadonly requested: CDPHandler\n\t\t\treadonly started: CDPHandler\n\t\t\treadonly lifecycle: CDPHandler\n\t\t\treadonly stopped: CDPHandler\n\t\t\treadonly target: CDPHandler\n\t\t\treadonly released: CDPHandler\n\t\t}\n\t> = new Map()\n\t// The navigation steps each frame's owning session reports, which the navigation and element\n\t// managers consume; see `#accepts` for the ownership rule.\n\treadonly #steps = new Emitter<BrowserNavigationEventMap>()\n\t// The parent of each frame whose attach, frame tree, or target named one.\n\treadonly #parents: Map<string, string> = new Map()\n\t// The loader of each frame's latest accepted commit, so a stop is a load only for a commit that\n\t// named no loader.\n\treadonly #loaders: Map<string, string | undefined> = new Map()\n\t// The frame of each attach whose domain enable has not settled, keyed by its frame session, so a\n\t// navigation the frame session reports before publication reaches the published record.\n\treadonly #attaching: Map<string, BrowserFrameInfo> = new Map()\n\t#epoch = 0\n\t#floor = 0\n\t#closed = false\n\t#codegen: BrowserCodegen | undefined\n\t#registry: BrowserRegistry | undefined\n\treadonly #codegenStart: BrowserTransition<BrowserCodegen> = new BrowserTransition()\n\t#navigation: Promise<BrowserNavigationResult> | undefined\n\t#closing: Promise<void> | undefined\n\t#releasing: Promise<void> | undefined\n\t#loadEvents: readonly string[] = []\n\t#sameDocument = false\n\t#loader: string | undefined\n\t#loadTimer: ReturnType<typeof setTimeout> | undefined\n\t#loadResolve: (() => void) | undefined\n\t#loadReject: ((error: unknown) => void) | undefined\n\t#loadAbort: { readonly signal: AbortSignal; readonly listener: () => void } | undefined\n\t#responses: BrowserResponse[] | undefined\n\treadonly #navigationResponseHandler = this.#handleNavigationResponse.bind(this)\n\treadonly #destroyHandler = this.#handleDestroy.bind(this)\n\treadonly #loadHandler = this.#handleLoad.bind(this)\n\treadonly #restoreHandler = this.#handleRestore.bind(this)\n\treadonly #dialogHandler = this.#handleDialog.bind(this)\n\treadonly #chooserHandler = this.#handleChooser.bind(this)\n\treadonly #consoleHandler = this.#handleConsole.bind(this)\n\treadonly #errorHandler = this.#handleError.bind(this)\n\treadonly #crashHandler = this.#handleCrash.bind(this)\n\treadonly #downloadHandler = this.#handleDownload.bind(this)\n\treadonly #downloadProgressHandler = this.#handleDownloadProgress.bind(this)\n\n\tconstructor(\n\t\tclient: CDPClientInterface,\n\t\ttargetId: string,\n\t\tsessionId: string,\n\t\twriter?: BrowserWriterInterface,\n\t\turl?: string,\n\t\tframeId?: string,\n\t\tcontextId?: string,\n\t\topener?: BrowserPageInterface,\n\t\toptions?: BrowserPageOptions,\n\t\treference?: BrowserReferenceFunction,\n\t\tready?: Promise<void>,\n\t) {\n\t\tsuper(\n\t\t\tclient,\n\t\t\tsessionId,\n\t\t\tframeId ?? targetId,\n\t\t\turl ?? 'about:blank',\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tfalse,\n\t\t\t() => this.#epochOf(this.id),\n\t\t\t(session, call) => this.#world(this.id, session, call),\n\t\t)\n\t\tconst held = reference === undefined ? undefined : BrowserPage.#track(client)\n\t\tconst holder = held?.get(targetId)\n\t\tif (holder !== undefined && !holder.#closed)\n\t\t\tthrow new BrowserError('Browser target already has a page', 'BROWSER_TARGET_HELD', {\n\t\t\t\ttarget: targetId,\n\t\t\t})\n\t\tthis.#client = client\n\t\tthis.#targetId = targetId\n\t\tthis.#sessionId = sessionId\n\t\tthis.#writer = writer\n\t\tthis.#contextId = contextId\n\t\tthis.#opener = opener\n\t\tthis.#setup = ready ?? Promise.resolve()\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on !== undefined ? { on: options.on } : {}),\n\t\t\t...(options?.error !== undefined ? { error: options.error } : {}),\n\t\t})\n\t\tthis.#reference = reference ?? this.#nextReference.bind(this)\n\t\tthis.#elements = new BrowserElementManager({\n\t\t\tnavigation: this.#epochOf.bind(this),\n\t\t\tsteps: this.#steps,\n\t\t\tpage: this,\n\t\t\tclient,\n\t\t\tsession: sessionId,\n\t\t\tresolve: this.#resolveFrameSession.bind(this),\n\t\t\tworld: this.#world.bind(this),\n\t\t\treference: this.#reference,\n\t\t\tready: this.#ready.bind(this),\n\t\t})\n\t\tthis.#keyboard = new BrowserKeyboard(this)\n\t\tthis.#mouse = new BrowserMouse(this)\n\t\tthis.#touch = new BrowserTouch(this)\n\t\tthis.#client.subscribe('Page.lifecycleEvent', this.#lifecycleHandler, sessionId)\n\t\tthis.#network = new BrowserNetworkManager(this, writer)\n\t\tthis.#navigationManager = new BrowserNavigationManager(\n\t\t\tthis,\n\t\t\tclient,\n\t\t\tsessionId,\n\t\t\t() => this.#loader,\n\t\t\tthis.#steps,\n\t\t\tthis.#parents.get.bind(this.#parents),\n\t\t)\n\t\tthis.#scripts = new BrowserScriptManager(this)\n\t\tthis.#accessibility = new BrowserAccessibility(this)\n\t\tthis.#diagnostics = new BrowserDiagnostics(this, writer)\n\t\tthis.#clock = new BrowserClock(this)\n\t\tthis.#network.emitter.on('request', (request) => this.#emitter.emit('request', request))\n\t\tthis.#network.emitter.on('response', (response) => this.#emitter.emit('response', response))\n\t\tthis.#network.emitter.on('failure', (failure) => this.#emitter.emit('failure', failure))\n\t\tthis.#network.emitter.on('socket', (socket) => this.#emitter.emit('socket', socket))\n\n\t\tthis.#client.subscribe('Target.targetDestroyed', this.#destroyHandler)\n\t\tthis.#watchSession(this.#sessionId)\n\t\tthis.#client.subscribe('Page.javascriptDialogOpening', this.#dialogHandler, this.#sessionId)\n\t\tthis.#client.subscribe('Page.windowOpen', this.#openHandler, this.#sessionId)\n\t\tthis.#client.subscribe('Page.fileChooserOpened', this.#chooserHandler, this.#sessionId)\n\t\tthis.#client.subscribe('Runtime.consoleAPICalled', this.#consoleHandler, this.#sessionId)\n\t\tthis.#client.subscribe('Runtime.exceptionThrown', this.#errorHandler, this.#sessionId)\n\t\tthis.#client.subscribe('Inspector.targetCrashed', this.#crashHandler, this.#sessionId)\n\t\tthis.#client.subscribe('Browser.downloadWillBegin', this.#downloadHandler)\n\t\tthis.#client.subscribe('Browser.downloadProgress', this.#downloadProgressHandler)\n\t\tvoid this.#announcement.promise.catch(() => undefined)\n\t\tvoid this.#setup.then(\n\t\t\t() => {\n\t\t\t\tif (ready === undefined || opener === undefined) this.#announcement.resolve()\n\t\t\t},\n\t\t\t() => this.#unhold(),\n\t\t)\n\t\tif (held === undefined) return\n\t\theld.set(targetId, this)\n\t\tif (!BrowserPage.#discovered.has(client)) {\n\t\t\tBrowserPage.#discovered.add(client)\n\t\t\tvoid client\n\t\t\t\t.send('Target.setDiscoverTargets', { discover: true })\n\t\t\t\t.catch(() => BrowserPage.#discovered.delete(client))\n\t\t}\n\t\tvoid this.#announcement.promise.then(\n\t\t\t() => this.#drain(),\n\t\t\t() => undefined,\n\t\t)\n\t}\n\n\tget emitter(): EmitterInterface<BrowserPageEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget elements(): BrowserElementManagerInterface<BrowserPageElementInterface> {\n\t\treturn this.#elements\n\t}\n\n\tget trusted(): true {\n\t\treturn true\n\t}\n\n\tget keyboard(): BrowserKeyboardInterface {\n\t\treturn this.#keyboard\n\t}\n\n\tget mouse(): BrowserMouseInterface {\n\t\treturn this.#mouse\n\t}\n\n\tget touch(): BrowserTouchInterface {\n\t\treturn this.#touch\n\t}\n\n\t// The page's reading waits for the current document's DOMContentLoaded, as the outline does,\n\t// so a read issued while a navigation loads captures the loaded document.\n\toverride async read(options?: BrowserCallOptions): Promise<BrowserReadingInterface> {\n\t\tawait this.#ready(options)\n\t\treturn await super.read(options)\n\t}\n\n\tasync wait(text: string, options?: BrowserCallOptions): Promise<void> {\n\t\tthis.assert()\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst end = performance.now() + timeout\n\t\twhile (true) {\n\t\t\toptions?.signal?.throwIfAborted()\n\t\t\tconst remaining = Math.max(0, end - performance.now())\n\t\t\tawait this.#ready({ ...options, timeout: remaining })\n\t\t\tconst context = await this.#world(this.id, this.#sessionId, options)\n\t\t\tconst key = `__browserTextWait${++this.#waitSequence}`\n\t\t\ttry {\n\t\t\t\tconst result = await this.send(\n\t\t\t\t\t'Runtime.evaluate',\n\t\t\t\t\t{\n\t\t\t\t\t\texpression: compileTextWaitExpression(text, remaining, key),\n\t\t\t\t\t\tcontextId: context,\n\t\t\t\t\t\treturnByValue: true,\n\t\t\t\t\t\tawaitPromise: true,\n\t\t\t\t\t},\n\t\t\t\t\t{ ...options, timeout: remaining + 1000 },\n\t\t\t\t)\n\t\t\t\tif (readEvaluationResult(result) !== true)\n\t\t\t\t\tthrow new BrowserError('Browser text wait timed out', 'BROWSER_WAIT_TIMEOUT', {\n\t\t\t\t\t\ttext,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t})\n\t\t\t\treturn\n\t\t\t} catch (error) {\n\t\t\t\tif (options?.signal?.aborted === true) {\n\t\t\t\t\tawait this.send(\n\t\t\t\t\t\t'Runtime.evaluate',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\texpression: `globalThis[${JSON.stringify(key)}]?.()`,\n\t\t\t\t\t\t\tcontextId: context,\n\t\t\t\t\t\t\treturnByValue: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ timeout: 1000 },\n\t\t\t\t\t).catch(() => undefined)\n\t\t\t\t\tthrow options.signal.reason\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!isError(error) ||\n\t\t\t\t\t!/execution context was destroyed|cannot find context with specified id/i.test(\n\t\t\t\t\t\terror.message,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tthrow error\n\t\t\t\tthis.#dom = undefined\n\t\t\t\tif (performance.now() >= end)\n\t\t\t\t\tthrow new BrowserError('Browser text wait timed out', 'BROWSER_WAIT_TIMEOUT', {\n\t\t\t\t\t\ttext,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t})\n\t\t\t\tawait this.#parkReadiness({ ...options, timeout: Math.max(0, end - performance.now()) })\n\t\t\t}\n\t\t}\n\t}\n\n\tget network(): BrowserNetworkManagerInterface {\n\t\treturn this.#network\n\t}\n\n\tget registry(): BrowserRegistryInterface {\n\t\tthis.assert()\n\t\tthis.#registry ??= new BrowserRegistry(this, this.#client, this.#sessionId, this.#frameIds)\n\t\treturn this.#registry\n\t}\n\n\tget navigation(): BrowserNavigationManagerInterface {\n\t\treturn this.#navigationManager\n\t}\n\n\tget popups(): BrowserPopupManagerInterface {\n\t\treturn this.#popupManager\n\t}\n\n\tget scripts(): BrowserScriptManagerInterface {\n\t\treturn this.#scripts\n\t}\n\n\tget accessibility(): BrowserAccessibilityInterface {\n\t\treturn this.#accessibility\n\t}\n\n\tget diagnostics(): BrowserDiagnosticsInterface {\n\t\treturn this.#diagnostics\n\t}\n\n\tget clock(): BrowserClockInterface {\n\t\treturn this.#clock\n\t}\n\n\tget opener(): BrowserPageInterface | undefined {\n\t\treturn this.#opener\n\t}\n\n\tget target(): string {\n\t\treturn this.#targetId\n\t}\n\n\tget closed(): boolean {\n\t\treturn this.#closed\n\t}\n\n\tasync navigate(\n\t\turl: string,\n\t\toptions?: BrowserNavigationOptions,\n\t): Promise<BrowserNavigationResult> {\n\t\tthis.assert()\n\t\twhile (this.#navigation !== undefined) {\n\t\t\tawait this.#navigation.catch(() => undefined)\n\t\t}\n\t\tthis.assert()\n\t\tconst navigation = this.#navigate(url, options)\n\t\tthis.#navigation = navigation\n\n\t\ttry {\n\t\t\treturn await navigation\n\t\t} finally {\n\t\t\tif (this.#navigation === navigation) this.#navigation = undefined\n\t\t}\n\t}\n\n\tasync reload(options?: BrowserNavigationOptions): Promise<BrowserNavigationResult> {\n\t\tthis.assert()\n\t\twhile (this.#navigation !== undefined) {\n\t\t\tawait this.#navigation.catch(() => undefined)\n\t\t}\n\t\tthis.assert()\n\t\tconst navigation = this.#reload(options)\n\t\tthis.#navigation = navigation\n\n\t\ttry {\n\t\t\treturn await navigation\n\t\t} finally {\n\t\t\tif (this.#navigation === navigation) this.#navigation = undefined\n\t\t}\n\t}\n\n\tasync back(options?: BrowserNavigationOptions): Promise<BrowserNavigationResult> {\n\t\treturn await this.#history(-1, options)\n\t}\n\n\tasync forward(options?: BrowserNavigationOptions): Promise<BrowserNavigationResult> {\n\t\treturn await this.#history(1, options)\n\t}\n\n\tasync screenshot(options?: BrowserScreenshotOptions): Promise<BrowserScreenshotResult> {\n\t\tthis.assert()\n\t\tconst params: Record<string, unknown> = { ...browserScreenshotToParams(options) }\n\n\t\tif (options?.full === true) {\n\t\t\tconst metrics = await this.send('Page.getLayoutMetrics')\n\t\t\tconst size =\n\t\t\t\tisRecord(metrics) && isRecord(metrics['cssContentSize'])\n\t\t\t\t\t? metrics['cssContentSize']\n\t\t\t\t\t: isRecord(metrics) && isRecord(metrics['contentSize'])\n\t\t\t\t\t\t? metrics['contentSize']\n\t\t\t\t\t\t: undefined\n\t\t\tconst width = size?.['width']\n\t\t\tconst height = size?.['height']\n\t\t\tif (!isFiniteNumber(width) || width <= 0 || !isFiniteNumber(height) || height <= 0) {\n\t\t\t\tthrow new BrowserError('Browser full-page screenshot metrics are malformed')\n\t\t\t}\n\t\t\tparams['clip'] = { x: 0, y: 0, width, height, scale: 1 }\n\t\t\tparams['captureBeyondViewport'] = true\n\t\t}\n\n\t\tif (options?.scale !== undefined) {\n\t\t\tconst ratio = options.scale === 'css' ? 1 : await this.evaluate('devicePixelRatio')\n\t\t\tif (!isFiniteNumber(ratio) || ratio <= 0) {\n\t\t\t\tthrow new BrowserError('Browser screenshot device scale is malformed')\n\t\t\t}\n\t\t\tif (!isRecord(params['clip'])) {\n\t\t\t\tconst metrics = await this.send('Page.getLayoutMetrics')\n\t\t\t\tconst viewport =\n\t\t\t\t\tisRecord(metrics) && isRecord(metrics['cssVisualViewport'])\n\t\t\t\t\t\t? metrics['cssVisualViewport']\n\t\t\t\t\t\t: undefined\n\t\t\t\tif (\n\t\t\t\t\tviewport === undefined ||\n\t\t\t\t\t!isFiniteNumber(viewport['pageX']) ||\n\t\t\t\t\t!isFiniteNumber(viewport['pageY']) ||\n\t\t\t\t\t!isFiniteNumber(viewport['clientWidth']) ||\n\t\t\t\t\tviewport['clientWidth'] <= 0 ||\n\t\t\t\t\t!isFiniteNumber(viewport['clientHeight']) ||\n\t\t\t\t\tviewport['clientHeight'] <= 0\n\t\t\t\t) {\n\t\t\t\t\tthrow new BrowserError('Browser screenshot viewport metrics are malformed')\n\t\t\t\t}\n\t\t\t\tparams['clip'] = {\n\t\t\t\t\tx: viewport['pageX'],\n\t\t\t\t\ty: viewport['pageY'],\n\t\t\t\t\twidth: viewport['clientWidth'],\n\t\t\t\t\theight: viewport['clientHeight'],\n\t\t\t\t\tscale: ratio,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparams['clip']['scale'] = ratio\n\t\t\t}\n\t\t}\n\n\t\tlet token: string | undefined\n\t\tlet transparent = false\n\t\ttry {\n\t\t\tconst masks: BrowserRect[] = []\n\t\t\tfor (const element of options?.mask ?? []) {\n\t\t\t\tconst { points } = await element.quad()\n\t\t\t\tconst xs = points.filter((_value, index) => index % 2 === 0)\n\t\t\t\tconst ys = points.filter((_value, index) => index % 2 !== 0)\n\t\t\t\tconst left = Math.min(...xs)\n\t\t\t\tconst top = Math.min(...ys)\n\t\t\t\tmasks.push([left, top, Math.max(...xs) - left, Math.max(...ys) - top])\n\t\t\t}\n\t\t\tconst preparation = compileScreenshotPreparationExpression(options, masks)\n\t\t\tif (preparation !== undefined) {\n\t\t\t\tconst value = await this.evaluate(preparation)\n\t\t\t\tif (!isString(value)) throw new BrowserError('Browser screenshot preparation failed')\n\t\t\t\ttoken = value\n\t\t\t}\n\t\t\tif (options?.transparent === true) {\n\t\t\t\tawait this.send('Emulation.setDefaultBackgroundColorOverride', {\n\t\t\t\t\tcolor: { r: 0, g: 0, b: 0, a: 0 },\n\t\t\t\t})\n\t\t\t\ttransparent = true\n\t\t\t}\n\t\t\tconst result = await this.send('Page.captureScreenshot', params)\n\t\t\tif (!isRecord(result) || !isString(result['data'])) {\n\t\t\t\tthrow new BrowserError('Screenshot failed: no data returned')\n\t\t\t}\n\n\t\t\tconst bytes = decodeBase64(result['data'])\n\t\t\tif (options?.path !== undefined) await this.save(options.path, bytes)\n\t\t\treturn { bytes, path: options?.path }\n\t\t} finally {\n\t\t\tif (transparent) {\n\t\t\t\tawait this.send('Emulation.setDefaultBackgroundColorOverride').catch(() => undefined)\n\t\t\t}\n\t\t\tif (token !== undefined) {\n\t\t\t\tawait this.evaluate(compileScreenshotCleanupExpression(token)).catch(() => undefined)\n\t\t\t}\n\t\t}\n\t}\n\n\tasync pdf(options?: BrowserPDFOptions): Promise<BrowserPDFResult> {\n\t\tthis.assert()\n\t\tconst result = await this.send('Page.printToPDF', browserPDFToParams(options))\n\t\tif (!isRecord(result) || !isString(result['data'])) {\n\t\t\tthrow new BrowserError('PDF failed: no data returned')\n\t\t}\n\t\tconst bytes = decodeBase64(result['data'])\n\t\tif (options?.path !== undefined) await this.save(options.path, bytes)\n\t\treturn { bytes, path: options?.path }\n\t}\n\n\toverride async save(path: string, bytes: Uint8Array): Promise<void> {\n\t\tif (this.#writer === undefined) {\n\t\t\tthrow new BrowserError('Browser page has no configured file writer', undefined, { path })\n\t\t}\n\t\tawait this.#writer.write(path, bytes)\n\t}\n\n\tasync frame(name: string): Promise<BrowserFrameInterface | undefined> {\n\t\tconst frames = await this.frames()\n\t\treturn frames.find((frame) => frame.name === name || frame.url === name)\n\t}\n\n\tasync frames(): Promise<readonly BrowserFrameInterface[]> {\n\t\tthis.assert()\n\t\tconst result = await this.send('Page.getFrameTree')\n\t\tconst frames = readBrowserFrames(result, [...this.#iframes.values()])\n\t\tfor (const { id, parent } of frames) if (parent !== undefined) this.#parents.set(id, parent)\n\t\treturn frames.map((frame) => this.#frame(frame))\n\t}\n\n\tasync snapshot(options?: BrowserSnapshotOptions): Promise<BrowserSnapshotInterface> {\n\t\tthis.assert()\n\t\tconst styles = options?.styles ?? []\n\t\tconst result = await this.send('DOMSnapshot.captureSnapshot', {\n\t\t\tcomputedStyles: [...styles],\n\t\t\tincludePaintOrder: options?.paint ?? false,\n\t\t\tincludeDOMRects: options?.rects ?? false,\n\t\t})\n\t\treturn new BrowserSnapshot(\n\t\t\treadBrowserSnapshot(result, styles, options?.limit ?? BROWSER_SNAPSHOT_NODE_LIMIT),\n\t\t)\n\t}\n\n\tasync codegen(options?: BrowserRecorderOptions): Promise<BrowserCodegenInterface> {\n\t\tthis.assert()\n\t\tconst active = this.#codegenStart.pending\n\t\tif (active !== undefined) return await active\n\t\tif (this.#codegen !== undefined) return this.#codegen\n\n\t\treturn await this.#codegenStart.execute(() => this.#startCodegen(options))\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tconst active = this.#closing\n\t\tif (active !== undefined) return active\n\n\t\tthis.#closed = true\n\t\tconst closing = this.#destroy()\n\t\tthis.#closing = closing\n\t\treturn closing\n\t}\n\n\tclose(): Promise<void> {\n\t\tconst active = this.#closing\n\t\tif (active !== undefined) return active\n\n\t\tif (this.#closed) {\n\t\t\tconst closing = this.#release()\n\t\t\tthis.#closing = closing\n\t\t\treturn closing\n\t\t}\n\n\t\tthis.#closed = true\n\t\tconst closing = this.#close()\n\t\tthis.#closing = closing\n\t\treturn closing\n\t}\n\n\toverride assert(): void {\n\t\tsuper.assert()\n\t\tif (this.#closed) throw new BrowserError('Browser page is closed')\n\t}\n\n\tasync #navigate(\n\t\turl: string,\n\t\toptions?: BrowserNavigationOptions,\n\t): Promise<BrowserNavigationResult> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst signal = options?.signal\n\t\tconst call = { timeout, ...(signal === undefined ? {} : { signal }) }\n\t\tconst watch = this.#watchNavigation()\n\t\tconst condition = options?.condition ?? 'load'\n\t\tconst wait = this.#waitForLoadEvent(condition, timeout, signal)\n\t\tvoid wait.catch(() => undefined)\n\t\tlet loader: string | undefined\n\n\t\t// A load or a completion read that settles in the same tick as an abort leaves the signal as\n\t\t// the only witness, so cancellation is checked after the wait and after the completion read.\n\t\ttry {\n\t\t\tconst result = await this.send('Page.navigate', { url }, call)\n\t\t\tif (isRecord(result) && isString(result['errorText'])) {\n\t\t\t\tthrow new BrowserError(`Navigation failed: ${result['errorText']}`)\n\t\t\t}\n\t\t\tif (isRecord(result) && isString(result['loaderId'])) {\n\t\t\t\tloader = result['loaderId']\n\t\t\t\tthis.#loader = loader\n\t\t\t}\n\t\t\tawait wait\n\t\t\tsignal?.throwIfAborted()\n\t\t\tconst completed = await this.#completeNavigation(watch, loader, call)\n\t\t\tsignal?.throwIfAborted()\n\t\t\treturn completed\n\t\t} catch (error) {\n\t\t\tthis.#clearNavigationWatch(watch)\n\t\t\tthis.#cancelLoad()\n\t\t\tawait this.#stopLoading(Math.min(timeout, BROWSER_STOP_LOADING_TIMEOUT_MS))\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #reload(options?: BrowserNavigationOptions): Promise<BrowserNavigationResult> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst signal = options?.signal\n\t\tconst call = { timeout, ...(signal === undefined ? {} : { signal }) }\n\t\tconst watch = this.#watchNavigation()\n\t\tconst wait = this.#waitForLoadEvent(options?.condition ?? 'load', timeout, signal)\n\t\tvoid wait.catch(() => undefined)\n\n\t\t// Cancellation is checked after the wait and after the completion read, as `#navigate` does.\n\t\ttry {\n\t\t\tawait this.send('Page.reload', undefined, call)\n\t\t\tawait wait\n\t\t\tsignal?.throwIfAborted()\n\t\t\tconst completed = await this.#completeNavigation(watch, undefined, call)\n\t\t\tsignal?.throwIfAborted()\n\t\t\treturn completed\n\t\t} catch (error) {\n\t\t\tthis.#clearNavigationWatch(watch)\n\t\t\tthis.#cancelLoad()\n\t\t\tawait this.#stopLoading(Math.min(timeout, BROWSER_STOP_LOADING_TIMEOUT_MS))\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #history(\n\t\toffset: -1 | 1,\n\t\toptions?: BrowserNavigationOptions,\n\t): Promise<BrowserNavigationResult> {\n\t\tthis.assert()\n\t\toptions?.signal?.throwIfAborted()\n\t\twhile (this.#navigation !== undefined) {\n\t\t\tawait this.#navigation.catch(() => undefined)\n\t\t}\n\t\tthis.assert()\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst navigation = this.#navigateHistory(offset, options)\n\t\tthis.#navigation = navigation\n\n\t\ttry {\n\t\t\treturn await navigation\n\t\t} finally {\n\t\t\tif (this.#navigation === navigation) this.#navigation = undefined\n\t\t}\n\t}\n\n\tasync #navigateHistory(\n\t\toffset: -1 | 1,\n\t\toptions?: BrowserNavigationOptions,\n\t): Promise<BrowserNavigationResult> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst signal = options?.signal\n\t\tconst call = { timeout, ...(signal === undefined ? {} : { signal }) }\n\t\tconst history = await this.send('Page.getNavigationHistory', undefined, call)\n\t\tsignal?.throwIfAborted()\n\t\tif (!isRecord(history) || !isInteger(history['currentIndex']) || !isArray(history['entries'])) {\n\t\t\tthrow new BrowserError('Navigation history is malformed')\n\t\t}\n\t\tconst entry = history['entries'][history['currentIndex'] + offset]\n\t\tif (!isRecord(entry) || !isInteger(entry['id'])) {\n\t\t\treturn { url: this.url, response: undefined, same: false }\n\t\t}\n\n\t\tconst watch = this.#watchNavigation()\n\t\tconst condition = options?.condition ?? 'load'\n\t\tconst wait = this.#waitForLoadEvent(condition, timeout, signal)\n\t\tvoid wait.catch(() => undefined)\n\t\t// A back-forward cache restore commits a document that already loaded, so Chromium fires no\n\t\t// load or DOMContentLoaded event for it and the restore itself settles those two conditions.\n\t\tconst restorable = condition === 'load' || condition === 'domcontentloaded'\n\t\tif (restorable)\n\t\t\tthis.#client.subscribe('Page.frameNavigated', this.#restoreHandler, this.#sessionId)\n\t\t// A restore or load that settles the wait in the same tick as an abort leaves the signal as the\n\t\t// only witness, so cancellation is checked after the wait and after the completion read.\n\t\ttry {\n\t\t\tawait this.send('Page.navigateToHistoryEntry', { entryId: entry['id'] }, call)\n\t\t\tawait wait\n\t\t\tsignal?.throwIfAborted()\n\t\t\tconst result = await this.#completeNavigation(watch, undefined, call)\n\t\t\tsignal?.throwIfAborted()\n\t\t\treturn result\n\t\t} catch (error) {\n\t\t\tthis.#clearNavigationWatch(watch)\n\t\t\tthis.#cancelLoad()\n\t\t\tawait this.#stopLoading(Math.min(timeout, BROWSER_STOP_LOADING_TIMEOUT_MS))\n\t\t\tthrow error\n\t\t} finally {\n\t\t\tif (restorable)\n\t\t\t\tthis.#client.unsubscribe('Page.frameNavigated', this.#restoreHandler, this.#sessionId)\n\t\t}\n\t}\n\n\t#watchNavigation(): BrowserNavigationWatch {\n\t\tconst responses: BrowserResponse[] = []\n\t\tthis.#responses = responses\n\t\tthis.#network.emitter.on('response', this.#navigationResponseHandler)\n\t\treturn { responses }\n\t}\n\n\t#clearNavigationWatch(watch: BrowserNavigationWatch): void {\n\t\tthis.#network.emitter.off('response', this.#navigationResponseHandler)\n\t\tif (this.#responses === watch.responses) this.#responses = undefined\n\t}\n\n\t#navigationResult(\n\t\twatch: BrowserNavigationWatch,\n\t\turl: string,\n\t\tloader?: string,\n\t): BrowserNavigationResult {\n\t\tthis.#clearNavigationWatch(watch)\n\t\tconst response =\n\t\t\tloader === undefined\n\t\t\t\t? watch.responses.findLast((candidate) => candidate.url === url)\n\t\t\t\t: watch.responses.findLast((candidate) => candidate.loader === loader)\n\t\treturn {\n\t\t\turl,\n\t\t\tresponse,\n\t\t\tsame: this.#sameDocument,\n\t\t}\n\t}\n\n\tasync #completeNavigation(\n\t\twatch: BrowserNavigationWatch,\n\t\tloader?: string,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<BrowserNavigationResult> {\n\t\ttry {\n\t\t\tconst currentUrl = await this.evaluate('location.href', options)\n\t\t\tconst resolved = requireBrowserString(currentUrl, 'Navigation URL')\n\t\t\tthis.update(resolved)\n\t\t\treturn this.#navigationResult(watch, resolved, loader)\n\t\t} catch (error) {\n\t\t\tthis.#clearNavigationWatch(watch)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #startCodegen(options?: BrowserRecorderOptions): Promise<BrowserCodegen> {\n\t\tconst codegen = new BrowserCodegen(this.#client, this.#sessionId, options, () =>\n\t\t\t[...this.#frameSessions.values()].map(({ session }) => session),\n\t\t)\n\t\tthis.#codegen = codegen\n\t\ttry {\n\t\t\tawait codegen.start()\n\t\t} catch (error) {\n\t\t\tthis.#codegen = undefined\n\t\t\tawait codegen.destroy()\n\t\t\tthrow error\n\t\t}\n\t\tif (this.#closed) {\n\t\t\tawait codegen.destroy()\n\t\t\tthrow new BrowserError('Browser page is closed')\n\t\t}\n\t\tthis.#codegen = codegen\n\t\treturn codegen\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\tawait this.#release()\n\t\ttry {\n\t\t\tawait this.#client.send(\n\t\t\t\t'Target.detachFromTarget',\n\t\t\t\t{ sessionId: this.#sessionId },\n\t\t\t\tthis.#owner === undefined ? undefined : { session: this.#owner },\n\t\t\t)\n\t\t} catch {\n\t\t\t// The session may already be detached.\n\t\t}\n\t}\n\n\tasync #close(): Promise<void> {\n\t\tawait this.#release()\n\t\ttry {\n\t\t\tawait this.#client.send('Target.closeTarget', { targetId: this.#targetId })\n\t\t} catch {\n\t\t\t// The target may already be closed.\n\t\t}\n\t}\n\n\t#release(): Promise<void> {\n\t\tconst active = this.#releasing\n\t\tif (active !== undefined) return active\n\t\tconst release = this.#releaseResources()\n\t\tthis.#releasing = release\n\t\treturn release\n\t}\n\n\tasync #releaseResources(): Promise<void> {\n\t\tthis.#unhold()\n\t\tthis.#announcement.reject(new BrowserError('Browser session ended'))\n\t\tthis.#client.unsubscribe('Page.lifecycleEvent', this.#lifecycleHandler, this.#sessionId)\n\t\tfor (const id of this.#readiness.keys())\n\t\t\tthis.#settleReadiness(id)?.reject(new BrowserError('Browser session ended'))\n\t\tthis.#cancelLoad()\n\t\tawait this.#registry?.destroy().catch(() => undefined)\n\t\tawait this.#codegenStart.pending?.catch(() => undefined)\n\t\tawait this.#scripts.destroy().catch(() => undefined)\n\t\tawait this.#diagnostics.destroy().catch(() => undefined)\n\t\tawait this.#clock.uninstall().catch(() => undefined)\n\t\tawait this.#network.destroy().catch(() => undefined)\n\n\t\tif (this.#codegen !== undefined) {\n\t\t\ttry {\n\t\t\t\tawait this.#codegen.destroy()\n\t\t\t} catch {\n\t\t\t\t// The recorder's session may already be unavailable.\n\t\t\t}\n\t\t\tthis.#codegen = undefined\n\t\t}\n\n\t\tthis.#advancePage()\n\t\tfor (const session of this.#frameIds.keys()) this.#unwatchSession(session)\n\t\tthis.#frameSessions.clear()\n\t\tthis.#frameIds.clear()\n\t\tthis.#attaching.clear()\n\t\tthis.#iframes.clear()\n\t\tfor (const worker of this.#workers.values()) worker.detach()\n\t\tthis.#workers.clear()\n\t\tthis.#popups.clear()\n\t\tthis.#claimed.clear()\n\t\tthis.#downloads.clear()\n\t\tthis.#client.unsubscribe('Target.targetDestroyed', this.#destroyHandler)\n\t\tthis.#unwatchSession(this.#sessionId)\n\t\tthis.#client.unsubscribe('Page.javascriptDialogOpening', this.#dialogHandler, this.#sessionId)\n\t\tthis.#client.unsubscribe('Page.windowOpen', this.#openHandler, this.#sessionId)\n\t\tthis.#records.clear()\n\t\tthis.#wakePopups()\n\t\tthis.#client.unsubscribe('Page.fileChooserOpened', this.#chooserHandler, this.#sessionId)\n\t\tthis.#client.unsubscribe('Runtime.consoleAPICalled', this.#consoleHandler, this.#sessionId)\n\t\tthis.#client.unsubscribe('Runtime.exceptionThrown', this.#errorHandler, this.#sessionId)\n\t\tthis.#client.unsubscribe('Inspector.targetCrashed', this.#crashHandler, this.#sessionId)\n\t\tthis.#client.unsubscribe('Browser.downloadWillBegin', this.#downloadHandler)\n\t\tthis.#client.unsubscribe('Browser.downloadProgress', this.#downloadProgressHandler)\n\t\tthis.#parents.clear()\n\t\tthis.#loaders.clear()\n\t\tthis.#pending.clear()\n\t\tif (!this.#emitter.destroyed) {\n\t\t\tthis.#emitter.emit('close')\n\t\t\tthis.#emitter.destroy()\n\t\t}\n\t\tthis.#steps.destroy()\n\t}\n\n\t#frame(frame: BrowserFrameInfo): BrowserFrameInterface {\n\t\treturn new BrowserFrame(\n\t\t\tthis.#client,\n\t\t\t(id) => this.#resolveFrameSession(id),\n\t\t\tframe.id,\n\t\t\tframe.url,\n\t\t\tframe.parent,\n\t\t\tframe.name,\n\t\t\ttrue,\n\t\t\t() => this.#epochOf(frame.id),\n\t\t\t(session, call) => this.#world(frame.id, session, call),\n\t\t)\n\t}\n\n\t#epochOf(frame: string): number {\n\t\treturn this.#epochs.get(frame) ?? this.#floor\n\t}\n\n\t#advanceFrame(frame: string): void {\n\t\tthis.#epoch += 1\n\t\tthis.#epochs.set(frame, this.#epoch)\n\t}\n\n\t// A page-frame document change replaces every frame document, so it advances them together.\n\t#advancePage(): void {\n\t\tthis.#dom = undefined\n\t\tthis.#seed = undefined\n\t\tthis.#epoch += 1\n\t\tthis.#floor = this.#epoch\n\t\tthis.#epochs.clear()\n\t\tthis.#worlds.clear()\n\t\tthis.#creating.clear()\n\t}\n\n\t#nextReference(): string {\n\t\treturn `${BROWSER_REFERENCE_PREFIX}${++this.#referenceSequence}`\n\t}\n\n\tasync #ready(options?: BrowserCallOptions): Promise<void> {\n\t\tthis.assert()\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\tconst end = performance.now() + timeout\n\t\tif (this.#loader === undefined && this.#seed === undefined) {\n\t\t\tconst seed = this.#seedReadiness({ timeout: BROWSER_DEFAULT_TIMEOUT_MS })\n\t\t\tthis.#seed = seed\n\t\t\tvoid seed.catch(this.#rejectSeed.bind(this, seed))\n\t\t}\n\t\tif (this.#seed !== undefined) await this.#parkReadiness(options, this.#seed)\n\t\tif (this.#dom !== undefined && this.#dom === (this.#loader ?? 'initial')) return\n\t\tawait this.#parkReadiness({ ...options, timeout: Math.max(0, end - performance.now()) })\n\t}\n\n\t#rejectSeed(seed: Promise<void>): void {\n\t\tif (this.#seed === seed) this.#seed = undefined\n\t}\n\n\t// The seed answers for the document it was issued against: `#floor` changes only when the\n\t// page frame's document changes, so a same-document navigation during the seed keeps its\n\t// answer.\n\tasync #seedReadiness(options?: BrowserCallOptions): Promise<void> {\n\t\tconst document = this.#floor\n\t\tconst context = await this.#world(this.id, this.#sessionId, options)\n\t\tconst result = await this.send(\n\t\t\t'Runtime.evaluate',\n\t\t\t{ expression: 'document.readyState', contextId: context, returnByValue: true },\n\t\t\toptions,\n\t\t)\n\t\tconst state = readEvaluationResult(result)\n\t\tif (document === this.#floor && (state === 'interactive' || state === 'complete'))\n\t\t\tthis.#dom = this.#loader ?? 'initial'\n\t}\n\n\t#parkReadiness(options?: BrowserCallOptions, seed?: Promise<void>): Promise<void> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst deferred = Promise.withResolvers<void>()\n\t\tconst id = Symbol('readiness')\n\t\tconst timer = setTimeout(\n\t\t\t() =>\n\t\t\t\tthis.#settleReadiness(id)?.reject(\n\t\t\t\t\tnew BrowserError('Browser DOM readiness timed out', 'BROWSER_WAIT_TIMEOUT'),\n\t\t\t\t),\n\t\t\ttimeout,\n\t\t)\n\t\tconst signal = options?.signal\n\t\tconst listener = signal === undefined ? undefined : this.#abortReadiness.bind(this, id, signal)\n\t\tthis.#readiness.set(id, {\n\t\t\tresolve: deferred.resolve,\n\t\t\treject: deferred.reject,\n\t\t\ttimer,\n\t\t\tsignal,\n\t\t\tlistener,\n\t\t})\n\t\tif (listener !== undefined) signal?.addEventListener('abort', listener, { once: true })\n\t\tif (seed !== undefined)\n\t\t\tvoid seed.then(\n\t\t\t\t() => this.#settleReadiness(id)?.resolve(),\n\t\t\t\t(error: unknown) => this.#settleReadiness(id)?.reject(error),\n\t\t\t)\n\t\treturn deferred.promise\n\t}\n\n\t#abortReadiness(id: symbol, signal: AbortSignal): void {\n\t\tthis.#settleReadiness(id)?.reject(signal.reason)\n\t}\n\n\t#settleReadiness(id: symbol): BrowserReadinessWait | undefined {\n\t\tconst wait = this.#readiness.get(id)\n\t\tif (wait === undefined) return undefined\n\t\tclearTimeout(wait.timer)\n\t\tif (wait.listener !== undefined) wait.signal?.removeEventListener('abort', wait.listener)\n\t\tthis.#readiness.delete(id)\n\t\treturn wait\n\t}\n\n\t#handleLifecycle(params: Readonly<Record<string, unknown>>): void {\n\t\tif (\n\t\t\tparams['frameId'] !== this.id ||\n\t\t\tparams['name'] !== 'DOMContentLoaded' ||\n\t\t\t!isString(params['loaderId'])\n\t\t)\n\t\t\treturn\n\t\tif (this.#loader !== undefined && params['loaderId'] !== this.#loader) return\n\t\tthis.#dom = this.#loader ?? 'initial'\n\t\tfor (const id of this.#readiness.keys()) this.#settleReadiness(id)?.resolve()\n\t}\n\n\t#world(frame: string, session: string, options?: BrowserCallOptions): Promise<number> {\n\t\tconst cached = this.#worlds.get(frame)\n\t\tif (cached !== undefined) return Promise.resolve(cached.context)\n\t\tconst existing = this.#creating.get(frame)\n\t\tif (existing !== undefined) return existing.promise\n\t\tconst pending: Promise<number> = this.#client\n\t\t\t.send(\n\t\t\t\t'Page.createIsolatedWorld',\n\t\t\t\t{ frameId: frame, worldName: BROWSER_FRAME_WORLD_NAME },\n\t\t\t\t{ session, ...options },\n\t\t\t)\n\t\t\t.then(this.#decodeWorld.bind(this, frame))\n\t\tthis.#creating.set(frame, { session, promise: pending })\n\t\tvoid pending.then(\n\t\t\tthis.#publishWorld.bind(this, frame, session, pending),\n\t\t\tthis.#settleWorld.bind(this, frame, pending),\n\t\t)\n\t\treturn pending\n\t}\n\n\t#decodeWorld(frame: string, world: unknown): number {\n\t\treturn readBrowserWorld(world, frame)\n\t}\n\n\t// Publication requires the creation to be the frame's current one, so an invalidation that\n\t// landed while the request was in flight discards its context.\n\t#publishWorld(frame: string, session: string, pending: Promise<number>, context: number): void {\n\t\tif (this.#creating.get(frame)?.promise === pending && !this.#closed) {\n\t\t\tthis.#worlds.set(frame, { session, context })\n\t\t}\n\t\tthis.#settleWorld(frame, pending)\n\t}\n\n\t#settleWorld(frame: string, pending: Promise<number>): void {\n\t\tif (this.#creating.get(frame)?.promise === pending) this.#creating.delete(frame)\n\t}\n\n\t#resolveSessionHandlers(session: string): {\n\t\treadonly destroyed: CDPHandler\n\t\treadonly cleared: CDPHandler\n\t\treadonly navigated: CDPHandler\n\t\treadonly routed: CDPHandler\n\t\treadonly detached: CDPHandler\n\t\treadonly attached: CDPHandler\n\t\treadonly requested: CDPHandler\n\t\treadonly started: CDPHandler\n\t\treadonly lifecycle: CDPHandler\n\t\treadonly stopped: CDPHandler\n\t\treadonly target: CDPHandler\n\t\treadonly released: CDPHandler\n\t} {\n\t\tconst existing = this.#sessionHandlers.get(session)\n\t\tif (existing !== undefined) return existing\n\t\tconst created = {\n\t\t\tdestroyed: this.#handleContextDestroyed.bind(this, session),\n\t\t\tcleared: this.#handleContextsCleared.bind(this, session),\n\t\t\tnavigated: this.#handleSessionNavigated.bind(this, session),\n\t\t\trouted: this.#handleSessionRouted.bind(this, session),\n\t\t\tdetached: this.#handleFrameDetached.bind(this, session),\n\t\t\tattached: this.#handleFrameAttached.bind(this, session),\n\t\t\trequested: this.#handleRequested.bind(this, session),\n\t\t\tstarted: this.#handleStarted.bind(this, session),\n\t\t\tlifecycle: this.#handleSessionLifecycle.bind(this, session),\n\t\t\tstopped: this.#handleStopped.bind(this, session),\n\t\t\ttarget: this.#handleAttached.bind(this, session),\n\t\t\treleased: this.#handleDetached.bind(this),\n\t\t}\n\t\tthis.#sessionHandlers.set(session, created)\n\t\treturn created\n\t}\n\n\t// Every session the page follows, its own included, reports its frames' steps through the same\n\t// persistent handlers from the moment it is watched until it is unwatched; no action subscribes.\n\t#watchSession(session: string): void {\n\t\tconst handlers = this.#resolveSessionHandlers(session)\n\t\tfor (const [method, handler] of this.#pairSessionHandlers(handlers))\n\t\t\tthis.#client.subscribe(method, handler, session)\n\t}\n\n\t#unwatchSession(session: string): void {\n\t\tconst handlers = this.#resolveSessionHandlers(session)\n\t\tfor (const [method, handler] of this.#pairSessionHandlers(handlers))\n\t\t\tthis.#client.unsubscribe(method, handler, session)\n\t\tthis.#sessionHandlers.delete(session)\n\t}\n\n\t#pairSessionHandlers(handlers: {\n\t\treadonly destroyed: CDPHandler\n\t\treadonly cleared: CDPHandler\n\t\treadonly navigated: CDPHandler\n\t\treadonly routed: CDPHandler\n\t\treadonly detached: CDPHandler\n\t\treadonly attached: CDPHandler\n\t\treadonly requested: CDPHandler\n\t\treadonly started: CDPHandler\n\t\treadonly lifecycle: CDPHandler\n\t\treadonly stopped: CDPHandler\n\t\treadonly target: CDPHandler\n\t\treadonly released: CDPHandler\n\t}): ReadonlyArray<readonly [method: string, handler: CDPHandler]> {\n\t\treturn [\n\t\t\t['Target.attachedToTarget', handlers.target],\n\t\t\t['Target.detachedFromTarget', handlers.released],\n\t\t\t['Page.frameAttached', handlers.attached],\n\t\t\t['Page.frameDetached', handlers.detached],\n\t\t\t['Page.frameRequestedNavigation', handlers.requested],\n\t\t\t['Page.frameStartedNavigating', handlers.started],\n\t\t\t['Page.frameNavigated', handlers.navigated],\n\t\t\t['Page.navigatedWithinDocument', handlers.routed],\n\t\t\t['Page.lifecycleEvent', handlers.lifecycle],\n\t\t\t['Page.frameStoppedLoading', handlers.stopped],\n\t\t\t['Runtime.executionContextDestroyed', handlers.destroyed],\n\t\t\t['Runtime.executionContextsCleared', handlers.cleared],\n\t\t]\n\t}\n\n\tasync #resolveFrameSession(frame: string): Promise<string> {\n\t\tconst owner = this.#frameSessions.get(frame)\n\t\treturn owner === undefined ? this.#sessionId : await owner.attempt\n\t}\n\n\t// A frame session reports its frame's load only with lifecycle events enabled, and a nested\n\t// out-of-process frame attaches only through its parent frame's own auto-attach; a refusal fails\n\t// the enablement. The target waits for the debugger until both are in effect, so the commit and\n\t// the load of the document it holds arrive on this session after the resume.\n\tasync #enableFrameSession(session: string): Promise<string> {\n\t\tawait this.#client.send('Page.enable', undefined, { session })\n\t\tawait this.#codegen?.attach(session)\n\t\tawait this.#client.send('Runtime.enable', undefined, { session })\n\t\tawait this.#client.send('Page.setLifecycleEventsEnabled', { enabled: true }, { session })\n\t\tawait this.#client.send(\n\t\t\t'Target.setAutoAttach',\n\t\t\t{\n\t\t\t\tautoAttach: true,\n\t\t\t\twaitForDebuggerOnStart: true,\n\t\t\t\tflatten: true,\n\t\t\t\tfilter: [{ type: 'iframe' }],\n\t\t\t},\n\t\t\t{ session },\n\t\t)\n\t\tthis.#resumeTarget(session)\n\t\treturn session\n\t}\n\n\t// Every target the page's auto-attach reaches waits for the debugger until the page resumes it;\n\t// a target gone before its resume ends with its detach.\n\t#resumeTarget(session: string): void {\n\t\tvoid this.#client\n\t\t\t.send('Runtime.runIfWaitingForDebugger', undefined, { session })\n\t\t\t.catch(() => undefined)\n\t}\n\n\t// A detach alone leaves a paused target waiting, so a target the page releases runs uninstrumented\n\t// rather than frozen. The wait ends when the resume attempt settles: a reply shows the renderer\n\t// processed the resume before the browser processes the detach that follows, and a refusal, the\n\t// client's timeout, or the connection's close lets the detach go ahead as best-effort cleanup.\n\tasync #releaseTarget(session: string): Promise<void> {\n\t\tawait this.#client\n\t\t\t.send('Runtime.runIfWaitingForDebugger', undefined, { session })\n\t\t\t.catch(() => undefined)\n\t}\n\n\t// A target that names no parent frame is placed by its own frame tree, whose root supplies the\n\t// parent, the URL, and the name; a navigation the session reported since the attach replaced\n\t// `attached` with a URL newer than the tree's snapshot, which the record keeps.\n\tasync #readFrameTree(session: string, attached: BrowserFrameInfo, named: boolean): Promise<void> {\n\t\tif (named) return\n\t\tconst result = await this.#client\n\t\t\t.send('Page.getFrameTree', undefined, { session })\n\t\t\t.catch(() => undefined)\n\t\tconst [root] = readBrowserFrames(result)\n\t\tif (root === undefined || root.id !== attached.id || this.#attaching.get(session) !== attached)\n\t\t\treturn\n\t\tconst parent = root.parent ?? attached.parent\n\t\tif (parent !== undefined) this.#parents.set(attached.id, parent)\n\t\tthis.#attaching.set(session, {\n\t\t\t...attached,\n\t\t\tparent,\n\t\t\turl: root.url,\n\t\t\tname: root.name ?? attached.name,\n\t\t})\n\t}\n\n\tasync #attachWorker(\n\t\tsession: string,\n\t\tid: string,\n\t\turl: string,\n\t\tcategory: BrowserWorkerCategory,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#client.send('Runtime.enable', undefined, { session })\n\t\t\tif (this.#closed) {\n\t\t\t\tawait this.#detachChild(session, this.#sessionId)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.#resumeTarget(session)\n\t\t\tconst worker = new BrowserWorker(this.#client, session, id, url, category)\n\t\t\tthis.#workers.set(id, worker)\n\t\t\tthis.#emitter.emit('worker', worker)\n\t\t} catch {\n\t\t\t// A worker can terminate before its session is enabled.\n\t\t\tawait this.#detachChild(session, this.#sessionId)\n\t\t}\n\t}\n\n\t// Discovery attaches a popup on the browser session, which keeps the popup's session alive after\n\t// its opener closes; a session attached through this page's session would end with it.\n\tasync #discoverPopup(id: string, url: string | undefined): Promise<void> {\n\t\tconst held = this.#holder(id)\n\t\tif (held !== undefined) {\n\t\t\tconst ready = await held.#setup.then(\n\t\t\t\t() => true,\n\t\t\t\t() => false,\n\t\t\t)\n\t\t\tthis.#claimed.delete(id)\n\t\t\tif (ready && this.#holder(id) === held) this.#publish(held)\n\t\t\telse this.#concludePopup(id)\n\t\t\treturn\n\t\t}\n\t\tconst result: unknown = await this.#client\n\t\t\t.send('Target.attachToTarget', { targetId: id, flatten: true })\n\t\t\t.catch(() => undefined)\n\t\t// A popup can close before the attach reaches it.\n\t\tif (!isRecord(result) || !isString(result['sessionId'])) {\n\t\t\tthis.#claimed.delete(id)\n\t\t\tthis.#concludePopup(id)\n\t\t\treturn\n\t\t}\n\t\tawait this.#attachPopup(result['sessionId'], id, url, undefined)\n\t}\n\n\t// `owner` is the session the popup's session was attached through, undefined for the browser\n\t// session; a discovered popup reports no URL before its first commit, so its frame tree does.\n\tasync #attachPopup(\n\t\tsession: string,\n\t\tid: string,\n\t\turl: string | undefined,\n\t\towner: string | undefined,\n\t): Promise<void> {\n\t\tlet popup: BrowserPage | undefined\n\t\tconst setup = Promise.withResolvers<void>()\n\t\ttry {\n\t\t\tawait this.#client.send('Page.enable', undefined, { session })\n\t\t\tawait this.#client.send('Runtime.enable', undefined, { session })\n\t\t\tawait this.#client.send('Page.setLifecycleEventsEnabled', { enabled: true }, { session })\n\t\t\tconst result = await this.#client.send('Page.getFrameTree', undefined, { session })\n\t\t\tconst frame = readBrowserFrames(result)[0]\n\t\t\tif (frame === undefined || this.#closed) {\n\t\t\t\tthis.#concludePopup(id)\n\t\t\t\tawait this.#detachChild(session, owner)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst held = this.#holder(id)\n\t\t\tif (held !== undefined) {\n\t\t\t\tawait this.#detachChild(session, owner)\n\t\t\t\tconst ready = await held.#setup.then(\n\t\t\t\t\t() => true,\n\t\t\t\t\t() => false,\n\t\t\t\t)\n\t\t\t\tif (ready && !this.#closed && this.#holder(id) === held) this.#publish(held)\n\t\t\t\telse this.#concludePopup(id)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tpopup = new BrowserPage(\n\t\t\t\tthis.#client,\n\t\t\t\tid,\n\t\t\t\tsession,\n\t\t\t\tthis.#writer,\n\t\t\t\turl ?? frame.url,\n\t\t\t\tframe.id,\n\t\t\t\tthis.#contextId,\n\t\t\t\tthis,\n\t\t\t\tundefined,\n\t\t\t\tthis.#reference,\n\t\t\t\tsetup.promise,\n\t\t\t)\n\t\t\tpopup.#owner = owner\n\t\t\tawait popup.send('Target.setAutoAttach', {\n\t\t\t\tautoAttach: true,\n\t\t\t\twaitForDebuggerOnStart: true,\n\t\t\t\tflatten: true,\n\t\t\t})\n\t\t\tawait popup.send('Page.setInterceptFileChooserDialog', { enabled: true })\n\t\t\tawait popup.network.start()\n\t\t\tif (this.#closed) throw new BrowserError('Browser page is closed')\n\t\t\tthis.#resumeTarget(session)\n\t\t\tsetup.resolve()\n\t\t\tthis.#publish(popup)\n\t\t} catch (error) {\n\t\t\t// A popup can close before its session initialization completes.\n\t\t\tthis.#concludePopup(id)\n\t\t\tif (popup !== undefined) {\n\t\t\t\tsetup.reject(error)\n\t\t\t\tawait this.#releaseTarget(session)\n\t\t\t\tawait popup.destroy()\n\t\t\t} else await this.#detachChild(session, owner)\n\t\t} finally {\n\t\t\tthis.#claimed.delete(id)\n\t\t}\n\t}\n\n\t// Publishes a page this page opened once this page is published itself, so the observer of this\n\t// page sees it before any page it opened.\n\t#publish(popup: BrowserPage): void {\n\t\tvoid this.#announcement.promise.then(\n\t\t\t() => this.#emitPopup(popup),\n\t\t\t() => this.#emitPopup(popup),\n\t\t)\n\t}\n\n\t// Emits one popup once; a closed popup is never emitted, and a popup this page constructed is\n\t// released when this page closed first.\n\t#emitPopup(popup: BrowserPage): void {\n\t\tconst id = popup.#targetId\n\t\tif (this.#popups.get(id) === popup) return\n\t\tif (popup.#closed) {\n\t\t\tthis.#concludePopup(id)\n\t\t\treturn\n\t\t}\n\t\tif (this.#closed) {\n\t\t\tif (popup.#opener === this) void popup.destroy().catch(() => undefined)\n\t\t\treturn\n\t\t}\n\t\tpopup.#opener ??= this\n\t\tthis.#popups.set(id, popup)\n\t\tpopup.emitter.on('close', () => {\n\t\t\tif (this.#popups.get(id) === popup) this.#popups.delete(id)\n\t\t})\n\t\tthis.#emitter.emit('popup', popup)\n\t\tpopup.#announcement.resolve()\n\t\tthis.#concludePopup(id, popup)\n\t}\n\n\t#recordPopups(): BrowserPopupRecordInterface {\n\t\tthis.assert()\n\t\tconst key = Symbol('popups')\n\t\tthis.#records.set(key, { opened: 0, targets: new Set(), outcomes: new Map() })\n\t\treturn {\n\t\t\tsettle: this.#settlePopups.bind(this, key),\n\t\t\tdestroy: this.#endPopups.bind(this, key),\n\t\t}\n\t}\n\n\t// Parks until as many popup targets adopted since the record opened concluded as\n\t// `Page.windowOpen` reports arrived, or until `timeout`, which ends the wait with the popups\n\t// announced so far.\n\tasync #settlePopups(\n\t\tkey: symbol,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<readonly BrowserPageInterface[]> {\n\t\tconst timeout = options?.timeout ?? BROWSER_DEFAULT_TIMEOUT_MS\n\t\tvalidateBrowserTimeout(timeout)\n\t\t// The platform deadline takes whole milliseconds.\n\t\tconst deadline = AbortSignal.timeout(Math.ceil(timeout))\n\t\twhile (true) {\n\t\t\toptions?.signal?.throwIfAborted()\n\t\t\tconst record = this.#records.get(key)\n\t\t\tif (record === undefined)\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\tthis.#closed\n\t\t\t\t\t\t? 'Browser popup record ended because the page closed'\n\t\t\t\t\t\t: 'Browser popup record ended',\n\t\t\t\t)\n\t\t\tif (record.opened === 0) return []\n\t\t\tif (record.outcomes.size >= record.opened || deadline.aborted)\n\t\t\t\treturn [...record.outcomes.values()].filter(\n\t\t\t\t\t(popup): popup is BrowserPage => popup !== undefined && popup.#opener === this,\n\t\t\t\t)\n\t\t\tawait this.#parkPopups(deadline, options?.signal)\n\t\t}\n\t}\n\n\t// Resolves on the next change to a popup record or when `deadline` aborts; rejects with the\n\t// signal's reason on abort.\n\tasync #parkPopups(deadline: AbortSignal, signal: AbortSignal | undefined): Promise<void> {\n\t\tconst wake = Promise.withResolvers<void>()\n\t\tconst abort = this.#abandonPopups.bind(this, wake, signal)\n\t\tthis.#wakes.add(wake.resolve)\n\t\tdeadline.addEventListener('abort', abort, { once: true })\n\t\tsignal?.addEventListener('abort', abort, { once: true })\n\t\ttry {\n\t\t\tawait wake.promise\n\t\t} finally {\n\t\t\tthis.#wakes.delete(wake.resolve)\n\t\t\tdeadline.removeEventListener('abort', abort)\n\t\t\tsignal?.removeEventListener('abort', abort)\n\t\t}\n\t}\n\n\t// The caller's abort rejects a parked settle with its reason; the deadline's wakes it.\n\t#abandonPopups(wake: PromiseWithResolvers<void>, signal: AbortSignal | undefined): void {\n\t\tif (signal?.aborted === true) wake.reject(signal.reason)\n\t\telse wake.resolve()\n\t}\n\n\t#endPopups(key: symbol): void {\n\t\tif (this.#records.delete(key)) this.#wakePopups()\n\t}\n\n\t#wakePopups(): void {\n\t\tfor (const wake of [...this.#wakes]) wake()\n\t}\n\n\t// Chromium 141 reports a window this page's document opens on this page's session before it\n\t// answers the input that opened it; a report names no target, so each one counts. Chromium 141\n\t// announces such a window only to discovery, so a page that takes no part in it counts none.\n\t#handleOpen(): void {\n\t\tif (this.#holder(this.#targetId) !== this) return\n\t\tfor (const [key, record] of this.#records)\n\t\t\tthis.#records.set(key, { ...record, opened: record.opened + 1 })\n\t\tthis.#wakePopups()\n\t}\n\n\t// Names a popup target this page begins to adopt in every open popup record.\n\t#expectPopup(id: string): void {\n\t\tfor (const [key, record] of this.#records)\n\t\t\tthis.#records.set(key, { ...record, targets: new Set([...record.targets, id]) })\n\t}\n\n\t// Concludes a popup target in every open record that expects it: announced with its page, or\n\t// skipped without one when it closed or failed its setup first.\n\t#concludePopup(id: string, popup?: BrowserPage): void {\n\t\tfor (const [key, record] of this.#records)\n\t\t\tif (record.targets.has(id) && !record.outcomes.has(id))\n\t\t\t\tthis.#records.set(key, { ...record, outcomes: new Map([...record.outcomes, [id, popup]]) })\n\t\tthis.#wakePopups()\n\t}\n\n\t// Reads the live page that holds a target on this page's connection.\n\t#holder(id: string): BrowserPage | undefined {\n\t\tconst held = BrowserPage.#held.get(this.#client)?.get(id)\n\t\treturn held === undefined || held.#closed ? undefined : held\n\t}\n\n\t#unhold(): void {\n\t\tconst held = BrowserPage.#held.get(this.#client)\n\t\tif (held?.get(this.#targetId) === this) held.delete(this.#targetId)\n\t}\n\n\t// Takes the discovery reports that waited for this page's target.\n\t#drain(): void {\n\t\tconst reports = BrowserPage.#reports.get(this.#client)\n\t\tif (reports === undefined) return\n\t\tfor (const [id, target] of reports) {\n\t\t\tif (target['openerId'] !== this.#targetId) continue\n\t\t\treports.delete(id)\n\t\t\tthis.#discover(target)\n\t\t}\n\t}\n\n\t// A session attached through a page session detaches only through that session, after the page\n\t// releases its target.\n\tasync #detachChild(session: string, owner: string | undefined): Promise<void> {\n\t\tawait this.#releaseTarget(session)\n\t\tawait this.#client\n\t\t\t.send(\n\t\t\t\t'Target.detachFromTarget',\n\t\t\t\t{ sessionId: session },\n\t\t\t\towner === undefined ? undefined : { session: owner },\n\t\t\t)\n\t\t\t.catch(() => undefined)\n\t}\n\n\tasync #stopLoading(timeout: number): Promise<void> {\n\t\ttry {\n\t\t\tawait this.send('Page.stopLoading', undefined, { timeout })\n\t\t} catch {\n\t\t\t// Best-effort only — the original navigation error wins.\n\t\t}\n\t}\n\n\t#handleNavigationResponse(response: BrowserResponse): void {\n\t\tif (response.frame === this.id) this.#responses?.push(response)\n\t}\n\n\t#handleDestroy(params: Readonly<Record<string, unknown>>): void {\n\t\tif (!isString(params['targetId']) || params['targetId'] !== this.#targetId) return\n\t\tthis.#closed = true\n\t\tvoid this.#release().catch(() => undefined)\n\t}\n\n\t#handleLoad(params: Readonly<Record<string, unknown>>): void {\n\t\tif (isString(params['name'])) {\n\t\t\tif (params['name'] === 'networkIdle' && this.#loader !== undefined) {\n\t\t\t\tif (params['loaderId'] === this.#loader) this.#resolveLoad()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tif (this.#loadEvents.includes('Page.navigatedWithinDocument')) {\n\t\t\tconst frame = params['frameId']\n\t\t\tif (isString(frame) && frame === this.id) {\n\t\t\t\tthis.#sameDocument = true\n\t\t\t\tthis.#resolveLoad()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif (this.#loadEvents.includes('Page.frameNavigated')) {\n\t\t\tconst frame = params['frame']\n\t\t\tif (isRecord(frame) && frame['id'] === this.id) this.#resolveLoad()\n\t\t\treturn\n\t\t}\n\t\tif (\n\t\t\tthis.#loadEvents.includes('Page.loadEventFired') ||\n\t\t\tthis.#loadEvents.includes('Page.domContentEventFired')\n\t\t) {\n\t\t\tthis.#resolveLoad()\n\t\t}\n\t}\n\n\t#handleRestore(params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frame']\n\t\tif (params['type'] === 'BackForwardCacheRestore' && isRecord(frame) && frame['id'] === this.id)\n\t\t\tthis.#resolveLoad()\n\t}\n\n\t// Every session that owns a frame names the parent of a frame it attaches; only the page\n\t// session's frames are announced, as before a frame session reported any.\n\t#handleFrameAttached(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tconst parent = params['parentFrameId']\n\t\tif (!isString(frame) || !this.#accepts(session, frame)) return\n\t\tif (isString(parent)) this.#parents.set(frame, parent)\n\t\tif (session !== this.#sessionId) return\n\t\tthis.#emitter.emit(\n\t\t\t'attach',\n\t\t\tnew BrowserFrame(\n\t\t\t\tthis.#client,\n\t\t\t\t(id) => this.#resolveFrameSession(id),\n\t\t\t\tframe,\n\t\t\t\t'about:blank',\n\t\t\t\tisString(parent) ? parent : undefined,\n\t\t\t\tundefined,\n\t\t\t\ttrue,\n\t\t\t\t() => this.#epochOf(frame),\n\t\t\t\t(owner, call) => this.#world(frame, owner, call),\n\t\t\t),\n\t\t)\n\t}\n\n\t#handleFrameNavigated(params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frame']\n\t\tif (!isRecord(frame) || !isString(frame['id']) || !isString(frame['url'])) return\n\t\tif (frame['id'] !== this.id) {\n\t\t\tthis.#advanceFrame(frame['id'])\n\t\t\tthis.#worlds.delete(frame['id'])\n\t\t\tthis.#creating.delete(frame['id'])\n\t\t\treturn\n\t\t}\n\t\tthis.#advancePage()\n\t\tif (isString(frame['loaderId'])) this.#loader = frame['loaderId']\n\t\tif (params['type'] === 'BackForwardCacheRestore') {\n\t\t\tthis.#dom = this.#loader ?? 'initial'\n\t\t\tfor (const id of this.#readiness.keys()) this.#settleReadiness(id)?.resolve()\n\t\t}\n\t\tthis.update(frame['url'])\n\t\tthis.#emitter.emit('navigate', frame['url'], false)\n\t}\n\n\t// A frame session reports its own frame's committed URL, which `Target.attachedToTarget` does\n\t// not carry before the framed document commits.\n\t// The ownership check precedes every change, so a report the page rejects leaves the frame's\n\t// epoch, world, and parent as they were.\n\t#handleSessionNavigated(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frame']\n\t\tif (!isRecord(frame) || !isString(frame['id']) || !isString(frame['url'])) return\n\t\tif (!this.#accepts(session, frame['id'])) return\n\t\tthis.#handleFrameNavigated(params)\n\t\tthis.#updateFrame(session, frame['id'], {\n\t\t\turl: frame['url'],\n\t\t\tname: isString(frame['name']) && frame['name'] !== '' ? frame['name'] : undefined,\n\t\t})\n\t\tif (isString(frame['parentId'])) this.#parents.set(frame['id'], frame['parentId'])\n\t\tconst loader = isString(frame['loaderId']) ? frame['loaderId'] : undefined\n\t\tthis.#loaders.set(frame['id'], loader)\n\t\tthis.#steps.emit('commit', frame['id'], frame['url'], loader, false)\n\t}\n\n\t#handleSessionRouted(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tconst url = params['url']\n\t\tif (!isString(frame) || !this.#accepts(session, frame)) return\n\t\tthis.#pending.delete(frame)\n\t\tthis.#handleSameDocument(params)\n\t\tif (!isString(url)) return\n\t\tthis.#updateFrame(session, frame, { url })\n\t\tthis.#steps.emit('commit', frame, url, undefined, true)\n\t}\n\n\t// The one ownership rule every navigation step passes: the page session reports every frame in\n\t// the page's process and every swap, and a frame session reports the frame it owns and any frame\n\t// no session owns, until another session supersedes it.\n\t#accepts(session: string, frame: string): boolean {\n\t\tif (session === this.#sessionId) return true\n\t\tif (!this.#frameIds.has(session)) return false\n\t\tconst owner = this.#frameSessions.get(frame)?.session\n\t\treturn owner === undefined || owner === session\n\t}\n\n\t// A start the protocol announces with its loader is the step; the request that precedes it in the\n\t// current tab is the step on a host that announces no start, and carries the navigation's reason\n\t// when it is a `BROWSER_NAVIGATION_REASONS` value.\n\t#handleRequested(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tconst url = params['url']\n\t\tif (params['disposition'] !== 'currentTab' || !isString(frame) || !isString(url)) return\n\t\tconst reason = BROWSER_NAVIGATION_REASONS.find((candidate) => candidate === params['reason'])\n\t\tif (session === this.#sessionId || this.#frameIds.has(session))\n\t\t\tthis.#pending.set(frame, { url, reason })\n\t\tif (!this.#accepts(session, frame)) return\n\t\tthis.#steps.emit('request', frame, url, undefined, reason)\n\t}\n\n\t#handleStarted(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tconst url = params['url']\n\t\tconst loader = params['loaderId']\n\t\tif (!isString(frame) || !isString(url) || !isString(loader) || !this.#accepts(session, frame))\n\t\t\treturn\n\t\t// A reload or a history traversal repeats an entry rather than following a request.\n\t\tconst repeated = BROWSER_RELOAD_NAVIGATION_TYPES.some(\n\t\t\t(type) => type === params['navigationType'],\n\t\t)\n\t\t// Every start ends the frame's pending request, and only the start it requested takes its reason.\n\t\tconst requested = this.#pending.get(frame)\n\t\tthis.#pending.delete(frame)\n\t\tthis.#steps.emit(\n\t\t\t'request',\n\t\t\tframe,\n\t\t\turl,\n\t\t\tloader,\n\t\t\t!repeated && requested?.url === url ? requested.reason : undefined,\n\t\t)\n\t}\n\n\t// Enabling lifecycle events replays earlier lifecycle names under a loader of no navigation, so a\n\t// load step carries its loader for the consumer to match.\n\t#handleSessionLifecycle(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tconst loader = params['loaderId']\n\t\tif (params['name'] !== 'load' || !isString(frame) || !this.#accepts(session, frame)) return\n\t\tthis.#steps.emit('load', frame, isString(loader) ? loader : undefined)\n\t}\n\n\t// A stop carries no loader, so it is a load only for a commit that named none.\n\t#handleStopped(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tif (\n\t\t\t!isString(frame) ||\n\t\t\t!this.#loaders.has(frame) ||\n\t\t\tthis.#loaders.get(frame) !== undefined ||\n\t\t\t!this.#accepts(session, frame)\n\t\t)\n\t\t\treturn\n\t\tthis.#steps.emit('load', frame, undefined)\n\t}\n\n\t// Only the frame's owning session describes its document, so an event from a superseded session\n\t// or about a nested frame leaves the record alone. A commit reports the frame's name, which a\n\t// same-document navigation leaves as it was.\n\t#updateFrame(\n\t\tsession: string,\n\t\tframe: string,\n\t\tupdate: Pick<BrowserFrameInfo, 'url'> & Partial<Pick<BrowserFrameInfo, 'name'>>,\n\t): void {\n\t\tif (this.#frameSessions.get(frame)?.session !== session) return\n\t\tconst attaching = this.#attaching.get(session)\n\t\tif (attaching !== undefined) this.#attaching.set(session, { ...attaching, ...update })\n\t\tconst listed = this.#iframes.get(frame)\n\t\tif (listed !== undefined) this.#iframes.set(frame, { ...listed, ...update })\n\t}\n\n\t#handleSameDocument(params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\tif (!isString(frame)) return\n\t\tthis.#advanceFrame(frame)\n\t\tif (frame !== this.id || !isString(params['url'])) return\n\t\tthis.update(params['url'])\n\t\tthis.#emitter.emit('navigate', params['url'], true)\n\t}\n\n\t#handleFrameDetached(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst frame = params['frameId']\n\t\t// The page session is entitled to report any frame's swap or removal, which `#accepts` grants\n\t\t// it; a frame session reports only a frame it owns.\n\t\tif (!isString(frame) || !this.#accepts(session, frame)) return\n\t\tconst swapped = params['reason'] === 'swap'\n\t\tthis.#advanceFrame(frame)\n\t\tthis.#worlds.delete(frame)\n\t\tthis.#creating.delete(frame)\n\t\t// CDP reports a process replacement as `swap`: the frame persists in another renderer, whose\n\t\t// session `Target.attachedToTarget` can have registered before this detach arrives.\n\t\tif (!swapped) {\n\t\t\tthis.#frameSessions.delete(frame)\n\t\t\tthis.#pending.delete(frame)\n\t\t\tthis.#parents.delete(frame)\n\t\t\tthis.#loaders.delete(frame)\n\t\t\tthis.#emitter.emit('detach', frame)\n\t\t}\n\t\tthis.#steps.emit('detach', frame, swapped)\n\t}\n\n\t#handleDialog(params: Readonly<Record<string, unknown>>): void {\n\t\tconst category = params['type']\n\t\tif (\n\t\t\t(category !== 'alert' &&\n\t\t\t\tcategory !== 'confirm' &&\n\t\t\t\tcategory !== 'prompt' &&\n\t\t\t\tcategory !== 'beforeunload') ||\n\t\t\t!isString(params['message'])\n\t\t) {\n\t\t\treturn\n\t\t}\n\t\tthis.#emitter.emit(\n\t\t\t'dialog',\n\t\t\tnew BrowserDialog(\n\t\t\t\tthis,\n\t\t\t\tcategory,\n\t\t\t\tparams['message'],\n\t\t\t\tisString(params['defaultPrompt']) ? params['defaultPrompt'] : '',\n\t\t\t),\n\t\t)\n\t}\n\n\t#handleChooser(params: Readonly<Record<string, unknown>>): void {\n\t\tconst backend = params['backendNodeId']\n\t\tconst mode = params['mode']\n\t\tif (!isInteger(backend)) return\n\t\tthis.#emitter.emit('chooser', new BrowserFileChooser(this, backend, mode === 'selectMultiple'))\n\t}\n\n\t#handleConsole(params: Readonly<Record<string, unknown>>): void {\n\t\tconst message = parseBrowserConsoleMessage(params)\n\t\tif (message !== undefined) this.#emitter.emit('console', message)\n\t}\n\n\t#handleError(params: Readonly<Record<string, unknown>>): void {\n\t\tconst error = parseBrowserPageError(params)\n\t\tif (error !== undefined) this.#emitter.emit('error', error)\n\t}\n\n\t#handleCrash(): void {\n\t\tthis.#emitter.emit('crash')\n\t}\n\n\t#handleDownload(params: Readonly<Record<string, unknown>>): void {\n\t\tconst start = parseBrowserDownloadStart(params)\n\t\tif (start === undefined || (start.frame !== this.id && !this.#frameSessions.has(start.frame))) {\n\t\t\treturn\n\t\t}\n\t\tconst download = new BrowserDownload(\n\t\t\tthis.#client,\n\t\t\tstart.id,\n\t\t\tstart.url,\n\t\t\tstart.name,\n\t\t\tthis.#contextId,\n\t\t)\n\t\tthis.#downloads.set(start.id, download)\n\t\tthis.#emitter.emit('download', download)\n\t}\n\n\t#handleDownloadProgress(params: Readonly<Record<string, unknown>>): void {\n\t\tconst decoded = parseBrowserDownloadProgress(params)\n\t\tif (decoded === undefined) return\n\t\tconst [id, progress] = decoded\n\t\tconst download = this.#downloads.get(id)\n\t\tif (download === undefined) return\n\t\tdownload.update(progress)\n\t\tif (progress.status !== 'pending') this.#downloads.delete(id)\n\t}\n\n\t// Registers a client's discovery routing with its first held page; the end of each connection\n\t// and each later connection leave no held page and no waiting report, and discovery enables\n\t// again.\n\tstatic #track(client: CDPClientInterface): Map<string, BrowserPage> {\n\t\tconst known = BrowserPage.#held.get(client)\n\t\tif (known !== undefined) return known\n\t\tconst held = new Map<string, BrowserPage>()\n\t\tconst reports = new Map<string, Readonly<Record<string, unknown>>>()\n\t\tBrowserPage.#held.set(client, held)\n\t\tBrowserPage.#reports.set(client, reports)\n\t\tclient.subscribe('Target.targetCreated', (params) => BrowserPage.#route(client, params))\n\t\tclient.subscribe('Target.targetDestroyed', (params) => {\n\t\t\tif (isString(params['targetId'])) reports.delete(params['targetId'])\n\t\t})\n\t\tfor (const event of ['connect', 'close', 'drop'] as const)\n\t\t\tclient.emitter.on(event, () => {\n\t\t\t\theld.clear()\n\t\t\t\treports.clear()\n\t\t\t\tBrowserPage.#discovered.delete(client)\n\t\t\t})\n\t\treturn held\n\t}\n\n\t// Chromium 141 reports a `window.open` page only to browser-session discovery, whose `openerId`\n\t// names the page that opened it, and enumerates existing targets when discovery turns on; a\n\t// report whose opener no page holds yet waits for that page.\n\tstatic #route(client: CDPClientInterface, params: Readonly<Record<string, unknown>>): void {\n\t\tconst target = params['targetInfo']\n\t\tif (\n\t\t\t!isRecord(target) ||\n\t\t\ttarget['type'] !== 'page' ||\n\t\t\ttarget['attached'] === true ||\n\t\t\t!isString(target['targetId']) ||\n\t\t\t!isString(target['openerId'])\n\t\t)\n\t\t\treturn\n\t\tconst opener = BrowserPage.#held.get(client)?.get(target['openerId'])\n\t\tif (opener === undefined || opener.#closed) {\n\t\t\tBrowserPage.#reports.get(client)?.set(target['targetId'], target)\n\t\t\treturn\n\t\t}\n\t\topener.#discover(target)\n\t}\n\n\t#discover(target: Readonly<Record<string, unknown>>): void {\n\t\tconst id = target['targetId']\n\t\tconst context = target['browserContextId']\n\t\tif (\n\t\t\t!isString(id) ||\n\t\t\t(this.#contextId !== undefined && isString(context) && context !== this.#contextId)\n\t\t)\n\t\t\treturn\n\t\tif (this.#closed || this.#popups.has(id) || this.#claimed.has(id)) return\n\t\tthis.#claimed.add(id)\n\t\tthis.#expectPopup(id)\n\t\tconst url = target['url']\n\t\tvoid this.#discoverPopup(id, isString(url) && url !== '' ? url : undefined)\n\t}\n\n\t// `owner` is the session that reported the attach: the page session for a page, a worker, or a\n\t// frame the page's process embeds, and a frame session for a frame nested in its frame.\n\t#handleAttached(owner: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst target = params['targetInfo']\n\t\tconst session = params['sessionId']\n\t\tif (!isRecord(target) || !isString(target['targetId']) || !isString(session)) {\n\t\t\treturn\n\t\t}\n\n\t\tconst category = target['type']\n\t\tif (owner !== this.#sessionId && category !== 'iframe') return\n\t\tif (category === 'worker' || category === 'service_worker' || category === 'shared_worker') {\n\t\t\tvoid this.#attachWorker(\n\t\t\t\tsession,\n\t\t\t\ttarget['targetId'],\n\t\t\t\tisString(target['url']) ? target['url'] : '',\n\t\t\t\tcategory,\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tif (category === 'page') {\n\t\t\tconst id = target['targetId']\n\t\t\tif (this.#popups.has(id) || this.#claimed.has(id)) {\n\t\t\t\tvoid this.#detachChild(session, this.#sessionId)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.#claimed.add(id)\n\t\t\tthis.#expectPopup(id)\n\t\t\tvoid this.#attachPopup(\n\t\t\t\tsession,\n\t\t\t\tid,\n\t\t\t\tisString(target['url']) ? target['url'] : 'about:blank',\n\t\t\t\tthis.#sessionId,\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tif (category !== 'iframe') {\n\t\t\tthis.#resumeTarget(session)\n\t\t\treturn\n\t\t}\n\n\t\tconst frame = target['targetId']\n\t\tconst named = isString(target['parentFrameId'])\n\t\tconst parent = isString(target['parentFrameId'])\n\t\t\t? target['parentFrameId']\n\t\t\t: this.#parents.get(frame)\n\t\tif (parent !== undefined) this.#parents.set(frame, parent)\n\t\tconst attached: BrowserFrameInfo = {\n\t\t\tid: frame,\n\t\t\tparent,\n\t\t\tname: undefined,\n\t\t\turl: isString(target['url']) ? target['url'] : 'about:blank',\n\t\t}\n\t\tthis.#attaching.set(session, attached)\n\t\tthis.#worlds.delete(frame)\n\t\tthis.#creating.delete(frame)\n\t\t// A later attach for the same frame supersedes every earlier session, which stops describing\n\t\t// the frame here and keeps no pending record to publish.\n\t\tfor (const [other, owned] of this.#frameIds) {\n\t\t\tif (owned !== frame || other === session) continue\n\t\t\tthis.#attaching.delete(other)\n\t\t\tthis.#frameIds.delete(other)\n\t\t\tthis.#unwatchSession(other)\n\t\t}\n\t\tthis.#watchSession(session)\n\t\tconst attempt = this.#enableFrameSession(session)\n\t\tthis.#frameSessions.set(frame, { session, attempt })\n\t\tthis.#frameIds.set(session, frame)\n\t\tvoid attempt.then(this.#readFrameTree.bind(this, session, attached, named)).then(\n\t\t\t() => {\n\t\t\t\tconst info = this.#attaching.get(session)\n\t\t\t\tthis.#attaching.delete(session)\n\t\t\t\tif (\n\t\t\t\t\tinfo === undefined ||\n\t\t\t\t\tthis.#closed ||\n\t\t\t\t\tthis.#frameSessions.get(frame)?.attempt !== attempt\n\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\tthis.#iframes.set(frame, info)\n\t\t\t\tthis.#emitter.emit('session', this.#frame(info))\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.#attaching.delete(session)\n\t\t\t\tif (this.#frameSessions.get(frame)?.attempt === attempt) this.#frameSessions.delete(frame)\n\t\t\t\tif (this.#frameIds.get(session) === frame) this.#frameIds.delete(session)\n\t\t\t\tthis.#unwatchSession(session)\n\t\t\t\tvoid this.#detachChild(session, owner)\n\t\t\t},\n\t\t)\n\t}\n\n\t#handleDetached(params: Readonly<Record<string, unknown>>): void {\n\t\tconst session = params['sessionId']\n\t\tconst target = params['targetId']\n\t\tif (isString(target)) {\n\t\t\tconst worker = this.#workers.get(target)\n\t\t\tif (worker !== undefined) {\n\t\t\t\tworker.detach()\n\t\t\t\tthis.#workers.delete(target)\n\t\t\t}\n\t\t\tconst popup = this.#popups.get(target)\n\t\t\t// A detached second session of a popup leaves the popup on the session it was published on.\n\t\t\tif (popup !== undefined && popup.#sessionId === session) {\n\t\t\t\tthis.#popups.delete(target)\n\t\t\t\tvoid popup.destroy().catch(() => undefined)\n\t\t\t}\n\t\t}\n\t\tconst frame = isString(target)\n\t\t\t? target\n\t\t\t: isString(session)\n\t\t\t\t? this.#frameIds.get(session)\n\t\t\t\t: undefined\n\t\tconst owner = frame === undefined ? undefined : this.#frameSessions.get(frame)?.session\n\t\t// A superseded session's detach leaves the frame to the session that replaced it.\n\t\tconst superseded = isString(session) && owner !== undefined && owner !== session\n\t\tif (frame !== undefined && !superseded) {\n\t\t\tif (this.#frameSessions.delete(frame)) this.#advanceFrame(frame)\n\t\t\tthis.#pending.delete(frame)\n\t\t\tthis.#iframes.delete(frame)\n\t\t\tthis.#worlds.delete(frame)\n\t\t\tthis.#creating.delete(frame)\n\t\t}\n\t\tif (isString(session) && this.#frameIds.delete(session)) this.#unwatchSession(session)\n\t}\n\n\t#handleContextDestroyed(session: string, params: Readonly<Record<string, unknown>>): void {\n\t\tconst context = params['executionContextId']\n\t\tif (!isInteger(context)) return\n\t\tfor (const [frame, world] of this.#worlds) {\n\t\t\tif (world.session === session && world.context === context) this.#worlds.delete(frame)\n\t\t}\n\t}\n\n\t#handleContextsCleared(session: string): void {\n\t\tfor (const [frame, world] of this.#worlds) {\n\t\t\tif (world.session === session) this.#worlds.delete(frame)\n\t\t}\n\t\tfor (const [frame, pending] of this.#creating) {\n\t\t\tif (pending.session === session) this.#creating.delete(frame)\n\t\t}\n\t}\n\n\t// A signal ends the load wait with its reason, so an abort after `Page.navigate` replied is\n\t// reported as the abort rather than as the navigation timeout.\n\t#waitForLoadEvent(\n\t\tcondition: BrowserWaitUntil,\n\t\ttimeout: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<void> {\n\t\tconst eventName =\n\t\t\tcondition === 'commit'\n\t\t\t\t? 'Page.frameNavigated'\n\t\t\t\t: condition === 'domcontentloaded'\n\t\t\t\t\t? 'Page.domContentEventFired'\n\t\t\t\t\t: condition === 'idle'\n\t\t\t\t\t\t? 'Page.lifecycleEvent'\n\t\t\t\t\t\t: 'Page.loadEventFired'\n\t\tconst deferred = Promise.withResolvers<void>()\n\t\tthis.#sameDocument = false\n\t\tif (condition === 'idle') this.#loader = undefined\n\t\tthis.#loadEvents = [eventName, 'Page.navigatedWithinDocument']\n\t\tthis.#loadResolve = deferred.resolve\n\t\tthis.#loadReject = deferred.reject\n\t\tthis.#loadTimer = setTimeout(() => {\n\t\t\tthis.#rejectLoad(new BrowserError(`Navigation timeout after ${timeout}ms`))\n\t\t}, timeout)\n\t\tfor (const event of this.#loadEvents) {\n\t\t\tthis.#client.subscribe(event, this.#loadHandler, this.#sessionId)\n\t\t}\n\t\tif (signal !== undefined) {\n\t\t\tconst listener = this.#abortLoad.bind(this, signal)\n\t\t\tthis.#loadAbort = { signal, listener }\n\t\t\tsignal.addEventListener('abort', listener, { once: true })\n\t\t}\n\t\treturn deferred.promise\n\t}\n\n\t#abortLoad(signal: AbortSignal): void {\n\t\tthis.#rejectLoad(signal.reason)\n\t}\n\n\t#resolveLoad(): void {\n\t\tconst resolve = this.#loadResolve\n\t\tthis.#clearLoad()\n\t\tresolve?.()\n\t}\n\n\t#rejectLoad(error: unknown): void {\n\t\tconst reject = this.#loadReject\n\t\tthis.#clearLoad()\n\t\treject?.(error)\n\t}\n\n\t#cancelLoad(): void {\n\t\tthis.#rejectLoad(new BrowserError('Navigation cancelled'))\n\t}\n\n\t#clearLoad(): void {\n\t\tif (this.#loadTimer !== undefined) clearTimeout(this.#loadTimer)\n\t\tfor (const event of this.#loadEvents) {\n\t\t\tthis.#client.unsubscribe(event, this.#loadHandler, this.#sessionId)\n\t\t}\n\t\tthis.#loadEvents = []\n\t\tthis.#loadAbort?.signal.removeEventListener('abort', this.#loadAbort.listener)\n\t\tthis.#loadAbort = undefined\n\t\tthis.#loadTimer = undefined\n\t\tthis.#loadResolve = undefined\n\t\tthis.#loadReject = undefined\n\t}\n}\n","import type { BrowserPermissionManagerInterface, CDPClientInterface } from './types.js'\n\n/**\n * Applies permission overrides isolated to one browser context.\n *\n * @example\n * ```ts\n * import { BrowserPermissionManager } from '@orkestrel/browser'\n *\n * const permissions = new BrowserPermissionManager(client)\n * await permissions.grant(['geolocation'], 'https://example.com')\n * await permissions.clear()\n * ```\n */\nexport class BrowserPermissionManager implements BrowserPermissionManagerInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #context: string | undefined\n\n\tconstructor(client: CDPClientInterface, context?: string) {\n\t\tthis.#client = client\n\t\tthis.#context = context\n\t}\n\n\tasync grant(permissions: readonly string[], origin?: string): Promise<void> {\n\t\tawait this.#set(permissions, 'granted', origin)\n\t}\n\n\tasync deny(permissions: readonly string[], origin?: string): Promise<void> {\n\t\tawait this.#set(permissions, 'denied', origin)\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tconst params: Record<string, unknown> = {}\n\t\tif (this.#context !== undefined) params['browserContextId'] = this.#context\n\t\tawait this.#client.send('Browser.resetPermissions', params)\n\t}\n\n\tasync #set(\n\t\tpermissions: readonly string[],\n\t\tsetting: 'granted' | 'denied',\n\t\torigin?: string,\n\t): Promise<void> {\n\t\tfor (const name of permissions) {\n\t\t\tconst params: Record<string, unknown> = {\n\t\t\t\tpermission: { name },\n\t\t\t\tsetting,\n\t\t\t}\n\t\t\tif (origin !== undefined) params['origin'] = origin\n\t\t\tif (this.#context !== undefined) params['browserContextId'] = this.#context\n\t\t\tawait this.#client.send('Browser.setPermission', params)\n\t\t}\n\t}\n}\n","import type {\n\tBrowserCookieInput,\n\tBrowserCookieManagerInterface,\n\tBrowserPagesFunction,\n\tBrowserStorageManagerInterface,\n\tBrowserStorageOptions,\n\tBrowserStorageOrigin,\n\tBrowserStorageState,\n} from './types.js'\nimport {\n\tcompileStorageClearExpression,\n\tcompileStorageReadExpression,\n\tcompileStorageRestoreExpression,\n} from './compilers.js'\nimport { readBrowserStorageOrigin } from './helpers.js'\nimport { BrowserError } from './errors.js'\nimport { attempt } from '@orkestrel/contract'\n\n/**\n * Imports, exports, and clears cookie and web-storage state for one browser context.\n *\n * @example\n * ```ts\n * import { BrowserStorageManager } from '@orkestrel/browser'\n *\n * const storage = new BrowserStorageManager(context.cookies, () => context.pages())\n * const state = await storage.state({ origins: ['https://example.com'] })\n * await storage.restore(state)\n * ```\n */\nexport class BrowserStorageManager implements BrowserStorageManagerInterface {\n\treadonly #cookies: BrowserCookieManagerInterface\n\treadonly #pages: BrowserPagesFunction\n\n\tconstructor(cookies: BrowserCookieManagerInterface, pages: BrowserPagesFunction) {\n\t\tthis.#cookies = cookies\n\t\tthis.#pages = pages\n\t}\n\n\tasync state(options?: BrowserStorageOptions): Promise<BrowserStorageState> {\n\t\tconst pages = this.#pages()\n\t\tconst requested = options?.origins\n\t\tconst origins =\n\t\t\trequested === undefined\n\t\t\t\t? [\n\t\t\t\t\t\t...new Set(\n\t\t\t\t\t\t\tpages.map((page) => this.#origin(page.url)).filter((origin) => origin !== undefined),\n\t\t\t\t\t\t),\n\t\t\t\t\t]\n\t\t\t\t: [...new Set(requested.map((origin) => this.#validate(origin)))]\n\t\tconst storage: BrowserStorageOrigin[] = []\n\n\t\tfor (const origin of origins) {\n\t\t\tconst page = pages.find((candidate) => this.#origin(candidate.url) === origin)\n\t\t\tif (page === undefined) {\n\t\t\t\tthrow new BrowserError('Storage origin has no attached page', undefined, { origin })\n\t\t\t}\n\t\t\tstorage.push(\n\t\t\t\treadBrowserStorageOrigin(await page.evaluate(compileStorageReadExpression()), origin),\n\t\t\t)\n\t\t}\n\n\t\tconst cookies: BrowserCookieInput[] = (await this.#cookies.cookies()).map((cookie) => ({\n\t\t\tname: cookie.name,\n\t\t\tvalue: cookie.value,\n\t\t\tdomain: cookie.domain,\n\t\t\tpath: cookie.path,\n\t\t\texpires: cookie.expires,\n\t\t\thttp: cookie.http,\n\t\t\tsecure: cookie.secure,\n\t\t\t...(cookie.site !== undefined ? { site: cookie.site } : {}),\n\t\t\t...(cookie.partition !== undefined ? { partition: cookie.partition } : {}),\n\t\t}))\n\t\treturn { cookies, origins: storage }\n\t}\n\n\tasync restore(state: BrowserStorageState): Promise<void> {\n\t\tconst pages = this.#pages()\n\t\tfor (const origin of state.origins) {\n\t\t\tconst normalized = this.#validate(origin.origin)\n\t\t\tconst page = pages.find((candidate) => this.#origin(candidate.url) === normalized)\n\t\t\tif (page === undefined) {\n\t\t\t\tthrow new BrowserError('Storage origin has no attached page', undefined, {\n\t\t\t\t\torigin: normalized,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tawait this.#cookies.set(state.cookies)\n\t\tfor (const origin of state.origins) {\n\t\t\tconst normalized = this.#validate(origin.origin)\n\t\t\tconst page = pages.find((candidate) => this.#origin(candidate.url) === normalized)\n\t\t\tif (page === undefined) {\n\t\t\t\tthrow new BrowserError('Storage origin disappeared during restore', undefined, {\n\t\t\t\t\torigin: normalized,\n\t\t\t\t})\n\t\t\t}\n\t\t\tawait page.evaluate(compileStorageRestoreExpression(origin))\n\t\t}\n\t}\n\n\tasync clear(origin?: string): Promise<void> {\n\t\tawait this.#cookies.clear()\n\t\tconst normalized = origin === undefined ? undefined : this.#validate(origin)\n\t\tfor (const page of this.#pages()) {\n\t\t\tif (normalized !== undefined && this.#origin(page.url) !== normalized) continue\n\t\t\tawait page.evaluate(compileStorageClearExpression())\n\t\t}\n\t}\n\n\t#origin(value: string): string | undefined {\n\t\tconst result = attempt(() => new URL(value))\n\t\tif (!result.success) return undefined\n\t\tif (result.value.protocol !== 'http:' && result.value.protocol !== 'https:') return undefined\n\t\treturn result.value.origin\n\t}\n\n\t#validate(value: string): string {\n\t\tconst origin = this.#origin(value)\n\t\tif (origin === undefined) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Browser storage origin must be an absolute HTTP(S) origin',\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\torigin: value,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn origin\n\t}\n}\n","import type {\n\tBrowserContextEventMap,\n\tBrowserContextInterface,\n\tBrowserContextOptions,\n\tBrowserCookieManagerInterface,\n\tBrowserDownloadOptions,\n\tBrowserEmulationManagerInterface,\n\tBrowserEmulationOptions,\n\tBrowserPageEventMap,\n\tBrowserPageInterface,\n\tBrowserPageOptions,\n\tBrowserPermissionManagerInterface,\n\tBrowserStorageManagerInterface,\n\tBrowserViewport,\n\tCDPClientInterface,\n\tCDPTarget,\n\tBrowserWriterInterface,\n} from './types.js'\nimport type { EmitterErrorHandler, EmitterHooks, EmitterInterface } from '@orkestrel/emitter'\nimport { BrowserCookieManager } from './BrowserCookieManager.js'\nimport { BrowserTransition } from './BrowserTransition.js'\nimport { BrowserEmulationManager } from './BrowserEmulationManager.js'\nimport { BrowserPage } from './BrowserPage.js'\nimport { BrowserPermissionManager } from './BrowserPermissionManager.js'\nimport { BrowserStorageManager } from './BrowserStorageManager.js'\nimport { BrowserError } from './errors.js'\nimport { BROWSER_REFERENCE_PREFIX } from './constants.js'\nimport { readBrowserFrames, settleBrowserTeardown, validateBrowserViewport } from './helpers.js'\nimport { instanceOf, isRecord, isString } from '@orkestrel/contract'\nimport { Emitter, extractKeys } from '@orkestrel/emitter'\n\n// === BrowserContext\n\n/**\n * Owns pages and shared state inside one Chromium browser context.\n *\n * @remarks\n * Every page a context constructs holds its target on the client's connection, so `sync` and a\n * popup that discovery reports for the same target yield one page, and the first such page on a\n * connection enables `Target.setDiscoverTargets` for it. The context adopts every popup its pages\n * publish into `pages()` after its opener, and emits `page` once per page; a popup that closed\n * before its adoption completed is not adopted.\n *\n * @example\n * ```ts\n * import { BrowserContext } from '@orkestrel/browser'\n *\n * const context = new BrowserContext(client)\n * const page = await context.create({ url: 'https://example.com' })\n * await context.destroy()\n * ```\n */\nexport class BrowserContext implements BrowserContextInterface {\n\treadonly #client: CDPClientInterface\n\treadonly #id: string | undefined\n\treadonly #viewport: BrowserViewport | undefined\n\treadonly #writer: BrowserWriterInterface | undefined\n\treadonly #downloads: BrowserDownloadOptions | undefined\n\treadonly #emitter: Emitter<BrowserContextEventMap>\n\treadonly #cookies: BrowserCookieManager\n\treadonly #permissions: BrowserPermissionManager\n\treadonly #storage: BrowserStorageManager\n\treadonly #emulation: BrowserEmulationManager\n\treadonly #pages: Map<string, BrowserPage> = new Map()\n\treadonly #creating: Set<Promise<BrowserPage>> = new Set()\n\treadonly #syncing: BrowserTransition = new BrowserTransition()\n\t// The attach by `create` or `sync` in flight for each target, which a popup adoption waits for.\n\treadonly #publishing: Map<string, Promise<void>> = new Map()\n\treadonly #observed: WeakSet<BrowserPage> = new WeakSet()\n\t#shutdown: Promise<void> | undefined\n\t#reference = 0\n\n\tconstructor(\n\t\tclient: CDPClientInterface,\n\t\tid?: string,\n\t\tviewport?: BrowserViewport,\n\t\twriter?: BrowserWriterInterface,\n\t\temulation?: BrowserEmulationOptions,\n\t\tdownloads?: BrowserDownloadOptions,\n\t\toptions?: BrowserContextOptions,\n\t) {\n\t\tthis.#client = client\n\t\tif (viewport !== undefined) validateBrowserViewport(viewport)\n\t\tthis.#id = id\n\t\tthis.#viewport = viewport\n\t\tthis.#writer = writer\n\t\tthis.#downloads = downloads\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on !== undefined ? { on: options.on } : {}),\n\t\t\t...(options?.error !== undefined ? { error: options.error } : {}),\n\t\t})\n\t\tthis.#cookies = new BrowserCookieManager(client, id)\n\t\tthis.#permissions = new BrowserPermissionManager(client, id)\n\t\tthis.#storage = new BrowserStorageManager(this.#cookies, () => this.pages())\n\t\tthis.#emulation = new BrowserEmulationManager(() => this.pages(), emulation)\n\t}\n\n\tget emitter(): EmitterInterface<BrowserContextEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget id(): string | undefined {\n\t\treturn this.#id\n\t}\n\n\tget cookies(): BrowserCookieManagerInterface {\n\t\treturn this.#cookies\n\t}\n\n\tget permissions(): BrowserPermissionManagerInterface {\n\t\treturn this.#permissions\n\t}\n\n\tget storage(): BrowserStorageManagerInterface {\n\t\treturn this.#storage\n\t}\n\n\tget emulation(): BrowserEmulationManagerInterface {\n\t\treturn this.#emulation\n\t}\n\n\tpage(index?: number): BrowserPageInterface | undefined {\n\t\tconst i = index ?? 0\n\t\tconst pages = [...this.#pages.values()]\n\t\treturn i >= 0 && i < pages.length ? pages[i] : undefined\n\t}\n\n\tpages(): readonly BrowserPageInterface[] {\n\t\treturn [...this.#pages.values()]\n\t}\n\n\tasync create(options?: BrowserPageOptions): Promise<BrowserPageInterface> {\n\t\tif (this.#shutdown !== undefined)\n\t\t\tthrow new BrowserError('Browser context is closed', 'BROWSER_CONTEXT_CLOSED')\n\n\t\tconst attempt = this.#create(options)\n\t\tthis.#creating.add(attempt)\n\t\ttry {\n\t\t\treturn await attempt\n\t\t} finally {\n\t\t\tthis.#creating.delete(attempt)\n\t\t}\n\t}\n\n\tasync sync(targets: readonly CDPTarget[]): Promise<void> {\n\t\tlet active = this.#syncing.pending\n\t\twhile (active !== undefined) {\n\t\t\tawait active\n\t\t\tactive = this.#syncing.pending\n\t\t}\n\t\tif (this.#shutdown !== undefined)\n\t\t\tthrow new BrowserError('Browser context is closed', 'BROWSER_CONTEXT_CLOSED')\n\n\t\tawait this.#syncing.execute(() => this.#sync(targets))\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tconst active = this.#shutdown\n\t\tif (active !== undefined) return active\n\n\t\tconst shutdown = this.#destroyResources()\n\t\tthis.#shutdown = shutdown\n\t\treturn shutdown\n\t}\n\n\tclose(): Promise<void> {\n\t\tconst active = this.#shutdown\n\t\tif (active !== undefined) return active\n\n\t\tconst shutdown = this.#closeResources()\n\t\tthis.#shutdown = shutdown\n\t\treturn shutdown\n\t}\n\n\t// === Private helpers\n\n\tasync #create(options?: BrowserPageOptions): Promise<BrowserPage> {\n\t\tif (options?.viewport !== undefined) validateBrowserViewport(options.viewport)\n\t\tconst result: unknown = await this.#client.send('Target.createTarget', {\n\t\t\turl: 'about:blank',\n\t\t\t...(this.#id === undefined ? {} : { browserContextId: this.#id }),\n\t\t})\n\n\t\tif (!isRecord(result) || !isString(result['targetId'])) {\n\t\t\tthrow new BrowserError('Failed to create new browser target')\n\t\t}\n\n\t\tconst targetId = result['targetId']\n\t\tlet page: BrowserPage | undefined\n\t\tconst published = await this.#acquire(targetId)\n\t\tif (published === undefined) return await this.#join(targetId, options)\n\n\t\ttry {\n\t\t\tconst viewport = options?.viewport ?? this.#viewport\n\t\t\tpage = await this.#attach(\n\t\t\t\ttargetId,\n\t\t\t\toptions?.url ?? 'about:blank',\n\t\t\t\tviewport,\n\t\t\t\tpublished.promise,\n\t\t\t\toptions,\n\t\t\t)\n\n\t\t\tif (options?.url !== undefined && options.url !== 'about:blank') {\n\t\t\t\tawait page.navigate(options.url, {\n\t\t\t\t\t...(options.timeout !== undefined ? { timeout: options.timeout } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (this.#shutdown !== undefined) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t'Browser context closed during page creation',\n\t\t\t\t\t'BROWSER_CONTEXT_CLOSED',\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tif (!this.#publish(page)) throw this.#refuse(targetId)\n\t\t\tpublished.resolve()\n\t\t\treturn page\n\t\t} catch (error) {\n\t\t\tif (page !== undefined) {\n\t\t\t\tawait page.close()\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\t// A target another path already holds stays open; the creation joins that path's page.\n\t\t\tif (instanceOf(BrowserError)(error) && error.code === 'BROWSER_TARGET_HELD') {\n\t\t\t\tthis.#unreserve(targetId, published)\n\t\t\t\tconst retry = await this.#acquire(targetId)\n\t\t\t\tif (retry === undefined) return await this.#join(targetId, options)\n\t\t\t\tthis.#unreserve(targetId, retry)\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tawait this.#closeTarget(targetId)\n\t\t\tthrow error\n\t\t} finally {\n\t\t\tthis.#unreserve(targetId, published)\n\t\t}\n\t}\n\n\tasync #sync(targets: readonly CDPTarget[]): Promise<void> {\n\t\tconst pageTargets = targets.filter((target) => target.category === 'page')\n\t\tconst targetIds = new Set(pageTargets.map((target) => target.id))\n\n\t\tfor (const [id, page] of this.#pages) {\n\t\t\tif (targetIds.has(id)) continue\n\t\t\tawait page.destroy()\n\t\t\tthis.#pages.delete(id)\n\t\t}\n\n\t\tfor (const target of pageTargets) {\n\t\t\tif (this.#shutdown !== undefined) continue\n\t\t\tconst published = await this.#acquire(target.id)\n\t\t\tif (published === undefined) continue\n\t\t\ttry {\n\t\t\t\tconst page = await this.#reattach(target.id, target.url, this.#viewport, published.promise)\n\t\t\t\tif (this.#shutdown !== undefined) {\n\t\t\t\t\tawait page.destroy()\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t// A page that closed before its publication settles the reservation as a failure.\n\t\t\t\tif (this.#publish(page)) published.resolve()\n\t\t\t} catch {\n\t\t\t\t// A disappearing or unsupported target, or one a popup attach already holds, does not\n\t\t\t\t// invalidate its siblings.\n\t\t\t} finally {\n\t\t\t\tthis.#unreserve(target.id, published)\n\t\t\t}\n\t\t}\n\t}\n\n\tasync #attach(\n\t\ttargetId: string,\n\t\turl: string,\n\t\tviewport: BrowserViewport | undefined,\n\t\tready: Promise<void>,\n\t\toptions?: BrowserPageOptions,\n\t): Promise<BrowserPage> {\n\t\tlet sessionId: string | undefined\n\t\tlet page: BrowserPage | undefined\n\n\t\ttry {\n\t\t\tsessionId = await this.#openSession(targetId)\n\t\t\tawait this.#enableSession(sessionId)\n\t\t\tconst frameId = await this.#mainFrame(sessionId)\n\t\t\tpage = new BrowserPage(\n\t\t\t\tthis.#client,\n\t\t\t\ttargetId,\n\t\t\t\tsessionId,\n\t\t\t\tthis.#writer,\n\t\t\t\turl,\n\t\t\t\tframeId,\n\t\t\t\tthis.#id,\n\t\t\t\tundefined,\n\t\t\t\toptions,\n\t\t\t\tthis.#nextReference.bind(this),\n\t\t\t\tready,\n\t\t\t)\n\t\t\tthis.#observe(page)\n\t\t\tawait this.#configurePage(page)\n\t\t\tawait this.#emulation.attach(page)\n\t\t\tif (viewport !== undefined) await this.#applyViewport(page, viewport)\n\n\t\t\treturn page\n\t\t} catch (error) {\n\t\t\tif (page !== undefined) await page.destroy().catch(() => undefined)\n\t\t\telse if (sessionId !== undefined) await this.#detachSession(sessionId)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #reattach(\n\t\ttargetId: string,\n\t\turl: string,\n\t\tviewport: BrowserViewport | undefined,\n\t\tready: Promise<void>,\n\t): Promise<BrowserPage> {\n\t\tlet sessionId: string | undefined\n\t\tlet page: BrowserPage | undefined\n\n\t\ttry {\n\t\t\tsessionId = await this.#openSession(targetId)\n\t\t\tawait this.#enableSession(sessionId)\n\t\t\tconst frameId = await this.#mainFrame(sessionId)\n\t\t\tpage = new BrowserPage(\n\t\t\t\tthis.#client,\n\t\t\t\ttargetId,\n\t\t\t\tsessionId,\n\t\t\t\tthis.#writer,\n\t\t\t\turl,\n\t\t\t\tframeId,\n\t\t\t\tthis.#id,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tthis.#nextReference.bind(this),\n\t\t\t\tready,\n\t\t\t)\n\t\t\tthis.#observe(page)\n\t\t\tawait this.#configurePage(page)\n\t\t\tawait this.#emulation.attach(page)\n\t\t\tif (viewport !== undefined) await this.#tryViewport(page, viewport)\n\n\t\t\treturn page\n\t\t} catch (error) {\n\t\t\tif (page !== undefined) await page.destroy().catch(() => undefined)\n\t\t\telse if (sessionId !== undefined) await this.#detachSession(sessionId)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t#nextReference(): string {\n\t\treturn `${BROWSER_REFERENCE_PREFIX}${++this.#reference}`\n\t}\n\n\tasync #destroyResources(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#settle()\n\t\t\tconst failure = await settleBrowserTeardown(\n\t\t\t\t...[...this.#pages.values()].map((page) => () => page.destroy()),\n\t\t\t)\n\t\t\tthis.#pages.clear()\n\t\t\tif (failure !== undefined) throw failure\n\t\t} finally {\n\t\t\tthis.#finish()\n\t\t}\n\t}\n\n\tasync #closeResources(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#settle()\n\t\t\tlet failure = await settleBrowserTeardown(\n\t\t\t\t...[...this.#pages.values()].map((page) => () => page.close()),\n\t\t\t)\n\t\t\tthis.#pages.clear()\n\n\t\t\tconst id = this.#id\n\t\t\tif (id !== undefined) {\n\t\t\t\tconst settled = await settleBrowserTeardown(() =>\n\t\t\t\t\tthis.#client.send('Target.disposeBrowserContext', { browserContextId: id }),\n\t\t\t\t)\n\t\t\t\tfailure ??= settled\n\t\t\t}\n\t\t\tif (failure !== undefined) throw failure\n\t\t} finally {\n\t\t\tthis.#finish()\n\t\t}\n\t}\n\n\tasync #settle(): Promise<void> {\n\t\tawait Promise.allSettled([...this.#creating])\n\t\tawait this.#syncing.pending?.catch(() => undefined)\n\t}\n\n\t// Acquires a target's reservation for `create` or `sync`: after every wait for the current\n\t// reservation to settle, the check for a held page and for a current reservation and the\n\t// installation of this one run as one synchronous step, so a waiter that resumes never installs\n\t// over a reservation another path installed while it waited. Undefined when the context holds\n\t// a page for the target.\n\tasync #acquire(target: string): Promise<PromiseWithResolvers<void> | undefined> {\n\t\tfor (\n\t\t\tlet current = this.#publishing.get(target);\n\t\t\tcurrent !== undefined;\n\t\t\tcurrent = this.#publishing.get(target)\n\t\t)\n\t\t\tawait Promise.allSettled([current])\n\t\treturn this.#pages.has(target) ? undefined : this.#reserve(target)\n\t}\n\n\t// Joins a creation to the page another path published for its target, applying the creation's\n\t// hooks, viewport, and navigation to it; a page that closed first or meanwhile rejects.\n\tasync #join(target: string, options?: BrowserPageOptions): Promise<BrowserPage> {\n\t\tconst page = this.#pages.get(target)\n\t\tif (page === undefined || page.closed) throw this.#refuse(target)\n\t\tconst hooks = options?.on\n\t\tif (hooks !== undefined)\n\t\t\tfor (const event of extractKeys(hooks)) this.#hook(page, event, hooks, options?.error)\n\t\ttry {\n\t\t\tif (options?.viewport !== undefined) await this.#applyViewport(page, options.viewport)\n\t\t\t// A joined page can have left the blank document the target was created at.\n\t\t\tif (options?.url !== undefined) {\n\t\t\t\tawait page.navigate(options.url, {\n\t\t\t\t\t...(options.timeout !== undefined ? { timeout: options.timeout } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (page.closed) throw this.#refuse(target)\n\t\t\tthrow error\n\t\t}\n\t\tif (page.closed || this.#pages.get(target) !== page) throw this.#refuse(target)\n\t\treturn page\n\t}\n\n\t// Registers one creation hook on a joined page, reporting its throw to the creation's own\n\t// `error` handler, as the emitter a creation constructs would, and never to the page's.\n\t#hook<K extends keyof BrowserPageEventMap>(\n\t\tpage: BrowserPage,\n\t\tevent: K,\n\t\thooks: EmitterHooks<BrowserPageEventMap>,\n\t\treport: EmitterErrorHandler | undefined,\n\t): void {\n\t\tconst handler = hooks[event]\n\t\tif (handler === undefined) return\n\t\tpage.emitter.on(event, (...args) => {\n\t\t\ttry {\n\t\t\t\thandler(...args)\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\treport?.(error, String(event))\n\t\t\t\t} catch {\n\t\t\t\t\t// A throwing reporter is swallowed, as the emitter swallows its own.\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\t#refuse(target: string): BrowserError {\n\t\treturn new BrowserError('Browser page closed during creation', 'BROWSER_PAGE_CLOSED', {\n\t\t\ttarget,\n\t\t})\n\t}\n\n\t// Installs a target's reservation, which a popup adoption of a descendant waits for; the page it\n\t// passes as `ready` holds its target until the publication fails. `create` and `sync` install\n\t// one only through `#acquire`; an adoption replaces the current one and waits for it.\n\t#reserve(target: string): PromiseWithResolvers<void> {\n\t\tconst published = Promise.withResolvers<void>()\n\t\tvoid published.promise.catch(() => undefined)\n\t\tthis.#publishing.set(target, published.promise)\n\t\treturn published\n\t}\n\n\t#unreserve(target: string, published: PromiseWithResolvers<void>): void {\n\t\tif (this.#publishing.get(target) === published.promise) this.#publishing.delete(target)\n\t\tpublished.reject(new BrowserError('Browser page was not published'))\n\t}\n\n\t// Publishes a live page once; true if the context holds it afterwards, false for a closed page.\n\t#publish(page: BrowserPage): boolean {\n\t\tif (page.closed) return false\n\t\tif (this.#pages.get(page.target) === page) return true\n\t\tthis.#pages.set(page.target, page)\n\t\tthis.#emitter.emit('page', page)\n\t\treturn true\n\t}\n\n\tasync #openSession(targetId: string): Promise<string> {\n\t\tconst result: unknown = await this.#client.send('Target.attachToTarget', {\n\t\t\ttargetId,\n\t\t\tflatten: true,\n\t\t})\n\t\tif (!isRecord(result) || !isString(result['sessionId'])) {\n\t\t\tthrow new BrowserError('Failed to attach to browser target')\n\t\t}\n\t\treturn result['sessionId']\n\t}\n\n\tasync #enableSession(sessionId: string): Promise<void> {\n\t\tawait this.#client.send('Page.enable', undefined, { session: sessionId })\n\t\tawait this.#client.send('Runtime.enable', undefined, { session: sessionId })\n\t}\n\n\tasync #mainFrame(sessionId: string): Promise<string> {\n\t\tconst result = await this.#client.send('Page.getFrameTree', undefined, { session: sessionId })\n\t\tconst frame = readBrowserFrames(result)[0]\n\t\tif (frame === undefined) throw new BrowserError('Failed to resolve the main browser frame')\n\t\treturn frame.id\n\t}\n\n\tasync #configurePage(page: BrowserPage): Promise<void> {\n\t\tawait page.send('Target.setAutoAttach', {\n\t\t\tautoAttach: true,\n\t\t\twaitForDebuggerOnStart: true,\n\t\t\tflatten: true,\n\t\t})\n\t\tawait page.send('Page.setInterceptFileChooserDialog', { enabled: true })\n\t\tawait page.send('Page.setLifecycleEventsEnabled', { enabled: true })\n\t\tconst download: Record<string, unknown> = {\n\t\t\tbehavior:\n\t\t\t\tthis.#downloads === undefined\n\t\t\t\t\t? 'default'\n\t\t\t\t\t: this.#downloads.named === true\n\t\t\t\t\t\t? 'allowAndName'\n\t\t\t\t\t\t: 'allow',\n\t\t\teventsEnabled: true,\n\t\t}\n\t\tif (this.#id !== undefined) download['browserContextId'] = this.#id\n\t\tif (this.#downloads !== undefined) download['downloadPath'] = this.#downloads.path\n\t\tawait this.#client.send('Browser.setDownloadBehavior', download)\n\t\tawait page.network.start()\n\t}\n\n\tasync #applyViewport(page: BrowserPage, viewport: BrowserViewport): Promise<void> {\n\t\tawait page.send('Emulation.setDeviceMetricsOverride', {\n\t\t\twidth: viewport.width,\n\t\t\theight: viewport.height,\n\t\t\tdeviceScaleFactor: viewport.scale ?? 1,\n\t\t\tmobile: viewport.mobile ?? false,\n\t\t\tscreenOrientation:\n\t\t\t\tviewport.landscape === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: {\n\t\t\t\t\t\t\ttype: viewport.landscape ? 'landscapePrimary' : 'portraitPrimary',\n\t\t\t\t\t\t\tangle: viewport.landscape ? 90 : 0,\n\t\t\t\t\t\t},\n\t\t})\n\t\tawait page.send('Emulation.setTouchEmulationEnabled', { enabled: viewport.touch ?? false })\n\t}\n\n\tasync #tryViewport(page: BrowserPage, viewport: BrowserViewport): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#applyViewport(page, viewport)\n\t\t} catch {\n\t\t\t// Reattached targets may not support viewport emulation.\n\t\t}\n\t}\n\n\tasync #closeTarget(targetId: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#client.send('Target.closeTarget', { targetId })\n\t\t} catch {\n\t\t\t// The target may already be gone.\n\t\t}\n\t}\n\n\tasync #detachSession(sessionId: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#client.send('Target.detachFromTarget', { sessionId })\n\t\t} catch {\n\t\t\t// The session may already be detached.\n\t\t}\n\t}\n\n\t#observe(page: BrowserPage): void {\n\t\tif (this.#observed.has(page)) return\n\t\tthis.#observed.add(page)\n\t\tpage.emitter.on('popup', (popup) => {\n\t\t\tif (this.#shutdown !== undefined) {\n\t\t\t\tvoid popup.destroy().catch(() => undefined)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (instanceOf(BrowserPage)(popup)) {\n\t\t\t\tvoid this.#adoptPopup(popup)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.#emitter.emit('page', popup)\n\t\t})\n\t\tpage.emitter.on('close', () => {\n\t\t\tif (this.#pages.get(page.target) === page) this.#pages.delete(page.target)\n\t\t})\n\t}\n\n\t// An adoption takes over its target's reservation for as long as it runs, after the `create` or\n\t// `sync` reservation it replaced settles; a popup that attach holds is published by it. Each\n\t// adoption waits for its opener's publication, so each `page` event follows its opener's.\n\tasync #adoptPopup(popup: BrowserPage): Promise<void> {\n\t\tthis.#observe(popup)\n\t\tconst predecessor = this.#publishing.get(popup.target)\n\t\tconst published = this.#reserve(popup.target)\n\t\ttry {\n\t\t\tawait Promise.allSettled([this.#publishing.get(popup.opener?.target ?? ''), predecessor])\n\t\t\tif (this.#pages.get(popup.target) === popup) return\n\t\t\tawait this.#emulation.attach(popup)\n\t\t\tif (this.#shutdown !== undefined || popup.closed) {\n\t\t\t\tawait popup.destroy()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.#publish(popup)\n\t\t\tpublished.resolve()\n\t\t} catch {\n\t\t\tawait popup.destroy().catch(() => undefined)\n\t\t} finally {\n\t\t\tthis.#unreserve(popup.target, published)\n\t\t}\n\t}\n\n\t#finish(): void {\n\t\tif (this.#emitter.destroyed) return\n\t\tthis.#emitter.emit('close')\n\t\tthis.#emitter.destroy()\n\t}\n}\n","import type { BrowserHoldInterface } from './types.js'\n\n/**\n * Owns a replay's caller token and releases its admission reservation once.\n *\n * @example\n * ```ts\n * const hold = await toolset.hold('add-kettle')\n * try {\n * \tawait toolset.perform(call, { caller: hold.token, signal })\n * } finally {\n * \thold.destroy()\n * }\n * ```\n */\nexport class BrowserHold implements BrowserHoldInterface {\n\treadonly #name: string\n\treadonly #token = crypto.randomUUID()\n\t#release: (() => void) | undefined\n\n\tconstructor(name: string, release: () => void) {\n\t\tthis.#name = name\n\t\tthis.#release = release\n\t}\n\n\tget name(): string {\n\t\treturn this.#name\n\t}\n\n\tget token(): string {\n\t\treturn this.#token\n\t}\n\n\tdestroy(): void {\n\t\tconst release = this.#release\n\t\tthis.#release = undefined\n\t\trelease?.()\n\t}\n}\n","import type {\n\tBrowserAction,\n\tBrowserJourney,\n\tBrowserJourneyStep,\n\tBrowserJourneyStepInput,\n\tBrowserRecorderEventMap,\n\tBrowserRecorderInterface,\n\tBrowserRecorderOptions,\n\tBrowserToolsetInterface,\n} from '../types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport { Emitter } from '@orkestrel/emitter'\nimport {\n\tBROWSER_JOURNEY_ACTIONS,\n\tBROWSER_JOURNEY_NON_STEP_TOOLS,\n\tBROWSER_JOURNEY_STEP_KEYS,\n} from '../constants.js'\nimport { BrowserError } from '../errors.js'\nimport {\n\tbuildBrowserJourney,\n\tcollectBrowserJourneyTextBindings,\n\tderiveBrowserJourneySecret,\n} from '../helpers.js'\n\n/**\n * Records semantic steps from completed toolset actions and omits refused or timed-out actions.\n * @remarks\n * Gaps mark a child frame, a held replay, or an unanswered interruption.\n * @example\n * const recorder = new BrowserRecorder(toolset)\n * await recorder.start()\n * await toolset.perform(call)\n * const steps = await recorder.stop()\n */\nexport class BrowserRecorder implements BrowserRecorderInterface {\n\treadonly #toolset: BrowserToolsetInterface\n\treadonly #emitter: Emitter<BrowserRecorderEventMap>\n\treadonly #action = this.#recordAction.bind(this)\n\treadonly #hold = this.#recordHold.bind(this)\n\t#started = false\n\t#steps: readonly BrowserJourneyStep[] = []\n\t#pending: BrowserAction | undefined\n\n\tconstructor(toolset: BrowserToolsetInterface, options?: BrowserRecorderOptions) {\n\t\tthis.#toolset = toolset\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t\ttoolset.emitter.on('action', this.#action)\n\t\ttoolset.emitter.on('hold', this.#hold)\n\t}\n\n\tget emitter(): EmitterInterface<BrowserRecorderEventMap> {\n\t\treturn this.#emitter\n\t}\n\tget started(): boolean {\n\t\treturn this.#started\n\t}\n\n\tasync start(): Promise<void> {\n\t\tif (this.#emitter.destroyed) throw new BrowserError('The recorder was destroyed')\n\t\tthis.clear()\n\t\tthis.#started = true\n\t\tconst held = this.#toolset.held\n\t\tif (held !== undefined)\n\t\t\tthis.#append({ action: 'unresolved', arguments: {}, gap: `replayed ${held}` })\n\t\tthis.#emitter.emit('start')\n\t}\n\n\tasync stop(): Promise<readonly BrowserJourneyStep[]> {\n\t\tthis.#flushPending()\n\t\tthis.#started = false\n\t\tconst steps = this.steps()\n\t\tthis.#emitter.emit('stop', structuredClone(steps))\n\t\treturn steps\n\t}\n\n\tsteps(): readonly BrowserJourneyStep[] {\n\t\treturn structuredClone(this.#steps)\n\t}\n\n\tjourney(options: { readonly name: string; readonly description: string }): BrowserJourney {\n\t\tconst steps: readonly BrowserJourneyStep[] =\n\t\t\tthis.#pending === undefined\n\t\t\t\t? this.#steps\n\t\t\t\t: [\n\t\t\t\t\t\t...this.#steps,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: `s${this.#steps.length + 1}`,\n\t\t\t\t\t\t\taction: 'unresolved',\n\t\t\t\t\t\t\targuments: {},\n\t\t\t\t\t\t\tgap: `interrupted ${this.#pending.action}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\treturn buildBrowserJourney(steps, options)\n\t}\n\n\tclear(): void {\n\t\tthis.#steps = []\n\t\tthis.#pending = undefined\n\t\tthis.#emitter.emit('clear')\n\t}\n\n\tasync destroy(): Promise<void> {\n\t\tthis.#started = false\n\t\tthis.#pending = undefined\n\t\tthis.#toolset.emitter.off('action', this.#action)\n\t\tthis.#toolset.emitter.off('hold', this.#hold)\n\t\tthis.#emitter.destroy()\n\t}\n\n\t#recordAction(action: BrowserAction): void {\n\t\tif (!this.#started || this.#toolset.held !== undefined) return\n\t\tif (this.#pending !== undefined) {\n\t\t\tconst pending = this.#pending\n\t\t\tthis.#pending = undefined\n\t\t\tif (action.action === 'dialog' && action.outcome === 'done') this.#appendAction(pending)\n\t\t\telse\n\t\t\t\tthis.#append({ action: 'unresolved', arguments: {}, gap: `interrupted ${pending.action}` })\n\t\t}\n\t\tif (\n\t\t\tBROWSER_JOURNEY_NON_STEP_TOOLS.includes(action.action) ||\n\t\t\taction.outcome === 'refused' ||\n\t\t\taction.outcome === 'timeout'\n\t\t)\n\t\t\treturn\n\t\tif (action.outcome === 'interrupted') {\n\t\t\tthis.#pending = structuredClone(action)\n\t\t\treturn\n\t\t}\n\t\tthis.#appendAction(action)\n\t}\n\n\t#appendAction(action: BrowserAction): void {\n\t\tif (action.target?.frame !== undefined) {\n\t\t\tthis.#append({ action: 'unresolved', arguments: {}, gap: 'the element is in a child frame' })\n\t\t\treturn\n\t\t}\n\t\tconst args = { ...action.arguments }\n\t\tif (BROWSER_JOURNEY_ACTIONS.some((name) => name === action.action)) {\n\t\t\tfor (const key of BROWSER_JOURNEY_STEP_KEYS) delete args[key]\n\t\t}\n\t\tif (action.action === 'type' && action.secret === true) {\n\t\t\tconst taken = collectBrowserJourneyTextBindings(this.#steps)\n\t\t\targs['text'] = { parameter: deriveBrowserJourneySecret(action.target?.name ?? '', taken) }\n\t\t}\n\t\tthis.#append({\n\t\t\taction: action.action,\n\t\t\targuments: args,\n\t\t\t...(action.target === undefined\n\t\t\t\t? {}\n\t\t\t\t: {\n\t\t\t\t\t\ttarget: {\n\t\t\t\t\t\t\trole: action.target.role,\n\t\t\t\t\t\t\tname: action.target.name,\n\t\t\t\t\t\t\treference: action.target.reference,\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t// A click that opened a popup carries the popup's tab as settlement evidence; only a switch\n\t\t\t// step names a tab.\n\t\t\t...(action.action !== 'switch' || action.tab === undefined ? {} : { tab: action.tab }),\n\t\t})\n\t}\n\n\t#append(step: BrowserJourneyStepInput): void {\n\t\tconst recorded = structuredClone({ ...step, id: `s${this.#steps.length + 1}` })\n\t\tthis.#steps = [...this.#steps, recorded]\n\t\tthis.#emitter.emit('step', structuredClone(recorded))\n\t}\n\n\t#flushPending(): void {\n\t\tif (this.#pending === undefined) return\n\t\tconst pending = this.#pending\n\t\tthis.#pending = undefined\n\t\tthis.#append({ action: 'unresolved', arguments: {}, gap: `interrupted ${pending.action}` })\n\t}\n\n\t#recordHold(name: string): void {\n\t\tif (!this.#started) return\n\t\tthis.#flushPending()\n\t\tthis.#append({ action: 'unresolved', arguments: {}, gap: `replayed ${name}` })\n\t}\n}\n","import type { JSONValue } from '@orkestrel/contract'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tBrowserAction,\n\tBrowserJourney,\n\tBrowserCallOptions,\n\tBrowserConsoleMessage,\n\tBrowserHoldInterface,\n\tBrowserJourneyRevision,\n\tBrowserJourneyStep,\n\tBrowserPageError,\n\tBrowserReplayEventMap,\n\tBrowserReplayInterface,\n\tBrowserReplayOptions,\n\tBrowserRun,\n\tBrowserRunOutcome,\n\tBrowserRunSlot,\n\tBrowserRunStep,\n\tBrowserToolsetInterface,\n\tBrowserViewEventMap,\n} from './types.js'\nimport { isString } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { BROWSER_JOURNEY_ACTIONS, BROWSER_JOURNEY_FORMAT_VERSION } from './constants.js'\nimport { BrowserError, isBrowserError, isBrowserStepError } from './errors.js'\nimport {\n\tderiveBrowserJourneyTrigger,\n\tgenerateBrowserRunId,\n\tresolveBrowserJourneyBinding,\n\tvalidateBrowserJourney,\n} from './helpers.js'\nimport { isBrowserJourneyBinding, isBrowserSecretBinding } from './validators.js'\n/**\n * Prepares and replays a journey under a toolset hold, retaining its executed prefix.\n * @example\n * const replay = new BrowserReplay(toolset, { journey }, { runs })\n * const run = await replay.execute({ signal })\n */\nexport class BrowserReplay implements BrowserReplayInterface {\n\treadonly #toolset: BrowserToolsetInterface\n\treadonly #revision: BrowserJourneyRevision\n\treadonly #options: BrowserReplayOptions | undefined\n\treadonly #emitter: Emitter<BrowserReplayEventMap>\n\n\tconstructor(\n\t\ttoolset: BrowserToolsetInterface,\n\t\trevision: BrowserJourneyRevision,\n\t\toptions?: BrowserReplayOptions,\n\t) {\n\t\tthis.#toolset = toolset\n\t\tthis.#revision = revision\n\t\tthis.#options = options\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t}\n\n\tget emitter(): EmitterInterface<BrowserReplayEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tasync execute(options?: BrowserCallOptions): Promise<BrowserRun> {\n\t\tconst inputs = this.#prepare()\n\t\tconst revision = structuredClone(this.#revision)\n\t\tconst journey = revision.journey\n\t\tif (this.#toolset.emitter.destroyed)\n\t\t\tthrow new BrowserError('The browser session ended', 'BROWSER_TOOLSET_ENDED')\n\t\tconst started = performance.now()\n\t\tconst secret = Object.values(journey.parameters).some((parameter) => parameter.secret === true)\n\t\tconst visible = Object.fromEntries(\n\t\t\tObject.entries(inputs).filter(([name]) => journey.parameters[name]?.secret !== true),\n\t\t)\n\t\tconst steps: BrowserRunStep[] = []\n\t\tconst output: string[] = []\n\t\tconst cleanup: Array<() => void> = []\n\t\tconst observed = new Set<EmitterInterface<BrowserViewEventMap>>()\n\t\tlet hold: BrowserHoldInterface | undefined\n\t\tlet slot: BrowserRunSlot = { id: generateBrowserRunId() }\n\t\tlet outcome: BrowserRunOutcome = 'complete'\n\t\tlet fault: string | undefined\n\t\tlet run: BrowserRun\n\t\ttry {\n\t\t\thold = await this.#toolset.hold(journey.name, options)\n\t\t\toptions?.signal?.throwIfAborted()\n\t\t\tif (this.#options?.runs !== undefined)\n\t\t\t\tslot = await this.#options.runs.open(journey.name, options)\n\t\t\tif (!secret) {\n\t\t\t\tthis.#observe(output, cleanup, observed)\n\t\t\t\tconst select = this.#observe.bind(this, output, cleanup, observed)\n\t\t\t\tthis.#toolset.emitter.on('select', select)\n\t\t\t\tcleanup.push(() => this.#toolset.emitter.off('select', select))\n\t\t\t}\n\t\t\tfor (const [index, step] of journey.steps.entries()) {\n\t\t\t\toptions?.signal?.throwIfAborted()\n\t\t\t\tconst previous = steps.at(-1)\n\t\t\t\tlet recorded = await this.#executeStep(\n\t\t\t\t\tstep,\n\t\t\t\t\tinputs,\n\t\t\t\t\thold.token,\n\t\t\t\t\tprevious?.outcome === 'interrupted',\n\t\t\t\t\tjourney.parameters,\n\t\t\t\t\toptions,\n\t\t\t\t)\n\t\t\t\tsteps.push(recorded)\n\t\t\t\ttry {\n\t\t\t\t\tif (!secret && !options?.signal?.aborted && recorded.outcome !== 'interrupted') {\n\t\t\t\t\t\tconst capture = await this.#capture(slot, step.id, options)\n\t\t\t\t\t\tif (capture !== undefined) {\n\t\t\t\t\t\t\trecorded = { ...recorded, capture }\n\t\t\t\t\t\t\tsteps[steps.length - 1] = recorded\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tthis.#emitter.emit('step', structuredClone(recorded))\n\t\t\t\t}\n\t\t\t\tconst result = recorded\n\t\t\t\tif (options?.signal?.aborted) {\n\t\t\t\t\toutcome = 'aborted'\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tresult.outcome !== 'done' ||\n\t\t\t\t\tresult.stage === 'requested' ||\n\t\t\t\t\tresult.stage === 'committed'\n\t\t\t\t) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tresult.outcome === 'interrupted' &&\n\t\t\t\t\t\tjourney.steps[index + 1]?.action === 'dialog' &&\n\t\t\t\t\t\tresult.stage !== 'requested' &&\n\t\t\t\t\t\tresult.stage !== 'committed'\n\t\t\t\t\t)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\toutcome = 'stopped'\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\toutcome = options?.signal?.aborted ? 'aborted' : 'stopped'\n\t\t\tif (!options?.signal?.aborted) fault = error instanceof Error ? error.message : String(error)\n\t\t} finally {\n\t\t\thold?.destroy()\n\t\t\tfor (const release of cleanup) release()\n\t\t\trun = {\n\t\t\t\tformat: BROWSER_JOURNEY_FORMAT_VERSION,\n\t\t\t\tid: slot.id,\n\t\t\t\tjourney,\n\t\t\t\t...(revision.revision === undefined ? {} : { revision: revision.revision }),\n\t\t\t\tinputs: visible,\n\t\t\t\tsteps,\n\t\t\t\toutcome,\n\t\t\t\t...(secret || !this.#toolset.view.trusted ? {} : { output }),\n\t\t\t\telapsed: performance.now() - started,\n\t\t\t\t...(fault === undefined ? {} : { fault }),\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait this.#write(run)\n\t\t\t} catch (error) {\n\t\t\t\trun = { ...run, fault: error instanceof Error ? error.message : String(error) }\n\t\t\t}\n\t\t}\n\t\treturn run\n\t}\n\n\t#prepare(): Readonly<Record<string, string>> {\n\t\tconst journey = this.#revision.journey\n\t\tconst placement = this.#toolset.native.some((tool) => tool.name === 'navigate') ? 'page' : 'dom'\n\t\ttry {\n\t\t\tvalidateBrowserJourney(journey)\n\t\t} catch (error) {\n\t\t\tif (!isBrowserError(error)) throw error\n\t\t\tthrow new BrowserError(\n\t\t\t\terror.message,\n\t\t\t\terror.code,\n\t\t\t\terror.context ?? { action: 'replay', placement },\n\t\t\t)\n\t\t}\n\t\tconst supplied = this.#options?.inputs ?? {}\n\t\tfor (const name of Object.keys(supplied)) {\n\t\t\tif (!Object.hasOwn(journey.parameters, name))\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Journey ${journey.name} has no parameter named ${JSON.stringify(name)}.`,\n\t\t\t\t\t'BROWSER_JOURNEY_INPUT',\n\t\t\t\t\t{ parameter: name },\n\t\t\t\t)\n\t\t}\n\t\t// The generated module reads `inputs.NAME`, and only an own member for a name\n\t\t// `Object.prototype` carries; an own `undefined` is an omitted input there too.\n\t\tconst values = new Map(\n\t\t\tObject.keys(journey.parameters).map((name): [string, unknown] => [\n\t\t\t\tname,\n\t\t\t\tname in Object.prototype && !Object.hasOwn(supplied, name) ? undefined : supplied[name],\n\t\t\t]),\n\t\t)\n\t\tconst parameters = Object.entries(journey.parameters)\n\t\t// The module checks every required input before any defaulted one, so the refusals agree.\n\t\tfor (const [name, parameter] of parameters) {\n\t\t\tif (parameter.default === undefined && !isString(values.get(name)))\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Journey ${journey.name} needs input ${JSON.stringify(name)}.`,\n\t\t\t\t\t'BROWSER_JOURNEY_INPUT',\n\t\t\t\t\t{ parameter: name },\n\t\t\t\t)\n\t\t}\n\t\tconst inputs: Record<string, string> = {}\n\t\tfor (const [name, parameter] of parameters) {\n\t\t\tconst value = values.get(name)\n\t\t\tif (isString(value)) inputs[name] = value\n\t\t\telse if (value !== undefined)\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Journey ${journey.name} input ${JSON.stringify(name)} is not a string.`,\n\t\t\t\t\t'BROWSER_JOURNEY_INPUT',\n\t\t\t\t\t{ parameter: name },\n\t\t\t\t)\n\t\t\telse if (parameter.default !== undefined) inputs[name] = parameter.default\n\t\t}\n\t\tfor (const step of journey.steps) {\n\t\t\tif (step.action === 'unresolved')\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Step ${step.id} is unresolved: ${step.gap}.`,\n\t\t\t\t\t'BROWSER_JOURNEY_GAP',\n\t\t\t\t\t{ step: step.id },\n\t\t\t\t)\n\t\t\tif (BROWSER_JOURNEY_ACTIONS.some((name) => name === step.action)) {\n\t\t\t\tconst supported =\n\t\t\t\t\t['click', 'type', 'wait'].includes(step.action) ||\n\t\t\t\t\t(step.action === 'dialog'\n\t\t\t\t\t\t? this.#toolset.native.some((tool) => tool.name === 'navigate')\n\t\t\t\t\t\t: step.action === 'switch'\n\t\t\t\t\t\t\t? this.#toolset.tools.tool('switch') !== undefined\n\t\t\t\t\t\t\t: this.#toolset.native.some((tool) => tool.name === step.action))\n\t\t\t\tif (!supported)\n\t\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t\t`Step ${step.id} cannot execute ${step.action} in this placement.`,\n\t\t\t\t\t\t'BROWSER_JOURNEY_PLACEMENT',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstep: step.id,\n\t\t\t\t\t\t\taction: step.action,\n\t\t\t\t\t\t\tplacement,\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\treturn inputs\n\t}\n\n\tasync #executeStep(\n\t\tstep: BrowserJourneyStep,\n\t\tinputs: Readonly<Record<string, string>>,\n\t\tcaller: string,\n\t\tinterrupted: boolean,\n\t\tparameters: BrowserJourney['parameters'],\n\t\toptions?: BrowserCallOptions,\n\t): Promise<BrowserRunStep> {\n\t\tconst started = performance.now()\n\t\tconst args: Record<string, JSONValue> = {}\n\t\tconst native = BROWSER_JOURNEY_ACTIONS.some((name) => name === step.action)\n\t\tfor (const [key, value] of Object.entries(step.arguments)) {\n\t\t\targs[key] =\n\t\t\t\tnative && isBrowserJourneyBinding(value) && !isString(value)\n\t\t\t\t\t? resolveBrowserJourneyBinding(value, inputs)\n\t\t\t\t\t: value\n\t\t}\n\t\tconst secret = isBrowserSecretBinding(step, parameters)\n\t\tlet action: BrowserAction | undefined\n\t\tlet refusal: string | undefined\n\t\ttry {\n\t\t\tif (step.action === 'dialog' && !interrupted)\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Step ${step.id} answers no interrupted action.`,\n\t\t\t\t\t'BROWSER_JOURNEY_DIALOG',\n\t\t\t\t)\n\t\t\taction = await this.#toolset.follow(\n\t\t\t\tstep.id,\n\t\t\t\t{\n\t\t\t\t\taction: step.action,\n\t\t\t\t\targuments: args,\n\t\t\t\t\t...(step.target === undefined\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\ttarget: {\n\t\t\t\t\t\t\t\t\trole: step.target.role,\n\t\t\t\t\t\t\t\t\tname: resolveBrowserJourneyBinding(step.target.name, inputs),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t...(step.tab === undefined ? {} : { tab: step.tab }),\n\t\t\t\t},\n\t\t\t\t{ ...options, caller, secret },\n\t\t\t)\n\t\t} catch (error) {\n\t\t\trefusal = error instanceof Error ? error.message : String(error)\n\t\t\tif (isBrowserStepError(error)) action = error.action\n\t\t}\n\t\tconst recorded: Record<string, JSONValue> = { ...(action?.arguments ?? args) }\n\t\tif (secret) delete recorded['text']\n\t\treturn {\n\t\t\tid: step.id,\n\t\t\taction: step.action,\n\t\t\ttrigger: deriveBrowserJourneyTrigger(step, inputs),\n\t\t\targuments: recorded,\n\t\t\toutcome: action?.outcome ?? 'refused',\n\t\t\t...(action?.stage === undefined ? {} : { stage: action.stage }),\n\t\t\t...(action?.reason === undefined ? {} : { reason: action.reason }),\n\t\t\tresult: action?.receipt ?? refusal ?? '',\n\t\t\telapsed: action?.elapsed ?? performance.now() - started,\n\t\t}\n\t}\n\n\t#observe(\n\t\toutput: string[],\n\t\tcleanup: Array<() => void>,\n\t\tobserved: Set<EmitterInterface<BrowserViewEventMap>>,\n\t): void {\n\t\tconst view = this.#toolset.view\n\t\tconst emitter = view.emitter\n\t\tif (!view.trusted || emitter === undefined || observed.has(emitter)) return\n\t\tobserved.add(emitter)\n\t\tconst console = this.#collectConsole.bind(this, output)\n\t\tconst error = this.#collectError.bind(this, output)\n\t\temitter.on('console', console)\n\t\temitter.on('error', error)\n\t\tcleanup.push(() => {\n\t\t\temitter.off('console', console)\n\t\t\temitter.off('error', error)\n\t\t})\n\t}\n\n\t#collectConsole(output: string[], message: BrowserConsoleMessage): void {\n\t\toutput.push(message.text)\n\t}\n\n\t#collectError(output: string[], error: BrowserPageError): void {\n\t\toutput.push(error.message)\n\t}\n\n\tasync #capture(\n\t\tslot: BrowserRunSlot,\n\t\tid: string,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<string | undefined> {\n\t\tconst view = this.#toolset.view\n\t\tconst runs = this.#options?.runs\n\t\tif (runs === undefined || !view.trusted || view.screenshot === undefined) return undefined\n\t\tconst screenshot = await view.screenshot()\n\t\treturn runs.capture(slot, `${id}.png`, screenshot.bytes, {\n\t\t\t...(options?.signal === undefined ? {} : { signal: options.signal }),\n\t\t})\n\t}\n\n\tasync #write(run: BrowserRun): Promise<void> {\n\t\tif (this.#options?.runs === undefined) return\n\t\tconst signal = AbortSignal.timeout(1_000)\n\t\tconst deadline = Promise.withResolvers<void>()\n\t\tconst abort = deadline.reject.bind(\n\t\t\tundefined,\n\t\t\tnew BrowserError('Writing the run timed out', 'BROWSER_JOURNEY_FILE'),\n\t\t)\n\t\tsignal.addEventListener('abort', abort, { once: true })\n\t\ttry {\n\t\t\tawait Promise.race([\n\t\t\t\tthis.#options.runs.set(structuredClone(run), { signal }),\n\t\t\t\tdeadline.promise,\n\t\t\t])\n\t\t} finally {\n\t\t\tsignal.removeEventListener('abort', abort)\n\t\t}\n\t}\n}\n","import type {\n\tBrowserJourney,\n\tBrowserJourneyRevision,\n\tBrowserJourneyStoreInterface,\n\tBrowserStoreOptions,\n\tBrowserStorePage,\n} from '../types.js'\nimport { BrowserError } from '../errors.js'\nimport {\n\tvalidateBrowserJourney,\n\tvalidateBrowserJourneyName,\n\tvalidateBrowserStorePage,\n} from '../helpers.js'\n\n/**\n * Keeps owned journey snapshots and revision counters across deletion.\n * @example\n * const store = new MemoryBrowserJourneyStore()\n * await store.set(journey)\n */\nexport class MemoryBrowserJourneyStore implements BrowserJourneyStoreInterface {\n\treadonly #journeys = new Map<string, BrowserJourneyRevision>()\n\treadonly #revisions = new Map<string, number>()\n\n\tasync get(\n\t\tname: string,\n\t\toptions?: BrowserStoreOptions,\n\t): Promise<BrowserJourneyRevision | undefined> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\treturn structuredClone(this.#journeys.get(name))\n\t}\n\n\tasync set(\n\t\tjourney: BrowserJourney,\n\t\texpected?: number,\n\t\toptions?: BrowserStoreOptions,\n\t): Promise<BrowserJourneyRevision> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(journey.name)\n\t\tvalidateBrowserJourney(journey)\n\t\tconst previous = this.#revisions.get(journey.name)\n\t\tif (expected !== undefined && expected !== (this.#journeys.get(journey.name)?.revision ?? 0))\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Journey ${journey.name} changed since you read it`,\n\t\t\t\t'BROWSER_JOURNEY_STALE',\n\t\t\t)\n\t\tconst revision = (previous ?? 0) + 1\n\t\tconst saved = structuredClone({ journey, revision })\n\t\tthis.#journeys.set(journey.name, saved)\n\t\tthis.#revisions.set(journey.name, revision)\n\t\treturn structuredClone(saved)\n\t}\n\n\tasync delete(name: string, options?: BrowserStoreOptions): Promise<void> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\tthis.#journeys.delete(name)\n\t}\n\n\tasync list(\n\t\toptions?: BrowserStoreOptions & { readonly offset?: number; readonly limit?: number },\n\t): Promise<BrowserStorePage<BrowserJourneyRevision>> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst entries = [...this.#journeys.entries()]\n\t\t\t.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n\t\t\t.map(([, revision]) => revision)\n\t\tconst offset = options?.offset ?? 0\n\t\tconst limit = options?.limit ?? Math.max(1, entries.length)\n\t\tvalidateBrowserStorePage(offset, limit)\n\t\treturn {\n\t\t\tentries: structuredClone(entries.slice(offset, offset + limit)),\n\t\t\ttruncated: offset + limit < entries.length,\n\t\t\tfaults: [],\n\t\t}\n\t}\n}\n","import type {\n\tBrowserRun,\n\tBrowserRunSlot,\n\tBrowserRunStoreInterface,\n\tBrowserStoreOptions,\n\tBrowserStorePage,\n} from '../types.js'\nimport { BrowserError } from '../errors.js'\nimport {\n\tgenerateBrowserRunId,\n\tvalidateBrowserRun,\n\tvalidateBrowserJourneyName,\n\tvalidateBrowserStorePage,\n} from '../helpers.js'\n\n/**\n * Keeps owned runs under their journey names and producer ids without directories.\n * @example\n * const store = new MemoryBrowserRunStore()\n * const slot = await store.open('add-kettle')\n */\nexport class MemoryBrowserRunStore implements BrowserRunStoreInterface {\n\treadonly #runs = new Map<string, Map<string, BrowserRun>>()\n\treadonly #slots = new Map<string, Set<string>>()\n\treadonly #opened = new WeakMap<BrowserRunSlot, string>()\n\n\tasync open(name: string, options?: BrowserStoreOptions): Promise<BrowserRunSlot> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\tconst slots = this.#slots.get(name) ?? new Set<string>()\n\t\tlet id = generateBrowserRunId()\n\t\twhile (slots.has(id) || this.#runs.get(name)?.has(id)) id = generateBrowserRunId()\n\t\tslots.add(id)\n\t\tthis.#slots.set(name, slots)\n\t\tconst slot = { id }\n\t\tthis.#opened.set(slot, name)\n\t\treturn slot\n\t}\n\n\tasync get(\n\t\tname: string,\n\t\tid: string,\n\t\toptions?: BrowserStoreOptions,\n\t): Promise<BrowserRun | undefined> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\treturn structuredClone(this.#runs.get(name)?.get(id))\n\t}\n\n\tasync set(run: BrowserRun, options?: BrowserStoreOptions): Promise<void> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserRun(run)\n\t\tif (!this.#slots.get(run.journey.name)?.has(run.id))\n\t\t\tthrow new BrowserError('The run was not opened by this store', 'BROWSER_JOURNEY_PATH')\n\t\tconst runs = this.#runs.get(run.journey.name) ?? new Map<string, BrowserRun>()\n\t\truns.set(run.id, structuredClone(run))\n\t\tthis.#runs.set(run.journey.name, runs)\n\t}\n\n\tasync capture(\n\t\tslot: BrowserRunSlot,\n\t\t_name: string,\n\t\t_bytes: Uint8Array,\n\t\toptions?: BrowserStoreOptions,\n\t): Promise<string | undefined> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tconst journey = this.#opened.get(slot)\n\t\tif (journey === undefined || !this.#slots.get(journey)?.has(slot.id))\n\t\t\tthrow new BrowserError('The run slot was not opened by this store', 'BROWSER_JOURNEY_PATH')\n\t\t// Memory stores own slots but have no directory in which to persist these bytes.\n\t\treturn undefined\n\t}\n\n\tasync delete(name: string, id: string, options?: BrowserStoreOptions): Promise<void> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\tthis.#runs.get(name)?.delete(id)\n\t\tthis.#slots.get(name)?.delete(id)\n\t}\n\n\tasync clear(name: string, options?: BrowserStoreOptions): Promise<number> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\tconst count = this.#slots.get(name)?.size ?? 0\n\t\tthis.#runs.delete(name)\n\t\tthis.#slots.delete(name)\n\t\treturn count\n\t}\n\n\tasync list(\n\t\tname: string,\n\t\toptions?: BrowserStoreOptions & { readonly offset?: number; readonly limit?: number },\n\t): Promise<BrowserStorePage<BrowserRun>> {\n\t\toptions?.signal?.throwIfAborted()\n\t\tvalidateBrowserJourneyName(name)\n\t\tconst entries = [...(this.#runs.get(name)?.values() ?? [])].sort((left, right) =>\n\t\t\tleft.id < right.id ? -1 : left.id > right.id ? 1 : 0,\n\t\t)\n\t\tconst offset = options?.offset ?? 0\n\t\tconst limit = options?.limit ?? Math.max(1, entries.length)\n\t\tvalidateBrowserStorePage(offset, limit)\n\t\treturn {\n\t\t\tentries: structuredClone(entries.slice(offset, offset + limit)),\n\t\t\ttruncated: offset + limit < entries.length,\n\t\t\tfaults: [],\n\t\t}\n\t}\n}\n","import type {\n\tBrowserJourneyRevision,\n\tBrowserJourneyStoreInterface,\n\tBrowserRecorderInterface,\n\tBrowserRecorderOptions,\n\tBrowserReplayInterface,\n\tBrowserReplayOptions,\n\tBrowserRunStoreInterface,\n\tBrowserPageInterface,\n\tBrowserReadingInput,\n\tBrowserReadingInterface,\n\tBrowserSnapshotInput,\n\tBrowserSnapshotInterface,\n\tBrowserToolsetInterface,\n\tBrowserToolsetOptions,\n\tCDPClientInterface,\n\tCDPClientOptions,\n} from './types.js'\nimport { BrowserRecorder } from './recorders/BrowserRecorder.js'\nimport { BrowserReplay } from './BrowserReplay.js'\nimport { MemoryBrowserJourneyStore } from './stores/MemoryBrowserJourneyStore.js'\nimport { MemoryBrowserRunStore } from './stores/MemoryBrowserRunStore.js'\nimport { BrowserReading } from './BrowserReading.js'\nimport { BrowserSnapshot } from './BrowserSnapshot.js'\nimport { BrowserToolset } from './BrowserToolset.js'\nimport { CDPClient } from './CDPClient.js'\n/**\n * Creates a `CDPClientInterface` bound to the given `CDPTransportInterface`.\n *\n * @param options - The transport (and optional timeout) the client uses\n * @returns A {@link CDPClientInterface}\n *\n * @example\n * ```ts\n * import { createCDPClient } from '@orkestrel/browser'\n *\n * const client = createCDPClient({ transport })\n * await client.connect()\n * ```\n */\nexport function createCDPClient(options: CDPClientOptions): CDPClientInterface {\n\treturn new CDPClient(options)\n}\n\n/**\n * Creates a navigable `BrowserSnapshotInterface` over decoded `BrowserSnapshotInput` data.\n *\n * @param input - Captured documents and computed-style names\n * @returns A {@link BrowserSnapshotInterface}\n *\n * @example\n * ```ts\n * import { createBrowserSnapshot, readBrowserSnapshot } from '@orkestrel/browser'\n *\n * const snapshot = createBrowserSnapshot(readBrowserSnapshot(captured, ['display']))\n * snapshot.find({ name: 'main' })\n * ```\n */\nexport function createBrowserSnapshot(input: BrowserSnapshotInput): BrowserSnapshotInterface {\n\treturn new BrowserSnapshot(input)\n}\n\n/**\n * Creates a `BrowserReadingInterface` over a captured document, parsing its HTML one time.\n *\n * @remarks\n * A reading built with a `navigation` source reports `stale` when that source's epoch differs\n * from the `epoch` recorded at capture; a reading built without one never does.\n *\n * @param input - The document URL, title, and HTML, and the optional navigation epoch\n * @returns A {@link BrowserReadingInterface}\n *\n * @example\n * ```ts\n * import { createBrowserReading } from '@orkestrel/browser'\n *\n * const reading = createBrowserReading({\n * \turl: 'https://example.com/',\n * \ttitle: 'Example',\n * \thtml: '<nav>Menu</nav><main><p>Body</p></main>',\n * })\n * reading.text({ distill: false }) // { text: 'Menu\\nBody', offset: 0, total: 9 }\n * ```\n */\nexport function createBrowserReading(input: BrowserReadingInput): BrowserReadingInterface {\n\treturn new BrowserReading(input)\n}\n\n/**\n * Creates a `BrowserToolsetInterface` that publishes the browser vocabulary over one page into a\n * `@orkestrel/tool` manager.\n *\n * @remarks\n * The page is both the toolset's view and its `page` option, so the toolset advertises the seven\n * CDP tools. It registers its tools during `start()`: the generic tools first, then the page\n * tools as their adoption resolves. Its options are described on {@link BrowserToolsetOptions};\n * hand `toolset.tools` to an agent, and publish `toolset.native` to a built-in browser agent.\n *\n * @param page - The page the tools act on first\n * @param options - The manager, page-tool source, context, bound, and schemes; `page` is replaced\n * by the page argument\n * @returns A {@link BrowserToolsetInterface}\n *\n * @example\n * ```ts\n * import { createBrowserToolset } from '@orkestrel/browser'\n *\n * const toolset = createBrowserToolset(page, { context })\n * await toolset.start()\n * const result = await toolset.tools.execute({ id: '1', name: 'look', arguments: { what: 'cart' } })\n * ```\n *\n * @example Drive a page with a small model\n * ```ts\n * import { createAgent } from '@orkestrel/agent'\n * import { createBrowserToolset } from '@orkestrel/browser'\n * import { createBrowser } from '@orkestrel/browser/server'\n * import { createOllama } from '@orkestrel/ollama'\n * import { createToolManager } from '@orkestrel/tool'\n *\n * const system =\n * \t'You control a web browser with tools and must call a tool before you answer. ' +\n * \t'The first message shows the page as look returns it; references such as e4 name its elements. ' +\n * \t'To learn a fact, call read with what set to your question; when its result ends by naming an offset, call read again with that offset. ' +\n * \t'To search, call type with the search box reference, the words, and submit true. ' +\n * \t'To press a button or follow a link, call click with its reference from the latest result. Never invent a reference. ' +\n * \t'If text you expect has not appeared, call wait once. ' +\n * \t'When the task is done, answer in one short sentence.'\n *\n * const browser = createBrowser({ headless: true })\n * await browser.connect()\n * const page = await browser.create({ url: 'https://shop.example.test/' })\n * const toolset = createBrowserToolset(page, { tools: createToolManager() })\n * await toolset.start()\n * toolset.tools.tools().map((tool) => tool.name) // ['look', 'read', 'click', 'type', 'press', 'navigate', 'wait']\n * const seeded = await toolset.tools.execute({\n * \tid: 'seed',\n * \tname: 'look',\n * \targuments: { what: 'the page' },\n * })\n * const view = seeded.success ? String(seeded.value) : seeded.error\n * const agent = createAgent(createOllama({ model: 'qwen3.5:2b-q4_K_M' }), {\n * \tsystem,\n * \ttools: toolset.tools,\n * })\n * agent.context.messages.add({\n * \trole: 'user',\n * \tcontent: `What does the Alpine Kettle cost?\\n\\nThe browser shows this page:\\n${view}`,\n * })\n * const result = await agent.generate()\n * await toolset.destroy()\n * await browser.destroy()\n * ```\n */\nexport function createBrowserToolset(\n\tpage: BrowserPageInterface,\n\toptions?: BrowserToolsetOptions,\n): BrowserToolsetInterface {\n\treturn new BrowserToolset(page, { ...options, page })\n}\n\n/**\n * Creates a recorder over toolset actions.\n * @param toolset - The recording source\n * @param options - Event hooks and observer error handling\n * @returns The recorder\n * @example\n * const recorder = createBrowserRecorder(toolset)\n * await recorder.start()\n */\nexport function createBrowserRecorder(\n\ttoolset: BrowserToolsetInterface,\n\toptions?: BrowserRecorderOptions,\n): BrowserRecorderInterface {\n\treturn new BrowserRecorder(toolset, options)\n}\n\n/**\n * Creates a replay of one journey revision.\n * @param toolset - The toolset that performs the steps\n * @param revision - The journey and optional stored revision\n * @param options - Inputs, run store, and event hooks\n * @returns The replay\n * @example\n * const run = await createBrowserReplay(toolset, { journey }).execute()\n */\nexport function createBrowserReplay(\n\ttoolset: BrowserToolsetInterface,\n\trevision: BrowserJourneyRevision,\n\toptions?: BrowserReplayOptions,\n): BrowserReplayInterface {\n\treturn new BrowserReplay(toolset, revision, options)\n}\n\n/**\n * Creates an in-memory journey store with persistent revision counters.\n * @returns The store\n * @example\n * const store = createMemoryBrowserJourneyStore()\n * await store.set(journey)\n */\nexport function createMemoryBrowserJourneyStore(): BrowserJourneyStoreInterface {\n\treturn new MemoryBrowserJourneyStore()\n}\n\n/**\n * Creates an in-memory run store without capture directories.\n * @returns The store\n * @example\n * const runs = createMemoryBrowserRunStore()\n * await runs.set(run)\n */\nexport function createMemoryBrowserRunStore(): BrowserRunStoreInterface {\n\treturn new MemoryBrowserRunStore()\n}\n","import type {\n\tBrowserJourney,\n\tBrowserJourneyEdit,\n\tBrowserJourneyOptions,\n\tBrowserJourneyRevision,\n\tBrowserJourneyStoreInterface,\n\tBrowserJourneyTarget,\n\tBrowserJourneyToolsetInterface,\n\tBrowserRecorderInterface,\n\tBrowserRun,\n\tBrowserRunStoreInterface,\n\tBrowserToolName,\n\tBrowserToolsetInterface,\n} from './types.js'\nimport type { ToolContext, ToolInterface } from '@orkestrel/tool'\nimport { attempt, isArray, isInteger, isRecord, isString } from '@orkestrel/contract'\nimport { createTool } from '@orkestrel/tool'\nimport {\n\tBROWSER_JOURNEY_EMPTY_LISTING,\n\tBROWSER_JOURNEY_IDLE_REFUSAL,\n\tBROWSER_JOURNEY_NAME_PATTERN,\n\tBROWSER_JOURNEY_READONLY_REFUSAL,\n\tBROWSER_JOURNEY_RECORDING_REFUSAL,\n\tBROWSER_JOURNEY_TOOL_NAMES,\n\tBROWSER_TOOL_COPY,\n} from './constants.js'\nimport { BrowserElementError, BrowserError, isBrowserError } from './errors.js'\nimport { createBrowserRecorder, createBrowserReplay } from './factories.js'\nimport {\n\teditBrowserJourney,\n\treadBrowserToolString,\n\trenderBrowserJourney,\n\trenderBrowserRun,\n\tnormalizeBrowserJourneyReason,\n\trenderBrowserJourneyFault,\n\trequireBrowserReference,\n\tvalidateBrowserToolArguments,\n\tvalidateBrowserJourneyEdit,\n} from './helpers.js'\n\n/**\n * Registers the journey tools `record`, `save`, `journeys`, `edit`, `replay`, and `forget` over a toolset\n * and owns the recording and the active replay.\n *\n * @remarks\n * The journey toolset composes the toolset's public members: `perform` reads the view a receipt\n * carries through `look`, `hold` and `emitter` drive the recorder and the replay, `view` converts\n * an edit's `ref` to a target, and `tools` receives the six tools at construction, which refuses\n * with `BROWSER_TOOLSET_RESERVED` when the manager already holds one of the names. Every refusal\n * is a sentence that names the next call, and a reason inside it is a clause without a directive\n * or a final period.\n *\n * `readonly` refuses `record`, `save`, `edit`, and `forget` before any store access; `replay` still writes\n * its run. The call's signal reaches every store call and every replayed step, and `destroy()`\n * aborts it as well. `save` writes a snapshot before it ends the recording, so a failed or\n * locked write keeps the recorder recording with its steps for the next\n * `save`. An empty snapshot refuses with `BROWSER_JOURNEY_EMPTY` and keeps recording.\n * `edit` accepts an array or its JSON string and names a parse error when the string is invalid.\n * `journeys` joins the listings with one blank line and cuts the result at `limit`\n * characters with a footer that names the next offset. `replay` returns the run's render followed\n * by the view after the run.\n *\n * `destroy()` aborts the active replay and waits for it to finish, stops a recording without\n * saving it, and removes the six tools the manager still holds under the instances it added.\n *\n * @example\n * ```ts\n * import { BrowserJourneyToolset, createMemoryBrowserJourneyStore } from '@orkestrel/browser'\n *\n * const journeys = new BrowserJourneyToolset(toolset, { store: createMemoryBrowserJourneyStore() })\n * await toolset.tools.execute({ id: '1', name: 'record', arguments: { journey: 'add-kettle' } })\n * await journeys.destroy()\n * ```\n */\nexport class BrowserJourneyToolset implements BrowserJourneyToolsetInterface {\n\treadonly #toolset: BrowserToolsetInterface\n\treadonly #store: BrowserJourneyStoreInterface\n\treadonly #runs: BrowserRunStoreInterface | undefined\n\treadonly #readonly: boolean\n\treadonly #limit: number\n\treadonly #lifetime = new AbortController()\n\treadonly #tools: readonly ToolInterface[]\n\t#recorder: BrowserRecorderInterface | undefined\n\t#recording: string | undefined\n\t#saved: string | undefined\n\t#replaying: string | undefined\n\t#replay: Promise<void> | undefined\n\t#destroying: Promise<void> | undefined\n\n\tconstructor(toolset: BrowserToolsetInterface, options: BrowserJourneyOptions) {\n\t\tconst limit = options.limit ?? toolset.limit\n\t\tif (!Number.isSafeInteger(limit) || limit < 1) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The journeys limit must be a positive integer',\n\t\t\t\t'BROWSER_JOURNEY_ARGUMENT',\n\t\t\t\t{\n\t\t\t\t\tlimit,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst held = BROWSER_JOURNEY_TOOL_NAMES.find((name) => toolset.tools.tool(name) !== undefined)\n\t\tif (held !== undefined) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The tool manager already holds a tool named ${held}, a name the browser toolset reserves`,\n\t\t\t\t'BROWSER_TOOLSET_RESERVED',\n\t\t\t\t{ name: held },\n\t\t\t)\n\t\t}\n\t\tthis.#toolset = toolset\n\t\tthis.#store = options.store\n\t\tthis.#runs = options.runs\n\t\tthis.#readonly = options.readonly === true\n\t\tthis.#limit = limit\n\t\tthis.#tools = Object.freeze([\n\t\t\tthis.#create('record', this.#record.bind(this)),\n\t\t\tthis.#create('save', this.#save.bind(this)),\n\t\t\tthis.#create('journeys', this.#journeys.bind(this)),\n\t\t\tthis.#create('edit', this.#edit.bind(this)),\n\t\t\tthis.#create('replay', this.#replayJourney.bind(this)),\n\t\t\tthis.#create('forget', this.#forget.bind(this)),\n\t\t])\n\t\ttoolset.tools.add(this.#tools)\n\t}\n\n\tget recording(): string | undefined {\n\t\treturn this.#recording\n\t}\n\n\tget replaying(): string | undefined {\n\t\treturn this.#replaying\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tthis.#destroying ??= this.#teardown()\n\t\treturn this.#destroying\n\t}\n\n\t#create(\n\t\tname: BrowserToolName,\n\t\thandler: (args: Readonly<Record<string, unknown>>, signal: AbortSignal) => Promise<string>,\n\t): ToolInterface {\n\t\treturn createTool({\n\t\t\t...BROWSER_TOOL_COPY[name],\n\t\t\texecute: this.#execute.bind(this, name, handler),\n\t\t})\n\t}\n\n\t// The one boundary every journey tool runs through: the lifecycle check, the advertised\n\t// parameters, and a signal that `destroy()` also aborts.\n\tasync #execute(\n\t\tname: BrowserToolName,\n\t\thandler: (args: Readonly<Record<string, unknown>>, signal: AbortSignal) => Promise<string>,\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<string> {\n\t\tif (this.#destroying !== undefined) throw this.#ended()\n\t\tvalidateBrowserToolArguments(BROWSER_TOOL_COPY[name], args)\n\t\tconst signal = AbortSignal.any([context.signal, this.#lifetime.signal])\n\t\tsignal.throwIfAborted()\n\t\treturn handler(args, signal)\n\t}\n\n\tasync #record(args: Readonly<Record<string, unknown>>, signal: AbortSignal): Promise<string> {\n\t\tif (this.#readonly)\n\t\t\tthrow new BrowserError(BROWSER_JOURNEY_READONLY_REFUSAL, 'BROWSER_JOURNEY_READONLY')\n\t\tthis.#idleReplay()\n\t\tconst name = readBrowserToolString(args, 'journey')\n\t\tif (this.#recording !== undefined)\n\t\t\tthrow new BrowserError(BROWSER_JOURNEY_RECORDING_REFUSAL, 'BROWSER_JOURNEY_RECORDING')\n\t\tif (!BROWSER_JOURNEY_NAME_PATTERN.test(name)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`${JSON.stringify(name)} is not a journey name; use lowercase words joined by hyphens, such as add-kettle.`,\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'journey' },\n\t\t\t)\n\t\t}\n\t\tthis.#recording = name\n\t\tlet recorder: BrowserRecorderInterface | undefined\n\t\ttry {\n\t\t\tif ((await this.#read(name, signal)) !== undefined) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Journey ${JSON.stringify(name)} is saved already; do not call record for it again. Call journeys to list it, edit to change it, or replay to run it, or answer the user.`,\n\t\t\t\t\t'BROWSER_JOURNEY_SAVED',\n\t\t\t\t\t{ name },\n\t\t\t\t)\n\t\t\t}\n\t\t\tthis.#idleReplay()\n\t\t\tsignal.throwIfAborted()\n\t\t\tif (this.#destroying !== undefined) throw this.#ended()\n\t\t\trecorder = createBrowserRecorder(this.#toolset)\n\t\t\tawait recorder.start()\n\t\t\tsignal.throwIfAborted()\n\t\t\tif (this.#destroying !== undefined) throw this.#ended()\n\t\t\tthis.#recorder = recorder\n\t\t} catch (error) {\n\t\t\tthis.#recording = undefined\n\t\t\tawait recorder?.destroy()\n\t\t\tthrow error\n\t\t}\n\t\treturn `Recording ${name}; each action you take is a step; call save when it is done.\\n\\n${await this.#view(signal)}`\n\t}\n\n\tasync #save(args: Readonly<Record<string, unknown>>, signal: AbortSignal): Promise<string> {\n\t\tif (this.#readonly)\n\t\t\tthrow new BrowserError(BROWSER_JOURNEY_READONLY_REFUSAL, 'BROWSER_JOURNEY_READONLY')\n\t\tconst description = readBrowserToolString(args, 'description')\n\t\tconst recorder = this.#recorder\n\t\tconst name = this.#recording\n\t\tif (recorder === undefined || name === undefined)\n\t\t\tthrow new BrowserError(\n\t\t\t\tthis.#saved === undefined\n\t\t\t\t\t? BROWSER_JOURNEY_IDLE_REFUSAL\n\t\t\t\t\t: `Nothing is recording; ${JSON.stringify(this.#saved)} was saved. Call journeys, edit, or replay.`,\n\t\t\t\t'BROWSER_JOURNEY_RECORDING',\n\t\t\t)\n\t\tconst snapshot = attempt(() => recorder.journey({ name, description }))\n\t\tif (!snapshot.success) {\n\t\t\tif (\n\t\t\t\tisBrowserError(snapshot.error) &&\n\t\t\t\tsnapshot.error.code === 'BROWSER_JOURNEY_INVALID' &&\n\t\t\t\tsnapshot.error.context?.['field'] === 'steps'\n\t\t\t)\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Nothing is recorded for ${name}: the actions before record are not steps. Perform the flow's actions and call save, or answer the user when the task is done.`,\n\t\t\t\t\t'BROWSER_JOURNEY_EMPTY',\n\t\t\t\t\t{ name },\n\t\t\t\t)\n\t\t\tthrow snapshot.error\n\t\t}\n\t\tlet saved: BrowserJourneyRevision\n\t\ttry {\n\t\t\tsaved = await this.#store.set(snapshot.value, 0, { signal })\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) throw error\n\t\t\tif (isBrowserError(error) && error.code === 'BROWSER_JOURNEY_STALE')\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`A journey named \"${name}\" is saved; call journeys, or record another name.`,\n\t\t\t\t\terror.code,\n\t\t\t\t\t{ name },\n\t\t\t\t)\n\t\t\tif (isBrowserError(error) && error.code === 'BROWSER_JOURNEY_LOCKED')\n\t\t\t\tthrow new BrowserError(`Journey ${name} is locked; call save again.`, error.code, { name })\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Saving ${name} failed: ${normalizeBrowserJourneyReason(error)}; call save again.`,\n\t\t\t\tisBrowserError(error) ? error.code : 'BROWSER_JOURNEY_FILE',\n\t\t\t\t{ name },\n\t\t\t)\n\t\t}\n\t\tthis.#saved = name\n\t\tif (this.#recorder === recorder) {\n\t\t\tthis.#recorder = undefined\n\t\t\tthis.#recording = undefined\n\t\t}\n\t\tawait recorder.destroy()\n\t\tconst count = saved.journey.steps.length\n\t\treturn `Saved ${name} with ${count} ${count === 1 ? 'step' : 'steps'}.\\n\\n${renderBrowserJourney(saved.journey)}`\n\t}\n\n\tasync #journeys(args: Readonly<Record<string, unknown>>, signal: AbortSignal): Promise<string> {\n\t\tconst offset = args['offset'] ?? 0\n\t\tif (!isInteger(offset) || offset < 0) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The offset parameter must be a non-negative integer.',\n\t\t\t\t'BROWSER_JOURNEY_ARGUMENT',\n\t\t\t\t{ key: 'offset' },\n\t\t\t)\n\t\t}\n\t\tconst listings: string[] = []\n\t\tconst faults = new Set<string>()\n\t\tlet position = 0\n\t\tfor (;;) {\n\t\t\tconst page = await this.#store.list({ signal, offset: position })\n\t\t\tlistings.push(...page.entries.map((entry) => renderBrowserJourney(entry.journey)))\n\t\t\t// File stores can report the same unreadable path on successive pages.\n\t\t\tfor (const fault of page.faults) {\n\t\t\t\tif (faults.has(fault.name)) continue\n\t\t\t\tfaults.add(fault.name)\n\t\t\t\tlistings.push(renderBrowserJourneyFault(fault))\n\t\t\t}\n\t\t\tconst span = page.entries.length\n\t\t\tposition += span\n\t\t\tif (!page.truncated || span === 0) break\n\t\t}\n\t\tif (listings.length === 0) return BROWSER_JOURNEY_EMPTY_LISTING\n\t\tconst listing = listings.join('\\n\\n')\n\t\tconst start = offset < listing.length ? offset : 0\n\t\tlet end = Math.min(listing.length, start + this.#limit)\n\t\tconst last = listing.charCodeAt(end - 1)\n\t\tif (end < listing.length && last >= 0xd800 && last <= 0xdbff) end -= 1\n\t\t// A limit that cannot hold the next code point would never advance the continuation.\n\t\tif (end === start) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The journeys limit of ${this.#limit} characters cannot hold the next character at offset ${start}; raise the journeys limit.`,\n\t\t\t\t'BROWSER_TOOLSET_LIMIT',\n\t\t\t\t{ limit: this.#limit, offset: start },\n\t\t\t)\n\t\t}\n\t\tconst text = listing.slice(start, end)\n\t\tif (start === 0 && end === listing.length) return text\n\t\treturn `${text}\\n\\n[characters ${start}–${end} of ${listing.length}${end < listing.length ? `; call journeys with offset ${end} for more` : ''}]`\n\t}\n\n\tasync #edit(args: Readonly<Record<string, unknown>>, signal: AbortSignal): Promise<string> {\n\t\tif (this.#readonly)\n\t\t\tthrow new BrowserError(BROWSER_JOURNEY_READONLY_REFUSAL, 'BROWSER_JOURNEY_READONLY')\n\t\tconst name = readBrowserToolString(args, 'journey')\n\t\tlet requests = args['edits']\n\t\tif (isString(requests)) {\n\t\t\tconst text = requests\n\t\t\tconst parsed = attempt<unknown>(() => JSON.parse(text))\n\t\t\tif (!parsed.success)\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`The edits parameter is not valid JSON: ${normalizeBrowserJourneyReason(parsed.error)}; pass an array or a JSON string of the array.`,\n\t\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t\t{ key: 'edits' },\n\t\t\t\t)\n\t\t\trequests = parsed.value\n\t\t}\n\t\tif (!isArray(requests)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The edits parameter must be an array or a JSON string of the array.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{\n\t\t\t\t\tkey: 'edits',\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst revision = await this.#find(name, signal)\n\t\tconst edits = requests.map((request, index) => this.#convert(request, index + 1))\n\t\tlet edited: BrowserJourney\n\t\ttry {\n\t\t\tedited = editBrowserJourney(revision.journey, edits)\n\t\t} catch (error) {\n\t\t\tif (!isBrowserError(error) || error.code !== 'BROWSER_JOURNEY_EDIT') throw error\n\t\t\tthrow new BrowserError(`${error.message}; call journeys.`, error.code, error.context)\n\t\t}\n\t\tlet saved: BrowserJourneyRevision\n\t\ttry {\n\t\t\tsaved = await this.#store.set(edited, revision.revision, { signal })\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) throw error\n\t\t\tconst code = isBrowserError(error) ? error.code : 'BROWSER_JOURNEY_FILE'\n\t\t\tif (code === 'BROWSER_JOURNEY_STALE')\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Journey ${name} changed since you read it; call journeys, then edit again.`,\n\t\t\t\t\tcode,\n\t\t\t\t\t{ name },\n\t\t\t\t)\n\t\t\tif (code === 'BROWSER_JOURNEY_LOCKED')\n\t\t\t\tthrow new BrowserError(`Journey ${name} is locked; call edit again.`, code, { name })\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Editing ${name} failed: ${normalizeBrowserJourneyReason(error)}; call edit again.`,\n\t\t\t\tcode,\n\t\t\t\t{ name },\n\t\t\t)\n\t\t}\n\t\treturn `Edited ${name}.\\n\\n${renderBrowserJourney(saved.journey)}`\n\t}\n\n\tasync #forget(args: Readonly<Record<string, unknown>>, signal: AbortSignal): Promise<string> {\n\t\tif (this.#readonly)\n\t\t\tthrow new BrowserError(BROWSER_JOURNEY_READONLY_REFUSAL, 'BROWSER_JOURNEY_READONLY')\n\t\tthis.#idleReplay()\n\t\tconst name = readBrowserToolString(args, 'journey')\n\t\tif (this.#recording === name)\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Journey ${JSON.stringify(name)} is recording; call save first, or record another name.`,\n\t\t\t\t'BROWSER_JOURNEY_RECORDING',\n\t\t\t\t{ name },\n\t\t\t)\n\t\tawait this.#find(name, signal)\n\t\tthis.#idleReplay()\n\t\tlet count: number\n\t\ttry {\n\t\t\t// Remove runs first so a failed removal leaves the saved name available for a retry.\n\t\t\tcount = (await this.#runs?.clear(name, { signal })) ?? 0\n\t\t\tawait this.#store.delete(name, { signal })\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) throw error\n\t\t\tconst code = isBrowserError(error) ? error.code : 'BROWSER_JOURNEY_FILE'\n\t\t\tif (code === 'BROWSER_JOURNEY_LOCKED')\n\t\t\t\tthrow new BrowserError(`Journey ${name} is locked; call forget again.`, code, { name })\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Forgetting ${name} failed: ${normalizeBrowserJourneyReason(error)}; call forget again.`,\n\t\t\t\tcode,\n\t\t\t\t{ name },\n\t\t\t)\n\t\t}\n\t\tif (this.#saved === name) this.#saved = undefined\n\t\treturn `Forgot ${name} and its ${count} ${count === 1 ? 'run' : 'runs'}; the name is free to record again.`\n\t}\n\n\tasync #replayJourney(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tsignal: AbortSignal,\n\t): Promise<string> {\n\t\tconst name = readBrowserToolString(args, 'journey')\n\t\tconst inputs: Record<string, string> = {}\n\t\tconst given = args['inputs'] ?? {}\n\t\tif (!isRecord(given) || !Object.values(given).every(isString)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The inputs parameter must be an object of strings.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'inputs' },\n\t\t\t)\n\t\t}\n\t\tfor (const [key, value] of Object.entries(given)) if (isString(value)) inputs[key] = value\n\t\tif (this.#recording !== undefined) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Journey ${this.#recording} is recording; call save before you replay another.`,\n\t\t\t\t'BROWSER_JOURNEY_RECORDING',\n\t\t\t\t{ name: this.#recording },\n\t\t\t)\n\t\t}\n\t\tthis.#idleReplay()\n\t\t// The replay claims the toolset before its first await, so a second `replay` is refused\n\t\t// rather than queued behind it.\n\t\tthis.#replaying = name\n\t\tconst finished = Promise.withResolvers<void>()\n\t\tthis.#replay = finished.promise\n\t\ttry {\n\t\t\tconst revision = await this.#find(name, signal)\n\t\t\tlet run: BrowserRun\n\t\t\ttry {\n\t\t\t\trun = await createBrowserReplay(this.#toolset, revision, {\n\t\t\t\t\tinputs,\n\t\t\t\t\t...(this.#runs === undefined ? {} : { runs: this.#runs }),\n\t\t\t\t}).execute({ signal })\n\t\t\t} catch (error) {\n\t\t\t\tthrow this.#prepared(error, revision.journey)\n\t\t\t}\n\t\t\treturn renderBrowserRun(run, signal.aborted ? undefined : await this.#view(signal))\n\t\t} finally {\n\t\t\tthis.#replaying = undefined\n\t\t\tthis.#replay = undefined\n\t\t\tfinished.resolve()\n\t\t}\n\t}\n\n\t// Maps a preparation refusal to its sentence; any other failure keeps its own message.\n\t#prepared(error: unknown, journey: BrowserJourney): unknown {\n\t\tif (!isBrowserError(error)) return error\n\t\tconst name = journey.name\n\t\tswitch (error.code) {\n\t\t\tcase 'BROWSER_JOURNEY_INPUT': {\n\t\t\t\tconst parameter = error.context?.['parameter']\n\t\t\t\tif (!isString(parameter)) return error\n\t\t\t\tif (!Object.hasOwn(journey.parameters, parameter))\n\t\t\t\t\treturn new BrowserError(\n\t\t\t\t\t\t`Journey ${name} has no parameter named ${JSON.stringify(parameter)}; call journeys.`,\n\t\t\t\t\t\terror.code,\n\t\t\t\t\t\terror.context,\n\t\t\t\t\t)\n\t\t\t\treturn new BrowserError(\n\t\t\t\t\t`Journey ${name} needs the input ${JSON.stringify(parameter)}; call replay with inputs.`,\n\t\t\t\t\terror.code,\n\t\t\t\t\terror.context,\n\t\t\t\t)\n\t\t\t}\n\t\t\tcase 'BROWSER_JOURNEY_GAP': {\n\t\t\t\tconst step = journey.steps.find((candidate) => candidate.id === error.context?.['step'])\n\t\t\t\tif (step === undefined) return error\n\t\t\t\treturn new BrowserError(\n\t\t\t\t\t`Journey ${name} has a gap at ${step.id} (${step.gap}); call edit to remove or replace ${step.id}.`,\n\t\t\t\t\terror.code,\n\t\t\t\t\terror.context,\n\t\t\t\t)\n\t\t\t}\n\t\t\tcase 'BROWSER_JOURNEY_PLACEMENT': {\n\t\t\t\tconst id = error.context?.['step']\n\t\t\t\tconst action = error.context?.['action']\n\t\t\t\tconst placement = error.context?.['placement']\n\t\t\t\tif (!isString(id) || !isString(action) || !isString(placement)) return error\n\t\t\t\treturn new BrowserError(\n\t\t\t\t\taction === 'switch'\n\t\t\t\t\t\t? `Journey ${name} cannot run here: ${id} switch needs a browser context; call journeys.`\n\t\t\t\t\t\t: `Journey ${name} cannot run here: ${id} ${action} is not available in a ${placement === 'dom' ? 'page' : 'browser'} toolset; call journeys.`,\n\t\t\t\t\terror.code,\n\t\t\t\t\terror.context,\n\t\t\t\t)\n\t\t\t}\n\t\t\tcase 'BROWSER_JOURNEY_FORMAT':\n\t\t\tcase 'BROWSER_JOURNEY_INVALID':\n\t\t\t\treturn new BrowserError(\n\t\t\t\t\t`Journey ${name} cannot be read: ${normalizeBrowserJourneyReason(error)}; call journeys.`,\n\t\t\t\t\terror.code,\n\t\t\t\t\terror.context,\n\t\t\t\t)\n\t\t\tdefault:\n\t\t\t\treturn error\n\t\t}\n\t}\n\n\t// Converts a wire edit's `ref` to a target from the current view, then checks the edit's own\n\t// shape, so the pure editor receives a typed batch.\n\t#convert(request: unknown, index: number): BrowserJourneyEdit {\n\t\tlet edit = request\n\t\tif (isRecord(request) && request['operation'] === 'add' && isRecord(request['step'])) {\n\t\t\tconst { ref, ...step } = request['step']\n\t\t\tif (ref !== undefined) edit = { ...request, step: { ...step, target: this.#target(ref) } }\n\t\t} else if (isRecord(request) && request['operation'] === 'update') {\n\t\t\tconst { ref, ...update } = request\n\t\t\tif (ref !== undefined) edit = { ...update, target: this.#target(ref) }\n\t\t}\n\t\ttry {\n\t\t\tvalidateBrowserJourneyEdit(edit)\n\t\t} catch (error) {\n\t\t\tconst reason = normalizeBrowserJourneyReason(error)\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Edit ${index} is refused: ${reason.startsWith('its ') ? reason : `it ${reason}`}; call journeys.`,\n\t\t\t\t'BROWSER_JOURNEY_EDIT',\n\t\t\t\t{ index, reason },\n\t\t\t)\n\t\t}\n\t\treturn edit\n\t}\n\n\t#target(ref: unknown): BrowserJourneyTarget {\n\t\tconst reference = requireBrowserReference(ref)\n\t\tconst element = this.#toolset.view.elements.element(reference)\n\t\tif (element === undefined)\n\t\t\tthrow new BrowserElementError(\n\t\t\t\treference,\n\t\t\t\t'UNKNOWN',\n\t\t\t\t'is not in the current view; call look for fresh refs',\n\t\t\t)\n\t\treturn { role: element.role, name: element.name, reference: element.reference }\n\t}\n\n\tasync #find(name: string, signal: AbortSignal): Promise<BrowserJourneyRevision> {\n\t\tconst revision = BROWSER_JOURNEY_NAME_PATTERN.test(name)\n\t\t\t? await this.#read(name, signal)\n\t\t\t: undefined\n\t\tif (revision === undefined)\n\t\t\tthrow new BrowserError(\n\t\t\t\t`No journey is named ${JSON.stringify(name)}; call journeys.`,\n\t\t\t\t'BROWSER_JOURNEY_MISSING',\n\t\t\t\t{ name },\n\t\t\t)\n\t\treturn revision\n\t}\n\n\tasync #read(name: string, signal: AbortSignal): Promise<BrowserJourneyRevision | undefined> {\n\t\ttry {\n\t\t\treturn await this.#store.get(name, { signal })\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) throw error\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Journey ${name} cannot be read: ${normalizeBrowserJourneyReason(error)}; call journeys.`,\n\t\t\t\tisBrowserError(error) ? error.code : 'BROWSER_JOURNEY_FILE',\n\t\t\t\t{ name },\n\t\t\t)\n\t\t}\n\t}\n\n\t// Reads the view a receipt carries through `look`, so it is cut at the toolset's limit and\n\t// carries the notes of any view move.\n\tasync #view(signal: AbortSignal): Promise<string> {\n\t\tconst performed = await this.#toolset.perform(\n\t\t\t{ id: 'journey', name: 'look', arguments: { what: 'the page' } },\n\t\t\t{ signal },\n\t\t)\n\t\treturn performed.result.success ? String(performed.result.value) : performed.result.error\n\t}\n\n\t#ended(): BrowserError {\n\t\treturn new BrowserError('the browser session ended', 'BROWSER_TOOLSET_ENDED')\n\t}\n\n\tasync #teardown(): Promise<void> {\n\t\tthis.#lifetime.abort(this.#ended())\n\t\tfor (const tool of this.#tools)\n\t\t\tif (this.#toolset.tools.tool(tool.name) === tool) this.#toolset.tools.remove(tool.name)\n\t\tconst recorder = this.#recorder\n\t\tthis.#recorder = undefined\n\t\tthis.#recording = undefined\n\t\tawait recorder?.destroy()\n\t\tawait this.#replay\n\t}\n\n\t#idleReplay(): void {\n\t\tconst active = this.#replaying ?? this.#toolset.held\n\t\tif (active !== undefined)\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The toolset is replaying ${active} until it finishes; call look.`,\n\t\t\t\t'BROWSER_TOOLSET_BUSY',\n\t\t\t)\n\t}\n}\n","import type {\n\tBrowserAction,\n\tBrowserFollowOptions,\n\tBrowserHoldInterface,\n\tBrowserJourneyStepInput,\n\tBrowserJourneyTab,\n\tBrowserJourneyTarget,\n\tBrowserJourneyToolsetInterface,\n\tBrowserToolsetResult,\n\tBrowserCallOptions,\n\tBrowserContextInterface,\n\tBrowserDestination,\n\tBrowserDestinationRelationship,\n\tBrowserDialogInterface,\n\tBrowserElementInterface,\n\tBrowserFrameInterface,\n\tBrowserNavigationRecordInterface,\n\tBrowserPageInterface,\n\tBrowserPopupRecordInterface,\n\tBrowserReadingInterface,\n\tBrowserTab,\n\tBrowserTool,\n\tBrowserToolName,\n\tBrowserToolSourceInterface,\n\tBrowserToolsetEventMap,\n\tBrowserToolsetHandler,\n\tBrowserToolsetInterface,\n\tBrowserToolsetOptions,\n\tBrowserToolsetReason,\n\tBrowserToolsetWatch,\n\tBrowserViewInterface,\n} from './types.js'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tToolCall,\n\tToolContext,\n\tToolInterface,\n\tToolManagerInterface,\n\tToolResult,\n} from '@orkestrel/tool'\nimport {\n\tcloneJSONRecord,\n\tisArray,\n\tisBoolean,\n\tisError,\n\tisFiniteNumber,\n\tisInteger,\n\tisRecord,\n\tisString,\n} from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { BrowserHold } from './BrowserHold.js'\nimport { BrowserJourneyToolset } from './BrowserJourneyToolset.js'\nimport { createTool, createToolManager } from '@orkestrel/tool'\nimport {\n\tBROWSER_JOURNEY_TOOL_NAMES,\n\tBROWSER_OBSERVATION_TOOL_NAMES,\n\tBROWSER_SCHEMES,\n\tBROWSER_TOOL_CAPTURE_MS,\n\tBROWSER_TOOL_CHANGED_NOTE,\n\tBROWSER_TOOL_COPY,\n\tBROWSER_TOOL_CUT_FOOTER,\n\tBROWSER_TOOL_DEADLINE_NOTE,\n\tBROWSER_TOOL_HANDLED_STATUS,\n\tBROWSER_TOOL_LIMIT,\n\tBROWSER_TOOL_NAMES,\n\tBROWSER_TOOL_PENDING_NOTE,\n\tBROWSER_TOOL_NAME_PATTERN,\n\tBROWSER_TOOL_TIMEOUT_LIMIT_MS,\n\tBROWSER_TOOL_TIMEOUT_MS,\n\tBROWSER_TOOL_VIEW_FOOTER,\n\tBROWSER_TYPED_ROLES,\n} from './constants.js'\nimport {\n\tBrowserElementError,\n\tBrowserError,\n\tBrowserStepError,\n\tisBrowserElementError,\n\tisBrowserError,\n} from './errors.js'\nimport { compileSubmitObserverExpression, compileSubmitReadExpression } from './compilers.js'\nimport {\n\tboundBrowserText,\n\tderiveBrowserToolSchema,\n\tnormalizeBrowserKey,\n\treadBrowserToolString,\n\trenderBrowserElement,\n\trenderBrowserReceipt,\n\trenderBrowserToolOutput,\n\trequireBrowserReference,\n\tvalidateBrowserToolArguments,\n} from './helpers.js'\n\n/**\n * Publishes the browser vocabulary as `@orkestrel/tool` tools over one view and adopts the\n * view's own tools beside them.\n *\n * @remarks\n * Every toolset advertises `look`, `read`, `click`, `type`, and `wait`, which need only the\n * `BrowserViewInterface` it is constructed over. With `options.page` it also advertises `press`\n * and `navigate`, stages the `dialog` tool while a dialog is open on the current page, follows a\n * popup the current page opens and returns to the opener when the popup closes, and adopts\n * `page.registry` by default; with `options.context` as well it advertises `tabs` and `switch`.\n * With `options.journeys` the constructor constructs a `BrowserJourneyToolset`, which adds\n * `record`, `save`, `journeys`, `edit`, and `replay` to the manager and reserves those names, and\n * `destroy()` destroys it first. The result that carries the view after a move names the move.\n *\n * Every tool, the page tools included, runs through one boundary. The boundary refuses with\n * `the browser session ended` after `destroy()`, refuses an aborted signal before the tool runs,\n * refuses every tool but `dialog` while a dialog is open, forwards `ToolContext.signal` into every\n * protocol call, refuses a call to a toolset tool that carries a parameter the tool does not\n * advertise, and cuts every returned string and every thrown message at `limit` characters plus\n * a footer; the footer of a cut result that carries a view names `read` as the next call. `look`\n * and `read` read the page, never one element. A page tool's error message and JSON output reach\n * the toolset already cut at `BROWSER_REGISTRY_OUTPUT_LIMIT` (4 096) by the registry, so a\n * `limit` over that shows at most 4 096 characters of either; a page tool's text output reaches\n * the boundary whole.\n *\n * `click`, `type`, `press`, `navigate`, and `switch` are actions: one runs at a time, in call\n * order, and holds the queue until its receipt. A queued action whose signal aborts leaves\n * without sending anything. An action whose receipt returned while its command was still\n * pending, because a dialog opened or a navigation was requested, is awaited by the next action.\n * Every pending step is raced against the page's `dialog` event, so a dialog returns the receipt\n * that names it while the blocked command settles later without a second receipt. Before `click`\n * sends its input and before `type` edits the control, the action opens the page's navigation\n * record for the element's frame, and `press` opens one for the main frame. `click`, `type` with\n * `submit`, and `press` of Enter open the page's popup record beside it: after the navigation\n * settles, the receipt waits under the same deadline for the popups the record's reports name,\n * moves the view to the first one still open with the note `The view moved to a new tab: URL.`,\n * and records that popup's URL and title as the action's `tab`, so the receipt carries the popup's\n * view. A popup the current page announces outside such an action, or during one that did not\n * move to it, moves the view when the page announces it or when the action ends. Before the\n * navigation record opens, `click` and `type` with `submit` install a `submit` observer in the\n * isolated world of the element's document, and `press` in every document one `page.frames()`\n * call lists; an action whose input\n * document cannot be observed is refused with `BROWSER_TOOLSET_OBSERVE` before any input, and a\n * document `press` did not list is not observed. A navigation that starts in the input's frame or\n * an ancestor before the input settles is followed; when the input settles first, each observed\n * submission that kept its default action names its destination frame, and the receipt waits for\n * the navigation the record selects to commit and load under the receipt's deadline; a submission\n * every listener prevented adds no wait. When the reads name no surviving destination and no\n * navigation followed, the receipt's status is `BROWSER_TOOL_HANDLED_STATUS`, which names `wait` as\n * the next call, after a prevented submission, and `no form received the submission` when `type`\n * with `submit`, or a `press` of Enter that an input a form owns received, recorded none. The\n * page placement's `type` with `submit` ends its action with `and submitted the form` when a read\n * recorded a submission, or when the navigation the receipt settled names `formSubmissionGet` or\n * `formSubmissionPost` as its reason, whatever the read answered, and with `and pressed Enter`\n * otherwise. A `read`\n * at an offset at or past its retained reading's end restarts that reading at 0. A receipt that\n * waits for a requested navigation shares one `BROWSER_TOOL_TIMEOUT_MS` deadline between that\n * wait and its view capture, of which `BROWSER_TOOL_CAPTURE_MS` is reserved for the capture. The\n * deadline runs from the moment the receipt starts waiting, after any time the action spent\n * queued and after `navigate`'s own load wait; its timers end with the receipt, and settling the\n * receipt aborts the capture. A capture that the page's change makes stale waits for the page's\n * readiness and reads the view once more inside the same deadline, and reports\n * `BROWSER_TOOL_CHANGED_NOTE` when that read fails too. `type` refuses an element whose role is\n * not in `BROWSER_TYPED_ROLES` before it sends anything, naming `click` as the next call. A `click` on an element whose role is in `BROWSER_TYPED_ROLES`\n * adds `; call type with REF to enter text` to its receipt line. A click\n * or type over a view whose `trusted` is `false` ends its receipt line with ` (untrusted event)`.\n *\n * A page tool is skipped, with `skip` emitted, when its name is reserved (`unresolved` included), when the manager holds\n * its name under a tool the toolset did not add (checked again immediately before each addition),\n * when its name falls outside `BROWSER_TOOL_NAME_PATTERN`, when its parameters or, for a source\n * that supplies `tools()`, its selected registration declare `what` optional, or when that\n * registration is marked `debugging`. The selected registration is the main frame's, then the\n * earlier one. A page tool whose parameters require nothing advertises a required `what`, which\n * is stripped before the tool runs. Every adopted tool is advertised `untrusted`. `destroy()`\n * removes only the tools the manager still holds under the instances the toolset added, never\n * closes a page, and ends only what `options.release` hands over, calling it one time last.\n *\n * @example\n * ```ts\n * import { BrowserToolset } from '@orkestrel/browser'\n *\n * const toolset = new BrowserToolset(page, { page })\n * await toolset.start()\n * const result = await toolset.tools.execute({ id: '1', name: 'look', arguments: { what: 'cart' } })\n * await toolset.destroy()\n * ```\n */\nexport class BrowserToolset implements BrowserToolsetInterface {\n\treadonly #view: BrowserViewInterface\n\treadonly #origin: BrowserPageInterface | undefined\n\treadonly #tools: ToolManagerInterface\n\treadonly #manager: ToolManagerInterface\n\treadonly #source: BrowserToolSourceInterface | undefined\n\treadonly #context: BrowserContextInterface | undefined\n\treadonly #limit: number\n\treadonly #schemes: readonly string[]\n\treadonly #owned: (() => Promise<void> | void) | undefined\n\treadonly #emitter: Emitter<BrowserToolsetEventMap>\n\treadonly #lifetime = new AbortController()\n\treadonly #native: readonly ToolInterface[]\n\treadonly #dialogTool: ToolInterface | undefined\n\treadonly #contextTools: readonly ToolInterface[]\n\treadonly #journeys: BrowserJourneyToolsetInterface | undefined\n\treadonly #added = new Set<ToolInterface>()\n\treadonly #adopted = new Map<string, ToolInterface>()\n\treadonly #watches = new Map<BrowserPageInterface, BrowserToolsetWatch>()\n\treadonly #dialogs = new Map<BrowserPageInterface, BrowserDialogInterface>()\n\treadonly #handlers = new WeakMap<\n\t\tToolInterface,\n\t\t{ readonly handler: BrowserToolsetHandler; readonly clause: string }\n\t>()\n\treadonly #actions = new WeakMap<AbortSignal, Partial<BrowserAction>>()\n\treadonly #invocations = new WeakMap<\n\t\tToolContext,\n\t\t{ readonly handler: BrowserToolsetHandler; readonly clause: string }\n\t>()\n\t#reservation: BrowserHoldInterface | undefined\n\treadonly #holds = new Map<PromiseWithResolvers<void>, BrowserHoldInterface>()\n\treadonly #interrupts = new Map<PromiseWithResolvers<never>, string>()\n\treadonly #notes: string[] = []\n\treadonly #changeHandler = this.#handleChange.bind(this)\n\treadonly #removeHandler = this.#handleRemove.bind(this)\n\treadonly #clearHandler = this.#handleClear.bind(this)\n\t#page: BrowserPageInterface | undefined\n\t#following: BrowserToolSourceInterface | undefined\n\t#reading:\n\t\t| { readonly view: BrowserViewInterface; readonly reading: BrowserReadingInterface }\n\t\t| undefined\n\t#tail: Promise<void> = Promise.resolve()\n\t#pending: Promise<void> | undefined\n\t// Numbers each action, so the observer it installs answers only its own read and removal.\n\t#sequence = 0\n\t#navigating: BrowserPageInterface | undefined\n\t// The popups announced while an action holds a popup record, with their openers; the action\n\t// moves the view itself, and the rest follow when it ends.\n\t#arrivals:\n\t\t| ReadonlyArray<readonly [opener: BrowserPageInterface, popup: BrowserPageInterface]>\n\t\t| undefined\n\t#generation = 0\n\t#started = false\n\t#starting: Promise<void> | undefined\n\t#destroying: Promise<void> | undefined\n\n\tconstructor(view: BrowserViewInterface, options?: BrowserToolsetOptions) {\n\t\tconst limit = options?.limit ?? BROWSER_TOOL_LIMIT\n\t\tif (!isInteger(limit) || limit < 1) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'Browser toolset limit must be a positive integer',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{\n\t\t\t\t\tlimit,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (options?.context !== undefined && options.page === undefined) {\n\t\t\tthrow new BrowserError('Browser toolset context requires a page', 'BROWSER_TOOLSET_CONTEXT')\n\t\t}\n\t\tthis.#view = view\n\t\tthis.#origin = options?.page\n\t\tthis.#page = options?.page\n\t\tthis.#tools = options?.tools ?? createToolManager()\n\t\tthis.#manager = new Proxy(this.#tools, { get: this.#readManager.bind(this) })\n\t\tthis.#source = options?.source\n\t\tthis.#context = options?.context\n\t\tthis.#limit = limit\n\t\tthis.#schemes = options?.schemes ?? BROWSER_SCHEMES\n\t\tthis.#owned = options?.release\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t\tconst look = this.#create('look', this.#look.bind(this), BROWSER_TOOL_VIEW_FOOTER)\n\t\tconst read = this.#create('read', this.#read.bind(this), BROWSER_TOOL_CUT_FOOTER)\n\t\tconst click = this.#create('click', this.#click.bind(this), BROWSER_TOOL_VIEW_FOOTER)\n\t\tconst type = this.#create('type', this.#type.bind(this), BROWSER_TOOL_VIEW_FOOTER)\n\t\tconst wait = this.#create('wait', this.#wait.bind(this), BROWSER_TOOL_CUT_FOOTER)\n\t\tthis.#native = Object.freeze(\n\t\t\toptions?.page === undefined\n\t\t\t\t? [look, read, click, type, wait]\n\t\t\t\t: [\n\t\t\t\t\t\tlook,\n\t\t\t\t\t\tread,\n\t\t\t\t\t\tclick,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tthis.#create('press', this.#press.bind(this), BROWSER_TOOL_VIEW_FOOTER),\n\t\t\t\t\t\tthis.#create('navigate', this.#navigate.bind(this), BROWSER_TOOL_VIEW_FOOTER),\n\t\t\t\t\t\twait,\n\t\t\t\t\t],\n\t\t)\n\t\tthis.#dialogTool =\n\t\t\toptions?.page === undefined\n\t\t\t\t? undefined\n\t\t\t\t: this.#create('dialog', this.#dialog.bind(this), BROWSER_TOOL_VIEW_FOOTER)\n\t\tthis.#contextTools = Object.freeze(\n\t\t\toptions?.context === undefined\n\t\t\t\t? []\n\t\t\t\t: [\n\t\t\t\t\t\tthis.#create('tabs', this.#tabs.bind(this), BROWSER_TOOL_CUT_FOOTER),\n\t\t\t\t\t\tthis.#create('switch', this.#switch.bind(this), BROWSER_TOOL_VIEW_FOOTER),\n\t\t\t\t\t],\n\t\t)\n\t\tthis.#journeys =\n\t\t\toptions?.journeys === undefined\n\t\t\t\t? undefined\n\t\t\t\t: new BrowserJourneyToolset(this, {\n\t\t\t\t\t\t...options.journeys,\n\t\t\t\t\t\tlimit: options.journeys.limit ?? limit,\n\t\t\t\t\t})\n\t}\n\n\tget emitter(): EmitterInterface<BrowserToolsetEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget tools(): ToolManagerInterface {\n\t\treturn this.#manager\n\t}\n\n\tget limit(): number {\n\t\treturn this.#limit\n\t}\n\n\t#readManager(target: ToolManagerInterface, key: string | symbol): unknown {\n\t\tif (key === 'execute') return this.#performManaged.bind(this)\n\t\tconst value: unknown = Reflect.get(target, key, target)\n\t\treturn typeof value === 'function' ? value.bind(target) : value\n\t}\n\n\t#performManaged(call: ToolCall, context?: ToolContext): Promise<ToolResult>\n\t#performManaged(calls: readonly ToolCall[], context?: ToolContext): Promise<readonly ToolResult[]>\n\tasync #performManaged(\n\t\tcalls: ToolCall | readonly ToolCall[],\n\t\tcontext?: ToolContext,\n\t): Promise<ToolResult | readonly ToolResult[]> {\n\t\tif (isArray(calls))\n\t\t\treturn Promise.all(calls.map(async (call) => (await this.perform(call, context)).result))\n\t\treturn (await this.perform(calls, context)).result\n\t}\n\n\tget native(): readonly ToolInterface[] {\n\t\treturn this.#native\n\t}\n\n\tget view(): BrowserViewInterface {\n\t\treturn this.#cursor\n\t}\n\n\tget held(): string | undefined {\n\t\treturn this.#reservation?.name\n\t}\n\n\tasync perform(call: ToolCall, context?: ToolContext): Promise<BrowserToolsetResult> {\n\t\tconst tool = this.#tools.tool(call.name)\n\t\tconst entry =\n\t\t\t(context === undefined ? undefined : this.#invocations.get(context)) ??\n\t\t\t(tool === undefined ? undefined : this.#handlers.get(tool))\n\t\tif (entry === undefined || context?.signal.aborted === true) {\n\t\t\tconst result = await this.#tools.execute(call, context)\n\t\t\tconst secret =\n\t\t\t\tcall.name === 'type' && call.arguments['secret'] === true\n\t\t\t\t\t? call.arguments['text']\n\t\t\t\t\t: undefined\n\t\t\treturn {\n\t\t\t\tresult: result.success\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tvalue: isString(result.value)\n\t\t\t\t\t\t\t\t? this.#boundReceipt(result.value, secret)\n\t\t\t\t\t\t\t\t: result.value,\n\t\t\t\t\t\t}\n\t\t\t\t\t: { ...result, error: this.#boundReceipt(result.error, secret) },\n\t\t\t}\n\t\t}\n\t\tconst signal = AbortSignal.any([\n\t\t\tcontext?.signal ?? new AbortController().signal,\n\t\t\tthis.#lifetime.signal,\n\t\t])\n\t\tconst started = performance.now()\n\t\tconst acting = !BROWSER_OBSERVATION_TOOL_NAMES.includes(call.name)\n\t\tlet result: ToolResult\n\t\tlet fault: unknown\n\t\ttry {\n\t\t\tif (acting) {\n\t\t\t\tconst secret = call.name === 'type' && call.arguments['secret'] === true\n\t\t\t\tthis.#actions.set(signal, {\n\t\t\t\t\taction: call.name,\n\t\t\t\t\targuments: cloneJSONRecord(\n\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\tObject.entries(call.arguments).filter(([key]) => !secret || key !== 'text'),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t\t...(secret ? { secret: true } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst value = await this.#execute(call.name, entry.clause, entry.handler, call.arguments, {\n\t\t\t\t...context,\n\t\t\t\tsignal,\n\t\t\t})\n\t\t\tresult = { id: call.id, name: call.name, success: true, value }\n\t\t} catch (error) {\n\t\t\tfault = error\n\t\t\tresult = {\n\t\t\t\tid: call.id,\n\t\t\t\tname: call.name,\n\t\t\t\tsuccess: false,\n\t\t\t\terror: isError(error) ? error.message : String(error),\n\t\t\t}\n\t\t}\n\t\tconst state = this.#actions.get(signal)\n\t\tthis.#actions.delete(signal)\n\t\tconst action: BrowserAction | undefined =\n\t\t\tstate?.arguments === undefined\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\t...state,\n\t\t\t\t\t\taction: call.name,\n\t\t\t\t\t\targuments: state.arguments,\n\t\t\t\t\t\toutcome: result.success ? (state.outcome ?? 'done') : 'refused',\n\t\t\t\t\t\treceipt: result.success ? (state.receipt ?? String(result.value)) : result.error,\n\t\t\t\t\t\telapsed: performance.now() - started,\n\t\t\t\t\t}\n\t\tif (action !== undefined) this.#emitter.emit('action', action)\n\t\treturn {\n\t\t\tresult,\n\t\t\t...(action === undefined ? {} : { action }),\n\t\t\t...(result.success ? {} : { fault }),\n\t\t}\n\t}\n\n\tasync hold(name: string, options?: BrowserCallOptions): Promise<BrowserHoldInterface> {\n\t\tthis.#live()\n\t\tconst signal = AbortSignal.any([\n\t\t\toptions?.signal ?? new AbortController().signal,\n\t\t\tthis.#lifetime.signal,\n\t\t])\n\t\tsignal.throwIfAborted()\n\t\tthis.#holdable()\n\t\tconst released = Promise.withResolvers<void>()\n\t\tconst hold = new BrowserHold(name, this.#releaseHold.bind(this, released))\n\t\tconst earlier = [...this.#holds.keys()]\n\t\tthis.#holds.set(released, hold)\n\t\ttry {\n\t\t\tif (earlier.length > 0)\n\t\t\t\tawait this.#race(Promise.all(earlier.map((entry) => entry.promise)), '', signal)\n\t\t\tconst turn = await this.#acquire(signal, false, true)\n\t\t\ttry {\n\t\t\t\tsignal.throwIfAborted()\n\t\t\t\tthis.#reservation = hold\n\t\t\t\tthis.#emitter.emit('hold', name)\n\t\t\t\treturn hold\n\t\t\t} finally {\n\t\t\t\tturn.resolve()\n\t\t\t}\n\t\t} catch (error) {\n\t\t\thold.destroy()\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync follow(\n\t\tid: string,\n\t\tstep: BrowserJourneyStepInput,\n\t\toptions?: BrowserFollowOptions,\n\t): Promise<BrowserAction> {\n\t\tconst context: ToolContext = {\n\t\t\tsignal: options?.signal ?? new AbortController().signal,\n\t\t\t...(options?.caller === undefined ? {} : { caller: options.caller }),\n\t\t}\n\t\tlet args: Readonly<Record<string, unknown>> = step.arguments\n\t\tif ((step.action === 'click' || step.action === 'type') && step.target !== undefined)\n\t\t\targs = { ...args, ref: await this.#resolveTarget(id, step.target, options) }\n\t\tif (step.action === 'type' && options?.secret === true) args = { ...args, secret: true }\n\t\t// Without a context the manager refuses `switch` itself, as it refuses any unadvertised step.\n\t\tif (step.action === 'switch' && step.tab !== undefined && this.#context !== undefined)\n\t\t\targs = { ...args, tab: await this.#resolveTab(id, step.tab, options) }\n\t\tconst performed = await this.perform({ id, name: step.action, arguments: args }, context)\n\t\tconst action = performed.action\n\t\tif (action === undefined)\n\t\t\tthrow new BrowserError(\n\t\t\t\t`${id}: ${performed.result.success ? String(performed.result.value) : performed.result.error}`,\n\t\t\t)\n\t\tif (\n\t\t\t(action.outcome !== 'done' && action.outcome !== 'interrupted') ||\n\t\t\taction.stage === 'requested' ||\n\t\t\taction.stage === 'committed'\n\t\t)\n\t\t\tthrow new BrowserStepError(id, action)\n\t\treturn action\n\t}\n\n\tasync tabs(options?: BrowserCallOptions): Promise<readonly BrowserTab[]> {\n\t\tthis.#live()\n\t\tconst signal = AbortSignal.any([\n\t\t\toptions?.signal ?? new AbortController().signal,\n\t\t\tthis.#lifetime.signal,\n\t\t])\n\t\tsignal.throwIfAborted()\n\t\tthis.#refuseDialog()\n\t\t// A dialog that opens while the titles are read never interrupts the listing, because the\n\t\t// interruption is a receipt and this result is data.\n\t\treturn this.#list(signal, false)\n\t}\n\n\tstart(options?: BrowserCallOptions): Promise<void> {\n\t\tif (this.#destroying !== undefined) return Promise.reject(this.#ended())\n\t\tif (this.#starting === undefined) {\n\t\t\t// The startup runs in a continuation, so the shared promise exists before any listener\n\t\t\t// the startup triggers can call `start()` again.\n\t\t\tconst starting = Promise.resolve().then(this.#begin.bind(this, options))\n\t\t\tthis.#starting = starting\n\t\t\tvoid starting.catch(this.#forget.bind(this, starting))\n\t\t}\n\t\treturn this.#starting\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tthis.#destroying ??= this.#teardown()\n\t\treturn this.#destroying\n\t}\n\n\tget #cursor(): BrowserViewInterface {\n\t\treturn this.#page ?? this.#view\n\t}\n\n\t#create(name: BrowserToolName, handler: BrowserToolsetHandler, clause: string): ToolInterface {\n\t\tconst validated = this.#validate.bind(this, name, handler)\n\t\tconst tool = createTool({\n\t\t\t...BROWSER_TOOL_COPY[name],\n\t\t\texecute: this.#dispatch.bind(this, name, validated, clause),\n\t\t})\n\t\tthis.#handlers.set(tool, { handler: validated, clause })\n\t\treturn tool\n\t}\n\n\tasync #dispatch(\n\t\tname: string,\n\t\thandler: BrowserToolsetHandler,\n\t\tclause: string,\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<unknown> {\n\t\tthis.#live()\n\t\tif (name !== 'type' || args['secret'] !== true) context.signal.throwIfAborted()\n\t\tconst invocation = { ...context }\n\t\tthis.#invocations.set(invocation, { handler, clause })\n\t\tconst performed = await this.perform({ id: '', name, arguments: args }, invocation)\n\t\tif (!performed.result.success) throw performed.fault ?? new BrowserError(performed.result.error)\n\t\treturn performed.result.value\n\t}\n\n\t#admit(category: 'observation' | 'action', caller: unknown): void {\n\t\tconst hold = this.#reservation ?? this.#holds.values().next().value\n\t\tif (hold !== undefined && caller !== hold.token && category !== 'observation')\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The toolset is replaying ${hold.name} until it finishes; call look.`,\n\t\t\t\t'BROWSER_TOOLSET_BUSY',\n\t\t\t)\n\t}\n\n\t#holdable(): void {\n\t\tconst dialog = this.#page === undefined ? undefined : this.#dialogs.get(this.#page)\n\t\tif (dialog !== undefined || this.#pending !== undefined)\n\t\t\tthrow new BrowserError(\n\t\t\t\tdialog === undefined\n\t\t\t\t\t? BROWSER_TOOL_PENDING_NOTE\n\t\t\t\t\t: renderBrowserReceipt({ action: '', dialog }),\n\t\t\t\t'BROWSER_TOOLSET_DIALOG',\n\t\t\t)\n\t}\n\n\t#releaseHold(released: PromiseWithResolvers<void>): void {\n\t\tconst hold = this.#holds.get(released)\n\t\tthis.#holds.delete(released)\n\t\treleased.resolve()\n\t\tif (hold !== undefined && this.#reservation === hold) {\n\t\t\tthis.#reservation = undefined\n\t\t\tthis.#emitter.emit('release', hold.name)\n\t\t}\n\t}\n\n\t// Refuses a parameter the tool does not advertise before its handler reads any argument.\n\t#validate(\n\t\tname: BrowserToolName,\n\t\thandler: BrowserToolsetHandler,\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tvalidateBrowserToolArguments(BROWSER_TOOL_COPY[name], args)\n\t\treturn handler(args, context)\n\t}\n\n\t// Every await is followed by a lifecycle check, so a `destroy()` that ran meanwhile leaves\n\t// nothing registered.\n\tasync #begin(options?: BrowserCallOptions): Promise<void> {\n\t\tthis.#live()\n\t\tconst conflict = BROWSER_TOOL_NAMES.find((name) => {\n\t\t\tconst held = this.#tools.tool(name)\n\t\t\treturn held !== undefined && !this.#added.has(held)\n\t\t})\n\t\tif (conflict !== undefined) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The tool manager already holds a tool named ${conflict}, a name the browser toolset reserves`,\n\t\t\t\t'BROWSER_TOOLSET_RESERVED',\n\t\t\t\t{ name: conflict },\n\t\t\t)\n\t\t}\n\t\tconst page = this.#page\n\t\ttry {\n\t\t\tthis.#listen(this.#source ?? page?.registry)\n\t\t\tif (this.#source === undefined && page !== undefined) await page.registry.start(options)\n\t\t\tthis.#live()\n\t\t\tif (page !== undefined) await this.#watch(page)\n\t\t\tthis.#live()\n\t\t} catch (error) {\n\t\t\tthis.#listen(undefined)\n\t\t\tif (page !== undefined) await this.#unwatch(page)\n\t\t\tthrow error\n\t\t}\n\t\tthis.#tools.emitter.on('remove', this.#removeHandler)\n\t\tthis.#tools.emitter.on('clear', this.#clearHandler)\n\t\tthis.#started = true\n\t\tfor (const tool of [...this.#native, ...this.#contextTools]) {\n\t\t\tthis.#add(tool)\n\t\t\tthis.#live()\n\t\t}\n\t\tthis.#stage()\n\t\tawait this.#adopt()\n\t\tthis.#live()\n\t}\n\n\t// The one boundary every tool runs through; a handler returns its body and a footer the\n\t// boundary appends after cutting the body, and `clause` closes the footer of a cut body.\n\tasync #execute(\n\t\tname: string,\n\t\tclause: string,\n\t\thandler: BrowserToolsetHandler,\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<string> {\n\t\tif (this.#destroying !== undefined) throw this.#ended()\n\t\tconst signal = context.signal\n\t\tconst secret = name === 'type' && args['secret'] === true ? args['text'] : undefined\n\t\ttry {\n\t\t\tsignal.throwIfAborted()\n\t\t\tthis.#admit(\n\t\t\t\tBROWSER_OBSERVATION_TOOL_NAMES.includes(name) || name === 'wait' ? 'observation' : 'action',\n\t\t\t\tcontext.caller,\n\t\t\t)\n\t\t\tif (name !== 'dialog') this.#refuseDialog()\n\t\t\tconst [content, suffix] = await handler(args, { ...context, signal })\n\t\t\tconst body = this.#boundReceipt(content, secret)\n\t\t\tconst footer = this.#boundReceipt(suffix, secret)\n\t\t\t// A cancellation that lands while the handler finishes wins over its result.\n\t\t\tsignal.throwIfAborted()\n\t\t\tconst state = this.#actions.get(signal)\n\t\t\tif (state !== undefined)\n\t\t\t\tthis.#actions.set(signal, {\n\t\t\t\t\t...state,\n\t\t\t\t\treceipt: boundBrowserText(body.split('\\n\\n')[0] ?? body, this.#limit, clause),\n\t\t\t\t})\n\t\t\treturn `${this.#boundReceipt(`${this.#drain()}${body}`, secret, clause)}${footer}`\n\t\t} catch (error) {\n\t\t\tconst original = isError(error) ? error.message : String(error)\n\t\t\tconst message = this.#boundReceipt(original, secret)\n\t\t\tif (context.signal.aborted && error === context.signal.reason && message === original)\n\t\t\t\tthrow error\n\t\t\tif (isBrowserError(error) && error.code === 'BROWSER_TOOLSET_RECEIPT') {\n\t\t\t\tthis.#actions.set(signal, { ...this.#actions.get(signal), outcome: 'interrupted' })\n\t\t\t\treturn this.#boundReceipt(`${this.#drain()}${message}`, secret, BROWSER_TOOL_CUT_FOOTER)\n\t\t\t}\n\t\t\tif (message === original && message.length <= this.#limit) throw error\n\t\t\tthrow new BrowserError(\n\t\t\t\tboundBrowserText(message, this.#limit, BROWSER_TOOL_CUT_FOOTER),\n\t\t\t\tisBrowserError(error) ? error.code : undefined,\n\t\t\t\tisBrowserError(error) ? error.context : undefined,\n\t\t\t)\n\t\t}\n\t}\n\n\t// Redacts before splitting or clipping, which could otherwise retain only part of a secret.\n\t#boundReceipt(message: string, secret: unknown, clause?: string): string {\n\t\tif (isString(secret) && secret.length > 0) {\n\t\t\tmessage = message\n\t\t\t\t.replaceAll(JSON.stringify(secret), '[redacted]')\n\t\t\t\t.replaceAll(secret, '[redacted]')\n\t\t}\n\t\treturn clause === undefined ? message : boundBrowserText(message, this.#limit, clause)\n\t}\n\n\tasync #look(\n\t\t_args: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\t// The outline carries the signal, so an abort rejects with its own pending protocol\n\t\t// entry's reason rather than a toolset-level copy of it.\n\t\tconst outline = await this.#race(this.#cursor.elements.outline({ signal: context.signal }), '')\n\t\treturn [outline.text, '']\n\t}\n\n\tasync #read(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst offset = args['offset'] ?? 0\n\t\tif (!isInteger(offset) || offset < 0) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The offset parameter must be a non-negative integer.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'offset' },\n\t\t\t)\n\t\t}\n\t\tconst view = this.#cursor\n\t\tconst retained = this.#reading\n\t\tlet reading = retained?.reading\n\t\t// A continuation reuses the capture it continues; a changed view or a navigation recaptures.\n\t\t// The slice restarts at 0 after a recapture and at an offset at or past the retained\n\t\t// reading's end, so the footer shows the reset.\n\t\tif (\n\t\t\toffset === 0 ||\n\t\t\tretained === undefined ||\n\t\t\treading === undefined ||\n\t\t\tretained.view !== view ||\n\t\t\treading.stale\n\t\t) {\n\t\t\treading = await this.#race(view.read({ signal: context.signal }), '', context.signal)\n\t\t\tthis.#reading = { view, reading }\n\t\t}\n\t\tconst start =\n\t\t\treading === retained?.reading && offset < reading.markdown({ offset: 0, limit: 1 }).total\n\t\t\t\t? offset\n\t\t\t\t: 0\n\t\t// A move note shares the limit with the slice, so the continuation offset counts only the\n\t\t// reading characters this result carries.\n\t\tconst note = boundBrowserText(\n\t\t\tthis.#drain(),\n\t\t\tMath.max(1, this.#limit - 1),\n\t\t\tBROWSER_TOOL_CUT_FOOTER,\n\t\t)\n\t\tconst room = this.#limit - note.length\n\t\tconst slice =\n\t\t\troom < 1\n\t\t\t\t? { text: '', offset: start, total: reading.markdown({ offset: 0 }).total }\n\t\t\t\t: reading.markdown({ offset: start, limit: room })\n\t\t// A limit that cannot hold the next code point would never advance the continuation.\n\t\tif (note === '' && slice.text === '' && slice.offset < slice.total) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The read limit of ${this.#limit} characters cannot hold the next character at offset ${start}; raise the toolset limit.`,\n\t\t\t\t'BROWSER_TOOLSET_LIMIT',\n\t\t\t\t{ limit: this.#limit, offset: start },\n\t\t\t)\n\t\t}\n\t\tconst end = slice.offset + slice.text.length\n\t\tconst more = end < slice.total\n\t\tif (start === 0 && !more) return [`${note}${slice.text}`, '']\n\t\treturn [\n\t\t\t`${note}${slice.text}`,\n\t\t\t`\\n\\n[characters ${start}–${end} of ${slice.total}${more ? `; call read with offset ${end} for more` : ''}]`,\n\t\t]\n\t}\n\n\tasync #click(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst turn = await this.#acquire(context.signal)\n\t\tconst observation = { token: (this.#sequence += 1), frames: new Set<BrowserFrameInterface>() }\n\t\tlet record: BrowserNavigationRecordInterface | undefined\n\t\tlet popups: BrowserPopupRecordInterface | undefined\n\t\ttry {\n\t\t\tconst element = this.#element(args['ref'], context.signal)\n\t\t\tconst action = BROWSER_TYPED_ROLES.has(element.role)\n\t\t\t\t? `Clicked ${renderBrowserElement(element)}; call type with ${element.reference} to enter text`\n\t\t\t\t: `Clicked ${renderBrowserElement(element)}`\n\t\t\tconst page = this.#page\n\t\t\tif (page !== undefined) {\n\t\t\t\tconst frame = this.#resolveFrame(page, element.reference)\n\t\t\t\tawait this.#observe(\n\t\t\t\t\tawait this.#locate(page, frame, context.signal),\n\t\t\t\t\tframe,\n\t\t\t\t\tobservation,\n\t\t\t\t\tcontext.signal,\n\t\t\t\t)\n\t\t\t\trecord = page.navigation.record(frame)\n\t\t\t\tpopups = this.#recordPopups(page)\n\t\t\t}\n\t\t\treturn [\n\t\t\t\tawait this.#settle(\n\t\t\t\t\telement.click({ signal: context.signal }),\n\t\t\t\t\taction,\n\t\t\t\t\tcontext.signal,\n\t\t\t\t\tthis.#view.trusted,\n\t\t\t\t\trecord,\n\t\t\t\t\tpopups,\n\t\t\t\t\tobservation,\n\t\t\t\t),\n\t\t\t\t'',\n\t\t\t]\n\t\t} finally {\n\t\t\trecord?.destroy()\n\t\t\tpopups?.destroy()\n\t\t\tthis.#flushArrivals()\n\t\t\ttry {\n\t\t\t\tawait this.#unobserve(observation, context.signal)\n\t\t\t} finally {\n\t\t\t\tturn.resolve()\n\t\t\t}\n\t\t}\n\t}\n\n\tasync #type(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst text = readBrowserToolString(args, 'text')\n\t\tconst submit = args['submit']\n\t\tconst secret = args['secret']\n\t\tif (secret !== undefined && !isBoolean(secret))\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The secret parameter must be a boolean.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'secret' },\n\t\t\t)\n\t\tif (submit !== undefined && !isBoolean(submit)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The submit parameter must be a boolean.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'submit' },\n\t\t\t)\n\t\t}\n\n\t\tconst turn = await this.#acquire(context.signal)\n\t\tconst observation = { token: (this.#sequence += 1), frames: new Set<BrowserFrameInterface>() }\n\t\tlet record: BrowserNavigationRecordInterface | undefined\n\t\tlet popups: BrowserPopupRecordInterface | undefined\n\t\ttry {\n\t\t\tconst element = this.#element(args['ref'], context.signal)\n\t\t\t// The role the latest capture recorded decides, so a control that takes no text is\n\t\t\t// refused before any protocol command reaches it.\n\t\t\tif (!BROWSER_TYPED_ROLES.has(element.role)) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Element ${renderBrowserElement(element)} takes no text; call click for ${/^[aeiou]/i.test(element.role) ? 'an' : 'a'} ${element.role}.`,\n\t\t\t\t\t'BROWSER_TOOLSET_ROLE',\n\t\t\t\t\t{ reference: element.reference, role: element.role },\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst chosen = `Selected ${secret === true ? 'a secret' : JSON.stringify(text)} in ${renderBrowserElement(element)} (programmatic)`\n\t\t\tconst typed = `Typed ${secret === true ? 'a secret' : JSON.stringify(text)} into ${renderBrowserElement(element)}`\n\t\t\t// The observer and the record precede the edit, because the inserted text or the chosen\n\t\t\t// option can run a handler that submits the form.\n\t\t\tconst page = this.#page\n\t\t\tif (page !== undefined) {\n\t\t\t\tconst frame = this.#resolveFrame(page, element.reference)\n\t\t\t\tif (submit === true)\n\t\t\t\t\tawait this.#observe(\n\t\t\t\t\t\tawait this.#locate(page, frame, context.signal),\n\t\t\t\t\t\tframe,\n\t\t\t\t\t\tobservation,\n\t\t\t\t\t\tcontext.signal,\n\t\t\t\t\t)\n\t\t\t\trecord = page.navigation.record(frame)\n\t\t\t\tif (submit === true) popups = this.#recordPopups(page)\n\t\t\t}\n\t\t\t// A combobox or listbox role names a select element or a text input with suggestions;\n\t\t\t// the receipt names the path taken, and a dialog mid-edit names the path attempted.\n\t\t\tconst choosing = element.role === 'combobox' || element.role === 'listbox'\n\t\t\tconst edit = choosing\n\t\t\t\t? this.#choose(element, text, context.signal)\n\t\t\t\t: element.fill(text, { signal: context.signal }).then(() => false)\n\t\t\t// The edit is the first input, so a navigation it starts wins the race as a click's does:\n\t\t\t// the unfinished edit stays the queue barrier, and no submission is sent through the\n\t\t\t// reference that navigation replaces.\n\t\t\tconst attempted = choosing ? chosen : typed\n\t\t\tconst started = record?.wait({ signal: context.signal }).then(\n\t\t\t\t() => undefined,\n\t\t\t\t() => new Promise<undefined>(() => undefined),\n\t\t\t)\n\t\t\tconst selected = await this.#command(\n\t\t\t\tstarted === undefined ? edit : Promise.race([started, edit]),\n\t\t\t\tattempted,\n\t\t\t\tedit,\n\t\t\t)\n\t\t\tif (selected === undefined)\n\t\t\t\treturn [\n\t\t\t\t\tawait this.#settle(\n\t\t\t\t\t\tedit.then(() => undefined),\n\t\t\t\t\t\tattempted,\n\t\t\t\t\t\tcontext.signal,\n\t\t\t\t\t\tthis.#view.trusted,\n\t\t\t\t\t\trecord,\n\t\t\t\t\t\tpopups,\n\t\t\t\t\t\tobservation,\n\t\t\t\t\t),\n\t\t\t\t\t'',\n\t\t\t\t]\n\t\t\tconst action = selected ? chosen : typed\n\t\t\tif (submit !== true) {\n\t\t\t\treturn [\n\t\t\t\t\tawait this.#settle(Promise.resolve(), action, context.signal, this.#view.trusted, record),\n\t\t\t\t\t'',\n\t\t\t\t]\n\t\t\t}\n\t\t\t// The page placement submits with a trusted Enter, so its receipt names the submission\n\t\t\t// only when the observer recorded one; the DOM placement calls `requestSubmit()`.\n\t\t\treturn [\n\t\t\t\tawait this.#settle(\n\t\t\t\t\telement.submit({ signal: context.signal }),\n\t\t\t\t\tpage === undefined ? `${action} and submitted the form` : `${action} and pressed Enter`,\n\t\t\t\t\tcontext.signal,\n\t\t\t\t\tthis.#view.trusted,\n\t\t\t\t\trecord,\n\t\t\t\t\tpopups,\n\t\t\t\t\tobservation,\n\t\t\t\t\tpage === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: { explicit: true, action: `${action} and submitted the form` },\n\t\t\t\t),\n\t\t\t\t'',\n\t\t\t]\n\t\t} finally {\n\t\t\trecord?.destroy()\n\t\t\tpopups?.destroy()\n\t\t\tthis.#flushArrivals()\n\t\t\ttry {\n\t\t\t\tawait this.#unobserve(observation, context.signal)\n\t\t\t} finally {\n\t\t\t\tturn.resolve()\n\t\t\t}\n\t\t}\n\t}\n\n\tasync #press(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst key = normalizeBrowserKey(readBrowserToolString(args, 'key'))\n\t\tconst turn = await this.#acquire(context.signal)\n\t\tconst observation = { token: (this.#sequence += 1), frames: new Set<BrowserFrameInterface>() }\n\t\tlet record: BrowserNavigationRecordInterface | undefined\n\t\tlet popups: BrowserPopupRecordInterface | undefined\n\t\ttry {\n\t\t\tconst page = this.#paged()\n\t\t\t// The focused document receives the keys, so every document one census lists is observed,\n\t\t\t// and only the main frame's must install.\n\t\t\tconst frames = await this.#race(page.frames(), '', context.signal)\n\t\t\tawait this.#observe(frames, page.id, observation, context.signal)\n\t\t\trecord = page.navigation.record(page.id)\n\t\t\tif (key === 'Enter') popups = this.#recordPopups(page)\n\t\t\t// The keyboard takes no signal and sends each release without one, so the signal is\n\t\t\t// checked before the first key goes down.\n\t\t\tcontext.signal.throwIfAborted()\n\t\t\tconst action = `Pressed ${key}`\n\t\t\treturn [\n\t\t\t\tawait this.#settle(\n\t\t\t\t\tpage.keyboard.press(key),\n\t\t\t\t\taction,\n\t\t\t\t\tcontext.signal,\n\t\t\t\t\ttrue,\n\t\t\t\t\trecord,\n\t\t\t\t\tpopups,\n\t\t\t\t\tobservation,\n\t\t\t\t\tkey === 'Enter' ? { explicit: false, action } : undefined,\n\t\t\t\t),\n\t\t\t\t'',\n\t\t\t]\n\t\t} finally {\n\t\t\trecord?.destroy()\n\t\t\tpopups?.destroy()\n\t\t\tthis.#flushArrivals()\n\t\t\ttry {\n\t\t\t\tawait this.#unobserve(observation, context.signal)\n\t\t\t} finally {\n\t\t\t\tturn.resolve()\n\t\t\t}\n\t\t}\n\t}\n\n\tasync #navigate(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst url = readBrowserToolString(args, 'url')\n\t\tconst parsed = URL.canParse(url) ? new URL(url) : undefined\n\t\tif (parsed === undefined) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Navigation refused: ${JSON.stringify(url)} is not an absolute URL.`,\n\t\t\t\t'BROWSER_TOOLSET_SCHEME',\n\t\t\t\t{ url },\n\t\t\t)\n\t\t}\n\t\tif (!this.#schemes.includes(parsed.protocol)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Navigation refused: the ${parsed.protocol} scheme is not allowed; use ${this.#schemes.join(' or ')}.`,\n\t\t\t\t'BROWSER_TOOLSET_SCHEME',\n\t\t\t\t{ url },\n\t\t\t)\n\t\t}\n\t\tconst turn = await this.#acquire(context.signal)\n\t\tconst page = this.#paged()\n\t\tthis.#navigating = page\n\t\tconst record = page.navigation.record(page.id)\n\t\ttry {\n\t\t\t// The page's load wait rejects with the signal's reason after its cleanup, so the\n\t\t\t// command stays the queue's barrier until that cleanup settles.\n\t\t\tconst navigation = page.navigate(url, { condition: 'load', signal: context.signal })\n\t\t\tconst result = await this.#command(navigation, `Navigating to ${url}`, navigation)\n\t\t\tconst settled = await record.settle({ signal: context.signal, timeout: 0 })\n\t\t\tthis.#actions.set(context.signal, {\n\t\t\t\t...this.#actions.get(context.signal),\n\t\t\t\tstage: 'loaded',\n\t\t\t\t...(settled?.reason === undefined ? {} : { reason: settled.reason }),\n\t\t\t})\n\t\t\tconst action = `Navigated to ${result.url}`\n\t\t\treturn [\n\t\t\t\trenderBrowserReceipt({ action, view: await this.#capture(action, context.signal) }),\n\t\t\t\t'',\n\t\t\t]\n\t\t} finally {\n\t\t\tif (this.#navigating === page) this.#navigating = undefined\n\t\t\trecord.destroy()\n\t\t\tturn.resolve()\n\t\t}\n\t}\n\n\tasync #wait(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst text = readBrowserToolString(args, 'text')\n\t\tconst seconds = args['timeout']\n\t\tif (seconds !== undefined && (!isFiniteNumber(seconds) || seconds <= 0)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The timeout parameter must be a positive number of seconds.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'timeout' },\n\t\t\t)\n\t\t}\n\t\tconst timeout = Math.min(\n\t\t\tseconds === undefined ? BROWSER_TOOL_TIMEOUT_MS : Math.ceil(seconds * 1000),\n\t\t\tBROWSER_TOOL_TIMEOUT_LIMIT_MS,\n\t\t)\n\t\tconst quoted = JSON.stringify(text)\n\t\ttry {\n\t\t\tawait this.#race(\n\t\t\t\tthis.#cursor.wait(text, { timeout, signal: context.signal }),\n\t\t\t\t`Waited for ${quoted}`,\n\t\t\t\tcontext.signal,\n\t\t\t)\n\t\t\treturn [`${quoted} is on the page.`, '']\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\t!context.signal.aborted &&\n\t\t\t\tisBrowserError(error) &&\n\t\t\t\terror.code === 'BROWSER_WAIT_TIMEOUT'\n\t\t\t) {\n\t\t\t\tthis.#actions.set(context.signal, {\n\t\t\t\t\t...this.#actions.get(context.signal),\n\t\t\t\t\toutcome: 'timeout',\n\t\t\t\t})\n\t\t\t\treturn [`${quoted} did not appear within ${timeout / 1000} s.`, '']\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #dialog(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst accept = args['accept']\n\t\tconst text = args['text']\n\t\tif (!isBoolean(accept)) {\n\t\t\tthrow new BrowserError(\n\t\t\t\t'The accept parameter must be a boolean.',\n\t\t\t\t'BROWSER_TOOLSET_ARGUMENT',\n\t\t\t\t{ key: 'accept' },\n\t\t\t)\n\t\t}\n\t\tif (text !== undefined && !isString(text)) {\n\t\t\tthrow new BrowserError('The text parameter must be a string.', 'BROWSER_TOOLSET_ARGUMENT', {\n\t\t\t\tkey: 'text',\n\t\t\t})\n\t\t}\n\t\tconst turn = await this.#acquire(context.signal, true)\n\t\ttry {\n\t\t\tconst page = this.#paged()\n\t\t\tconst dialog = this.#dialogs.get(page)\n\t\t\tif (dialog === undefined) {\n\t\t\t\tthrow new BrowserError('No dialog is open; call look.', 'BROWSER_TOOLSET_DIALOG')\n\t\t\t}\n\t\t\tcontext.signal.throwIfAborted()\n\t\t\tif (accept) await dialog.accept(text)\n\t\t\telse await dialog.dismiss()\n\t\t\tif (this.#dialogs.get(page) === dialog) this.#dialogs.delete(page)\n\t\t\tthis.#stage()\n\t\t\tconst action = `${accept ? 'Accepted' : 'Dismissed'} the ${dialog.category} dialog ${JSON.stringify(dialog.message)}`\n\t\t\treturn [\n\t\t\t\trenderBrowserReceipt({ action, view: await this.#capture(action, context.signal) }),\n\t\t\t\t'',\n\t\t\t]\n\t\t} finally {\n\t\t\tturn.resolve()\n\t\t}\n\t}\n\n\tasync #tabs(\n\t\t_args: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst tabs = await this.#list(context.signal, true)\n\t\treturn [\n\t\t\ttabs\n\t\t\t\t.map(\n\t\t\t\t\t(tab) =>\n\t\t\t\t\t\t`${tab.id} ${JSON.stringify(tab.title)} ${tab.url}${tab.current ? ' (current)' : ''}`,\n\t\t\t\t)\n\t\t\t\t.join('\\n'),\n\t\t\t'',\n\t\t]\n\t}\n\n\tasync #switch(\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst tab = readBrowserToolString(args, 'tab')\n\t\tconst turn = await this.#acquire(context.signal)\n\t\ttry {\n\t\t\tconst pages = this.#context?.pages() ?? []\n\t\t\tconst match = /^t?([1-9]\\d*)$/i.exec(tab.trim())\n\t\t\tconst page = match === null ? undefined : pages[Number(match[1]) - 1]\n\t\t\tif (page === undefined) {\n\t\t\t\tthrow new BrowserError(\n\t\t\t\t\t`Tab ${JSON.stringify(tab)} is not open; call tabs.`,\n\t\t\t\t\t'BROWSER_TOOLSET_TAB',\n\t\t\t\t\t{ tab },\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst action = `Switched to t${pages.indexOf(page) + 1} ${page.url}`\n\t\t\tthis.#actions.set(context.signal, {\n\t\t\t\t...this.#actions.get(context.signal),\n\t\t\t\ttab: { url: page.url, title: await page.title({ signal: context.signal }) },\n\t\t\t})\n\t\t\tawait this.#select(page)\n\t\t\tconst front = page.send('Page.bringToFront', undefined, { signal: context.signal })\n\t\t\tawait this.#command(front, action, front)\n\t\t\treturn [\n\t\t\t\trenderBrowserReceipt({ action, view: await this.#capture(action, context.signal) }),\n\t\t\t\t'',\n\t\t\t]\n\t\t} finally {\n\t\t\tturn.resolve()\n\t\t}\n\t}\n\n\tasync #invoke(\n\t\ttool: ToolInterface,\n\t\tsynthetic: boolean,\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcontext: ToolContext,\n\t): Promise<readonly [string, string]> {\n\t\tconst turn = await this.#acquire(context.signal)\n\t\ttry {\n\t\t\tconst input = synthetic\n\t\t\t\t? Object.fromEntries(Object.entries(args).filter(([key]) => key !== 'what'))\n\t\t\t\t: args\n\t\t\tconst command = Promise.resolve(tool.execute(input, context))\n\t\t\tconst output = await this.#command(command, `Called ${tool.name}`, command, context.signal)\n\t\t\treturn [renderBrowserToolOutput(output), '']\n\t\t} finally {\n\t\t\tturn.resolve()\n\t\t}\n\t}\n\n\t// Lists the context's tabs; `interruptible` lets a dialog that opens meanwhile end the `tabs`\n\t// tool with its receipt.\n\t#list(signal: AbortSignal, interruptible: boolean): Promise<readonly BrowserTab[]> {\n\t\tconst pages = this.#context?.pages() ?? []\n\t\treturn this.#race(\n\t\t\tPromise.all(pages.map((page, index) => this.#tab(page, index, signal))),\n\t\t\t'',\n\t\t\tsignal,\n\t\t\tinterruptible,\n\t\t)\n\t}\n\n\tasync #tab(page: BrowserPageInterface, index: number, signal: AbortSignal): Promise<BrowserTab> {\n\t\tconst title = await page\n\t\t\t.title({ signal, timeout: BROWSER_TOOL_TIMEOUT_MS })\n\t\t\t.catch((error: unknown) => {\n\t\t\t\t// A tab that does not answer its title is still listed.\n\t\t\t\tif (signal.aborted) throw error\n\t\t\t\treturn ''\n\t\t\t})\n\t\treturn { id: `t${index + 1}`, title, url: page.url, current: page === this.#page }\n\t}\n\n\t// Refuses while a dialog is open on the current page, naming the dialog.\n\t#refuseDialog(): void {\n\t\tconst dialog = this.#page === undefined ? undefined : this.#dialogs.get(this.#page)\n\t\tif (dialog !== undefined)\n\t\t\tthrow new BrowserError(renderBrowserReceipt({ action: '', dialog }), 'BROWSER_TOOLSET_DIALOG')\n\t}\n\n\tasync #choose(\n\t\telement: BrowserElementInterface,\n\t\ttext: string,\n\t\tsignal: AbortSignal,\n\t): Promise<boolean> {\n\t\ttry {\n\t\t\tawait element.select([text], { signal })\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\t// The combobox role also names a text input with a suggestion list, which the select\n\t\t\t// function refuses and which takes typed text instead.\n\t\t\tif (!isBrowserError(error) || !error.message.includes('not a select control')) throw error\n\t\t}\n\t\tawait element.fill(text, { signal })\n\t\treturn false\n\t}\n\n\t#element(value: unknown, signal: AbortSignal): BrowserElementInterface {\n\t\tconst reference = requireBrowserReference(value)\n\t\tconst element = this.#cursor.elements.element(reference)\n\t\tif (element === undefined) {\n\t\t\tthrow new BrowserElementError(\n\t\t\t\treference,\n\t\t\t\t'UNKNOWN',\n\t\t\t\t'is not in the current view; call look for fresh refs',\n\t\t\t)\n\t\t}\n\t\tconst frame = this.#page === undefined ? undefined : this.#resolveFrame(this.#page, reference)\n\t\tthis.#actions.set(signal, {\n\t\t\t...this.#actions.get(signal),\n\t\t\ttarget: {\n\t\t\t\trole: element.role,\n\t\t\t\tname: element.name,\n\t\t\t\treference: element.reference,\n\t\t\t\t...(frame === undefined || frame === this.#page?.id ? {} : { frame }),\n\t\t\t},\n\t\t})\n\t\treturn element\n\t}\n\n\t#paged(): BrowserPageInterface {\n\t\tif (this.#page === undefined) {\n\t\t\tthrow new BrowserError('This view has no page', 'BROWSER_TOOLSET_PAGE')\n\t\t}\n\t\treturn this.#page\n\t}\n\n\t// Waits for the action queue and for a command an earlier receipt left pending.\n\tasync #acquire(\n\t\tsignal: AbortSignal,\n\t\tanswer = false,\n\t\tholding = false,\n\t): Promise<PromiseWithResolvers<void>> {\n\t\tconst previous = this.#tail\n\t\tconst turn = Promise.withResolvers<void>()\n\t\tthis.#tail = previous.then(() => turn.promise)\n\t\ttry {\n\t\t\tawait this.#race(previous, '', signal, !answer)\n\t\t\tif (holding) this.#holdable()\n\t\t\tconst pending = this.#pending\n\t\t\tif (!answer && pending !== undefined) await this.#race(pending, '', signal, !answer)\n\t\t\tif (!answer && this.#pending === pending) this.#pending = undefined\n\t\t} catch (error) {\n\t\t\tturn.resolve()\n\t\t\tif (isBrowserError(error) && error.code === 'BROWSER_TOOLSET_RECEIPT') {\n\t\t\t\tthrow new BrowserError(error.message, 'BROWSER_TOOLSET_DIALOG')\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t\treturn turn\n\t}\n\n\t// Races an action's command against the start of a navigation in its frame or an ancestor, then\n\t// bounds the settlement of the navigation the action started and the view capture by one\n\t// deadline, of which the capture keeps `BROWSER_TOOL_CAPTURE_MS` for itself. A command that settles\n\t// first leaves a form submission's navigation to start later, so the observation's reads name the\n\t// destinations the record also waits for under the same deadline. The record selects and follows\n\t// the navigation; this method holds no frame, session, loader, or request state. `enter` marks an\n\t// action that pressed Enter to submit: `explicit` when the model asked for the submission whatever\n\t// the Enter's target, and the `action` line that replaces the attempt when a read recorded a\n\t// submission, or when the settled navigation's reason names a form submission, which a form in a\n\t// document the observer does not cover can start; a navigation with another reason or none does\n\t// not prove one. A popup the input opened is part of the settlement: after the navigation, the\n\t// popup record waits within the same bound for the popups its reports name, and the view moves to\n\t// the first open one before the capture, so the receipt carries the popup's view and the move.\n\tasync #settle(\n\t\tcommand: Promise<void>,\n\t\taction: string,\n\t\tsignal: AbortSignal,\n\t\ttrusted: boolean,\n\t\trecord?: BrowserNavigationRecordInterface,\n\t\tpopups?: BrowserPopupRecordInterface,\n\t\tobservation?: { readonly token: number; readonly frames: Set<BrowserFrameInterface> },\n\t\tenter?: { readonly explicit: boolean; readonly action: string },\n\t): Promise<string> {\n\t\tlet deadline: number | undefined\n\t\ttry {\n\t\t\t// A wait that ends without a start leaves the command to decide the race.\n\t\t\tconst started = record?.wait({ signal }).then(\n\t\t\t\t() => true,\n\t\t\t\t() => new Promise<boolean>(() => undefined),\n\t\t\t)\n\t\t\tconst input = command.then(() => false)\n\t\t\tconst first = await this.#command(\n\t\t\t\tstarted === undefined ? input : Promise.race([started, input]),\n\t\t\t\taction,\n\t\t\t\tcommand,\n\t\t\t)\n\t\t\tdeadline = performance.now() + BROWSER_TOOL_TIMEOUT_MS\n\t\t\tconst bound = deadline - BROWSER_TOOL_CAPTURE_MS\n\t\t\tif (first) this.#parkInput(command)\n\t\t\tconst submissions =\n\t\t\t\tfirst || observation === undefined\n\t\t\t\t\t? { destinations: [], prevented: false, submitted: undefined, implicit: false }\n\t\t\t\t\t: await this.#readSubmissions(observation, action, signal, bound)\n\t\t\tconst settled =\n\t\t\t\trecord === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: await this.#race(\n\t\t\t\t\t\t\trecord.settle({\n\t\t\t\t\t\t\t\tdestinations: submissions.destinations,\n\t\t\t\t\t\t\t\ttimeout: Math.max(0, bound - performance.now()),\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\taction,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t)\n\t\t\tsignal.throwIfAborted()\n\t\t\tconst opened =\n\t\t\t\tpopups === undefined\n\t\t\t\t\t? []\n\t\t\t\t\t: await this.#race(\n\t\t\t\t\t\t\tpopups.settle({ timeout: Math.max(0, bound - performance.now()), signal }),\n\t\t\t\t\t\t\taction,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t)\n\t\t\tsignal.throwIfAborted()\n\t\t\tconst popup = opened.find((page) => !page.closed)\n\t\t\tif (popup !== undefined) await this.#followPopup(popup, action, signal, bound)\n\t\t\tif (settled !== undefined)\n\t\t\t\tthis.#actions.set(signal, {\n\t\t\t\t\t...this.#actions.get(signal),\n\t\t\t\t\tstage: settled.stage,\n\t\t\t\t\t...(settled.reason === undefined ? {} : { reason: settled.reason }),\n\t\t\t\t})\n\t\t\t// Without a surviving destination and a navigation, the observer names what became of the\n\t\t\t// submission: a listener handled it, or no form received the Enter the action asked for.\n\t\t\tconst unmoved = settled === undefined && submissions.destinations.length === 0\n\t\t\tconst status =\n\t\t\t\tsettled?.stage === 'committed'\n\t\t\t\t\t? `the page is still loading ${settled.url}`\n\t\t\t\t\t: settled?.stage === 'requested'\n\t\t\t\t\t\t? `it requested ${settled.url} and the page did not change`\n\t\t\t\t\t\t: unmoved && submissions.prevented\n\t\t\t\t\t\t\t? BROWSER_TOOL_HANDLED_STATUS\n\t\t\t\t\t\t\t: unmoved &&\n\t\t\t\t\t\t\t\t submissions.submitted === false &&\n\t\t\t\t\t\t\t\t (enter?.explicit === true || (enter !== undefined && submissions.implicit))\n\t\t\t\t\t\t\t\t? 'no form received the submission'\n\t\t\t\t\t\t\t\t: undefined\n\t\t\tconst line =\n\t\t\t\tenter !== undefined &&\n\t\t\t\t(submissions.submitted === true ||\n\t\t\t\t\tsettled?.reason === 'formSubmissionGet' ||\n\t\t\t\t\tsettled?.reason === 'formSubmissionPost')\n\t\t\t\t\t? enter.action\n\t\t\t\t\t: action\n\t\t\treturn renderBrowserReceipt({\n\t\t\t\taction: line,\n\t\t\t\ttrusted,\n\t\t\t\t...(status === undefined ? {} : { status }),\n\t\t\t\tview: await this.#capture(line, signal, deadline),\n\t\t\t})\n\t\t} finally {\n\t\t\trecord?.destroy()\n\t\t\tif (observation !== undefined) await this.#unobserve(observation, signal, deadline)\n\t\t}\n\t}\n\n\t// Opens the popup record of an action into `page`; until the action ends, a popup the page\n\t// announces waits for the action, which moves the view itself.\n\t#recordPopups(page: BrowserPageInterface): BrowserPopupRecordInterface {\n\t\tconst popups = page.popups.record()\n\t\tthis.#arrivals = []\n\t\treturn popups\n\t}\n\n\t// Hands the popups announced during the action to the popup handler once the action ends, which\n\t// moves the view to none the action already moved it past.\n\t#flushArrivals(): void {\n\t\tconst arrivals = this.#arrivals ?? []\n\t\tthis.#arrivals = undefined\n\t\tfor (const [opener, popup] of arrivals) this.#handlePopup(opener, popup)\n\t}\n\n\t// Moves the view to a popup the action opened and records it as the action's tab; a title the\n\t// popup cannot answer within `bound` is empty.\n\tasync #followPopup(\n\t\tpopup: BrowserPageInterface,\n\t\taction: string,\n\t\tsignal: AbortSignal,\n\t\tbound: number,\n\t): Promise<void> {\n\t\tconst title = await this.#bounded(\n\t\t\tpopup.title({ signal }).catch((error: unknown) => {\n\t\t\t\tif (signal.aborted) throw error\n\t\t\t\treturn ''\n\t\t\t}),\n\t\t\tbound,\n\t\t\taction,\n\t\t\tsignal,\n\t\t)\n\t\tthis.#actions.set(signal, {\n\t\t\t...this.#actions.get(signal),\n\t\t\ttab: { url: popup.url, title: title ?? '' },\n\t\t})\n\t\tawait this.#select(popup, `The view moved to a new tab: ${popup.url}.`)\n\t}\n\n\t// Races a command that carries the signal itself; a dialog leaves it pending for the next\n\t// action to await.\n\tasync #command<T>(\n\t\tstep: Promise<T>,\n\t\taction: string,\n\t\tcommand: Promise<unknown>,\n\t\tsignal?: AbortSignal,\n\t): Promise<T> {\n\t\ttry {\n\t\t\treturn await this.#race(step, action, signal)\n\t\t} catch (error) {\n\t\t\tif (isBrowserError(error) && error.code === 'BROWSER_TOOLSET_RECEIPT')\n\t\t\t\tthis.#parkInput(command)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t#parkInput(command: Promise<unknown>): void {\n\t\tconst pending = command.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined,\n\t\t)\n\t\tthis.#pending = pending\n\t\tvoid pending.then(() => {\n\t\t\tif (this.#pending === pending) this.#pending = undefined\n\t\t})\n\t}\n\n\t// Returns the frame whose document receives an input on the referenced element: the frame the\n\t// element manager recorded for it, or the main frame.\n\t// Returns the reference of the one element of the current view that carries the target's role\n\t// and exact name; the stored reference and selector are evidence a developer reads, never a lookup.\n\tasync #resolveTarget(\n\t\tid: string,\n\t\ttarget: BrowserJourneyTarget,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<string> {\n\t\tconst name = target.name\n\t\tif (!isString(name))\n\t\t\tthrow new BrowserError(\n\t\t\t\t`Step ${id} binds its target name to parameter ${JSON.stringify(name.parameter)}; pass the name itself.`,\n\t\t\t\t'BROWSER_JOURNEY_INPUT',\n\t\t\t\t{ step: id, parameter: name.parameter },\n\t\t\t)\n\t\tconst matches = await this.#cursor.elements.find(\n\t\t\t{ role: target.role, name, exact: true },\n\t\t\toptions,\n\t\t)\n\t\tconst [element] = matches\n\t\tif (matches.length === 1 && element !== undefined) return element.reference\n\t\tthrow new BrowserError(\n\t\t\t`Step ${id} names ${target.role} ${JSON.stringify(name)}, which ${matches.length === 0 ? 'no element carries' : `${matches.length} elements carry`}; call edit to remove or replace ${id}.`,\n\t\t\tmatches.length === 0 ? 'BROWSER_JOURNEY_TARGET' : 'BROWSER_JOURNEY_AMBIGUOUS',\n\t\t)\n\t}\n\n\t// Returns the id of the one open tab that carries the step's URL and title.\n\tasync #resolveTab(\n\t\tid: string,\n\t\ttab: BrowserJourneyTab,\n\t\toptions?: BrowserCallOptions,\n\t): Promise<string> {\n\t\tconst matches = (await this.tabs(options)).filter(\n\t\t\t(candidate) => candidate.title === tab.title && candidate.url === tab.url,\n\t\t)\n\t\tconst [match] = matches\n\t\tif (matches.length === 1 && match !== undefined) return match.id\n\t\tthrow new BrowserError(\n\t\t\t`${id}: The tab ${JSON.stringify(tab.title)} at ${tab.url} ${matches.length === 0 ? 'is not open' : 'is ambiguous'}; call tabs.`,\n\t\t\tmatches.length === 0 ? 'BROWSER_JOURNEY_TARGET' : 'BROWSER_JOURNEY_AMBIGUOUS',\n\t\t)\n\t}\n\n\t#resolveFrame(page: BrowserPageInterface, reference: string): string {\n\t\treturn page.elements.element(reference)?.frame ?? page.id\n\t}\n\n\t// Lists the document of `frame` as one census lists it, whose isolated world the observer runs\n\t// in, or none.\n\tasync #locate(\n\t\tpage: BrowserPageInterface,\n\t\tframe: string,\n\t\tsignal: AbortSignal,\n\t): Promise<readonly BrowserFrameInterface[]> {\n\t\tconst frames = await this.#race(page.frames(), '', signal)\n\t\treturn frames.filter((candidate) => candidate.id === frame)\n\t}\n\n\t// Installs the observer the action's token owns in each of `frames` concurrently; the action owns\n\t// a document from the moment its installation is sent, so every exit removes it. The document of\n\t// `required` receives the input and must install, or the action is refused before any input;\n\t// another document's failure leaves it unobserved.\n\tasync #observe(\n\t\tframes: readonly BrowserFrameInterface[],\n\t\trequired: string,\n\t\tobservation: { readonly token: number; readonly frames: Set<BrowserFrameInterface> },\n\t\tsignal: AbortSignal,\n\t): Promise<void> {\n\t\tconst installs = frames.map((frame) => {\n\t\t\tobservation.frames.add(frame)\n\t\t\treturn this.#install(frame, observation.token, signal)\n\t\t})\n\t\tconst installed = await this.#race(Promise.all(installs), '', signal)\n\t\tif (!frames.some((frame, index) => frame.id === required && installed[index] === true))\n\t\t\tthrow new BrowserError(\n\t\t\t\t`The action was not sent: frame ${required}, which receives the input, could not be observed for a form submission; call look.`,\n\t\t\t\t'BROWSER_TOOLSET_OBSERVE',\n\t\t\t\t{ frame: required },\n\t\t\t)\n\t}\n\n\tasync #install(\n\t\tframe: BrowserFrameInterface,\n\t\ttoken: number,\n\t\tsignal: AbortSignal,\n\t): Promise<boolean> {\n\t\ttry {\n\t\t\tawait frame.evaluate(compileSubmitObserverExpression(token), { signal })\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) throw error\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Reads every document the action still owns within `bound` and returns the destination of each\n\t// surviving submission, whether a listener prevented one, and whether an Enter reached an input\n\t// a form owns. `submitted` is true when any read recorded a submission, false when every\n\t// document answered and none did, and undefined otherwise; a read that fails or runs out of time\n\t// adds nothing, because the record already holds any navigation the input started in its frame\n\t// or an ancestor.\n\tasync #readSubmissions(\n\t\tobservation: { readonly token: number; readonly frames: Set<BrowserFrameInterface> },\n\t\taction: string,\n\t\tsignal: AbortSignal,\n\t\tbound: number,\n\t): Promise<{\n\t\treadonly destinations: readonly BrowserDestination[]\n\t\treadonly prevented: boolean\n\t\treadonly submitted: boolean | undefined\n\t\treadonly implicit: boolean\n\t}> {\n\t\tconst reads = await Promise.all(\n\t\t\t[...observation.frames].map((frame) =>\n\t\t\t\tthis.#readSubmission(frame, observation, action, signal, bound),\n\t\t\t),\n\t\t)\n\t\tconst answered = reads.flatMap((read) => (read === undefined ? [] : [read]))\n\t\treturn {\n\t\t\tdestinations: answered.flatMap((read) => read.destinations),\n\t\t\tprevented: answered.some((read) => read.prevented),\n\t\t\tsubmitted: answered.some((read) => read.submitted)\n\t\t\t\t? true\n\t\t\t\t: answered.length > 0 && answered.length === reads.length\n\t\t\t\t\t? false\n\t\t\t\t\t: undefined,\n\t\t\timplicit: answered.some((read) => read.implicit),\n\t\t}\n\t}\n\n\t// Returns undefined for a read that failed, ran out of time, found no observer to read, or\n\t// answered a record whose members are not the read's types, which leaves the outcome unknown.\n\tasync #readSubmission(\n\t\tframe: BrowserFrameInterface,\n\t\tobservation: { readonly token: number; readonly frames: Set<BrowserFrameInterface> },\n\t\taction: string,\n\t\tsignal: AbortSignal,\n\t\tbound: number,\n\t): Promise<\n\t\t| {\n\t\t\t\treadonly destinations: readonly BrowserDestination[]\n\t\t\t\treadonly prevented: boolean\n\t\t\t\treadonly submitted: boolean\n\t\t\t\treadonly implicit: boolean\n\t\t }\n\t\t| undefined\n\t> {\n\t\ttry {\n\t\t\tconst read = await this.#bounded(\n\t\t\t\tframe.evaluate(compileSubmitReadExpression(observation.token), { signal }),\n\t\t\t\tbound,\n\t\t\t\taction,\n\t\t\t\tsignal,\n\t\t\t)\n\t\t\t// A read that answered removed the observer, or found none to remove.\n\t\t\tif (read !== undefined) observation.frames.delete(frame)\n\t\t\tif (!isRecord(read)) return undefined\n\t\t\tconst { destinations, prevented, submitted, implicit } = read\n\t\t\tif (\n\t\t\t\t!isArray(destinations) ||\n\t\t\t\t!destinations.every(isString) ||\n\t\t\t\t!isBoolean(prevented) ||\n\t\t\t\t!isBoolean(submitted) ||\n\t\t\t\t!isBoolean(implicit)\n\t\t\t)\n\t\t\t\treturn undefined\n\t\t\treturn {\n\t\t\t\tdestinations: destinations\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t(relationship): relationship is BrowserDestinationRelationship =>\n\t\t\t\t\t\t\trelationship === 'self' || relationship === 'parent' || relationship === 'top',\n\t\t\t\t\t)\n\t\t\t\t\t.map((relationship) => ({ frame: frame.id, relationship })),\n\t\t\t\tprevented,\n\t\t\t\tsubmitted,\n\t\t\t\timplicit,\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (signal.aborted || (isBrowserError(error) && error.code === 'BROWSER_TOOLSET_RECEIPT')) {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\t}\n\n\t// Sends the removal of every observer the action still owns, without the action's signal, and\n\t// awaits it within the receipt's remaining deadline, or `BROWSER_TOOL_CAPTURE_MS` before the receipt\n\t// started one, unless the action's signal aborts the wait with its reason. A JavaScript dialog\n\t// blocks every evaluation until it is answered, and an aborted action ends at once, so neither\n\t// waits for the removal to land. The token keeps a late removal\n\t// from touching a later action's observer, and a replaced document took its observer with it.\n\tasync #unobserve(\n\t\tobservation: { readonly token: number; readonly frames: Set<BrowserFrameInterface> },\n\t\tsignal: AbortSignal,\n\t\tdeadline?: number,\n\t): Promise<void> {\n\t\tconst frames = [...observation.frames]\n\t\tobservation.frames.clear()\n\t\tif (frames.length === 0) return\n\t\tconst removal = Promise.allSettled(\n\t\t\tframes.map((frame) =>\n\t\t\t\tframe.evaluate(compileSubmitReadExpression(observation.token), {\n\t\t\t\t\ttimeout: BROWSER_TOOL_CAPTURE_MS,\n\t\t\t\t}),\n\t\t\t),\n\t\t)\n\t\tif (signal.aborted || (this.#page !== undefined && this.#dialogs.has(this.#page))) return\n\t\tawait this.#bounded(\n\t\t\tremoval,\n\t\t\tdeadline ?? performance.now() + BROWSER_TOOL_CAPTURE_MS,\n\t\t\t'',\n\t\t\tsignal,\n\t\t).catch((error: unknown) => {\n\t\t\tif (signal.aborted) throw error\n\t\t})\n\t}\n\n\t// Settles with the step, or rejects with the receipt naming a dialog that opens on the view\n\t// first, or with the signal's reason.\n\tasync #race<T>(\n\t\tstep: Promise<T>,\n\t\taction: string,\n\t\tsignal?: AbortSignal,\n\t\tinterruptible = true,\n\t): Promise<T> {\n\t\tconst interrupt = Promise.withResolvers<never>()\n\t\tconst abort = signal === undefined ? undefined : this.#abandon.bind(this, interrupt, signal)\n\t\tif (interruptible) this.#interrupts.set(interrupt, action)\n\t\tif (abort !== undefined) signal?.addEventListener('abort', abort, { once: true })\n\t\tif (signal?.aborted === true) interrupt.reject(signal.reason)\n\t\tconst dialog = this.#page === undefined ? undefined : this.#dialogs.get(this.#page)\n\t\tif (interruptible && dialog !== undefined) this.#interrupt(dialog)\n\t\ttry {\n\t\t\treturn await Promise.race([step, interrupt.promise])\n\t\t} finally {\n\t\t\tthis.#interrupts.delete(interrupt)\n\t\t\tif (abort !== undefined) signal?.removeEventListener('abort', abort)\n\t\t}\n\t}\n\n\t#abandon(interrupt: PromiseWithResolvers<never>, signal: AbortSignal): void {\n\t\tinterrupt.reject(signal.reason)\n\t}\n\n\t#interrupt(dialog: BrowserDialogInterface): void {\n\t\tfor (const [interrupt, action] of this.#interrupts) {\n\t\t\tinterrupt.reject(\n\t\t\t\tnew BrowserError(renderBrowserReceipt({ action, dialog }), 'BROWSER_TOOLSET_RECEIPT'),\n\t\t\t)\n\t\t}\n\t}\n\n\t// Races a step against a deadline inside the dialog and abort race; the deadline's timer is\n\t// cleared whenever that race settles, whichever branch wins.\n\tasync #bounded<T>(\n\t\tstep: Promise<T>,\n\t\tdeadline: number,\n\t\taction: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<T | undefined> {\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined\n\t\tconst lapse = new Promise<undefined>((resolve) => {\n\t\t\ttimer = setTimeout(resolve, Math.max(0, deadline - performance.now()), undefined)\n\t\t})\n\t\ttry {\n\t\t\treturn await this.#race(Promise.race([step, lapse]), action, signal)\n\t\t} finally {\n\t\t\tclearTimeout(timer)\n\t\t}\n\t}\n\n\t// Captures the view a receipt carries within the receipt's deadline; a capture that fails or\n\t// runs out of time is reported in the receipt, because the action it follows already\n\t// happened. An abort or a dialog still ends the receipt.\n\tasync #capture(\n\t\taction: string,\n\t\tsignal: AbortSignal,\n\t\tdeadline = performance.now() + BROWSER_TOOL_TIMEOUT_MS,\n\t): Promise<string> {\n\t\tif (deadline - performance.now() < 1) return BROWSER_TOOL_DEADLINE_NOTE\n\t\t// The capture belongs to the receipt: settling the receipt aborts it, so no readiness wait\n\t\t// or protocol call outlives the receipt. The deadline alone ends the capture; the outline's\n\t\t// own timeout sits past it, so a capture that runs out always reports the deadline note.\n\t\t// The outline carries the caller's signal, so an abort rejects with its pending protocol\n\t\t// entry's reason.\n\t\tconst receipt = new AbortController()\n\t\tconst options = {\n\t\t\tsignal: AbortSignal.any([signal, receipt.signal]),\n\t\t\ttimeout: BROWSER_TOOL_TIMEOUT_MS,\n\t\t}\n\t\ttry {\n\t\t\tconst outline = await this.#bounded(this.#cursor.elements.outline(options), deadline, action)\n\t\t\treturn outline === undefined ? BROWSER_TOOL_DEADLINE_NOTE : outline.text\n\t\t} catch (error) {\n\t\t\tif (signal.aborted || (isBrowserError(error) && error.code === 'BROWSER_TOOLSET_RECEIPT')) {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tif (!isBrowserElementError(error) || error.context?.['reason'] !== 'GONE') {\n\t\t\t\treturn `(The view could not be read: ${isError(error) ? error.message : String(error)}; call look.)`\n\t\t\t}\n\t\t\t// A navigation replaced the document mid-capture; the outline waits for the replacing\n\t\t\t// document's readiness before it reads once more, inside the same deadline.\n\t\t\ttry {\n\t\t\t\tconst outline = await this.#bounded(\n\t\t\t\t\tthis.#cursor.elements.outline(options),\n\t\t\t\t\tdeadline,\n\t\t\t\t\taction,\n\t\t\t\t)\n\t\t\t\treturn outline === undefined ? BROWSER_TOOL_DEADLINE_NOTE : outline.text\n\t\t\t} catch (retry) {\n\t\t\t\tif (signal.aborted || (isBrowserError(retry) && retry.code === 'BROWSER_TOOLSET_RECEIPT')) {\n\t\t\t\t\tthrow retry\n\t\t\t\t}\n\t\t\t\treturn BROWSER_TOOL_CHANGED_NOTE\n\t\t\t}\n\t\t} finally {\n\t\t\treceipt.abort(new BrowserError('the receipt settled', 'BROWSER_TOOLSET_SETTLED'))\n\t\t}\n\t}\n\n\t// Returns the pending move notes as a block that leads the next result, and forgets them.\n\t#drain(): string {\n\t\tconst notes = this.#notes.splice(0)\n\t\treturn notes.length === 0 ? '' : `${notes.join(' ')}\\n\\n`\n\t}\n\n\t// A failed startup lets a later `start()` try again, unless `destroy()` ended the toolset.\n\t#forget(starting: Promise<void>): void {\n\t\tif (this.#starting === starting && this.#destroying === undefined) this.#starting = undefined\n\t}\n\n\t#live(): void {\n\t\tif (this.#destroying !== undefined) throw this.#ended()\n\t}\n\n\t#ended(): BrowserError {\n\t\treturn new BrowserError('the browser session ended', 'BROWSER_TOOLSET_ENDED')\n\t}\n\n\t#current(generation: number, source: BrowserToolSourceInterface): boolean {\n\t\treturn (\n\t\t\tgeneration === this.#generation &&\n\t\t\tthis.#destroying === undefined &&\n\t\t\tsource === this.#following\n\t\t)\n\t}\n\n\t#add(tool: ToolInterface): void {\n\t\tthis.#added.add(tool)\n\t\tthis.#tools.add(tool)\n\t}\n\n\t#withdraw(tool: ToolInterface): void {\n\t\tif (this.#tools.tool(tool.name) === tool) this.#tools.remove(tool.name)\n\t\tthis.#added.delete(tool)\n\t}\n\n\t// Advertises `dialog` while the current page has an open dialog and the manager holds no other\n\t// tool under the name.\n\t#stage(): void {\n\t\tconst staged = this.#dialogTool\n\t\tif (staged === undefined || !this.#started || this.#destroying !== undefined) return\n\t\tconst open = this.#page !== undefined && this.#dialogs.has(this.#page)\n\t\tconst held = this.#tools.tool('dialog')\n\t\tif (open && held === undefined) this.#add(staged)\n\t\telse if (!open && held === staged) this.#withdraw(staged)\n\t}\n\n\t#listen(source: BrowserToolSourceInterface | undefined): void {\n\t\tthis.#following?.emitter.off('change', this.#changeHandler)\n\t\tthis.#following = source\n\t\tsource?.emitter.on('change', this.#changeHandler)\n\t}\n\n\tasync #select(page: BrowserPageInterface, note?: string): Promise<void> {\n\t\tif (this.#destroying !== undefined) return\n\t\tthis.#page = page\n\t\tthis.#generation += 1\n\t\tif (note !== undefined) this.#notes.push(note)\n\t\tthis.#stage()\n\t\tthis.#emitter.emit('select', page)\n\t\tif (this.#source === undefined) {\n\t\t\tfor (const tool of this.#adopted.values()) this.#withdraw(tool)\n\t\t\tthis.#adopted.clear()\n\t\t}\n\t\ttry {\n\t\t\tawait this.#watch(page)\n\t\t\tif (this.#source === undefined && this.#page === page) {\n\t\t\t\tthis.#listen(page.registry)\n\t\t\t\tawait page.registry.start()\n\t\t\t}\n\t\t} catch {\n\t\t\t// A page that closes while the view moves to it refuses the subscriptions; its close\n\t\t\t// event returns the view.\n\t\t\treturn\n\t\t}\n\t\tawait this.#adopt()\n\t}\n\n\t// Re-checks the lifecycle, the generation, and the source after every synchronous emission,\n\t// because a manager or toolset listener can re-enter.\n\tasync #adopt(): Promise<void> {\n\t\tconst source = this.#following\n\t\tif (source === undefined || this.#destroying !== undefined || !this.#started) return\n\t\tthis.#generation += 1\n\t\tconst generation = this.#generation\n\t\tlet adopted: readonly ToolInterface[]\n\t\ttry {\n\t\t\tadopted = await source.adopt()\n\t\t} catch {\n\t\t\t// A source whose page closed refuses to project; the page tools of its last projection\n\t\t\t// stay until the next change or move replaces them.\n\t\t\treturn\n\t\t}\n\t\tif (!this.#current(generation, source)) return\n\t\tconst census = source.tools?.()\n\t\tconst reasons = new Map<string, BrowserToolsetReason>()\n\t\tconst kept = new Map<\n\t\t\tstring,\n\t\t\t{ readonly tool: ToolInterface; readonly parameters: Readonly<Record<string, unknown>> }\n\t\t>()\n\t\tfor (const name of (census ?? []).map((tool) => tool.name)) {\n\t\t\tconst reason = reasons.has(name) ? undefined : this.#reason(name, census)\n\t\t\tif (reason !== undefined) reasons.set(name, reason)\n\t\t}\n\t\tfor (const tool of adopted) {\n\t\t\tif (reasons.has(tool.name) || kept.has(tool.name)) continue\n\t\t\tconst parameters = deriveBrowserToolSchema(tool.parameters)\n\t\t\tconst reason =\n\t\t\t\tthis.#reason(tool.name, census) ?? (parameters === undefined ? 'schema' : undefined)\n\t\t\tif (reason !== undefined) reasons.set(tool.name, reason)\n\t\t\telse if (parameters !== undefined) kept.set(tool.name, { tool, parameters })\n\t\t}\n\t\tfor (const [name, tool] of [...this.#adopted]) {\n\t\t\tif (kept.has(name)) continue\n\t\t\tthis.#adopted.delete(name)\n\t\t\tthis.#withdraw(tool)\n\t\t\tif (!this.#current(generation, source)) return\n\t\t}\n\t\tfor (const [name, { tool, parameters }] of kept) {\n\t\t\tconst held = this.#tools.tool(name)\n\t\t\tif (held !== undefined && !this.#added.has(held)) {\n\t\t\t\treasons.set(name, 'held')\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst handler = this.#invoke.bind(this, tool, parameters !== tool.parameters)\n\t\t\tconst wrapper = createTool({\n\t\t\t\tname,\n\t\t\t\t...(tool.title === undefined ? {} : { title: tool.title }),\n\t\t\t\t...(tool.description === undefined ? {} : { description: tool.description }),\n\t\t\t\t...(tool.summary === undefined ? {} : { summary: tool.summary }),\n\t\t\t\tparameters,\n\t\t\t\tannotations: { ...tool.annotations, untrusted: true },\n\t\t\t\texecute: this.#dispatch.bind(this, name, handler, BROWSER_TOOL_CUT_FOOTER),\n\t\t\t})\n\t\t\tthis.#handlers.set(wrapper, {\n\t\t\t\thandler,\n\t\t\t\tclause: BROWSER_TOOL_CUT_FOOTER,\n\t\t\t})\n\t\t\tthis.#adopted.set(name, wrapper)\n\t\t\tthis.#add(wrapper)\n\t\t\tif (!this.#current(generation, source)) return\n\t\t\tthis.#emitter.emit('adopt', wrapper)\n\t\t\tif (!this.#current(generation, source)) return\n\t\t}\n\t\tfor (const [name, reason] of reasons) {\n\t\t\tthis.#emitter.emit('skip', name, reason)\n\t\t\tif (!this.#current(generation, source)) return\n\t\t}\n\t}\n\n\t// Decides a skip by name, then by the registration the source selects for the name: the\n\t// current page's frame, then the earlier registration.\n\t#reason(\n\t\tname: string,\n\t\tcensus: readonly BrowserTool[] | undefined,\n\t): BrowserToolsetReason | undefined {\n\t\tif (\n\t\t\tname === 'unresolved' ||\n\t\t\tBROWSER_TOOL_NAMES.some((reserved) => reserved === name) ||\n\t\t\t(this.#journeys !== undefined &&\n\t\t\t\tBROWSER_JOURNEY_TOOL_NAMES.some((reserved) => reserved === name))\n\t\t)\n\t\t\treturn 'reserved'\n\t\tconst held = this.#tools.tool(name)\n\t\tif (held !== undefined && !this.#added.has(held)) return 'held'\n\t\tif (!BROWSER_TOOL_NAME_PATTERN.test(name)) return 'pattern'\n\t\tconst registrations = census?.filter((tool) => tool.name === name) ?? []\n\t\tconst selected = registrations.find((tool) => tool.frame === this.#page?.id) ?? registrations[0]\n\t\tif (selected === undefined) return undefined\n\t\tif (deriveBrowserToolSchema(selected.schema) === undefined) return 'schema'\n\t\tif (selected.annotation.debugging === true) return 'debugging'\n\t\treturn undefined\n\t}\n\n\tasync #watch(page: BrowserPageInterface): Promise<void> {\n\t\tif (this.#watches.has(page)) return\n\t\tconst watch: BrowserToolsetWatch = {\n\t\t\tdialog: this.#handleDialog.bind(this, page),\n\t\t\tpopup: this.#handlePopup.bind(this, page),\n\t\t\tclose: this.#handleClose.bind(this, page),\n\t\t\tclosed: this.#handleClosed.bind(this, page),\n\t\t}\n\t\tthis.#watches.set(page, watch)\n\t\tpage.emitter.on('dialog', watch.dialog)\n\t\tpage.emitter.on('popup', watch.popup)\n\t\tpage.emitter.on('close', watch.close)\n\t\tawait page.subscribe('Page.javascriptDialogClosed', watch.closed)\n\t\t// A watch removed while its subscriptions were landing releases what landed after.\n\t\tif (this.#watches.get(page) !== watch) await this.#release(page, watch)\n\t}\n\n\tasync #unwatch(page: BrowserPageInterface): Promise<void> {\n\t\tconst watch = this.#watches.get(page)\n\t\tif (watch === undefined) return\n\t\tthis.#watches.delete(page)\n\t\tawait this.#release(page, watch)\n\t}\n\n\tasync #release(page: BrowserPageInterface, watch: BrowserToolsetWatch): Promise<void> {\n\t\tpage.emitter.off('dialog', watch.dialog)\n\t\tpage.emitter.off('popup', watch.popup)\n\t\tpage.emitter.off('close', watch.close)\n\t\tawait page.unsubscribe('Page.javascriptDialogClosed', watch.closed)\n\t}\n\n\tasync #teardown(): Promise<void> {\n\t\t// The journey toolset goes first, so its replay releases its hold and writes its run while\n\t\t// the emitter and the manager still stand.\n\t\tawait this.#journeys?.destroy()\n\t\tthis.#reservation?.destroy()\n\t\tthis.#generation += 1\n\t\tthis.#lifetime.abort(this.#ended())\n\t\tthis.#listen(undefined)\n\t\tfor (const tool of [...this.#added]) this.#withdraw(tool)\n\t\tthis.#tools.emitter.off('remove', this.#removeHandler)\n\t\tthis.#tools.emitter.off('clear', this.#clearHandler)\n\t\tawait Promise.all([...this.#watches.keys()].map((page) => this.#unwatch(page)))\n\t\tthis.#dialogs.clear()\n\t\tthis.#adopted.clear()\n\t\tthis.#reading = undefined\n\t\tthis.#emitter.destroy()\n\t\tawait this.#owned?.()\n\t}\n\n\t#handleChange(): void {\n\t\tvoid this.#adopt()\n\t}\n\n\t#handleRemove(tool: ToolInterface): void {\n\t\tthis.#added.delete(tool)\n\t\tif (this.#adopted.get(tool.name) === tool) this.#adopted.delete(tool.name)\n\t}\n\n\t#handleClear(tools: readonly ToolInterface[]): void {\n\t\tfor (const tool of tools) this.#handleRemove(tool)\n\t}\n\n\t#handleDialog(page: BrowserPageInterface, dialog: BrowserDialogInterface): void {\n\t\tif (this.#navigating === page && dialog.category === 'beforeunload') {\n\t\t\t// `navigate` leaves the page at the model's request, so it answers the leave prompt; a\n\t\t\t// failed answer stages the dialog like any other.\n\t\t\tvoid dialog.accept().catch(this.#record.bind(this, page, dialog))\n\t\t\treturn\n\t\t}\n\t\tthis.#record(page, dialog)\n\t}\n\n\t#record(page: BrowserPageInterface, dialog: BrowserDialogInterface): void {\n\t\tthis.#dialogs.set(page, dialog)\n\t\tif (page !== this.#page) return\n\t\tthis.#stage()\n\t\tthis.#interrupt(dialog)\n\t}\n\n\t#handleClosed(page: BrowserPageInterface): void {\n\t\tthis.#dialogs.delete(page)\n\t\tif (page === this.#page) this.#stage()\n\t}\n\n\t// Follows a popup opened outside an action; one announced during an action that holds a popup\n\t// record waits for that action, and once the view moved to it, its opener is no longer the view.\n\t#handlePopup(opener: BrowserPageInterface, popup: BrowserPageInterface): void {\n\t\tif (opener !== this.#page || popup.closed) return\n\t\tif (this.#arrivals !== undefined) {\n\t\t\tthis.#arrivals = [...this.#arrivals, [opener, popup]]\n\t\t\treturn\n\t\t}\n\t\tvoid this.#select(popup, `The view moved to a new tab: ${popup.url}.`)\n\t}\n\n\t#handleClose(page: BrowserPageInterface): void {\n\t\tvoid this.#unwatch(page)\n\t\tthis.#dialogs.delete(page)\n\t\tconst origin = this.#origin\n\t\tif (page !== this.#page || origin === undefined || page === origin) return\n\t\tconst opener = page.opener\n\t\tconst target = opener !== undefined && !opener.closed ? opener : origin\n\t\tvoid this.#select(target, `The tab ${page.url} closed; the view returned to ${target.url}.`)\n\t}\n}\n"],"mappings":";;;;;;;;AAmBA,IAAa,eAAe;;AAG5B,IAAa,gBAAkD,OAAO,OAAO;CAC5E,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACN,CAAC;;;;;AAQD,IAAa,6BAA6B;;;;;;;;;;;;;;;;;;;;AAqB1C,IAAa,uBAAuB;;;;;;;;;;;AA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