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,303 +0,0 @@
1
- import { format } from "node:util";
2
- import { extractUpstreamCommandTokens, isPlainTextInspectionArgs } from "../runtime.js";
3
- import { extractExplicitSessionName, resolveAgentBrowserNamespace, scanUpstreamGlobalFlagOccurrences, } from "../argv-grammar.js";
4
- import { parseArgvDescriptor } from "../argv-descriptor.js";
5
- import { needsManagedSession } from "../command-policy.js";
6
- import { isRecord } from "../parsing.js";
7
- import { getAgentBrowserProcessTimeoutMs } from "../process.js";
8
- import { getCommandAwareProcessTimeoutMs } from "./browser-run/prepare/wait-timeouts.js";
9
- import { getAgentBrowserProcessEnvironment } from "../process-environment.js";
10
- import { withNativeSessionDefaults } from "./native-session-defaults.js";
11
- import { getBrowserCwdError, resolveExecutionCwd } from "../execution-cwd.js";
12
- import { resolveOperationPaths } from "./operation-paths.js";
13
- import { isCloseCommand } from "../command-taxonomy.js";
14
- import { getSessionContextKey } from "./browser-run/session-state.js";
15
- import { buildValidationFailureResult, resolveAgentBrowserInput, } from "./input-plan.js";
16
- import { applyAgentBrowserOutputPath } from "./output-file.js";
17
- import { loadAgentBrowserConfigSync } from "../config.js";
18
- import { scopeReadConfirmationArgs } from "../read-confirmation.js";
19
- import { getArtifactPreflightValidationError, commandClosesAllSessions, } from "./extension-artifact-preflight.js";
20
- import { browserExecutionFailure } from "./extension-result-state.js";
21
- import { shouldSerializeBrowserCommand } from "./extension-managed-ownership.js";
22
- import { shouldSerializeElectronHostInput } from "./extension-electron-ownership.js";
23
- import { shouldIncludeProjectConfig } from "./extension-prompt.js";
24
- import { validateUpstreamVersion } from "./extension-version-check.js";
25
- import { applyUnserializedOutputPath } from "./extension-command-output.js";
26
- import { runCoordinatedElectronHostInput } from "./extension-host-coordination.js";
27
- import { runWithinSessionQueue } from "./extension-execution-queue.js";
28
- function validationFailure(input, validationError) {
29
- return buildValidationFailureResult({
30
- ...input,
31
- attemptedKind: input.kind,
32
- kind: "invalid",
33
- status: "invalid",
34
- validationError,
35
- });
36
- }
37
- // tool_call hooks can mutate input before the canonical input planner validates it.
38
- function requestedOutputPath(params) {
39
- return isRecord(params) && typeof params.outputPath === "string" ? params.outputPath : undefined;
40
- }
41
- function operationTimeout(call, input) {
42
- const electronTimeout = input.kind === "electron" && "timeoutMs" in input.compiledElectron
43
- ? input.compiledElectron.timeoutMs
44
- : undefined;
45
- return (electronTimeout ??
46
- call.params.timeoutMs ??
47
- getCommandAwareProcessTimeoutMs(extractUpstreamCommandTokens(input.toolArgs), input.toolStdin) ??
48
- getAgentBrowserProcessTimeoutMs());
49
- }
50
- class BrowserAdmission {
51
- runtime;
52
- invocation;
53
- constructor(runtime, invocation) {
54
- this.runtime = runtime;
55
- this.invocation = invocation;
56
- }
57
- admit() {
58
- const { runtime, invocation } = this;
59
- const branch = invocation.selectedBranch ?? runtime.branch.capture(invocation.ctx);
60
- let operationCwd;
61
- try {
62
- operationCwd = invocation.capturedCwd ?? resolveExecutionCwd(runtime.pi, invocation.ctx);
63
- }
64
- catch (error) {
65
- return {
66
- failure: buildValidationFailureResult({
67
- kind: "invalid",
68
- status: "invalid",
69
- redactedArgs: [],
70
- toolArgs: [],
71
- validationError: error instanceof Error ? error.message : format("%s", error),
72
- }),
73
- };
74
- }
75
- return this.validateInvocation(branch, operationCwd);
76
- }
77
- validateInvocation(branch, operationCwd) {
78
- const { runtime, invocation } = this;
79
- const promptPolicy = runtime.prompt.policy(invocation.ctx);
80
- const outputPath = requestedOutputPath(invocation.params);
81
- const input = resolveAgentBrowserInput({
82
- getBatchPreflightValidationError: (args, stdin) => getArtifactPreflightValidationError({ args, cwd: operationCwd, outputPath, stdin }),
83
- params: invocation.params,
84
- });
85
- if (input.status === "invalid") {
86
- return { failure: buildValidationFailureResult(input) };
87
- }
88
- const replayError = this.replayFailure(input);
89
- if (replayError) {
90
- return { failure: replayError };
91
- }
92
- const explicitConfig = scanUpstreamGlobalFlagOccurrences(input.toolArgs, "--config").length > 0 ||
93
- getAgentBrowserProcessEnvironment().AGENT_BROWSER_CONFIG !== undefined;
94
- const session = extractExplicitSessionName(input.toolArgs);
95
- const managedAtAdmission = input.kind !== "electron" && (session === undefined || session === "") && !explicitConfig;
96
- return {
97
- call: {
98
- ...invocation,
99
- branch,
100
- operationCwd,
101
- promptPolicy,
102
- outputPath,
103
- admittedInput: input,
104
- explicitConfig,
105
- managedAtAdmission,
106
- },
107
- };
108
- }
109
- replayFailure(input) {
110
- const error = this.runtime.branch.replayError;
111
- if (error === undefined || error === "" || isPlainTextInspectionArgs(input.toolArgs)) {
112
- return undefined;
113
- }
114
- return browserExecutionFailure(new Error(error), this.invocation.signal, "validation-error");
115
- }
116
- selectBrowserCwd(call) {
117
- const session = extractExplicitSessionName(call.admittedInput.toolArgs);
118
- if (call.explicitConfig) {
119
- return call.operationCwd;
120
- }
121
- if (session !== undefined && session !== "") {
122
- const namespace = resolveAgentBrowserNamespace(call.admittedInput.toolArgs, getAgentBrowserProcessEnvironment().AGENT_BROWSER_NAMESPACE);
123
- return (this.runtime.managed.owned.get(getSessionContextKey(session, namespace) ?? session)?.cwd ??
124
- call.ctx.cwd);
125
- }
126
- if (call.params.sessionMode === "fresh") {
127
- return call.operationCwd;
128
- }
129
- return this.runtime.managed.active ? this.runtime.managed.cwd : call.ctx.cwd;
130
- }
131
- prepare(call) {
132
- const browserCwd = this.selectBrowserCwd(call);
133
- const input = call.admittedInput;
134
- const error = input.kind === "electron" ? undefined : getBrowserCwdError(browserCwd);
135
- if (error !== undefined && error !== "") {
136
- return { failure: validationFailure(input, error) };
137
- }
138
- const resolvedInput = this.bindOperationPaths(call, browserCwd);
139
- return {
140
- call: {
141
- ...call,
142
- browserCwd,
143
- resolvedInput,
144
- executionTimeoutMs: operationTimeout(call, resolvedInput),
145
- },
146
- };
147
- }
148
- bindOperationPaths(call, browserCwd) {
149
- const input = call.admittedInput;
150
- if (isPlainTextInspectionArgs(input.toolArgs) ||
151
- (call.operationCwd === browserCwd && call.operationCwd === call.ctx.cwd)) {
152
- return input;
153
- }
154
- const bound = resolveOperationPaths(input.toolArgs, input.toolStdin, call.operationCwd);
155
- return { ...input, toolArgs: bound.args, toolStdin: bound.stdin };
156
- }
157
- canSelectNativeRoot(call) {
158
- if (this.runtime.managed.active ||
159
- this.runtime.managed.freshOrdinal > 0 ||
160
- call.params.sessionMode === "fresh") {
161
- return false;
162
- }
163
- return (this.runtime.sessions.pages.findReadConfirmation([...call.resolvedInput.toolArgs], resolveAgentBrowserNamespace(call.resolvedInput.toolArgs, getAgentBrowserProcessEnvironment().AGENT_BROWSER_NAMESPACE), call.resolvedInput.toolStdin) === undefined);
164
- }
165
- nativeRoot(call, config) {
166
- if (!this.canSelectNativeRoot(call)) {
167
- return undefined;
168
- }
169
- const root = process.env.PI_SUBAGENT_ROOT_SESSION_ID;
170
- const id = process.env.PI_SUBAGENT_CHILD === "1" && root !== undefined && root !== ""
171
- ? root
172
- : call.ctx.sessionManager.getSessionId();
173
- const profile = config.trustedBrowserDefaultProfile;
174
- return {
175
- id,
176
- profile: profile?.policy === "always" && !/[\\/~]/.test(profile.name) ? profile.name : undefined,
177
- executablePath: config.trustedBrowserExecutablePath,
178
- };
179
- }
180
- async executeAdmitted(admitted) {
181
- const prepared = this.prepare(admitted);
182
- if ("failure" in prepared) {
183
- return prepared.failure;
184
- }
185
- const { call } = prepared;
186
- await this.runtime.beforeExecute?.(call.nativeToolCallId, { ...call.ctx, signal: call.signal });
187
- const config = loadAgentBrowserConfigSync({
188
- cwd: call.ctx.cwd,
189
- includeProjectConfig: shouldIncludeProjectConfig(call.ctx),
190
- });
191
- return withNativeSessionDefaults(call.resolvedInput, { cwd: call.browserCwd, signal: call.signal, root: this.nativeRoot(call, config) }, (input, defaults) => this.executeNative(call, input, defaults));
192
- }
193
- prepareNative(call, input, defaults) {
194
- const readConfirmation = this.runtime.sessions.pages.findReadConfirmation([...input.toolArgs], resolveAgentBrowserNamespace(input.toolArgs, getAgentBrowserProcessEnvironment().AGENT_BROWSER_NAMESPACE), input.toolStdin);
195
- const resolvedInput = readConfirmation
196
- ? { ...input, toolArgs: scopeReadConfirmationArgs(input.toolArgs, readConfirmation) }
197
- : input;
198
- const qaFailure = this.attachedQaFailure(resolvedInput);
199
- if (qaFailure) {
200
- return { failure: qaFailure };
201
- }
202
- return {
203
- call: {
204
- ...call,
205
- resolvedInput,
206
- readConfirmation,
207
- withLaunchDefaults: defaults,
208
- toolArgs: resolvedInput.toolArgs,
209
- compiledElectron: resolvedInput.kind === "electron" ? resolvedInput.compiledElectron : undefined,
210
- redactedCompiledElectron: resolvedInput.kind === "electron" ? resolvedInput.redactedCompiledElectron : undefined,
211
- },
212
- };
213
- }
214
- attachedQaFailure(input) {
215
- if (input.kind !== "qa" ||
216
- !input.compiledQaPreset.checks.attached ||
217
- this.runtime.managed.active) {
218
- return undefined;
219
- }
220
- const session = extractExplicitSessionName(input.toolArgs);
221
- if (session !== undefined && session !== "") {
222
- return undefined;
223
- }
224
- return validationFailure(input, "qa.attached requires an active attached session. Run electron.launch or connect to an Electron debug port first, or configure a native shared session.");
225
- }
226
- needsVersionCheck(call) {
227
- if (call.compiledElectron &&
228
- ["cleanup", "list", "status"].includes(call.compiledElectron.action)) {
229
- return false;
230
- }
231
- if (call.readConfirmation?.capabilities?.readRequiresConfirmation === true) {
232
- return false;
233
- }
234
- if (!needsManagedSession(parseArgvDescriptor(call.toolArgs), call.resolvedInput.toolStdin)) {
235
- return false;
236
- }
237
- return (!isPlainTextInspectionArgs(call.toolArgs) &&
238
- !isCloseCommand(extractUpstreamCommandTokens(call.toolArgs)[0]) &&
239
- call.signal?.aborted !== true);
240
- }
241
- coordinate(call) {
242
- const explicitSessionName = extractExplicitSessionName(call.toolArgs);
243
- const namespace = explicitSessionName !== undefined && explicitSessionName !== ""
244
- ? resolveAgentBrowserNamespace(call.toolArgs, getAgentBrowserProcessEnvironment().AGENT_BROWSER_NAMESPACE)
245
- : undefined;
246
- const serializeBrowserCommand = shouldSerializeBrowserCommand(this.runtime.managed.owned, this.runtime.electron.ownedRecords, {
247
- namespace,
248
- explicitSessionName,
249
- managedSessionName: this.runtime.managed.name,
250
- });
251
- const callerOwnedSessionQueueKey = !serializeBrowserCommand && explicitSessionName !== undefined && explicitSessionName !== ""
252
- ? (getSessionContextKey(explicitSessionName, namespace) ?? explicitSessionName)
253
- : undefined;
254
- return {
255
- ...call,
256
- explicitSessionName,
257
- callerOwnedSessionNamespace: namespace,
258
- serializeBrowserCommand,
259
- callerOwnedSessionQueueKey,
260
- closesAllSessions: commandClosesAllSessions(call.toolArgs, call.resolvedInput.toolStdin),
261
- };
262
- }
263
- async executeNative(prepared, input, defaults) {
264
- const admitted = this.prepareNative(prepared, input, defaults);
265
- if ("failure" in admitted) {
266
- return admitted.failure;
267
- }
268
- const { call } = admitted;
269
- if (this.needsVersionCheck(call)) {
270
- const failure = await validateUpstreamVersion(this.runtime.validatedUpstreamPathKeys, call.browserCwd, call.signal);
271
- if (failure) {
272
- return applyAgentBrowserOutputPath({
273
- cwd: call.operationCwd,
274
- outputPath: call.outputPath,
275
- result: failure,
276
- });
277
- }
278
- }
279
- const runHost = () => runCoordinatedElectronHostInput(this.runtime, call);
280
- const hostResult = await (shouldSerializeElectronHostInput(call.compiledElectron)
281
- ? this.runtime.managedSessionExecutionQueue.run(runHost, call.signal)
282
- : runHost());
283
- if (hostResult) {
284
- return call.compiledElectron?.action === "cleanup"
285
- ? hostResult
286
- : applyUnserializedOutputPath(this.runtime, call, hostResult);
287
- }
288
- return runWithinSessionQueue(this.runtime, this.coordinate(call));
289
- }
290
- async run() {
291
- const admitted = this.admit();
292
- if ("failure" in admitted) {
293
- return admitted.failure;
294
- }
295
- const { call } = admitted;
296
- return call.managedAtAdmission
297
- ? this.runtime.managedSessionExecutionQueue.run(() => this.executeAdmitted(call), call.signal)
298
- : this.executeAdmitted(call);
299
- }
300
- }
301
- export function executeBrowserInvocation(runtime, invocation) {
302
- return new BrowserAdmission(runtime, invocation).run();
303
- }
@@ -1,36 +0,0 @@
1
- import { buildValidationFailureResult } from "./input-plan.js";
2
- import { applyAgentBrowserOutputPath, canWriteAgentBrowserOutput } from "./output-file.js";
3
- import { getArtifactPreflightValidationError } from "./extension-artifact-preflight.js";
4
- import { warnRecordingPersistence, } from "./extension-recording.js";
5
- export async function applyUnserializedOutputPath(resources, call, result, preserveTextContent = false) {
6
- if (!(call.outputPath !== undefined && call.outputPath !== "") ||
7
- !canWriteAgentBrowserOutput(result)) {
8
- return warnRecordingPersistence(resources.recordings.dirty, result);
9
- }
10
- return resources.artifacts.queue.run(async () => {
11
- resources.recordings.flush();
12
- const reservationError = getArtifactPreflightValidationError({
13
- activeRecordingReservations: [...resources.recordings.active.values()],
14
- args: [],
15
- cwd: call.operationCwd,
16
- outputPath: call.outputPath,
17
- });
18
- if (reservationError !== undefined && reservationError !== "") {
19
- return warnRecordingPersistence(resources.recordings.dirty, buildValidationFailureResult({
20
- attemptedKind: call.resolvedInput.kind,
21
- kind: "invalid",
22
- redactedArgs: call.resolvedInput.redactedArgs,
23
- status: "invalid",
24
- toolArgs: call.resolvedInput.toolArgs,
25
- toolStdin: call.resolvedInput.toolStdin,
26
- validationError: reservationError,
27
- }));
28
- }
29
- return applyAgentBrowserOutputPath({
30
- cwd: call.operationCwd,
31
- outputPath: call.outputPath,
32
- preserveTextContent,
33
- result: warnRecordingPersistence(resources.recordings.dirty, result),
34
- });
35
- });
36
- }
@@ -1,335 +0,0 @@
1
- import { getSuccessfulBatchCloseLifecycle } from "../batch-lifecycle.js";
2
- import { appendBrowserTransition, applyArtifactChanges, artifactChanges, browserStateEffects, } from "../browser-transcript.js";
3
- import { appendBrowserRecord, hasPublishedBrowserJournal } from "../browser-journal.js";
4
- import { extractUpstreamCommandTokens } from "../runtime.js";
5
- import { isBooleanFlagEnabled, deleteIdentityKeysInNamespace, extractExplicitSessionName, getAgentBrowserSessionIdentityKey, isAgentBrowserSessionIdentityKeyInNamespace, } from "../argv-grammar.js";
6
- import { isRecord } from "../parsing.js";
7
- import { mergeBrowserRunArtifactManifest } from "./browser-run/artifact-merge.js";
8
- import { isCloseCommand } from "../command-taxonomy.js";
9
- import { getSessionContextKey } from "./browser-run/session-state.js";
10
- import { applyAgentBrowserOutputPath } from "./output-file.js";
11
- import { formatSessionArtifactRetentionSummary } from "../results/artifact-manifest.js";
12
- import { isSuccessfulNativeConfirmedClose } from "../read-confirmation.js";
13
- import { getArtifactCommandSteps } from "./extension-artifact-preflight.js";
14
- import { browserExecutionFailure, invocationArtifactManifest, browserPageChanges, } from "./extension-result-state.js";
15
- import { untrackOwnedManagedSession, syncOwnedManagedSessionsFromResult, } from "./extension-managed-ownership.js";
16
- import { getTouchedElectronLaunchIds } from "./extension-electron-ownership.js";
17
- import { warnRecordingPersistence, appendActiveRecordingCleanupAction, } from "./extension-recording.js";
18
- export class BrowserCommandResult {
19
- runtime;
20
- call;
21
- prepared;
22
- dispatch;
23
- result;
24
- branchRestoreStillCurrent;
25
- resultDetails;
26
- resultSessionName;
27
- resultNamespace;
28
- constructor(runtime, call, prepared, dispatch) {
29
- this.runtime = runtime;
30
- this.call = call;
31
- this.prepared = prepared;
32
- this.dispatch = dispatch;
33
- this.result = dispatch.result;
34
- this.branchRestoreStillCurrent = call.branch.isCurrent();
35
- this.resultDetails = isRecord(this.result.details) ? this.result.details : undefined;
36
- this.resultSessionName =
37
- typeof this.resultDetails?.sessionName === "string"
38
- ? this.resultDetails.sessionName
39
- : extractExplicitSessionName(call.toolArgs);
40
- this.resultNamespace =
41
- typeof this.resultDetails?.namespace === "string"
42
- ? this.resultDetails.namespace
43
- : prepared.selectedPlan.namespace;
44
- }
45
- reconcileNativeIdentity() {
46
- const { prepared } = this;
47
- if (prepared.browserRunState.confirmationPolicyMayBeEstablished === false) {
48
- prepared.workingPageState.setConfirmActions(prepared.selectedKey, prepared.priorPages.get(prepared.selectedKey)?.confirmActions);
49
- }
50
- this.annotateManagedIdentity();
51
- }
52
- resultMatchesManagedIdentity() {
53
- const details = this.resultDetails;
54
- if (!details ||
55
- typeof details.sessionName !== "string" ||
56
- !this.prepared.browserRunState.managedSessionActive) {
57
- return false;
58
- }
59
- return (getAgentBrowserSessionIdentityKey(details.sessionName, typeof details.namespace === "string" ? details.namespace : undefined) ===
60
- getAgentBrowserSessionIdentityKey(this.prepared.browserRunState.managedSessionName, this.prepared.browserRunState.managedSessionNamespace));
61
- }
62
- annotateManagedIdentity() {
63
- if (this.resultDetails && this.prepared.begin.event.state.wrapperManaged === true) {
64
- this.resultDetails.managedSessionSocketDir =
65
- this.prepared.begin.event.state.managedSessionSocketDir;
66
- }
67
- if (this.resultDetails && this.resultMatchesManagedIdentity()) {
68
- this.resultDetails.managedSessionCwd = this.prepared.browserRunState.managedSessionCwd;
69
- }
70
- }
71
- attachmentRemainsActive() {
72
- const outcome = isRecord(this.resultDetails?.managedSessionOutcome)
73
- ? this.resultDetails.managedSessionOutcome
74
- : undefined;
75
- return (this.result.isError !== true ||
76
- ((this.dispatch.attachedSessionRequested || this.dispatch.attachedSessionKnown) &&
77
- outcome?.activeAfter === true));
78
- }
79
- closesAttachment() {
80
- const tokens = extractUpstreamCommandTokens(this.call.toolArgs);
81
- return ((this.result.isError !== true &&
82
- (isCloseCommand(tokens[0]) ||
83
- isSuccessfulNativeConfirmedClose(tokens, this.resultDetails?.data))) ||
84
- getSuccessfulBatchCloseLifecycle(this.resultDetails?.batchSteps)?.endsClosed === true);
85
- }
86
- retainAttachment(key) {
87
- this.runtime.sessions.attached.add(key);
88
- this.result = {
89
- ...this.result,
90
- details: { ...this.resultDetails, attachedBrowserSession: true },
91
- };
92
- }
93
- shouldRetainAttachment() {
94
- return (this.attachmentRemainsActive() &&
95
- (this.dispatch.attachedSessionRequested || this.dispatch.attachedSessionKnown));
96
- }
97
- retainAfterCloseAll(key) {
98
- if (this.shouldRetainAttachment() &&
99
- getSuccessfulBatchCloseLifecycle(this.resultDetails?.batchSteps)?.endsClosed === false) {
100
- this.retainAttachment(key);
101
- }
102
- }
103
- reconcileAttachments() {
104
- if (!this.branchRestoreStillCurrent) {
105
- return;
106
- }
107
- const closeAll = this.resultDetails?.closeAllApplied === true;
108
- if (closeAll) {
109
- deleteIdentityKeysInNamespace(this.runtime.sessions.attached, this.resultNamespace);
110
- }
111
- const key = getSessionContextKey(this.resultSessionName, this.resultNamespace) ?? this.resultSessionName;
112
- if (key === undefined || key === "") {
113
- return;
114
- }
115
- if (closeAll) {
116
- this.retainAfterCloseAll(key);
117
- return;
118
- }
119
- if (this.closesAttachment()) {
120
- this.runtime.sessions.attached.delete(key);
121
- }
122
- else if (this.shouldRetainAttachment()) {
123
- this.retainAttachment(key);
124
- }
125
- }
126
- mergeRoutes() {
127
- const updated = this.prepared.browserRunState.networkRoutesBySession;
128
- const initial = this.dispatch.initialNetworkRoutesBySession;
129
- if (updated === initial) {
130
- return;
131
- }
132
- const merged = new Map(this.runtime.sessions.routes);
133
- for (const [key, value] of updated) {
134
- if (!initial.has(key) || initial.get(key) !== value) {
135
- merged.set(key, value);
136
- }
137
- }
138
- for (const key of initial.keys()) {
139
- if (!updated.has(key)) {
140
- merged.delete(key);
141
- }
142
- }
143
- this.runtime.sessions.routes = merged;
144
- }
145
- retireClosedRecordings() {
146
- const handled = this.runtime.recordings.syncResult(this.result);
147
- if (this.resultDetails?.closeAllApplied === true) {
148
- // Snapshot reservations because retiring an identity deletes from the live index.
149
- for (const [key, reservation] of Array.from(this.runtime.recordings.active)) {
150
- if (isAgentBrowserSessionIdentityKeyInNamespace(key, this.resultNamespace)) {
151
- this.runtime.recordings.retire(reservation.sessionName, reservation.namespace);
152
- }
153
- }
154
- }
155
- for (const key of this.prepared.browserRunState.closedManagedSessionNames) {
156
- if (handled.has(key)) {
157
- continue;
158
- }
159
- const reservation = this.runtime.recordings.active.get(key);
160
- if (reservation) {
161
- this.runtime.recordings.retire(reservation.sessionName, reservation.namespace);
162
- }
163
- }
164
- }
165
- appendRecordingCleanup() {
166
- if (this.resultSessionName === undefined || this.resultSessionName === "") {
167
- return;
168
- }
169
- const reservation = this.runtime.recordings.active.get(getAgentBrowserSessionIdentityKey(this.resultSessionName, this.resultNamespace));
170
- if (reservation) {
171
- this.result = appendActiveRecordingCleanupAction(this.result, reservation);
172
- }
173
- }
174
- mergeResultArtifacts() {
175
- if (!this.branchRestoreStillCurrent) {
176
- return;
177
- }
178
- this.mergeRoutes();
179
- this.runtime.artifacts.manifest = mergeBrowserRunArtifactManifest(this.runtime.artifacts.manifest, this.dispatch.initialArtifactManifest, this.prepared.browserRunState.artifactManifest);
180
- this.retireClosedRecordings();
181
- this.appendRecordingCleanup();
182
- if (this.runtime.artifacts.manifest && isRecord(this.result.details)) {
183
- this.result.details.artifactRetentionSummary = formatSessionArtifactRetentionSummary(this.runtime.artifacts.manifest);
184
- }
185
- }
186
- adoptRuntime() {
187
- const branchStateStillCurrent = this.prepared.generationAtStart === this.runtime.branch.stateGeneration &&
188
- this.call.branch.isCurrent();
189
- if (this.call.serializeBrowserCommand || branchStateStillCurrent) {
190
- this.runtime.managed.freshOrdinal = Math.max(this.runtime.managed.freshOrdinal, this.prepared.browserRunState.freshSessionOrdinal);
191
- this.runtime.managed.active = this.prepared.browserRunState.managedSessionActive;
192
- this.runtime.managed.compatibilityWorkaround =
193
- this.prepared.browserRunState.managedSessionCompatibilityWorkaround;
194
- this.runtime.managed.headedAutosaveDisabled =
195
- this.prepared.browserRunState.managedSessionHeadedAutosaveDisabled === true;
196
- this.runtime.managed.headedAutosaveInterval =
197
- this.prepared.browserRunState.managedSessionHeadedAutosaveInterval;
198
- this.runtime.managed.cwd = this.prepared.browserRunState.managedSessionCwd;
199
- this.runtime.managed.name = this.prepared.browserRunState.managedSessionName;
200
- this.runtime.managed.namespace = this.prepared.browserRunState.managedSessionNamespace;
201
- for (const closedSessionName of this.prepared.browserRunState.closedManagedSessionNames) {
202
- untrackOwnedManagedSession(this.runtime.managed.owned, closedSessionName);
203
- }
204
- syncOwnedManagedSessionsFromResult(this.runtime.managed.owned, this.result, this.prepared.browserRunState.managedSessionCwd);
205
- this.runtime.electron.mergeActive(this.runtime.electron.records, {
206
- ownerSessionId: this.call.ctx.sessionManager.getSessionId(),
207
- touchedLaunchIds: !(this.result.isError === true)
208
- ? getTouchedElectronLaunchIds(this.call.explicitSessionName ?? this.prepared.browserRunState.managedSessionName, this.runtime.electron.records, this.resultNamespace)
209
- : undefined,
210
- });
211
- if (this.call.serializeBrowserCommand) {
212
- this.runtime.branch.advanceState();
213
- }
214
- }
215
- }
216
- finishState() {
217
- return {
218
- ...browserStateEffects(isRecord(this.result.details) ? this.result.details : {}),
219
- ...this.prepared.browserRunState.observedBrowserEffects,
220
- ownerSessionId: this.call.ctx.sessionManager.getSessionId(),
221
- ...(this.prepared.begin.event.state.wrapperManaged === true
222
- ? {
223
- managedSessionDaemon: this.runtime.managed.restore.getDaemonReceipt(this.resultSessionName, this.resultNamespace),
224
- }
225
- : {}),
226
- };
227
- }
228
- needsFinish(pagesChanged, artifactsChanged) {
229
- return (this.prepared.browserAffecting ||
230
- pagesChanged ||
231
- (artifactsChanged && hasPublishedBrowserJournal(this.call.ctx.sessionManager)) ||
232
- this.resultDetails?.readConfirmation !== undefined ||
233
- this.prepared.browserRunState.observedBrowserEffects?.readConfirmation !== undefined);
234
- }
235
- buildFinish() {
236
- if (this.prepared.selectedPlan.plainTextInspection || !this.branchRestoreStillCurrent) {
237
- return undefined;
238
- }
239
- const changes = browserPageChanges(this.prepared.workingPageState, this.prepared.priorPages, [
240
- ...this.prepared.browserRunState.closedManagedSessionNames,
241
- ...(this.prepared.browserAffecting ? [this.prepared.selectedKey] : []),
242
- ]);
243
- const artifacts = artifactChanges(this.dispatch.initialArtifactManifest, this.runtime.artifacts.manifest);
244
- const requiresFinish = this.needsFinish(changes.pages.length > 0, artifacts !== undefined);
245
- if (!requiresFinish) {
246
- return undefined;
247
- }
248
- return {
249
- event: {
250
- version: 1,
251
- phase: this.prepared.browserAffecting ? "finish" : "state",
252
- operationId: this.prepared.operationId,
253
- toolCallId: this.call.toolCallId,
254
- commandIndex: this.call.commandIndex ?? 0,
255
- isError: this.result.isError === true,
256
- state: this.finishState(),
257
- pages: changes.pages,
258
- artifacts,
259
- },
260
- ...(changes.snapshot ? { snapshot: changes.snapshot } : {}),
261
- };
262
- }
263
- persistenceFailure(error) {
264
- return {
265
- ...this.result,
266
- ...browserExecutionFailure(new Error("The browser command finished, but its state could not be persisted. Changes may already have happened; inspect the current page before retrying.", { cause: error }), this.prepared.executionSignal),
267
- details: {
268
- ...(isRecord(this.result.details) ? this.result.details : {}),
269
- resultCategory: "failure",
270
- failureCategory: "upstream-error",
271
- browserStatePersistence: "finish-unconfirmed",
272
- nextActions: [
273
- {
274
- id: "inspect-after-browser-state-persistence-failure",
275
- tool: "agent_browser",
276
- params: {
277
- args: [
278
- "--session",
279
- this.prepared.selectedPlan.sessionName ?? "default",
280
- "--namespace",
281
- this.prepared.selectedPlan.namespace ?? "",
282
- "batch",
283
- "--bail",
284
- ],
285
- stdin: JSON.stringify([
286
- ["get", "url"],
287
- ["snapshot", "-i"],
288
- ]),
289
- },
290
- reason: "The effect may already have happened. Verify the current URL and inspect before deciding whether to retry.",
291
- safety: "Read-only inspection; no mutation is replayed.",
292
- },
293
- ],
294
- },
295
- };
296
- }
297
- async persistFinish() {
298
- const finish = this.buildFinish();
299
- if (!finish) {
300
- return undefined;
301
- }
302
- try {
303
- if (!(await appendBrowserRecord(this.call.ctx.sessionManager, () => appendBrowserTransition(this.runtime.pi, finish), finish, this.call.branch)) ||
304
- !this.call.branch.isCurrent()) {
305
- throw new Error("The selected Pi branch changed before browser-state confirmation.");
306
- }
307
- }
308
- catch (error) {
309
- return this.persistenceFailure(error);
310
- }
311
- this.runtime.sessions.pages.applyBrowserRecord(finish);
312
- this.runtime.artifacts.manifest = applyArtifactChanges(this.runtime.artifacts.manifest, finish.event.artifacts);
313
- return undefined;
314
- }
315
- async complete() {
316
- if (isRecord(this.result.details)) {
317
- this.result.details.browserEventVersion = 1;
318
- if (!(this.call.compiledElectron?.action === "launch" &&
319
- this.call.compiledElectron.handoff === "snapshot") &&
320
- !getArtifactCommandSteps(this.call.toolArgs, this.call.resolvedInput.toolStdin).steps.some((step) => step[0] === "snapshot")) {
321
- delete this.result.details.refSnapshot;
322
- }
323
- this.result.details.artifactManifest = invocationArtifactManifest(this.call.branch.isCurrent()
324
- ? this.runtime.artifacts.manifest
325
- : this.prepared.browserRunState.artifactManifest, this.dispatch.initialArtifactManifest, this.result.details);
326
- }
327
- return applyAgentBrowserOutputPath({
328
- cwd: this.call.operationCwd,
329
- outputPath: this.call.outputPath,
330
- preserveTextContent: Array.isArray(this.call.params.args) &&
331
- isBooleanFlagEnabled(this.call.params.args, "--json"),
332
- result: warnRecordingPersistence(this.runtime.recordings.dirty, this.result),
333
- });
334
- }
335
- }