pi-agent-browser-native 0.9.3 → 0.9.4

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 (391) hide show
  1. package/CHANGELOG.md +77 -5
  2. package/README.md +103 -81
  3. package/dist/extensions/agent-browser/index.js +43057 -2031
  4. package/dist/extensions/agent-browser/lib/argv-descriptor.js +49 -26
  5. package/dist/extensions/agent-browser/lib/argv-grammar.js +82 -93
  6. package/dist/extensions/agent-browser/lib/bash-guard.js +129 -126
  7. package/dist/extensions/agent-browser/lib/batch-lifecycle.js +112 -51
  8. package/dist/extensions/agent-browser/lib/browser-execution-claim-codec.js +61 -0
  9. package/dist/extensions/agent-browser/lib/browser-execution-claim-storage.js +232 -0
  10. package/dist/extensions/agent-browser/lib/browser-execution-claims.js +202 -0
  11. package/dist/extensions/agent-browser/lib/browser-execution-identity.js +77 -0
  12. package/dist/extensions/agent-browser/lib/browser-journal-branch.js +98 -0
  13. package/dist/extensions/agent-browser/lib/browser-journal-contracts.js +1 -0
  14. package/dist/extensions/agent-browser/lib/browser-journal-projection.js +221 -0
  15. package/dist/extensions/agent-browser/lib/browser-journal-reader.js +89 -0
  16. package/dist/extensions/agent-browser/lib/browser-journal-replay.js +246 -0
  17. package/dist/extensions/agent-browser/lib/browser-journal.js +103 -394
  18. package/dist/extensions/agent-browser/lib/browser-legacy-pages.js +220 -0
  19. package/dist/extensions/agent-browser/lib/browser-legacy-projection.js +282 -0
  20. package/dist/extensions/agent-browser/lib/browser-legacy-types.js +1 -0
  21. package/dist/extensions/agent-browser/lib/browser-session-conversion-stream.js +217 -0
  22. package/dist/extensions/agent-browser/lib/browser-session-conversion.js +80 -335
  23. package/dist/extensions/agent-browser/lib/browser-transcript-contracts.js +35 -0
  24. package/dist/extensions/agent-browser/lib/browser-transcript-validation.js +166 -0
  25. package/dist/extensions/agent-browser/lib/browser-transcript.js +137 -82
  26. package/dist/extensions/agent-browser/lib/browser-value-parsing.js +15 -0
  27. package/dist/extensions/agent-browser/lib/command-capabilities.js +340 -0
  28. package/dist/extensions/agent-browser/lib/command-policy.js +107 -88
  29. package/dist/extensions/agent-browser/lib/command-taxonomy.js +49 -322
  30. package/dist/extensions/agent-browser/lib/config-policy.js +138 -343
  31. package/dist/extensions/agent-browser/lib/config-providers.js +71 -0
  32. package/dist/extensions/agent-browser/lib/config-validation.js +218 -0
  33. package/dist/extensions/agent-browser/lib/config.js +19 -7
  34. package/dist/extensions/agent-browser/lib/electron/cdp.js +15 -7
  35. package/dist/extensions/agent-browser/lib/electron/cleanup.js +134 -55
  36. package/dist/extensions/agent-browser/lib/electron/discovery-darwin.js +109 -0
  37. package/dist/extensions/agent-browser/lib/electron/discovery-desktop.js +136 -0
  38. package/dist/extensions/agent-browser/lib/electron/discovery-evidence.js +89 -0
  39. package/dist/extensions/agent-browser/lib/electron/discovery-linux.js +93 -0
  40. package/dist/extensions/agent-browser/lib/electron/discovery-packages.js +162 -0
  41. package/dist/extensions/agent-browser/lib/electron/discovery-types.js +2 -0
  42. package/dist/extensions/agent-browser/lib/electron/discovery.js +140 -549
  43. package/dist/extensions/agent-browser/lib/electron/launch-monitor.js +102 -0
  44. package/dist/extensions/agent-browser/lib/electron/launch-process.js +209 -0
  45. package/dist/extensions/agent-browser/lib/electron/launch-types.js +2 -0
  46. package/dist/extensions/agent-browser/lib/electron/launch.js +249 -354
  47. package/dist/extensions/agent-browser/lib/executable-path.js +21 -12
  48. package/dist/extensions/agent-browser/lib/execution-cwd.js +35 -18
  49. package/dist/extensions/agent-browser/lib/input-modes/electron.js +162 -121
  50. package/dist/extensions/agent-browser/lib/input-modes/job.js +116 -313
  51. package/dist/extensions/agent-browser/lib/input-modes/lookup-network-evidence.js +104 -0
  52. package/dist/extensions/agent-browser/lib/input-modes/lookup-plan.js +132 -0
  53. package/dist/extensions/agent-browser/lib/input-modes/lookup-redaction.js +57 -0
  54. package/dist/extensions/agent-browser/lib/input-modes/lookup-source-evidence.js +151 -0
  55. package/dist/extensions/agent-browser/lib/input-modes/lookup-workspace.js +142 -0
  56. package/dist/extensions/agent-browser/lib/input-modes/lookups.js +57 -412
  57. package/dist/extensions/agent-browser/lib/input-modes/params.js +63 -17
  58. package/dist/extensions/agent-browser/lib/input-modes/qa-analysis.js +268 -0
  59. package/dist/extensions/agent-browser/lib/input-modes/qa-presentation.js +117 -0
  60. package/dist/extensions/agent-browser/lib/input-modes/script-child.js +396 -0
  61. package/dist/extensions/agent-browser/lib/input-modes/script-protocol.js +86 -0
  62. package/dist/extensions/agent-browser/lib/input-modes/script-types.js +1 -0
  63. package/dist/extensions/agent-browser/lib/input-modes/script-validation.js +60 -0
  64. package/dist/extensions/agent-browser/lib/input-modes/script.js +60 -409
  65. package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +218 -128
  66. package/dist/extensions/agent-browser/lib/input-modes/shared.js +15 -4
  67. package/dist/extensions/agent-browser/lib/input-modes/types.js +56 -7
  68. package/dist/extensions/agent-browser/lib/json-schema.js +22 -10
  69. package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +17 -5
  70. package/dist/extensions/agent-browser/lib/managed-session-policy-lock.js +92 -425
  71. package/dist/extensions/agent-browser/lib/managed-session-posix-storage.js +58 -0
  72. package/dist/extensions/agent-browser/lib/managed-session-project-identity.js +244 -0
  73. package/dist/extensions/agent-browser/lib/managed-session-restore-context.js +84 -0
  74. package/dist/extensions/agent-browser/lib/managed-session-restore-policy.js +119 -0
  75. package/dist/extensions/agent-browser/lib/managed-session-restore-state.js +83 -0
  76. package/dist/extensions/agent-browser/lib/managed-session-restore.js +168 -300
  77. package/dist/extensions/agent-browser/lib/managed-session-snapshot-records.js +277 -0
  78. package/dist/extensions/agent-browser/lib/managed-session-snapshots.js +128 -305
  79. package/dist/extensions/agent-browser/lib/managed-session-storage.js +56 -253
  80. package/dist/extensions/agent-browser/lib/native-confirmation.js +140 -0
  81. package/dist/extensions/agent-browser/lib/native-output.js +43 -9
  82. package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +106 -59
  83. package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-merge.js +14 -6
  84. package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-paths.js +109 -57
  85. package/dist/extensions/agent-browser/lib/orchestration/browser-run/browser-observation-result.js +82 -0
  86. package/dist/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.js +164 -60
  87. package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostic-values.js +31 -0
  88. package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +152 -781
  89. package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-observation.js +202 -0
  90. package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-text-diagnostics.js +109 -0
  91. package/dist/extensions/agent-browser/lib/orchestration/browser-run/fill-diagnostics.js +119 -0
  92. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-action-recovery.js +147 -0
  93. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-actions.js +144 -0
  94. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-content.js +123 -0
  95. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-contracts.js +1 -0
  96. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-details.js +156 -0
  97. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-electron.js +179 -0
  98. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-evidence.js +39 -0
  99. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-missing-binary.js +89 -0
  100. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-recovery.js +97 -0
  101. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-redaction.js +106 -0
  102. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-timeout.js +110 -0
  103. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +41 -538
  104. package/dist/extensions/agent-browser/lib/orchestration/browser-run/index.js +199 -154
  105. package/dist/extensions/agent-browser/lib/orchestration/browser-run/interaction-diagnostics.js +290 -0
  106. package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-close.js +167 -0
  107. package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-inspection.js +108 -0
  108. package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js +127 -205
  109. package/dist/extensions/agent-browser/lib/orchestration/browser-run/native-helper-observation.js +65 -0
  110. package/dist/extensions/agent-browser/lib/orchestration/browser-run/observation-types.js +1 -0
  111. package/dist/extensions/agent-browser/lib/orchestration/browser-run/overlay-diagnostics.js +120 -0
  112. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +113 -30
  113. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +109 -28
  114. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter-data.js +150 -0
  115. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +138 -253
  116. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-rendered-text.js +147 -0
  117. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/wait-timeouts.js +59 -24
  118. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-artifacts.js +159 -0
  119. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-command.js +131 -0
  120. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-contracts.js +1 -0
  121. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-daemon.js +93 -0
  122. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-failure.js +42 -0
  123. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-guards.js +242 -0
  124. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-input.js +75 -0
  125. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-observations.js +92 -0
  126. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-selection.js +254 -0
  127. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-state.js +121 -0
  128. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-refs.js +130 -0
  129. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-resources.js +114 -0
  130. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-semantic.js +121 -0
  131. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-session-plan.js +222 -0
  132. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-timeouts.js +68 -0
  133. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +176 -1123
  134. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-analysis.js +191 -0
  135. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-confirmation.js +152 -0
  136. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-diagnostics.js +182 -0
  137. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-electron.js +150 -0
  138. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-contracts.js +1 -0
  139. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase-contracts.js +1 -0
  140. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase.js +115 -0
  141. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle.js +256 -0
  142. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed-contracts.js +1 -0
  143. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed.js +256 -0
  144. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase-contracts.js +1 -0
  145. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase.js +93 -0
  146. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native.js +113 -0
  147. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation-contracts.js +1 -0
  148. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation.js +316 -0
  149. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-ownership.js +28 -0
  150. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase-contracts.js +1 -0
  151. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase.js +142 -0
  152. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation-contracts.js +1 -0
  153. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation.js +333 -0
  154. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase-contracts.js +1 -0
  155. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase.js +71 -0
  156. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication.js +201 -0
  157. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-receipts.js +183 -0
  158. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-refs.js +200 -0
  159. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-tabs.js +142 -0
  160. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +18 -968
  161. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.js +23 -13
  162. package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-receipt-reconciliation.js +198 -0
  163. package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-contracts.js +1 -0
  164. package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-presentation.js +154 -0
  165. package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery.js +68 -151
  166. package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-capture.js +14 -0
  167. package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-observation.js +169 -46
  168. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-commands.js +130 -0
  169. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-electron.js +210 -0
  170. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-observations.js +61 -0
  171. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-outcomes.js +187 -0
  172. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-refs.js +171 -0
  173. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-tabs.js +228 -0
  174. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +77 -765
  175. package/dist/extensions/agent-browser/lib/orchestration/browser-run/text-visibility-diagnostics.js +182 -0
  176. package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-diagnostics.js +256 -0
  177. package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-progress.js +108 -0
  178. package/dist/extensions/agent-browser/lib/orchestration/code-artifact-observation.js +39 -0
  179. package/dist/extensions/agent-browser/lib/orchestration/code-image-observation.js +119 -0
  180. package/dist/extensions/agent-browser/lib/orchestration/electron-host/branch.js +92 -0
  181. package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup-result.js +58 -0
  182. package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup.js +78 -0
  183. package/dist/extensions/agent-browser/lib/orchestration/electron-host/contracts.js +1 -0
  184. package/dist/extensions/agent-browser/lib/orchestration/electron-host/discovery.js +106 -0
  185. package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +48 -821
  186. package/dist/extensions/agent-browser/lib/orchestration/electron-host/policy.js +86 -0
  187. package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-collection.js +69 -0
  188. package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-data.js +167 -0
  189. package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-presentation.js +164 -0
  190. package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe.js +161 -0
  191. package/dist/extensions/agent-browser/lib/orchestration/electron-host/status.js +165 -0
  192. package/dist/extensions/agent-browser/lib/orchestration/execution-queue.js +21 -9
  193. package/dist/extensions/agent-browser/lib/orchestration/extension-artifact-preflight.js +211 -0
  194. package/dist/extensions/agent-browser/lib/orchestration/extension-artifacts.js +23 -0
  195. package/dist/extensions/agent-browser/lib/orchestration/extension-attachment-replay.js +99 -0
  196. package/dist/extensions/agent-browser/lib/orchestration/extension-branch-restore.js +275 -0
  197. package/dist/extensions/agent-browser/lib/orchestration/extension-code.js +280 -0
  198. package/dist/extensions/agent-browser/lib/orchestration/extension-command-admission.js +303 -0
  199. package/dist/extensions/agent-browser/lib/orchestration/extension-command-output.js +36 -0
  200. package/dist/extensions/agent-browser/lib/orchestration/extension-command-result.js +335 -0
  201. package/dist/extensions/agent-browser/lib/orchestration/extension-command-run.js +227 -0
  202. package/dist/extensions/agent-browser/lib/orchestration/extension-command-state.js +1 -0
  203. package/dist/extensions/agent-browser/lib/orchestration/extension-electron-ownership.js +204 -0
  204. package/dist/extensions/agent-browser/lib/orchestration/extension-execution-locks.js +139 -0
  205. package/dist/extensions/agent-browser/lib/orchestration/extension-execution-queue.js +24 -0
  206. package/dist/extensions/agent-browser/lib/orchestration/extension-host-coordination.js +98 -0
  207. package/dist/extensions/agent-browser/lib/orchestration/extension-host-run.js +295 -0
  208. package/dist/extensions/agent-browser/lib/orchestration/extension-intent-replay.js +41 -0
  209. package/dist/extensions/agent-browser/lib/orchestration/extension-invocation.js +7 -0
  210. package/dist/extensions/agent-browser/lib/orchestration/extension-lifecycle.js +102 -0
  211. package/dist/extensions/agent-browser/lib/orchestration/extension-managed-ownership.js +133 -0
  212. package/dist/extensions/agent-browser/lib/orchestration/extension-observation.js +120 -0
  213. package/dist/extensions/agent-browser/lib/orchestration/extension-prompt.js +180 -0
  214. package/dist/extensions/agent-browser/lib/orchestration/extension-recording.js +290 -0
  215. package/dist/extensions/agent-browser/lib/orchestration/extension-resource-contracts.js +1 -0
  216. package/dist/extensions/agent-browser/lib/orchestration/extension-resource-replay.js +269 -0
  217. package/dist/extensions/agent-browser/lib/orchestration/extension-result-state.js +113 -0
  218. package/dist/extensions/agent-browser/lib/orchestration/extension-runtime.js +146 -0
  219. package/dist/extensions/agent-browser/lib/orchestration/extension-script-leases.js +58 -0
  220. package/dist/extensions/agent-browser/lib/orchestration/extension-tool-boundary.js +62 -0
  221. package/dist/extensions/agent-browser/lib/orchestration/extension-version-check.js +54 -0
  222. package/dist/extensions/agent-browser/lib/orchestration/input-plan-types.js +1 -0
  223. package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +261 -185
  224. package/dist/extensions/agent-browser/lib/orchestration/input-redaction.js +62 -0
  225. package/dist/extensions/agent-browser/lib/orchestration/native-config.js +144 -0
  226. package/dist/extensions/agent-browser/lib/orchestration/native-root-launch.js +77 -0
  227. package/dist/extensions/agent-browser/lib/orchestration/native-session-defaults.js +210 -157
  228. package/dist/extensions/agent-browser/lib/orchestration/operation-paths.js +124 -58
  229. package/dist/extensions/agent-browser/lib/orchestration/output-file.js +197 -99
  230. package/dist/extensions/agent-browser/lib/orchestration/script-mode.js +199 -96
  231. package/dist/extensions/agent-browser/lib/owned-managed-session-context.js +55 -0
  232. package/dist/extensions/agent-browser/lib/page-target-batch.js +118 -0
  233. package/dist/extensions/agent-browser/lib/page-target-guards.js +50 -0
  234. package/dist/extensions/agent-browser/lib/page-target-navigation.js +104 -0
  235. package/dist/extensions/agent-browser/lib/page-target-validation.js +55 -246
  236. package/dist/extensions/agent-browser/lib/parsing.js +13 -4
  237. package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +133 -68
  238. package/dist/extensions/agent-browser/lib/playbook.js +16 -12
  239. package/dist/extensions/agent-browser/lib/process-child.js +284 -0
  240. package/dist/extensions/agent-browser/lib/process-environment.js +13 -6
  241. package/dist/extensions/agent-browser/lib/process-errors.js +23 -0
  242. package/dist/extensions/agent-browser/lib/process-identity.js +47 -15
  243. package/dist/extensions/agent-browser/lib/process-socket-storage.js +256 -0
  244. package/dist/extensions/agent-browser/lib/process-stdout.js +74 -0
  245. package/dist/extensions/agent-browser/lib/process.js +145 -536
  246. package/dist/extensions/agent-browser/lib/prompt-artifacts.js +287 -0
  247. package/dist/extensions/agent-browser/lib/prompt-policy.js +15 -194
  248. package/dist/extensions/agent-browser/lib/read-command.js +41 -0
  249. package/dist/extensions/agent-browser/lib/read-confirmation.js +131 -68
  250. package/dist/extensions/agent-browser/lib/recording-reservations.js +118 -45
  251. package/dist/extensions/agent-browser/lib/redaction-fields.js +75 -0
  252. package/dist/extensions/agent-browser/lib/redaction-json.js +149 -0
  253. package/dist/extensions/agent-browser/lib/redaction-url.js +88 -0
  254. package/dist/extensions/agent-browser/lib/results/action-contracts.js +1 -0
  255. package/dist/extensions/agent-browser/lib/results/action-recommendations.js +28 -271
  256. package/dist/extensions/agent-browser/lib/results/artifact-contracts.js +1 -0
  257. package/dist/extensions/agent-browser/lib/results/artifact-manifest-validation.js +133 -0
  258. package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +96 -94
  259. package/dist/extensions/agent-browser/lib/results/artifact-recommendations.js +73 -0
  260. package/dist/extensions/agent-browser/lib/results/categories.js +111 -54
  261. package/dist/extensions/agent-browser/lib/results/confirmation.js +29 -13
  262. package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +62 -27
  263. package/dist/extensions/agent-browser/lib/results/electron-recommendations.js +83 -0
  264. package/dist/extensions/agent-browser/lib/results/envelope-decoding.js +48 -0
  265. package/dist/extensions/agent-browser/lib/results/envelope.js +90 -67
  266. package/dist/extensions/agent-browser/lib/results/evidence-contracts.js +1 -0
  267. package/dist/extensions/agent-browser/lib/results/failure-recommendations.js +180 -0
  268. package/dist/extensions/agent-browser/lib/results/network-routes.js +86 -45
  269. package/dist/extensions/agent-browser/lib/results/network.js +35 -12
  270. package/dist/extensions/agent-browser/lib/results/next-actions.js +49 -19
  271. package/dist/extensions/agent-browser/lib/results/presentation/artifact-files.js +320 -0
  272. package/dist/extensions/agent-browser/lib/results/presentation/artifact-format.js +138 -0
  273. package/dist/extensions/agent-browser/lib/results/presentation/artifact-images.js +113 -0
  274. package/dist/extensions/agent-browser/lib/results/presentation/artifact-verification.js +145 -0
  275. package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +99 -555
  276. package/dist/extensions/agent-browser/lib/results/presentation/batch-contracts.js +1 -0
  277. package/dist/extensions/agent-browser/lib/results/presentation/batch-recording.js +118 -0
  278. package/dist/extensions/agent-browser/lib/results/presentation/batch-redaction.js +68 -0
  279. package/dist/extensions/agent-browser/lib/results/presentation/batch-rendering.js +135 -0
  280. package/dist/extensions/agent-browser/lib/results/presentation/batch-step.js +227 -0
  281. package/dist/extensions/agent-browser/lib/results/presentation/batch-summary.js +91 -0
  282. package/dist/extensions/agent-browser/lib/results/presentation/batch.js +91 -460
  283. package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +9 -5
  284. package/dist/extensions/agent-browser/lib/results/presentation/command-presenters.js +216 -0
  285. package/dist/extensions/agent-browser/lib/results/presentation/common.js +26 -9
  286. package/dist/extensions/agent-browser/lib/results/presentation/content.js +86 -29
  287. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-a11y.js +67 -0
  288. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-health.js +79 -0
  289. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-identity.js +199 -0
  290. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-logs.js +75 -0
  291. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network-actions.js +216 -0
  292. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network.js +124 -0
  293. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-redaction.js +64 -0
  294. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-storage.js +209 -0
  295. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-stream.js +69 -0
  296. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-summary.js +222 -0
  297. package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +103 -1052
  298. package/dist/extensions/agent-browser/lib/results/presentation/early-result.js +70 -0
  299. package/dist/extensions/agent-browser/lib/results/presentation/errors.js +130 -60
  300. package/dist/extensions/agent-browser/lib/results/presentation/input-contracts.js +1 -0
  301. package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +60 -145
  302. package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +147 -88
  303. package/dist/extensions/agent-browser/lib/results/presentation/notices.js +75 -0
  304. package/dist/extensions/agent-browser/lib/results/presentation/observation-contracts.js +1 -0
  305. package/dist/extensions/agent-browser/lib/results/presentation/observation-rendering.js +127 -0
  306. package/dist/extensions/agent-browser/lib/results/presentation/outcomes.js +120 -0
  307. package/dist/extensions/agent-browser/lib/results/presentation/output-completion.js +77 -0
  308. package/dist/extensions/agent-browser/lib/results/presentation/output-spill.js +51 -0
  309. package/dist/extensions/agent-browser/lib/results/presentation/registry.js +116 -240
  310. package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +35 -21
  311. package/dist/extensions/agent-browser/lib/results/presentation/skills.js +104 -73
  312. package/dist/extensions/agent-browser/lib/results/presentation/source.js +109 -0
  313. package/dist/extensions/agent-browser/lib/results/presentation.js +17 -261
  314. package/dist/extensions/agent-browser/lib/results/recommendation-contracts.js +1 -0
  315. package/dist/extensions/agent-browser/lib/results/recording.js +52 -14
  316. package/dist/extensions/agent-browser/lib/results/recovery-actions.js +14 -5
  317. package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +30 -22
  318. package/dist/extensions/agent-browser/lib/results/selector-recovery-target.js +83 -0
  319. package/dist/extensions/agent-browser/lib/results/selector-recovery.js +119 -119
  320. package/dist/extensions/agent-browser/lib/results/snapshot-compact.js +266 -0
  321. package/dist/extensions/agent-browser/lib/results/snapshot-content.js +32 -0
  322. package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +104 -71
  323. package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +31 -11
  324. package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +125 -66
  325. package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +26 -7
  326. package/dist/extensions/agent-browser/lib/results/snapshot.js +28 -248
  327. package/dist/extensions/agent-browser/lib/results/text.js +16 -5
  328. package/dist/extensions/agent-browser/lib/runtime-args-validation.js +133 -0
  329. package/dist/extensions/agent-browser/lib/runtime-compatibility.js +81 -0
  330. package/dist/extensions/agent-browser/lib/runtime-contracts.js +1 -0
  331. package/dist/extensions/agent-browser/lib/runtime-redaction.js +118 -0
  332. package/dist/extensions/agent-browser/lib/runtime-replay-events.js +144 -0
  333. package/dist/extensions/agent-browser/lib/runtime-session-identity.js +76 -0
  334. package/dist/extensions/agent-browser/lib/runtime-session-plan.js +114 -0
  335. package/dist/extensions/agent-browser/lib/runtime-session-replay.js +123 -0
  336. package/dist/extensions/agent-browser/lib/runtime-tab-correction.js +65 -0
  337. package/dist/extensions/agent-browser/lib/runtime-timeouts.js +28 -0
  338. package/dist/extensions/agent-browser/lib/runtime.js +137 -1041
  339. package/dist/extensions/agent-browser/lib/session-identity.js +51 -0
  340. package/dist/extensions/agent-browser/lib/session-page-observation.js +357 -0
  341. package/dist/extensions/agent-browser/lib/session-page-state.js +178 -333
  342. package/dist/extensions/agent-browser/lib/session-page-types.js +1 -0
  343. package/dist/extensions/agent-browser/lib/temp-artifact-budget.js +78 -0
  344. package/dist/extensions/agent-browser/lib/temp-mutation-queue.js +7 -0
  345. package/dist/extensions/agent-browser/lib/temp-root-ownership.js +234 -0
  346. package/dist/extensions/agent-browser/lib/temp-root.js +207 -0
  347. package/dist/extensions/agent-browser/lib/temp.js +33 -446
  348. package/dist/extensions/agent-browser/lib/tool-surface.js +94 -24
  349. package/dist/extensions/agent-browser/lib/upstream-version.js +3 -2
  350. package/dist/extensions/agent-browser/lib/web-search-providers.js +229 -0
  351. package/dist/extensions/agent-browser/lib/web-search-request.js +108 -0
  352. package/dist/extensions/agent-browser/lib/web-search-results.js +281 -0
  353. package/dist/extensions/agent-browser/lib/web-search-schema.js +82 -0
  354. package/dist/extensions/agent-browser/lib/web-search.js +109 -617
  355. package/dist/extensions/agent-browser/lib/webmcp-observation.js +13 -6
  356. package/dist/extensions/agent-browser/lib/windows-stock-launcher.js +63 -37
  357. package/dist/extensions/agent-browser/script-worker.js +80 -43
  358. package/dist/scripts/agent-browser-target.mjs +4 -2
  359. package/docs/ARCHITECTURE.md +17 -5
  360. package/docs/CODE_QUALITY.md +242 -0
  361. package/docs/COMMAND_REFERENCE.md +251 -220
  362. package/docs/ELECTRON.md +53 -44
  363. package/docs/RELEASE.md +18 -15
  364. package/docs/REQUIREMENTS.md +1 -0
  365. package/docs/SUPPORT_MATRIX.md +76 -75
  366. package/docs/TOOL_CONTRACT.md +145 -116
  367. package/docs/platform-smoke.md +5 -5
  368. package/package.json +143 -120
  369. package/scripts/agent-browser-capability-baseline.mjs +361 -957
  370. package/scripts/agent-browser-target.mjs +6 -2
  371. package/scripts/build.mjs +37 -8
  372. package/scripts/capability-core-commands.mjs +193 -0
  373. package/scripts/capability-options.mjs +283 -0
  374. package/scripts/capability-samples.mjs +133 -0
  375. package/scripts/capability-section.mjs +11 -0
  376. package/scripts/config.mjs +213 -114
  377. package/scripts/convert-browser-session.mjs +30 -9
  378. package/scripts/doctor-sources.mjs +195 -0
  379. package/scripts/doctor.mjs +92 -247
  380. package/scripts/platform-smoke/artifacts.mjs +38 -11
  381. package/scripts/platform-smoke/commands.mjs +104 -0
  382. package/scripts/platform-smoke/crabbox-runner.mjs +167 -80
  383. package/scripts/platform-smoke/doctor-support.mjs +157 -0
  384. package/scripts/platform-smoke/doctor-windows.mjs +230 -0
  385. package/scripts/platform-smoke/doctor.mjs +212 -320
  386. package/scripts/platform-smoke/lease-evidence.mjs +134 -0
  387. package/scripts/platform-smoke/suite-checks.mjs +98 -0
  388. package/scripts/platform-smoke/suite-evidence.mjs +281 -0
  389. package/scripts/platform-smoke/targets.mjs +158 -472
  390. package/scripts/platform-smoke.mjs +55 -40
  391. package/scripts/prepare.mjs +16 -7
@@ -0,0 +1,118 @@
1
+ import { stat } from "node:fs/promises";
2
+ import { getAgentBrowserSessionIdentityKey } from "../../argv-grammar.js";
3
+ import { extractUpstreamCommandTokens } from "../../argv-descriptor.js";
4
+ import { isCloseCommand } from "../../command-taxonomy.js";
5
+ import { isRecord } from "../../parsing.js";
6
+ import { isPendingRecordingArtifact } from "../artifact-manifest.js";
7
+ async function unverifiedRecordingArtifact(artifact, subcommand) {
8
+ const { recordingState: _recordingState, willExistOnStop: _willExistOnStop, ...terminal } = artifact;
9
+ try {
10
+ const file = await stat(artifact.absolutePath);
11
+ return {
12
+ ...terminal,
13
+ exists: file.isFile(),
14
+ sizeBytes: file.size,
15
+ status: file.isFile() ? "unverified" : "missing",
16
+ subcommand,
17
+ };
18
+ }
19
+ catch (error) {
20
+ const missing = isRecord(error) && error.code === "ENOENT";
21
+ return {
22
+ ...terminal,
23
+ exists: missing ? false : undefined,
24
+ status: missing ? "missing" : "unverified",
25
+ subcommand,
26
+ };
27
+ }
28
+ }
29
+ class TerminalBatchRecordings {
30
+ artifacts = [];
31
+ pendingBySession = new Map();
32
+ removed = new Set();
33
+ session;
34
+ constructor(sessionName, namespace) {
35
+ this.session =
36
+ sessionName !== undefined && sessionName.length > 0
37
+ ? getAgentBrowserSessionIdentityKey(sessionName, namespace)
38
+ : "";
39
+ }
40
+ removeMatchingPending(artifact, session) {
41
+ const pending = this.pendingBySession.get(session) ?? [];
42
+ const matching = pending.map((index) => this.artifacts[index].kind).lastIndexOf(artifact.kind);
43
+ if (matching !== -1) {
44
+ const removed = pending.splice(matching, 1).at(0);
45
+ if (removed !== undefined) {
46
+ this.removed.add(removed);
47
+ }
48
+ }
49
+ return pending;
50
+ }
51
+ append(artifact) {
52
+ const index = this.artifacts.push(artifact) - 1;
53
+ if (artifact.command !== "record") {
54
+ return undefined;
55
+ }
56
+ const session = artifact.session !== undefined && artifact.session.length > 0
57
+ ? getAgentBrowserSessionIdentityKey(artifact.session, artifact.namespace)
58
+ : "";
59
+ if (isPendingRecordingArtifact(artifact)) {
60
+ const pending = this.pendingBySession.get(session) ?? [];
61
+ pending.push(index);
62
+ this.pendingBySession.set(session, pending);
63
+ return undefined;
64
+ }
65
+ const pending = this.removeMatchingPending(artifact, session);
66
+ if (artifact.kind !== "video") {
67
+ return undefined;
68
+ }
69
+ // A terminal video also ends its sheet; a native sheet below replaces this unverified row.
70
+ const sheets = pending.filter((position) => this.artifacts[position].kind === "image" &&
71
+ isPendingRecordingArtifact(this.artifacts[position]));
72
+ return sheets.length > 0 ? sheets : undefined;
73
+ }
74
+ getClosePending(step) {
75
+ const command = step.details.command;
76
+ if (!step.details.success ||
77
+ !command ||
78
+ !isCloseCommand(extractUpstreamCommandTokens(command)[0])) {
79
+ return [];
80
+ }
81
+ return (this.pendingBySession.get(this.session) ?? []).filter((index) => {
82
+ const current = this.artifacts.at(index);
83
+ return (current !== undefined && isPendingRecordingArtifact(current) && !this.removed.has(index));
84
+ });
85
+ }
86
+ async abandon(indices, subcommand) {
87
+ for (const index of indices) {
88
+ const current = this.artifacts.at(index);
89
+ if (current && isPendingRecordingArtifact(current) && !this.removed.has(index)) {
90
+ // Each replacement must finish before later lifecycle rows inspect the same artifact state.
91
+ // oxlint-disable-next-line no-await-in-loop
92
+ this.artifacts[index] = await unverifiedRecordingArtifact(current, subcommand);
93
+ }
94
+ }
95
+ }
96
+ async fold(steps) {
97
+ for (const step of steps) {
98
+ for (const artifact of step.presentation.artifacts ?? []) {
99
+ const sheets = this.append(artifact);
100
+ if (sheets) {
101
+ // Terminal receipt order determines which pending sheet the next row can replace.
102
+ // oxlint-disable-next-line no-await-in-loop
103
+ await this.abandon(sheets, artifact.subcommand ?? "stop");
104
+ }
105
+ }
106
+ const pending = this.getClosePending(step);
107
+ if (pending.length > 0) {
108
+ // Close abandonment must finish before any later recording receipt is folded.
109
+ // oxlint-disable-next-line no-await-in-loop
110
+ await this.abandon(pending, "close-abandoned");
111
+ }
112
+ }
113
+ return this.artifacts.filter((_, index) => !this.removed.has(index));
114
+ }
115
+ }
116
+ export async function coalesceTerminalBatchRecordingArtifacts(steps, sessionName, namespace) {
117
+ return new TerminalBatchRecordings(sessionName, namespace).fold(steps);
118
+ }
@@ -0,0 +1,68 @@
1
+ import { extractUpstreamCommandTokens } from "../../argv-descriptor.js";
2
+ import { redactSensitiveText, redactSensitiveValue } from "../../runtime-redaction.js";
3
+ import { isRecord } from "../../parsing.js";
4
+ import { getClipboardWritePayloadCandidates, redactClipboardPermissionErrorValue, } from "./errors.js";
5
+ export function hasModelFacingArgRedaction(args) {
6
+ return (args?.some((arg) => arg === "[REDACTED]" || arg.includes("%5BREDACTED%5D") || arg.includes("[REDACTED]")) === true);
7
+ }
8
+ function getPasswordValues(tokens) {
9
+ const values = [];
10
+ for (let index = 0; index < tokens.length; index += 1) {
11
+ const token = tokens[index];
12
+ const next = tokens.at(index + 1);
13
+ if (token === "--password" && next !== undefined && next.length > 0) {
14
+ values.push(next);
15
+ }
16
+ else if (token.startsWith("--password=")) {
17
+ values.push(token.slice("--password=".length));
18
+ }
19
+ }
20
+ return values;
21
+ }
22
+ function getStatefulValue(tokens) {
23
+ if (tokens[0] === "cookies" && tokens[1] === "set" && !tokens.slice(2).includes("--curl")) {
24
+ return tokens.at(3);
25
+ }
26
+ if (tokens[0] === "storage" &&
27
+ ["local", "session"].includes(tokens[1] ?? "") &&
28
+ tokens[2] === "set") {
29
+ return tokens.at(4);
30
+ }
31
+ return undefined;
32
+ }
33
+ function getStatefulCommandSensitiveValues(command) {
34
+ if (!command) {
35
+ return [];
36
+ }
37
+ const tokens = extractUpstreamCommandTokens(command);
38
+ const statefulValue = getStatefulValue(tokens);
39
+ const values = getPasswordValues(tokens);
40
+ if (statefulValue !== undefined) {
41
+ values.unshift(statefulValue);
42
+ }
43
+ return values.filter((value) => value.length > 0);
44
+ }
45
+ function redactExactValues(value, sensitiveValues) {
46
+ if (sensitiveValues.length === 0) {
47
+ return redactSensitiveValue(value);
48
+ }
49
+ if (typeof value === "string") {
50
+ let redacted = value;
51
+ for (const sensitive of sensitiveValues) {
52
+ redacted = redacted.split(sensitive).join("[REDACTED]");
53
+ }
54
+ return redactSensitiveText(redacted);
55
+ }
56
+ if (Array.isArray(value)) {
57
+ return value.map((item) => redactExactValues(item, sensitiveValues));
58
+ }
59
+ if (!isRecord(value)) {
60
+ return value;
61
+ }
62
+ return redactSensitiveValue(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redactExactValues(item, sensitiveValues)])));
63
+ }
64
+ export function redactBatchStepErrorData(command, value) {
65
+ return command?.[0] === "clipboard"
66
+ ? redactSensitiveValue(redactClipboardPermissionErrorValue({ command: "clipboard", subcommand: command[1] }, value, getClipboardWritePayloadCandidates(command)))
67
+ : redactExactValues(value, getStatefulCommandSensitiveValues(command));
68
+ }
@@ -0,0 +1,135 @@
1
+ import { getPresentationImages } from "./content.js";
2
+ function getTypedTextLength(command) {
3
+ return command?.[0] === "keyboard" && command[1] === "type" && typeof command.at(2) === "string"
4
+ ? Array.from(command[2]).length
5
+ : undefined;
6
+ }
7
+ function getWaitDelayMs(command) {
8
+ const delay = command?.at(1);
9
+ return command?.[0] === "wait" && delay !== undefined && /^\d+$/.test(delay) ? delay : undefined;
10
+ }
11
+ function getTypingDelayBetween(steps, index) {
12
+ const delay = steps.at(index + 1)?.details;
13
+ const next = steps.at(index + 2)?.details;
14
+ if (!delay ||
15
+ !next ||
16
+ !delay.success ||
17
+ !next.success ||
18
+ getTypedTextLength(next.command) === undefined) {
19
+ return undefined;
20
+ }
21
+ return getWaitDelayMs(delay.command);
22
+ }
23
+ function getTypedPulse(steps, index) {
24
+ const step = steps.at(index)?.details;
25
+ if (!step || !step.success) {
26
+ return undefined;
27
+ }
28
+ const chars = getTypedTextLength(step.command);
29
+ if (chars === undefined) {
30
+ return undefined;
31
+ }
32
+ const delay = getTypingDelayBetween(steps, index);
33
+ return { chars, delay, nextIndex: index + (delay === undefined ? 1 : 2) };
34
+ }
35
+ function scanTypingRun(steps, start) {
36
+ let index = start;
37
+ let typedCharCount = 0;
38
+ let typedStepCount = 0;
39
+ let delayMs;
40
+ while (index < steps.length) {
41
+ const pulse = getTypedPulse(steps, index);
42
+ if (!pulse) {
43
+ break;
44
+ }
45
+ typedCharCount += pulse.chars;
46
+ typedStepCount += 1;
47
+ if (pulse.delay !== undefined) {
48
+ if (delayMs !== undefined && delayMs !== pulse.delay) {
49
+ return undefined;
50
+ }
51
+ delayMs = pulse.delay;
52
+ }
53
+ index = pulse.nextIndex;
54
+ }
55
+ return typedStepCount >= 2 ? { nextIndex: index, typedCharCount, delayMs } : undefined;
56
+ }
57
+ function getTypingStart(steps, index) {
58
+ const details = steps.at(index)?.details;
59
+ if (!details || !details.success) {
60
+ return undefined;
61
+ }
62
+ if (details.command?.[0] === "focus" && typeof details.command.at(1) === "string") {
63
+ return { firstIndex: details.index, typingIndex: index + 1, target: details.command[1] };
64
+ }
65
+ return { firstIndex: details.index, typingIndex: index };
66
+ }
67
+ function getPressAfterTyping(steps, index) {
68
+ const details = steps.at(index)?.details;
69
+ if (!details || !details.success || details.command?.[0] !== "press") {
70
+ return undefined;
71
+ }
72
+ return details.command.at(1);
73
+ }
74
+ function formatTypedSequenceSummary(steps, startIndex) {
75
+ const start = getTypingStart(steps, startIndex);
76
+ if (!start) {
77
+ return undefined;
78
+ }
79
+ const run = scanTypingRun(steps, start.typingIndex);
80
+ if (!run) {
81
+ return undefined;
82
+ }
83
+ const pressedKey = getPressAfterTyping(steps, run.nextIndex);
84
+ const nextIndex = run.nextIndex + (pressedKey !== undefined ? 1 : 0);
85
+ const firstStep = start.firstIndex + 1;
86
+ const lastIndex = steps.at(nextIndex - 1)?.details.index;
87
+ const lastStep = lastIndex === undefined ? undefined : lastIndex + 1;
88
+ const range = lastStep !== undefined && lastStep > firstStep ? `${firstStep}-${lastStep}` : String(firstStep);
89
+ return { nextIndex, text: formatTypingSummaryText(range, start.target, run, pressedKey) };
90
+ }
91
+ function formatTypingSummaryText(range, target, run, pressedKey) {
92
+ const label = target !== undefined && target.length > 0 ? `type ${target}` : "keyboard type";
93
+ const lines = [
94
+ `Step ${range} — ${label} (succeeded)`,
95
+ `Typed ${run.typedCharCount} char${run.typedCharCount === 1 ? "" : "s"}${run.delayMs !== undefined ? ` with delayMs=${run.delayMs}` : ""}.`,
96
+ ];
97
+ if (pressedKey !== undefined && pressedKey.length > 0) {
98
+ lines.push(`Pressed ${pressedKey}.`);
99
+ }
100
+ return lines.join("\n");
101
+ }
102
+ function formatBatchStepDetails(step) {
103
+ const details = step.details;
104
+ const images = getPresentationImages(step.presentation).length;
105
+ const lines = [
106
+ `Step ${details.index + 1} — ${details.commandText} (${details.success ? "succeeded" : "failed"})`,
107
+ ];
108
+ if (details.text.length > 0) {
109
+ lines.push(details.text);
110
+ }
111
+ if (images > 0) {
112
+ lines.push(`(${images} inline image attachment${images === 1 ? "" : "s"} below)`);
113
+ }
114
+ return lines.join("\n");
115
+ }
116
+ export function formatBatchStepsText(steps) {
117
+ if (steps.length === 0) {
118
+ return "(no batch steps)";
119
+ }
120
+ const lines = [];
121
+ for (let index = 0; index < steps.length;) {
122
+ const sequence = formatTypedSequenceSummary(steps, index);
123
+ if (sequence) {
124
+ lines.push(sequence.text);
125
+ index = sequence.nextIndex;
126
+ continue;
127
+ }
128
+ const step = steps.at(index);
129
+ if (step) {
130
+ lines.push(formatBatchStepDetails(step));
131
+ }
132
+ index += 1;
133
+ }
134
+ return lines.join("\n\n");
135
+ }
@@ -0,0 +1,227 @@
1
+ import { parseCommandInfo } from "../../argv-descriptor.js";
2
+ import { isRecord } from "../../parsing.js";
3
+ import { redactInvocationArgs } from "../../runtime-redaction.js";
4
+ import { buildAgentBrowserNextActions } from "../action-recommendations.js";
5
+ import { buildPendingWebMcpNextActions } from "../recovery-next-actions.js";
6
+ import { classifyAgentBrowserFailureCategory } from "../categories.js";
7
+ import { detectConfirmationRequired } from "../confirmation.js";
8
+ import { applyNamespaceToNextActions, withOptionalSessionArgs } from "../next-actions.js";
9
+ import { buildNetworkRouteDiagnostics } from "../network-routes.js";
10
+ import { extractAgentBrowserLifecycle, stringifyModelFacing } from "./common.js";
11
+ import { classifyPresentationSuccessCategory } from "./artifacts.js";
12
+ import { formatBatchStepCommand, getPresentationPaths, getPresentationText, isStringArray, } from "./content.js";
13
+ import { buildPageChangeSummary } from "./navigation.js";
14
+ import { appendSelectorRecoveryHint, isOverlayBlockedClickError } from "./errors.js";
15
+ import { hasModelFacingArgRedaction, redactBatchStepErrorData } from "./batch-redaction.js";
16
+ function createStepIdentity(item, index) {
17
+ const command = isStringArray(item.command) ? item.command : undefined;
18
+ const redactedCommand = command ? redactInvocationArgs(command) : undefined;
19
+ return {
20
+ command,
21
+ redactedCommand,
22
+ index,
23
+ commandText: formatBatchStepCommand(hasModelFacingArgRedaction(redactedCommand) ? redactedCommand : command, index),
24
+ lifecycle: extractAgentBrowserLifecycle(item.result),
25
+ };
26
+ }
27
+ function formatBatchStepError(error) {
28
+ const text = stringifyModelFacing(error).trim();
29
+ return appendSelectorRecoveryHint(text.length > 0 ? `Error: ${text}` : "Error: batch step failed.");
30
+ }
31
+ function buildWaitTextAssertionFailureAction(sessionName) {
32
+ return {
33
+ id: "inspect-after-text-assertion-failure",
34
+ params: { args: withOptionalSessionArgs(sessionName, ["snapshot", "-i"]) },
35
+ reason: "Inspect the current page after the text assertion failed before concluding the expected text is absent.",
36
+ safety: "Read-only snapshot; use current refs or visible text from this page before retrying the assertion.",
37
+ tool: "agent_browser",
38
+ };
39
+ }
40
+ function describeStepFailure(command, error) {
41
+ const data = redactBatchStepErrorData(command, error);
42
+ const text = formatBatchStepError(data);
43
+ return {
44
+ data,
45
+ text,
46
+ category: classifyAgentBrowserFailureCategory({
47
+ args: command,
48
+ command: command?.[0],
49
+ errorText: text,
50
+ }),
51
+ confirmationId: detectConfirmationRequired(error)?.id,
52
+ overlayBlocked: isOverlayBlockedClickError(command?.[0], text, command),
53
+ };
54
+ }
55
+ function buildFailedStepActions(command, failure, scope) {
56
+ const recovery = buildAgentBrowserNextActions({
57
+ args: command,
58
+ command: command?.[0],
59
+ confirmationId: failure.confirmationId,
60
+ failureCategory: failure.category,
61
+ overlayBlockedClick: failure.overlayBlocked,
62
+ resultCategory: "failure",
63
+ sessionName: scope.sessionName,
64
+ subcommand: command?.[1],
65
+ });
66
+ const waitAction = command?.[0] === "wait" && command.includes("--text")
67
+ ? [buildWaitTextAssertionFailureAction(scope.sessionName)]
68
+ : [];
69
+ const seen = new Set();
70
+ const actions = [...waitAction, ...(recovery ?? [])].filter((action) => {
71
+ if (seen.has(action.id)) {
72
+ return false;
73
+ }
74
+ seen.add(action.id);
75
+ return true;
76
+ });
77
+ return applyNamespaceToNextActions(actions.length > 0 ? actions : undefined, scope.namespace);
78
+ }
79
+ function buildFailedStep(item, identity, scope) {
80
+ const failure = describeStepFailure(identity.command, item.error);
81
+ const { data, text, category: failureCategory } = failure;
82
+ const nextActions = buildFailedStepActions(identity.command, failure, scope);
83
+ const presentation = {
84
+ content: [{ type: "text", text }],
85
+ failureCategory,
86
+ nextActions,
87
+ resultCategory: "failure",
88
+ summary: text,
89
+ };
90
+ return {
91
+ presentation,
92
+ details: {
93
+ artifactVerification: presentation.artifactVerification,
94
+ artifacts: presentation.artifacts,
95
+ command: identity.redactedCommand,
96
+ commandText: identity.commandText,
97
+ data,
98
+ failureCategory,
99
+ index: identity.index,
100
+ lifecycle: identity.lifecycle,
101
+ nextActions,
102
+ resultCategory: "failure",
103
+ success: false,
104
+ summary: text,
105
+ text,
106
+ },
107
+ };
108
+ }
109
+ function buildNestedRequest(options, command) {
110
+ const commandInfo = parseCommandInfo(command ?? []);
111
+ return {
112
+ modelVisible: options.modelVisible,
113
+ artifactManifest: options.artifactManifest,
114
+ artifactMaxUpdatedAtMs: options.artifactMaxUpdatedAtMs,
115
+ artifactMinUpdatedAtMs: options.artifactMinUpdatedAtMs,
116
+ artifactRequest: options.artifactRequest,
117
+ commandInfo: command ? { ...commandInfo, commandTokens: command } : commandInfo,
118
+ cwd: options.cwd,
119
+ args: command,
120
+ envelope: {
121
+ data: options.item.result,
122
+ success: options.item.success !== false,
123
+ error: options.item.error,
124
+ },
125
+ errorText: options.item.success === false
126
+ ? formatBatchStepError(redactBatchStepErrorData(command, options.item.error))
127
+ : undefined,
128
+ piCleanupOwnership: options.piCleanupOwnership,
129
+ networkRouteDiagnostics: commandInfo.command === "network" && commandInfo.subcommand === "requests"
130
+ ? buildNetworkRouteDiagnostics(options.item.result, options.networkRoutes)
131
+ : undefined,
132
+ namespace: options.namespace,
133
+ persistentArtifactStore: options.persistentArtifactStore,
134
+ sessionName: options.sessionName,
135
+ };
136
+ }
137
+ function isPendingWebMcpMutation(command, data) {
138
+ return (command.command === "webmcp" &&
139
+ ["invoke", "result"].includes(command.subcommand ?? "") &&
140
+ isRecord(data) &&
141
+ data.status === "pending");
142
+ }
143
+ function buildStandardStepActions(presentation, command, sessionName) {
144
+ return (presentation.nextActions ??
145
+ buildAgentBrowserNextActions({
146
+ artifacts: presentation.artifacts,
147
+ args: command,
148
+ command: command?.[0],
149
+ failureCategory: presentation.failureCategory,
150
+ resultCategory: presentation.resultCategory !== "failure" ? "success" : "failure",
151
+ savedFilePath: presentation.savedFilePath,
152
+ sessionName,
153
+ subcommand: command?.[1],
154
+ successCategory: presentation.successCategory,
155
+ }));
156
+ }
157
+ function getStepNextActions(presentation, commandInfo, command, scope) {
158
+ const actions = presentation.resultCategory !== "failure" &&
159
+ isPendingWebMcpMutation(commandInfo, presentation.data)
160
+ ? buildPendingWebMcpNextActions(scope.sessionName)
161
+ : buildStandardStepActions(presentation, command, scope.sessionName);
162
+ return applyNamespaceToNextActions(actions, scope.namespace);
163
+ }
164
+ function buildStepDetails(presentation, identity, command, scope) {
165
+ const fullOutputPaths = getPresentationPaths({
166
+ primaryPath: presentation.fullOutputPath,
167
+ secondaryPaths: presentation.fullOutputPaths,
168
+ });
169
+ const imagePaths = getPresentationPaths({
170
+ primaryPath: presentation.imagePath,
171
+ secondaryPaths: presentation.imagePaths,
172
+ });
173
+ const text = getPresentationText(presentation);
174
+ const succeeded = presentation.resultCategory !== "failure";
175
+ const nextActions = getStepNextActions(presentation, command, identity.command, scope);
176
+ return {
177
+ artifactVerification: presentation.artifactVerification,
178
+ artifacts: presentation.artifacts,
179
+ command: identity.redactedCommand,
180
+ commandText: identity.commandText,
181
+ data: presentation.data,
182
+ failureCategory: succeeded ? undefined : presentation.failureCategory,
183
+ fullOutputPath: fullOutputPaths.at(0),
184
+ fullOutputPaths: fullOutputPaths.length > 0 ? fullOutputPaths : undefined,
185
+ imagePath: imagePaths.at(0),
186
+ imagePaths: imagePaths.length > 0 ? imagePaths : undefined,
187
+ imageObservations: presentation.imageObservations,
188
+ index: identity.index,
189
+ lifecycle: identity.lifecycle,
190
+ networkRouteDiagnostics: presentation.networkRouteDiagnostics,
191
+ nextActions,
192
+ pageChangeSummary: buildPageChangeSummary({
193
+ artifacts: presentation.artifacts,
194
+ commandInfo: command,
195
+ data: presentation.data,
196
+ nextActions,
197
+ savedFilePath: presentation.savedFilePath,
198
+ summary: presentation.summary,
199
+ }),
200
+ resultCategory: succeeded ? "success" : "failure",
201
+ savedFile: presentation.savedFile,
202
+ savedFilePath: presentation.savedFilePath,
203
+ success: succeeded,
204
+ successCategory: succeeded
205
+ ? classifyPresentationSuccessCategory({
206
+ artifactVerification: presentation.artifactVerification,
207
+ artifacts: presentation.artifacts,
208
+ savedFile: presentation.savedFile,
209
+ })
210
+ : undefined,
211
+ summary: presentation.summary,
212
+ text: text.length > 0 ? text : presentation.summary,
213
+ };
214
+ }
215
+ export async function buildBatchStepPresentation(options) {
216
+ const identity = createStepIdentity(options.item, options.index);
217
+ const scope = { namespace: options.namespace, sessionName: options.sessionName };
218
+ if (options.item.success === false && identity.command?.[0] !== "record") {
219
+ return buildFailedStep(options.item, identity, scope);
220
+ }
221
+ const request = buildNestedRequest(options, identity.command);
222
+ const presentation = await options.buildNestedToolPresentation(request);
223
+ return {
224
+ details: buildStepDetails(presentation, identity, request.commandInfo, scope),
225
+ presentation,
226
+ };
227
+ }
@@ -0,0 +1,91 @@
1
+ import { formatBatchStepsText } from "./batch-rendering.js";
2
+ import { buildPageChangeSummary } from "./navigation.js";
3
+ function getBatchFailure(steps) {
4
+ const failed = steps.filter((step) => !step.details.success);
5
+ const first = failed.at(0);
6
+ return first
7
+ ? {
8
+ failedStep: first.details,
9
+ failureCount: failed.length,
10
+ successCount: steps.length - failed.length,
11
+ totalCount: steps.length,
12
+ }
13
+ : undefined;
14
+ }
15
+ function countUnverifiedMutations(steps) {
16
+ return steps.filter((step) => step.details.pageChangeSummary?.changeType === "mutation" &&
17
+ !step.details.pageChangeSummary.observed).length;
18
+ }
19
+ export function summarizeBatchStatus(steps, requestedSummary) {
20
+ const failure = getBatchFailure(steps);
21
+ const summary = failure
22
+ ? `Batch failed: ${failure.successCount}/${failure.totalCount} succeeded`
23
+ : requestedSummary;
24
+ const mutations = countUnverifiedMutations(steps);
25
+ return {
26
+ failure,
27
+ summary,
28
+ header: failure
29
+ ? [
30
+ summary,
31
+ `First failing step: ${failure.failedStep.index + 1} — ${failure.failedStep.commandText}`,
32
+ failure.failureCount > 1
33
+ ? `${failure.failureCount} steps failed. See the per-step results below.`
34
+ : "See the per-step results below.",
35
+ ].join("\n")
36
+ : undefined,
37
+ mutationEvidenceText: mutations > 0
38
+ ? `Mutation evidence: ${mutations} action result${mutations === 1 ? " proves" : "s prove"} dispatch only, not application state change. Use explicit later assertions or external receipts as postconditions; fixed waits are not postconditions.`
39
+ : undefined,
40
+ };
41
+ }
42
+ export function formatBatchStatusText(steps, status, modelVisible) {
43
+ return [
44
+ status.header,
45
+ status.mutationEvidenceText,
46
+ modelVisible === false ? "" : formatBatchStepsText(steps),
47
+ ]
48
+ .filter((line) => line !== undefined)
49
+ .join("\n\n");
50
+ }
51
+ export function serializeBatchData(steps) {
52
+ return steps.map(({ details }) => details.success
53
+ ? { command: details.command, result: details.data, success: true }
54
+ : {
55
+ command: details.command,
56
+ error: details.text,
57
+ ...(details.command?.[0] === "record" ? { result: details.data } : {}),
58
+ success: false,
59
+ });
60
+ }
61
+ function formatBatchChangeText(observed, unverified) {
62
+ if (observed === 0) {
63
+ return `batch → ${unverified} action${unverified === 1 ? "" : "s"} dispatched → application change unverified`;
64
+ }
65
+ return `batch → ${observed} observed change${observed === 1 ? "" : "s"}${unverified > 0 ? `; ${unverified} dispatched action${unverified === 1 ? "" : "s"} unverified` : ""}`;
66
+ }
67
+ export function buildBatchPageChangeSummary(steps, artifacts, nextActions, summary) {
68
+ if (artifacts.length > 0) {
69
+ return buildPageChangeSummary({
70
+ artifacts,
71
+ commandInfo: { command: "batch" },
72
+ data: serializeBatchData(steps),
73
+ nextActions,
74
+ summary,
75
+ });
76
+ }
77
+ const changed = steps
78
+ .map((step) => step.details)
79
+ .filter((details) => details.pageChangeSummary !== undefined);
80
+ if (changed.length === 0) {
81
+ return undefined;
82
+ }
83
+ const observed = changed.filter((details) => details.pageChangeSummary?.observed === true).length;
84
+ return {
85
+ changeType: "mutation",
86
+ command: "batch",
87
+ nextActionIds: nextActions?.map((action) => action.id),
88
+ observed: observed > 0,
89
+ summary: formatBatchChangeText(observed, countUnverifiedMutations(steps)),
90
+ };
91
+ }