pi-agent-browser-native 0.9.5 → 0.9.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 (398) hide show
  1. package/CHANGELOG.md +114 -1
  2. package/README.md +17 -6
  3. package/dist/extensions/agent-browser/index.js +2482 -925
  4. package/dist/packaged/lib/browser-session-conversion.js +2946 -0
  5. package/dist/packaged/lib/config-policy.js +599 -0
  6. package/dist/packaged/lib/parsing.js +34 -0
  7. package/dist/packaged/lib/playbook.js +728 -0
  8. package/dist/packaged/lib/results/snapshot.js +2800 -0
  9. package/dist/packaged/lib/runtime.js +3075 -0
  10. package/docs/ARCHITECTURE.md +29 -10
  11. package/docs/CODE_QUALITY.md +32 -5
  12. package/docs/COMMAND_REFERENCE.md +156 -40
  13. package/docs/ELECTRON.md +1 -1
  14. package/docs/PERFORMANCE.md +252 -0
  15. package/docs/REFERENCE.md +15 -15
  16. package/docs/RELEASE.md +41 -18
  17. package/docs/REQUIREMENTS.md +6 -0
  18. package/docs/SESSION_STORAGE.md +13 -5
  19. package/docs/SUPPORT_MATRIX.md +31 -25
  20. package/docs/TOOL_CONTRACT.md +41 -18
  21. package/docs/performance/2026-10-12.json +7257 -0
  22. package/docs/platform-smoke.md +18 -14
  23. package/package.json +18 -4
  24. package/platform-smoke.config.mjs +3 -2
  25. package/scripts/agent-browser-capability-baseline.mjs +16 -2
  26. package/scripts/agent-browser-target.mjs +1 -1
  27. package/scripts/build.mjs +16 -5
  28. package/scripts/capability-options.mjs +20 -0
  29. package/scripts/capability-samples.mjs +23 -10
  30. package/scripts/config.mjs +1 -1
  31. package/scripts/convert-browser-session.mjs +1 -1
  32. package/scripts/platform-smoke/commands.mjs +30 -4
  33. package/scripts/platform-smoke/doctor-support.mjs +11 -2
  34. package/scripts/platform-smoke/doctor-windows.mjs +1 -1
  35. package/scripts/platform-smoke/doctor.mjs +26 -11
  36. package/scripts/platform-smoke/linux-image/Dockerfile +6 -3
  37. package/scripts/platform-smoke/platform-build-windows.ps1 +23 -3
  38. package/scripts/platform-smoke/suite-checks.mjs +11 -1
  39. package/scripts/platform-smoke/targets.mjs +4 -3
  40. package/scripts/platform-smoke.mjs +68 -25
  41. package/dist/extensions/agent-browser/lib/argv-descriptor.js +0 -123
  42. package/dist/extensions/agent-browser/lib/argv-grammar.js +0 -320
  43. package/dist/extensions/agent-browser/lib/bash-guard.js +0 -193
  44. package/dist/extensions/agent-browser/lib/batch-lifecycle.js +0 -131
  45. package/dist/extensions/agent-browser/lib/browser-execution-claim-codec.js +0 -61
  46. package/dist/extensions/agent-browser/lib/browser-execution-claim-storage.js +0 -232
  47. package/dist/extensions/agent-browser/lib/browser-execution-claims.js +0 -202
  48. package/dist/extensions/agent-browser/lib/browser-execution-identity.js +0 -77
  49. package/dist/extensions/agent-browser/lib/browser-journal-branch.js +0 -98
  50. package/dist/extensions/agent-browser/lib/browser-journal-contracts.js +0 -1
  51. package/dist/extensions/agent-browser/lib/browser-journal-projection.js +0 -221
  52. package/dist/extensions/agent-browser/lib/browser-journal-reader.js +0 -89
  53. package/dist/extensions/agent-browser/lib/browser-journal-replay.js +0 -246
  54. package/dist/extensions/agent-browser/lib/browser-journal.js +0 -148
  55. package/dist/extensions/agent-browser/lib/browser-legacy-pages.js +0 -220
  56. package/dist/extensions/agent-browser/lib/browser-legacy-projection.js +0 -282
  57. package/dist/extensions/agent-browser/lib/browser-legacy-types.js +0 -1
  58. package/dist/extensions/agent-browser/lib/browser-session-conversion-stream.js +0 -217
  59. package/dist/extensions/agent-browser/lib/browser-session-conversion.js +0 -126
  60. package/dist/extensions/agent-browser/lib/browser-transcript-contracts.js +0 -35
  61. package/dist/extensions/agent-browser/lib/browser-transcript-validation.js +0 -166
  62. package/dist/extensions/agent-browser/lib/browser-transcript.js +0 -189
  63. package/dist/extensions/agent-browser/lib/browser-value-parsing.js +0 -15
  64. package/dist/extensions/agent-browser/lib/command-capabilities.js +0 -340
  65. package/dist/extensions/agent-browser/lib/command-policy.js +0 -155
  66. package/dist/extensions/agent-browser/lib/command-taxonomy.js +0 -105
  67. package/dist/extensions/agent-browser/lib/config-policy.js +0 -450
  68. package/dist/extensions/agent-browser/lib/config-providers.js +0 -71
  69. package/dist/extensions/agent-browser/lib/config-validation.js +0 -231
  70. package/dist/extensions/agent-browser/lib/config.js +0 -69
  71. package/dist/extensions/agent-browser/lib/electron/cdp.js +0 -62
  72. package/dist/extensions/agent-browser/lib/electron/cleanup.js +0 -274
  73. package/dist/extensions/agent-browser/lib/electron/discovery-darwin.js +0 -109
  74. package/dist/extensions/agent-browser/lib/electron/discovery-desktop.js +0 -136
  75. package/dist/extensions/agent-browser/lib/electron/discovery-evidence.js +0 -90
  76. package/dist/extensions/agent-browser/lib/electron/discovery-linux.js +0 -93
  77. package/dist/extensions/agent-browser/lib/electron/discovery-packages.js +0 -162
  78. package/dist/extensions/agent-browser/lib/electron/discovery-types.js +0 -2
  79. package/dist/extensions/agent-browser/lib/electron/discovery.js +0 -217
  80. package/dist/extensions/agent-browser/lib/electron/launch-monitor.js +0 -102
  81. package/dist/extensions/agent-browser/lib/electron/launch-process.js +0 -209
  82. package/dist/extensions/agent-browser/lib/electron/launch-types.js +0 -2
  83. package/dist/extensions/agent-browser/lib/electron/launch.js +0 -340
  84. package/dist/extensions/agent-browser/lib/executable-path.js +0 -29
  85. package/dist/extensions/agent-browser/lib/execution-cwd.js +0 -67
  86. package/dist/extensions/agent-browser/lib/fs-utils.js +0 -10
  87. package/dist/extensions/agent-browser/lib/input-modes/electron.js +0 -201
  88. package/dist/extensions/agent-browser/lib/input-modes/job.js +0 -198
  89. package/dist/extensions/agent-browser/lib/input-modes/lookup-network-evidence.js +0 -116
  90. package/dist/extensions/agent-browser/lib/input-modes/lookup-plan.js +0 -132
  91. package/dist/extensions/agent-browser/lib/input-modes/lookup-redaction.js +0 -57
  92. package/dist/extensions/agent-browser/lib/input-modes/lookup-source-evidence.js +0 -151
  93. package/dist/extensions/agent-browser/lib/input-modes/lookup-workspace.js +0 -142
  94. package/dist/extensions/agent-browser/lib/input-modes/lookups.js +0 -84
  95. package/dist/extensions/agent-browser/lib/input-modes/params.js +0 -195
  96. package/dist/extensions/agent-browser/lib/input-modes/qa-analysis.js +0 -268
  97. package/dist/extensions/agent-browser/lib/input-modes/qa-presentation.js +0 -117
  98. package/dist/extensions/agent-browser/lib/input-modes/script-child.js +0 -396
  99. package/dist/extensions/agent-browser/lib/input-modes/script-protocol.js +0 -86
  100. package/dist/extensions/agent-browser/lib/input-modes/script-types.js +0 -1
  101. package/dist/extensions/agent-browser/lib/input-modes/script-validation.js +0 -60
  102. package/dist/extensions/agent-browser/lib/input-modes/script.js +0 -108
  103. package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +0 -243
  104. package/dist/extensions/agent-browser/lib/input-modes/shared.js +0 -48
  105. package/dist/extensions/agent-browser/lib/input-modes/types.js +0 -65
  106. package/dist/extensions/agent-browser/lib/json-schema.js +0 -65
  107. package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +0 -212
  108. package/dist/extensions/agent-browser/lib/managed-session-policy-lock.js +0 -165
  109. package/dist/extensions/agent-browser/lib/managed-session-posix-storage.js +0 -58
  110. package/dist/extensions/agent-browser/lib/managed-session-project-identity.js +0 -244
  111. package/dist/extensions/agent-browser/lib/managed-session-restore-context.js +0 -84
  112. package/dist/extensions/agent-browser/lib/managed-session-restore-policy.js +0 -119
  113. package/dist/extensions/agent-browser/lib/managed-session-restore-state.js +0 -83
  114. package/dist/extensions/agent-browser/lib/managed-session-restore.js +0 -212
  115. package/dist/extensions/agent-browser/lib/managed-session-snapshot-records.js +0 -277
  116. package/dist/extensions/agent-browser/lib/managed-session-snapshots.js +0 -181
  117. package/dist/extensions/agent-browser/lib/managed-session-storage.js +0 -126
  118. package/dist/extensions/agent-browser/lib/native-confirmation.js +0 -140
  119. package/dist/extensions/agent-browser/lib/native-output.js +0 -81
  120. package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +0 -182
  121. package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-merge.js +0 -30
  122. package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-paths.js +0 -188
  123. package/dist/extensions/agent-browser/lib/orchestration/browser-run/browser-observation-result.js +0 -82
  124. package/dist/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.js +0 -406
  125. package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostic-values.js +0 -31
  126. package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +0 -240
  127. package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-observation.js +0 -203
  128. package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-text-diagnostics.js +0 -109
  129. package/dist/extensions/agent-browser/lib/orchestration/browser-run/fill-diagnostics.js +0 -119
  130. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-action-recovery.js +0 -147
  131. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-actions.js +0 -144
  132. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-content.js +0 -123
  133. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-contracts.js +0 -1
  134. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-details.js +0 -156
  135. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-electron.js +0 -187
  136. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-evidence.js +0 -39
  137. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-missing-binary.js +0 -89
  138. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-recovery.js +0 -97
  139. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-redaction.js +0 -106
  140. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-timeout.js +0 -110
  141. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +0 -53
  142. package/dist/extensions/agent-browser/lib/orchestration/browser-run/index.js +0 -224
  143. package/dist/extensions/agent-browser/lib/orchestration/browser-run/interaction-diagnostics.js +0 -290
  144. package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-close.js +0 -167
  145. package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-inspection.js +0 -108
  146. package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js +0 -174
  147. package/dist/extensions/agent-browser/lib/orchestration/browser-run/native-helper-observation.js +0 -65
  148. package/dist/extensions/agent-browser/lib/orchestration/browser-run/observation-types.js +0 -1
  149. package/dist/extensions/agent-browser/lib/orchestration/browser-run/overlay-diagnostics.js +0 -120
  150. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +0 -192
  151. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +0 -225
  152. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter-data.js +0 -150
  153. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +0 -174
  154. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-rendered-text.js +0 -147
  155. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/wait-timeouts.js +0 -145
  156. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-artifacts.js +0 -159
  157. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-command.js +0 -131
  158. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-contracts.js +0 -1
  159. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-daemon.js +0 -93
  160. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-failure.js +0 -42
  161. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-guards.js +0 -242
  162. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-input.js +0 -75
  163. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-observations.js +0 -92
  164. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-selection.js +0 -254
  165. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-state.js +0 -121
  166. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-refs.js +0 -130
  167. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-resources.js +0 -114
  168. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-semantic.js +0 -121
  169. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-session-plan.js +0 -222
  170. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-timeouts.js +0 -68
  171. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +0 -202
  172. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-analysis.js +0 -191
  173. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-confirmation.js +0 -152
  174. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-diagnostics.js +0 -182
  175. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-electron.js +0 -150
  176. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-contracts.js +0 -1
  177. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase-contracts.js +0 -1
  178. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase.js +0 -115
  179. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle.js +0 -256
  180. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed-contracts.js +0 -1
  181. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed.js +0 -256
  182. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase-contracts.js +0 -1
  183. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase.js +0 -93
  184. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native.js +0 -113
  185. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation-contracts.js +0 -1
  186. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation.js +0 -316
  187. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-ownership.js +0 -28
  188. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase-contracts.js +0 -1
  189. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase.js +0 -142
  190. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation-contracts.js +0 -1
  191. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation.js +0 -333
  192. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase-contracts.js +0 -1
  193. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase.js +0 -71
  194. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication.js +0 -201
  195. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-receipts.js +0 -183
  196. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-refs.js +0 -200
  197. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-tabs.js +0 -142
  198. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +0 -25
  199. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.js +0 -50
  200. package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-receipt-reconciliation.js +0 -198
  201. package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-contracts.js +0 -1
  202. package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-presentation.js +0 -154
  203. package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery.js +0 -80
  204. package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-capture.js +0 -14
  205. package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-observation.js +0 -206
  206. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-commands.js +0 -130
  207. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-electron.js +0 -212
  208. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-observations.js +0 -61
  209. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-outcomes.js +0 -187
  210. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-refs.js +0 -169
  211. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-tabs.js +0 -228
  212. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +0 -117
  213. package/dist/extensions/agent-browser/lib/orchestration/browser-run/text-visibility-diagnostics.js +0 -182
  214. package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-diagnostics.js +0 -256
  215. package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-progress.js +0 -108
  216. package/dist/extensions/agent-browser/lib/orchestration/browser-run/types.js +0 -1
  217. package/dist/extensions/agent-browser/lib/orchestration/code-artifact-observation.js +0 -39
  218. package/dist/extensions/agent-browser/lib/orchestration/code-image-observation.js +0 -119
  219. package/dist/extensions/agent-browser/lib/orchestration/electron-host/branch.js +0 -93
  220. package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup-result.js +0 -58
  221. package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup.js +0 -78
  222. package/dist/extensions/agent-browser/lib/orchestration/electron-host/contracts.js +0 -1
  223. package/dist/extensions/agent-browser/lib/orchestration/electron-host/discovery.js +0 -106
  224. package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +0 -60
  225. package/dist/extensions/agent-browser/lib/orchestration/electron-host/policy.js +0 -86
  226. package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-collection.js +0 -68
  227. package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-data.js +0 -169
  228. package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-presentation.js +0 -182
  229. package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe.js +0 -161
  230. package/dist/extensions/agent-browser/lib/orchestration/electron-host/status.js +0 -167
  231. package/dist/extensions/agent-browser/lib/orchestration/execution-queue.js +0 -98
  232. package/dist/extensions/agent-browser/lib/orchestration/extension-artifact-preflight.js +0 -211
  233. package/dist/extensions/agent-browser/lib/orchestration/extension-artifacts.js +0 -23
  234. package/dist/extensions/agent-browser/lib/orchestration/extension-attachment-replay.js +0 -99
  235. package/dist/extensions/agent-browser/lib/orchestration/extension-branch-restore.js +0 -275
  236. package/dist/extensions/agent-browser/lib/orchestration/extension-code.js +0 -280
  237. package/dist/extensions/agent-browser/lib/orchestration/extension-command-admission.js +0 -303
  238. package/dist/extensions/agent-browser/lib/orchestration/extension-command-output.js +0 -36
  239. package/dist/extensions/agent-browser/lib/orchestration/extension-command-result.js +0 -335
  240. package/dist/extensions/agent-browser/lib/orchestration/extension-command-run.js +0 -227
  241. package/dist/extensions/agent-browser/lib/orchestration/extension-command-state.js +0 -1
  242. package/dist/extensions/agent-browser/lib/orchestration/extension-electron-ownership.js +0 -204
  243. package/dist/extensions/agent-browser/lib/orchestration/extension-execution-locks.js +0 -139
  244. package/dist/extensions/agent-browser/lib/orchestration/extension-execution-queue.js +0 -24
  245. package/dist/extensions/agent-browser/lib/orchestration/extension-host-coordination.js +0 -98
  246. package/dist/extensions/agent-browser/lib/orchestration/extension-host-run.js +0 -295
  247. package/dist/extensions/agent-browser/lib/orchestration/extension-intent-replay.js +0 -41
  248. package/dist/extensions/agent-browser/lib/orchestration/extension-invocation.js +0 -7
  249. package/dist/extensions/agent-browser/lib/orchestration/extension-lifecycle.js +0 -102
  250. package/dist/extensions/agent-browser/lib/orchestration/extension-managed-ownership.js +0 -133
  251. package/dist/extensions/agent-browser/lib/orchestration/extension-observation.js +0 -120
  252. package/dist/extensions/agent-browser/lib/orchestration/extension-prompt.js +0 -180
  253. package/dist/extensions/agent-browser/lib/orchestration/extension-recording.js +0 -290
  254. package/dist/extensions/agent-browser/lib/orchestration/extension-resource-contracts.js +0 -1
  255. package/dist/extensions/agent-browser/lib/orchestration/extension-resource-replay.js +0 -269
  256. package/dist/extensions/agent-browser/lib/orchestration/extension-result-state.js +0 -113
  257. package/dist/extensions/agent-browser/lib/orchestration/extension-runtime.js +0 -146
  258. package/dist/extensions/agent-browser/lib/orchestration/extension-script-leases.js +0 -58
  259. package/dist/extensions/agent-browser/lib/orchestration/extension-tool-boundary.js +0 -62
  260. package/dist/extensions/agent-browser/lib/orchestration/extension-version-check.js +0 -54
  261. package/dist/extensions/agent-browser/lib/orchestration/input-plan-types.js +0 -1
  262. package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +0 -313
  263. package/dist/extensions/agent-browser/lib/orchestration/input-redaction.js +0 -62
  264. package/dist/extensions/agent-browser/lib/orchestration/native-config.js +0 -144
  265. package/dist/extensions/agent-browser/lib/orchestration/native-root-launch.js +0 -77
  266. package/dist/extensions/agent-browser/lib/orchestration/native-session-defaults.js +0 -231
  267. package/dist/extensions/agent-browser/lib/orchestration/operation-paths.js +0 -142
  268. package/dist/extensions/agent-browser/lib/orchestration/output-file.js +0 -276
  269. package/dist/extensions/agent-browser/lib/orchestration/script-mode.js +0 -220
  270. package/dist/extensions/agent-browser/lib/owned-managed-session-context.js +0 -55
  271. package/dist/extensions/agent-browser/lib/page-target-batch.js +0 -118
  272. package/dist/extensions/agent-browser/lib/page-target-guards.js +0 -50
  273. package/dist/extensions/agent-browser/lib/page-target-navigation.js +0 -104
  274. package/dist/extensions/agent-browser/lib/page-target-validation.js +0 -90
  275. package/dist/extensions/agent-browser/lib/parsing.js +0 -30
  276. package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +0 -343
  277. package/dist/extensions/agent-browser/lib/playbook.js +0 -146
  278. package/dist/extensions/agent-browser/lib/process-child.js +0 -284
  279. package/dist/extensions/agent-browser/lib/process-environment.js +0 -48
  280. package/dist/extensions/agent-browser/lib/process-errors.js +0 -23
  281. package/dist/extensions/agent-browser/lib/process-identity.js +0 -127
  282. package/dist/extensions/agent-browser/lib/process-socket-storage.js +0 -256
  283. package/dist/extensions/agent-browser/lib/process-stdout.js +0 -74
  284. package/dist/extensions/agent-browser/lib/process.js +0 -216
  285. package/dist/extensions/agent-browser/lib/prompt-artifacts.js +0 -287
  286. package/dist/extensions/agent-browser/lib/prompt-policy.js +0 -54
  287. package/dist/extensions/agent-browser/lib/read-command.js +0 -41
  288. package/dist/extensions/agent-browser/lib/read-confirmation.js +0 -162
  289. package/dist/extensions/agent-browser/lib/recording-reservations.js +0 -208
  290. package/dist/extensions/agent-browser/lib/redaction-fields.js +0 -75
  291. package/dist/extensions/agent-browser/lib/redaction-json.js +0 -149
  292. package/dist/extensions/agent-browser/lib/redaction-url.js +0 -88
  293. package/dist/extensions/agent-browser/lib/results/action-contracts.js +0 -1
  294. package/dist/extensions/agent-browser/lib/results/action-recommendations.js +0 -38
  295. package/dist/extensions/agent-browser/lib/results/artifact-contracts.js +0 -1
  296. package/dist/extensions/agent-browser/lib/results/artifact-manifest-validation.js +0 -133
  297. package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +0 -173
  298. package/dist/extensions/agent-browser/lib/results/artifact-recommendations.js +0 -73
  299. package/dist/extensions/agent-browser/lib/results/categories.js +0 -152
  300. package/dist/extensions/agent-browser/lib/results/confirmation.js +0 -75
  301. package/dist/extensions/agent-browser/lib/results/contracts.js +0 -1
  302. package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +0 -99
  303. package/dist/extensions/agent-browser/lib/results/electron-recommendations.js +0 -83
  304. package/dist/extensions/agent-browser/lib/results/envelope-decoding.js +0 -48
  305. package/dist/extensions/agent-browser/lib/results/envelope.js +0 -198
  306. package/dist/extensions/agent-browser/lib/results/evidence-contracts.js +0 -1
  307. package/dist/extensions/agent-browser/lib/results/failure-recommendations.js +0 -180
  308. package/dist/extensions/agent-browser/lib/results/network-routes.js +0 -133
  309. package/dist/extensions/agent-browser/lib/results/network.js +0 -89
  310. package/dist/extensions/agent-browser/lib/results/next-actions.js +0 -111
  311. package/dist/extensions/agent-browser/lib/results/presentation/artifact-files.js +0 -320
  312. package/dist/extensions/agent-browser/lib/results/presentation/artifact-format.js +0 -138
  313. package/dist/extensions/agent-browser/lib/results/presentation/artifact-images.js +0 -113
  314. package/dist/extensions/agent-browser/lib/results/presentation/artifact-verification.js +0 -145
  315. package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +0 -165
  316. package/dist/extensions/agent-browser/lib/results/presentation/batch-contracts.js +0 -1
  317. package/dist/extensions/agent-browser/lib/results/presentation/batch-recording.js +0 -118
  318. package/dist/extensions/agent-browser/lib/results/presentation/batch-redaction.js +0 -68
  319. package/dist/extensions/agent-browser/lib/results/presentation/batch-rendering.js +0 -135
  320. package/dist/extensions/agent-browser/lib/results/presentation/batch-step.js +0 -227
  321. package/dist/extensions/agent-browser/lib/results/presentation/batch-summary.js +0 -91
  322. package/dist/extensions/agent-browser/lib/results/presentation/batch.js +0 -123
  323. package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +0 -54
  324. package/dist/extensions/agent-browser/lib/results/presentation/command-presenters.js +0 -216
  325. package/dist/extensions/agent-browser/lib/results/presentation/common.js +0 -81
  326. package/dist/extensions/agent-browser/lib/results/presentation/content.js +0 -119
  327. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-a11y.js +0 -67
  328. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-health.js +0 -79
  329. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-identity.js +0 -199
  330. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-logs.js +0 -75
  331. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network-actions.js +0 -216
  332. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network.js +0 -124
  333. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-redaction.js +0 -64
  334. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-storage.js +0 -209
  335. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-stream.js +0 -69
  336. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-summary.js +0 -222
  337. package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +0 -124
  338. package/dist/extensions/agent-browser/lib/results/presentation/early-result.js +0 -70
  339. package/dist/extensions/agent-browser/lib/results/presentation/errors.js +0 -285
  340. package/dist/extensions/agent-browser/lib/results/presentation/input-contracts.js +0 -1
  341. package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +0 -117
  342. package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +0 -231
  343. package/dist/extensions/agent-browser/lib/results/presentation/notices.js +0 -75
  344. package/dist/extensions/agent-browser/lib/results/presentation/observation-contracts.js +0 -1
  345. package/dist/extensions/agent-browser/lib/results/presentation/observation-rendering.js +0 -127
  346. package/dist/extensions/agent-browser/lib/results/presentation/outcomes.js +0 -120
  347. package/dist/extensions/agent-browser/lib/results/presentation/output-completion.js +0 -77
  348. package/dist/extensions/agent-browser/lib/results/presentation/output-spill.js +0 -51
  349. package/dist/extensions/agent-browser/lib/results/presentation/registry.js +0 -145
  350. package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +0 -104
  351. package/dist/extensions/agent-browser/lib/results/presentation/skills.js +0 -183
  352. package/dist/extensions/agent-browser/lib/results/presentation/source.js +0 -109
  353. package/dist/extensions/agent-browser/lib/results/presentation.js +0 -19
  354. package/dist/extensions/agent-browser/lib/results/recommendation-contracts.js +0 -1
  355. package/dist/extensions/agent-browser/lib/results/recording.js +0 -88
  356. package/dist/extensions/agent-browser/lib/results/recovery-actions.js +0 -118
  357. package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +0 -60
  358. package/dist/extensions/agent-browser/lib/results/selector-recovery-target.js +0 -83
  359. package/dist/extensions/agent-browser/lib/results/selector-recovery.js +0 -261
  360. package/dist/extensions/agent-browser/lib/results/snapshot-compact.js +0 -266
  361. package/dist/extensions/agent-browser/lib/results/snapshot-content.js +0 -32
  362. package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +0 -240
  363. package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +0 -103
  364. package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +0 -383
  365. package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +0 -53
  366. package/dist/extensions/agent-browser/lib/results/snapshot.js +0 -44
  367. package/dist/extensions/agent-browser/lib/results/text.js +0 -44
  368. package/dist/extensions/agent-browser/lib/runtime-args-validation.js +0 -133
  369. package/dist/extensions/agent-browser/lib/runtime-compatibility.js +0 -81
  370. package/dist/extensions/agent-browser/lib/runtime-contracts.js +0 -1
  371. package/dist/extensions/agent-browser/lib/runtime-redaction.js +0 -118
  372. package/dist/extensions/agent-browser/lib/runtime-replay-events.js +0 -144
  373. package/dist/extensions/agent-browser/lib/runtime-session-identity.js +0 -76
  374. package/dist/extensions/agent-browser/lib/runtime-session-plan.js +0 -114
  375. package/dist/extensions/agent-browser/lib/runtime-session-replay.js +0 -123
  376. package/dist/extensions/agent-browser/lib/runtime-tab-correction.js +0 -65
  377. package/dist/extensions/agent-browser/lib/runtime-timeouts.js +0 -28
  378. package/dist/extensions/agent-browser/lib/runtime.js +0 -163
  379. package/dist/extensions/agent-browser/lib/session-identity.js +0 -51
  380. package/dist/extensions/agent-browser/lib/session-page-observation.js +0 -357
  381. package/dist/extensions/agent-browser/lib/session-page-state.js +0 -353
  382. package/dist/extensions/agent-browser/lib/session-page-types.js +0 -1
  383. package/dist/extensions/agent-browser/lib/string-enum-schema.js +0 -8
  384. package/dist/extensions/agent-browser/lib/temp-artifact-budget.js +0 -81
  385. package/dist/extensions/agent-browser/lib/temp-mutation-queue.js +0 -7
  386. package/dist/extensions/agent-browser/lib/temp-root-ownership.js +0 -234
  387. package/dist/extensions/agent-browser/lib/temp-root.js +0 -211
  388. package/dist/extensions/agent-browser/lib/temp.js +0 -91
  389. package/dist/extensions/agent-browser/lib/tool-surface.js +0 -239
  390. package/dist/extensions/agent-browser/lib/upstream-version.js +0 -15
  391. package/dist/extensions/agent-browser/lib/web-search-providers.js +0 -193
  392. package/dist/extensions/agent-browser/lib/web-search-request.js +0 -102
  393. package/dist/extensions/agent-browser/lib/web-search-results.js +0 -281
  394. package/dist/extensions/agent-browser/lib/web-search-schema.js +0 -82
  395. package/dist/extensions/agent-browser/lib/web-search.js +0 -167
  396. package/dist/extensions/agent-browser/lib/webmcp-observation.js +0 -35
  397. package/dist/extensions/agent-browser/lib/windows-stock-launcher.js +0 -96
  398. package/dist/scripts/agent-browser-target.mjs +0 -23
@@ -1,99 +0,0 @@
1
- const EDITABLE_REF_EVIDENCE_KEYS = [
2
- "editable",
3
- "contentEditable",
4
- "contenteditable",
5
- "isContentEditable",
6
- ];
7
- const EDITABLE_FALSE_TEXT_PATTERN = /\b(?:contenteditable|editable)\s*=\s*["']?(?:false|0)["']?/i;
8
- const EDITABLE_ASSIGNMENT_TEXT_PATTERN = /\b(contenteditable|editable)\s*=\s*("[^"]*"|'[^']*'|[^\s,\]]+)/gi;
9
- const EDITABLE_BARE_TEXT_PATTERN = /\b(?:contenteditable|editable)\b(?!\s*=)/i;
10
- function parseEditableEvidenceValue(value) {
11
- if (typeof value === "boolean") {
12
- return value;
13
- }
14
- if (typeof value === "number") {
15
- if (value === 1) {
16
- return true;
17
- }
18
- if (value === 0) {
19
- return false;
20
- }
21
- return undefined;
22
- }
23
- if (typeof value !== "string") {
24
- return undefined;
25
- }
26
- const normalized = value
27
- .trim()
28
- .replace(/^["']|["']$/g, "")
29
- .toLowerCase();
30
- if (["false", "0", "no"].includes(normalized)) {
31
- return false;
32
- }
33
- if (["", "true", "1", "yes", "plaintext-only"].includes(normalized)) {
34
- return true;
35
- }
36
- return undefined;
37
- }
38
- function stripLeadingSnapshotAccessibleName(text) {
39
- return text.replace(/^(\s*[-*]\s+\S+\s+)(?:"[^"]*"|'[^']*')/, "$1");
40
- }
41
- function parseEditableAssignments(markerText) {
42
- let hasPositiveAssignment = false;
43
- for (const match of markerText.matchAll(EDITABLE_ASSIGNMENT_TEXT_PATTERN)) {
44
- const key = match[1]?.toLowerCase();
45
- const evidence = parseEditableEvidenceValue(match[2]);
46
- if (evidence === false) {
47
- return false;
48
- }
49
- if (evidence === true && (key === "contenteditable" || key === "editable")) {
50
- hasPositiveAssignment = true;
51
- }
52
- }
53
- return hasPositiveAssignment ? true : undefined;
54
- }
55
- function parseEditableEvidenceText(text) {
56
- if (text === undefined || text.length === 0) {
57
- return undefined;
58
- }
59
- const markerText = stripLeadingSnapshotAccessibleName(text);
60
- if (EDITABLE_FALSE_TEXT_PATTERN.test(markerText)) {
61
- return false;
62
- }
63
- const assignment = parseEditableAssignments(markerText);
64
- if (assignment !== undefined) {
65
- return assignment;
66
- }
67
- return EDITABLE_BARE_TEXT_PATTERN.test(markerText) ? true : undefined;
68
- }
69
- function getStructuredEditableEvidence(ref) {
70
- if (!ref) {
71
- return undefined;
72
- }
73
- let hasPositiveEvidence = false;
74
- for (const key of EDITABLE_REF_EVIDENCE_KEYS) {
75
- const evidence = parseEditableEvidenceValue(ref[key]);
76
- if (evidence === false) {
77
- return false;
78
- }
79
- if (evidence === true) {
80
- hasPositiveEvidence = true;
81
- }
82
- }
83
- return hasPositiveEvidence ? true : undefined;
84
- }
85
- export function getEditableRefEvidence(options) {
86
- const structuredEvidence = getStructuredEditableEvidence(options.ref);
87
- if (structuredEvidence === false) {
88
- return false;
89
- }
90
- let hasPositiveEvidence = structuredEvidence === true;
91
- const textEvidence = parseEditableEvidenceText(options.text);
92
- if (textEvidence === false) {
93
- return false;
94
- }
95
- if (textEvidence === true) {
96
- hasPositiveEvidence = true;
97
- }
98
- return hasPositiveEvidence ? true : undefined;
99
- }
@@ -1,83 +0,0 @@
1
- import { buildNextToolAction } from "./next-actions.js";
2
- function buildElectronToolAction(options) {
3
- return {
4
- id: options.id,
5
- params: { action: options.action, launchId: options.launchId },
6
- reason: options.reason,
7
- ...(options.safety !== undefined && options.safety.length > 0
8
- ? { safety: options.safety }
9
- : {}),
10
- tool: "agent_browser_electron",
11
- };
12
- }
13
- function buildActiveLaunchActions(launchId) {
14
- return [
15
- buildElectronToolAction({
16
- action: "status",
17
- id: "status-electron-launch",
18
- launchId,
19
- reason: "Check the wrapper-tracked Electron launch liveness and current CDP targets without mutating the app.",
20
- }),
21
- buildElectronToolAction({
22
- action: "probe",
23
- id: "probe-electron-launch",
24
- launchId,
25
- reason: "Probe the attached Electron managed session and carry the wrapper launchId for follow-up diagnostics.",
26
- }),
27
- buildElectronToolAction({
28
- action: "cleanup",
29
- id: "cleanup-electron-launch",
30
- launchId,
31
- reason: "Clean the wrapper-owned Electron process and isolated userDataDir when the run is complete.",
32
- safety: "Only operates on the launchId created by electron.launch; explicit artifacts and manually launched apps remain host-owned.",
33
- }),
34
- ];
35
- }
36
- function buildElectronSessionActions(sessionName) {
37
- if (sessionName === undefined || sessionName.length === 0) {
38
- return [];
39
- }
40
- return [
41
- buildNextToolAction({
42
- args: ["--session", sessionName, "tab", "list"],
43
- id: "list-electron-tabs",
44
- reason: "Inspect attached Electron page/webview targets before choosing the active tab.",
45
- }),
46
- buildNextToolAction({
47
- args: ["--session", sessionName, "snapshot", "-i"],
48
- id: "snapshot-electron-session",
49
- reason: "Refresh interactive refs for the attached Electron session.",
50
- safety: "Use current Electron refs only after a fresh snapshot for this session.",
51
- }),
52
- ];
53
- }
54
- export function buildElectronNextActions(options) {
55
- const launchId = options.electron?.launchId;
56
- if (launchId === undefined || launchId.length === 0) {
57
- return [];
58
- }
59
- if (options.resultCategory === "success" && options.electron?.status !== "cleaned") {
60
- return [
61
- ...buildActiveLaunchActions(launchId),
62
- ...buildElectronSessionActions(options.electron?.sessionName),
63
- ];
64
- }
65
- if (options.resultCategory === "failure" && options.failureCategory === "cleanup-failed") {
66
- return [
67
- buildElectronToolAction({
68
- action: "status",
69
- id: "status-electron-launch",
70
- launchId,
71
- reason: "Inspect which wrapper-tracked Electron resources remain after partial cleanup.",
72
- }),
73
- buildElectronToolAction({
74
- action: "cleanup",
75
- id: "retry-electron-cleanup",
76
- launchId,
77
- reason: "Retry cleanup for the same wrapper-owned Electron launch after reviewing remaining resources.",
78
- safety: "Only retry for the same launchId; do not use cleanup for manually launched Electron apps.",
79
- }),
80
- ];
81
- }
82
- return [];
83
- }
@@ -1,48 +0,0 @@
1
- import { isRecord } from "../parsing.js";
2
- function decodePluginList(value) {
3
- const keys = Object.keys(value);
4
- if (keys.length !== 1) {
5
- return undefined;
6
- }
7
- if (keys[0] === "plugins" && Array.isArray(value.plugins)) {
8
- return { success: true, data: { plugins: value.plugins } };
9
- }
10
- if (keys[0] === "plugin" && isRecord(value.plugin) && !Array.isArray(value.plugin)) {
11
- return { success: true, data: { plugin: value.plugin } };
12
- }
13
- return undefined;
14
- }
15
- export function decodeAgentBrowserEnvelope(value) {
16
- if (Array.isArray(value)) {
17
- return {
18
- envelope: {
19
- success: value.every((item) => !isRecord(item) || item.success !== false),
20
- data: value,
21
- },
22
- };
23
- }
24
- if (!isRecord(value)) {
25
- return { parseError: "agent-browser returned JSON, but it was not an object envelope." };
26
- }
27
- const plugin = decodePluginList(value);
28
- if (plugin) {
29
- return { envelope: plugin };
30
- }
31
- if (!("success" in value)) {
32
- return {
33
- parseError: "agent-browser returned an invalid JSON envelope: missing boolean success field.",
34
- };
35
- }
36
- if (typeof value.success !== "boolean") {
37
- return {
38
- parseError: "agent-browser returned an invalid JSON envelope: success field must be boolean.",
39
- };
40
- }
41
- if (!Object.hasOwn(value, "data")) {
42
- const { success, error, ...topLevelData } = value;
43
- if (Object.keys(topLevelData).length > 0) {
44
- return { envelope: { error, success, data: topLevelData } };
45
- }
46
- }
47
- return { envelope: { ...value, success: value.success } };
48
- }
@@ -1,198 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
- import { isRecord } from "../parsing.js";
3
- import { detectConfirmationRequired } from "./confirmation.js";
4
- import { decodeAgentBrowserEnvelope } from "./envelope-decoding.js";
5
- import { stringifyUnknown } from "./text.js";
6
- function hasStructuredBatchStepFailure(data) {
7
- return Array.isArray(data) && data.some((item) => isRecord(item) && item.success === false);
8
- }
9
- async function readEnvelopeSource(options) {
10
- if (options.stdoutPath === undefined || options.stdoutPath.length === 0) {
11
- return options.stdout;
12
- }
13
- try {
14
- return await readFile(options.stdoutPath, "utf8");
15
- }
16
- catch (error) {
17
- const message = error instanceof Error ? error.message : stringifyUnknown(error);
18
- throw new Error(`agent-browser output spill file could not be read: ${message}`, {
19
- cause: error,
20
- });
21
- }
22
- }
23
- export function extractEnvelopeErrorText(error) {
24
- if (typeof error === "string") {
25
- const trimmed = error.trim();
26
- return trimmed.length > 0 ? trimmed : undefined;
27
- }
28
- if (typeof error === "number" || typeof error === "boolean") {
29
- return String(error);
30
- }
31
- if (Array.isArray(error)) {
32
- const parts = error
33
- .map((item) => extractEnvelopeErrorText(item) ?? stringifyUnknown(item))
34
- .filter((item) => item.length > 0);
35
- return parts.length > 0 ? parts.join("\n") : undefined;
36
- }
37
- if (!isRecord(error)) {
38
- return error === null || error === undefined ? undefined : stringifyUnknown(error);
39
- }
40
- return extractStructuredEnvelopeErrorText(error);
41
- }
42
- function extractStructuredEnvelopeErrorText(error) {
43
- for (const key of ["message", "error", "details", "cause", "stderr"]) {
44
- const value = extractEnvelopeErrorText(error[key]);
45
- if ((value ?? "") !== "") {
46
- return value;
47
- }
48
- }
49
- const fallback = stringifyUnknown(error).trim();
50
- return fallback.length > 0 && fallback !== "{}" ? fallback : undefined;
51
- }
52
- function getEnvelopeOutputMode(options) {
53
- return typeof options === "string"
54
- ? { plainText: false, textOutput: false }
55
- : { plainText: options.plainText === true, textOutput: options.textOutput === true };
56
- }
57
- export async function parseAgentBrowserEnvelope(options) {
58
- let stdout;
59
- try {
60
- stdout = typeof options === "string" ? options : await readEnvelopeSource(options);
61
- }
62
- catch (error) {
63
- return { parseError: error instanceof Error ? error.message : stringifyUnknown(error) };
64
- }
65
- // ponytail: native text has no machine receipts; use JSON mode for structured evidence.
66
- // JSON-looking page text must never become an envelope, confirmation, or batch row.
67
- const { plainText, textOutput } = getEnvelopeOutputMode(options);
68
- if (textOutput) {
69
- return { envelope: { success: true, data: stdout } };
70
- }
71
- const trimmed = stdout.trim();
72
- if (trimmed.length === 0 && !plainText) {
73
- return { parseError: "agent-browser returned no JSON output." };
74
- }
75
- try {
76
- const parsed = JSON.parse(trimmed);
77
- return decodeAgentBrowserEnvelope(parsed);
78
- }
79
- catch (error) {
80
- if (plainText) {
81
- return { envelope: { success: true, data: trimmed } };
82
- }
83
- const message = error instanceof Error ? error.message : stringifyUnknown(error);
84
- return { parseError: `agent-browser returned invalid JSON: ${message}` };
85
- }
86
- }
87
- function buildInvocationLabel(options) {
88
- if (options.effectiveArgs && options.effectiveArgs.length > 0) {
89
- return `agent-browser ${options.effectiveArgs.join(" ")}`;
90
- }
91
- if (options.command !== undefined && options.command.trim().length > 0) {
92
- return `agent-browser ${options.command.trim()}`;
93
- }
94
- return "agent-browser";
95
- }
96
- function appendWrapperRecoveryHint(message, wrapperRecoveryHint) {
97
- const hint = wrapperRecoveryHint?.trim();
98
- return hint !== undefined && hint.length > 0 ? `${message}\n${hint}` : message;
99
- }
100
- function buildFailureFallback(options) {
101
- const invocation = buildInvocationLabel(options);
102
- const exitSuffix = options.exitCode !== 0 ? ` (exit code ${options.exitCode})` : "";
103
- return appendWrapperRecoveryHint(`${invocation} reported failure${exitSuffix}.`, options.wrapperRecoveryHint);
104
- }
105
- function buildExitCodeFallback(options) {
106
- const invocation = buildInvocationLabel(options);
107
- return appendWrapperRecoveryHint(`${invocation} exited with code ${options.exitCode}.`, options.wrapperRecoveryHint);
108
- }
109
- function buildWatchdogTimeoutMessage(options) {
110
- const timeoutText = options.timeoutMs === undefined
111
- ? "the wrapper watchdog"
112
- : `the ${options.timeoutMs}ms wrapper watchdog`;
113
- const ipcTiming = options.timeoutMs !== undefined && options.timeoutMs <= 30_000
114
- ? "before the upstream CLI entered its 30s IPC retry path"
115
- : "after waiting beyond the upstream CLI's 30s IPC retry window";
116
- return [
117
- `agent-browser exceeded ${timeoutText} and was stopped ${ipcTiming}.`,
118
- "Prefer a condition wait or split long work into shorter calls; for legitimately long opens or captures, pass agent_browser timeoutMs with a bounded higher value and inspect details.timeoutPartialProgress before retrying.",
119
- ].join(" ");
120
- }
121
- function isUpstreamIpcReadTimeoutMessage(message) {
122
- return /Failed to read: Resource temporarily unavailable(?: \(os error \d+\))?.*daemon may be busy or unresponsive/i.test(message);
123
- }
124
- function buildUpstreamIpcReadTimeoutMessage() {
125
- return [
126
- "agent-browser hit the upstream CLI 30s IPC read timeout while waiting for the daemon response.",
127
- 'The daemon may still be alive; do not blindly retry a non-idempotent command. Prefer a shorter command, split long waits, or retry with sessionMode: "fresh" after checking tab list.',
128
- ].join(" ");
129
- }
130
- function maybeAppendStaleRefHint(message, args) {
131
- const usedRef = args?.some((arg) => /^@e\d+\b/.test(arg)) ?? false;
132
- if (!usedRef || !/could not locate element|element not found|no element/i.test(message)) {
133
- return message;
134
- }
135
- return [
136
- message,
137
- 'This @ref may be stale after navigation, scrolling, or a DOM update. Run `agent_browser` with `{ "args": ["snapshot", "-i"] }` again and retry with a current ref, or use a stable `find` locator.',
138
- ].join("\n");
139
- }
140
- function getTransportErrorText(options) {
141
- if (options.timedOut === true) {
142
- return buildWatchdogTimeoutMessage(options);
143
- }
144
- if (options.aborted) {
145
- return "agent-browser was aborted.";
146
- }
147
- if (options.spawnError) {
148
- return options.spawnError.message;
149
- }
150
- if ((options.parseError ?? "") !== "") {
151
- return options.exitCode !== 0 && options.stderr.trim().length > 0
152
- ? options.stderr.trim()
153
- : options.parseError;
154
- }
155
- return undefined;
156
- }
157
- function getEnvelopeDataError(data) {
158
- if (typeof data === "string") {
159
- return data;
160
- }
161
- return isRecord(data) ? data.error : undefined;
162
- }
163
- function getFailedEnvelopeFallback(options, errorText) {
164
- const stderr = options.stderr.trim();
165
- return errorText ?? (stderr.length > 0 ? stderr : buildFailureFallback(options));
166
- }
167
- function getFailedEnvelopeErrorText(options, envelope) {
168
- const explicitErrorText = extractEnvelopeErrorText(envelope.error);
169
- if ((hasStructuredBatchStepFailure(envelope.data) || detectConfirmationRequired(envelope.data)) &&
170
- explicitErrorText === undefined) {
171
- return undefined;
172
- }
173
- const envelopeErrorText = explicitErrorText ?? extractEnvelopeErrorText(getEnvelopeDataError(envelope.data));
174
- if (envelopeErrorText !== undefined &&
175
- envelopeErrorText.length > 0 &&
176
- isUpstreamIpcReadTimeoutMessage(envelopeErrorText)) {
177
- return buildUpstreamIpcReadTimeoutMessage();
178
- }
179
- const fallback = getFailedEnvelopeFallback(options, envelopeErrorText);
180
- return maybeAppendStaleRefHint(fallback, options.staleRefArgs ?? options.effectiveArgs);
181
- }
182
- export function getAgentBrowserErrorText(options) {
183
- if (options.plainTextInspection) {
184
- return undefined;
185
- }
186
- const transportErrorText = getTransportErrorText(options);
187
- if (transportErrorText !== undefined) {
188
- return transportErrorText;
189
- }
190
- if (options.envelope?.success === false) {
191
- return getFailedEnvelopeErrorText(options, options.envelope);
192
- }
193
- if (options.exitCode !== 0) {
194
- const stderr = options.stderr.trim();
195
- return stderr.length > 0 ? stderr : buildExitCodeFallback(options);
196
- }
197
- return undefined;
198
- }
@@ -1,180 +0,0 @@
1
- import { isOpenNavigationCommand } from "../command-taxonomy.js";
2
- import { buildInspectOverlayStateAction, buildNextToolAction } from "./next-actions.js";
3
- import { AGENT_BROWSER_RECOVERY_NEXT_ACTION_IDS } from "./recovery-actions.js";
4
- import { buildMissingArtifactNextActions } from "./artifact-recommendations.js";
5
- function getExplicitDownloadWaitPath(args) {
6
- const candidate = args.at(args.indexOf("--download") + 1);
7
- return candidate !== undefined && candidate.length > 0 && !candidate.startsWith("-")
8
- ? candidate
9
- : undefined;
10
- }
11
- function getDownloadRetryPath(args, fallback) {
12
- if (fallback !== undefined && fallback.length > 0) {
13
- return fallback;
14
- }
15
- if (!args || args.length === 0) {
16
- return undefined;
17
- }
18
- if (args.includes("--download")) {
19
- return getExplicitDownloadWaitPath(args);
20
- }
21
- const downloadCommandIndex = args.indexOf("download");
22
- return downloadCommandIndex >= 0 && args.length > downloadCommandIndex + 2
23
- ? args.at(-1)
24
- : undefined;
25
- }
26
- function buildConfirmationActions(id) {
27
- if (id === undefined || id.length === 0) {
28
- return [];
29
- }
30
- return [
31
- buildNextToolAction({
32
- args: ["confirm", id],
33
- id: "approve-confirmation",
34
- reason: "Approve the pending upstream confirmation when the requested action is safe.",
35
- safety: "Only confirm after reviewing the guarded action shown in the result.",
36
- }),
37
- buildNextToolAction({
38
- args: ["deny", id],
39
- id: "deny-confirmation",
40
- reason: "Deny the pending upstream confirmation when the guarded action is unsafe or unintended.",
41
- }),
42
- ];
43
- }
44
- function buildDownloadFailureActions(options) {
45
- const path = getDownloadRetryPath(options.args, options.savedFilePath);
46
- return [
47
- buildNextToolAction({
48
- args: path !== undefined && path.length > 0
49
- ? ["wait", "--download", path]
50
- : ["wait", "--download"],
51
- id: "wait-for-download",
52
- reason: "Wait for the browser download and let the wrapper verify saved-file metadata.",
53
- safety: "Use an explicit wait timeout; if you set top-level timeoutMs, keep it above the wait duration plus a small grace window.",
54
- }),
55
- ];
56
- }
57
- function getTimeoutInspectionReason(command, textAssertion) {
58
- if (textAssertion) {
59
- return "Inspect the current page after the text assertion failed before concluding the expected text is absent.";
60
- }
61
- return command === "wait"
62
- ? "Inspect the current page after the wait condition timed out before retrying with a different selector or timeout."
63
- : "Inspect the current page after the timed-out browser operation.";
64
- }
65
- function buildTimeoutActions(options) {
66
- if (options.command === "session" && options.subcommand === "info") {
67
- return [
68
- buildNextToolAction({
69
- args: ["session", "info"],
70
- id: "retry-session-info",
71
- reason: "Retry the same session status check without opening a browser or inspecting its page.",
72
- }),
73
- ];
74
- }
75
- const textAssertion = options.command === "wait" && options.args?.includes("--text") === true;
76
- const urlAssertion = options.command === "wait" && options.args?.includes("--url") === true;
77
- const actions = [
78
- buildNextToolAction({
79
- args: ["snapshot", "-i"],
80
- id: textAssertion ? "inspect-after-text-assertion-failure" : "inspect-after-timeout",
81
- reason: getTimeoutInspectionReason(options.command, textAssertion),
82
- safety: textAssertion
83
- ? "Read-only snapshot; use current refs or visible text from this page before retrying the assertion."
84
- : "Read-only snapshot; do not assume the timed-out interaction completed.",
85
- }),
86
- ];
87
- if (urlAssertion) {
88
- actions.push(buildNextToolAction({
89
- args: ["open", "about:blank"],
90
- id: "fresh-session-after-url-wait-timeout",
91
- reason: "If a preceding click or form submit reported success but the page never navigated, upstream click dispatch may have silently missed (observed with agent-browser 0.34 after many spaced commands); replace about:blank with the target URL and replay the flow as one batch in a fresh session instead of retrying the wait.",
92
- safety: "Abandons the current browser session; capture page evidence with the inspect action first, and only abandon when the wait target is not simply wrong or slow.",
93
- sessionMode: "fresh",
94
- }));
95
- }
96
- return actions;
97
- }
98
- function buildUpstreamFailureActions(options) {
99
- if (options.overlayBlockedClick === true) {
100
- return [buildInspectOverlayStateAction(options.sessionName)];
101
- }
102
- return isOpenNavigationCommand(options.command)
103
- ? [
104
- buildNextToolAction({
105
- args: ["get", "url"],
106
- id: "inspect-page-after-navigation-error",
107
- reason: "Check which page, if any, remains active after the navigation or network error.",
108
- safety: "Read-only URL inspection; verify connectivity and the target URL before retrying navigation.",
109
- }),
110
- ]
111
- : [];
112
- }
113
- function buildTabGoneActions() {
114
- return [
115
- buildNextToolAction({
116
- args: ["tab", "list"],
117
- id: AGENT_BROWSER_RECOVERY_NEXT_ACTION_IDS.tabGoneListTabs,
118
- reason: "The pinned bound tab is gone; inspect remaining tabs before acting on a neighbor.",
119
- safety: "Read-only. Prefer a listed tab id, label, or CDP targetId, or open a new tab to rebind.",
120
- }),
121
- buildNextToolAction({
122
- args: ["tab", "new"],
123
- id: AGENT_BROWSER_RECOVERY_NEXT_ACTION_IDS.tabGoneNewTab,
124
- reason: "Bind a fresh tab after tab_gone instead of continuing on another session's page.",
125
- safety: "Opens a new tab in this session and rebinds the pin; pass a URL if you know the intended page.",
126
- }),
127
- ];
128
- }
129
- function buildTabDriftActions(options) {
130
- if (options.recovery?.kind === "about-blank" || options.recovery?.kind === "tab-drift") {
131
- return [];
132
- }
133
- return [
134
- buildNextToolAction({
135
- args: ["tab", "list"],
136
- id: AGENT_BROWSER_RECOVERY_NEXT_ACTION_IDS.genericTabDriftListTabs,
137
- reason: "Inspect available tabs before selecting the intended target.",
138
- safety: "Read-only. Retry snapshot only after selecting or confirming the intended stable tab.",
139
- }),
140
- ];
141
- }
142
- export function buildFailureNextActions(options) {
143
- switch (options.failureCategory) {
144
- case "artifact-missing":
145
- return buildMissingArtifactNextActions(options.artifacts);
146
- case "confirmation-required":
147
- return buildConfirmationActions(options.confirmationId);
148
- case "stale-ref":
149
- case "selector-not-found":
150
- case "selector-unsupported":
151
- return [
152
- buildNextToolAction({
153
- args: ["snapshot", "-i"],
154
- id: "refresh-interactive-refs",
155
- reason: "Get current interactive refs before retrying the element action.",
156
- safety: "Prefer a current @ref or a stable find locator; do not retry stale refs blindly.",
157
- }),
158
- ];
159
- case "download-not-verified":
160
- return buildDownloadFailureActions(options);
161
- case "timeout":
162
- return buildTimeoutActions(options);
163
- case "upstream-error":
164
- return buildUpstreamFailureActions(options);
165
- case "tab-gone":
166
- return buildTabGoneActions();
167
- case "tab-drift":
168
- return buildTabDriftActions(options);
169
- case "aborted":
170
- case "cleanup-failed":
171
- case "missing-binary":
172
- case "parse-failure":
173
- case "policy-blocked":
174
- case "qa-failure":
175
- case "script-error":
176
- case "validation-error":
177
- case undefined:
178
- return [];
179
- }
180
- }