@ai-agent-forge/agent-forge 0.88.5 → 0.88.7

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.
Files changed (202) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/bundled-plugins/agent-loop-policy/agent-forge.json +1 -1
  3. package/bundled-plugins/agent-loop-policy/plugin.json +1 -1
  4. package/bundled-plugins/alignment/agent-forge.json +19 -0
  5. package/bundled-plugins/alignment/dist/baseline.d.ts +12 -0
  6. package/bundled-plugins/alignment/dist/baseline.d.ts.map +1 -0
  7. package/bundled-plugins/alignment/dist/baseline.js +68 -0
  8. package/bundled-plugins/alignment/dist/baseline.js.map +1 -0
  9. package/bundled-plugins/alignment/dist/engine.d.ts +102 -0
  10. package/bundled-plugins/alignment/dist/engine.d.ts.map +1 -0
  11. package/bundled-plugins/alignment/dist/engine.js +654 -0
  12. package/bundled-plugins/alignment/dist/engine.js.map +1 -0
  13. package/bundled-plugins/alignment/dist/entry.d.ts +14 -0
  14. package/bundled-plugins/alignment/dist/entry.d.ts.map +1 -0
  15. package/bundled-plugins/alignment/dist/entry.js +23 -0
  16. package/bundled-plugins/alignment/dist/entry.js.map +1 -0
  17. package/bundled-plugins/alignment/dist/export.d.ts +15 -0
  18. package/bundled-plugins/alignment/dist/export.d.ts.map +1 -0
  19. package/bundled-plugins/alignment/dist/export.js +122 -0
  20. package/bundled-plugins/alignment/dist/export.js.map +1 -0
  21. package/bundled-plugins/alignment/dist/http-server.d.ts +33 -0
  22. package/bundled-plugins/alignment/dist/http-server.d.ts.map +1 -0
  23. package/bundled-plugins/alignment/dist/http-server.js +119 -0
  24. package/bundled-plugins/alignment/dist/http-server.js.map +1 -0
  25. package/bundled-plugins/alignment/dist/index.d.ts +24 -0
  26. package/bundled-plugins/alignment/dist/index.d.ts.map +1 -0
  27. package/bundled-plugins/alignment/dist/index.js +719 -0
  28. package/bundled-plugins/alignment/dist/index.js.map +1 -0
  29. package/bundled-plugins/alignment/dist/page.d.ts +15 -0
  30. package/bundled-plugins/alignment/dist/page.d.ts.map +1 -0
  31. package/bundled-plugins/alignment/dist/page.js +857 -0
  32. package/bundled-plugins/alignment/dist/page.js.map +1 -0
  33. package/bundled-plugins/alignment/dist/render.d.ts +40 -0
  34. package/bundled-plugins/alignment/dist/render.d.ts.map +1 -0
  35. package/bundled-plugins/alignment/dist/render.js +194 -0
  36. package/bundled-plugins/alignment/dist/render.js.map +1 -0
  37. package/bundled-plugins/alignment/dist/types.d.ts +217 -0
  38. package/bundled-plugins/alignment/dist/types.d.ts.map +1 -0
  39. package/bundled-plugins/alignment/dist/types.js +30 -0
  40. package/bundled-plugins/alignment/dist/types.js.map +1 -0
  41. package/bundled-plugins/alignment/plugin.json +12 -0
  42. package/bundled-plugins/browser-playwright/MANUAL.md +60 -0
  43. package/bundled-plugins/browser-playwright/agent-forge.json +25 -0
  44. package/bundled-plugins/browser-playwright/dist/capability.d.ts +25 -0
  45. package/bundled-plugins/browser-playwright/dist/capability.d.ts.map +1 -0
  46. package/bundled-plugins/browser-playwright/dist/capability.js +612 -0
  47. package/bundled-plugins/browser-playwright/dist/capability.js.map +1 -0
  48. package/bundled-plugins/browser-playwright/dist/entry.d.ts +13 -0
  49. package/bundled-plugins/browser-playwright/dist/entry.d.ts.map +1 -0
  50. package/bundled-plugins/browser-playwright/dist/entry.js +14 -0
  51. package/bundled-plugins/browser-playwright/dist/entry.js.map +1 -0
  52. package/bundled-plugins/browser-playwright/dist/index.d.ts +7 -0
  53. package/bundled-plugins/browser-playwright/dist/index.d.ts.map +1 -0
  54. package/bundled-plugins/browser-playwright/dist/index.js +5 -0
  55. package/bundled-plugins/browser-playwright/dist/index.js.map +1 -0
  56. package/bundled-plugins/browser-playwright/dist/operations.d.ts +69 -0
  57. package/bundled-plugins/browser-playwright/dist/operations.d.ts.map +1 -0
  58. package/bundled-plugins/browser-playwright/dist/operations.js +149 -0
  59. package/bundled-plugins/browser-playwright/dist/operations.js.map +1 -0
  60. package/bundled-plugins/browser-playwright/dist/playwright-driver.d.ts +275 -0
  61. package/bundled-plugins/browser-playwright/dist/playwright-driver.d.ts.map +1 -0
  62. package/bundled-plugins/browser-playwright/dist/playwright-driver.js +953 -0
  63. package/bundled-plugins/browser-playwright/dist/playwright-driver.js.map +1 -0
  64. package/bundled-plugins/browser-playwright/dist/setup.d.ts +88 -0
  65. package/bundled-plugins/browser-playwright/dist/setup.d.ts.map +1 -0
  66. package/bundled-plugins/browser-playwright/dist/setup.js +252 -0
  67. package/bundled-plugins/browser-playwright/dist/setup.js.map +1 -0
  68. package/bundled-plugins/browser-playwright/dist/types.d.ts +270 -0
  69. package/bundled-plugins/browser-playwright/dist/types.d.ts.map +1 -0
  70. package/bundled-plugins/browser-playwright/dist/types.js +2 -0
  71. package/bundled-plugins/browser-playwright/dist/types.js.map +1 -0
  72. package/bundled-plugins/browser-playwright/plugin.json +20 -0
  73. package/bundled-plugins/coding-tools/agent-forge.json +1 -1
  74. package/bundled-plugins/coding-tools/dist/bash.d.ts +2 -7
  75. package/bundled-plugins/coding-tools/dist/bash.d.ts.map +1 -1
  76. package/bundled-plugins/coding-tools/dist/bash.js +2 -34
  77. package/bundled-plugins/coding-tools/dist/bash.js.map +1 -1
  78. package/bundled-plugins/coding-tools/dist/read.d.ts +2 -0
  79. package/bundled-plugins/coding-tools/dist/read.d.ts.map +1 -1
  80. package/bundled-plugins/coding-tools/dist/read.js +11 -0
  81. package/bundled-plugins/coding-tools/dist/read.js.map +1 -1
  82. package/bundled-plugins/coding-tools/plugin.json +1 -1
  83. package/bundled-plugins/compaction-policy/agent-forge.json +1 -1
  84. package/bundled-plugins/compaction-policy/plugin.json +1 -1
  85. package/bundled-plugins/mcp-http/dist/mcp-http.d.ts.map +1 -1
  86. package/bundled-plugins/mcp-http/dist/mcp-http.js +84 -31
  87. package/bundled-plugins/mcp-http/dist/mcp-http.js.map +1 -1
  88. package/bundled-plugins/overflow-policy/agent-forge.json +1 -1
  89. package/bundled-plugins/overflow-policy/plugin.json +1 -1
  90. package/bundled-plugins/provider-failover/agent-forge.json +1 -1
  91. package/bundled-plugins/provider-failover/plugin.json +1 -1
  92. package/bundled-plugins/retry-policy/agent-forge.json +1 -1
  93. package/bundled-plugins/retry-policy/plugin.json +1 -1
  94. package/dist/bundle/.build-manifest.json +60 -58
  95. package/dist/bundle/chunks/{anthropic-messages-3FJHRAJL.js → anthropic-messages-NL4Y6WPB.js} +1 -1
  96. package/dist/bundle/chunks/{azure-openai-responses-GCL47IDS.js → azure-openai-responses-CPXC42HO.js} +1 -1
  97. package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
  98. package/dist/bundle/chunks/chunk-5LRQFZFE.js +2 -0
  99. package/dist/bundle/chunks/{chunk-HTEVUY7F.js → chunk-7HSJPQKN.js} +1 -1
  100. package/dist/bundle/chunks/{chunk-AC2FIS4G.js → chunk-EDO7Q6XR.js} +1 -1
  101. package/dist/bundle/chunks/{chunk-755VNWIF.js → chunk-ISLHFRER.js} +6 -6
  102. package/dist/bundle/chunks/{chunk-HV64ASMT.js → chunk-K3S6GTL7.js} +1 -1
  103. package/dist/bundle/chunks/{chunk-HEL6TAWE.js → chunk-L2SXIPI5.js} +37 -36
  104. package/dist/bundle/chunks/{chunk-V3ACW7VD.js → chunk-WJSKB3FC.js} +1 -1
  105. package/dist/bundle/chunks/{chunk-32YDZI4J.js → chunk-ZS5JEI76.js} +1 -1
  106. package/dist/bundle/chunks/{google-generative-ai-6BMXWA44.js → google-generative-ai-UMZ53EFA.js} +1 -1
  107. package/dist/bundle/chunks/{google-vertex-6H7NLRTK.js → google-vertex-ZNR5NS6H.js} +1 -1
  108. package/dist/bundle/chunks/image-resize-worker.js +1 -1
  109. package/dist/bundle/chunks/{mistral-conversations-IXUHSFSJ.js → mistral-conversations-IT66WUNN.js} +1 -1
  110. package/dist/bundle/chunks/{openai-codex-responses-YHUAEVCM.js → openai-codex-responses-FOVCVG6I.js} +1 -1
  111. package/dist/bundle/chunks/{openai-completions-ULQCFC72.js → openai-completions-FLQ7CBOL.js} +1 -1
  112. package/dist/bundle/chunks/{openai-responses-NLLAJDPS.js → openai-responses-ABGYHS2T.js} +1 -1
  113. package/dist/bundle/chunks/{pi-messages-EJTI2EJ3.js → pi-messages-6K5W6LUN.js} +1 -1
  114. package/dist/bundle/chunks/{virtual-modules-TQWEGNNZ.js → virtual-modules-2QGILFV7.js} +1 -1
  115. package/dist/bundle/cli.js +1 -1
  116. package/dist/bundle/client.js +1 -1
  117. package/dist/bundle/index.js +1 -1
  118. package/dist/bundle/rpc-entry.js +1 -1
  119. package/dist/client/remote-session.d.ts.map +1 -1
  120. package/dist/client/remote-session.js +65 -6
  121. package/dist/client/remote-session.js.map +1 -1
  122. package/dist/core/agent-session-store.d.ts.map +1 -1
  123. package/dist/core/agent-session-store.js +20 -3
  124. package/dist/core/agent-session-store.js.map +1 -1
  125. package/dist/core/extensions/agent-composition.d.ts.map +1 -1
  126. package/dist/core/extensions/agent-composition.js +20 -1
  127. package/dist/core/extensions/agent-composition.js.map +1 -1
  128. package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -1
  129. package/dist/core/i18n/locales/zh-cn/core-errors.js +1 -0
  130. package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -1
  131. package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -1
  132. package/dist/core/i18n/locales/zh-cn/interactive-mode.js +10 -3
  133. package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -1
  134. package/dist/core/keybindings.d.ts +35 -0
  135. package/dist/core/keybindings.d.ts.map +1 -1
  136. package/dist/core/keybindings.js +34 -0
  137. package/dist/core/keybindings.js.map +1 -1
  138. package/dist/core/sdk.d.ts.map +1 -1
  139. package/dist/core/sdk.js +62 -15
  140. package/dist/core/sdk.js.map +1 -1
  141. package/dist/core/session-manager.d.ts.map +1 -1
  142. package/dist/core/session-manager.js +11 -3
  143. package/dist/core/session-manager.js.map +1 -1
  144. package/dist/core/system-prompt.d.ts.map +1 -1
  145. package/dist/core/system-prompt.js +2 -2
  146. package/dist/core/system-prompt.js.map +1 -1
  147. package/dist/core/tools/capability-mount.d.ts.map +1 -1
  148. package/dist/core/tools/capability-mount.js +4 -21
  149. package/dist/core/tools/capability-mount.js.map +1 -1
  150. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  151. package/dist/modes/interactive/components/assistant-message.js +2 -2
  152. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  153. package/dist/modes/interactive/components/bash-execution.d.ts +2 -0
  154. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  155. package/dist/modes/interactive/components/bash-execution.js +25 -0
  156. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  157. package/dist/modes/interactive/components/changelog-pager.d.ts +53 -0
  158. package/dist/modes/interactive/components/changelog-pager.d.ts.map +1 -0
  159. package/dist/modes/interactive/components/changelog-pager.js +239 -0
  160. package/dist/modes/interactive/components/changelog-pager.js.map +1 -0
  161. package/dist/modes/interactive/components/tool-execution.d.ts +6 -0
  162. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  163. package/dist/modes/interactive/components/tool-execution.js +12 -0
  164. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  165. package/dist/modes/interactive/components/tool-run-group.d.ts +41 -11
  166. package/dist/modes/interactive/components/tool-run-group.d.ts.map +1 -1
  167. package/dist/modes/interactive/components/tool-run-group.js +126 -14
  168. package/dist/modes/interactive/components/tool-run-group.js.map +1 -1
  169. package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
  170. package/dist/modes/interactive/interactive-commands.js +23 -13
  171. package/dist/modes/interactive/interactive-commands.js.map +1 -1
  172. package/dist/modes/interactive/interactive-events.d.ts +14 -4
  173. package/dist/modes/interactive/interactive-events.d.ts.map +1 -1
  174. package/dist/modes/interactive/interactive-events.js +94 -12
  175. package/dist/modes/interactive/interactive-events.js.map +1 -1
  176. package/dist/modes/interactive/interactive-mode.d.ts +6 -1
  177. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  178. package/dist/modes/interactive/interactive-mode.js +21 -5
  179. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  180. package/dist/plugins/ecosystem/node-local-package-source.d.ts +2 -1
  181. package/dist/plugins/ecosystem/node-local-package-source.d.ts.map +1 -1
  182. package/dist/plugins/ecosystem/node-local-package-source.js +110 -4
  183. package/dist/plugins/ecosystem/node-local-package-source.js.map +1 -1
  184. package/dist/plugins/ecosystem/node-package-install-host.d.ts.map +1 -1
  185. package/dist/plugins/ecosystem/node-package-install-host.js +106 -39
  186. package/dist/plugins/ecosystem/node-package-install-host.js.map +1 -1
  187. package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
  188. package/dist/plugins/ecosystem/node-plugin-bootstrap.js +85 -2
  189. package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
  190. package/dist/suites/builtin-suites.d.ts.map +1 -1
  191. package/dist/suites/builtin-suites.js +2 -2
  192. package/dist/suites/builtin-suites.js.map +1 -1
  193. package/dist/utils/changelog.d.ts +27 -0
  194. package/dist/utils/changelog.d.ts.map +1 -1
  195. package/dist/utils/changelog.js +110 -0
  196. package/dist/utils/changelog.js.map +1 -1
  197. package/docs/keybindings.md +14 -0
  198. package/examples/extensions/with-deps/package-lock.json +2 -2
  199. package/examples/extensions/with-deps/package.json +1 -1
  200. package/examples/extensions/with-deps/plugin.json +1 -1
  201. package/package.json +1 -1
  202. package/dist/bundle/chunks/chunk-A3JYRWB6.js +0 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright-driver.js","sourceRoot":"","sources":["../src/playwright-driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACN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ver for the browser capability.\n *\n * Playwright is resolved lazily at connect time through\n * `createRequire(<browser-deps>/package.json)` — the deliberate optional-heavy\n * dependency load point; this package never imports Playwright types, so the\n * surface used here is declared structurally below. A missing module throws\n * the structured guidance message (exact install commands plus the\n * `browser_setup` hint), which the capability layer surfaces verbatim.\n *\n * Bounded results: aria snapshots are capped at 16KiB, DOM captures and all\n * JSON payloads (console/network entries, performance metrics, evaluate\n * results, storage/tab/viewport state) at 64KiB, screenshots at 4MiB of PNG\n * bytes. Styles capture is declared `not_supported_in_this_build` (parameter\n * stays accepted for contract compatibility). Console and network evidence\n * come from 200-entry ring buffers attached to every opened page.\n *\n * Built-in policies (no dedicated tools): `dialog` events are auto-accepted\n * and logged into the console ring as a `[dialog]` entry; `download` events\n * are saved into `<agentDir>/browser-deps/downloads/` and the most recent\n * download filename is attached to snapshot results.\n */\nimport { mkdirSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\nimport {\n\tbuildPluginResultV1,\n\ttype EvidenceKindV1,\n\ttype EvidenceRefV1,\n\ttype PluginResultV1,\n} from \"@agent-forge/plugin-sdk\";\nimport {\n\tBROWSER_DEFAULT_EVALUATE_TIMEOUT_MS_V1,\n\tclampDragStepsV1,\n\tclampViewportDimensionV1,\n\tclampWaitMsV1,\n\tfilterConsoleEntriesV1,\n\tfilterNetworkEntriesV1,\n\tparseScrollDirectiveV1,\n\tparseUploadPathsV1,\n\tscrollWheelDeltaV1,\n\tserializeJsonPayloadV1,\n\tshapePerformanceV1,\n\twaitMissingInput,\n} from \"./operations.ts\";\nimport {\n\tBROWSER_BROWSERS_DIR_NAME_V1,\n\ttype BrowserSetupOptionsV1,\n\tboundedPreviewV1,\n\tbrowserDepsDirFor,\n\tinstallGuidanceMessage,\n\tresolvePlaywrightModule,\n\tsetupBrowserDepsPlaywrightV1,\n} from \"./setup.ts\";\nimport type {\n\tBrowserConsoleEntryV1,\n\tBrowserConsoleReadInputV1,\n\tBrowserDragInputV1,\n\tBrowserDriverV1,\n\tBrowserEvaluateInputV1,\n\tBrowserEvidenceKindV1,\n\tBrowserLocatorActionInputV1,\n\tBrowserLocatorV1,\n\tBrowserMouseInputV1,\n\tBrowserNavigateInputV1,\n\tBrowserNetworkEntryV1,\n\tBrowserNetworkReadInputV1,\n\tBrowserOperationOptionsV1,\n\tBrowserPerformanceRawV1,\n\tBrowserPostconditionV1,\n\tBrowserPressKeyInputV1,\n\tBrowserRuntimeV1,\n\tBrowserSetupOutcomeV1,\n\tBrowserSnapshotInputV1,\n\tBrowserStorageInputV1,\n\tBrowserTabsInputV1,\n\tBrowserViewportInputV1,\n\tBrowserWaitInputV1,\n} from \"./types.ts\";\n\nexport const BROWSER_MAX_SNAPSHOT_CHARS_V1 = 16 * 1024;\nexport const BROWSER_MAX_DOM_CHARS_V1 = 64 * 1024;\nexport const BROWSER_MAX_EVIDENCE_CHARS_V1 = 64 * 1024;\nexport const BROWSER_MAX_SCREENSHOT_BYTES_V1 = 4 * 1024 * 1024;\nexport const BROWSER_RING_BUFFER_SIZE_V1 = 200;\nexport const BROWSER_DOWNLOADS_DIR_NAME_V1 = \"downloads\";\nconst BROWSER_CONDITION_LABEL_CHARS_V1 = 256;\n\n/** Minimal structural surface of the lazily required `playwright` module. */\nexport interface PlaywrightLocatorLike {\n\tclick(options?: { readonly button?: \"left\" | \"right\" | \"middle\"; readonly timeout?: number }): Promise<void>;\n\tdblclick(options?: { readonly timeout?: number }): Promise<void>;\n\tfill(value: string, options?: { readonly timeout?: number }): Promise<void>;\n\ttype(text: string, options?: { readonly delay?: number; readonly timeout?: number }): Promise<void>;\n\tpress(key: string, options?: { readonly timeout?: number }): Promise<void>;\n\thover(options?: { readonly timeout?: number }): Promise<void>;\n\tselectOption(value: string, options?: { readonly timeout?: number }): Promise<void>;\n\tcheck(options?: { readonly timeout?: number }): Promise<void>;\n\tuncheck(options?: { readonly timeout?: number }): Promise<void>;\n\tclear(options?: { readonly timeout?: number }): Promise<void>;\n\tsetInputFiles(files: readonly string[], options?: { readonly timeout?: number }): Promise<void>;\n\tscrollIntoViewIfNeeded(options?: { readonly timeout?: number }): Promise<void>;\n\twaitFor(options: { readonly state: \"visible\" | \"hidden\"; readonly timeout?: number }): Promise<void>;\n\tboundingBox(): Promise<{\n\t\treadonly x: number;\n\t\treadonly y: number;\n\t\treadonly width: number;\n\t\treadonly height: number;\n\t} | null>;\n\tisVisible(): Promise<boolean>;\n\tisHidden(): Promise<boolean>;\n\tinputValue(options?: { readonly timeout?: number }): Promise<string>;\n\ttextContent(options?: { readonly timeout?: number }): Promise<string | null>;\n\tariaSnapshot(options?: { readonly timeout?: number }): Promise<string>;\n}\n\nexport interface PlaywrightConsoleMessageLike {\n\ttype(): string;\n\ttext(): string;\n\tlocation(): { readonly url: string; readonly lineNumber: number; readonly columnNumber: number };\n}\n\nexport interface PlaywrightRequestLike {\n\tmethod(): string;\n\ttiming(): { readonly startTime: number; readonly responseEnd: number };\n}\n\nexport interface PlaywrightResponseLike {\n\turl(): string;\n\tstatus(): number;\n\theaders(): Record<string, string>;\n\trequest(): PlaywrightRequestLike;\n}\n\nexport interface PlaywrightDialogLike {\n\ttype(): string;\n\tmessage(): string;\n\taccept(text?: string): Promise<void>;\n}\n\nexport interface PlaywrightDownloadLike {\n\tsuggestedFilename(): string;\n\tsaveAs(path: string): Promise<void>;\n}\n\nexport interface PlaywrightMouseLike {\n\tmove(x: number, y: number, options?: { readonly steps?: number }): Promise<void>;\n\tdown(options?: { readonly button?: \"left\" | \"right\" | \"middle\" }): Promise<void>;\n\tup(options?: { readonly button?: \"left\" | \"right\" | \"middle\" }): Promise<void>;\n\tclick(\n\t\tx: number,\n\t\ty: number,\n\t\toptions?: { readonly button?: \"left\" | \"right\" | \"middle\"; readonly clickCount?: number },\n\t): Promise<void>;\n\tdblclick(x: number, y: number, options?: { readonly button?: \"left\" | \"right\" | \"middle\" }): Promise<void>;\n\twheel(deltaX: number, deltaY: number): Promise<void>;\n}\n\nexport interface PlaywrightKeyboardLike {\n\tpress(key: string, options?: { readonly delay?: number }): Promise<void>;\n}\n\nexport interface PlaywrightPageLike {\n\turl(): string;\n\tgoto(\n\t\turl: string,\n\t\toptions?: {\n\t\t\treadonly waitUntil?: \"commit\" | \"domcontentloaded\" | \"load\" | \"networkidle\";\n\t\t\treadonly timeout?: number;\n\t\t},\n\t): Promise<unknown>;\n\tcontent(): Promise<string>;\n\tscreenshot(options?: { readonly type: \"png\" }): Promise<Buffer>;\n\ttitle(): Promise<string>;\n\tclose(options?: { readonly runBeforeUnload?: boolean }): Promise<void>;\n\t/**\n\t * Internal scripts are passed as function objects (real Playwright invokes\n\t * them with `arg`); plain-string evaluation is only reliable for\n\t * user-supplied expressions, where a `() => ...` string is NOT invoked.\n\t */\n\tevaluate<T = unknown>(script: string | ((arg: never) => unknown), arg?: unknown): Promise<T>;\n\twaitForLoadState(\n\t\tstate: \"load\" | \"domcontentloaded\" | \"networkidle\",\n\t\toptions?: { readonly timeout?: number },\n\t): Promise<void>;\n\tsetViewportSize(viewport: { readonly width: number; readonly height: number }): Promise<void>;\n\tviewportSize(): { readonly width: number; readonly height: number } | null;\n\tlocator(selector: string): PlaywrightLocatorLike;\n\tgetByRole(role: string, options?: { readonly name?: string }): PlaywrightLocatorLike;\n\tgetByText(text: string): PlaywrightLocatorLike;\n\tgetByTestId(testId: string): PlaywrightLocatorLike;\n\treadonly mouse: PlaywrightMouseLike;\n\treadonly keyboard: PlaywrightKeyboardLike;\n\ton(event: \"console\", listener: (message: PlaywrightConsoleMessageLike) => void): void;\n\ton(event: \"response\", listener: (response: PlaywrightResponseLike) => void): void;\n\ton(event: \"dialog\", listener: (dialog: PlaywrightDialogLike) => void): void;\n\ton(event: \"download\", listener: (download: PlaywrightDownloadLike) => void): void;\n}\n\nexport interface PlaywrightCookieLike {\n\treadonly name: string;\n\treadonly value: string;\n\treadonly domain: string;\n\treadonly path: string;\n\treadonly expires: number;\n\treadonly httpOnly: boolean;\n\treadonly secure: boolean;\n\treadonly sameSite: string;\n}\n\nexport interface PlaywrightCookieParamV1 {\n\treadonly name: string;\n\treadonly value: string;\n\treadonly domain?: string;\n\treadonly path?: string;\n\treadonly expires?: number;\n}\n\nexport interface PlaywrightContextLike {\n\tnewPage(): Promise<PlaywrightPageLike>;\n\tcookies(urls?: readonly string[]): Promise<readonly PlaywrightCookieLike[]>;\n\taddCookies(cookies: readonly PlaywrightCookieParamV1[]): Promise<void>;\n\tclearCookies(): Promise<void>;\n}\n\nexport interface PlaywrightBrowserLike {\n\tnewContext(): Promise<PlaywrightContextLike>;\n\tclose(): Promise<void>;\n}\n\nexport interface PlaywrightModuleLike {\n\tchromium: {\n\t\tlaunch(options?: { readonly headless?: boolean }): Promise<PlaywrightBrowserLike>;\n\t};\n}\n\nexport interface PlaywrightDriverOptionsV1 {\n\t/** Host agent directory; the default deps dir is `<agentDir>/browser-deps`. */\n\treadonly agentDir?: string;\n\t/** Direct override of the resolution directory; wins over `agentDir`. */\n\treadonly browserDepsDir?: string;\n\treadonly headless?: boolean;\n\t/** Deterministic seam for the module probe (tests; production uses createRequire). */\n\treadonly resolvePlaywright?: (browserDepsDir: string) => string | undefined;\n\t/**\n\t * Deterministic seam replacing the createRequire lazy load (tests and\n\t * brokered hosts). Production leaves it undefined so the module resolves\n\t * from `<browser-deps>` at connect time.\n\t */\n\treadonly loadPlaywright?: () => PlaywrightModuleLike;\n\t/** Deterministic seam for download-directory creation (tests inject a no-op). */\n\treadonly ensureDir?: (dir: string) => void;\n}\n\nconst placeholder = (text: string): string => (text.trim() === \"\" ? \"(empty)\" : text);\n\nconst sanitizeUrlV1 = (value: string): string => {\n\ttry {\n\t\tconst parsed = new URL(value);\n\t\treturn `${parsed.origin}${parsed.pathname.slice(0, 512)}`;\n\t} catch {\n\t\treturn value.slice(0, 512);\n\t}\n};\n\nconst conditionLabel = (condition: BrowserPostconditionV1, index: number): string => {\n\tconst raw =\n\t\tcondition.kind === \"url\"\n\t\t\t? `url ${condition.equals !== undefined ? `equals ${JSON.stringify(condition.equals)}` : \"\"}${condition.contains !== undefined ? ` contains ${JSON.stringify(condition.contains)}` : \"\"}`\n\t\t\t: condition.kind === \"element\"\n\t\t\t\t? `element ${condition.locator.kind}=${JSON.stringify(condition.locator.value)} state ${condition.state}`\n\t\t\t\t: condition.kind === \"text\"\n\t\t\t\t\t? `text contains ${JSON.stringify(condition.contains)}`\n\t\t\t\t\t: condition.kind === \"console\"\n\t\t\t\t\t\t? `console contains ${JSON.stringify(condition.contains)}`\n\t\t\t\t\t\t: `network containsUrl ${JSON.stringify(condition.containsUrl)}`;\n\treturn `${index + 1}: ${raw.trim()}`.slice(0, BROWSER_CONDITION_LABEL_CHARS_V1);\n};\n\nconst locatorLabel = (locator: BrowserLocatorV1): string =>\n\t`${locator.kind}=${locator.value.slice(0, 64)}${locator.name === undefined ? \"\" : ` name=${locator.name.slice(0, 64)}`}`;\n\n/**\n * Page-side globals referenced by the in-page evaluate scripts below. These\n * module-scoped declarations exist only so the scripts typecheck (the\n * Node-side tsconfig has no DOM lib); Playwright stringifies the functions\n * and runs them in the browser, where the real globals are present.\n */\ntype PagePerformanceEntryV1 = {\n\treadonly name: string;\n\treadonly startTime: number;\n\treadonly duration: number;\n\treadonly responseStart: number;\n\treadonly domContentLoadedEventEnd: number;\n\treadonly loadEventEnd: number;\n\treadonly transferSize: number;\n};\ntype PageLocalStorageV1 = {\n\tgetItem(key: string): string | null;\n\tsetItem(key: string, value: string): void;\n\tclear(): void;\n};\ndeclare const document: { getElementsByTagName(tag: string): ArrayLike<unknown> };\ndeclare const window: { localStorage: PageLocalStorageV1 };\n\n/**\n * In-page performance collection evaluated through `page.evaluate`. Must stay a\n * closure-free function object: real Playwright stringifies it and runs it in\n * the page. Passing an equivalent `() => {...}` *string* is silently wrong —\n * real Playwright evaluates the string, serializes the resulting function\n * object, and yields `undefined` on the Node side.\n */\nconst collectPerformanceInPage = (): BrowserPerformanceRawV1 => {\n\tconst entries = (type: string): PagePerformanceEntryV1[] =>\n\t\t(performance as unknown as { getEntriesByType(type: string): PagePerformanceEntryV1[] }).getEntriesByType(type);\n\tconst nav = entries(\"navigation\")[0] ?? null;\n\tconst paints = entries(\"paint\").map((entry) => ({ name: String(entry.name), startTimeMs: entry.startTime }));\n\tconst resources = entries(\"resource\").map((entry) => ({\n\t\turl: String(entry.name),\n\t\tdurationMs: entry.duration,\n\t\ttransferBytes: entry.transferSize,\n\t}));\n\treturn {\n\t\tnavigation:\n\t\t\tnav === null\n\t\t\t\t? null\n\t\t\t\t: {\n\t\t\t\t\t\tttfbMs: nav.responseStart - nav.startTime,\n\t\t\t\t\t\tdomContentLoadedMs: nav.domContentLoadedEventEnd - nav.startTime,\n\t\t\t\t\t\tloadMs: nav.loadEventEnd - nav.startTime,\n\t\t\t\t\t},\n\t\tpaints,\n\t\tresources,\n\t\tdomNodes: document.getElementsByTagName(\"*\").length,\n\t};\n};\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\n/**\n * `page.evaluate` with a wall-clock escape: Playwright itself cannot cancel a\n * hung script, so the race rejects after `timeoutMs` and leaves the page-side\n * evaluation to finish on its own.\n */\nasync function evaluateWithTimeout<T>(\n\tpage: PlaywrightPageLike,\n\texpression: string,\n\targ: unknown,\n\ttimeoutMs: number,\n): Promise<T> {\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tconst timeout = new Promise<never>((_, reject) => {\n\t\ttimer = setTimeout(() => reject(new Error(`browser_evaluate timed out after ${timeoutMs}ms`)), timeoutMs);\n\t\ttimer.unref?.();\n\t});\n\ttry {\n\t\treturn await Promise.race([page.evaluate<T>(expression, arg), timeout]);\n\t} finally {\n\t\tif (timer !== undefined) clearTimeout(timer);\n\t}\n}\n\nconst isTimeoutError = (error: unknown): error is Error => error instanceof Error && error.name === \"TimeoutError\";\n\nexport class PlaywrightBrowserDriver implements BrowserDriverV1 {\n\tprivate readonly depsDir: string;\n\tprivate readonly headless: boolean;\n\tprivate readonly resolveModule: (browserDepsDir: string) => string | undefined;\n\tprivate readonly loadPlaywright: (() => PlaywrightModuleLike) | undefined;\n\tprivate readonly ensureDir: (dir: string) => void;\n\tprivate browser: PlaywrightBrowserLike | undefined;\n\tprivate context: PlaywrightContextLike | undefined;\n\tprivate page: PlaywrightPageLike | undefined;\n\tprivate pages: PlaywrightPageLike[] = [];\n\tprivate pageIndex = 0;\n\tprivate consoleRing: BrowserConsoleEntryV1[] = [];\n\tprivate networkRing: BrowserNetworkEntryV1[] = [];\n\tprivate lastDownload: string | undefined;\n\n\tconstructor(options: PlaywrightDriverOptionsV1 = {}) {\n\t\tthis.depsDir =\n\t\t\toptions.browserDepsDir ?? (options.agentDir === undefined ? \"\" : browserDepsDirFor(options.agentDir));\n\t\tthis.headless = options.headless ?? true;\n\t\tthis.resolveModule = options.resolvePlaywright ?? resolvePlaywrightModule;\n\t\tthis.loadPlaywright = options.loadPlaywright;\n\t\tthis.ensureDir = options.ensureDir ?? ((dir: string) => mkdirSync(dir, { recursive: true }));\n\t}\n\n\t/** Resolves Playwright, launches Chromium, and opens the context. Idempotent. */\n\tasync connect(): Promise<void> {\n\t\tif (this.browser !== undefined) return;\n\t\tconst playwright = this.loadModule();\n\t\t// Point the Playwright registry at the same isolated directory the setup\n\t\t// flow installs browsers into; never override an explicit user setting.\n\t\t// Without this, `browser_setup` binaries land in <deps>/browsers while\n\t\t// launch silently looks in the shared OS cache and fails on a fresh host.\n\t\tif (this.depsDir !== \"\") {\n\t\t\tprocess.env.PLAYWRIGHT_BROWSERS_PATH ??= join(this.depsDir, BROWSER_BROWSERS_DIR_NAME_V1);\n\t\t}\n\t\tlet browser: PlaywrightBrowserLike;\n\t\ttry {\n\t\t\tbrowser = await playwright.chromium.launch({ headless: this.headless });\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : \"\";\n\t\t\t// The module resolves but the browser binaries were never installed.\n\t\t\tif (/Executable doesn't exist|playwright install/i.test(message)) {\n\t\t\t\tthrow new Error(installGuidanceMessage(this.depsDir), {\n\t\t\t\t\tcause: error instanceof Error ? error : undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tthis.browser = browser;\n\t\tthis.context = await browser.newContext();\n\t}\n\n\t/** Idempotent best-effort teardown; never throws. */\n\tclose(): void {\n\t\tconst browser = this.browser;\n\t\tthis.browser = undefined;\n\t\tthis.context = undefined;\n\t\tthis.page = undefined;\n\t\tthis.pages = [];\n\t\tthis.pageIndex = 0;\n\t\tthis.consoleRing = [];\n\t\tthis.networkRing = [];\n\t\tthis.lastDownload = undefined;\n\t\tif (browser === undefined) return;\n\t\tvoid browser.close().catch(() => undefined);\n\t}\n\n\tasync navigate(input: BrowserNavigateInputV1, options: BrowserOperationOptionsV1 = {}): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tawait this.connect();\n\t\tconst page = this.page ?? (await this.openPage());\n\t\tawait page.goto(input.url, { waitUntil: input.waitUntil ?? \"load\" });\n\t\treturn buildPluginResultV1({\n\t\t\tversion: 1,\n\t\t\toperationId,\n\t\t\tstatus: \"succeeded\",\n\t\t\tsummary: `Navigated to ${sanitizeUrlV1(page.url())}`,\n\t\t\tartifacts: [],\n\t\t\tevidence: [],\n\t\t});\n\t}\n\n\tasync snapshot(\n\t\tinput: BrowserSnapshotInputV1 = {},\n\t\toptions: BrowserOperationOptionsV1 = {},\n\t): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tconst evidence = evidenceBuilder(operationId);\n\t\tconst parts: string[] = [];\n\t\tif (input.includeStyles === true) parts.push(\"styles: not_supported_in_this_build\");\n\t\tif (input.includeA11y !== false) {\n\t\t\tevidence.add(\n\t\t\t\t\"structure\",\n\t\t\t\tplaceholder(boundedPreviewV1(await page.locator(\"body\").ariaSnapshot(), BROWSER_MAX_SNAPSHOT_CHARS_V1)),\n\t\t\t);\n\t\t\tparts.push(\"a11y\");\n\t\t}\n\t\tif (input.includeDom === true) {\n\t\t\tevidence.add(\"dom\", placeholder(boundedPreviewV1(await page.content(), BROWSER_MAX_DOM_CHARS_V1)));\n\t\t\tparts.push(\"dom\");\n\t\t}\n\t\tif (input.includeScreenshot === true) {\n\t\t\tconst png = await page.screenshot({ type: \"png\" });\n\t\t\tif (png.byteLength > BROWSER_MAX_SCREENSHOT_BYTES_V1) {\n\t\t\t\treturn failed(operationId, \"screenshot_too_large\", \"Screenshot exceeds the 4MiB evidence budget\");\n\t\t\t}\n\t\t\tevidence.add(\"screenshot\", `data:image/png;base64,${png.toString(\"base64\")}`);\n\t\t\tparts.push(\"screenshot\");\n\t\t}\n\t\tif (this.lastDownload !== undefined) {\n\t\t\tconst filename = this.lastDownload.slice(0, 256);\n\t\t\tevidence.add(\"log\", `download: ${filename}`);\n\t\t\tparts.push(`download: ${filename}`);\n\t\t}\n\t\treturn buildPluginResultV1({\n\t\t\tversion: 1,\n\t\t\toperationId,\n\t\t\tstatus: \"succeeded\",\n\t\t\tsummary: `Captured browser snapshot (${parts.length === 0 ? \"none\" : parts.join(\", \")})`,\n\t\t\tartifacts: [],\n\t\t\tevidence: evidence.refs,\n\t\t});\n\t}\n\n\tasync locatorAction(\n\t\tinput: BrowserLocatorActionInputV1,\n\t\toptions: BrowserOperationOptionsV1 = {},\n\t): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tconst missing = actionMissingInput(input);\n\t\tif (missing !== undefined) {\n\t\t\treturn failed(operationId, \"browser_action_invalid\", `The ${input.action} action requires ${missing}`);\n\t\t}\n\t\tconst locator = resolveLocator(page, input.locator);\n\t\tswitch (input.action) {\n\t\t\tcase \"click\":\n\t\t\t\tawait locator.click();\n\t\t\t\tbreak;\n\t\t\tcase \"dblclick\":\n\t\t\t\tawait locator.dblclick();\n\t\t\t\tbreak;\n\t\t\tcase \"rightclick\":\n\t\t\t\tawait locator.click({ button: \"right\" });\n\t\t\t\tbreak;\n\t\t\tcase \"fill\":\n\t\t\t\tawait locator.fill(input.value ?? \"\");\n\t\t\t\tbreak;\n\t\t\tcase \"type\":\n\t\t\t\tawait locator.type(input.value ?? \"\", input.delay === undefined ? {} : { delay: input.delay });\n\t\t\t\tbreak;\n\t\t\tcase \"press\":\n\t\t\t\tawait locator.press(input.key ?? \"\");\n\t\t\t\tbreak;\n\t\t\tcase \"hover\":\n\t\t\t\tawait locator.hover();\n\t\t\t\tbreak;\n\t\t\tcase \"select\":\n\t\t\t\tawait locator.selectOption(input.value ?? \"\");\n\t\t\t\tbreak;\n\t\t\tcase \"check\":\n\t\t\t\tawait locator.check();\n\t\t\t\tbreak;\n\t\t\tcase \"uncheck\":\n\t\t\t\tawait locator.uncheck();\n\t\t\t\tbreak;\n\t\t\tcase \"clear\":\n\t\t\t\tawait locator.clear();\n\t\t\t\tbreak;\n\t\t\tcase \"upload\": {\n\t\t\t\tlet paths: readonly string[];\n\t\t\t\ttry {\n\t\t\t\t\tpaths = parseUploadPathsV1(input.value ?? \"\");\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn failed(\n\t\t\t\t\t\toperationId,\n\t\t\t\t\t\t\"browser_action_invalid\",\n\t\t\t\t\t\terror instanceof Error ? error.message : \"Invalid upload value\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait locator.setInputFiles([...paths]);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"scroll\": {\n\t\t\t\tlet directive: ReturnType<typeof parseScrollDirectiveV1>;\n\t\t\t\ttry {\n\t\t\t\t\tdirective = parseScrollDirectiveV1(input.value ?? \"\");\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn failed(\n\t\t\t\t\t\toperationId,\n\t\t\t\t\t\t\"browser_action_invalid\",\n\t\t\t\t\t\terror instanceof Error ? error.message : \"Invalid scroll value\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait locator.scrollIntoViewIfNeeded();\n\t\t\t\t// Wheel scrolls whatever scrollable container is under the cursor,\n\t\t\t\t// so park the cursor over the target element first; otherwise the\n\t\t\t\t// delta lands on whatever the mouse happened to hover before.\n\t\t\t\tconst scrollBox = await locator.boundingBox();\n\t\t\t\tif (scrollBox !== null) {\n\t\t\t\t\tawait page.mouse.move(scrollBox.x + scrollBox.width / 2, scrollBox.y + scrollBox.height / 2);\n\t\t\t\t}\n\t\t\t\tconst delta = scrollWheelDeltaV1(directive);\n\t\t\t\tawait page.mouse.wheel(delta.deltaX, delta.deltaY);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tconst evidence = evidenceBuilder(operationId);\n\t\tevidence.add(\n\t\t\t\"structure\",\n\t\t\tplaceholder(boundedPreviewV1(await page.locator(\"body\").ariaSnapshot(), BROWSER_MAX_SNAPSHOT_CHARS_V1)),\n\t\t);\n\t\treturn buildPluginResultV1({\n\t\t\tversion: 1,\n\t\t\toperationId,\n\t\t\tstatus: \"succeeded\",\n\t\t\tsummary: `Performed ${input.action}`,\n\t\t\tartifacts: [],\n\t\t\tevidence: evidence.refs,\n\t\t});\n\t}\n\n\tasync assertPostcondition(\n\t\tinput: BrowserPostconditionV1 | readonly BrowserPostconditionV1[],\n\t\toptions: BrowserOperationOptionsV1 = {},\n\t): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tconst conditions = Array.isArray(input) ? input : [input];\n\t\tconst checks: string[] = [];\n\t\tconst failedChecks: string[] = [];\n\t\tfor (const [index, condition] of conditions.entries()) {\n\t\t\tconst label = conditionLabel(condition, index);\n\t\t\tconst passed = await this.checkCondition(page, condition);\n\t\t\tchecks.push(`${label}:${passed ? \"passed\" : \"failed\"}`);\n\t\t\tif (!passed) failedChecks.push(label);\n\t\t}\n\t\tif (failedChecks.length === 0) {\n\t\t\treturn buildPluginResultV1({\n\t\t\t\tversion: 1,\n\t\t\t\toperationId,\n\t\t\t\tstatus: \"succeeded\",\n\t\t\t\tsummary: `All ${checks.length} postcondition(s) passed`,\n\t\t\t\tartifacts: [],\n\t\t\t\tevidence: [],\n\t\t\t\tverification: { version: 1, status: \"passed\", checks },\n\t\t\t});\n\t\t}\n\t\treturn buildPluginResultV1({\n\t\t\tversion: 1,\n\t\t\toperationId,\n\t\t\tstatus: \"failed\",\n\t\t\tsummary: \"One or more postconditions failed\",\n\t\t\tartifacts: [],\n\t\t\tevidence: [],\n\t\t\tverification: { version: 1, status: \"failed\", checks },\n\t\t\terror: {\n\t\t\t\tversion: 1,\n\t\t\t\tcode: \"postcondition_failed\",\n\t\t\t\tmessage: boundedPreviewV1(`Failed postconditions: ${failedChecks.join(\"; \")}`, 2048),\n\t\t\t},\n\t\t});\n\t}\n\n\tasync collectEvidence(\n\t\tkind: BrowserEvidenceKindV1,\n\t\toptions: BrowserOperationOptionsV1 = {},\n\t): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tconst evidence = evidenceBuilder(operationId);\n\t\tif (kind === \"console\") {\n\t\t\tconst text = this.consoleRing.map((entry) => `[${entry.type}] ${entry.text}`).join(\"\\n\");\n\t\t\tevidence.add(\"log\", placeholder(boundedPreviewV1(text, BROWSER_MAX_EVIDENCE_CHARS_V1)));\n\t\t} else if (kind === \"network\") {\n\t\t\tconst text = this.networkRing.map((entry) => `${entry.status} ${entry.url}`).join(\"\\n\");\n\t\t\tevidence.add(\"network\", placeholder(boundedPreviewV1(text, BROWSER_MAX_EVIDENCE_CHARS_V1)));\n\t\t} else {\n\t\t\tevidence.add(\n\t\t\t\t\"structure\",\n\t\t\t\tplaceholder(boundedPreviewV1(await page.locator(\"body\").ariaSnapshot(), BROWSER_MAX_SNAPSHOT_CHARS_V1)),\n\t\t\t);\n\t\t}\n\t\treturn buildPluginResultV1({\n\t\t\tversion: 1,\n\t\t\toperationId,\n\t\t\tstatus: \"succeeded\",\n\t\t\tsummary: `Collected ${kind} evidence`,\n\t\t\tartifacts: [],\n\t\t\tevidence: evidence.refs,\n\t\t});\n\t}\n\n\tasync evaluate(input: BrowserEvaluateInputV1, options: BrowserOperationOptionsV1 = {}): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tconst started = Date.now();\n\t\tconst value = await evaluateWithTimeout(\n\t\t\tpage,\n\t\t\tinput.expression,\n\t\t\tinput.arg,\n\t\t\tBROWSER_DEFAULT_EVALUATE_TIMEOUT_MS_V1,\n\t\t);\n\t\tconst evidence = evidenceBuilder(operationId);\n\t\tevidence.add(\"log\", placeholder(boundedPreviewV1(serializeJsonPayloadV1(value), BROWSER_MAX_EVIDENCE_CHARS_V1)));\n\t\treturn buildPluginResultV1({\n\t\t\tversion: 1,\n\t\t\toperationId,\n\t\t\tstatus: \"succeeded\",\n\t\t\tsummary: `Evaluated expression in ${Date.now() - started}ms`,\n\t\t\tartifacts: [],\n\t\t\tevidence: evidence.refs,\n\t\t});\n\t}\n\n\tasync consoleEntries(\n\t\tinput: BrowserConsoleReadInputV1,\n\t\toptions: BrowserOperationOptionsV1 = {},\n\t): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tlet result: ReturnType<typeof filterConsoleEntriesV1>;\n\t\ttry {\n\t\t\tresult = filterConsoleEntriesV1(this.consoleRing, input);\n\t\t} catch (error) {\n\t\t\treturn failed(\n\t\t\t\toperationId,\n\t\t\t\t\"browser_console_invalid\",\n\t\t\t\terror instanceof Error ? error.message : \"Invalid console filter\",\n\t\t\t);\n\t\t}\n\t\treturn payloadResult(\n\t\t\toperationId,\n\t\t\t`Read console: ${result.total} entry(ies), ${result.returned.length} returned`,\n\t\t\t\"log\",\n\t\t\tresult,\n\t\t);\n\t}\n\n\tasync networkEntries(\n\t\tinput: BrowserNetworkReadInputV1,\n\t\toptions: BrowserOperationOptionsV1 = {},\n\t): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tconst result = filterNetworkEntriesV1(this.networkRing, input);\n\t\treturn payloadResult(\n\t\t\toperationId,\n\t\t\t`Read network: ${result.total} entry(ies), ${result.returned.length} returned`,\n\t\t\t\"network\",\n\t\t\tresult,\n\t\t);\n\t}\n\n\tasync performance(options: BrowserOperationOptionsV1 = {}): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tconst raw = await page.evaluate<BrowserPerformanceRawV1>(collectPerformanceInPage);\n\t\tconst payload = shapePerformanceV1(raw);\n\t\treturn payloadResult(\n\t\t\toperationId,\n\t\t\t`Collected performance metrics (${payload.resources.count} resource(s), ${payload.domNodes} DOM nodes)`,\n\t\t\t\"trace\",\n\t\t\tpayload,\n\t\t);\n\t}\n\n\tasync wait(input: BrowserWaitInputV1, options: BrowserOperationOptionsV1 = {}): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tconst missing = waitMissingInput(input);\n\t\tif (missing !== undefined) {\n\t\t\treturn failed(operationId, \"browser_wait_invalid\", `The ${input.until} wait requires ${missing}`);\n\t\t}\n\t\tconst effectiveMs = clampWaitMsV1(input.ms);\n\t\tconst started = Date.now();\n\t\tlet label: string;\n\t\ttry {\n\t\t\tswitch (input.until) {\n\t\t\t\tcase \"selector\": {\n\t\t\t\t\tconst locator = resolveLocator(page, input.locator!);\n\t\t\t\t\tawait locator.waitFor({ state: \"visible\", timeout: effectiveMs });\n\t\t\t\t\tlabel = `selector ${locatorLabel(input.locator!)}`;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"navigation\":\n\t\t\t\t\tawait page.waitForLoadState(\"load\", { timeout: effectiveMs });\n\t\t\t\t\tlabel = \"navigation\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"networkidle\":\n\t\t\t\t\tawait page.waitForLoadState(\"networkidle\", { timeout: effectiveMs });\n\t\t\t\t\tlabel = \"networkidle\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"time\":\n\t\t\t\t\tawait sleep(effectiveMs);\n\t\t\t\t\tlabel = \"time\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!isTimeoutError(error)) throw error;\n\t\t\treturn failed(\n\t\t\t\toperationId,\n\t\t\t\t\"browser_wait_timeout\",\n\t\t\t\t`Wait for ${input.until} timed out after ${effectiveMs}ms: ${boundedPreviewV1(error.message, 2048)}`,\n\t\t\t);\n\t\t}\n\t\tconst waitedMs = Date.now() - started;\n\t\tconst payload = {\n\t\t\tuntil: input.until,\n\t\t\t...(input.ms === undefined ? {} : { requestedMs: input.ms }),\n\t\t\teffectiveMs,\n\t\t\twaitedMs,\n\t\t};\n\t\treturn payloadResult(operationId, `Waited ${waitedMs}ms for ${label}`, \"log\", payload);\n\t}\n\n\tasync drag(input: BrowserDragInputV1, options: BrowserOperationOptionsV1 = {}): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tconst steps = clampDragStepsV1(input.steps);\n\t\tconst from = resolveLocator(page, input.from);\n\t\tconst to = resolveLocator(page, input.to);\n\t\tawait from.hover();\n\t\tawait page.mouse.down();\n\t\t// Deliberately no `to.hover()` while the button is down: pages that call\n\t\t// setPointerCapture (the standard drag idiom) retarget pointer events to\n\t\t// the from-element, so Playwright's hover hit-target check would retry\n\t\t// until timeout. Move by geometry instead.\n\t\tconst box = await to.boundingBox();\n\t\tif (box !== null) {\n\t\t\tawait page.mouse.move(box.x + box.width / 2, box.y + box.height / 2, { steps });\n\t\t}\n\t\tawait page.mouse.up();\n\t\tconst payload = {\n\t\t\tsteps,\n\t\t\ttoCenter: box === null ? null : { x: box.x + box.width / 2, y: box.y + box.height / 2 },\n\t\t};\n\t\treturn payloadResult(\n\t\t\toperationId,\n\t\t\t`Dragged from ${locatorLabel(input.from)} to ${locatorLabel(input.to)}`,\n\t\t\t\"log\",\n\t\t\tpayload,\n\t\t);\n\t}\n\n\tasync mouse(input: BrowserMouseInputV1, options: BrowserOperationOptionsV1 = {}): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tconst buttonOptions = input.button === undefined ? {} : { button: input.button };\n\t\tlet summary: string;\n\t\tswitch (input.action) {\n\t\t\tcase \"move\":\n\t\t\t\tawait page.mouse.move(input.x, input.y);\n\t\t\t\tsummary = `Mouse moved to (${input.x}, ${input.y})`;\n\t\t\t\tbreak;\n\t\t\tcase \"click\":\n\t\t\t\tawait page.mouse.click(input.x, input.y, buttonOptions);\n\t\t\t\tsummary = `Mouse clicked (${input.button ?? \"left\"}) at (${input.x}, ${input.y})`;\n\t\t\t\tbreak;\n\t\t\tcase \"dblclick\":\n\t\t\t\tawait page.mouse.dblclick(input.x, input.y, buttonOptions);\n\t\t\t\tsummary = `Mouse double-clicked (${input.button ?? \"left\"}) at (${input.x}, ${input.y})`;\n\t\t\t\tbreak;\n\t\t\tcase \"rightclick\":\n\t\t\t\tawait page.mouse.click(input.x, input.y, { ...buttonOptions, button: \"right\" });\n\t\t\t\tsummary = `Mouse right-clicked at (${input.x}, ${input.y})`;\n\t\t\t\tbreak;\n\t\t\tcase \"wheel\": {\n\t\t\t\tconst deltaX = input.deltaX ?? 0;\n\t\t\t\tconst deltaY = input.deltaY ?? 0;\n\t\t\t\tawait page.mouse.wheel(deltaX, deltaY);\n\t\t\t\tsummary = `Mouse wheel (${deltaX}, ${deltaY})`;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn payloadResult(operationId, summary, \"log\", input);\n\t}\n\n\tasync pressKey(input: BrowserPressKeyInputV1, options: BrowserOperationOptionsV1 = {}): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tawait page.keyboard.press(input.key, input.delay === undefined ? {} : { delay: input.delay });\n\t\treturn payloadResult(operationId, `Pressed key ${input.key}`, \"log\", input);\n\t}\n\n\tasync tabs(input: BrowserTabsInputV1, options: BrowserOperationOptionsV1 = {}): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tif (input.action === \"new\") {\n\t\t\tawait this.connect();\n\t\t\tconst page = await this.openPage();\n\t\t\tif (input.url !== undefined) await page.goto(input.url, { waitUntil: \"load\" });\n\t\t\treturn payloadResult(operationId, `Opened tab ${this.pageIndex}`, \"log\", {\n\t\t\t\tindex: this.pageIndex,\n\t\t\t\ttitle: await page.title(),\n\t\t\t\turl: page.url(),\n\t\t\t});\n\t\t}\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tif (input.action === \"list\") {\n\t\t\tconst tabs: { index: number; title: string; url: string }[] = [];\n\t\t\tfor (const [index, entry] of this.pages.entries()) {\n\t\t\t\ttabs.push({ index, title: await entry.title(), url: entry.url() });\n\t\t\t}\n\t\t\treturn payloadResult(operationId, `Listed ${tabs.length} tab(s), current ${this.pageIndex}`, \"log\", {\n\t\t\t\tcurrentIndex: this.pageIndex,\n\t\t\t\ttabs,\n\t\t\t});\n\t\t}\n\t\tif (input.action === \"switch\") {\n\t\t\tif (\n\t\t\t\tinput.index === undefined ||\n\t\t\t\t!Number.isInteger(input.index) ||\n\t\t\t\tinput.index < 0 ||\n\t\t\t\tinput.index >= this.pages.length\n\t\t\t) {\n\t\t\t\treturn failed(\n\t\t\t\t\toperationId,\n\t\t\t\t\t\"browser_tabs_invalid\",\n\t\t\t\t\t`switch requires an index between 0 and ${this.pages.length - 1}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.pageIndex = input.index;\n\t\t\tthis.page = this.pages[this.pageIndex];\n\t\t\treturn payloadResult(operationId, `Switched to tab ${this.pageIndex}`, \"log\", {\n\t\t\t\tindex: this.pageIndex,\n\t\t\t\ttitle: await this.page.title(),\n\t\t\t\turl: this.page.url(),\n\t\t\t});\n\t\t}\n\t\t// close\n\t\tif (\n\t\t\tinput.index === undefined ||\n\t\t\t!Number.isInteger(input.index) ||\n\t\t\tinput.index < 0 ||\n\t\t\tinput.index >= this.pages.length\n\t\t) {\n\t\t\treturn failed(\n\t\t\t\toperationId,\n\t\t\t\t\"browser_tabs_invalid\",\n\t\t\t\t`close requires an index between 0 and ${this.pages.length - 1}`,\n\t\t\t);\n\t\t}\n\t\tconst closing = this.pages[input.index];\n\t\tawait closing.close();\n\t\tthis.pages.splice(input.index, 1);\n\t\tif (this.pageIndex >= input.index) this.pageIndex = Math.max(0, this.pageIndex - 1);\n\t\tthis.page = this.pages[this.pageIndex];\n\t\treturn payloadResult(operationId, `Closed tab ${input.index}; ${this.pages.length} remaining`, \"log\", {\n\t\t\tclosedIndex: input.index,\n\t\t\tremaining: this.pages.length,\n\t\t\t...(this.page === undefined ? {} : { currentIndex: this.pageIndex }),\n\t\t});\n\t}\n\n\tasync storage(input: BrowserStorageInputV1, options: BrowserOperationOptionsV1 = {}): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tswitch (input.action) {\n\t\t\tcase \"get-cookies\": {\n\t\t\t\tconst context = this.context;\n\t\t\t\tif (context === undefined) return sessionRequired(operationId);\n\t\t\t\tconst cookies = await context.cookies();\n\t\t\t\treturn payloadResult(operationId, `Read ${cookies.length} cookie(s)`, \"log\", { cookies });\n\t\t\t}\n\t\t\tcase \"set-cookie\": {\n\t\t\t\tconst context = this.context;\n\t\t\t\tif (context === undefined) return sessionRequired(operationId);\n\t\t\t\tif (input.name === undefined || input.value === undefined || input.domain === undefined) {\n\t\t\t\t\treturn failed(operationId, \"browser_storage_invalid\", \"set-cookie requires name, value, and domain\");\n\t\t\t\t}\n\t\t\t\tawait context.addCookies([\n\t\t\t\t\t{\n\t\t\t\t\t\tname: input.name,\n\t\t\t\t\t\tvalue: input.value,\n\t\t\t\t\t\tdomain: input.domain,\n\t\t\t\t\t\t...(input.path === undefined ? {} : { path: input.path }),\n\t\t\t\t\t\t...(input.expires === undefined ? {} : { expires: input.expires }),\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t\treturn payloadResult(operationId, `Set cookie ${input.name}`, \"log\", {\n\t\t\t\t\tname: input.name,\n\t\t\t\t\tdomain: input.domain,\n\t\t\t\t\t...(input.path === undefined ? {} : { path: input.path }),\n\t\t\t\t\t...(input.expires === undefined ? {} : { expires: input.expires }),\n\t\t\t\t});\n\t\t\t}\n\t\t\tcase \"clear-cookies\": {\n\t\t\t\tconst context = this.context;\n\t\t\t\tif (context === undefined) return sessionRequired(operationId);\n\t\t\t\tawait context.clearCookies();\n\t\t\t\treturn payloadResult(operationId, \"Cleared cookies\", \"log\", { cleared: \"cookies\" });\n\t\t\t}\n\t\t\tcase \"get-local\": {\n\t\t\t\tconst page = this.page;\n\t\t\t\tif (page === undefined) return sessionRequired(operationId);\n\t\t\t\tif (input.key === undefined) {\n\t\t\t\t\treturn failed(operationId, \"browser_storage_invalid\", \"get-local requires a key\");\n\t\t\t\t}\n\t\t\t\tconst value = await page.evaluate<string | null>((key) => window.localStorage.getItem(key), input.key);\n\t\t\t\treturn payloadResult(operationId, `Read localStorage[\"${input.key}\"]`, \"log\", { key: input.key, value });\n\t\t\t}\n\t\t\tcase \"set-local\": {\n\t\t\t\tconst page = this.page;\n\t\t\t\tif (page === undefined) return sessionRequired(operationId);\n\t\t\t\tif (input.key === undefined || input.value === undefined) {\n\t\t\t\t\treturn failed(operationId, \"browser_storage_invalid\", \"set-local requires key and value\");\n\t\t\t\t}\n\t\t\t\tawait page.evaluate(\n\t\t\t\t\t({ key, value }) => {\n\t\t\t\t\t\twindow.localStorage.setItem(key, value);\n\t\t\t\t\t},\n\t\t\t\t\t{ key: input.key, value: input.value },\n\t\t\t\t);\n\t\t\t\treturn payloadResult(operationId, `Set localStorage[\"${input.key}\"]`, \"log\", { key: input.key });\n\t\t\t}\n\t\t\tcase \"clear-local\": {\n\t\t\t\tconst page = this.page;\n\t\t\t\tif (page === undefined) return sessionRequired(operationId);\n\t\t\t\tawait page.evaluate(() => {\n\t\t\t\t\twindow.localStorage.clear();\n\t\t\t\t});\n\t\t\t\treturn payloadResult(operationId, \"Cleared localStorage\", \"log\", { cleared: \"local\" });\n\t\t\t}\n\t\t}\n\t}\n\n\tasync viewport(input: BrowserViewportInputV1, options: BrowserOperationOptionsV1 = {}): Promise<PluginResultV1> {\n\t\tconst operationId = options.operationId ?? \"browser-tool-call\";\n\t\tif (options.signal?.aborted) return cancelled(operationId);\n\t\tconst page = this.page;\n\t\tif (page === undefined) return sessionRequired(operationId);\n\t\tif (input.action === \"get\") {\n\t\t\tconst viewport = page.viewportSize();\n\t\t\treturn payloadResult(operationId, \"Read viewport size\", \"log\", {\n\t\t\t\twidth: viewport?.width ?? null,\n\t\t\t\theight: viewport?.height ?? null,\n\t\t\t});\n\t\t}\n\t\tif (input.width === undefined || input.height === undefined) {\n\t\t\treturn failed(operationId, \"browser_viewport_invalid\", \"set requires width and height\");\n\t\t}\n\t\tconst width = clampViewportDimensionV1(input.width);\n\t\tconst height = clampViewportDimensionV1(input.height);\n\t\tawait page.setViewportSize({ width, height });\n\t\tconst clamped = width !== input.width || height !== input.height;\n\t\treturn payloadResult(operationId, `Viewport set to ${width}x${height}${clamped ? \" (clamped)\" : \"\"}`, \"log\", {\n\t\t\twidth,\n\t\t\theight,\n\t\t\t...(clamped ? { requestedWidth: input.width, requestedHeight: input.height } : {}),\n\t\t});\n\t}\n\n\tprivate loadModule(): PlaywrightModuleLike {\n\t\tif (this.loadPlaywright !== undefined) return this.loadPlaywright();\n\t\tif (this.depsDir === \"\") throw new Error(installGuidanceMessage());\n\t\tif (this.resolveModule(this.depsDir) === undefined) throw new Error(installGuidanceMessage(this.depsDir));\n\t\ttry {\n\t\t\tconst require = createRequire(join(this.depsDir, \"package.json\"));\n\t\t\treturn require(\"playwright\") as PlaywrightModuleLike;\n\t\t} catch (error) {\n\t\t\tthrow new Error(installGuidanceMessage(this.depsDir), {\n\t\t\t\tcause: error instanceof Error ? error : undefined,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate downloadsDir(): string | undefined {\n\t\treturn this.depsDir === \"\" ? undefined : join(this.depsDir, BROWSER_DOWNLOADS_DIR_NAME_V1);\n\t}\n\n\tprivate async openPage(): Promise<PlaywrightPageLike> {\n\t\tconst context = this.context;\n\t\tif (context === undefined) throw new Error(\"Browser context is not initialized; connect first\");\n\t\tconst page = await context.newPage();\n\t\tpage.on(\"console\", (message) => {\n\t\t\tconst location = message.location();\n\t\t\tthis.pushRing(\n\t\t\t\tthis.consoleRing,\n\t\t\t\t{\n\t\t\t\t\ttype: message.type(),\n\t\t\t\t\ttext: message.text(),\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t...(location.url === \"\" ? {} : { location }),\n\t\t\t\t},\n\t\t\t\tBROWSER_RING_BUFFER_SIZE_V1,\n\t\t\t);\n\t\t});\n\t\tpage.on(\"response\", (response) => {\n\t\t\tthis.pushRing(this.networkRing, networkEntryOf(response), BROWSER_RING_BUFFER_SIZE_V1);\n\t\t});\n\t\t// Built-in dialog policy: auto-accept and keep a bounded trace entry so\n\t\t// assert/evidence tools can observe that a dialog appeared.\n\t\tpage.on(\"dialog\", (dialog) => {\n\t\t\tvoid dialog.accept().catch(() => undefined);\n\t\t\tthis.pushRing(\n\t\t\t\tthis.consoleRing,\n\t\t\t\t{ type: \"dialog\", text: `[dialog] ${dialog.type()}: ${dialog.message()}`, timestamp: Date.now() },\n\t\t\t\tBROWSER_RING_BUFFER_SIZE_V1,\n\t\t\t);\n\t\t});\n\t\t// Built-in download policy: persist into <agentDir>/browser-deps/downloads.\n\t\tpage.on(\"download\", (download) => {\n\t\t\tconst filename = download.suggestedFilename();\n\t\t\tthis.lastDownload = filename;\n\t\t\tconst dir = this.downloadsDir();\n\t\t\tif (dir === undefined) return;\n\t\t\ttry {\n\t\t\t\tthis.ensureDir(dir);\n\t\t\t} catch (error) {\n\t\t\t\tthis.pushRing(\n\t\t\t\t\tthis.consoleRing,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"download\",\n\t\t\t\t\t\ttext: `[download] could not create ${dir}: ${error instanceof Error ? error.message : \"unknown error\"}`,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t},\n\t\t\t\t\tBROWSER_RING_BUFFER_SIZE_V1,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvoid download.saveAs(join(dir, filename)).catch((error: unknown) => {\n\t\t\t\tthis.pushRing(\n\t\t\t\t\tthis.consoleRing,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"download\",\n\t\t\t\t\t\ttext: `[download] could not save ${filename}: ${error instanceof Error ? error.message : \"unknown error\"}`,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t},\n\t\t\t\t\tBROWSER_RING_BUFFER_SIZE_V1,\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\t\tthis.pages.push(page);\n\t\tthis.pageIndex = this.pages.length - 1;\n\t\tthis.page = page;\n\t\treturn page;\n\t}\n\n\tprivate pushRing<T>(ring: T[], entry: T, maximum: number): void {\n\t\tring.push(entry);\n\t\tif (ring.length > maximum) ring.splice(0, ring.length - maximum);\n\t}\n\n\tprivate async checkCondition(page: PlaywrightPageLike, condition: BrowserPostconditionV1): Promise<boolean> {\n\t\tif (condition.kind === \"url\") {\n\t\t\tconst url = page.url();\n\t\t\tif (condition.equals !== undefined && url !== condition.equals) return false;\n\t\t\tif (condition.contains !== undefined && !url.includes(condition.contains)) return false;\n\t\t\treturn true;\n\t\t}\n\t\tif (condition.kind === \"element\") {\n\t\t\tconst locator = resolveLocator(page, condition.locator);\n\t\t\tif (condition.state === \"visible\") return locator.isVisible();\n\t\t\tif (condition.state === \"hidden\") return locator.isHidden();\n\t\t\tconst value = await locator.inputValue();\n\t\t\treturn condition.value === undefined || value === condition.value;\n\t\t}\n\t\tif (condition.kind === \"text\") {\n\t\t\tconst text =\n\t\t\t\tcondition.locator === undefined\n\t\t\t\t\t? ((await page.locator(\"body\").textContent()) ?? \"\")\n\t\t\t\t\t: ((await resolveLocator(page, condition.locator).textContent()) ?? \"\");\n\t\t\treturn text.includes(condition.contains);\n\t\t}\n\t\tif (condition.kind === \"console\") {\n\t\t\treturn this.consoleRing.some(\n\t\t\t\t(entry) =>\n\t\t\t\t\tentry.text.includes(condition.contains) &&\n\t\t\t\t\t(condition.level === undefined || entry.type === condition.level),\n\t\t\t);\n\t\t}\n\t\treturn this.networkRing.some(\n\t\t\t(entry) =>\n\t\t\t\tentry.url.includes(condition.containsUrl) &&\n\t\t\t\t(condition.status === undefined || entry.status === condition.status),\n\t\t);\n\t}\n}\n\n/** Shapes a ring-buffer response event into a bounded network entry. */\nfunction networkEntryOf(response: PlaywrightResponseLike): BrowserNetworkEntryV1 {\n\tconst request = response.request();\n\tlet durationMs: number | undefined;\n\tconst timing = request.timing();\n\tif (timing.responseEnd > 0 && timing.responseEnd >= timing.startTime) {\n\t\tdurationMs = Math.round(timing.responseEnd - timing.startTime);\n\t}\n\tconst contentLength = response.headers()[\"content-length\"];\n\tconst sizeBytes = contentLength === undefined ? undefined : Number.parseInt(contentLength, 10);\n\treturn {\n\t\tmethod: request.method(),\n\t\turl: response.url(),\n\t\tstatus: response.status(),\n\t\ttimestamp: Date.now(),\n\t\t...(durationMs === undefined ? {} : { durationMs }),\n\t\t...(sizeBytes === undefined || Number.isNaN(sizeBytes) ? {} : { sizeBytes }),\n\t};\n}\n\n/** Builds a succeeded result carrying one bounded JSON payload as evidence. */\nfunction payloadResult(operationId: string, summary: string, kind: EvidenceKindV1, payload: unknown): PluginResultV1 {\n\tconst evidence = evidenceBuilder(operationId);\n\tevidence.add(kind, placeholder(boundedPreviewV1(serializeJsonPayloadV1(payload), BROWSER_MAX_EVIDENCE_CHARS_V1)));\n\treturn buildPluginResultV1({\n\t\tversion: 1,\n\t\toperationId,\n\t\tstatus: \"succeeded\",\n\t\tsummary,\n\t\tartifacts: [],\n\t\tevidence: evidence.refs,\n\t});\n}\n\n/**\n * Production runtime: one driver per session plus the `browser_setup`\n * self-install face. Hosts and tests may inject `spawnSync` and\n * `resolvePlaywright` through the setup options.\n */\nexport class PlaywrightBrowserRuntimeV1 implements BrowserRuntimeV1 {\n\tprivate readonly options: PlaywrightDriverOptionsV1 & BrowserSetupOptionsV1;\n\tprivate driver: PlaywrightBrowserDriver | undefined;\n\n\tconstructor(options: PlaywrightDriverOptionsV1 & Omit<BrowserSetupOptionsV1, \"agentDir\" | \"browserDepsDir\"> = {}) {\n\t\tthis.options = options;\n\t}\n\n\tasync connect(): Promise<BrowserDriverV1> {\n\t\tif (this.driver === undefined) this.driver = new PlaywrightBrowserDriver(this.options);\n\t\tawait this.driver.connect();\n\t\treturn this.driver;\n\t}\n\n\tasync setup(): Promise<BrowserSetupOutcomeV1> {\n\t\treturn setupBrowserDepsPlaywrightV1(this.options);\n\t}\n}\n\nconst actionMissingInput = (input: BrowserLocatorActionInputV1): string | undefined => {\n\tif (\n\t\t(input.action === \"fill\" ||\n\t\t\tinput.action === \"type\" ||\n\t\t\tinput.action === \"select\" ||\n\t\t\tinput.action === \"upload\" ||\n\t\t\tinput.action === \"scroll\") &&\n\t\tinput.value === undefined\n\t)\n\t\treturn \"a value\";\n\tif (input.action === \"press\" && input.key === undefined) return \"a key\";\n\treturn undefined;\n};\n\nconst resolveLocator = (page: PlaywrightPageLike, locator: BrowserLocatorV1): PlaywrightLocatorLike => {\n\tif (locator.kind === \"id\") return page.locator(`#${locator.value}`);\n\tif (locator.kind === \"role\")\n\t\treturn page.getByRole(locator.value, locator.name === undefined ? {} : { name: locator.name });\n\tif (locator.kind === \"text\") return page.getByText(locator.value);\n\tif (locator.kind === \"test-id\") return page.getByTestId(locator.value);\n\treturn page.locator(locator.value);\n};\n\nconst cancelled = (operationId: string): PluginResultV1 =>\n\tfailed(operationId, \"cancelled\", \"Browser operation was cancelled\");\n\nconst sessionRequired = (operationId: string): PluginResultV1 =>\n\tfailed(operationId, \"browser_session_required\", \"No active browser session. Call browser_navigate first.\");\n\nfunction failed(operationId: string, code: string, message: string): PluginResultV1 {\n\treturn buildPluginResultV1({\n\t\tversion: 1,\n\t\toperationId,\n\t\tstatus: code === \"cancelled\" ? \"cancelled\" : \"failed\",\n\t\tsummary: message,\n\t\tartifacts: [],\n\t\tevidence: [],\n\t\terror: { version: 1, code, message },\n\t});\n}\n\nfunction evidenceBuilder(operationId: string): {\n\treadonly refs: EvidenceRefV1[];\n\tadd(kind: EvidenceKindV1, summary: string): void;\n} {\n\tconst refs: EvidenceRefV1[] = [];\n\tlet index = 1;\n\treturn {\n\t\trefs,\n\t\tadd(kind: EvidenceKindV1, summary: string): void {\n\t\t\trefs.push({\n\t\t\t\tversion: 1,\n\t\t\t\tevidenceId: `${operationId}-evidence-${index}`,\n\t\t\t\tkind,\n\t\t\t\toperationId,\n\t\t\t\tsummary,\n\t\t\t});\n\t\t\tindex += 1;\n\t\t},\n\t};\n}\n"]}
@@ -0,0 +1,88 @@
1
+ import type { BrowserSetupOutcomeV1 } from "./types.ts";
2
+ export declare const BROWSER_SETUP_TIMEOUT_MS_V1 = 600000;
3
+ export declare const BROWSER_DEPS_DIR_NAME_V1 = "browser-deps";
4
+ export declare const BROWSER_BROWSERS_DIR_NAME_V1 = "browsers";
5
+ export declare const BROWSER_MAX_PROGRESS_CHARS_V1 = 8192;
6
+ export declare const BROWSER_MAX_FAILURE_MESSAGE_CHARS_V1 = 8192;
7
+ export declare const BROWSER_MAX_STDERR_TAIL_CHARS_V1 = 4096;
8
+ export declare const BROWSER_MAX_STDOUT_TAIL_CHARS_V1 = 2048;
9
+ export type BrowserSpawnResultV1 = {
10
+ readonly error?: Error;
11
+ readonly status: number | null;
12
+ readonly stdout: string;
13
+ readonly stderr: string;
14
+ };
15
+ export type BrowserSpawnSyncV1 = (command: string, args: readonly string[], options: {
16
+ readonly cwd: string;
17
+ readonly env: NodeJS.ProcessEnv;
18
+ readonly encoding: "utf8";
19
+ readonly timeout: number;
20
+ readonly windowsHide: boolean;
21
+ readonly shell: boolean;
22
+ }) => BrowserSpawnResultV1;
23
+ export interface BrowserSetupOptionsV1 {
24
+ /** Host agent directory; `<agentDir>/browser-deps` is the install target. */
25
+ readonly agentDir?: string;
26
+ /** Direct override of the install target; wins over `agentDir`. */
27
+ readonly browserDepsDir?: string;
28
+ readonly timeoutMs?: number;
29
+ /** Deterministic seam for tests and brokered hosts. */
30
+ readonly spawnSync?: BrowserSpawnSyncV1;
31
+ /** Deterministic seam for the "already installed" probe. */
32
+ readonly resolvePlaywright?: (browserDepsDir: string) => string | undefined;
33
+ /** Deterministic seam for the Chromium executable probe. */
34
+ readonly resolveChromiumExecutable?: (browserDepsDir: string) => string | undefined;
35
+ /** Deterministic seam for the executable existence check (tests inject a fake). */
36
+ readonly executableExists?: (path: string) => boolean;
37
+ /** Deterministic seam for directory creation (tests inject a no-op). */
38
+ readonly ensureDir?: (dir: string) => void;
39
+ }
40
+ export declare function browserDepsDirFor(agentDir: string): string;
41
+ /**
42
+ * Resolves the `playwright` module against `<browser-deps>` without touching
43
+ * this package's own dependency graph. Returns the resolved entry path, or
44
+ * undefined when the module is absent. Never throws.
45
+ */
46
+ export declare function resolvePlaywrightModule(browserDepsDir: string): string | undefined;
47
+ /**
48
+ * Resolves the Chromium executable path through the installed playwright
49
+ * module itself, so the probe targets the exact binary `chromium.launch()`
50
+ * will use. Returns undefined when the module cannot be loaded; the reported
51
+ * path may not exist on disk (the caller checks existence). Never throws.
52
+ */
53
+ export declare function resolveChromiumExecutable(browserDepsDir: string): string | undefined;
54
+ /**
55
+ * Structured guidance returned when Playwright is missing. The message lists
56
+ * the two exact install commands and points at the `browser_setup` tool; the
57
+ * capability layer passes it through verbatim (it stays under the 2048-char
58
+ * browser error budget).
59
+ */
60
+ export declare function installGuidanceMessage(browserDepsDir?: string): string;
61
+ /**
62
+ * Environment for the spawned installers (and, via PLAYWRIGHT_BROWSERS_PATH,
63
+ * for the driver's own browser launches): the whitelist from the macOS AX
64
+ * adapter plus PLAYWRIGHT_BROWSERS_PATH — an explicit user value wins so
65
+ * install and launch resolve browsers from the same directory, otherwise the
66
+ * given default browsers dir is pinned (matches connect()'s ??=). Everything
67
+ * else is dropped.
68
+ */
69
+ export declare function browserSetupEnvironmentV1(browsersDir: string): NodeJS.ProcessEnv;
70
+ /** Head/tail bounded preview (75% head, rest tail) mirroring process-exec's shaping. */
71
+ export declare function boundedPreviewV1(text: string, maximumChars: number): string;
72
+ /** Tail-only bounded preview, keeping the original ending intact. */
73
+ export declare function boundedTailV1(text: string, maximumChars: number): string;
74
+ /**
75
+ * Installs Playwright into the browser-deps directory:
76
+ * 1. already resolvable with the Chromium executable present -> succeed with
77
+ * `alreadyInstalled: true` (no spawn); a module without its browser binary
78
+ * does not short-circuit;
79
+ * 2. otherwise `npm install playwright --prefix <depsDir>`, then
80
+ * `npx playwright install chromium` (cwd = depsDir, whitelisted env plus
81
+ * PLAYWRIGHT_BROWSERS_PATH — explicit user value wins, else
82
+ * <depsDir>/browsers — bounded timeout);
83
+ * 3. post-install verification (module resolvable plus the Chromium
84
+ * executable present, the same probe as step 1) so a silent install
85
+ * failure is reported.
86
+ */
87
+ export declare function setupBrowserDepsPlaywrightV1(options?: BrowserSetupOptionsV1): Promise<BrowserSetupOutcomeV1>;
88
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,eAAO,MAAM,2BAA2B,SAAU,CAAC;AACnD,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,4BAA4B,aAAa,CAAC;AACvD,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAClD,eAAO,MAAM,oCAAoC,OAAO,CAAC;AACzD,eAAO,MAAM,gCAAgC,OAAO,CAAC;AACrD,eAAO,MAAM,gCAAgC,OAAO,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,MA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,MAAM,GAAG,MAAM,GAAG,SAAS,CAsBpF;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAiBtE;AAID;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAQhF;AAED,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAM3E;AAED,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAGxE;AAkCD;;;;;;;;;;;;GAYG;AACH,wBAAsB,4BAA4B,CACjD,OAAO,GAAE,qBAA0B,GACjC,OAAO,CAAC,qBAAqB,CAAC,CAsFhC","sourcesContent":["/**\n * Self-installation of Playwright into `<agentDir>/browser-deps` (the\n * `browser_setup` tool's engine).\n *\n * Playwright is deliberately not a dependency of this package: it is the only\n * optional heavy dependency in the product's browser channel, and it is\n * resolved at runtime through `createRequire(<browser-deps>/package.json)`.\n * This module owns the install sequence (`npm install playwright --prefix`\n * then `npx playwright install chromium`), the already-installed probe\n * (module resolvable plus the Chromium executable present), the environment\n * whitelist passed to the spawned installers, bounded progress/preview\n * shaping, and the structured guidance message returned when the module is\n * missing.\n */\nimport { spawnSync as nodeSpawnSync } from \"node:child_process\";\nimport { existsSync, mkdirSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\nimport type { BrowserSetupOutcomeV1 } from \"./types.ts\";\n\nexport const BROWSER_SETUP_TIMEOUT_MS_V1 = 600_000;\nexport const BROWSER_DEPS_DIR_NAME_V1 = \"browser-deps\";\nexport const BROWSER_BROWSERS_DIR_NAME_V1 = \"browsers\";\nexport const BROWSER_MAX_PROGRESS_CHARS_V1 = 8192;\nexport const BROWSER_MAX_FAILURE_MESSAGE_CHARS_V1 = 8192;\nexport const BROWSER_MAX_STDERR_TAIL_CHARS_V1 = 4096;\nexport const BROWSER_MAX_STDOUT_TAIL_CHARS_V1 = 2048;\n\nexport type BrowserSpawnResultV1 = {\n\treadonly error?: Error;\n\treadonly status: number | null;\n\treadonly stdout: string;\n\treadonly stderr: string;\n};\n\nexport type BrowserSpawnSyncV1 = (\n\tcommand: string,\n\targs: readonly string[],\n\toptions: {\n\t\treadonly cwd: string;\n\t\treadonly env: NodeJS.ProcessEnv;\n\t\treadonly encoding: \"utf8\";\n\t\treadonly timeout: number;\n\t\treadonly windowsHide: boolean;\n\t\treadonly shell: boolean;\n\t},\n) => BrowserSpawnResultV1;\n\nexport interface BrowserSetupOptionsV1 {\n\t/** Host agent directory; `<agentDir>/browser-deps` is the install target. */\n\treadonly agentDir?: string;\n\t/** Direct override of the install target; wins over `agentDir`. */\n\treadonly browserDepsDir?: string;\n\treadonly timeoutMs?: number;\n\t/** Deterministic seam for tests and brokered hosts. */\n\treadonly spawnSync?: BrowserSpawnSyncV1;\n\t/** Deterministic seam for the \"already installed\" probe. */\n\treadonly resolvePlaywright?: (browserDepsDir: string) => string | undefined;\n\t/** Deterministic seam for the Chromium executable probe. */\n\treadonly resolveChromiumExecutable?: (browserDepsDir: string) => string | undefined;\n\t/** Deterministic seam for the executable existence check (tests inject a fake). */\n\treadonly executableExists?: (path: string) => boolean;\n\t/** Deterministic seam for directory creation (tests inject a no-op). */\n\treadonly ensureDir?: (dir: string) => void;\n}\n\nexport function browserDepsDirFor(agentDir: string): string {\n\treturn join(agentDir, BROWSER_DEPS_DIR_NAME_V1);\n}\n\n/**\n * Resolves the `playwright` module against `<browser-deps>` without touching\n * this package's own dependency graph. Returns the resolved entry path, or\n * undefined when the module is absent. Never throws.\n */\nexport function resolvePlaywrightModule(browserDepsDir: string): string | undefined {\n\tif (browserDepsDir === \"\") return undefined;\n\ttry {\n\t\treturn createRequire(join(browserDepsDir, \"package.json\")).resolve(\"playwright\") as string;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Minimal shape of the installed playwright module used by the browser probe. */\ninterface PlaywrightChromiumProbeV1 {\n\tchromium: {\n\t\texecutablePath(): string;\n\t};\n}\n\n/**\n * Resolves the Chromium executable path through the installed playwright\n * module itself, so the probe targets the exact binary `chromium.launch()`\n * will use. Returns undefined when the module cannot be loaded; the reported\n * path may not exist on disk (the caller checks existence). Never throws.\n */\nexport function resolveChromiumExecutable(browserDepsDir: string): string | undefined {\n\tif (browserDepsDir === \"\") return undefined;\n\ttry {\n\t\t// playwright-core computes its registry directory once at module load\n\t\t// from PLAYWRIGHT_BROWSERS_PATH; when the user has not set it, pin it\n\t\t// before the require to the same isolated directory the install flow\n\t\t// populates and connect() falls back to. An explicit user value wins\n\t\t// (same precedence as connect()'s ??=), so probe and launch agree.\n\t\tconst previous = process.env.PLAYWRIGHT_BROWSERS_PATH;\n\t\tif (previous === undefined) {\n\t\t\tprocess.env.PLAYWRIGHT_BROWSERS_PATH = join(browserDepsDir, BROWSER_BROWSERS_DIR_NAME_V1);\n\t\t}\n\t\ttry {\n\t\t\tconst require = createRequire(join(browserDepsDir, \"package.json\"));\n\t\t\tconst playwright = require(\"playwright\") as PlaywrightChromiumProbeV1;\n\t\t\treturn playwright.chromium.executablePath();\n\t\t} finally {\n\t\t\tif (previous === undefined) delete process.env.PLAYWRIGHT_BROWSERS_PATH;\n\t\t}\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Structured guidance returned when Playwright is missing. The message lists\n * the two exact install commands and points at the `browser_setup` tool; the\n * capability layer passes it through verbatim (it stays under the 2048-char\n * browser error budget).\n */\nexport function installGuidanceMessage(browserDepsDir?: string): string {\n\tconst target =\n\t\tbrowserDepsDir === undefined || browserDepsDir === \"\"\n\t\t\t? join(\"<agentDir>\", BROWSER_DEPS_DIR_NAME_V1)\n\t\t\t: browserDepsDir;\n\treturn [\n\t\t\"Playwright is required by the browser tools but is not installed.\",\n\t\t\"Install it with:\",\n\t\t` npm install playwright --prefix ${target}`,\n\t\t// With an explicit PLAYWRIGHT_BROWSERS_PATH in the environment the bare\n\t\t// command already installs where the driver looks; pinning the prefix\n\t\t// here would override the user's directory (connect honors it via ??=).\n\t\tprocess.env.PLAYWRIGHT_BROWSERS_PATH === undefined\n\t\t\t? ` PLAYWRIGHT_BROWSERS_PATH=${join(target, BROWSER_BROWSERS_DIR_NAME_V1)} npx playwright install chromium`\n\t\t\t: \" npx playwright install chromium\",\n\t\t\"Or call the browser_setup tool to install these dependencies automatically.\",\n\t].join(\"\\n\");\n}\n\nconst BROWSER_SETUP_ENV_KEYS_V1: readonly string[] = [\"PATH\", \"HOME\", \"APPDATA\", \"USER\", \"LOGNAME\", \"TMPDIR\"];\n\n/**\n * Environment for the spawned installers (and, via PLAYWRIGHT_BROWSERS_PATH,\n * for the driver's own browser launches): the whitelist from the macOS AX\n * adapter plus PLAYWRIGHT_BROWSERS_PATH — an explicit user value wins so\n * install and launch resolve browsers from the same directory, otherwise the\n * given default browsers dir is pinned (matches connect()'s ??=). Everything\n * else is dropped.\n */\nexport function browserSetupEnvironmentV1(browsersDir: string): NodeJS.ProcessEnv {\n\tconst env: NodeJS.ProcessEnv = {};\n\tfor (const key of BROWSER_SETUP_ENV_KEYS_V1) {\n\t\tconst value = process.env[key];\n\t\tif (value !== undefined) env[key] = value;\n\t}\n\tenv.PLAYWRIGHT_BROWSERS_PATH = process.env.PLAYWRIGHT_BROWSERS_PATH ?? browsersDir;\n\treturn env;\n}\n\n/** Head/tail bounded preview (75% head, rest tail) mirroring process-exec's shaping. */\nexport function boundedPreviewV1(text: string, maximumChars: number): string {\n\tif (text.length <= maximumChars) return text;\n\tconst head = Math.ceil((maximumChars * 3) / 4);\n\tconst tail = Math.max(0, maximumChars - head - 40);\n\tconst omitted = text.length - head - tail;\n\treturn `${text.slice(0, head)}\\n... [${omitted} chars omitted] ...\\n${tail > 0 ? text.slice(text.length - tail) : \"\"}`;\n}\n\n/** Tail-only bounded preview, keeping the original ending intact. */\nexport function boundedTailV1(text: string, maximumChars: number): string {\n\tif (text.length <= maximumChars) return text;\n\treturn `... [${text.length - maximumChars} chars omitted] ...\\n${text.slice(text.length - maximumChars)}`;\n}\n\nconst isWin32 = process.platform === \"win32\";\nconst npmCommand = (): string => (isWin32 ? \"npm.cmd\" : \"npm\");\nconst npxCommand = (): string => (isWin32 ? \"npx.cmd\" : \"npx\");\n\nconst defaultSpawn: BrowserSpawnSyncV1 = (command, args, options) => {\n\tconst outcome = nodeSpawnSync(command, [...args], { ...options });\n\treturn {\n\t\terror: outcome.error,\n\t\tstatus: outcome.status,\n\t\tstdout: typeof outcome.stdout === \"string\" ? outcome.stdout : \"\",\n\t\tstderr: typeof outcome.stderr === \"string\" ? outcome.stderr : \"\",\n\t};\n};\n\nconst describeExit = (outcome: BrowserSpawnResultV1): string => {\n\tif (outcome.status === 0) return \"0\";\n\tif (outcome.status !== null) return String(outcome.status);\n\treturn outcome.error?.message ?? \"no exit status\";\n};\n\nconst spawnSucceeded = (outcome: BrowserSpawnResultV1): boolean => outcome.error === undefined && outcome.status === 0;\n\nconst failureMessage = (label: string, outcome: BrowserSpawnResultV1, depsDir: string): string => {\n\tconst parts = [`${label} failed (exit ${describeExit(outcome)})`];\n\tconst stderr = boundedTailV1(outcome.stderr, BROWSER_MAX_STDERR_TAIL_CHARS_V1);\n\tif (stderr.trim() !== \"\") parts.push(`stderr tail:\\n${stderr}`);\n\tconst stdout = boundedTailV1(outcome.stdout, BROWSER_MAX_STDOUT_TAIL_CHARS_V1);\n\tif (stdout.trim() !== \"\") parts.push(`stdout tail:\\n${stdout}`);\n\tparts.push(installGuidanceMessage(depsDir));\n\treturn boundedPreviewV1(parts.join(\"\\n\"), BROWSER_MAX_FAILURE_MESSAGE_CHARS_V1);\n};\n\n/**\n * Installs Playwright into the browser-deps directory:\n * 1. already resolvable with the Chromium executable present -> succeed with\n * `alreadyInstalled: true` (no spawn); a module without its browser binary\n * does not short-circuit;\n * 2. otherwise `npm install playwright --prefix <depsDir>`, then\n * `npx playwright install chromium` (cwd = depsDir, whitelisted env plus\n * PLAYWRIGHT_BROWSERS_PATH — explicit user value wins, else\n * <depsDir>/browsers — bounded timeout);\n * 3. post-install verification (module resolvable plus the Chromium\n * executable present, the same probe as step 1) so a silent install\n * failure is reported.\n */\nexport async function setupBrowserDepsPlaywrightV1(\n\toptions: BrowserSetupOptionsV1 = {},\n): Promise<BrowserSetupOutcomeV1> {\n\tconst depsDir =\n\t\toptions.browserDepsDir ?? (options.agentDir === undefined ? undefined : browserDepsDirFor(options.agentDir));\n\tif (depsDir === undefined || depsDir === \"\") {\n\t\treturn {\n\t\t\tok: false,\n\t\t\tmessage: `${installGuidanceMessage()}\\nThe running host did not declare an agentDir, so browser_setup cannot install anything.`,\n\t\t};\n\t}\n\tconst resolve = options.resolvePlaywright ?? resolvePlaywrightModule;\n\tconst resolveChromium = options.resolveChromiumExecutable ?? resolveChromiumExecutable;\n\tconst executableExists = options.executableExists ?? existsSync;\n\tconst spawn = options.spawnSync ?? defaultSpawn;\n\tconst ensureDir = options.ensureDir ?? ((dir: string) => mkdirSync(dir, { recursive: true }));\n\tconst timeoutMs = options.timeoutMs ?? BROWSER_SETUP_TIMEOUT_MS_V1;\n\tconst resolved = resolve(depsDir);\n\t// Already-installed requires BOTH the module and the browser binary:\n\t// a past run that installed the package but failed the chromium download\n\t// must re-run the install instead of reporting success the driver cannot\n\t// honor (launch would fail with \"Executable doesn't exist\").\n\tconst chromiumExecutable = resolved === undefined ? undefined : resolveChromium(depsDir);\n\tif (resolved !== undefined && chromiumExecutable !== undefined && executableExists(chromiumExecutable)) {\n\t\treturn { ok: true, alreadyInstalled: true, log: `playwright resolvable at ${resolved}` };\n\t}\n\tconst log: string[] = [`target: ${depsDir}`];\n\tensureDir(depsDir);\n\tconst env = browserSetupEnvironmentV1(join(depsDir, BROWSER_BROWSERS_DIR_NAME_V1));\n\tconst spawnOptions = {\n\t\tcwd: depsDir,\n\t\tenv,\n\t\tencoding: \"utf8\",\n\t\ttimeout: timeoutMs,\n\t\twindowsHide: true,\n\t\t// Node >= 18.20 refuses to spawn .cmd shims directly (EINVAL), so win32\n\t\t// runs through cmd.exe, which joins argv with spaces and never quotes;\n\t\t// --prefix carries an arbitrary user path (homedir may contain spaces),\n\t\t// so quote it explicitly on win32 (node-package-install-host precedent).\n\t\tshell: isWin32,\n\t} as const;\n\tconst install = spawn(\n\t\tnpmCommand(),\n\t\t[\"install\", \"playwright\", \"--prefix\", isWin32 ? `\"${depsDir}\"` : depsDir],\n\t\tspawnOptions,\n\t);\n\tif (!spawnSucceeded(install)) {\n\t\treturn { ok: false, message: failureMessage(\"npm install playwright --prefix\", install, depsDir) };\n\t}\n\tlog.push(`npm install playwright --prefix: exit ${describeExit(install)}`);\n\tconst browsers = spawn(npxCommand(), [\"playwright\", \"install\", \"chromium\"], spawnOptions);\n\tif (!spawnSucceeded(browsers)) {\n\t\treturn { ok: false, message: failureMessage(\"npx playwright install chromium\", browsers, depsDir) };\n\t}\n\tlog.push(`npx playwright install chromium: exit ${describeExit(browsers)}`);\n\tconst verified = resolve(depsDir);\n\tif (verified === undefined) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\tmessage: boundedPreviewV1(\n\t\t\t\t`${installGuidanceMessage(depsDir)}\\nInstallation commands reported success but playwright is still not resolvable from ${depsDir}.`,\n\t\t\t\tBROWSER_MAX_FAILURE_MESSAGE_CHARS_V1,\n\t\t\t),\n\t\t};\n\t}\n\tlog.push(`verification: playwright resolvable at ${verified}`);\n\t// The install commands can exit 0 while the chromium download silently\n\t// failed (e.g. a blocked download host), so verify the exact binary\n\t// chromium.launch() will use — the same probe the already-installed\n\t// check above runs.\n\tconst verifiedExecutable = resolveChromium(depsDir);\n\tif (verifiedExecutable === undefined || !executableExists(verifiedExecutable)) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\tmessage: boundedPreviewV1(\n\t\t\t\t`${installGuidanceMessage(depsDir)}\\nInstallation commands reported success but the Chromium executable is still missing${\n\t\t\t\t\tverifiedExecutable === undefined ? \".\" : ` (expected at ${verifiedExecutable}).`\n\t\t\t\t}`,\n\t\t\t\tBROWSER_MAX_FAILURE_MESSAGE_CHARS_V1,\n\t\t\t),\n\t\t};\n\t}\n\tlog.push(`verification: chromium executable at ${verifiedExecutable}`);\n\treturn {\n\t\tok: true,\n\t\talreadyInstalled: false,\n\t\tlog: boundedPreviewV1(log.join(\"\\n\"), BROWSER_MAX_PROGRESS_CHARS_V1),\n\t};\n}\n"]}
@@ -0,0 +1,252 @@
1
+ /**
2
+ * Self-installation of Playwright into `<agentDir>/browser-deps` (the
3
+ * `browser_setup` tool's engine).
4
+ *
5
+ * Playwright is deliberately not a dependency of this package: it is the only
6
+ * optional heavy dependency in the product's browser channel, and it is
7
+ * resolved at runtime through `createRequire(<browser-deps>/package.json)`.
8
+ * This module owns the install sequence (`npm install playwright --prefix`
9
+ * then `npx playwright install chromium`), the already-installed probe
10
+ * (module resolvable plus the Chromium executable present), the environment
11
+ * whitelist passed to the spawned installers, bounded progress/preview
12
+ * shaping, and the structured guidance message returned when the module is
13
+ * missing.
14
+ */
15
+ import { spawnSync as nodeSpawnSync } from "node:child_process";
16
+ import { existsSync, mkdirSync } from "node:fs";
17
+ import { createRequire } from "node:module";
18
+ import { join } from "node:path";
19
+ export const BROWSER_SETUP_TIMEOUT_MS_V1 = 600_000;
20
+ export const BROWSER_DEPS_DIR_NAME_V1 = "browser-deps";
21
+ export const BROWSER_BROWSERS_DIR_NAME_V1 = "browsers";
22
+ export const BROWSER_MAX_PROGRESS_CHARS_V1 = 8192;
23
+ export const BROWSER_MAX_FAILURE_MESSAGE_CHARS_V1 = 8192;
24
+ export const BROWSER_MAX_STDERR_TAIL_CHARS_V1 = 4096;
25
+ export const BROWSER_MAX_STDOUT_TAIL_CHARS_V1 = 2048;
26
+ export function browserDepsDirFor(agentDir) {
27
+ return join(agentDir, BROWSER_DEPS_DIR_NAME_V1);
28
+ }
29
+ /**
30
+ * Resolves the `playwright` module against `<browser-deps>` without touching
31
+ * this package's own dependency graph. Returns the resolved entry path, or
32
+ * undefined when the module is absent. Never throws.
33
+ */
34
+ export function resolvePlaywrightModule(browserDepsDir) {
35
+ if (browserDepsDir === "")
36
+ return undefined;
37
+ try {
38
+ return createRequire(join(browserDepsDir, "package.json")).resolve("playwright");
39
+ }
40
+ catch {
41
+ return undefined;
42
+ }
43
+ }
44
+ /**
45
+ * Resolves the Chromium executable path through the installed playwright
46
+ * module itself, so the probe targets the exact binary `chromium.launch()`
47
+ * will use. Returns undefined when the module cannot be loaded; the reported
48
+ * path may not exist on disk (the caller checks existence). Never throws.
49
+ */
50
+ export function resolveChromiumExecutable(browserDepsDir) {
51
+ if (browserDepsDir === "")
52
+ return undefined;
53
+ try {
54
+ // playwright-core computes its registry directory once at module load
55
+ // from PLAYWRIGHT_BROWSERS_PATH; when the user has not set it, pin it
56
+ // before the require to the same isolated directory the install flow
57
+ // populates and connect() falls back to. An explicit user value wins
58
+ // (same precedence as connect()'s ??=), so probe and launch agree.
59
+ const previous = process.env.PLAYWRIGHT_BROWSERS_PATH;
60
+ if (previous === undefined) {
61
+ process.env.PLAYWRIGHT_BROWSERS_PATH = join(browserDepsDir, BROWSER_BROWSERS_DIR_NAME_V1);
62
+ }
63
+ try {
64
+ const require = createRequire(join(browserDepsDir, "package.json"));
65
+ const playwright = require("playwright");
66
+ return playwright.chromium.executablePath();
67
+ }
68
+ finally {
69
+ if (previous === undefined)
70
+ delete process.env.PLAYWRIGHT_BROWSERS_PATH;
71
+ }
72
+ }
73
+ catch {
74
+ return undefined;
75
+ }
76
+ }
77
+ /**
78
+ * Structured guidance returned when Playwright is missing. The message lists
79
+ * the two exact install commands and points at the `browser_setup` tool; the
80
+ * capability layer passes it through verbatim (it stays under the 2048-char
81
+ * browser error budget).
82
+ */
83
+ export function installGuidanceMessage(browserDepsDir) {
84
+ const target = browserDepsDir === undefined || browserDepsDir === ""
85
+ ? join("<agentDir>", BROWSER_DEPS_DIR_NAME_V1)
86
+ : browserDepsDir;
87
+ return [
88
+ "Playwright is required by the browser tools but is not installed.",
89
+ "Install it with:",
90
+ ` npm install playwright --prefix ${target}`,
91
+ // With an explicit PLAYWRIGHT_BROWSERS_PATH in the environment the bare
92
+ // command already installs where the driver looks; pinning the prefix
93
+ // here would override the user's directory (connect honors it via ??=).
94
+ process.env.PLAYWRIGHT_BROWSERS_PATH === undefined
95
+ ? ` PLAYWRIGHT_BROWSERS_PATH=${join(target, BROWSER_BROWSERS_DIR_NAME_V1)} npx playwright install chromium`
96
+ : " npx playwright install chromium",
97
+ "Or call the browser_setup tool to install these dependencies automatically.",
98
+ ].join("\n");
99
+ }
100
+ const BROWSER_SETUP_ENV_KEYS_V1 = ["PATH", "HOME", "APPDATA", "USER", "LOGNAME", "TMPDIR"];
101
+ /**
102
+ * Environment for the spawned installers (and, via PLAYWRIGHT_BROWSERS_PATH,
103
+ * for the driver's own browser launches): the whitelist from the macOS AX
104
+ * adapter plus PLAYWRIGHT_BROWSERS_PATH — an explicit user value wins so
105
+ * install and launch resolve browsers from the same directory, otherwise the
106
+ * given default browsers dir is pinned (matches connect()'s ??=). Everything
107
+ * else is dropped.
108
+ */
109
+ export function browserSetupEnvironmentV1(browsersDir) {
110
+ const env = {};
111
+ for (const key of BROWSER_SETUP_ENV_KEYS_V1) {
112
+ const value = process.env[key];
113
+ if (value !== undefined)
114
+ env[key] = value;
115
+ }
116
+ env.PLAYWRIGHT_BROWSERS_PATH = process.env.PLAYWRIGHT_BROWSERS_PATH ?? browsersDir;
117
+ return env;
118
+ }
119
+ /** Head/tail bounded preview (75% head, rest tail) mirroring process-exec's shaping. */
120
+ export function boundedPreviewV1(text, maximumChars) {
121
+ if (text.length <= maximumChars)
122
+ return text;
123
+ const head = Math.ceil((maximumChars * 3) / 4);
124
+ const tail = Math.max(0, maximumChars - head - 40);
125
+ const omitted = text.length - head - tail;
126
+ return `${text.slice(0, head)}\n... [${omitted} chars omitted] ...\n${tail > 0 ? text.slice(text.length - tail) : ""}`;
127
+ }
128
+ /** Tail-only bounded preview, keeping the original ending intact. */
129
+ export function boundedTailV1(text, maximumChars) {
130
+ if (text.length <= maximumChars)
131
+ return text;
132
+ return `... [${text.length - maximumChars} chars omitted] ...\n${text.slice(text.length - maximumChars)}`;
133
+ }
134
+ const isWin32 = process.platform === "win32";
135
+ const npmCommand = () => (isWin32 ? "npm.cmd" : "npm");
136
+ const npxCommand = () => (isWin32 ? "npx.cmd" : "npx");
137
+ const defaultSpawn = (command, args, options) => {
138
+ const outcome = nodeSpawnSync(command, [...args], { ...options });
139
+ return {
140
+ error: outcome.error,
141
+ status: outcome.status,
142
+ stdout: typeof outcome.stdout === "string" ? outcome.stdout : "",
143
+ stderr: typeof outcome.stderr === "string" ? outcome.stderr : "",
144
+ };
145
+ };
146
+ const describeExit = (outcome) => {
147
+ if (outcome.status === 0)
148
+ return "0";
149
+ if (outcome.status !== null)
150
+ return String(outcome.status);
151
+ return outcome.error?.message ?? "no exit status";
152
+ };
153
+ const spawnSucceeded = (outcome) => outcome.error === undefined && outcome.status === 0;
154
+ const failureMessage = (label, outcome, depsDir) => {
155
+ const parts = [`${label} failed (exit ${describeExit(outcome)})`];
156
+ const stderr = boundedTailV1(outcome.stderr, BROWSER_MAX_STDERR_TAIL_CHARS_V1);
157
+ if (stderr.trim() !== "")
158
+ parts.push(`stderr tail:\n${stderr}`);
159
+ const stdout = boundedTailV1(outcome.stdout, BROWSER_MAX_STDOUT_TAIL_CHARS_V1);
160
+ if (stdout.trim() !== "")
161
+ parts.push(`stdout tail:\n${stdout}`);
162
+ parts.push(installGuidanceMessage(depsDir));
163
+ return boundedPreviewV1(parts.join("\n"), BROWSER_MAX_FAILURE_MESSAGE_CHARS_V1);
164
+ };
165
+ /**
166
+ * Installs Playwright into the browser-deps directory:
167
+ * 1. already resolvable with the Chromium executable present -> succeed with
168
+ * `alreadyInstalled: true` (no spawn); a module without its browser binary
169
+ * does not short-circuit;
170
+ * 2. otherwise `npm install playwright --prefix <depsDir>`, then
171
+ * `npx playwright install chromium` (cwd = depsDir, whitelisted env plus
172
+ * PLAYWRIGHT_BROWSERS_PATH — explicit user value wins, else
173
+ * <depsDir>/browsers — bounded timeout);
174
+ * 3. post-install verification (module resolvable plus the Chromium
175
+ * executable present, the same probe as step 1) so a silent install
176
+ * failure is reported.
177
+ */
178
+ export async function setupBrowserDepsPlaywrightV1(options = {}) {
179
+ const depsDir = options.browserDepsDir ?? (options.agentDir === undefined ? undefined : browserDepsDirFor(options.agentDir));
180
+ if (depsDir === undefined || depsDir === "") {
181
+ return {
182
+ ok: false,
183
+ message: `${installGuidanceMessage()}\nThe running host did not declare an agentDir, so browser_setup cannot install anything.`,
184
+ };
185
+ }
186
+ const resolve = options.resolvePlaywright ?? resolvePlaywrightModule;
187
+ const resolveChromium = options.resolveChromiumExecutable ?? resolveChromiumExecutable;
188
+ const executableExists = options.executableExists ?? existsSync;
189
+ const spawn = options.spawnSync ?? defaultSpawn;
190
+ const ensureDir = options.ensureDir ?? ((dir) => mkdirSync(dir, { recursive: true }));
191
+ const timeoutMs = options.timeoutMs ?? BROWSER_SETUP_TIMEOUT_MS_V1;
192
+ const resolved = resolve(depsDir);
193
+ // Already-installed requires BOTH the module and the browser binary:
194
+ // a past run that installed the package but failed the chromium download
195
+ // must re-run the install instead of reporting success the driver cannot
196
+ // honor (launch would fail with "Executable doesn't exist").
197
+ const chromiumExecutable = resolved === undefined ? undefined : resolveChromium(depsDir);
198
+ if (resolved !== undefined && chromiumExecutable !== undefined && executableExists(chromiumExecutable)) {
199
+ return { ok: true, alreadyInstalled: true, log: `playwright resolvable at ${resolved}` };
200
+ }
201
+ const log = [`target: ${depsDir}`];
202
+ ensureDir(depsDir);
203
+ const env = browserSetupEnvironmentV1(join(depsDir, BROWSER_BROWSERS_DIR_NAME_V1));
204
+ const spawnOptions = {
205
+ cwd: depsDir,
206
+ env,
207
+ encoding: "utf8",
208
+ timeout: timeoutMs,
209
+ windowsHide: true,
210
+ // Node >= 18.20 refuses to spawn .cmd shims directly (EINVAL), so win32
211
+ // runs through cmd.exe, which joins argv with spaces and never quotes;
212
+ // --prefix carries an arbitrary user path (homedir may contain spaces),
213
+ // so quote it explicitly on win32 (node-package-install-host precedent).
214
+ shell: isWin32,
215
+ };
216
+ const install = spawn(npmCommand(), ["install", "playwright", "--prefix", isWin32 ? `"${depsDir}"` : depsDir], spawnOptions);
217
+ if (!spawnSucceeded(install)) {
218
+ return { ok: false, message: failureMessage("npm install playwright --prefix", install, depsDir) };
219
+ }
220
+ log.push(`npm install playwright --prefix: exit ${describeExit(install)}`);
221
+ const browsers = spawn(npxCommand(), ["playwright", "install", "chromium"], spawnOptions);
222
+ if (!spawnSucceeded(browsers)) {
223
+ return { ok: false, message: failureMessage("npx playwright install chromium", browsers, depsDir) };
224
+ }
225
+ log.push(`npx playwright install chromium: exit ${describeExit(browsers)}`);
226
+ const verified = resolve(depsDir);
227
+ if (verified === undefined) {
228
+ return {
229
+ ok: false,
230
+ message: boundedPreviewV1(`${installGuidanceMessage(depsDir)}\nInstallation commands reported success but playwright is still not resolvable from ${depsDir}.`, BROWSER_MAX_FAILURE_MESSAGE_CHARS_V1),
231
+ };
232
+ }
233
+ log.push(`verification: playwright resolvable at ${verified}`);
234
+ // The install commands can exit 0 while the chromium download silently
235
+ // failed (e.g. a blocked download host), so verify the exact binary
236
+ // chromium.launch() will use — the same probe the already-installed
237
+ // check above runs.
238
+ const verifiedExecutable = resolveChromium(depsDir);
239
+ if (verifiedExecutable === undefined || !executableExists(verifiedExecutable)) {
240
+ return {
241
+ ok: false,
242
+ message: boundedPreviewV1(`${installGuidanceMessage(depsDir)}\nInstallation commands reported success but the Chromium executable is still missing${verifiedExecutable === undefined ? "." : ` (expected at ${verifiedExecutable}).`}`, BROWSER_MAX_FAILURE_MESSAGE_CHARS_V1),
243
+ };
244
+ }
245
+ log.push(`verification: chromium executable at ${verifiedExecutable}`);
246
+ return {
247
+ ok: true,
248
+ alreadyInstalled: false,
249
+ log: boundedPreviewV1(log.join("\n"), BROWSER_MAX_PROGRESS_CHARS_V1),
250
+ };
251
+ }
252
+ //# sourceMappingURL=setup.js.map