pi-agent-browser-native 0.9.5 → 0.9.6

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 (380) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +3 -0
  3. package/dist/extensions/agent-browser/index.js +1214 -583
  4. package/dist/packaged/lib/browser-session-conversion.js +2810 -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 +694 -0
  8. package/dist/packaged/lib/results/snapshot.js +2671 -0
  9. package/dist/packaged/lib/runtime.js +3027 -0
  10. package/docs/ARCHITECTURE.md +11 -1
  11. package/docs/CODE_QUALITY.md +11 -0
  12. package/docs/COMMAND_REFERENCE.md +2 -2
  13. package/docs/PERFORMANCE.md +243 -0
  14. package/docs/REFERENCE.md +3 -3
  15. package/docs/SESSION_STORAGE.md +11 -3
  16. package/docs/SUPPORT_MATRIX.md +8 -4
  17. package/docs/TOOL_CONTRACT.md +4 -4
  18. package/docs/performance/2026-10-12.json +7257 -0
  19. package/package.json +13 -2
  20. package/scripts/build.mjs +16 -5
  21. package/scripts/config.mjs +1 -1
  22. package/scripts/convert-browser-session.mjs +1 -1
  23. package/dist/extensions/agent-browser/lib/argv-descriptor.js +0 -123
  24. package/dist/extensions/agent-browser/lib/argv-grammar.js +0 -320
  25. package/dist/extensions/agent-browser/lib/bash-guard.js +0 -193
  26. package/dist/extensions/agent-browser/lib/batch-lifecycle.js +0 -131
  27. package/dist/extensions/agent-browser/lib/browser-execution-claim-codec.js +0 -61
  28. package/dist/extensions/agent-browser/lib/browser-execution-claim-storage.js +0 -232
  29. package/dist/extensions/agent-browser/lib/browser-execution-claims.js +0 -202
  30. package/dist/extensions/agent-browser/lib/browser-execution-identity.js +0 -77
  31. package/dist/extensions/agent-browser/lib/browser-journal-branch.js +0 -98
  32. package/dist/extensions/agent-browser/lib/browser-journal-contracts.js +0 -1
  33. package/dist/extensions/agent-browser/lib/browser-journal-projection.js +0 -221
  34. package/dist/extensions/agent-browser/lib/browser-journal-reader.js +0 -89
  35. package/dist/extensions/agent-browser/lib/browser-journal-replay.js +0 -246
  36. package/dist/extensions/agent-browser/lib/browser-journal.js +0 -148
  37. package/dist/extensions/agent-browser/lib/browser-legacy-pages.js +0 -220
  38. package/dist/extensions/agent-browser/lib/browser-legacy-projection.js +0 -282
  39. package/dist/extensions/agent-browser/lib/browser-legacy-types.js +0 -1
  40. package/dist/extensions/agent-browser/lib/browser-session-conversion-stream.js +0 -217
  41. package/dist/extensions/agent-browser/lib/browser-session-conversion.js +0 -126
  42. package/dist/extensions/agent-browser/lib/browser-transcript-contracts.js +0 -35
  43. package/dist/extensions/agent-browser/lib/browser-transcript-validation.js +0 -166
  44. package/dist/extensions/agent-browser/lib/browser-transcript.js +0 -189
  45. package/dist/extensions/agent-browser/lib/browser-value-parsing.js +0 -15
  46. package/dist/extensions/agent-browser/lib/command-capabilities.js +0 -340
  47. package/dist/extensions/agent-browser/lib/command-policy.js +0 -155
  48. package/dist/extensions/agent-browser/lib/command-taxonomy.js +0 -105
  49. package/dist/extensions/agent-browser/lib/config-policy.js +0 -450
  50. package/dist/extensions/agent-browser/lib/config-providers.js +0 -71
  51. package/dist/extensions/agent-browser/lib/config-validation.js +0 -231
  52. package/dist/extensions/agent-browser/lib/config.js +0 -69
  53. package/dist/extensions/agent-browser/lib/electron/cdp.js +0 -62
  54. package/dist/extensions/agent-browser/lib/electron/cleanup.js +0 -274
  55. package/dist/extensions/agent-browser/lib/electron/discovery-darwin.js +0 -109
  56. package/dist/extensions/agent-browser/lib/electron/discovery-desktop.js +0 -136
  57. package/dist/extensions/agent-browser/lib/electron/discovery-evidence.js +0 -90
  58. package/dist/extensions/agent-browser/lib/electron/discovery-linux.js +0 -93
  59. package/dist/extensions/agent-browser/lib/electron/discovery-packages.js +0 -162
  60. package/dist/extensions/agent-browser/lib/electron/discovery-types.js +0 -2
  61. package/dist/extensions/agent-browser/lib/electron/discovery.js +0 -217
  62. package/dist/extensions/agent-browser/lib/electron/launch-monitor.js +0 -102
  63. package/dist/extensions/agent-browser/lib/electron/launch-process.js +0 -209
  64. package/dist/extensions/agent-browser/lib/electron/launch-types.js +0 -2
  65. package/dist/extensions/agent-browser/lib/electron/launch.js +0 -340
  66. package/dist/extensions/agent-browser/lib/executable-path.js +0 -29
  67. package/dist/extensions/agent-browser/lib/execution-cwd.js +0 -67
  68. package/dist/extensions/agent-browser/lib/fs-utils.js +0 -10
  69. package/dist/extensions/agent-browser/lib/input-modes/electron.js +0 -201
  70. package/dist/extensions/agent-browser/lib/input-modes/job.js +0 -198
  71. package/dist/extensions/agent-browser/lib/input-modes/lookup-network-evidence.js +0 -116
  72. package/dist/extensions/agent-browser/lib/input-modes/lookup-plan.js +0 -132
  73. package/dist/extensions/agent-browser/lib/input-modes/lookup-redaction.js +0 -57
  74. package/dist/extensions/agent-browser/lib/input-modes/lookup-source-evidence.js +0 -151
  75. package/dist/extensions/agent-browser/lib/input-modes/lookup-workspace.js +0 -142
  76. package/dist/extensions/agent-browser/lib/input-modes/lookups.js +0 -84
  77. package/dist/extensions/agent-browser/lib/input-modes/params.js +0 -195
  78. package/dist/extensions/agent-browser/lib/input-modes/qa-analysis.js +0 -268
  79. package/dist/extensions/agent-browser/lib/input-modes/qa-presentation.js +0 -117
  80. package/dist/extensions/agent-browser/lib/input-modes/script-child.js +0 -396
  81. package/dist/extensions/agent-browser/lib/input-modes/script-protocol.js +0 -86
  82. package/dist/extensions/agent-browser/lib/input-modes/script-types.js +0 -1
  83. package/dist/extensions/agent-browser/lib/input-modes/script-validation.js +0 -60
  84. package/dist/extensions/agent-browser/lib/input-modes/script.js +0 -108
  85. package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +0 -243
  86. package/dist/extensions/agent-browser/lib/input-modes/shared.js +0 -48
  87. package/dist/extensions/agent-browser/lib/input-modes/types.js +0 -65
  88. package/dist/extensions/agent-browser/lib/json-schema.js +0 -65
  89. package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +0 -212
  90. package/dist/extensions/agent-browser/lib/managed-session-policy-lock.js +0 -165
  91. package/dist/extensions/agent-browser/lib/managed-session-posix-storage.js +0 -58
  92. package/dist/extensions/agent-browser/lib/managed-session-project-identity.js +0 -244
  93. package/dist/extensions/agent-browser/lib/managed-session-restore-context.js +0 -84
  94. package/dist/extensions/agent-browser/lib/managed-session-restore-policy.js +0 -119
  95. package/dist/extensions/agent-browser/lib/managed-session-restore-state.js +0 -83
  96. package/dist/extensions/agent-browser/lib/managed-session-restore.js +0 -212
  97. package/dist/extensions/agent-browser/lib/managed-session-snapshot-records.js +0 -277
  98. package/dist/extensions/agent-browser/lib/managed-session-snapshots.js +0 -181
  99. package/dist/extensions/agent-browser/lib/managed-session-storage.js +0 -126
  100. package/dist/extensions/agent-browser/lib/native-confirmation.js +0 -140
  101. package/dist/extensions/agent-browser/lib/native-output.js +0 -81
  102. package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +0 -182
  103. package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-merge.js +0 -30
  104. package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-paths.js +0 -188
  105. package/dist/extensions/agent-browser/lib/orchestration/browser-run/browser-observation-result.js +0 -82
  106. package/dist/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.js +0 -406
  107. package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostic-values.js +0 -31
  108. package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +0 -240
  109. package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-observation.js +0 -203
  110. package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-text-diagnostics.js +0 -109
  111. package/dist/extensions/agent-browser/lib/orchestration/browser-run/fill-diagnostics.js +0 -119
  112. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-action-recovery.js +0 -147
  113. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-actions.js +0 -144
  114. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-content.js +0 -123
  115. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-contracts.js +0 -1
  116. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-details.js +0 -156
  117. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-electron.js +0 -187
  118. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-evidence.js +0 -39
  119. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-missing-binary.js +0 -89
  120. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-recovery.js +0 -97
  121. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-redaction.js +0 -106
  122. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-timeout.js +0 -110
  123. package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +0 -53
  124. package/dist/extensions/agent-browser/lib/orchestration/browser-run/index.js +0 -224
  125. package/dist/extensions/agent-browser/lib/orchestration/browser-run/interaction-diagnostics.js +0 -290
  126. package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-close.js +0 -167
  127. package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-inspection.js +0 -108
  128. package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js +0 -174
  129. package/dist/extensions/agent-browser/lib/orchestration/browser-run/native-helper-observation.js +0 -65
  130. package/dist/extensions/agent-browser/lib/orchestration/browser-run/observation-types.js +0 -1
  131. package/dist/extensions/agent-browser/lib/orchestration/browser-run/overlay-diagnostics.js +0 -120
  132. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +0 -192
  133. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +0 -225
  134. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter-data.js +0 -150
  135. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +0 -174
  136. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-rendered-text.js +0 -147
  137. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/wait-timeouts.js +0 -145
  138. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-artifacts.js +0 -159
  139. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-command.js +0 -131
  140. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-contracts.js +0 -1
  141. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-daemon.js +0 -93
  142. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-failure.js +0 -42
  143. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-guards.js +0 -242
  144. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-input.js +0 -75
  145. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-observations.js +0 -92
  146. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-selection.js +0 -254
  147. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-state.js +0 -121
  148. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-refs.js +0 -130
  149. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-resources.js +0 -114
  150. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-semantic.js +0 -121
  151. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-session-plan.js +0 -222
  152. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-timeouts.js +0 -68
  153. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +0 -202
  154. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-analysis.js +0 -191
  155. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-confirmation.js +0 -152
  156. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-diagnostics.js +0 -182
  157. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-electron.js +0 -150
  158. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-contracts.js +0 -1
  159. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase-contracts.js +0 -1
  160. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase.js +0 -115
  161. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle.js +0 -256
  162. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed-contracts.js +0 -1
  163. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed.js +0 -256
  164. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase-contracts.js +0 -1
  165. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase.js +0 -93
  166. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native.js +0 -113
  167. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation-contracts.js +0 -1
  168. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation.js +0 -316
  169. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-ownership.js +0 -28
  170. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase-contracts.js +0 -1
  171. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase.js +0 -142
  172. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation-contracts.js +0 -1
  173. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation.js +0 -333
  174. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase-contracts.js +0 -1
  175. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase.js +0 -71
  176. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication.js +0 -201
  177. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-receipts.js +0 -183
  178. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-refs.js +0 -200
  179. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-tabs.js +0 -142
  180. package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +0 -25
  181. package/dist/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.js +0 -50
  182. package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-receipt-reconciliation.js +0 -198
  183. package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-contracts.js +0 -1
  184. package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-presentation.js +0 -154
  185. package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery.js +0 -80
  186. package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-capture.js +0 -14
  187. package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-observation.js +0 -206
  188. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-commands.js +0 -130
  189. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-electron.js +0 -212
  190. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-observations.js +0 -61
  191. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-outcomes.js +0 -187
  192. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-refs.js +0 -169
  193. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-tabs.js +0 -228
  194. package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +0 -117
  195. package/dist/extensions/agent-browser/lib/orchestration/browser-run/text-visibility-diagnostics.js +0 -182
  196. package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-diagnostics.js +0 -256
  197. package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-progress.js +0 -108
  198. package/dist/extensions/agent-browser/lib/orchestration/browser-run/types.js +0 -1
  199. package/dist/extensions/agent-browser/lib/orchestration/code-artifact-observation.js +0 -39
  200. package/dist/extensions/agent-browser/lib/orchestration/code-image-observation.js +0 -119
  201. package/dist/extensions/agent-browser/lib/orchestration/electron-host/branch.js +0 -93
  202. package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup-result.js +0 -58
  203. package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup.js +0 -78
  204. package/dist/extensions/agent-browser/lib/orchestration/electron-host/contracts.js +0 -1
  205. package/dist/extensions/agent-browser/lib/orchestration/electron-host/discovery.js +0 -106
  206. package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +0 -60
  207. package/dist/extensions/agent-browser/lib/orchestration/electron-host/policy.js +0 -86
  208. package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-collection.js +0 -68
  209. package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-data.js +0 -169
  210. package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-presentation.js +0 -182
  211. package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe.js +0 -161
  212. package/dist/extensions/agent-browser/lib/orchestration/electron-host/status.js +0 -167
  213. package/dist/extensions/agent-browser/lib/orchestration/execution-queue.js +0 -98
  214. package/dist/extensions/agent-browser/lib/orchestration/extension-artifact-preflight.js +0 -211
  215. package/dist/extensions/agent-browser/lib/orchestration/extension-artifacts.js +0 -23
  216. package/dist/extensions/agent-browser/lib/orchestration/extension-attachment-replay.js +0 -99
  217. package/dist/extensions/agent-browser/lib/orchestration/extension-branch-restore.js +0 -275
  218. package/dist/extensions/agent-browser/lib/orchestration/extension-code.js +0 -280
  219. package/dist/extensions/agent-browser/lib/orchestration/extension-command-admission.js +0 -303
  220. package/dist/extensions/agent-browser/lib/orchestration/extension-command-output.js +0 -36
  221. package/dist/extensions/agent-browser/lib/orchestration/extension-command-result.js +0 -335
  222. package/dist/extensions/agent-browser/lib/orchestration/extension-command-run.js +0 -227
  223. package/dist/extensions/agent-browser/lib/orchestration/extension-command-state.js +0 -1
  224. package/dist/extensions/agent-browser/lib/orchestration/extension-electron-ownership.js +0 -204
  225. package/dist/extensions/agent-browser/lib/orchestration/extension-execution-locks.js +0 -139
  226. package/dist/extensions/agent-browser/lib/orchestration/extension-execution-queue.js +0 -24
  227. package/dist/extensions/agent-browser/lib/orchestration/extension-host-coordination.js +0 -98
  228. package/dist/extensions/agent-browser/lib/orchestration/extension-host-run.js +0 -295
  229. package/dist/extensions/agent-browser/lib/orchestration/extension-intent-replay.js +0 -41
  230. package/dist/extensions/agent-browser/lib/orchestration/extension-invocation.js +0 -7
  231. package/dist/extensions/agent-browser/lib/orchestration/extension-lifecycle.js +0 -102
  232. package/dist/extensions/agent-browser/lib/orchestration/extension-managed-ownership.js +0 -133
  233. package/dist/extensions/agent-browser/lib/orchestration/extension-observation.js +0 -120
  234. package/dist/extensions/agent-browser/lib/orchestration/extension-prompt.js +0 -180
  235. package/dist/extensions/agent-browser/lib/orchestration/extension-recording.js +0 -290
  236. package/dist/extensions/agent-browser/lib/orchestration/extension-resource-contracts.js +0 -1
  237. package/dist/extensions/agent-browser/lib/orchestration/extension-resource-replay.js +0 -269
  238. package/dist/extensions/agent-browser/lib/orchestration/extension-result-state.js +0 -113
  239. package/dist/extensions/agent-browser/lib/orchestration/extension-runtime.js +0 -146
  240. package/dist/extensions/agent-browser/lib/orchestration/extension-script-leases.js +0 -58
  241. package/dist/extensions/agent-browser/lib/orchestration/extension-tool-boundary.js +0 -62
  242. package/dist/extensions/agent-browser/lib/orchestration/extension-version-check.js +0 -54
  243. package/dist/extensions/agent-browser/lib/orchestration/input-plan-types.js +0 -1
  244. package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +0 -313
  245. package/dist/extensions/agent-browser/lib/orchestration/input-redaction.js +0 -62
  246. package/dist/extensions/agent-browser/lib/orchestration/native-config.js +0 -144
  247. package/dist/extensions/agent-browser/lib/orchestration/native-root-launch.js +0 -77
  248. package/dist/extensions/agent-browser/lib/orchestration/native-session-defaults.js +0 -231
  249. package/dist/extensions/agent-browser/lib/orchestration/operation-paths.js +0 -142
  250. package/dist/extensions/agent-browser/lib/orchestration/output-file.js +0 -276
  251. package/dist/extensions/agent-browser/lib/orchestration/script-mode.js +0 -220
  252. package/dist/extensions/agent-browser/lib/owned-managed-session-context.js +0 -55
  253. package/dist/extensions/agent-browser/lib/page-target-batch.js +0 -118
  254. package/dist/extensions/agent-browser/lib/page-target-guards.js +0 -50
  255. package/dist/extensions/agent-browser/lib/page-target-navigation.js +0 -104
  256. package/dist/extensions/agent-browser/lib/page-target-validation.js +0 -90
  257. package/dist/extensions/agent-browser/lib/parsing.js +0 -30
  258. package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +0 -343
  259. package/dist/extensions/agent-browser/lib/playbook.js +0 -146
  260. package/dist/extensions/agent-browser/lib/process-child.js +0 -284
  261. package/dist/extensions/agent-browser/lib/process-environment.js +0 -48
  262. package/dist/extensions/agent-browser/lib/process-errors.js +0 -23
  263. package/dist/extensions/agent-browser/lib/process-identity.js +0 -127
  264. package/dist/extensions/agent-browser/lib/process-socket-storage.js +0 -256
  265. package/dist/extensions/agent-browser/lib/process-stdout.js +0 -74
  266. package/dist/extensions/agent-browser/lib/process.js +0 -216
  267. package/dist/extensions/agent-browser/lib/prompt-artifacts.js +0 -287
  268. package/dist/extensions/agent-browser/lib/prompt-policy.js +0 -54
  269. package/dist/extensions/agent-browser/lib/read-command.js +0 -41
  270. package/dist/extensions/agent-browser/lib/read-confirmation.js +0 -162
  271. package/dist/extensions/agent-browser/lib/recording-reservations.js +0 -208
  272. package/dist/extensions/agent-browser/lib/redaction-fields.js +0 -75
  273. package/dist/extensions/agent-browser/lib/redaction-json.js +0 -149
  274. package/dist/extensions/agent-browser/lib/redaction-url.js +0 -88
  275. package/dist/extensions/agent-browser/lib/results/action-contracts.js +0 -1
  276. package/dist/extensions/agent-browser/lib/results/action-recommendations.js +0 -38
  277. package/dist/extensions/agent-browser/lib/results/artifact-contracts.js +0 -1
  278. package/dist/extensions/agent-browser/lib/results/artifact-manifest-validation.js +0 -133
  279. package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +0 -173
  280. package/dist/extensions/agent-browser/lib/results/artifact-recommendations.js +0 -73
  281. package/dist/extensions/agent-browser/lib/results/categories.js +0 -152
  282. package/dist/extensions/agent-browser/lib/results/confirmation.js +0 -75
  283. package/dist/extensions/agent-browser/lib/results/contracts.js +0 -1
  284. package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +0 -99
  285. package/dist/extensions/agent-browser/lib/results/electron-recommendations.js +0 -83
  286. package/dist/extensions/agent-browser/lib/results/envelope-decoding.js +0 -48
  287. package/dist/extensions/agent-browser/lib/results/envelope.js +0 -198
  288. package/dist/extensions/agent-browser/lib/results/evidence-contracts.js +0 -1
  289. package/dist/extensions/agent-browser/lib/results/failure-recommendations.js +0 -180
  290. package/dist/extensions/agent-browser/lib/results/network-routes.js +0 -133
  291. package/dist/extensions/agent-browser/lib/results/network.js +0 -89
  292. package/dist/extensions/agent-browser/lib/results/next-actions.js +0 -111
  293. package/dist/extensions/agent-browser/lib/results/presentation/artifact-files.js +0 -320
  294. package/dist/extensions/agent-browser/lib/results/presentation/artifact-format.js +0 -138
  295. package/dist/extensions/agent-browser/lib/results/presentation/artifact-images.js +0 -113
  296. package/dist/extensions/agent-browser/lib/results/presentation/artifact-verification.js +0 -145
  297. package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +0 -165
  298. package/dist/extensions/agent-browser/lib/results/presentation/batch-contracts.js +0 -1
  299. package/dist/extensions/agent-browser/lib/results/presentation/batch-recording.js +0 -118
  300. package/dist/extensions/agent-browser/lib/results/presentation/batch-redaction.js +0 -68
  301. package/dist/extensions/agent-browser/lib/results/presentation/batch-rendering.js +0 -135
  302. package/dist/extensions/agent-browser/lib/results/presentation/batch-step.js +0 -227
  303. package/dist/extensions/agent-browser/lib/results/presentation/batch-summary.js +0 -91
  304. package/dist/extensions/agent-browser/lib/results/presentation/batch.js +0 -123
  305. package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +0 -54
  306. package/dist/extensions/agent-browser/lib/results/presentation/command-presenters.js +0 -216
  307. package/dist/extensions/agent-browser/lib/results/presentation/common.js +0 -81
  308. package/dist/extensions/agent-browser/lib/results/presentation/content.js +0 -119
  309. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-a11y.js +0 -67
  310. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-health.js +0 -79
  311. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-identity.js +0 -199
  312. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-logs.js +0 -75
  313. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network-actions.js +0 -216
  314. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network.js +0 -124
  315. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-redaction.js +0 -64
  316. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-storage.js +0 -209
  317. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-stream.js +0 -69
  318. package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-summary.js +0 -222
  319. package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +0 -124
  320. package/dist/extensions/agent-browser/lib/results/presentation/early-result.js +0 -70
  321. package/dist/extensions/agent-browser/lib/results/presentation/errors.js +0 -285
  322. package/dist/extensions/agent-browser/lib/results/presentation/input-contracts.js +0 -1
  323. package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +0 -117
  324. package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +0 -231
  325. package/dist/extensions/agent-browser/lib/results/presentation/notices.js +0 -75
  326. package/dist/extensions/agent-browser/lib/results/presentation/observation-contracts.js +0 -1
  327. package/dist/extensions/agent-browser/lib/results/presentation/observation-rendering.js +0 -127
  328. package/dist/extensions/agent-browser/lib/results/presentation/outcomes.js +0 -120
  329. package/dist/extensions/agent-browser/lib/results/presentation/output-completion.js +0 -77
  330. package/dist/extensions/agent-browser/lib/results/presentation/output-spill.js +0 -51
  331. package/dist/extensions/agent-browser/lib/results/presentation/registry.js +0 -145
  332. package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +0 -104
  333. package/dist/extensions/agent-browser/lib/results/presentation/skills.js +0 -183
  334. package/dist/extensions/agent-browser/lib/results/presentation/source.js +0 -109
  335. package/dist/extensions/agent-browser/lib/results/presentation.js +0 -19
  336. package/dist/extensions/agent-browser/lib/results/recommendation-contracts.js +0 -1
  337. package/dist/extensions/agent-browser/lib/results/recording.js +0 -88
  338. package/dist/extensions/agent-browser/lib/results/recovery-actions.js +0 -118
  339. package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +0 -60
  340. package/dist/extensions/agent-browser/lib/results/selector-recovery-target.js +0 -83
  341. package/dist/extensions/agent-browser/lib/results/selector-recovery.js +0 -261
  342. package/dist/extensions/agent-browser/lib/results/snapshot-compact.js +0 -266
  343. package/dist/extensions/agent-browser/lib/results/snapshot-content.js +0 -32
  344. package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +0 -240
  345. package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +0 -103
  346. package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +0 -383
  347. package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +0 -53
  348. package/dist/extensions/agent-browser/lib/results/snapshot.js +0 -44
  349. package/dist/extensions/agent-browser/lib/results/text.js +0 -44
  350. package/dist/extensions/agent-browser/lib/runtime-args-validation.js +0 -133
  351. package/dist/extensions/agent-browser/lib/runtime-compatibility.js +0 -81
  352. package/dist/extensions/agent-browser/lib/runtime-contracts.js +0 -1
  353. package/dist/extensions/agent-browser/lib/runtime-redaction.js +0 -118
  354. package/dist/extensions/agent-browser/lib/runtime-replay-events.js +0 -144
  355. package/dist/extensions/agent-browser/lib/runtime-session-identity.js +0 -76
  356. package/dist/extensions/agent-browser/lib/runtime-session-plan.js +0 -114
  357. package/dist/extensions/agent-browser/lib/runtime-session-replay.js +0 -123
  358. package/dist/extensions/agent-browser/lib/runtime-tab-correction.js +0 -65
  359. package/dist/extensions/agent-browser/lib/runtime-timeouts.js +0 -28
  360. package/dist/extensions/agent-browser/lib/runtime.js +0 -163
  361. package/dist/extensions/agent-browser/lib/session-identity.js +0 -51
  362. package/dist/extensions/agent-browser/lib/session-page-observation.js +0 -357
  363. package/dist/extensions/agent-browser/lib/session-page-state.js +0 -353
  364. package/dist/extensions/agent-browser/lib/session-page-types.js +0 -1
  365. package/dist/extensions/agent-browser/lib/string-enum-schema.js +0 -8
  366. package/dist/extensions/agent-browser/lib/temp-artifact-budget.js +0 -81
  367. package/dist/extensions/agent-browser/lib/temp-mutation-queue.js +0 -7
  368. package/dist/extensions/agent-browser/lib/temp-root-ownership.js +0 -234
  369. package/dist/extensions/agent-browser/lib/temp-root.js +0 -211
  370. package/dist/extensions/agent-browser/lib/temp.js +0 -91
  371. package/dist/extensions/agent-browser/lib/tool-surface.js +0 -239
  372. package/dist/extensions/agent-browser/lib/upstream-version.js +0 -15
  373. package/dist/extensions/agent-browser/lib/web-search-providers.js +0 -193
  374. package/dist/extensions/agent-browser/lib/web-search-request.js +0 -102
  375. package/dist/extensions/agent-browser/lib/web-search-results.js +0 -281
  376. package/dist/extensions/agent-browser/lib/web-search-schema.js +0 -82
  377. package/dist/extensions/agent-browser/lib/web-search.js +0 -167
  378. package/dist/extensions/agent-browser/lib/webmcp-observation.js +0 -35
  379. package/dist/extensions/agent-browser/lib/windows-stock-launcher.js +0 -96
  380. package/dist/scripts/agent-browser-target.mjs +0 -23
@@ -1,138 +0,0 @@
1
- import { isPendingRecordingArtifact } from "../artifact-manifest.js";
2
- import { formatRecordingReceipt } from "../recording.js";
3
- import { isDownloadWaitSubcommand } from "./artifact-files.js";
4
- export function formatByteCount(bytes) {
5
- if (bytes < 1_024) {
6
- return `${bytes} B`;
7
- }
8
- if (bytes < 1_024 * 1_024) {
9
- return `${(bytes / 1_024).toFixed(1)} KiB`;
10
- }
11
- return `${(bytes / (1_024 * 1_024)).toFixed(1)} MiB`;
12
- }
13
- function formatPreviousRecordingLabel(artifact) {
14
- if (artifact.status === "stale") {
15
- return "Previous recording stale";
16
- }
17
- return artifact.exists === false ? "Previous recording missing" : "Previous recording saved";
18
- }
19
- function formatRecordingLabel(artifact) {
20
- const previous = artifact.subcommand === "restart-previous";
21
- if (artifact.status === "failed") {
22
- return previous ? "Previous recording failed" : "Recording failed";
23
- }
24
- if (artifact.status === "unverified") {
25
- return previous ? "Previous recording unverified" : "Recording unverified";
26
- }
27
- if (artifact.command === "record" && previous) {
28
- return formatPreviousRecordingLabel(artifact);
29
- }
30
- if (!isPendingRecordingArtifact(artifact)) {
31
- return artifact.status === "saved"
32
- ? "Saved recording"
33
- : "Recording reported; file not verified";
34
- }
35
- return formatPendingRecordingLabel(artifact.subcommand);
36
- }
37
- function formatPendingRecordingLabel(subcommand) {
38
- if (subcommand === "stop") {
39
- return "Recording finalization pending";
40
- }
41
- return subcommand === "restart"
42
- ? "Recording restarted; output will be written on stop"
43
- : "Recording started; output will be written on stop";
44
- }
45
- function formatDownloadLabel(artifact) {
46
- const wait = artifact.command === "wait" && isDownloadWaitSubcommand(artifact.subcommand);
47
- if (artifact.exists !== true) {
48
- return wait
49
- ? "Download event reported; file not verified"
50
- : "Download reported; file not verified";
51
- }
52
- return wait ? "Download saved and verified" : "Downloaded file verified";
53
- }
54
- function formatImageLabel(artifact) {
55
- const diff = artifact.command === "diff" && artifact.subcommand === "screenshot";
56
- if (artifact.exists !== true) {
57
- return diff ? "Diff image reported; file not verified" : "Image reported; file not verified";
58
- }
59
- return diff ? "Saved diff image" : "Saved image";
60
- }
61
- function formatArtifactLabel(artifact) {
62
- switch (artifact.kind) {
63
- case "download":
64
- return formatDownloadLabel(artifact);
65
- case "file":
66
- return artifact.command === "state" ? "State file" : "Saved file";
67
- case "har":
68
- return "Saved HAR";
69
- case "image":
70
- return formatImageLabel(artifact);
71
- case "pdf":
72
- return "Saved PDF";
73
- case "profile":
74
- return "Saved profile";
75
- case "trace":
76
- return "Saved trace";
77
- case "video":
78
- return formatRecordingLabel(artifact);
79
- }
80
- }
81
- export function formatArtifactSummary(artifacts) {
82
- if (artifacts.length === 0) {
83
- return undefined;
84
- }
85
- if (artifacts.length === 1) {
86
- const artifact = artifacts[0];
87
- return `${formatArtifactLabel(artifact)}: ${artifact.path}`;
88
- }
89
- const restartArtifact = artifacts.find((artifact) => isPendingRecordingArtifact(artifact) && artifact.subcommand === "restart");
90
- const previous = artifacts.filter((artifact) => artifact.command === "record" && artifact.subcommand === "restart-previous");
91
- if (restartArtifact && previous.length > 0) {
92
- return [...previous, restartArtifact]
93
- .map((artifact) => `${formatArtifactLabel(artifact)}: ${artifact.path}`)
94
- .join("\n");
95
- }
96
- return `${artifacts.every((artifact) => artifact.status === "saved") ? "Saved" : "Reported"} ${artifacts.length} artifacts: ${artifacts.map((artifact) => `${artifact.kind} ${artifact.path}`).join(", ")}`;
97
- }
98
- function optionalField(label, value) {
99
- return value !== undefined && value.length > 0 ? `${label}: ${value}` : undefined;
100
- }
101
- function formatPendingDetails(artifact) {
102
- return [
103
- `Exists: ${artifact.exists ?? "pending until record stop"}`,
104
- `Status: ${artifact.status ?? "pending"}`,
105
- `Recording state: ${artifact.recordingState ?? "openRecording"}`,
106
- `Will exist on stop: ${artifact.willExistOnStop !== false}`,
107
- ];
108
- }
109
- function formatFileDetails(artifact) {
110
- return [
111
- `Exists: ${artifact.exists ?? "unknown"}`,
112
- artifact.exists === false ? "not found on disk" : undefined,
113
- typeof artifact.sizeBytes === "number"
114
- ? `Size: ${formatByteCount(artifact.sizeBytes)}`
115
- : undefined,
116
- typeof artifact.sizeBytes === "number" ? `Size bytes: ${artifact.sizeBytes}` : undefined,
117
- `Status: ${artifact.status ?? (artifact.exists === false ? "missing" : "saved")}`,
118
- optionalField("Reported path", artifact.tempPath),
119
- optionalField("Media type", artifact.mediaType),
120
- ];
121
- }
122
- export function formatArtifactMetadataLines(artifacts) {
123
- return artifacts.map((artifact, index) => [
124
- `${formatArtifactLabel(artifact)}: ${artifact.path}`,
125
- `Artifact type: ${artifact.kind}`,
126
- optionalField("Requested path", artifact.requestedPath),
127
- `Absolute path: ${artifact.absolutePath}`,
128
- ...(isPendingRecordingArtifact(artifact)
129
- ? formatPendingDetails(artifact)
130
- : formatFileDetails(artifact)),
131
- optionalField("Session", artifact.session),
132
- optionalField("CWD", artifact.cwd),
133
- artifact.recording ? formatRecordingReceipt(artifact.recording) : undefined,
134
- `Machine data: details.artifacts[${index}]`,
135
- ]
136
- .filter((item) => item !== undefined)
137
- .join("\n"));
138
- }
@@ -1,113 +0,0 @@
1
- import { readFile, stat } from "node:fs/promises";
2
- import { resolve } from "node:path";
3
- import { inspect } from "node:util";
4
- import { getImageDimensions } from "@earendil-works/pi-tui";
5
- import { isRecord, parsePositiveInteger } from "../../parsing.js";
6
- import { LIGHTPANDA_IMAGE_REASON } from "./common.js";
7
- import { getImageMimeType, isNonFileArtifactPathCandidate, readImageHeader, } from "./artifact-files.js";
8
- import { formatByteCount } from "./artifact-format.js";
9
- const DEFAULT_INLINE_IMAGE_MAX_BYTES = 5 * 1_024 * 1_024;
10
- function getInlineImageMaxBytes(env = process.env) {
11
- return (parsePositiveInteger(env.PI_AGENT_BROWSER_INLINE_IMAGE_MAX_BYTES) ??
12
- DEFAULT_INLINE_IMAGE_MAX_BYTES);
13
- }
14
- export function appendPresentationNotice(presentation, message) {
15
- const existingText = presentation.content[0]?.type === "text" ? presentation.content[0].text : "";
16
- presentation.content[0] = {
17
- type: "text",
18
- text: existingText.length > 0 ? `${existingText}\n\n${message}` : message,
19
- };
20
- }
21
- export function getScreenshotSummary(data) {
22
- if (data.changed === false) {
23
- return "Screenshot unchanged; no image saved.";
24
- }
25
- return typeof data.path === "string" ? `Saved image: ${data.path}` : undefined;
26
- }
27
- export function extractImagePath(commandInfo, cwd, data) {
28
- if (commandInfo.command !== "screenshot") {
29
- return undefined;
30
- }
31
- let path;
32
- if (typeof data === "string") {
33
- path = data;
34
- }
35
- else if (isRecord(data) && typeof data.path === "string") {
36
- path = data.path;
37
- }
38
- return path !== undefined && path.trim().length > 0 && !isNonFileArtifactPathCandidate(path)
39
- ? resolve(cwd, path)
40
- : undefined;
41
- }
42
- function isTextRendered(data) {
43
- if (!isRecord(data) || !isRecord(data.lifecycle)) {
44
- return false;
45
- }
46
- return (isRecord(data.lifecycle.effectiveLaunch) &&
47
- data.lifecycle.effectiveLaunch.engine === "lightpanda");
48
- }
49
- function buildImageObservation(imagePath, header, mimeType, textRendered) {
50
- const dimensions = getImageDimensions(header.toString("base64"), mimeType);
51
- let reason = "Image dimensions could not be read from the bounded header.";
52
- if (dimensions) {
53
- reason = "Capture geometry was not observed.";
54
- }
55
- if (textRendered) {
56
- reason = LIGHTPANDA_IMAGE_REASON;
57
- }
58
- return {
59
- path: imagePath,
60
- mimeType,
61
- ...(textRendered ? { rendering: "text" } : {}),
62
- pixels: dimensions ? { width: dimensions.widthPx, height: dimensions.heightPx } : undefined,
63
- capture: "unknown",
64
- geometry: { status: "unknown", reason },
65
- };
66
- }
67
- async function attachVisibleImage(presentation, options) {
68
- if (options.textRendered) {
69
- appendPresentationNotice(presentation, LIGHTPANDA_IMAGE_REASON);
70
- }
71
- const limit = getInlineImageMaxBytes();
72
- if (options.size > limit) {
73
- appendPresentationNotice(presentation, `Image attachment skipped: ${formatByteCount(options.size)} exceeds the inline limit of ${formatByteCount(limit)}.`);
74
- return;
75
- }
76
- const file = await readFile(options.imagePath);
77
- presentation.content.push({
78
- type: "image",
79
- data: file.toString("base64"),
80
- mimeType: options.mimeType,
81
- });
82
- }
83
- export async function attachInlineImage(presentation, imagePath, modelVisible = true) {
84
- try {
85
- const fileStats = await stat(imagePath);
86
- // Pi's dimension API accepts base64. Encode only a bounded header, never the whole code-mode image.
87
- const header = await readImageHeader(imagePath, 64 * 1024);
88
- const mimeType = getImageMimeType(header);
89
- if (mimeType === undefined) {
90
- return presentation;
91
- }
92
- const textRendered = isTextRendered(presentation.data);
93
- presentation.imagePath = imagePath;
94
- presentation.imageObservations = [
95
- buildImageObservation(imagePath, header, mimeType, textRendered),
96
- ];
97
- if (modelVisible) {
98
- await attachVisibleImage(presentation, {
99
- imagePath,
100
- size: fileStats.size,
101
- mimeType,
102
- textRendered,
103
- });
104
- }
105
- return presentation;
106
- }
107
- catch (error) {
108
- const message = error instanceof Error ? error.message : inspect(error);
109
- appendPresentationNotice(presentation, `Image attachment failed: ${message}`);
110
- presentation.imagePath = imagePath;
111
- return presentation;
112
- }
113
- }
@@ -1,145 +0,0 @@
1
- import { isPendingRecordingArtifact } from "../artifact-manifest.js";
2
- import { classifyAgentBrowserSuccessCategory } from "../categories.js";
3
- function artifactState(artifact) {
4
- if (["failed", "stale", "unverified"].includes(artifact.status ?? "")) {
5
- return "unverified";
6
- }
7
- if (artifact.exists === true) {
8
- return "verified";
9
- }
10
- return artifact.exists === false ? "missing" : "unverified";
11
- }
12
- function artifactLimitation(artifact, state) {
13
- if (artifact.status === "failed" || artifact.status === "unverified") {
14
- return "File presence does not prove successful native recording finalization or encoding. Inspect the receipt and original failure.";
15
- }
16
- if (artifact.status === "stale") {
17
- return "The reported path's modification time fell outside this command's bounded artifact window. Treat the artifact as stale until regenerated.";
18
- }
19
- if (state === "missing") {
20
- return "The wrapper did not find the reported artifact at absolutePath. Treat the path as unverified until recovered or regenerated.";
21
- }
22
- return state === "unverified"
23
- ? "The wrapper could not prove local filesystem existence for this artifact."
24
- : undefined;
25
- }
26
- function getArtifactVerificationEntry(artifact) {
27
- const common = {
28
- absolutePath: artifact.absolutePath,
29
- exists: artifact.exists,
30
- kind: artifact.kind,
31
- recording: artifact.recording,
32
- recordingStartedAtMs: artifact.recordingStartedAtMs,
33
- mediaType: artifact.mediaType,
34
- path: artifact.path,
35
- requestedPath: artifact.requestedPath,
36
- sizeBytes: artifact.sizeBytes,
37
- };
38
- if (isPendingRecordingArtifact(artifact)) {
39
- return {
40
- ...common,
41
- limitation: "Recording output is pending until native finalization succeeds and the file is verified.",
42
- recordingState: artifact.recordingState ?? "openRecording",
43
- retentionState: undefined,
44
- state: "pending",
45
- status: artifact.status ?? "pending",
46
- storageScope: undefined,
47
- willExistOnStop: artifact.willExistOnStop ?? true,
48
- };
49
- }
50
- const state = artifactState(artifact);
51
- return {
52
- ...common,
53
- limitation: artifactLimitation(artifact, state),
54
- retentionState: artifact.exists === false ? "missing" : "live",
55
- state,
56
- status: artifact.status,
57
- storageScope: "explicit-path",
58
- updatedAtMs: artifact.updatedAtMs,
59
- };
60
- }
61
- const MANIFEST_STATES = {
62
- live: "verified",
63
- missing: "missing",
64
- evicted: "missing",
65
- ephemeral: "unverified",
66
- };
67
- function getManifestVerificationEntry(entry) {
68
- if (entry.storageScope === "explicit-path") {
69
- return undefined;
70
- }
71
- let limitation;
72
- if (entry.retentionState === "ephemeral") {
73
- limitation = "This spill file is process-temporary and may not survive reload or restart.";
74
- }
75
- if (entry.retentionState === "evicted") {
76
- limitation = "This persisted spill file was evicted from the bounded session artifact store.";
77
- }
78
- return {
79
- absolutePath: entry.absolutePath,
80
- exists: entry.exists,
81
- kind: entry.kind,
82
- limitation,
83
- mediaType: entry.mediaType,
84
- path: entry.path,
85
- requestedPath: entry.requestedPath,
86
- retentionState: entry.retentionState,
87
- sizeBytes: entry.sizeBytes,
88
- state: MANIFEST_STATES[entry.retentionState],
89
- storageScope: entry.storageScope,
90
- };
91
- }
92
- export function buildArtifactVerificationSummary(artifacts, manifest, manifestPaths) {
93
- const entries = [
94
- ...artifacts.map(getArtifactVerificationEntry),
95
- ...(manifest?.entries.flatMap((entry) => {
96
- if (manifestPaths && !manifestPaths.has(entry.path)) {
97
- return [];
98
- }
99
- const verificationEntry = getManifestVerificationEntry(entry);
100
- return verificationEntry ? [verificationEntry] : [];
101
- }) ?? []),
102
- ];
103
- if (entries.length === 0) {
104
- return undefined;
105
- }
106
- const counts = { verified: 0, missing: 0, pending: 0, unverified: 0 };
107
- for (const entry of entries) {
108
- counts[entry.state] += 1;
109
- }
110
- return {
111
- artifacts: entries,
112
- missingCount: counts.missing,
113
- pendingCount: counts.pending,
114
- unverifiedCount: counts.unverified,
115
- verified: counts.verified === entries.length,
116
- verifiedCount: counts.verified,
117
- };
118
- }
119
- function isMissingFileArtifact(artifact) {
120
- return (!isPendingRecordingArtifact(artifact) &&
121
- (artifact.exists === false || artifact.status === "stale"));
122
- }
123
- export function hasMissingFileArtifact(artifacts) {
124
- return (artifacts ?? []).some(isMissingFileArtifact);
125
- }
126
- export function formatMissingArtifactFailureText(artifacts) {
127
- const failedArtifacts = (artifacts ?? []).filter(isMissingFileArtifact);
128
- if (failedArtifacts.length === 0) {
129
- return undefined;
130
- }
131
- if (failedArtifacts.length === 1) {
132
- const artifact = failedArtifacts[0];
133
- return artifact.status === "stale"
134
- ? `Artifact verification failed: requested ${artifact.kind} path ${artifact.absolutePath} has a modification time outside the current command window.`
135
- : `Artifact verification failed: requested ${artifact.kind} was not found at ${artifact.absolutePath}.`;
136
- }
137
- return `Artifact verification failed: ${failedArtifacts.length} requested artifacts were missing or stale.`;
138
- }
139
- export function classifyPresentationSuccessCategory(options) {
140
- if ((options.artifactVerification?.missingCount ?? 0) > 0 ||
141
- (options.artifactVerification?.unverifiedCount ?? 0) > 0) {
142
- return "artifact-unverified";
143
- }
144
- return classifyAgentBrowserSuccessCategory({ ...options, artifacts: options.artifacts?.slice() });
145
- }
@@ -1,165 +0,0 @@
1
- import { isRecord } from "../../parsing.js";
2
- import { formatSessionArtifactRetentionSummary, getSessionArtifactManifestEntryKey, isPendingRecordingArtifact, mergeSessionArtifactManifest, } from "../artifact-manifest.js";
3
- import { getRecordingReceipt } from "../recording.js";
4
- import { buildFileArtifactMetadata, buildPreviousRestartRecordingArtifact, extractPathStrings, isDownloadWaitSubcommand, isNonFileArtifactPathCandidate, } from "./artifact-files.js";
5
- import { appendPresentationNotice } from "./artifact-images.js";
6
- export { attachInlineImage, extractImagePath, getScreenshotSummary } from "./artifact-images.js";
7
- export { formatArtifactMetadataLines, formatArtifactSummary } from "./artifact-format.js";
8
- export { buildArtifactVerificationSummary, classifyPresentationSuccessCategory, formatMissingArtifactFailureText, hasMissingFileArtifact, } from "./artifact-verification.js";
9
- function noticeWorthy(entry) {
10
- return entry.retentionState === "evicted" || entry.storageScope !== "explicit-path";
11
- }
12
- export function manifestHasNewNoticeWorthyEntries(base, current) {
13
- if (!current) {
14
- return false;
15
- }
16
- const baseKeys = new Set((base?.entries ?? []).map(getSessionArtifactManifestEntryKey));
17
- return current.entries.some((entry) => !baseKeys.has(getSessionArtifactManifestEntryKey(entry)) && noticeWorthy(entry));
18
- }
19
- export function applyArtifactManifest(presentation, baseManifest, entries) {
20
- if (entries.length === 0) {
21
- return presentation;
22
- }
23
- const artifactManifest = mergeSessionArtifactManifest({
24
- base: baseManifest,
25
- entries: [...entries],
26
- });
27
- if (!artifactManifest) {
28
- return presentation;
29
- }
30
- presentation.artifactManifest = artifactManifest;
31
- presentation.artifactRetentionSummary = formatSessionArtifactRetentionSummary(artifactManifest);
32
- if (entries.some(noticeWorthy)) {
33
- appendPresentationNotice(presentation, presentation.artifactRetentionSummary);
34
- }
35
- return presentation;
36
- }
37
- function getRecordingPending(options, recording) {
38
- return (options.recordingPending ??
39
- (recording?.success === null &&
40
- isRecord(options.data) &&
41
- isRecord(options.data.capture) &&
42
- recording.capture.endedAt === null));
43
- }
44
- async function extractContactSheet(options, recordingPending) {
45
- if (options.commandInfo.command !== "record" || !isRecord(options.data)) {
46
- return undefined;
47
- }
48
- const path = options.data.contactSheetPath;
49
- if (typeof path !== "string" ||
50
- path.trim().length === 0 ||
51
- isNonFileArtifactPathCandidate(path)) {
52
- return undefined;
53
- }
54
- const sheet = await buildFileArtifactMetadata({
55
- ...options,
56
- artifactRequest: undefined,
57
- kind: "image",
58
- path,
59
- recordingPending: recordingPending === true ||
60
- ["start", "restart"].includes(options.commandInfo.subcommand ?? ""),
61
- });
62
- return sheet ? { ...sheet, requestedPath: undefined } : undefined;
63
- }
64
- async function extractPreviousContactSheet(options) {
65
- if (options.commandInfo.command !== "record" ||
66
- options.commandInfo.subcommand !== "restart" ||
67
- options.recordingOutcome !== true) {
68
- return undefined;
69
- }
70
- const path = options.previousRecordingContactSheetPath;
71
- if (path === undefined || path.length === 0) {
72
- return undefined;
73
- }
74
- const sheet = await buildFileArtifactMetadata({
75
- ...options,
76
- artifactRequest: undefined,
77
- commandInfo: { command: "record", subcommand: "restart-previous" },
78
- kind: "image",
79
- path,
80
- recordingPending: false,
81
- });
82
- // Native restart omits the previous sheet's terminal receipt. Disk presence isn't finalization proof.
83
- return sheet
84
- ? { ...sheet, status: sheet.status === "saved" ? "unverified" : sheet.status }
85
- : undefined;
86
- }
87
- export async function extractFileArtifacts(options) {
88
- if (options.commandInfo.command === "screenshot" &&
89
- isRecord(options.data) &&
90
- options.data.changed === false) {
91
- return [];
92
- }
93
- const recording = options.commandInfo.command === "record"
94
- ? getRecordingReceipt(options.data, options.commandInfo.subcommand === "stop" ? options.recordingOutcome : undefined)
95
- : undefined;
96
- const recordingPending = getRecordingPending(options, recording);
97
- const current = (await Promise.all(extractPathStrings(options.data).map((path) => buildFileArtifactMetadata({ ...options, path, recording, recordingPending })))).filter((artifact) => artifact !== undefined);
98
- const sheet = await extractContactSheet(options, recordingPending);
99
- if (sheet) {
100
- current.push(sheet);
101
- }
102
- const previousSheet = await extractPreviousContactSheet(options);
103
- if (previousSheet) {
104
- current.unshift(previousSheet);
105
- }
106
- const previous = await buildPreviousRestartRecordingArtifact(options);
107
- return previous ? [previous, ...current] : current;
108
- }
109
- export function buildManifestEntriesForFileArtifacts(artifacts, nowMs = Date.now()) {
110
- return artifacts.map((artifact) => ({
111
- absolutePath: artifact.absolutePath,
112
- command: artifact.command,
113
- createdAtMs: nowMs,
114
- cwd: artifact.cwd,
115
- exists: artifact.exists,
116
- extension: artifact.extension,
117
- kind: artifact.kind,
118
- mediaType: artifact.mediaType,
119
- namespace: artifact.namespace,
120
- path: artifact.path,
121
- recording: artifact.recording,
122
- recordingStartedAtMs: artifact.recordingStartedAtMs,
123
- recordingState: artifact.recordingState,
124
- status: artifact.status,
125
- requestedPath: artifact.requestedPath,
126
- retentionState: artifact.exists === false || artifact.status === "stale" ? "missing" : "live",
127
- session: artifact.session,
128
- sizeBytes: artifact.sizeBytes,
129
- storageScope: "explicit-path",
130
- subcommand: artifact.subcommand,
131
- }));
132
- }
133
- export function isManifestFileArtifact(artifact) {
134
- return artifact.kind === "video" && artifact.command === "record"
135
- ? true
136
- : artifact.status !== "stale" && !isPendingRecordingArtifact(artifact);
137
- }
138
- function getSavedFileCommand(commandInfo) {
139
- if (commandInfo.command === "wait" && isDownloadWaitSubcommand(commandInfo.subcommand)) {
140
- return "wait";
141
- }
142
- return commandInfo.command === "download" || commandInfo.command === "pdf"
143
- ? commandInfo.command
144
- : undefined;
145
- }
146
- export function getSavedFileDetails(commandInfo, data) {
147
- const path = typeof data.path === "string" && data.path.trim().length > 0 ? data.path : undefined;
148
- if (path === undefined || isNonFileArtifactPathCandidate(path)) {
149
- return undefined;
150
- }
151
- const command = getSavedFileCommand(commandInfo);
152
- if (command === undefined) {
153
- return undefined;
154
- }
155
- const { path: _path, ...metadata } = data;
156
- return {
157
- command,
158
- kind: command === "pdf" ? "pdf" : "download",
159
- path,
160
- ...(Object.keys(metadata).length > 0 ? { metadata } : {}),
161
- ...(commandInfo.subcommand !== undefined && commandInfo.subcommand.length > 0
162
- ? { subcommand: commandInfo.subcommand }
163
- : {}),
164
- };
165
- }
@@ -1,118 +0,0 @@
1
- import { stat } from "node:fs/promises";
2
- import { getAgentBrowserSessionIdentityKey } from "../../argv-grammar.js";
3
- import { extractUpstreamCommandTokens } from "../../argv-descriptor.js";
4
- import { isCloseCommand } from "../../command-taxonomy.js";
5
- import { isRecord } from "../../parsing.js";
6
- import { isPendingRecordingArtifact } from "../artifact-manifest.js";
7
- async function unverifiedRecordingArtifact(artifact, subcommand) {
8
- const { recordingState: _recordingState, willExistOnStop: _willExistOnStop, ...terminal } = artifact;
9
- try {
10
- const file = await stat(artifact.absolutePath);
11
- return {
12
- ...terminal,
13
- exists: file.isFile(),
14
- sizeBytes: file.size,
15
- status: file.isFile() ? "unverified" : "missing",
16
- subcommand,
17
- };
18
- }
19
- catch (error) {
20
- const missing = isRecord(error) && error.code === "ENOENT";
21
- return {
22
- ...terminal,
23
- exists: missing ? false : undefined,
24
- status: missing ? "missing" : "unverified",
25
- subcommand,
26
- };
27
- }
28
- }
29
- class TerminalBatchRecordings {
30
- artifacts = [];
31
- pendingBySession = new Map();
32
- removed = new Set();
33
- session;
34
- constructor(sessionName, namespace) {
35
- this.session =
36
- sessionName !== undefined && sessionName.length > 0
37
- ? getAgentBrowserSessionIdentityKey(sessionName, namespace)
38
- : "";
39
- }
40
- removeMatchingPending(artifact, session) {
41
- const pending = this.pendingBySession.get(session) ?? [];
42
- const matching = pending.map((index) => this.artifacts[index].kind).lastIndexOf(artifact.kind);
43
- if (matching !== -1) {
44
- const removed = pending.splice(matching, 1).at(0);
45
- if (removed !== undefined) {
46
- this.removed.add(removed);
47
- }
48
- }
49
- return pending;
50
- }
51
- append(artifact) {
52
- const index = this.artifacts.push(artifact) - 1;
53
- if (artifact.command !== "record") {
54
- return undefined;
55
- }
56
- const session = artifact.session !== undefined && artifact.session.length > 0
57
- ? getAgentBrowserSessionIdentityKey(artifact.session, artifact.namespace)
58
- : "";
59
- if (isPendingRecordingArtifact(artifact)) {
60
- const pending = this.pendingBySession.get(session) ?? [];
61
- pending.push(index);
62
- this.pendingBySession.set(session, pending);
63
- return undefined;
64
- }
65
- const pending = this.removeMatchingPending(artifact, session);
66
- if (artifact.kind !== "video") {
67
- return undefined;
68
- }
69
- // A terminal video also ends its sheet; a native sheet below replaces this unverified row.
70
- const sheets = pending.filter((position) => this.artifacts[position].kind === "image" &&
71
- isPendingRecordingArtifact(this.artifacts[position]));
72
- return sheets.length > 0 ? sheets : undefined;
73
- }
74
- getClosePending(step) {
75
- const command = step.details.command;
76
- if (!step.details.success ||
77
- !command ||
78
- !isCloseCommand(extractUpstreamCommandTokens(command)[0])) {
79
- return [];
80
- }
81
- return (this.pendingBySession.get(this.session) ?? []).filter((index) => {
82
- const current = this.artifacts.at(index);
83
- return (current !== undefined && isPendingRecordingArtifact(current) && !this.removed.has(index));
84
- });
85
- }
86
- async abandon(indices, subcommand) {
87
- for (const index of indices) {
88
- const current = this.artifacts.at(index);
89
- if (current && isPendingRecordingArtifact(current) && !this.removed.has(index)) {
90
- // Each replacement must finish before later lifecycle rows inspect the same artifact state.
91
- // oxlint-disable-next-line no-await-in-loop
92
- this.artifacts[index] = await unverifiedRecordingArtifact(current, subcommand);
93
- }
94
- }
95
- }
96
- async fold(steps) {
97
- for (const step of steps) {
98
- for (const artifact of step.presentation.artifacts ?? []) {
99
- const sheets = this.append(artifact);
100
- if (sheets) {
101
- // Terminal receipt order determines which pending sheet the next row can replace.
102
- // oxlint-disable-next-line no-await-in-loop
103
- await this.abandon(sheets, artifact.subcommand ?? "stop");
104
- }
105
- }
106
- const pending = this.getClosePending(step);
107
- if (pending.length > 0) {
108
- // Close abandonment must finish before any later recording receipt is folded.
109
- // oxlint-disable-next-line no-await-in-loop
110
- await this.abandon(pending, "close-abandoned");
111
- }
112
- }
113
- return this.artifacts.filter((_, index) => !this.removed.has(index));
114
- }
115
- }
116
- export async function coalesceTerminalBatchRecordingArtifacts(steps, sessionName, namespace) {
117
- return new TerminalBatchRecordings(sessionName, namespace).fold(steps);
118
- }