@opengeni/react 6.36.0 → 6.36.1-canary.45113772604001

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 (1087) hide show
  1. package/dist/app/app-state.js +10 -10
  2. package/dist/app/components/Composer.js +19 -19
  3. package/dist/app/components/agent/agent-capability-picker.js +6 -6
  4. package/dist/app/components/agents/agent-can-use.js +21 -20
  5. package/dist/app/components/agents/agent-form-page.js +69 -65
  6. package/dist/app/components/agents/agent-form-page.js.map +1 -1
  7. package/dist/app/components/agents/agent-page.js +68 -64
  8. package/dist/app/components/agents/agent-setup-sections.js +40 -36
  9. package/dist/app/components/agents/agent-skills.js +5 -5
  10. package/dist/app/components/agents/agent-trigger-chat-field.js +4 -4
  11. package/dist/app/components/agents/agent-trigger-dialog.js +20 -17
  12. package/dist/app/components/agents/agent-trigger-model.d.ts +14 -0
  13. package/dist/app/components/agents/agent-trigger-picker.js +6 -5
  14. package/dist/app/components/agents/agent-trigger-repositories.d.ts +9 -0
  15. package/dist/app/components/agents/agent-trigger-repositories.js +31 -0
  16. package/dist/app/components/agents/agents-page.css +1905 -0
  17. package/dist/app/components/agents/agents-page.css.map +1 -0
  18. package/dist/app/components/agents/agents-page.js +106 -61
  19. package/dist/app/components/agents/agents-page.js.map +1 -1
  20. package/dist/app/components/agents/composer-agent-chip.js +29 -29
  21. package/dist/app/components/agents/session-agent-chip.js +29 -29
  22. package/dist/app/components/artifacts/app-package.js +3 -3
  23. package/dist/app/components/artifacts/app-server-status.d.ts +22 -0
  24. package/dist/app/components/artifacts/app-server-status.js +13 -0
  25. package/dist/app/components/artifacts/artifact-library.css +1905 -0
  26. package/dist/app/components/artifacts/artifact-library.css.map +1 -0
  27. package/dist/app/components/artifacts/artifact-library.js +8 -8
  28. package/dist/app/components/artifacts/artifact-viewer.css +1905 -0
  29. package/dist/app/components/artifacts/artifact-viewer.css.map +1 -0
  30. package/dist/app/components/artifacts/artifact-viewer.js +30 -30
  31. package/dist/app/components/artifacts/chat-interactive-block.js +16 -16
  32. package/dist/app/components/artifacts/file-reach-dialog.js +6 -6
  33. package/dist/app/components/artifacts/inline-chat-image.js +28 -28
  34. package/dist/app/components/artifacts/ready-made-apps.css +1905 -0
  35. package/dist/app/components/artifacts/ready-made-apps.css.map +1 -0
  36. package/dist/app/components/artifacts/ready-made-apps.d.ts +3 -0
  37. package/dist/app/components/artifacts/ready-made-apps.js +40 -0
  38. package/dist/app/components/artifacts/retained-file-preview.js +30 -30
  39. package/dist/app/components/artifacts/retained-text-preview.js +3 -3
  40. package/dist/app/components/artifacts/site-actions.js +1 -1
  41. package/dist/app/components/artifacts/site-audience.js +3 -3
  42. package/dist/app/components/artifacts/site-conversations.js +15 -15
  43. package/dist/app/components/artifacts/site-data.js +11 -11
  44. package/dist/app/components/artifacts/site-publishing-page.js +32 -32
  45. package/dist/app/components/artifacts/site-publishing.js +24 -24
  46. package/dist/app/components/artifacts/site-settings.js +31 -31
  47. package/dist/app/components/artifacts/site-version-menu.js +4 -4
  48. package/dist/app/components/billing-class-mark.js +3 -3
  49. package/dist/app/components/capabilities/capability-detail-sheet.js +7 -7
  50. package/dist/app/components/capabilities/capability-logo-source.js +15 -14
  51. package/dist/app/components/capabilities/connector-tool-permissions.js +4 -4
  52. package/dist/app/components/capabilities/native-connect-setup.js +16 -15
  53. package/dist/app/components/capabilities/own-logins-shared-heads-up.js +3 -3
  54. package/dist/app/components/capabilities/perform-capability-action.js +1 -1
  55. package/dist/app/components/capabilities/prepared-mcp-setup-card.js +17 -16
  56. package/dist/app/components/capabilities/session-capability-card.js +70 -69
  57. package/dist/app/components/capabilities/session-capability-card.js.map +1 -1
  58. package/dist/app/components/capabilities/session-chrome-card.js +22 -22
  59. package/dist/app/components/capabilities/session-connect-inputs-card.js +16 -15
  60. package/dist/app/components/capabilities/session-custom-mcp-card.js +18 -17
  61. package/dist/app/components/capabilities/session-github-card.js +19 -18
  62. package/dist/app/components/capabilities/session-machine-card.js +21 -21
  63. package/dist/app/components/capabilities/session-personal-github-card.js +16 -15
  64. package/dist/app/components/capabilities/session-plugin-card.js +9 -9
  65. package/dist/app/components/capabilities/use-connection-accounts.js +1 -1
  66. package/dist/app/components/command-menu/chat-status.js +18 -18
  67. package/dist/app/components/command-menu/chat-switcher.js +47 -47
  68. package/dist/app/components/command-menu/command-menu.js +58 -58
  69. package/dist/app/components/command-menu/shortcut-sheet.js +15 -15
  70. package/dist/app/components/composer-capabilities-menu-body.js +4 -4
  71. package/dist/app/components/composer-mobile-plus-panel.js +9 -9
  72. package/dist/app/components/composer-mobile-plus.js +1 -1
  73. package/dist/app/components/credit-required-gate.js +1 -1
  74. package/dist/app/components/credit-required-prompt.js +11 -11
  75. package/dist/app/components/credits/checkout-credits-celebration.js +2 -2
  76. package/dist/app/components/credits/checkout-return.js +2 -2
  77. package/dist/app/components/credits/credit-refusal-notice.js +2 -2
  78. package/dist/app/components/desktop/app-shots.js +7 -7
  79. package/dist/app/components/desktop/computer-use.js +2 -2
  80. package/dist/app/components/desktop/this-computer.js +5 -5
  81. package/dist/app/components/feedback.js +3 -3
  82. package/dist/app/components/follow-up-repository-menu-body.js +2 -2
  83. package/dist/app/components/follow-up-repository-picker.js +1 -1
  84. package/dist/app/components/github-app-connect-launcher.js +1 -1
  85. package/dist/app/components/machines/connect-machine-dialog.js +11 -11
  86. package/dist/app/components/markdown.js +7 -7
  87. package/dist/app/components/models/models-ui.js +6 -6
  88. package/dist/app/components/models/subscription-usage.js +5 -5
  89. package/dist/app/components/my-things.js +4 -4
  90. package/dist/app/components/own-where-it-works.js +3 -3
  91. package/dist/app/components/personal-resource-attachment-surface.js +4 -4
  92. package/dist/app/components/pickers.js +6 -6
  93. package/dist/app/components/rail/channel-create-dialog.js +3 -3
  94. package/dist/app/components/rail/project-glyph.js +29 -29
  95. package/dist/app/components/rail/project-profile.js +36 -36
  96. package/dist/app/components/rail/rail-context.js +1 -1
  97. package/dist/app/components/rail/rail-sections.js +80 -80
  98. package/dist/app/components/rail/session-header.js +64 -64
  99. package/dist/app/components/rail/session-list.js +78 -78
  100. package/dist/app/components/rail/session-row-content.js +4 -4
  101. package/dist/app/components/rail/session-row-hover-details.js +20 -20
  102. package/dist/app/components/rail/session-shell.js +102 -102
  103. package/dist/app/components/rail/site-session-group-heading.js +14 -14
  104. package/dist/app/components/repository-picker.js +2 -2
  105. package/dist/app/components/session/agent-configuration-panel.js +16 -16
  106. package/dist/app/components/session/artifact-session-page.js +1 -1
  107. package/dist/app/components/session/banners.js +9 -9
  108. package/dist/app/components/session/chat-avatar.js +29 -29
  109. package/dist/app/components/session/console-new-conversation.js +51 -51
  110. package/dist/app/components/session/descendant-requests.js +46 -46
  111. package/dist/app/components/session/editable-artifacts-workspace.css +1905 -0
  112. package/dist/app/components/session/editable-artifacts-workspace.css.map +1 -0
  113. package/dist/app/components/session/editable-artifacts-workspace.js +22 -22
  114. package/dist/app/components/session/failed-session-banner.js +10 -10
  115. package/dist/app/components/session/failure-recovery-boundary.js +3 -3
  116. package/dist/app/components/session/human-input-delegation-record.js +2 -2
  117. package/dist/app/components/session/human-input.js +42 -42
  118. package/dist/app/components/session/inspector.js +56 -56
  119. package/dist/app/components/session/linked-panel.js +3 -3
  120. package/dist/app/components/session/message-actions.js +3 -3
  121. package/dist/app/components/session/model-recovery-notice.js +3 -3
  122. package/dist/app/components/session/new-session-settings-menu.js +11 -11
  123. package/dist/app/components/session/new-session-setup-strip.js +30 -30
  124. package/dist/app/components/session/pull-request-panel.js +11 -11
  125. package/dist/app/components/session/sandbox-recovery-actions.js +3 -3
  126. package/dist/app/components/session/sandbox-switcher.js +8 -8
  127. package/dist/app/components/session/sandbox-workspace.js +58 -58
  128. package/dist/app/components/session/search-markdown-highlight.js +8 -8
  129. package/dist/app/components/session/search-results-view.js +9 -9
  130. package/dist/app/components/session/session-admin-access.js +4 -4
  131. package/dist/app/components/session/session-admission-notice.js +4 -4
  132. package/dist/app/components/session/session-avatar-picker.js +30 -30
  133. package/dist/app/components/session/session-avatar.js +28 -28
  134. package/dist/app/components/session/session-machine-access-notice.js +4 -4
  135. package/dist/app/components/session/session-profile-dialog.js +34 -34
  136. package/dist/app/components/session/session-profile-editor.js +35 -35
  137. package/dist/app/components/session/session-retention.js +4 -4
  138. package/dist/app/components/session/session-search-dialog.js +9 -9
  139. package/dist/app/components/session/session-tenancy-control.js +8 -8
  140. package/dist/app/components/session/session-usage-limit-section.js +4 -4
  141. package/dist/app/components/session/share-chat-dialog.js +6 -6
  142. package/dist/app/components/session/subagents.js +13 -13
  143. package/dist/app/components/session/subscription-account-indicator.js +11 -11
  144. package/dist/app/components/session/subscription-account-menu.js +6 -6
  145. package/dist/app/components/settings/row-select.js +4 -4
  146. package/dist/app/components/toaster.js +2 -2
  147. package/dist/app/components/transcription-settings.js +6 -6
  148. package/dist/app/components/ui/destructive-confirm.js +5 -5
  149. package/dist/app/components/usage/usage-entry.js +3 -3
  150. package/dist/app/components/window-bar.js +13 -13
  151. package/dist/app/components/workspace-composer-plus.js +18 -17
  152. package/dist/app/components/workspace-reach.js +4 -4
  153. package/dist/app/embed/session-app.js +241 -240
  154. package/dist/app/lib/actions/actions-provider.js +12 -12
  155. package/dist/app/lib/agent-capabilities.js +3 -3
  156. package/dist/app/lib/app-connect-card.js +9 -9
  157. package/dist/app/lib/app-shared-key-dialog.js +4 -4
  158. package/dist/app/lib/app-sync-opt-in.js +3 -3
  159. package/dist/app/lib/codex-usage-query.js +2 -2
  160. package/dist/app/lib/composer-connectors.js +16 -15
  161. package/dist/app/lib/console-site.js +5 -5
  162. package/dist/app/lib/console-text.js +2 -2
  163. package/dist/app/lib/events.js +18 -18
  164. package/dist/app/lib/failed-session-copy.js +3 -3
  165. package/dist/app/lib/model-access-onboarding.js +3 -3
  166. package/dist/app/lib/move-chat-to-machine.js +3 -3
  167. package/dist/app/lib/needs-you.d.ts +2 -1
  168. package/dist/app/lib/needs-you.js +1 -1
  169. package/dist/app/lib/ready-made-apps.d.ts +14 -0
  170. package/dist/app/lib/ready-made-apps.js +8 -0
  171. package/dist/app/lib/session-branch-cache.js +13 -13
  172. package/dist/app/lib/session-capabilities.js +1 -1
  173. package/dist/app/lib/session-create.js +4 -4
  174. package/dist/app/lib/session-group-pagination.js +13 -13
  175. package/dist/app/lib/session-hover-facts.js +17 -17
  176. package/dist/app/lib/session-list-dirty-scopes.js +14 -14
  177. package/dist/app/lib/session-model.js +2 -2
  178. package/dist/app/lib/session-rail.js +10 -10
  179. package/dist/app/lib/session-rename.js +3 -3
  180. package/dist/app/lib/sessions-group.js +12 -12
  181. package/dist/app/lib/site-tool-consent-dialog.js +8 -8
  182. package/dist/app/lib/site-tool-consent.js +1 -1
  183. package/dist/app/lib/turn-failure-analytics.js +4 -4
  184. package/dist/app/lib/use-follow-up-repositories.js +3 -3
  185. package/dist/app/lib/use-workspace-machines.js +4 -4
  186. package/dist/app/lib/use-workspace-model-catalog.js +3 -3
  187. package/dist/app/lib/use-workspace-rigs.js +2 -2
  188. package/dist/app/lib/workspace-navigation-preference.js +4 -4
  189. package/dist/app/lib/workspace-scope-context.js +3 -3
  190. package/dist/app/routes/app-page-view.js +10 -10
  191. package/dist/app/routes/app-page.js +1 -1
  192. package/dist/app/routes/artifacts.css +1905 -0
  193. package/dist/app/routes/artifacts.css.map +1 -0
  194. package/dist/app/routes/artifacts.js +105 -94
  195. package/dist/app/routes/artifacts.js.map +1 -1
  196. package/dist/app/routes/retained-artifact.js +47 -47
  197. package/dist/app/routes/session-unavailable.js +2 -2
  198. package/dist/app/routes/session.js +131 -130
  199. package/dist/app/routes/sessions-index-hydration.js +5 -5
  200. package/dist/app/routes/sessions-index.js +108 -107
  201. package/dist/app/routes/site-view.js +107 -95
  202. package/dist/app/routes/site-view.js.map +1 -1
  203. package/dist/approval-review-model.js +2 -2
  204. package/dist/artifacts-document.js +4 -4
  205. package/dist/artifacts-presentation.js +5 -5
  206. package/dist/artifacts-spreadsheet.js +4 -4
  207. package/dist/artifacts.js +15 -15
  208. package/dist/automation-model.js +5 -5
  209. package/dist/automations.d.ts +1 -0
  210. package/dist/automations.js +29 -22
  211. package/dist/automations.js.map +1 -1
  212. package/dist/browser-viewer-EPGAK2W6.js +23 -0
  213. package/dist/chat-interactive-block-65YU6TMO.js +22 -0
  214. package/dist/chunk-25ODMMHH.js +403 -0
  215. package/dist/chunk-266ZPUMH.js +400 -0
  216. package/dist/chunk-2A7SB7UR.js +168 -0
  217. package/dist/chunk-2EU4Y7A7.js +100 -0
  218. package/dist/chunk-2F7VSGRS.js +1177 -0
  219. package/dist/chunk-2F7VSGRS.js.map +1 -0
  220. package/dist/chunk-2L6B6766.js +5915 -0
  221. package/dist/chunk-2L6B6766.js.map +1 -0
  222. package/dist/chunk-2LBYEHBH.js +570 -0
  223. package/dist/chunk-2MHIIF4N.js +141 -0
  224. package/dist/chunk-2SHWGDAA.js +283 -0
  225. package/dist/chunk-2VX42S4W.js +773 -0
  226. package/dist/chunk-2WGJQ4XK.js +311 -0
  227. package/dist/chunk-2XSF44TY.js +15 -0
  228. package/dist/chunk-33HUZMNE.js +639 -0
  229. package/dist/chunk-36IKHM4Q.js +148 -0
  230. package/dist/chunk-3JVQZAXQ.js +4480 -0
  231. package/dist/chunk-3SDESU6U.js +287 -0
  232. package/dist/chunk-3VXZFBP6.js +292 -0
  233. package/dist/chunk-3WDNCSVU.js +197 -0
  234. package/dist/chunk-3WDNCSVU.js.map +1 -0
  235. package/dist/chunk-3YKED2ZV.js +307 -0
  236. package/dist/chunk-3ZNOKD3S.js +1019 -0
  237. package/dist/chunk-45SB4UK3.js +2580 -0
  238. package/dist/chunk-47BETTVA.js +133 -0
  239. package/dist/chunk-4BTQ473O.js +274 -0
  240. package/dist/chunk-4JQRWJVR.js +249 -0
  241. package/dist/chunk-4NGIKV2W.js +316 -0
  242. package/dist/chunk-4NGIKV2W.js.map +1 -0
  243. package/dist/chunk-4R6WFQKZ.js +202 -0
  244. package/dist/chunk-4WEPVL7X.js +283 -0
  245. package/dist/chunk-4YWHOAB4.js +201 -0
  246. package/dist/chunk-52XGYRVS.js +155 -0
  247. package/dist/chunk-5G6UHUJZ.js +43 -0
  248. package/dist/chunk-5HFITPHH.js +229 -0
  249. package/dist/chunk-5LVVN2K7.js +650 -0
  250. package/dist/chunk-5PVXFVIT.js +48 -0
  251. package/dist/chunk-5WFGW7B7.js +187 -0
  252. package/dist/chunk-5YMSLKJP.js +92 -0
  253. package/dist/chunk-5YMSLKJP.js.map +1 -0
  254. package/dist/chunk-66M7RVM6.js +3070 -0
  255. package/dist/chunk-6AGNZI2W.js +437 -0
  256. package/dist/chunk-6ENO634Y.js +373 -0
  257. package/dist/chunk-6LQ5KEMP.js +200 -0
  258. package/dist/chunk-6QGIWLH5.js +428 -0
  259. package/dist/chunk-6WEDWD4N.js +170 -0
  260. package/dist/chunk-6YCYPXDA.js +114 -0
  261. package/dist/chunk-6YTNMDFP.js +318 -0
  262. package/dist/chunk-73O7NO3F.js +50 -0
  263. package/dist/chunk-76VXLTQF.js +251 -0
  264. package/dist/chunk-7EJ7PSZT.js +93 -0
  265. package/dist/chunk-7GS2MGFU.js +27 -0
  266. package/dist/chunk-7MF6MFHS.js +406 -0
  267. package/dist/chunk-7N35XBSC.js +386 -0
  268. package/dist/chunk-7ND2VMKV.js +270 -0
  269. package/dist/chunk-7RVJLO3N.js +154 -0
  270. package/dist/chunk-7VAILBP6.js +353 -0
  271. package/dist/chunk-7VSJQWFO.js +37 -0
  272. package/dist/chunk-7YKUIKGH.js +335 -0
  273. package/dist/chunk-A7DS77WC.js +138 -0
  274. package/dist/chunk-ABGHRGID.js +376 -0
  275. package/dist/chunk-ABGHRGID.js.map +1 -0
  276. package/dist/chunk-AEH34OOU.js +298 -0
  277. package/dist/chunk-ANWMRO2G.js +554 -0
  278. package/dist/chunk-APGUIORF.js +247 -0
  279. package/dist/chunk-ASCVQJB4.js +1309 -0
  280. package/dist/chunk-AVYFJKQS.js +10044 -0
  281. package/dist/chunk-AVYFJKQS.js.map +1 -0
  282. package/dist/chunk-AY4XH73V.js +1333 -0
  283. package/dist/chunk-B6AH43UQ.js +2434 -0
  284. package/dist/chunk-BBZUHH4F.js +154 -0
  285. package/dist/chunk-BBZUHH4F.js.map +1 -0
  286. package/dist/chunk-BGT43KDL.js +42 -0
  287. package/dist/chunk-BHS4KW4W.js +3851 -0
  288. package/dist/chunk-BJUDGPOD.js +1803 -0
  289. package/dist/chunk-BJUDGPOD.js.map +1 -0
  290. package/dist/chunk-BNWO72C2.js +851 -0
  291. package/dist/chunk-BSPIASSQ.js +2551 -0
  292. package/dist/chunk-BVWJEZXG.js +230 -0
  293. package/dist/chunk-BZ47G3VP.js +366 -0
  294. package/dist/chunk-C6KI5P3H.js +72 -0
  295. package/dist/chunk-CLERWAEA.js +2317 -0
  296. package/dist/chunk-CNRFFCAE.js +572 -0
  297. package/dist/chunk-CPC6CYVW.js +236 -0
  298. package/dist/chunk-D23UAPXK.js +107 -0
  299. package/dist/chunk-DAPZEB4R.js +29 -0
  300. package/dist/chunk-DEDEA3WS.js +205 -0
  301. package/dist/chunk-DHVA3T3K.js +271 -0
  302. package/dist/chunk-DJQ6TKIP.js +391 -0
  303. package/dist/chunk-DK2CDAMR.js +33 -0
  304. package/dist/chunk-DPOB6MUS.js +278 -0
  305. package/dist/chunk-DSO7S6PZ.js +137 -0
  306. package/dist/chunk-DV3OECO6.js +333 -0
  307. package/dist/chunk-DW2IQRMB.js +1187 -0
  308. package/dist/chunk-DWLPQTDL.js +134 -0
  309. package/dist/chunk-DXMKECFR.js +3176 -0
  310. package/dist/chunk-DYQRNIID.js +73 -0
  311. package/dist/chunk-DZLWO73N.js +129 -0
  312. package/dist/chunk-DZZSFPMW.js +66 -0
  313. package/dist/chunk-DZZSFPMW.js.map +1 -0
  314. package/dist/chunk-E2GNUL64.js +107 -0
  315. package/dist/chunk-E7XU2KHD.js +192 -0
  316. package/dist/chunk-ENYULVQW.js +114 -0
  317. package/dist/chunk-EWHQ3DFM.js +41 -0
  318. package/dist/chunk-F2T4J7CK.js +4957 -0
  319. package/dist/chunk-F2T4J7CK.js.map +1 -0
  320. package/dist/chunk-F3LIUDXN.js +738 -0
  321. package/dist/chunk-F5C7DTVR.js +103 -0
  322. package/dist/chunk-F5NFGBIN.js +391 -0
  323. package/dist/chunk-F6XJLGOV.js +175 -0
  324. package/dist/chunk-F7T2STMX.js +158 -0
  325. package/dist/chunk-FAEVOM6B.js +371 -0
  326. package/dist/chunk-FCFAXQDM.js +276 -0
  327. package/dist/chunk-FEQVCQMK.js +138 -0
  328. package/dist/chunk-FLD4VOJW.js +4565 -0
  329. package/dist/chunk-FLD4VOJW.js.map +1 -0
  330. package/dist/chunk-FLDF2Z44.js +396 -0
  331. package/dist/chunk-GADABL3P.js +772 -0
  332. package/dist/chunk-GFUDB3SA.js +140 -0
  333. package/dist/chunk-GGPZPBHS.js +215 -0
  334. package/dist/chunk-GIEGIEMT.js +311 -0
  335. package/dist/chunk-GKWFQEO3.js +187 -0
  336. package/dist/chunk-GMMB4NCN.js +250 -0
  337. package/dist/chunk-GN4FOL2G.js +269 -0
  338. package/dist/chunk-GQJAMANY.js +469 -0
  339. package/dist/chunk-H7F4ANJQ.js +379 -0
  340. package/dist/chunk-HEPFJ3XQ.js +3110 -0
  341. package/dist/chunk-HLRAQITA.js +234 -0
  342. package/dist/chunk-HXYSZKCC.js +117 -0
  343. package/dist/chunk-I5Q6FVHP.js +828 -0
  344. package/dist/chunk-I7M5BYJU.js +265 -0
  345. package/dist/chunk-IH3J7VWW.js +85 -0
  346. package/dist/chunk-IMMDXSZ4.js +178 -0
  347. package/dist/chunk-IOMZDY5D.js +199 -0
  348. package/dist/chunk-IQTCUUDF.js +1236 -0
  349. package/dist/chunk-ISR6KXWT.js +898 -0
  350. package/dist/chunk-IWPPGXUZ.js +3321 -0
  351. package/dist/chunk-IYKO6BBK.js +3854 -0
  352. package/dist/chunk-IYKO6BBK.js.map +1 -0
  353. package/dist/chunk-IYUZPNMU.js +79 -0
  354. package/dist/chunk-IYUZPNMU.js.map +1 -0
  355. package/dist/chunk-JNPCRNPA.js +84 -0
  356. package/dist/chunk-JSJGGP32.js +505 -0
  357. package/dist/chunk-JZZUEJYD.js +56 -0
  358. package/dist/chunk-K5XFZKK5.js +270 -0
  359. package/dist/chunk-K6GRTSEA.js +65 -0
  360. package/dist/chunk-KA4PZU3Q.js +103 -0
  361. package/dist/chunk-KGZ35ESO.js +83 -0
  362. package/dist/chunk-KRM4PW5N.js +1021 -0
  363. package/dist/chunk-KSNKF6FE.js +551 -0
  364. package/dist/chunk-KSNKF6FE.js.map +1 -0
  365. package/dist/chunk-LEZGGRDQ.js +1095 -0
  366. package/dist/chunk-LFWMFFKT.js +144 -0
  367. package/dist/chunk-LKSPUZPH.js +849 -0
  368. package/dist/chunk-LLX4S6BI.js +401 -0
  369. package/dist/chunk-M4WEF4DZ.js +850 -0
  370. package/dist/chunk-MATYGLUT.js +121 -0
  371. package/dist/chunk-MDI6SH7B.js +27 -0
  372. package/dist/chunk-MQO7MSA6.js +43 -0
  373. package/dist/chunk-MQO7MSA6.js.map +1 -0
  374. package/dist/chunk-MQTYIBY6.js +263 -0
  375. package/dist/chunk-MRKY2GL5.js +1185 -0
  376. package/dist/chunk-MSIQ42IY.js +794 -0
  377. package/dist/chunk-MVGU7BET.js +357 -0
  378. package/dist/chunk-MWY4TBDY.js +404 -0
  379. package/dist/chunk-NGQCWCD6.js +234 -0
  380. package/dist/chunk-NKXMIOYN.js +538 -0
  381. package/dist/chunk-NMVRFFCR.js +256 -0
  382. package/dist/chunk-NNTDIKJP.js +407 -0
  383. package/dist/chunk-NQXCPP4G.js +98 -0
  384. package/dist/chunk-NYGS6FNV.js +132 -0
  385. package/dist/chunk-O3LOQDTI.js +176 -0
  386. package/dist/chunk-O5HRZ2KG.js +818 -0
  387. package/dist/chunk-O5PZRVQR.js +214 -0
  388. package/dist/chunk-O6KR5SN7.js +399 -0
  389. package/dist/chunk-OBKDRV2H.js +259 -0
  390. package/dist/chunk-OBKKUBGL.js +107 -0
  391. package/dist/chunk-OFYXDB6I.js +52 -0
  392. package/dist/chunk-OLMWJGSJ.js +50 -0
  393. package/dist/chunk-OO7N6APA.js +598 -0
  394. package/dist/chunk-OO7N6APA.js.map +1 -0
  395. package/dist/chunk-ORRACKLB.js +1263 -0
  396. package/dist/chunk-P426WWAB.js +351 -0
  397. package/dist/chunk-P4GOY3ZL.js +177 -0
  398. package/dist/chunk-P4KVJLUC.js +129 -0
  399. package/dist/chunk-P4N7ZS6W.js +56 -0
  400. package/dist/chunk-P6LSLNSL.js +209 -0
  401. package/dist/chunk-P7MQCSML.js +77 -0
  402. package/dist/chunk-P7MQCSML.js.map +1 -0
  403. package/dist/chunk-PAFSIDM2.js +111 -0
  404. package/dist/chunk-PC2JAIAH.js +117 -0
  405. package/dist/chunk-PGSXT5OY.js +207 -0
  406. package/dist/chunk-QDMGUTOU.js +2984 -0
  407. package/dist/chunk-QEMDQKQT.js +1356 -0
  408. package/dist/chunk-QK7VU5N3.js +2412 -0
  409. package/dist/chunk-QL4Q332Z.js +12 -0
  410. package/dist/chunk-QL5227KT.js +1184 -0
  411. package/dist/chunk-QREYGVWO.js +297 -0
  412. package/dist/chunk-QREYGVWO.js.map +1 -0
  413. package/dist/chunk-QUFCZMHG.js +114 -0
  414. package/dist/chunk-QXPKUKOV.js +227 -0
  415. package/dist/chunk-QZE3KD34.js +441 -0
  416. package/dist/chunk-RAIUIXCY.js +166 -0
  417. package/dist/chunk-RDLS6IZY.js +723 -0
  418. package/dist/chunk-RKPETJDJ.js +175 -0
  419. package/dist/chunk-RMDLTRLI.js +372 -0
  420. package/dist/chunk-RR6DQN4X.js +523 -0
  421. package/dist/chunk-RVPH6BB7.js +218 -0
  422. package/dist/chunk-RVXLSVJH.js +931 -0
  423. package/dist/chunk-RVY5EZNU.js +246 -0
  424. package/dist/chunk-RWHBX4MN.js +1024 -0
  425. package/dist/chunk-RWHDMGFG.js +214 -0
  426. package/dist/chunk-RYB3WBMZ.js +113 -0
  427. package/dist/chunk-S7EO77EE.js +449 -0
  428. package/dist/chunk-S7J4HBPP.js +584 -0
  429. package/dist/chunk-SA3XI7FB.js +108 -0
  430. package/dist/chunk-SKRTCSUL.js +196 -0
  431. package/dist/chunk-SUWDILUY.js +5089 -0
  432. package/dist/chunk-SWTPVMR4.js +251 -0
  433. package/dist/chunk-T5BYEE66.js +191 -0
  434. package/dist/chunk-T652Q4R6.js +48 -0
  435. package/dist/chunk-TBUOHK6R.js +608 -0
  436. package/dist/chunk-TCUAGCAX.js +1628 -0
  437. package/dist/chunk-TLWH4E3P.js +126 -0
  438. package/dist/chunk-TNHGSWG3.js +1152 -0
  439. package/dist/chunk-TO6VBJI3.js +383 -0
  440. package/dist/chunk-TOL7MOAN.js +162 -0
  441. package/dist/chunk-U243CBVZ.js +2553 -0
  442. package/dist/chunk-U2CEPRDH.js +46 -0
  443. package/dist/chunk-UAZPXKPH.js +3996 -0
  444. package/dist/chunk-UHRGUMLJ.js +412 -0
  445. package/dist/chunk-UNDSD6UA.js +131 -0
  446. package/dist/chunk-USU2SS4V.js +3690 -0
  447. package/dist/chunk-USWA5GQQ.js +340 -0
  448. package/dist/chunk-UXGTI4HR.js +184 -0
  449. package/dist/chunk-UZKAHEQO.js +172 -0
  450. package/dist/chunk-VALESBNH.js +113 -0
  451. package/dist/chunk-VMSMVWCJ.js +515 -0
  452. package/dist/chunk-VPERSFGV.js +158 -0
  453. package/dist/chunk-VVW2CBWK.js +21 -0
  454. package/dist/chunk-VVW2CBWK.js.map +1 -0
  455. package/dist/chunk-VXPY2GF3.js +124 -0
  456. package/dist/chunk-W7RKXZDV.js +112 -0
  457. package/dist/chunk-WEGZPK4I.js +532 -0
  458. package/dist/chunk-WPKY3BGG.js +380 -0
  459. package/dist/chunk-X3T3N6W5.js +1022 -0
  460. package/dist/chunk-X4OGMBY6.js +110 -0
  461. package/dist/chunk-X7ZHIJEI.js +82 -0
  462. package/dist/chunk-XR7Y2HPZ.js +67 -0
  463. package/dist/chunk-Y2NMKJ7F.js +57 -0
  464. package/dist/chunk-Y2QYPJDN.js +26 -0
  465. package/dist/chunk-Y47EPVCD.js +211 -0
  466. package/dist/chunk-Y5Q4ETIW.js +162 -0
  467. package/dist/chunk-YMQVVFXI.js +105 -0
  468. package/dist/chunk-YQ6FP33X.js +378 -0
  469. package/dist/chunk-YUA42N5A.js +406 -0
  470. package/dist/chunk-YXFNW64N.js +91 -0
  471. package/dist/chunk-Z76RJPZF.js +389 -0
  472. package/dist/chunk-ZD67RM6G.js +60 -0
  473. package/dist/chunk-ZE4RD7U5.js +231 -0
  474. package/dist/chunk-ZGR7LNXC.js +432 -0
  475. package/dist/chunk-ZNA65Q6Y.js +20 -0
  476. package/dist/chunk-ZRNK6FK6.js +188 -0
  477. package/dist/chunk-ZVAIKQMC.js +296 -0
  478. package/dist/chunk-ZZ3KNGTJ.js +246 -0
  479. package/dist/components/automations/pasted-webhook-steps.d.ts +29 -0
  480. package/dist/components/browser-viewer.d.ts +4 -1
  481. package/dist/components/human-input-form.d.ts +3 -4
  482. package/dist/components/use-fit-browser-viewport.d.ts +10 -0
  483. package/dist/composer.js +8 -8
  484. package/dist/computer-viewer-M5N3GWBR.js +21 -0
  485. package/dist/connect.js +17 -15
  486. package/dist/connection-step-up-CNVFVWYO.js +146 -0
  487. package/dist/connection-step-up-CNVFVWYO.js.map +1 -0
  488. package/dist/desktop-dictation.js +8 -8
  489. package/dist/desktop.js +2 -2
  490. package/dist/editor.js +2 -2
  491. package/dist/embedded-new-voice-QZJG5DZ3.js +25 -0
  492. package/dist/embedded-voice-7KOQNGKU.js +25 -0
  493. package/dist/fleet-decision-row-FJPAWNOQ.js +361 -0
  494. package/dist/in-chat-connect-model.js +5 -5
  495. package/dist/index.js +65 -65
  496. package/dist/interaction.js +5 -5
  497. package/dist/latest-question-F3VPDR7U.js +124 -0
  498. package/dist/machines.js +3 -3
  499. package/dist/meetings-recorder.js +1 -1
  500. package/dist/meetings.js +20 -20
  501. package/dist/messages/en.d.ts +1 -1
  502. package/dist/messages.js +1 -1
  503. package/dist/model-policy-picker-menu-UNI5B6N6.js +23 -0
  504. package/dist/model-policy-picker-menu-UNI5B6N6.js.map +1 -0
  505. package/dist/payment-page-card-HZJVN3F4.js +226 -0
  506. package/dist/platform-activity-row-NPEGG2VE.js +156 -0
  507. package/dist/queue-surface-implementation-RTCTPF5T.js +932 -0
  508. package/dist/realtime.js +4 -4
  509. package/dist/recorder-host-YPWPLMS6.js +80 -0
  510. package/dist/recordings.js +3 -3
  511. package/dist/sandbox-files-BJKCREOU.js +28 -0
  512. package/dist/sandbox-files-BJKCREOU.js.map +1 -0
  513. package/dist/session-app.js +242 -241
  514. package/dist/session-connect-cards-DK3UJZRY.js +27 -0
  515. package/dist/session-connect-cards-DK3UJZRY.js.map +1 -0
  516. package/dist/session-list-model.js +2 -2
  517. package/dist/session-realtime-AKDUKFY4.js +30 -0
  518. package/dist/session-realtime-AKDUKFY4.js.map +1 -0
  519. package/dist/session-realtime.js +2 -2
  520. package/dist/session-ui.js +42 -42
  521. package/dist/session.js +11 -11
  522. package/dist/sites.js +2 -2
  523. package/dist/terminal.js +2 -2
  524. package/dist/this-computer.js +3 -3
  525. package/dist/timeline-annotation-markers-7QSYK22C.js +157 -0
  526. package/dist/timeline-annotation-selection-XYNMESWL.js +208 -0
  527. package/dist/timeline-annotations-dialog-WSI6L2CP.js +283 -0
  528. package/dist/timeline-model.js +26 -26
  529. package/dist/ui/access-list.js +5 -5
  530. package/dist/ui/cadence-picker.js +5 -5
  531. package/dist/ui/choice-cards.js +3 -3
  532. package/dist/ui/confirm-dialog.js +2 -2
  533. package/dist/ui/copy-field.js +3 -3
  534. package/dist/ui/detail-page.js +2 -2
  535. package/dist/ui/detail-sheet.js +2 -2
  536. package/dist/ui/disclosure.js +3 -3
  537. package/dist/ui/email-chips-input.js +3 -3
  538. package/dist/ui/field.js +2 -2
  539. package/dist/ui/flush-form-page.js +3 -3
  540. package/dist/ui/form-dialog.js +2 -2
  541. package/dist/ui/list-row.js +4 -4
  542. package/dist/ui/relative-time.js +3 -3
  543. package/dist/ui/revision-history.js +5 -5
  544. package/dist/ui/role-select.js +5 -5
  545. package/dist/ui/select-menu.js +3 -3
  546. package/dist/ui/usage-meter.js +4 -4
  547. package/dist/usage.js +2 -2
  548. package/dist/workbench.js +4 -4
  549. package/package.json +6 -5
  550. package/src/app/components/agents/agent-skills.tsx +21 -18
  551. package/src/app/components/agents/agent-trigger-dialog.tsx +80 -119
  552. package/src/app/components/agents/agent-trigger-model.ts +47 -0
  553. package/src/app/components/agents/agent-trigger-repositories.tsx +88 -0
  554. package/src/app/components/agents/agents-page.tsx +118 -38
  555. package/src/app/components/artifacts/app-server-status.test.tsx +33 -0
  556. package/src/app/components/artifacts/app-server-status.tsx +93 -0
  557. package/src/app/components/artifacts/ready-made-apps.tsx +84 -0
  558. package/src/app/lib/codex-model-switch.ts +1 -0
  559. package/src/app/lib/needs-you.test.ts +8 -0
  560. package/src/app/lib/needs-you.tsx +3 -1
  561. package/src/app/lib/ready-made-apps.tsx +42 -0
  562. package/src/app/lib/session-capabilities.tsx +1 -0
  563. package/src/app/routes/artifacts.tsx +11 -0
  564. package/src/app/routes/site-view.tsx +9 -0
  565. package/src/automations.ts +8 -2
  566. package/src/components/automations/pasted-webhook-steps.tsx +89 -0
  567. package/src/components/browser-viewer.tsx +49 -7
  568. package/src/components/human-input-form.tsx +16 -5
  569. package/src/components/secret-question-field.tsx +42 -32
  570. package/src/components/use-fit-browser-viewport.ts +84 -0
  571. package/src/messages/en.ts +1 -1
  572. package/src/timeline/projection.ts +5 -2
  573. package/src/timeline/tool-steps.ts +2 -0
  574. package/dist/browser-viewer-EIEMRVFF.js +0 -23
  575. package/dist/chat-interactive-block-FV37LWYZ.js +0 -22
  576. package/dist/chunk-2COBAJC7.js +0 -818
  577. package/dist/chunk-2HS3IUXE.js +0 -170
  578. package/dist/chunk-2JTMFYCT.js +0 -296
  579. package/dist/chunk-2JXKP4M6.js +0 -114
  580. package/dist/chunk-2P5K7CBH.js +0 -269
  581. package/dist/chunk-2XGRHMRI.js +0 -250
  582. package/dist/chunk-332BYSAZ.js +0 -65
  583. package/dist/chunk-3EM5GTP3.js +0 -158
  584. package/dist/chunk-3L5ATO4A.js +0 -52
  585. package/dist/chunk-3S3PJB7J.js +0 -107
  586. package/dist/chunk-3SBKYPNM.js +0 -270
  587. package/dist/chunk-3Z7VA6ET.js +0 -114
  588. package/dist/chunk-43BRJBEV.js +0 -207
  589. package/dist/chunk-46LZO4ZO.js +0 -188
  590. package/dist/chunk-4AH4EEHE.js +0 -298
  591. package/dist/chunk-4D3YJNVN.js +0 -270
  592. package/dist/chunk-4E5QVAT4.js +0 -4480
  593. package/dist/chunk-4I4RTI4D.js +0 -37
  594. package/dist/chunk-4KASGJTF.js +0 -287
  595. package/dist/chunk-4RUKLIOF.js +0 -1263
  596. package/dist/chunk-4UU7FN3I.js +0 -650
  597. package/dist/chunk-4ZRNASBF.js +0 -2551
  598. package/dist/chunk-5EJBPQI2.js +0 -41
  599. package/dist/chunk-5G4IGG7F.js +0 -209
  600. package/dist/chunk-5JAYZOAW.js +0 -131
  601. package/dist/chunk-5JOKVDSR.js +0 -789
  602. package/dist/chunk-5JOKVDSR.js.map +0 -1
  603. package/dist/chunk-5MP3G7ZV.js +0 -1236
  604. package/dist/chunk-5OVRMKP5.js +0 -42
  605. package/dist/chunk-5SGTRULO.js +0 -1184
  606. package/dist/chunk-5SOL4INY.js +0 -572
  607. package/dist/chunk-5Y34P32B.js +0 -27
  608. package/dist/chunk-62HIKJ5F.js +0 -72
  609. package/dist/chunk-63VNZRLY.js +0 -386
  610. package/dist/chunk-63WDQV5X.js +0 -148
  611. package/dist/chunk-6DOIINY4.js +0 -201
  612. package/dist/chunk-6DQBUKGJ.js +0 -112
  613. package/dist/chunk-6SETNFNH.js +0 -1399
  614. package/dist/chunk-6SETNFNH.js.map +0 -1
  615. package/dist/chunk-6XYFMHNT.js +0 -56
  616. package/dist/chunk-6YU3WV2P.js +0 -33
  617. package/dist/chunk-6YUHDFOZ.js +0 -351
  618. package/dist/chunk-72EOXOR7.js +0 -1185
  619. package/dist/chunk-72ND4ALI.js +0 -532
  620. package/dist/chunk-757LE32E.js +0 -283
  621. package/dist/chunk-7S2S4MXR.js +0 -138
  622. package/dist/chunk-7SYCHMXS.js +0 -200
  623. package/dist/chunk-7TVAPQOV.js +0 -5089
  624. package/dist/chunk-7UDLRDHK.js +0 -214
  625. package/dist/chunk-7YLQCMZP.js +0 -357
  626. package/dist/chunk-A5GX3CAE.js +0 -849
  627. package/dist/chunk-A7EBV2EB.js +0 -318
  628. package/dist/chunk-AB5SPXUR.js +0 -114
  629. package/dist/chunk-AHVQGL5A.js +0 -202
  630. package/dist/chunk-AI77ZKEV.js +0 -26
  631. package/dist/chunk-AIX2D6RB.js +0 -1019
  632. package/dist/chunk-AVSIHP7Q.js +0 -192
  633. package/dist/chunk-AWK23Q32.js +0 -107
  634. package/dist/chunk-AYM3UFP2.js +0 -43
  635. package/dist/chunk-AYM3UFP2.js.map +0 -1
  636. package/dist/chunk-AYVWA6KD.js +0 -432
  637. package/dist/chunk-AYVWA6KD.js.map +0 -1
  638. package/dist/chunk-AYZXE4IM.js +0 -2553
  639. package/dist/chunk-AZGGSPTE.js +0 -124
  640. package/dist/chunk-B45TB4HY.js +0 -931
  641. package/dist/chunk-BC7PTVXW.js +0 -140
  642. package/dist/chunk-BIUJHNVR.js +0 -46
  643. package/dist/chunk-BJUOKUE5.js +0 -234
  644. package/dist/chunk-BMT5IXQW.js +0 -154
  645. package/dist/chunk-BMT5IXQW.js.map +0 -1
  646. package/dist/chunk-BPEEVMKH.js +0 -292
  647. package/dist/chunk-BXMND6YU.js +0 -307
  648. package/dist/chunk-C6OM2SRG.js +0 -117
  649. package/dist/chunk-CIRCUDKF.js +0 -1309
  650. package/dist/chunk-CLKR4UG3.js +0 -403
  651. package/dist/chunk-CPX6BHER.js +0 -554
  652. package/dist/chunk-CVC4RO7D.js +0 -155
  653. package/dist/chunk-D3YJAQGK.js +0 -103
  654. package/dist/chunk-DFQ72BLS.js +0 -1024
  655. package/dist/chunk-DG65PJOZ.js +0 -4564
  656. package/dist/chunk-DG65PJOZ.js.map +0 -1
  657. package/dist/chunk-DNAXAS5R.js +0 -406
  658. package/dist/chunk-DO247ITS.js +0 -175
  659. package/dist/chunk-DONBARLL.js +0 -154
  660. package/dist/chunk-DTLXQ3ZU.js +0 -373
  661. package/dist/chunk-EAXTACI4.js +0 -274
  662. package/dist/chunk-EDPH7AJH.js +0 -412
  663. package/dist/chunk-EER3B3G5.js +0 -10036
  664. package/dist/chunk-EER3B3G5.js.map +0 -1
  665. package/dist/chunk-EFKQHCGJ.js +0 -276
  666. package/dist/chunk-EILSPMVD.js +0 -133
  667. package/dist/chunk-EMWT6GOK.js +0 -437
  668. package/dist/chunk-EO22NST7.js +0 -259
  669. package/dist/chunk-ER5MYLIE.js +0 -256
  670. package/dist/chunk-ES5HKVQF.js +0 -234
  671. package/dist/chunk-EXRQ5ATC.js +0 -738
  672. package/dist/chunk-F26YBYAZ.js +0 -111
  673. package/dist/chunk-F6QP4GSK.js +0 -515
  674. package/dist/chunk-F7QEO7M2.js +0 -851
  675. package/dist/chunk-FJFGDLXB.js +0 -12
  676. package/dist/chunk-FLLJ2WXW.js +0 -113
  677. package/dist/chunk-FMBJKMT4.js +0 -107
  678. package/dist/chunk-FPN4I4CG.js +0 -3690
  679. package/dist/chunk-FUXFJTXL.js +0 -3070
  680. package/dist/chunk-FZI4QOAV.js +0 -3996
  681. package/dist/chunk-G6SSSX5R.js +0 -158
  682. package/dist/chunk-GBGCMHBB.js +0 -608
  683. package/dist/chunk-GJ4GTYOD.js +0 -372
  684. package/dist/chunk-GLSDWNFV.js +0 -432
  685. package/dist/chunk-GMGAW3T6.js +0 -278
  686. package/dist/chunk-GNGI6XFN.js +0 -43
  687. package/dist/chunk-GSW4YHZE.js +0 -229
  688. package/dist/chunk-GUC6IWEY.js +0 -407
  689. package/dist/chunk-GWAY3SO5.js +0 -15
  690. package/dist/chunk-GXOTNT5D.js +0 -168
  691. package/dist/chunk-GZZCVF76.js +0 -3851
  692. package/dist/chunk-H4VMHFOX.js +0 -214
  693. package/dist/chunk-HA5RFQAF.js +0 -110
  694. package/dist/chunk-HJLHGXWL.js +0 -103
  695. package/dist/chunk-HKNMNL7B.js +0 -2984
  696. package/dist/chunk-HT7MBHLY.js +0 -1021
  697. package/dist/chunk-I5FSUZVW.js +0 -584
  698. package/dist/chunk-II376XH3.js +0 -117
  699. package/dist/chunk-IINQO425.js +0 -246
  700. package/dist/chunk-IIXNEOK4.js +0 -1022
  701. package/dist/chunk-IM3WA5AL.js +0 -311
  702. package/dist/chunk-IX4P4OGR.js +0 -399
  703. package/dist/chunk-IX5VHZYS.js +0 -129
  704. package/dist/chunk-J7QHW2KS.js +0 -549
  705. package/dist/chunk-J7QHW2KS.js.map +0 -1
  706. package/dist/chunk-JB3TSUZO.js +0 -263
  707. package/dist/chunk-JD6LHU26.js +0 -3852
  708. package/dist/chunk-JD6LHU26.js.map +0 -1
  709. package/dist/chunk-JIC6RLUB.js +0 -27
  710. package/dist/chunk-JNJIZCTN.js +0 -172
  711. package/dist/chunk-JNV5ZPUV.js +0 -828
  712. package/dist/chunk-JPQFVR24.js +0 -50
  713. package/dist/chunk-JPZVMXDP.js +0 -1333
  714. package/dist/chunk-JVPF34MX.js +0 -215
  715. package/dist/chunk-KED67KAF.js +0 -85
  716. package/dist/chunk-KJ72GMZ2.js +0 -378
  717. package/dist/chunk-KVPQUADA.js +0 -5915
  718. package/dist/chunk-KVPQUADA.js.map +0 -1
  719. package/dist/chunk-KXBLLFOO.js +0 -249
  720. package/dist/chunk-LIOZ2MXJ.js +0 -380
  721. package/dist/chunk-LPEFULJY.js +0 -73
  722. package/dist/chunk-LRMGPO7E.js +0 -98
  723. package/dist/chunk-LVKTKORH.js +0 -121
  724. package/dist/chunk-MFVUNNFN.js +0 -205
  725. package/dist/chunk-MIUJ3EH5.js +0 -60
  726. package/dist/chunk-MIUMNTIJ.js +0 -175
  727. package/dist/chunk-ML46TXRM.js +0 -113
  728. package/dist/chunk-MQRHTOQ2.js +0 -218
  729. package/dist/chunk-NIPON7YB.js +0 -850
  730. package/dist/chunk-NPBEUU22.js +0 -196
  731. package/dist/chunk-NSXKGS2K.js +0 -178
  732. package/dist/chunk-NUEFORM6.js +0 -2317
  733. package/dist/chunk-NZOFNQNC.js +0 -176
  734. package/dist/chunk-OATXCLTY.js +0 -211
  735. package/dist/chunk-OG3ELROW.js +0 -538
  736. package/dist/chunk-OI4WS7FW.js +0 -162
  737. package/dist/chunk-OITGZUDC.js +0 -82
  738. package/dist/chunk-OKD2LBMK.js +0 -333
  739. package/dist/chunk-OSA4CGST.js +0 -134
  740. package/dist/chunk-OXYAKUFU.js +0 -401
  741. package/dist/chunk-OYMSMU5O.js +0 -396
  742. package/dist/chunk-P4NZ72KY.js +0 -162
  743. package/dist/chunk-PBYL2VIM.js +0 -379
  744. package/dist/chunk-PDW3OOSZ.js +0 -505
  745. package/dist/chunk-PGRKTQIW.js +0 -523
  746. package/dist/chunk-Q273Q33U.js +0 -166
  747. package/dist/chunk-Q4CLS2HL.js +0 -340
  748. package/dist/chunk-QFOBUA2J.js +0 -428
  749. package/dist/chunk-QLIM4D56.js +0 -1095
  750. package/dist/chunk-QMQF5U2D.js +0 -20
  751. package/dist/chunk-QPOUPVPD.js +0 -144
  752. package/dist/chunk-QTJAQ6DS.js +0 -48
  753. package/dist/chunk-QUOFP3G7.js +0 -404
  754. package/dist/chunk-QVOTPOXK.js +0 -29
  755. package/dist/chunk-QYZ5RVGM.js +0 -184
  756. package/dist/chunk-R7CVDKRN.js +0 -2580
  757. package/dist/chunk-RB7MXNZD.js +0 -639
  758. package/dist/chunk-RDZQFZOQ.js +0 -187
  759. package/dist/chunk-RIHKEGWS.js +0 -194
  760. package/dist/chunk-RIHKEGWS.js.map +0 -1
  761. package/dist/chunk-ROSB7GF6.js +0 -57
  762. package/dist/chunk-RP3YMYCX.js +0 -723
  763. package/dist/chunk-RPHXJHNX.js +0 -271
  764. package/dist/chunk-RVC3M66H.js +0 -191
  765. package/dist/chunk-S3OTJAAC.js +0 -283
  766. package/dist/chunk-SBWPMVRN.js +0 -56
  767. package/dist/chunk-SERECSAR.js +0 -138
  768. package/dist/chunk-SHSEF3GJ.js +0 -187
  769. package/dist/chunk-SMS2M3RG.js +0 -772
  770. package/dist/chunk-SRDHDIRQ.js +0 -177
  771. package/dist/chunk-SXRYA7NN.js +0 -389
  772. package/dist/chunk-SYA3WYG4.js +0 -1187
  773. package/dist/chunk-T2QDSTBH.js +0 -371
  774. package/dist/chunk-TFSCGFYV.js +0 -251
  775. package/dist/chunk-TGCKZOSX.js +0 -246
  776. package/dist/chunk-THILLYQM.js +0 -132
  777. package/dist/chunk-TI6LGUEZ.js +0 -2412
  778. package/dist/chunk-TSY6YZL2.js +0 -366
  779. package/dist/chunk-TW2RHTLH.js +0 -3321
  780. package/dist/chunk-TWA5G277.js +0 -141
  781. package/dist/chunk-TZZ2S4XI.js +0 -247
  782. package/dist/chunk-UECD27LX.js +0 -251
  783. package/dist/chunk-UFJDETKG.js +0 -108
  784. package/dist/chunk-UHBIXNRW.js +0 -100
  785. package/dist/chunk-UHCFYX4I.js +0 -570
  786. package/dist/chunk-UHTURYJO.js +0 -898
  787. package/dist/chunk-UJH63JT3.js +0 -67
  788. package/dist/chunk-UMLPIMGW.js +0 -105
  789. package/dist/chunk-UOLDS6S5.js +0 -1152
  790. package/dist/chunk-UUE3OGXI.js +0 -84
  791. package/dist/chunk-UUNJ2E57.js +0 -391
  792. package/dist/chunk-UYQVWRAH.js +0 -199
  793. package/dist/chunk-UYWWUEL4.js +0 -126
  794. package/dist/chunk-V4CQKX5H.js +0 -48
  795. package/dist/chunk-V4QM7GDQ.js +0 -3176
  796. package/dist/chunk-V5Y74WII.js +0 -91
  797. package/dist/chunk-VGGZLUQK.js +0 -129
  798. package/dist/chunk-VGX636MB.js +0 -311
  799. package/dist/chunk-VGZLFQO2.js +0 -773
  800. package/dist/chunk-VJWZATNF.js +0 -137
  801. package/dist/chunk-VMWCIC2N.js +0 -50
  802. package/dist/chunk-VPWKTIU5.js +0 -227
  803. package/dist/chunk-VXOLG6YB.js +0 -469
  804. package/dist/chunk-W2NAU5VB.js +0 -1628
  805. package/dist/chunk-WGORKMR3.js +0 -353
  806. package/dist/chunk-WMIDELSJ.js +0 -391
  807. package/dist/chunk-WSOSGL2G.js +0 -383
  808. package/dist/chunk-WXUUOM4X.js +0 -400
  809. package/dist/chunk-WZ74QHLE.js +0 -4863
  810. package/dist/chunk-WZ74QHLE.js.map +0 -1
  811. package/dist/chunk-X2OWM2ME.js +0 -1870
  812. package/dist/chunk-X2OWM2ME.js.map +0 -1
  813. package/dist/chunk-XDXKB25W.js +0 -93
  814. package/dist/chunk-XE4PHI74.js +0 -231
  815. package/dist/chunk-XLJ4SQFS.js +0 -230
  816. package/dist/chunk-XOD4FX6M.js +0 -2434
  817. package/dist/chunk-XODQ2GPF.js +0 -3110
  818. package/dist/chunk-XT54RTAM.js +0 -441
  819. package/dist/chunk-YDQHFJM2.js +0 -83
  820. package/dist/chunk-YH6O6OQ6.js +0 -1356
  821. package/dist/chunk-YIKPC2QP.js +0 -794
  822. package/dist/chunk-ZD7PKYC4.js +0 -335
  823. package/dist/chunk-ZEQYHEWP.js +0 -406
  824. package/dist/chunk-ZRVUCTSI.js +0 -265
  825. package/dist/chunk-ZSI3ITRK.js +0 -449
  826. package/dist/chunk-ZZMEQCIZ.js +0 -236
  827. package/dist/computer-viewer-ZBY3BPYW.js +0 -21
  828. package/dist/connection-step-up-JQ4OFSQN.js +0 -145
  829. package/dist/connection-step-up-JQ4OFSQN.js.map +0 -1
  830. package/dist/embedded-new-voice-ZB5XLKLU.js +0 -25
  831. package/dist/embedded-voice-MZJISDCS.js +0 -25
  832. package/dist/fleet-decision-row-LG3SYVR3.js +0 -361
  833. package/dist/latest-question-QWJTXMFA.js +0 -124
  834. package/dist/model-policy-picker-menu-5Y72PLNF.js +0 -23
  835. package/dist/payment-page-card-YPSXRHBA.js +0 -226
  836. package/dist/platform-activity-row-ZU4MEBNK.js +0 -156
  837. package/dist/queue-surface-implementation-6Q25RPH6.js +0 -932
  838. package/dist/recorder-host-JD4GWJ2Z.js +0 -80
  839. package/dist/sandbox-files-HCLEEJMU.js +0 -28
  840. package/dist/session-connect-cards-DRKEN3Z4.js +0 -27
  841. package/dist/session-realtime-IZOTTRH6.js +0 -30
  842. package/dist/timeline-annotation-markers-WWXNJOXI.js +0 -157
  843. package/dist/timeline-annotation-selection-ZKRIQFIQ.js +0 -208
  844. package/dist/timeline-annotations-dialog-4IMKTOXJ.js +0 -283
  845. /package/dist/{browser-viewer-EIEMRVFF.js.map → app/components/agents/agent-trigger-repositories.js.map} +0 -0
  846. /package/dist/{chat-interactive-block-FV37LWYZ.js.map → app/components/artifacts/app-server-status.js.map} +0 -0
  847. /package/dist/{computer-viewer-ZBY3BPYW.js.map → app/components/artifacts/ready-made-apps.js.map} +0 -0
  848. /package/dist/{embedded-new-voice-ZB5XLKLU.js.map → app/lib/ready-made-apps.js.map} +0 -0
  849. /package/dist/{embedded-voice-MZJISDCS.js.map → browser-viewer-EPGAK2W6.js.map} +0 -0
  850. /package/dist/{model-policy-picker-menu-5Y72PLNF.js.map → chat-interactive-block-65YU6TMO.js.map} +0 -0
  851. /package/dist/{chunk-CLKR4UG3.js.map → chunk-25ODMMHH.js.map} +0 -0
  852. /package/dist/{chunk-WXUUOM4X.js.map → chunk-266ZPUMH.js.map} +0 -0
  853. /package/dist/{chunk-GXOTNT5D.js.map → chunk-2A7SB7UR.js.map} +0 -0
  854. /package/dist/{chunk-UHBIXNRW.js.map → chunk-2EU4Y7A7.js.map} +0 -0
  855. /package/dist/{chunk-UHCFYX4I.js.map → chunk-2LBYEHBH.js.map} +0 -0
  856. /package/dist/{chunk-TWA5G277.js.map → chunk-2MHIIF4N.js.map} +0 -0
  857. /package/dist/{chunk-757LE32E.js.map → chunk-2SHWGDAA.js.map} +0 -0
  858. /package/dist/{chunk-VGZLFQO2.js.map → chunk-2VX42S4W.js.map} +0 -0
  859. /package/dist/{chunk-VGX636MB.js.map → chunk-2WGJQ4XK.js.map} +0 -0
  860. /package/dist/{chunk-GWAY3SO5.js.map → chunk-2XSF44TY.js.map} +0 -0
  861. /package/dist/{chunk-RB7MXNZD.js.map → chunk-33HUZMNE.js.map} +0 -0
  862. /package/dist/{chunk-63WDQV5X.js.map → chunk-36IKHM4Q.js.map} +0 -0
  863. /package/dist/{chunk-4E5QVAT4.js.map → chunk-3JVQZAXQ.js.map} +0 -0
  864. /package/dist/{chunk-4KASGJTF.js.map → chunk-3SDESU6U.js.map} +0 -0
  865. /package/dist/{chunk-BPEEVMKH.js.map → chunk-3VXZFBP6.js.map} +0 -0
  866. /package/dist/{chunk-BXMND6YU.js.map → chunk-3YKED2ZV.js.map} +0 -0
  867. /package/dist/{chunk-AIX2D6RB.js.map → chunk-3ZNOKD3S.js.map} +0 -0
  868. /package/dist/{chunk-R7CVDKRN.js.map → chunk-45SB4UK3.js.map} +0 -0
  869. /package/dist/{chunk-EILSPMVD.js.map → chunk-47BETTVA.js.map} +0 -0
  870. /package/dist/{chunk-EAXTACI4.js.map → chunk-4BTQ473O.js.map} +0 -0
  871. /package/dist/{chunk-KXBLLFOO.js.map → chunk-4JQRWJVR.js.map} +0 -0
  872. /package/dist/{chunk-AHVQGL5A.js.map → chunk-4R6WFQKZ.js.map} +0 -0
  873. /package/dist/{chunk-S3OTJAAC.js.map → chunk-4WEPVL7X.js.map} +0 -0
  874. /package/dist/{chunk-6DOIINY4.js.map → chunk-4YWHOAB4.js.map} +0 -0
  875. /package/dist/{chunk-CVC4RO7D.js.map → chunk-52XGYRVS.js.map} +0 -0
  876. /package/dist/{chunk-GNGI6XFN.js.map → chunk-5G6UHUJZ.js.map} +0 -0
  877. /package/dist/{chunk-GSW4YHZE.js.map → chunk-5HFITPHH.js.map} +0 -0
  878. /package/dist/{chunk-4UU7FN3I.js.map → chunk-5LVVN2K7.js.map} +0 -0
  879. /package/dist/{chunk-V4CQKX5H.js.map → chunk-5PVXFVIT.js.map} +0 -0
  880. /package/dist/{chunk-RDZQFZOQ.js.map → chunk-5WFGW7B7.js.map} +0 -0
  881. /package/dist/{chunk-FUXFJTXL.js.map → chunk-66M7RVM6.js.map} +0 -0
  882. /package/dist/{chunk-EMWT6GOK.js.map → chunk-6AGNZI2W.js.map} +0 -0
  883. /package/dist/{chunk-DTLXQ3ZU.js.map → chunk-6ENO634Y.js.map} +0 -0
  884. /package/dist/{chunk-7SYCHMXS.js.map → chunk-6LQ5KEMP.js.map} +0 -0
  885. /package/dist/{chunk-QFOBUA2J.js.map → chunk-6QGIWLH5.js.map} +0 -0
  886. /package/dist/{chunk-2HS3IUXE.js.map → chunk-6WEDWD4N.js.map} +0 -0
  887. /package/dist/{chunk-AB5SPXUR.js.map → chunk-6YCYPXDA.js.map} +0 -0
  888. /package/dist/{chunk-A7EBV2EB.js.map → chunk-6YTNMDFP.js.map} +0 -0
  889. /package/dist/{chunk-JPQFVR24.js.map → chunk-73O7NO3F.js.map} +0 -0
  890. /package/dist/{chunk-UECD27LX.js.map → chunk-76VXLTQF.js.map} +0 -0
  891. /package/dist/{chunk-XDXKB25W.js.map → chunk-7EJ7PSZT.js.map} +0 -0
  892. /package/dist/{chunk-JIC6RLUB.js.map → chunk-7GS2MGFU.js.map} +0 -0
  893. /package/dist/{chunk-DNAXAS5R.js.map → chunk-7MF6MFHS.js.map} +0 -0
  894. /package/dist/{chunk-63VNZRLY.js.map → chunk-7N35XBSC.js.map} +0 -0
  895. /package/dist/{chunk-3SBKYPNM.js.map → chunk-7ND2VMKV.js.map} +0 -0
  896. /package/dist/{chunk-DONBARLL.js.map → chunk-7RVJLO3N.js.map} +0 -0
  897. /package/dist/{chunk-WGORKMR3.js.map → chunk-7VAILBP6.js.map} +0 -0
  898. /package/dist/{chunk-4I4RTI4D.js.map → chunk-7VSJQWFO.js.map} +0 -0
  899. /package/dist/{chunk-ZD7PKYC4.js.map → chunk-7YKUIKGH.js.map} +0 -0
  900. /package/dist/{chunk-SERECSAR.js.map → chunk-A7DS77WC.js.map} +0 -0
  901. /package/dist/{chunk-4AH4EEHE.js.map → chunk-AEH34OOU.js.map} +0 -0
  902. /package/dist/{chunk-CPX6BHER.js.map → chunk-ANWMRO2G.js.map} +0 -0
  903. /package/dist/{chunk-TZZ2S4XI.js.map → chunk-APGUIORF.js.map} +0 -0
  904. /package/dist/{chunk-CIRCUDKF.js.map → chunk-ASCVQJB4.js.map} +0 -0
  905. /package/dist/{chunk-JPZVMXDP.js.map → chunk-AY4XH73V.js.map} +0 -0
  906. /package/dist/{chunk-XOD4FX6M.js.map → chunk-B6AH43UQ.js.map} +0 -0
  907. /package/dist/{chunk-5OVRMKP5.js.map → chunk-BGT43KDL.js.map} +0 -0
  908. /package/dist/{chunk-GZZCVF76.js.map → chunk-BHS4KW4W.js.map} +0 -0
  909. /package/dist/{chunk-F7QEO7M2.js.map → chunk-BNWO72C2.js.map} +0 -0
  910. /package/dist/{chunk-4ZRNASBF.js.map → chunk-BSPIASSQ.js.map} +0 -0
  911. /package/dist/{chunk-XLJ4SQFS.js.map → chunk-BVWJEZXG.js.map} +0 -0
  912. /package/dist/{chunk-TSY6YZL2.js.map → chunk-BZ47G3VP.js.map} +0 -0
  913. /package/dist/{chunk-62HIKJ5F.js.map → chunk-C6KI5P3H.js.map} +0 -0
  914. /package/dist/{chunk-NUEFORM6.js.map → chunk-CLERWAEA.js.map} +0 -0
  915. /package/dist/{chunk-5SOL4INY.js.map → chunk-CNRFFCAE.js.map} +0 -0
  916. /package/dist/{chunk-ZZMEQCIZ.js.map → chunk-CPC6CYVW.js.map} +0 -0
  917. /package/dist/{chunk-FMBJKMT4.js.map → chunk-D23UAPXK.js.map} +0 -0
  918. /package/dist/{chunk-QVOTPOXK.js.map → chunk-DAPZEB4R.js.map} +0 -0
  919. /package/dist/{chunk-MFVUNNFN.js.map → chunk-DEDEA3WS.js.map} +0 -0
  920. /package/dist/{chunk-RPHXJHNX.js.map → chunk-DHVA3T3K.js.map} +0 -0
  921. /package/dist/{chunk-UUNJ2E57.js.map → chunk-DJQ6TKIP.js.map} +0 -0
  922. /package/dist/{chunk-6YU3WV2P.js.map → chunk-DK2CDAMR.js.map} +0 -0
  923. /package/dist/{chunk-GMGAW3T6.js.map → chunk-DPOB6MUS.js.map} +0 -0
  924. /package/dist/{chunk-VJWZATNF.js.map → chunk-DSO7S6PZ.js.map} +0 -0
  925. /package/dist/{chunk-OKD2LBMK.js.map → chunk-DV3OECO6.js.map} +0 -0
  926. /package/dist/{chunk-SYA3WYG4.js.map → chunk-DW2IQRMB.js.map} +0 -0
  927. /package/dist/{chunk-OSA4CGST.js.map → chunk-DWLPQTDL.js.map} +0 -0
  928. /package/dist/{chunk-V4QM7GDQ.js.map → chunk-DXMKECFR.js.map} +0 -0
  929. /package/dist/{chunk-LPEFULJY.js.map → chunk-DYQRNIID.js.map} +0 -0
  930. /package/dist/{chunk-VGGZLUQK.js.map → chunk-DZLWO73N.js.map} +0 -0
  931. /package/dist/{chunk-AWK23Q32.js.map → chunk-E2GNUL64.js.map} +0 -0
  932. /package/dist/{chunk-AVSIHP7Q.js.map → chunk-E7XU2KHD.js.map} +0 -0
  933. /package/dist/{chunk-2JXKP4M6.js.map → chunk-ENYULVQW.js.map} +0 -0
  934. /package/dist/{chunk-5EJBPQI2.js.map → chunk-EWHQ3DFM.js.map} +0 -0
  935. /package/dist/{chunk-EXRQ5ATC.js.map → chunk-F3LIUDXN.js.map} +0 -0
  936. /package/dist/{chunk-D3YJAQGK.js.map → chunk-F5C7DTVR.js.map} +0 -0
  937. /package/dist/{chunk-WMIDELSJ.js.map → chunk-F5NFGBIN.js.map} +0 -0
  938. /package/dist/{chunk-DO247ITS.js.map → chunk-F6XJLGOV.js.map} +0 -0
  939. /package/dist/{chunk-G6SSSX5R.js.map → chunk-F7T2STMX.js.map} +0 -0
  940. /package/dist/{chunk-T2QDSTBH.js.map → chunk-FAEVOM6B.js.map} +0 -0
  941. /package/dist/{chunk-EFKQHCGJ.js.map → chunk-FCFAXQDM.js.map} +0 -0
  942. /package/dist/{chunk-7S2S4MXR.js.map → chunk-FEQVCQMK.js.map} +0 -0
  943. /package/dist/{chunk-OYMSMU5O.js.map → chunk-FLDF2Z44.js.map} +0 -0
  944. /package/dist/{chunk-SMS2M3RG.js.map → chunk-GADABL3P.js.map} +0 -0
  945. /package/dist/{chunk-BC7PTVXW.js.map → chunk-GFUDB3SA.js.map} +0 -0
  946. /package/dist/{chunk-JVPF34MX.js.map → chunk-GGPZPBHS.js.map} +0 -0
  947. /package/dist/{chunk-IM3WA5AL.js.map → chunk-GIEGIEMT.js.map} +0 -0
  948. /package/dist/{chunk-SHSEF3GJ.js.map → chunk-GKWFQEO3.js.map} +0 -0
  949. /package/dist/{chunk-2XGRHMRI.js.map → chunk-GMMB4NCN.js.map} +0 -0
  950. /package/dist/{chunk-2P5K7CBH.js.map → chunk-GN4FOL2G.js.map} +0 -0
  951. /package/dist/{chunk-VXOLG6YB.js.map → chunk-GQJAMANY.js.map} +0 -0
  952. /package/dist/{chunk-PBYL2VIM.js.map → chunk-H7F4ANJQ.js.map} +0 -0
  953. /package/dist/{chunk-XODQ2GPF.js.map → chunk-HEPFJ3XQ.js.map} +0 -0
  954. /package/dist/{chunk-ES5HKVQF.js.map → chunk-HLRAQITA.js.map} +0 -0
  955. /package/dist/{chunk-II376XH3.js.map → chunk-HXYSZKCC.js.map} +0 -0
  956. /package/dist/{chunk-JNV5ZPUV.js.map → chunk-I5Q6FVHP.js.map} +0 -0
  957. /package/dist/{chunk-ZRVUCTSI.js.map → chunk-I7M5BYJU.js.map} +0 -0
  958. /package/dist/{chunk-KED67KAF.js.map → chunk-IH3J7VWW.js.map} +0 -0
  959. /package/dist/{chunk-NSXKGS2K.js.map → chunk-IMMDXSZ4.js.map} +0 -0
  960. /package/dist/{chunk-UYQVWRAH.js.map → chunk-IOMZDY5D.js.map} +0 -0
  961. /package/dist/{chunk-5MP3G7ZV.js.map → chunk-IQTCUUDF.js.map} +0 -0
  962. /package/dist/{chunk-UHTURYJO.js.map → chunk-ISR6KXWT.js.map} +0 -0
  963. /package/dist/{chunk-TW2RHTLH.js.map → chunk-IWPPGXUZ.js.map} +0 -0
  964. /package/dist/{chunk-UUE3OGXI.js.map → chunk-JNPCRNPA.js.map} +0 -0
  965. /package/dist/{chunk-PDW3OOSZ.js.map → chunk-JSJGGP32.js.map} +0 -0
  966. /package/dist/{chunk-SBWPMVRN.js.map → chunk-JZZUEJYD.js.map} +0 -0
  967. /package/dist/{chunk-4D3YJNVN.js.map → chunk-K5XFZKK5.js.map} +0 -0
  968. /package/dist/{chunk-332BYSAZ.js.map → chunk-K6GRTSEA.js.map} +0 -0
  969. /package/dist/{chunk-HJLHGXWL.js.map → chunk-KA4PZU3Q.js.map} +0 -0
  970. /package/dist/{chunk-YDQHFJM2.js.map → chunk-KGZ35ESO.js.map} +0 -0
  971. /package/dist/{chunk-HT7MBHLY.js.map → chunk-KRM4PW5N.js.map} +0 -0
  972. /package/dist/{chunk-QLIM4D56.js.map → chunk-LEZGGRDQ.js.map} +0 -0
  973. /package/dist/{chunk-QPOUPVPD.js.map → chunk-LFWMFFKT.js.map} +0 -0
  974. /package/dist/{chunk-A5GX3CAE.js.map → chunk-LKSPUZPH.js.map} +0 -0
  975. /package/dist/{chunk-OXYAKUFU.js.map → chunk-LLX4S6BI.js.map} +0 -0
  976. /package/dist/{chunk-NIPON7YB.js.map → chunk-M4WEF4DZ.js.map} +0 -0
  977. /package/dist/{chunk-LVKTKORH.js.map → chunk-MATYGLUT.js.map} +0 -0
  978. /package/dist/{chunk-5Y34P32B.js.map → chunk-MDI6SH7B.js.map} +0 -0
  979. /package/dist/{chunk-JB3TSUZO.js.map → chunk-MQTYIBY6.js.map} +0 -0
  980. /package/dist/{chunk-72EOXOR7.js.map → chunk-MRKY2GL5.js.map} +0 -0
  981. /package/dist/{chunk-YIKPC2QP.js.map → chunk-MSIQ42IY.js.map} +0 -0
  982. /package/dist/{chunk-7YLQCMZP.js.map → chunk-MVGU7BET.js.map} +0 -0
  983. /package/dist/{chunk-QUOFP3G7.js.map → chunk-MWY4TBDY.js.map} +0 -0
  984. /package/dist/{chunk-BJUOKUE5.js.map → chunk-NGQCWCD6.js.map} +0 -0
  985. /package/dist/{chunk-OG3ELROW.js.map → chunk-NKXMIOYN.js.map} +0 -0
  986. /package/dist/{chunk-ER5MYLIE.js.map → chunk-NMVRFFCR.js.map} +0 -0
  987. /package/dist/{chunk-GUC6IWEY.js.map → chunk-NNTDIKJP.js.map} +0 -0
  988. /package/dist/{chunk-LRMGPO7E.js.map → chunk-NQXCPP4G.js.map} +0 -0
  989. /package/dist/{chunk-THILLYQM.js.map → chunk-NYGS6FNV.js.map} +0 -0
  990. /package/dist/{chunk-NZOFNQNC.js.map → chunk-O3LOQDTI.js.map} +0 -0
  991. /package/dist/{chunk-2COBAJC7.js.map → chunk-O5HRZ2KG.js.map} +0 -0
  992. /package/dist/{chunk-H4VMHFOX.js.map → chunk-O5PZRVQR.js.map} +0 -0
  993. /package/dist/{chunk-IX4P4OGR.js.map → chunk-O6KR5SN7.js.map} +0 -0
  994. /package/dist/{chunk-EO22NST7.js.map → chunk-OBKDRV2H.js.map} +0 -0
  995. /package/dist/{chunk-3S3PJB7J.js.map → chunk-OBKKUBGL.js.map} +0 -0
  996. /package/dist/{chunk-3L5ATO4A.js.map → chunk-OFYXDB6I.js.map} +0 -0
  997. /package/dist/{chunk-VMWCIC2N.js.map → chunk-OLMWJGSJ.js.map} +0 -0
  998. /package/dist/{chunk-4RUKLIOF.js.map → chunk-ORRACKLB.js.map} +0 -0
  999. /package/dist/{chunk-6YUHDFOZ.js.map → chunk-P426WWAB.js.map} +0 -0
  1000. /package/dist/{chunk-SRDHDIRQ.js.map → chunk-P4GOY3ZL.js.map} +0 -0
  1001. /package/dist/{chunk-IX5VHZYS.js.map → chunk-P4KVJLUC.js.map} +0 -0
  1002. /package/dist/{chunk-6XYFMHNT.js.map → chunk-P4N7ZS6W.js.map} +0 -0
  1003. /package/dist/{chunk-5G4IGG7F.js.map → chunk-P6LSLNSL.js.map} +0 -0
  1004. /package/dist/{chunk-F26YBYAZ.js.map → chunk-PAFSIDM2.js.map} +0 -0
  1005. /package/dist/{chunk-C6OM2SRG.js.map → chunk-PC2JAIAH.js.map} +0 -0
  1006. /package/dist/{chunk-43BRJBEV.js.map → chunk-PGSXT5OY.js.map} +0 -0
  1007. /package/dist/{chunk-HKNMNL7B.js.map → chunk-QDMGUTOU.js.map} +0 -0
  1008. /package/dist/{chunk-YH6O6OQ6.js.map → chunk-QEMDQKQT.js.map} +0 -0
  1009. /package/dist/{chunk-TI6LGUEZ.js.map → chunk-QK7VU5N3.js.map} +0 -0
  1010. /package/dist/{chunk-FJFGDLXB.js.map → chunk-QL4Q332Z.js.map} +0 -0
  1011. /package/dist/{chunk-5SGTRULO.js.map → chunk-QL5227KT.js.map} +0 -0
  1012. /package/dist/{chunk-3Z7VA6ET.js.map → chunk-QUFCZMHG.js.map} +0 -0
  1013. /package/dist/{chunk-VPWKTIU5.js.map → chunk-QXPKUKOV.js.map} +0 -0
  1014. /package/dist/{chunk-XT54RTAM.js.map → chunk-QZE3KD34.js.map} +0 -0
  1015. /package/dist/{chunk-Q273Q33U.js.map → chunk-RAIUIXCY.js.map} +0 -0
  1016. /package/dist/{chunk-RP3YMYCX.js.map → chunk-RDLS6IZY.js.map} +0 -0
  1017. /package/dist/{chunk-MIUMNTIJ.js.map → chunk-RKPETJDJ.js.map} +0 -0
  1018. /package/dist/{chunk-GJ4GTYOD.js.map → chunk-RMDLTRLI.js.map} +0 -0
  1019. /package/dist/{chunk-PGRKTQIW.js.map → chunk-RR6DQN4X.js.map} +0 -0
  1020. /package/dist/{chunk-MQRHTOQ2.js.map → chunk-RVPH6BB7.js.map} +0 -0
  1021. /package/dist/{chunk-B45TB4HY.js.map → chunk-RVXLSVJH.js.map} +0 -0
  1022. /package/dist/{chunk-IINQO425.js.map → chunk-RVY5EZNU.js.map} +0 -0
  1023. /package/dist/{chunk-DFQ72BLS.js.map → chunk-RWHBX4MN.js.map} +0 -0
  1024. /package/dist/{chunk-7UDLRDHK.js.map → chunk-RWHDMGFG.js.map} +0 -0
  1025. /package/dist/{chunk-FLLJ2WXW.js.map → chunk-RYB3WBMZ.js.map} +0 -0
  1026. /package/dist/{chunk-ZSI3ITRK.js.map → chunk-S7EO77EE.js.map} +0 -0
  1027. /package/dist/{chunk-I5FSUZVW.js.map → chunk-S7J4HBPP.js.map} +0 -0
  1028. /package/dist/{chunk-UFJDETKG.js.map → chunk-SA3XI7FB.js.map} +0 -0
  1029. /package/dist/{chunk-NPBEUU22.js.map → chunk-SKRTCSUL.js.map} +0 -0
  1030. /package/dist/{chunk-7TVAPQOV.js.map → chunk-SUWDILUY.js.map} +0 -0
  1031. /package/dist/{chunk-TFSCGFYV.js.map → chunk-SWTPVMR4.js.map} +0 -0
  1032. /package/dist/{chunk-RVC3M66H.js.map → chunk-T5BYEE66.js.map} +0 -0
  1033. /package/dist/{chunk-QTJAQ6DS.js.map → chunk-T652Q4R6.js.map} +0 -0
  1034. /package/dist/{chunk-GBGCMHBB.js.map → chunk-TBUOHK6R.js.map} +0 -0
  1035. /package/dist/{chunk-W2NAU5VB.js.map → chunk-TCUAGCAX.js.map} +0 -0
  1036. /package/dist/{chunk-UYWWUEL4.js.map → chunk-TLWH4E3P.js.map} +0 -0
  1037. /package/dist/{chunk-UOLDS6S5.js.map → chunk-TNHGSWG3.js.map} +0 -0
  1038. /package/dist/{chunk-WSOSGL2G.js.map → chunk-TO6VBJI3.js.map} +0 -0
  1039. /package/dist/{chunk-OI4WS7FW.js.map → chunk-TOL7MOAN.js.map} +0 -0
  1040. /package/dist/{chunk-AYZXE4IM.js.map → chunk-U243CBVZ.js.map} +0 -0
  1041. /package/dist/{chunk-BIUJHNVR.js.map → chunk-U2CEPRDH.js.map} +0 -0
  1042. /package/dist/{chunk-FZI4QOAV.js.map → chunk-UAZPXKPH.js.map} +0 -0
  1043. /package/dist/{chunk-EDPH7AJH.js.map → chunk-UHRGUMLJ.js.map} +0 -0
  1044. /package/dist/{chunk-5JAYZOAW.js.map → chunk-UNDSD6UA.js.map} +0 -0
  1045. /package/dist/{chunk-FPN4I4CG.js.map → chunk-USU2SS4V.js.map} +0 -0
  1046. /package/dist/{chunk-Q4CLS2HL.js.map → chunk-USWA5GQQ.js.map} +0 -0
  1047. /package/dist/{chunk-QYZ5RVGM.js.map → chunk-UXGTI4HR.js.map} +0 -0
  1048. /package/dist/{chunk-JNJIZCTN.js.map → chunk-UZKAHEQO.js.map} +0 -0
  1049. /package/dist/{chunk-ML46TXRM.js.map → chunk-VALESBNH.js.map} +0 -0
  1050. /package/dist/{chunk-F6QP4GSK.js.map → chunk-VMSMVWCJ.js.map} +0 -0
  1051. /package/dist/{chunk-3EM5GTP3.js.map → chunk-VPERSFGV.js.map} +0 -0
  1052. /package/dist/{chunk-AZGGSPTE.js.map → chunk-VXPY2GF3.js.map} +0 -0
  1053. /package/dist/{chunk-6DQBUKGJ.js.map → chunk-W7RKXZDV.js.map} +0 -0
  1054. /package/dist/{chunk-72ND4ALI.js.map → chunk-WEGZPK4I.js.map} +0 -0
  1055. /package/dist/{chunk-LIOZ2MXJ.js.map → chunk-WPKY3BGG.js.map} +0 -0
  1056. /package/dist/{chunk-IIXNEOK4.js.map → chunk-X3T3N6W5.js.map} +0 -0
  1057. /package/dist/{chunk-HA5RFQAF.js.map → chunk-X4OGMBY6.js.map} +0 -0
  1058. /package/dist/{chunk-OITGZUDC.js.map → chunk-X7ZHIJEI.js.map} +0 -0
  1059. /package/dist/{chunk-UJH63JT3.js.map → chunk-XR7Y2HPZ.js.map} +0 -0
  1060. /package/dist/{chunk-ROSB7GF6.js.map → chunk-Y2NMKJ7F.js.map} +0 -0
  1061. /package/dist/{chunk-AI77ZKEV.js.map → chunk-Y2QYPJDN.js.map} +0 -0
  1062. /package/dist/{chunk-OATXCLTY.js.map → chunk-Y47EPVCD.js.map} +0 -0
  1063. /package/dist/{chunk-P4NZ72KY.js.map → chunk-Y5Q4ETIW.js.map} +0 -0
  1064. /package/dist/{chunk-UMLPIMGW.js.map → chunk-YMQVVFXI.js.map} +0 -0
  1065. /package/dist/{chunk-KJ72GMZ2.js.map → chunk-YQ6FP33X.js.map} +0 -0
  1066. /package/dist/{chunk-ZEQYHEWP.js.map → chunk-YUA42N5A.js.map} +0 -0
  1067. /package/dist/{chunk-V5Y74WII.js.map → chunk-YXFNW64N.js.map} +0 -0
  1068. /package/dist/{chunk-SXRYA7NN.js.map → chunk-Z76RJPZF.js.map} +0 -0
  1069. /package/dist/{chunk-MIUJ3EH5.js.map → chunk-ZD67RM6G.js.map} +0 -0
  1070. /package/dist/{chunk-XE4PHI74.js.map → chunk-ZE4RD7U5.js.map} +0 -0
  1071. /package/dist/{chunk-GLSDWNFV.js.map → chunk-ZGR7LNXC.js.map} +0 -0
  1072. /package/dist/{chunk-QMQF5U2D.js.map → chunk-ZNA65Q6Y.js.map} +0 -0
  1073. /package/dist/{chunk-46LZO4ZO.js.map → chunk-ZRNK6FK6.js.map} +0 -0
  1074. /package/dist/{chunk-2JTMFYCT.js.map → chunk-ZVAIKQMC.js.map} +0 -0
  1075. /package/dist/{chunk-TGCKZOSX.js.map → chunk-ZZ3KNGTJ.js.map} +0 -0
  1076. /package/dist/{sandbox-files-HCLEEJMU.js.map → computer-viewer-M5N3GWBR.js.map} +0 -0
  1077. /package/dist/{session-connect-cards-DRKEN3Z4.js.map → embedded-new-voice-QZJG5DZ3.js.map} +0 -0
  1078. /package/dist/{session-realtime-IZOTTRH6.js.map → embedded-voice-7KOQNGKU.js.map} +0 -0
  1079. /package/dist/{fleet-decision-row-LG3SYVR3.js.map → fleet-decision-row-FJPAWNOQ.js.map} +0 -0
  1080. /package/dist/{latest-question-QWJTXMFA.js.map → latest-question-F3VPDR7U.js.map} +0 -0
  1081. /package/dist/{payment-page-card-YPSXRHBA.js.map → payment-page-card-HZJVN3F4.js.map} +0 -0
  1082. /package/dist/{platform-activity-row-ZU4MEBNK.js.map → platform-activity-row-NPEGG2VE.js.map} +0 -0
  1083. /package/dist/{queue-surface-implementation-6Q25RPH6.js.map → queue-surface-implementation-RTCTPF5T.js.map} +0 -0
  1084. /package/dist/{recorder-host-JD4GWJ2Z.js.map → recorder-host-YPWPLMS6.js.map} +0 -0
  1085. /package/dist/{timeline-annotation-markers-WWXNJOXI.js.map → timeline-annotation-markers-7QSYK22C.js.map} +0 -0
  1086. /package/dist/{timeline-annotation-selection-ZKRIQFIQ.js.map → timeline-annotation-selection-XYNMESWL.js.map} +0 -0
  1087. /package/dist/{timeline-annotations-dialog-4IMKTOXJ.js.map → timeline-annotations-dialog-WSI6L2CP.js.map} +0 -0
@@ -1,4863 +0,0 @@
1
- "use client";
2
- import {
3
- InteractionInterventionBanner,
4
- isInteractionControlUnavailable,
5
- isNonRetryableInteractionError,
6
- isSourcePlacementChangedError,
7
- isSourcePlacementElsewhereError,
8
- useInteractionInterventions,
9
- useInteractionInvalidation,
10
- useViewerMenuDismiss
11
- } from "./chunk-LIOZ2MXJ.js";
12
- import {
13
- interactionHostPlatform
14
- } from "./chunk-ZUWF4NF7.js";
15
- import {
16
- STREAM_CLOSE_REASON_NORMAL,
17
- STREAM_KIND_BROWSER,
18
- STREAM_ROLE_CLIENT,
19
- decodeStreamFrame,
20
- decodeStreamOpenAck,
21
- encodeStreamClose,
22
- encodeStreamOpen
23
- } from "./chunk-TNEZNMSN.js";
24
- import {
25
- copyTextToClipboard
26
- } from "./chunk-PEHTX3V7.js";
27
- import {
28
- useClientConfigFlags
29
- } from "./chunk-XESA3B7W.js";
30
- import {
31
- usePageLiveActivity
32
- } from "./chunk-SW4S6I5E.js";
33
- import {
34
- cn
35
- } from "./chunk-TXS65BB2.js";
36
- import {
37
- useEmbeddedBrowserInteraction
38
- } from "./chunk-BVUAHAQX.js";
39
- import {
40
- useOpenGeniText
41
- } from "./chunk-KVPQUADA.js";
42
- import {
43
- formatBytes
44
- } from "./chunk-UIK52VL4.js";
45
-
46
- // src/components/browser-viewer.tsx
47
- import { interactionControlFailureFromError } from "@opengeni/sdk/interaction";
48
- import {
49
- BugIcon,
50
- ArchiveIcon,
51
- ArrowLeftIcon,
52
- ArrowRightIcon,
53
- CheckIcon,
54
- ChevronDownIcon,
55
- CircleAlertIcon,
56
- DownloadIcon,
57
- FileCheck2Icon,
58
- Globe2Icon,
59
- LoaderCircleIcon,
60
- MonitorIcon,
61
- PlusIcon,
62
- RefreshCwIcon,
63
- RotateCcwIcon,
64
- SaveIcon,
65
- UserRoundIcon,
66
- XIcon,
67
- ZapIcon
68
- } from "lucide-react";
69
- import {
70
- useCallback as useCallback8,
71
- useEffect as useEffect9,
72
- useId,
73
- useLayoutEffect as useLayoutEffect2,
74
- useMemo as useMemo2,
75
- useRef as useRef9,
76
- useState as useState9
77
- } from "react";
78
-
79
- // src/hooks/use-browser-frame-stream.ts
80
- import {
81
- browserFrameSocketUrl,
82
- decodeBrowserFrameMessage
83
- } from "@opengeni/sdk/interaction";
84
- import { useCallback, useEffect, useRef, useState } from "react";
85
- import { errorMessage } from "@opengeni/contracts/values";
86
- var RELAY_TAG_OPEN = 1;
87
- var RELAY_TAG_OPEN_ACK = 2;
88
- var RELAY_TAG_FRAME = 3;
89
- var RELAY_TAG_CLOSE = 4;
90
- var MAX_AUTOMATIC_RECONNECTS_WITHOUT_A_FRAME = 2;
91
- function useBrowserFrameStream(options) {
92
- const t = useOpenGeniText();
93
- const { client, workspaceId } = useEmbeddedBrowserInteraction(options);
94
- const pageLive = usePageLiveActivity();
95
- const enabled = (options.enabled ?? true) && pageLive;
96
- const [nonce, setNonce] = useState(0);
97
- const [result, setResult] = useState({
98
- state: "idle",
99
- frame: null,
100
- attachment: null,
101
- error: null
102
- });
103
- const latestRef = useRef({
104
- key: "",
105
- sequence: -1
106
- });
107
- const factoryRef = useRef(options.webSocketFactory);
108
- const streamRef = useRef(options.stream);
109
- factoryRef.current = options.webSocketFactory;
110
- streamRef.current = options.stream;
111
- const reconnect = useCallback(() => setNonce((value) => value + 1), []);
112
- useEffect(() => {
113
- const browserSessionId = options.browserSessionId;
114
- const targetId = options.targetId;
115
- if (!enabled || !browserSessionId || !targetId || typeof window === "undefined") {
116
- setResult({ state: "idle", frame: null, attachment: null, error: null });
117
- return;
118
- }
119
- latestRef.current = { key: "", sequence: -1 };
120
- setResult({
121
- state: "attaching",
122
- frame: null,
123
- attachment: null,
124
- error: null
125
- });
126
- let disposed = false;
127
- let socket = null;
128
- let socketHandlers = null;
129
- let reconnectTimer = null;
130
- let expiryTimer = null;
131
- let failures = 0;
132
- let controllerGeneration = null;
133
- let activeAttachment = null;
134
- let activeStream = null;
135
- let attachmentExpiresAt = 0;
136
- let lastRelaySequence = null;
137
- let relayAccepted = false;
138
- let pendingFrame = null;
139
- let decodingFrame = false;
140
- const attachmentAbort = new AbortController();
141
- const clearSocket = (terminateProducer = false) => {
142
- if (!socket) return;
143
- const current = socket;
144
- const handlers = socketHandlers;
145
- if (terminateProducer && activeStream?.kind === "relay" && socket.readyState === 1) {
146
- try {
147
- socket.send(
148
- relayDatagram(
149
- RELAY_TAG_CLOSE,
150
- encodeStreamClose({
151
- channelId: activeStream.channel.channelId,
152
- reason: STREAM_CLOSE_REASON_NORMAL,
153
- message: "viewer detached"
154
- })
155
- )
156
- );
157
- } catch {
158
- }
159
- }
160
- if (handlers) {
161
- current.removeEventListener("open", handlers.open);
162
- current.removeEventListener("message", handlers.message);
163
- current.removeEventListener("error", handlers.error);
164
- current.removeEventListener("close", handlers.close);
165
- }
166
- if (current.readyState === 0 || current.readyState === 1) {
167
- current.close(1e3, "viewer detached");
168
- }
169
- socket = null;
170
- socketHandlers = null;
171
- pendingFrame = null;
172
- };
173
- const scheduleReconnect = () => {
174
- if (disposed || reconnectTimer) return;
175
- if (failures >= MAX_AUTOMATIC_RECONNECTS_WITHOUT_A_FRAME) return;
176
- const delay = Math.min(5e3, 250 * 2 ** Math.min(failures, 5));
177
- failures += 1;
178
- setResult((current) => ({ ...current, state: "reconnecting" }));
179
- reconnectTimer = setTimeout(() => {
180
- reconnectTimer = null;
181
- connectSocket();
182
- }, delay);
183
- };
184
- const fail = (cause, reconnectAutomatically = true) => {
185
- if (disposed) return;
186
- const error = cause instanceof Error ? cause : new Error(String(cause));
187
- setResult((current) => ({ ...current, state: "error", error }));
188
- clearSocket();
189
- if (reconnectAutomatically) scheduleReconnect();
190
- };
191
- const onOpen = (source) => {
192
- if (disposed || source !== socket) return;
193
- if (activeStream?.kind === "relay") {
194
- const body = encodeStreamOpen({
195
- channel: {
196
- ...activeStream.channel,
197
- kind: STREAM_KIND_BROWSER
198
- },
199
- token: activeStream.token,
200
- role: STREAM_ROLE_CLIENT,
201
- resumeFromSeq: lastRelaySequence === null ? "0" : (BigInt(lastRelaySequence) + 1n).toString()
202
- });
203
- try {
204
- source.send(relayDatagram(RELAY_TAG_OPEN, body));
205
- } catch (error) {
206
- fail(error);
207
- }
208
- return;
209
- }
210
- setResult((current) => ({ ...current, state: "live", error: null }));
211
- };
212
- const drainLatestFrame = async () => {
213
- if (decodingFrame) return;
214
- decodingFrame = true;
215
- try {
216
- while (pendingFrame) {
217
- if (disposed) break;
218
- const pending = pendingFrame;
219
- pendingFrame = null;
220
- const { bytes, source } = pending;
221
- const frame = decodeBrowserFrameMessage(bytes);
222
- if (disposed || source !== socket) continue;
223
- if (frame.browserSessionId !== browserSessionId || frame.targetId !== targetId) {
224
- throw new Error("browser frame belongs to another resource");
225
- }
226
- if (!controllerGeneration || frame.controllerGeneration !== controllerGeneration) {
227
- throw new Error("browser frame belongs to a stale controller");
228
- }
229
- const key = `${browserSessionId}:${targetId}:${frame.controllerGeneration}:${frame.targetGeneration}:${frame.documentGeneration}`;
230
- if (latestRef.current.key === key && frame.sequence <= latestRef.current.sequence)
231
- continue;
232
- latestRef.current = { key, sequence: frame.sequence };
233
- failures = 0;
234
- setResult((current) => ({
235
- ...current,
236
- state: "live",
237
- frame,
238
- error: null
239
- }));
240
- }
241
- } catch (cause) {
242
- fail(cause);
243
- } finally {
244
- decodingFrame = false;
245
- if (!disposed && pendingFrame) void drainLatestFrame();
246
- }
247
- };
248
- const onMessage = (source, event) => {
249
- void (async () => {
250
- try {
251
- const bytes = await messageBytes(event.data);
252
- if (disposed || source !== socket) return;
253
- let frameBytes = bytes;
254
- if (activeStream?.kind === "relay") {
255
- if (bytes.length < 1) throw new Error("browser relay returned an empty message");
256
- const tag = bytes[0];
257
- const body = bytes.subarray(1);
258
- if (tag === RELAY_TAG_OPEN_ACK) {
259
- const ack = decodeStreamOpenAck(body);
260
- if (!ack.accepted) {
261
- activeAttachment = null;
262
- activeStream = null;
263
- attachmentExpiresAt = 0;
264
- throw new Error(ack.error?.message ?? "browser stream was rejected by the relay");
265
- }
266
- relayAccepted = true;
267
- return;
268
- }
269
- if (tag === RELAY_TAG_CLOSE) {
270
- activeAttachment = null;
271
- activeStream = null;
272
- attachmentExpiresAt = 0;
273
- lastRelaySequence = null;
274
- relayAccepted = false;
275
- fail(new Error("Browser frame source ended."), false);
276
- return;
277
- }
278
- if (tag !== RELAY_TAG_FRAME || !relayAccepted) return;
279
- const relayFrame = decodeStreamFrame(body);
280
- lastRelaySequence = relayFrame.seq;
281
- frameBytes = relayFrame.data;
282
- }
283
- pendingFrame = { bytes: frameBytes, source };
284
- void drainLatestFrame();
285
- } catch (cause) {
286
- fail(cause);
287
- }
288
- })();
289
- };
290
- const onError = (source) => {
291
- if (source !== socket) return;
292
- fail(new Error(t("hooks.useBrowserFrameStream.browserViewLostConnection")));
293
- };
294
- const onClose = (source) => {
295
- if (disposed || source !== socket) return;
296
- clearSocket();
297
- scheduleReconnect();
298
- };
299
- const connectSocket = () => {
300
- if (disposed) return;
301
- clearSocket();
302
- if (!activeAttachment || !activeStream || attachmentExpiresAt <= Date.now() + 1e3) {
303
- void attach();
304
- return;
305
- }
306
- relayAccepted = false;
307
- setResult((current) => ({
308
- ...current,
309
- state: "connecting",
310
- error: null
311
- }));
312
- const createSocket = factoryRef.current ?? ((url, protocols) => new WebSocket(url, protocols));
313
- const openedSocket = createSocket(
314
- activeStream.kind === "relay" ? activeStream.url : browserFrameSocketUrl(activeAttachment, streamRef.current),
315
- activeStream.kind === "direct_websocket" ? [...activeStream.protocols] : []
316
- );
317
- latestRef.current = { key: "", sequence: -1 };
318
- socket = openedSocket;
319
- socketHandlers = {
320
- open: () => onOpen(openedSocket),
321
- message: (event) => onMessage(openedSocket, event),
322
- error: () => onError(openedSocket),
323
- close: () => onClose(openedSocket)
324
- };
325
- openedSocket.binaryType = "arraybuffer";
326
- openedSocket.addEventListener("open", socketHandlers.open);
327
- openedSocket.addEventListener("message", socketHandlers.message);
328
- openedSocket.addEventListener("error", socketHandlers.error);
329
- openedSocket.addEventListener("close", socketHandlers.close);
330
- };
331
- const attach = async () => {
332
- if (disposed) return;
333
- clearSocket();
334
- if (expiryTimer) clearTimeout(expiryTimer);
335
- setResult((current) => ({
336
- ...current,
337
- state: current.attachment ? "reconnecting" : "attaching",
338
- error: null
339
- }));
340
- try {
341
- const attachment = await client.attachBrowserSession(
342
- workspaceId,
343
- browserSessionId,
344
- {
345
- targetId,
346
- expiresInSeconds: 120,
347
- ...streamRef.current ? { stream: streamRef.current } : {}
348
- },
349
- { signal: attachmentAbort.signal }
350
- );
351
- if (disposed) return;
352
- if (attachment.browserSessionId !== browserSessionId || attachment.targetId !== targetId) {
353
- throw new Error("browser attachment does not match the requested resource");
354
- }
355
- controllerGeneration = attachment.controllerGeneration;
356
- activeAttachment = attachment;
357
- activeStream = attachment.stream;
358
- attachmentExpiresAt = Date.parse(attachment.expiresAt);
359
- lastRelaySequence = null;
360
- relayAccepted = false;
361
- setResult((current) => ({
362
- ...current,
363
- state: "connecting",
364
- attachment: {
365
- browserSessionId: attachment.browserSessionId,
366
- controllerGeneration: attachment.controllerGeneration,
367
- targetId: attachment.targetId,
368
- expiresAt: attachment.expiresAt,
369
- ...attachment.fencedInputBatches === true ? { fencedInputBatches: true } : {},
370
- ...attachment.focusedInputObservations === true ? { focusedInputObservations: true } : {}
371
- },
372
- error: null
373
- }));
374
- const refreshIn = Number.isFinite(attachmentExpiresAt) ? Math.max(1e3, attachmentExpiresAt - Date.now() - 5e3) : 6e4;
375
- expiryTimer = setTimeout(() => {
376
- if (disposed) return;
377
- clearSocket(true);
378
- activeAttachment = null;
379
- activeStream = null;
380
- attachmentExpiresAt = 0;
381
- void attach();
382
- }, refreshIn);
383
- connectSocket();
384
- } catch (cause) {
385
- if (attachmentAbort.signal.aborted || disposed) return;
386
- fail(cause, !isPlacementGenerationLossError(cause));
387
- }
388
- };
389
- void attach();
390
- return () => {
391
- disposed = true;
392
- attachmentAbort.abort();
393
- if (reconnectTimer) clearTimeout(reconnectTimer);
394
- if (expiryTimer) clearTimeout(expiryTimer);
395
- clearSocket(true);
396
- };
397
- }, [client, enabled, nonce, options.browserSessionId, options.targetId, workspaceId, t]);
398
- return { ...result, reconnect };
399
- }
400
- function relayDatagram(tag, body) {
401
- const message = new Uint8Array(body.length + 1);
402
- message[0] = tag;
403
- message.set(body, 1);
404
- return message.buffer;
405
- }
406
- async function messageBytes(value) {
407
- if (value instanceof ArrayBuffer) return new Uint8Array(value);
408
- if (ArrayBuffer.isView(value)) {
409
- return new Uint8Array(value.buffer, value.byteOffset, value.byteLength).slice();
410
- }
411
- if (typeof Blob !== "undefined" && value instanceof Blob) {
412
- return new Uint8Array(await value.arrayBuffer());
413
- }
414
- throw new Error("browser frame stream returned a non-binary message");
415
- }
416
- function isPlacementGenerationLossError(cause) {
417
- const message = errorMessage(cause);
418
- return /placement instance changed|controller authority changed/i.test(message);
419
- }
420
-
421
- // src/hooks/use-attached-browsers.ts
422
- import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
423
- function useAttachedBrowsers(options = {}) {
424
- const { client, workspaceId, workspaceInteractionEvent, workspaceInteractionConnectionState } = useEmbeddedBrowserInteraction(options);
425
- const enabled = options.enabled ?? true;
426
- const includeDisconnected = options.includeDisconnected ?? false;
427
- const [state, setState] = useState2(() => emptyState(workspaceId, enabled));
428
- const requestRef = useRef2({
429
- id: 0,
430
- controller: null
431
- });
432
- const mountedRef = useRef2(true);
433
- const visible = state.workspaceId === workspaceId ? state : emptyState(workspaceId, enabled);
434
- const cancelLoad = useCallback2(() => {
435
- const id = requestRef.current.id + 1;
436
- requestRef.current.controller?.abort();
437
- requestRef.current = { id, controller: null };
438
- }, []);
439
- const load = useCallback2(
440
- async (foreground) => {
441
- if (!enabled) return;
442
- const id = requestRef.current.id + 1;
443
- requestRef.current.controller?.abort();
444
- const controller = new AbortController();
445
- requestRef.current = { id, controller };
446
- setState((current) => ({
447
- ...current.workspaceId === workspaceId ? current : emptyState(workspaceId, true),
448
- loading: foreground,
449
- refreshing: !foreground,
450
- error: foreground || current.workspaceId !== workspaceId ? null : current.error
451
- }));
452
- try {
453
- const response = await client.listAttachedBrowsers(workspaceId, {
454
- includeDisconnected,
455
- signal: controller.signal
456
- });
457
- if (!mountedRef.current || requestRef.current.id !== id) return;
458
- setState({
459
- workspaceId,
460
- revision: response.revision,
461
- bridges: response.bridges,
462
- devices: sortDevices(response.devices),
463
- loading: false,
464
- refreshing: false,
465
- error: null
466
- });
467
- } catch (cause) {
468
- if (controller.signal.aborted || !mountedRef.current || requestRef.current.id !== id)
469
- return;
470
- setState((current) => ({
471
- ...current.workspaceId === workspaceId ? current : emptyState(workspaceId, true),
472
- loading: false,
473
- refreshing: false,
474
- error: cause instanceof Error ? cause : new Error(String(cause))
475
- }));
476
- } finally {
477
- if (requestRef.current.id === id) requestRef.current = { id, controller: null };
478
- }
479
- },
480
- [client, enabled, includeDisconnected, workspaceId]
481
- );
482
- const refresh = useCallback2(async () => await load(false), [load]);
483
- useEffect2(() => {
484
- mountedRef.current = true;
485
- if (!enabled) {
486
- cancelLoad();
487
- setState(emptyState(workspaceId, false));
488
- return;
489
- }
490
- void load(true);
491
- return () => {
492
- mountedRef.current = false;
493
- cancelLoad();
494
- };
495
- }, [cancelLoad, enabled, load, workspaceId]);
496
- useInteractionInvalidation({
497
- workspaceId,
498
- key: `${workspaceId}:${includeDisconnected}`,
499
- enabled,
500
- event: workspaceInteractionEvent,
501
- connectionState: workspaceInteractionConnectionState,
502
- knownRevision: visible.revision,
503
- refresh,
504
- fallbackPollIntervalMs: options.pollIntervalMs
505
- });
506
- return {
507
- revision: visible.revision,
508
- bridges: visible.bridges,
509
- devices: visible.devices,
510
- loading: visible.loading,
511
- refreshing: visible.refreshing,
512
- error: visible.error,
513
- refresh
514
- };
515
- }
516
- function emptyState(workspaceId, loading) {
517
- return {
518
- workspaceId,
519
- revision: 0,
520
- bridges: [],
521
- devices: [],
522
- loading,
523
- refreshing: false,
524
- error: null
525
- };
526
- }
527
- function sortDevices(devices) {
528
- return [...devices].sort(
529
- (left, right) => Number(right.state === "connected") - Number(left.state === "connected") || timestamp(right.lastSeenAt) - timestamp(left.lastSeenAt) || left.name.localeCompare(right.name)
530
- );
531
- }
532
- function timestamp(value) {
533
- const parsed = Date.parse(value);
534
- return Number.isFinite(parsed) ? parsed : 0;
535
- }
536
-
537
- // src/hooks/use-browser-identities.ts
538
- import { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
539
- function useBrowserIdentities(options = {}) {
540
- const { client, workspaceId, workspaceInteractionEvent, workspaceInteractionConnectionState } = useEmbeddedBrowserInteraction(options);
541
- const enabled = options.enabled ?? true;
542
- const includeArchived = options.includeArchived ?? false;
543
- const [state, setState] = useState3(() => emptyState2(workspaceId, enabled));
544
- const [mutationCount, setMutationCount] = useState3(0);
545
- const requestRef = useRef3({
546
- id: 0,
547
- controller: null
548
- });
549
- const mountedRef = useRef3(true);
550
- const visibleState = state.workspaceId === workspaceId ? state : emptyState2(workspaceId, enabled);
551
- const cancelLoad = useCallback3(() => {
552
- const id = requestRef.current.id + 1;
553
- requestRef.current.controller?.abort();
554
- requestRef.current = { id, controller: null };
555
- }, []);
556
- const load = useCallback3(
557
- async (foreground) => {
558
- if (!enabled) return;
559
- const id = requestRef.current.id + 1;
560
- requestRef.current.controller?.abort();
561
- const controller = new AbortController();
562
- requestRef.current = { id, controller };
563
- setState((current) => ({
564
- ...current.workspaceId === workspaceId ? current : emptyState2(workspaceId, true),
565
- loading: foreground,
566
- refreshing: !foreground,
567
- error: foreground || current.workspaceId !== workspaceId ? null : current.error
568
- }));
569
- try {
570
- const response = await client.listBrowserIdentities(workspaceId, {
571
- includeArchived,
572
- signal: controller.signal
573
- });
574
- if (!mountedRef.current || requestRef.current.id !== id) return;
575
- setState({
576
- workspaceId,
577
- revision: response.revision,
578
- identities: sortIdentities(response.identities),
579
- loading: false,
580
- refreshing: false,
581
- error: null
582
- });
583
- } catch (cause) {
584
- if (controller.signal.aborted || !mountedRef.current || requestRef.current.id !== id)
585
- return;
586
- setState((current) => ({
587
- ...current.workspaceId === workspaceId ? current : emptyState2(workspaceId, true),
588
- loading: false,
589
- refreshing: false,
590
- error: cause instanceof Error ? cause : new Error(String(cause))
591
- }));
592
- } finally {
593
- if (requestRef.current.id === id) requestRef.current = { id, controller: null };
594
- }
595
- },
596
- [client, enabled, includeArchived, workspaceId]
597
- );
598
- const refresh = useCallback3(async () => await load(false), [load]);
599
- useEffect3(() => {
600
- mountedRef.current = true;
601
- if (!enabled) {
602
- cancelLoad();
603
- setState(emptyState2(workspaceId, false));
604
- return;
605
- }
606
- void load(true);
607
- return () => {
608
- mountedRef.current = false;
609
- cancelLoad();
610
- };
611
- }, [cancelLoad, enabled, load, workspaceId]);
612
- useInteractionInvalidation({
613
- workspaceId,
614
- key: workspaceId,
615
- enabled,
616
- event: workspaceInteractionEvent,
617
- connectionState: workspaceInteractionConnectionState,
618
- knownRevision: visibleState.revision,
619
- refresh
620
- });
621
- const mutate = useCallback3(async (operation) => {
622
- setMutationCount((count) => count + 1);
623
- try {
624
- return await operation();
625
- } finally {
626
- if (mountedRef.current) setMutationCount((count) => Math.max(0, count - 1));
627
- }
628
- }, []);
629
- const create = useCallback3(
630
- async (request) => await mutate(async () => {
631
- const response = await client.createBrowserIdentity(workspaceId, {
632
- ...request,
633
- operationId: request.operationId ?? crypto.randomUUID()
634
- });
635
- setState((current) => mergeIdentity(current, workspaceId, response.identity));
636
- return response;
637
- }),
638
- [client, mutate, workspaceId]
639
- );
640
- const revisions = useCallback3(
641
- async (identityId) => await client.listBrowserRevisions(workspaceId, identityId),
642
- [client, workspaceId]
643
- );
644
- const update = useCallback3(
645
- async (identityId, request) => await mutate(async () => {
646
- const response = await client.updateBrowserIdentity(workspaceId, identityId, {
647
- ...request,
648
- operationId: request.operationId ?? crypto.randomUUID()
649
- });
650
- setState(
651
- (current) => mergeIdentity(current, workspaceId, response.identity, includeArchived)
652
- );
653
- return response;
654
- }),
655
- [client, includeArchived, mutate, workspaceId]
656
- );
657
- const publish = useCallback3(
658
- async (browserSessionId, request) => await mutate(async () => {
659
- const response = await client.publishBrowserRevision(workspaceId, browserSessionId, {
660
- ...request,
661
- operationId: request.operationId ?? crypto.randomUUID()
662
- });
663
- setState((current) => mergeIdentity(current, workspaceId, response.identity));
664
- return response;
665
- }),
666
- [client, mutate, workspaceId]
667
- );
668
- return {
669
- revision: visibleState.revision,
670
- identities: visibleState.identities,
671
- loading: visibleState.loading,
672
- refreshing: visibleState.refreshing,
673
- mutating: mutationCount > 0,
674
- error: visibleState.error,
675
- refresh,
676
- create,
677
- update,
678
- revisions,
679
- publish
680
- };
681
- }
682
- function emptyState2(workspaceId, loading) {
683
- return {
684
- workspaceId,
685
- revision: 0,
686
- identities: [],
687
- loading,
688
- refreshing: false,
689
- error: null
690
- };
691
- }
692
- function sortIdentities(identities) {
693
- return [...identities].sort(
694
- (left, right) => timestamp2(right.updatedAt) - timestamp2(left.updatedAt) || left.name.localeCompare(right.name)
695
- );
696
- }
697
- function timestamp2(value) {
698
- const parsed = Date.parse(value);
699
- return Number.isFinite(parsed) ? parsed : 0;
700
- }
701
- function mergeIdentity(current, workspaceId, identity, includeArchived = false) {
702
- if (current.workspaceId !== workspaceId) return current;
703
- return {
704
- ...current,
705
- identities: sortIdentities(
706
- identity.status === "archived" && !includeArchived ? current.identities.filter((candidate) => candidate.id !== identity.id) : [...current.identities.filter((candidate) => candidate.id !== identity.id), identity]
707
- ),
708
- error: null
709
- };
710
- }
711
-
712
- // src/hooks/use-browser-downloads.ts
713
- import { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
714
- function useBrowserDownloads(options) {
715
- const { client, workspaceId } = useEmbeddedBrowserInteraction(options);
716
- const browserSessionId = options.browserSessionId;
717
- const enabled = (options.enabled ?? true) && browserSessionId !== null;
718
- const pageLive = usePageLiveActivity();
719
- const pollIntervalMs = Math.max(750, options.pollIntervalMs ?? 2e3);
720
- const scope = browserSessionId ?? "none";
721
- const [state, setState] = useState4(() => emptyState3(scope, enabled));
722
- const [saving, setSaving] = useState4({});
723
- const visible = state.scope === scope ? state : emptyState3(scope, enabled);
724
- const requestRef = useRef4({
725
- id: 0,
726
- controller: null
727
- });
728
- const mountedRef = useRef4(true);
729
- const retryOperationsRef = useRef4(/* @__PURE__ */ new Map());
730
- const cancelLoad = useCallback4(() => {
731
- requestRef.current.controller?.abort();
732
- requestRef.current = { id: requestRef.current.id + 1, controller: null };
733
- }, []);
734
- const load = useCallback4(
735
- async (foreground) => {
736
- if (!enabled || !browserSessionId) return;
737
- const id = requestRef.current.id + 1;
738
- requestRef.current.controller?.abort();
739
- const controller = new AbortController();
740
- requestRef.current = { id, controller };
741
- setState((current) => ({
742
- ...current.scope === scope ? current : emptyState3(scope, true),
743
- loading: foreground,
744
- refreshing: !foreground,
745
- error: foreground || current.scope !== scope ? null : current.error
746
- }));
747
- try {
748
- const response = await client.listBrowserDownloads(workspaceId, browserSessionId, {
749
- signal: controller.signal
750
- });
751
- if (!mountedRef.current || requestRef.current.id !== id) return;
752
- setState({
753
- scope,
754
- downloads: sortDownloads(response.downloads),
755
- loading: false,
756
- refreshing: false,
757
- error: null
758
- });
759
- } catch (cause) {
760
- if (controller.signal.aborted || !mountedRef.current || requestRef.current.id !== id)
761
- return;
762
- setState((current) => ({
763
- ...current.scope === scope ? current : emptyState3(scope, true),
764
- loading: false,
765
- refreshing: false,
766
- error: asError(cause)
767
- }));
768
- } finally {
769
- if (requestRef.current.id === id) requestRef.current = { id, controller: null };
770
- }
771
- },
772
- [browserSessionId, client, enabled, scope, workspaceId]
773
- );
774
- const refresh = useCallback4(async () => await load(false), [load]);
775
- useEffect4(() => {
776
- retryOperationsRef.current.clear();
777
- setSaving({});
778
- }, [scope]);
779
- useEffect4(() => {
780
- mountedRef.current = true;
781
- if (!enabled) {
782
- cancelLoad();
783
- setState(emptyState3(scope, false));
784
- return () => {
785
- mountedRef.current = false;
786
- cancelLoad();
787
- };
788
- }
789
- void load(true);
790
- return () => {
791
- mountedRef.current = false;
792
- cancelLoad();
793
- };
794
- }, [cancelLoad, enabled, load, scope]);
795
- useEffect4(() => {
796
- if (!enabled || !pageLive || Object.keys(saving).length > 0) return;
797
- const timer = setInterval(() => {
798
- if (!requestRef.current.controller) void refresh();
799
- }, pollIntervalMs);
800
- return () => clearInterval(timer);
801
- }, [enabled, pageLive, pollIntervalMs, refresh, saving]);
802
- const saveToWorkspace = useCallback4(
803
- async (downloadId, destinationPath, saveOptions = {}) => {
804
- if (!browserSessionId) throw new Error("No BrowserSession is selected.");
805
- const overwrite = saveOptions.overwrite ?? false;
806
- const attemptKey = `${browserSessionId}\0${downloadId}\0${destinationPath}\0${overwrite}`;
807
- const operationId = saveOptions.operationId ?? retryOperationsRef.current.get(attemptKey) ?? crypto.randomUUID();
808
- retryOperationsRef.current.set(attemptKey, operationId);
809
- setSaving((current) => ({ ...current, [downloadId]: (current[downloadId] ?? 0) + 1 }));
810
- try {
811
- const response = await client.saveBrowserDownload(
812
- workspaceId,
813
- browserSessionId,
814
- downloadId,
815
- { operationId, destinationPath, overwrite }
816
- );
817
- retryOperationsRef.current.delete(attemptKey);
818
- if (mountedRef.current) {
819
- setState(
820
- (current) => current.scope === scope ? {
821
- ...current,
822
- downloads: sortDownloads([
823
- ...current.downloads.filter((download) => download.id !== response.download.id),
824
- response.download
825
- ]),
826
- error: null
827
- } : current
828
- );
829
- }
830
- return response;
831
- } finally {
832
- if (mountedRef.current) {
833
- setSaving((current) => {
834
- const count = (current[downloadId] ?? 1) - 1;
835
- if (count > 0) return { ...current, [downloadId]: count };
836
- const { [downloadId]: _removed, ...rest } = current;
837
- return rest;
838
- });
839
- }
840
- }
841
- },
842
- [browserSessionId, client, scope, workspaceId]
843
- );
844
- return {
845
- downloads: visible.downloads,
846
- loading: visible.loading,
847
- refreshing: visible.refreshing,
848
- savingDownloadIds: Object.keys(saving),
849
- error: visible.error,
850
- refresh,
851
- saveToWorkspace
852
- };
853
- }
854
- function emptyState3(scope, loading) {
855
- return {
856
- scope,
857
- downloads: [],
858
- loading,
859
- refreshing: false,
860
- error: null
861
- };
862
- }
863
- function sortDownloads(downloads) {
864
- return [...downloads].sort(
865
- (left, right) => right.startedAt.localeCompare(left.startedAt) || left.id.localeCompare(right.id)
866
- );
867
- }
868
- function asError(cause) {
869
- return cause instanceof Error ? cause : new Error(String(cause));
870
- }
871
-
872
- // src/hooks/use-browser-session.ts
873
- import { OpenGeniApiError } from "@opengeni/sdk";
874
- import { useCallback as useCallback5, useEffect as useEffect5, useRef as useRef5, useState as useState5 } from "react";
875
- function useBrowserSession(options) {
876
- const t = useOpenGeniText();
877
- const { client, workspaceId } = useEmbeddedBrowserInteraction(options);
878
- const browserSessionId = options.browserSessionId;
879
- const enabled = (options.enabled ?? true) && browserSessionId !== null;
880
- const sourceRef = useRef5({ client, workspaceId, browserSessionId, enabled });
881
- if (sourceRef.current.client !== client || sourceRef.current.workspaceId !== workspaceId || sourceRef.current.browserSessionId !== browserSessionId || sourceRef.current.enabled !== enabled) {
882
- sourceRef.current = { client, workspaceId, browserSessionId, enabled };
883
- }
884
- const source = sourceRef.current;
885
- const semanticObservationEnabled = options.semanticObservationEnabled ?? true;
886
- const semanticObservationEnabledRef = useRef5(semanticObservationEnabled);
887
- semanticObservationEnabledRef.current = semanticObservationEnabled;
888
- const previousSemanticObservationRef = useRef5({
889
- browserSessionId,
890
- enabled: semanticObservationEnabled
891
- });
892
- const pageLive = usePageLiveActivity();
893
- const pollIntervalMs = Math.max(750, options.pollIntervalMs ?? 2e3);
894
- const refusedObservationPageRef = useRef5(null);
895
- const [state, setState] = useState5(() => ({ ...emptyState4(browserSessionId, enabled), source }));
896
- const visible = state.source === source && state.browserSessionId === browserSessionId ? state : { ...emptyState4(browserSessionId, enabled), source };
897
- const refreshBlocked = isNonRetryableInteractionError(visible.error);
898
- const inputFailureRef = useRef5(visible.inputFailure);
899
- inputFailureRef.current = visible.inputFailure;
900
- const selectedTargetIdRef = useRef5(visible.selectedTargetId);
901
- selectedTargetIdRef.current = visible.selectedTargetId;
902
- const selectionRevisionRef = useRef5(0);
903
- const actionResultOrderRef = useRef5({ next: 0, settled: 0 });
904
- const selectedTargetRef = useRef5(
905
- visible.targets.find((target) => target.id === visible.selectedTargetId) ?? null
906
- );
907
- selectedTargetRef.current = visible.targets.find((target) => target.id === visible.selectedTargetId) ?? null;
908
- const observationRef = useRef5({ browserSessionId, observation: visible.observation });
909
- const lastObservationAtRef = useRef5(0);
910
- if (observationRef.current.browserSessionId !== browserSessionId) {
911
- observationRef.current = {
912
- browserSessionId,
913
- observation: visible.observation
914
- };
915
- } else {
916
- observationRef.current.observation = visible.observation;
917
- }
918
- const requestRef = useRef5({
919
- id: 0,
920
- controller: null
921
- });
922
- const mutationRef = useRef5({
923
- browserSessionId,
924
- source,
925
- count: 0,
926
- needsInventoryReconcile: false
927
- });
928
- const mountedRef = useRef5(true);
929
- const isCurrentSource = useCallback5(
930
- () => mountedRef.current && sourceRef.current === source,
931
- [source]
932
- );
933
- const invalidateRefresh = useCallback5(() => {
934
- const id = requestRef.current.id + 1;
935
- requestRef.current.controller?.abort();
936
- requestRef.current = { id, controller: null };
937
- }, []);
938
- const refreshInventory = useCallback5(
939
- async (checkInput = false, observeSelectedTarget = true) => {
940
- if (!enabled || !browserSessionId || !isCurrentSource()) return;
941
- const checkedInputFailure = inputFailureRef.current;
942
- const id = requestRef.current.id + 1;
943
- requestRef.current.controller?.abort();
944
- const controller = new AbortController();
945
- requestRef.current = { id, controller };
946
- try {
947
- const [session, targetResponse] = await Promise.all([
948
- client.getBrowserSession(workspaceId, browserSessionId, {
949
- signal: controller.signal
950
- }),
951
- client.listBrowserTargets(workspaceId, browserSessionId, {
952
- signal: controller.signal
953
- })
954
- ]);
955
- if (!isCurrentSource() || requestRef.current.id !== id) return;
956
- const selected = chooseTarget(targetResponse.targets, selectedTargetIdRef.current);
957
- selectedTargetIdRef.current = selected?.id ?? null;
958
- selectedTargetRef.current = selected;
959
- const previousObservation = observationRef.current.browserSessionId === browserSessionId ? observationRef.current.observation : null;
960
- const retainedObservation = selected && previousObservation && sameObservationTarget(previousObservation, selected) ? previousObservation : null;
961
- observationRef.current = {
962
- browserSessionId,
963
- observation: retainedObservation
964
- };
965
- setState(
966
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === browserSessionId ? {
967
- ...current,
968
- session,
969
- targets: targetResponse.targets,
970
- selectedTargetId: selected?.id ?? null,
971
- observation: retainedObservation,
972
- loading: false,
973
- error: null,
974
- // Media and background polling cannot confirm an input outcome.
975
- // Only an explicit fresh check clears the notice it began with.
976
- inputFailure: checkInput && session.id === browserSessionId && targetResponse.browserSessionId === browserSessionId && current.inputFailure === checkedInputFailure ? null : current.inputFailure
977
- } : current
978
- );
979
- if (!selected || !observeSelectedTarget || !semanticObservationEnabledRef.current || refusedObservationPageRef.current === observedPageKey(selected))
980
- return;
981
- try {
982
- const observation = await client.observeBrowserTarget(
983
- workspaceId,
984
- browserSessionId,
985
- selected.id,
986
- { signal: controller.signal }
987
- );
988
- if (!isCurrentSource() || requestRef.current.id !== id) return;
989
- const currentSelected = selectedTargetRef.current;
990
- if (observationRef.current.browserSessionId !== browserSessionId || currentSelected?.id !== selected.id || observation.browserSessionId !== browserSessionId || observation.target.id !== selected.id || observation.target.controllerGeneration !== currentSelected.controllerGeneration || observation.target.targetGeneration !== currentSelected.targetGeneration)
991
- return;
992
- selectedTargetRef.current = observation.target;
993
- observationRef.current = { browserSessionId, observation };
994
- lastObservationAtRef.current = Date.now();
995
- setState(
996
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === browserSessionId && current.selectedTargetId === observation.target.id ? {
997
- ...current,
998
- observation,
999
- targets: replaceTarget(current.targets, observation.target)
1000
- } : current
1001
- );
1002
- } catch (cause) {
1003
- if (controller.signal.aborted || !isCurrentSource() || requestRef.current.id !== id)
1004
- return;
1005
- if (isFinalObservationRefusal(cause))
1006
- refusedObservationPageRef.current = observedPageKey(selected);
1007
- }
1008
- } catch (cause) {
1009
- if (controller.signal.aborted || !isCurrentSource() || requestRef.current.id !== id) return;
1010
- setState(
1011
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === browserSessionId ? {
1012
- ...current,
1013
- loading: false,
1014
- error: cause instanceof Error ? cause : new Error(String(cause))
1015
- } : current
1016
- );
1017
- } finally {
1018
- if (requestRef.current.id === id) {
1019
- requestRef.current = { id, controller: null };
1020
- }
1021
- }
1022
- },
1023
- [browserSessionId, client, enabled, isCurrentSource, source, workspaceId]
1024
- );
1025
- const refresh = useCallback5(async () => await refreshInventory(true), [refreshInventory]);
1026
- const refreshSemantic = useCallback5(async () => {
1027
- if (!enabled || !browserSessionId || !isCurrentSource()) return;
1028
- const target = selectedTargetRef.current;
1029
- if (!target || refusedObservationPageRef.current === observedPageKey(target)) return;
1030
- const id = requestRef.current.id + 1;
1031
- requestRef.current.controller?.abort();
1032
- const controller = new AbortController();
1033
- requestRef.current = { id, controller };
1034
- try {
1035
- const observation = await client.observeBrowserTarget(
1036
- workspaceId,
1037
- browserSessionId,
1038
- target.id,
1039
- { signal: controller.signal }
1040
- );
1041
- if (!isCurrentSource() || requestRef.current.id !== id) return;
1042
- if (!sameObservationTarget(observation, selectedTargetRef.current)) return;
1043
- observationRef.current = { browserSessionId, observation };
1044
- lastObservationAtRef.current = Date.now();
1045
- setState(
1046
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === browserSessionId && current.selectedTargetId === target.id ? { ...current, observation } : current
1047
- );
1048
- } catch (cause) {
1049
- if (isFinalObservationRefusal(cause) && requestRef.current.id === id)
1050
- refusedObservationPageRef.current = observedPageKey(target);
1051
- } finally {
1052
- if (requestRef.current.id === id) requestRef.current = { id, controller: null };
1053
- }
1054
- }, [browserSessionId, client, enabled, isCurrentSource, source, workspaceId]);
1055
- useEffect5(() => {
1056
- mountedRef.current = true;
1057
- if (!enabled) {
1058
- invalidateRefresh();
1059
- setState({ ...emptyState4(browserSessionId, false), source });
1060
- return;
1061
- }
1062
- setState(
1063
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === browserSessionId ? { ...current, loading: true } : { ...emptyState4(browserSessionId, true), source }
1064
- );
1065
- void refreshInventory();
1066
- return () => {
1067
- mountedRef.current = false;
1068
- invalidateRefresh();
1069
- };
1070
- }, [browserSessionId, enabled, invalidateRefresh, isCurrentSource, refreshInventory, source]);
1071
- useEffect5(() => {
1072
- const previous = previousSemanticObservationRef.current;
1073
- previousSemanticObservationRef.current = {
1074
- browserSessionId,
1075
- enabled: semanticObservationEnabled
1076
- };
1077
- if (enabled && semanticObservationEnabled && previous.browserSessionId === browserSessionId && !previous.enabled) {
1078
- const currentObservation = observationRef.current.observation;
1079
- if (currentObservation && sameObservationTarget(currentObservation, selectedTargetRef.current) && Date.now() - lastObservationAtRef.current < pollIntervalMs) {
1080
- return;
1081
- }
1082
- observationRef.current = { browserSessionId, observation: null };
1083
- setState(
1084
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === browserSessionId ? { ...current, observation: null } : current
1085
- );
1086
- void refreshSemantic();
1087
- }
1088
- }, [
1089
- browserSessionId,
1090
- enabled,
1091
- isCurrentSource,
1092
- pollIntervalMs,
1093
- refreshSemantic,
1094
- semanticObservationEnabled,
1095
- source
1096
- ]);
1097
- useEffect5(() => {
1098
- if (!enabled || !pageLive || visible.mutating || refreshBlocked) return;
1099
- const timer = setInterval(() => {
1100
- if (!requestRef.current.controller) void refreshInventory();
1101
- }, pollIntervalMs);
1102
- return () => clearInterval(timer);
1103
- }, [enabled, pageLive, pollIntervalMs, refreshInventory, refreshBlocked, visible.mutating]);
1104
- useEffect5(() => {
1105
- if (!enabled || !browserSessionId || !pageLive || refreshBlocked) return;
1106
- let disposed = false;
1107
- const heartbeat = () => {
1108
- if (!isCurrentSource()) return;
1109
- void client.heartbeatBrowserSession(workspaceId, browserSessionId).catch(() => {
1110
- if (!disposed) void refreshInventory();
1111
- });
1112
- };
1113
- const timer = setInterval(heartbeat, 3e4);
1114
- return () => {
1115
- disposed = true;
1116
- clearInterval(timer);
1117
- };
1118
- }, [
1119
- browserSessionId,
1120
- client,
1121
- enabled,
1122
- isCurrentSource,
1123
- pageLive,
1124
- refreshInventory,
1125
- refreshBlocked,
1126
- workspaceId
1127
- ]);
1128
- const runMutation = useCallback5(
1129
- async (scopeBrowserSessionId, operation, selectionRead = false, changesInventory = false) => {
1130
- if (!enabled || !isCurrentSource()) {
1131
- throw new Error(t("hooks.useBrowserSession.theBrowserSourceIsNo"));
1132
- }
1133
- const selectionRevision = ++selectionRevisionRef.current;
1134
- invalidateRefresh();
1135
- const readRequestId = requestRef.current.id;
1136
- if (mutationRef.current.browserSessionId !== scopeBrowserSessionId || mutationRef.current.source !== source) {
1137
- mutationRef.current = {
1138
- browserSessionId: scopeBrowserSessionId,
1139
- source,
1140
- count: 0,
1141
- needsInventoryReconcile: false
1142
- };
1143
- }
1144
- mutationRef.current.count += 1;
1145
- setState(
1146
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === scopeBrowserSessionId ? { ...current, mutating: true, error: null } : current
1147
- );
1148
- try {
1149
- return await operation(selectionRevision, readRequestId);
1150
- } catch (cause) {
1151
- const error = cause instanceof Error ? cause : new Error(String(cause));
1152
- if (!selectionRead || requestRef.current.id === readRequestId) {
1153
- setState(
1154
- (current) => isCurrentSource() && selectionRevisionRef.current === selectionRevision && current.source === source && current.browserSessionId === scopeBrowserSessionId ? { ...current, error } : current
1155
- );
1156
- }
1157
- throw error;
1158
- } finally {
1159
- if (mutationRef.current.browserSessionId === scopeBrowserSessionId && mutationRef.current.source === source) {
1160
- if (changesInventory && (selectionRevisionRef.current !== selectionRevision || requestRef.current.id !== readRequestId)) {
1161
- mutationRef.current.needsInventoryReconcile = true;
1162
- }
1163
- mutationRef.current.count = Math.max(0, mutationRef.current.count - 1);
1164
- const mutating = mutationRef.current.count > 0;
1165
- setState(
1166
- (current) => isCurrentSource() && current.source === source && current.browserSessionId === scopeBrowserSessionId ? { ...current, mutating } : current
1167
- );
1168
- if (!mutating && mutationRef.current.needsInventoryReconcile && isCurrentSource()) {
1169
- mutationRef.current.needsInventoryReconcile = false;
1170
- void refreshInventory(false, false);
1171
- }
1172
- }
1173
- }
1174
- },
1175
- [enabled, invalidateRefresh, isCurrentSource, refreshInventory, source, t]
1176
- );
1177
- const selectTarget = useCallback5(
1178
- async (targetId) => {
1179
- if (!browserSessionId) throw new Error("No BrowserSession is selected.");
1180
- return await runMutation(
1181
- browserSessionId,
1182
- async (selectionRevision, readRequestId) => {
1183
- const isCurrentSelection = () => isCurrentSource() && selectionRevisionRef.current === selectionRevision;
1184
- const isCurrentSelectionRead = () => isCurrentSelection() && requestRef.current.id === readRequestId;
1185
- let targets = visible.targets;
1186
- let target;
1187
- let observation;
1188
- try {
1189
- observation = await client.selectBrowserTarget(workspaceId, browserSessionId, targetId);
1190
- target = observation.target;
1191
- } catch (cause) {
1192
- if (!isCurrentSelectionRead() || !isMissingBrowserTarget(cause)) throw cause;
1193
- const response = await client.listBrowserTargets(workspaceId, browserSessionId);
1194
- if (!isCurrentSelectionRead()) throw cause;
1195
- targets = response.targets;
1196
- const fallback = chooseTarget(targets, null);
1197
- if (!fallback) {
1198
- selectedTargetIdRef.current = null;
1199
- selectedTargetRef.current = null;
1200
- observationRef.current = { browserSessionId, observation: null };
1201
- setState(
1202
- (current) => isCurrentSelection() && current.source === source && current.browserSessionId === browserSessionId ? {
1203
- ...current,
1204
- targets,
1205
- selectedTargetId: null,
1206
- observation: null
1207
- } : current
1208
- );
1209
- throw cause;
1210
- }
1211
- observation = await client.selectBrowserTarget(
1212
- workspaceId,
1213
- browserSessionId,
1214
- fallback.id
1215
- );
1216
- target = observation.target;
1217
- }
1218
- if (!isCurrentSelectionRead()) return target;
1219
- selectedTargetIdRef.current = target.id;
1220
- selectedTargetRef.current = target;
1221
- observationRef.current = { browserSessionId, observation };
1222
- lastObservationAtRef.current = Date.now();
1223
- setState(
1224
- (current) => isCurrentSelection() && current.source === source && current.browserSessionId === browserSessionId ? {
1225
- ...current,
1226
- targets: replaceTarget(targets, target).map((candidate) => ({
1227
- ...candidate,
1228
- selected: candidate.id === target.id
1229
- })),
1230
- selectedTargetId: target.id,
1231
- observation
1232
- } : current
1233
- );
1234
- return target;
1235
- },
1236
- true
1237
- );
1238
- },
1239
- [browserSessionId, client, isCurrentSource, runMutation, source, visible.targets, workspaceId]
1240
- );
1241
- const openTarget = useCallback5(
1242
- async (url) => {
1243
- if (!browserSessionId) throw new Error("No BrowserSession is selected.");
1244
- return await runMutation(
1245
- browserSessionId,
1246
- async (selectionRevision, readRequestId) => {
1247
- const isCurrentSelection = () => isCurrentSource() && selectionRevisionRef.current === selectionRevision;
1248
- const isCurrentSelectionRead = () => isCurrentSelection() && requestRef.current.id === readRequestId;
1249
- const observation = await client.openBrowserTarget(
1250
- workspaceId,
1251
- browserSessionId,
1252
- url === void 0 ? {} : { url }
1253
- );
1254
- const target = observation.target;
1255
- if (!isCurrentSource()) return target;
1256
- if (!isCurrentSelectionRead()) return target;
1257
- selectedTargetIdRef.current = target.id;
1258
- selectedTargetRef.current = target;
1259
- observationRef.current = { browserSessionId, observation };
1260
- lastObservationAtRef.current = Date.now();
1261
- setState(
1262
- (current) => isCurrentSelection() && current.source === source && current.browserSessionId === browserSessionId ? {
1263
- ...current,
1264
- targets: [
1265
- ...current.targets.map((candidate) => ({
1266
- ...candidate,
1267
- selected: false
1268
- })),
1269
- target
1270
- ],
1271
- selectedTargetId: target.id,
1272
- observation
1273
- } : current
1274
- );
1275
- return target;
1276
- },
1277
- false,
1278
- true
1279
- );
1280
- },
1281
- [browserSessionId, client, isCurrentSource, runMutation, source, workspaceId]
1282
- );
1283
- const closeTarget = useCallback5(
1284
- async (targetId) => {
1285
- if (!browserSessionId) throw new Error("No BrowserSession is selected.");
1286
- await runMutation(
1287
- browserSessionId,
1288
- async (selectionRevision, readRequestId) => {
1289
- const isCurrentSelection = () => isCurrentSource() && selectionRevisionRef.current === selectionRevision;
1290
- const isCurrentSelectionRead = () => isCurrentSelection() && requestRef.current.id === readRequestId;
1291
- const response = await client.closeBrowserTarget(workspaceId, browserSessionId, targetId);
1292
- if (!isCurrentSource()) return;
1293
- if (!isCurrentSelectionRead()) return;
1294
- const selected = chooseTarget(response.targets, selectedTargetIdRef.current);
1295
- const observed = selected ? await client.observeBrowserTarget(workspaceId, browserSessionId, selected.id) : null;
1296
- if (!isCurrentSource()) return;
1297
- if (!isCurrentSelectionRead()) return;
1298
- const observation = observed && selected && observed.browserSessionId === browserSessionId && observed.target.id === selected.id && observed.target.controllerGeneration === selected.controllerGeneration && observed.target.targetGeneration === selected.targetGeneration ? observed : null;
1299
- const currentTarget = observation?.target ?? selected;
1300
- selectedTargetIdRef.current = currentTarget?.id ?? null;
1301
- selectedTargetRef.current = currentTarget;
1302
- observationRef.current = { browserSessionId, observation };
1303
- if (observation) lastObservationAtRef.current = Date.now();
1304
- setState(
1305
- (current) => isCurrentSelection() && current.source === source && current.browserSessionId === browserSessionId ? {
1306
- ...current,
1307
- targets: currentTarget ? replaceTarget(response.targets, currentTarget) : response.targets,
1308
- selectedTargetId: currentTarget?.id ?? null,
1309
- observation
1310
- } : current
1311
- );
1312
- },
1313
- false,
1314
- true
1315
- );
1316
- },
1317
- [browserSessionId, client, isCurrentSource, runMutation, source, workspaceId]
1318
- );
1319
- const dispatchAction = useCallback5(
1320
- async (action, operationId, frame, observationMode = "none") => {
1321
- if (!browserSessionId) throw new Error("No BrowserSession is selected.");
1322
- if (!enabled || !isCurrentSource()) {
1323
- throw new Error(t("hooks.useBrowserSession.theBrowserSourceIsNo"));
1324
- }
1325
- if (!selectedTargetRef.current) {
1326
- throw new Error("The browser page is not ready for input.");
1327
- }
1328
- if (frame && frame.browserSessionId !== browserSessionId) {
1329
- throw new Error("The displayed browser frame belongs to another BrowserSession.");
1330
- }
1331
- const currentObservation = observationRef.current.browserSessionId === browserSessionId ? observationRef.current.observation : null;
1332
- const fence = frame ? {
1333
- targetId: frame.targetId,
1334
- expectedTargetGeneration: frame.targetGeneration,
1335
- expectedDocumentGeneration: frame.documentGeneration,
1336
- expectedFrameId: frame.frameId
1337
- } : currentObservation && sameObservationTarget(currentObservation, selectedTargetRef.current) ? {
1338
- targetId: currentObservation.target.id,
1339
- expectedTargetGeneration: currentObservation.target.targetGeneration,
1340
- expectedDocumentGeneration: currentObservation.target.documentGeneration,
1341
- expectedFrameId: currentObservation.frameId
1342
- } : null;
1343
- if (!fence) {
1344
- throw new Error("The browser page is not ready for input.");
1345
- }
1346
- const expectedControllerGeneration = frame?.controllerGeneration ?? currentObservation.target.controllerGeneration;
1347
- const selectionRevision = selectionRevisionRef.current;
1348
- const resultOrder = ++actionResultOrderRef.current.next;
1349
- let resultDocumentGeneration = fence.expectedDocumentGeneration;
1350
- const isCurrentResultView = () => {
1351
- const selected = selectedTargetRef.current;
1352
- return isCurrentSource() && selectionRevisionRef.current === selectionRevision && selected?.browserSessionId === browserSessionId && selected.id === fence.targetId && selected.controllerGeneration === expectedControllerGeneration && selected.targetGeneration === fence.expectedTargetGeneration && (selected.documentGeneration === fence.expectedDocumentGeneration || selected.documentGeneration === resultDocumentGeneration);
1353
- };
1354
- const canProjectResult = () => isCurrentResultView() && resultOrder >= actionResultOrderRef.current.settled;
1355
- const settleResult = () => {
1356
- if (!canProjectResult()) return false;
1357
- actionResultOrderRef.current.settled = resultOrder;
1358
- invalidateRefresh();
1359
- return true;
1360
- };
1361
- try {
1362
- const receipt = await client.actInBrowser(workspaceId, browserSessionId, {
1363
- operationId,
1364
- ...fence,
1365
- observationMode,
1366
- action
1367
- });
1368
- resultDocumentGeneration = receipt.observation?.target.documentGeneration ?? fence.expectedDocumentGeneration;
1369
- const settled = receipt.state === "completed" || receipt.state === "failed" || receipt.state === "outcome_unknown";
1370
- if (!canProjectResult() || settled && !settleResult()) return receipt;
1371
- const receivedObservation = receipt.observation;
1372
- const selectedTarget = selectedTargetRef.current;
1373
- let projectedObservation = null;
1374
- if (settled && receivedObservation && canProjectResult() && receipt.browserSessionId === browserSessionId && receipt.controllerGeneration === expectedControllerGeneration && receipt.targetId === fence.targetId && observationRef.current.browserSessionId === browserSessionId && receivedObservation.browserSessionId === browserSessionId && selectedTarget?.browserSessionId === browserSessionId && selectedTarget.id === fence.targetId && receivedObservation.target.id === fence.targetId && selectedTarget.controllerGeneration === expectedControllerGeneration && receivedObservation.target.controllerGeneration === expectedControllerGeneration && selectedTarget.targetGeneration === fence.expectedTargetGeneration && receivedObservation.target.targetGeneration === fence.expectedTargetGeneration && (selectedTarget.documentGeneration === fence.expectedDocumentGeneration || selectedTarget.documentGeneration === receivedObservation.target.documentGeneration)) {
1375
- projectedObservation = receivedObservation;
1376
- observationRef.current = {
1377
- browserSessionId,
1378
- observation: receivedObservation
1379
- };
1380
- selectedTargetRef.current = receivedObservation.target;
1381
- lastObservationAtRef.current = Date.now();
1382
- }
1383
- setState(
1384
- (current) => isCurrentResultView() && current.source === source && current.browserSessionId === browserSessionId && current.actionResultOrder <= resultOrder ? {
1385
- ...current,
1386
- actionResultOrder: settled ? resultOrder : current.actionResultOrder,
1387
- error: receipt.state === "completed" ? null : current.error,
1388
- inputFailure: receipt.state === "completed" ? current.inputFailure : {
1389
- operationId: receipt.operationId,
1390
- state: receipt.state,
1391
- error: receipt.error
1392
- },
1393
- ...projectedObservation ? {
1394
- observation: projectedObservation,
1395
- targets: replaceTarget(current.targets, projectedObservation.target)
1396
- } : {}
1397
- } : current
1398
- );
1399
- return receipt;
1400
- } catch (cause) {
1401
- const error = cause instanceof Error ? cause : new Error(String(cause));
1402
- if (settleResult()) {
1403
- setState(
1404
- (current) => isCurrentResultView() && current.source === source && current.browserSessionId === browserSessionId && current.actionResultOrder <= resultOrder ? { ...current, error, actionResultOrder: resultOrder } : current
1405
- );
1406
- }
1407
- throw error;
1408
- }
1409
- },
1410
- [browserSessionId, client, enabled, invalidateRefresh, isCurrentSource, source, workspaceId, t]
1411
- );
1412
- const act = useCallback5(
1413
- async (action, operationId = crypto.randomUUID()) => await dispatchAction(action, operationId, null),
1414
- [dispatchAction]
1415
- );
1416
- const actFromFrame = useCallback5(
1417
- async (action, frame, operationId = crypto.randomUUID(), observationMode = "none") => await dispatchAction(action, operationId, frame, observationMode),
1418
- [dispatchAction]
1419
- );
1420
- const observeForInput = useCallback5(async () => {
1421
- const target = selectedTargetRef.current;
1422
- if (!enabled || !isCurrentSource()) {
1423
- throw new Error(t("hooks.useBrowserSession.theBrowserSourceIsNo"));
1424
- }
1425
- if (!browserSessionId || !target)
1426
- throw new Error(t("hooks.useBrowserSession.noBrowserTabIsSelected"));
1427
- const observation = await client.observeBrowserTarget(workspaceId, browserSessionId, target.id);
1428
- if (!isCurrentSource() || observation.browserSessionId !== browserSessionId || !sameObservationTarget(observation, selectedTargetRef.current)) {
1429
- throw new Error(t("hooks.useBrowserSession.theBrowserPageChangedOpen"));
1430
- }
1431
- refusedObservationPageRef.current = null;
1432
- return observation;
1433
- }, [browserSessionId, client, enabled, isCurrentSource, workspaceId, t]);
1434
- const actFromObservation = useCallback5(
1435
- async (action, observation) => {
1436
- if (!sameObservationTarget(observation, selectedTargetRef.current)) {
1437
- throw new Error(t("hooks.useBrowserSession.theBrowserPageChangedOpen"));
1438
- }
1439
- return await dispatchAction(action, crypto.randomUUID(), {
1440
- browserSessionId: observation.browserSessionId,
1441
- controllerGeneration: observation.target.controllerGeneration,
1442
- targetId: observation.target.id,
1443
- targetGeneration: observation.target.targetGeneration,
1444
- documentGeneration: observation.target.documentGeneration,
1445
- frameId: observation.frameId
1446
- });
1447
- },
1448
- [dispatchAction, t]
1449
- );
1450
- const diagnostics = useCallback5(
1451
- async (diagnosticOptions = {}) => {
1452
- if (!enabled || !isCurrentSource()) {
1453
- throw new Error(t("hooks.useBrowserSession.theBrowserSourceIsNo"));
1454
- }
1455
- const targetId = selectedTargetIdRef.current;
1456
- if (!browserSessionId || !targetId) {
1457
- throw new Error(t("hooks.useBrowserSession.noBrowserTabIsSelected"));
1458
- }
1459
- return await client.listBrowserDiagnostics(
1460
- workspaceId,
1461
- browserSessionId,
1462
- targetId,
1463
- diagnosticOptions
1464
- );
1465
- },
1466
- [browserSessionId, client, enabled, isCurrentSource, workspaceId, t]
1467
- );
1468
- const readClipboard = useCallback5(async () => {
1469
- if (!enabled || !isCurrentSource()) {
1470
- throw new Error(t("hooks.useBrowserSession.theBrowserSourceIsNo"));
1471
- }
1472
- if (!browserSessionId) throw new Error("No BrowserSession is selected.");
1473
- const clipboard = await client.readBrowserClipboard(workspaceId, browserSessionId);
1474
- if (!isCurrentSource() || clipboard.browserSessionId !== browserSessionId) {
1475
- throw new Error("Browser clipboard belongs to another BrowserSession.");
1476
- }
1477
- return clipboard;
1478
- }, [browserSessionId, client, enabled, isCurrentSource, workspaceId, t]);
1479
- return {
1480
- session: visible.session,
1481
- targets: visible.targets,
1482
- selectedTarget: visible.targets.find((target) => target.id === visible.selectedTargetId) ?? null,
1483
- observation: visible.observation,
1484
- loading: visible.loading,
1485
- mutating: visible.mutating,
1486
- error: visible.error,
1487
- inputFailure: visible.inputFailure,
1488
- refresh,
1489
- observeForInput,
1490
- actFromObservation,
1491
- selectTarget,
1492
- openTarget,
1493
- closeTarget,
1494
- act,
1495
- actFromFrame,
1496
- readClipboard,
1497
- diagnostics
1498
- };
1499
- }
1500
- function emptyState4(browserSessionId, loading) {
1501
- return {
1502
- browserSessionId,
1503
- session: null,
1504
- targets: [],
1505
- selectedTargetId: null,
1506
- observation: null,
1507
- loading,
1508
- mutating: false,
1509
- error: null,
1510
- inputFailure: null,
1511
- actionResultOrder: 0
1512
- };
1513
- }
1514
- function chooseTarget(targets, preferredId) {
1515
- return targets.find((target) => target.id === preferredId) ?? targets.find((target) => target.selected && target.kind === "page") ?? targets.find((target) => target.kind === "page") ?? targets[0] ?? null;
1516
- }
1517
- function replaceTarget(targets, target) {
1518
- const next = targets.filter((candidate) => candidate.id !== target.id);
1519
- next.push(target);
1520
- return next.sort((left, right) => left.createdAt.localeCompare(right.createdAt));
1521
- }
1522
- function sameObservationTarget(observation, target) {
1523
- return target !== null && observation.browserSessionId === target.browserSessionId && observation.target.id === target.id && observation.target.controllerGeneration === target.controllerGeneration && observation.target.targetGeneration === target.targetGeneration && observation.target.documentGeneration === target.documentGeneration;
1524
- }
1525
- function isMissingBrowserTarget(error) {
1526
- return error instanceof OpenGeniApiError && error.code === "target_not_found";
1527
- }
1528
- function observedPageKey(target) {
1529
- return JSON.stringify([
1530
- target.browserSessionId,
1531
- target.id,
1532
- target.controllerGeneration,
1533
- target.targetGeneration,
1534
- target.documentGeneration,
1535
- target.url
1536
- ]);
1537
- }
1538
- function isFinalObservationRefusal(error) {
1539
- return isNonRetryableInteractionError(error) && error.status >= 400 && error.status < 500;
1540
- }
1541
-
1542
- // src/hooks/use-browser-sessions.ts
1543
- import { useCallback as useCallback6, useEffect as useEffect6, useMemo, useRef as useRef6, useState as useState6 } from "react";
1544
- function useBrowserSessions(options = {}) {
1545
- const {
1546
- client,
1547
- workspaceId,
1548
- registerSessionReconciler,
1549
- workspaceInteractionEvent,
1550
- workspaceInteractionConnectionState
1551
- } = useEmbeddedBrowserInteraction(options);
1552
- const enabled = options.enabled ?? true;
1553
- const [state, setState] = useState6(() => emptyState5(workspaceId, enabled));
1554
- const requestRef = useRef6({
1555
- id: 0,
1556
- controller: null
1557
- });
1558
- const loadQueueRef = useRef6(null);
1559
- const mountedRef = useRef6(true);
1560
- const visibleState = state.workspaceId === workspaceId ? state : emptyState5(workspaceId, enabled);
1561
- const cancelLoad = useCallback6(() => {
1562
- loadQueueRef.current = null;
1563
- const id = requestRef.current.id + 1;
1564
- requestRef.current.controller?.abort();
1565
- requestRef.current = { id, controller: null };
1566
- }, []);
1567
- const loadOnce = useCallback6(
1568
- async (foreground) => {
1569
- if (!enabled) return;
1570
- const id = requestRef.current.id + 1;
1571
- requestRef.current.controller?.abort();
1572
- const controller = new AbortController();
1573
- requestRef.current = { id, controller };
1574
- setState((current) => ({
1575
- ...current.workspaceId === workspaceId ? current : emptyState5(workspaceId, true),
1576
- active: true,
1577
- loading: foreground,
1578
- refreshing: !foreground,
1579
- error: foreground || current.workspaceId !== workspaceId ? null : current.error
1580
- }));
1581
- try {
1582
- const response = await client.listBrowserSessions(workspaceId, {
1583
- signal: controller.signal
1584
- });
1585
- if (!mountedRef.current || requestRef.current.id !== id) return;
1586
- setState({
1587
- workspaceId,
1588
- active: true,
1589
- revision: response.revision,
1590
- sessions: sortBrowserSessions(response.sessions),
1591
- loading: false,
1592
- refreshing: false,
1593
- error: null
1594
- });
1595
- } catch (cause) {
1596
- if (controller.signal.aborted || !mountedRef.current || requestRef.current.id !== id)
1597
- return;
1598
- const error = cause instanceof Error ? cause : new Error(String(cause));
1599
- setState((current) => ({
1600
- ...current.workspaceId === workspaceId ? current : emptyState5(workspaceId, true),
1601
- loading: false,
1602
- refreshing: false,
1603
- error
1604
- }));
1605
- } finally {
1606
- if (requestRef.current.id === id) {
1607
- requestRef.current = { id, controller: null };
1608
- }
1609
- }
1610
- },
1611
- [client, enabled, workspaceId]
1612
- );
1613
- const load = useCallback6(
1614
- (foreground) => {
1615
- const current = loadQueueRef.current;
1616
- if (current) {
1617
- current.pending = true;
1618
- return current.promise;
1619
- }
1620
- const queue = { pending: false, promise: Promise.resolve() };
1621
- loadQueueRef.current = queue;
1622
- queue.promise = Promise.resolve().then(async () => {
1623
- while (loadQueueRef.current === queue) {
1624
- queue.pending = false;
1625
- await loadOnce(foreground);
1626
- foreground = false;
1627
- if (!queue.pending) break;
1628
- }
1629
- if (loadQueueRef.current === queue) loadQueueRef.current = null;
1630
- }).finally(() => {
1631
- if (loadQueueRef.current === queue) loadQueueRef.current = null;
1632
- });
1633
- return queue.promise;
1634
- },
1635
- [loadOnce]
1636
- );
1637
- const refresh = useCallback6(async () => await load(false), [load]);
1638
- useEffect6(() => {
1639
- mountedRef.current = true;
1640
- if (!enabled) {
1641
- cancelLoad();
1642
- setState(emptyState5(workspaceId, false));
1643
- return;
1644
- }
1645
- void load(true);
1646
- return () => {
1647
- mountedRef.current = false;
1648
- cancelLoad();
1649
- };
1650
- }, [cancelLoad, enabled, load, workspaceId]);
1651
- useInteractionInvalidation({
1652
- workspaceId,
1653
- key: workspaceId,
1654
- enabled,
1655
- event: workspaceInteractionEvent,
1656
- connectionState: workspaceInteractionConnectionState,
1657
- knownRevision: visibleState.revision,
1658
- refresh,
1659
- fallbackPollIntervalMs: options.pollIntervalMs
1660
- });
1661
- useEffect6(() => {
1662
- if (!enabled || !options.sessionId) return;
1663
- return registerSessionReconciler(options.sessionId, `browser-sessions:${workspaceId}`, refresh);
1664
- }, [enabled, options.sessionId, refresh, registerSessionReconciler, workspaceId]);
1665
- const create = useCallback6(
1666
- async (request) => {
1667
- const response = await client.createBrowserSession(workspaceId, {
1668
- ...request,
1669
- operationId: request.operationId ?? crypto.randomUUID()
1670
- });
1671
- setState((current) => mergeSession(current, workspaceId, response.session));
1672
- return response;
1673
- },
1674
- [client, workspaceId]
1675
- );
1676
- const end = useCallback6(
1677
- async (browserSessionId, operationId = crypto.randomUUID()) => {
1678
- const response = await client.endBrowserSession(workspaceId, browserSessionId, {
1679
- operationId
1680
- });
1681
- setState((current) => mergeSession(current, workspaceId, response.session));
1682
- return response;
1683
- },
1684
- [client, workspaceId]
1685
- );
1686
- const suspend = useCallback6(
1687
- async (browserSessionId, operationId = crypto.randomUUID()) => {
1688
- const response = await client.suspendBrowserSession(workspaceId, browserSessionId, {
1689
- operationId
1690
- });
1691
- setState((current) => mergeSession(current, workspaceId, response.session));
1692
- return response;
1693
- },
1694
- [client, workspaceId]
1695
- );
1696
- const resume = useCallback6(
1697
- async (browserSessionId, operationId = crypto.randomUUID()) => {
1698
- const response = await client.resumeBrowserSession(workspaceId, browserSessionId, {
1699
- operationId
1700
- });
1701
- setState((current) => mergeSession(current, workspaceId, response.session));
1702
- return response;
1703
- },
1704
- [client, workspaceId]
1705
- );
1706
- const relevantSessions = useMemo(
1707
- () => options.sessionId ? visibleState.sessions.filter(
1708
- (session) => session.associations.some((association) => association.sessionId === options.sessionId)
1709
- ) : [],
1710
- [options.sessionId, visibleState.sessions]
1711
- );
1712
- return {
1713
- revision: visibleState.revision,
1714
- sessions: visibleState.sessions,
1715
- relevantSessions,
1716
- // A disabled registry is deliberately empty. Expose the first re-enabled
1717
- // render as loading so consumers do not reconcile against that empty gap.
1718
- loading: enabled ? !visibleState.active || visibleState.loading : false,
1719
- refreshing: visibleState.refreshing,
1720
- error: visibleState.error,
1721
- refresh,
1722
- create,
1723
- suspend,
1724
- resume,
1725
- end
1726
- };
1727
- }
1728
- function emptyState5(workspaceId, loading) {
1729
- return {
1730
- workspaceId,
1731
- active: false,
1732
- revision: 0,
1733
- sessions: [],
1734
- loading,
1735
- refreshing: false,
1736
- error: null
1737
- };
1738
- }
1739
- function sortBrowserSessions(sessions) {
1740
- return [...sessions].sort((left, right) => {
1741
- const live = Number(isLiveBrowser(right)) - Number(isLiveBrowser(left));
1742
- return live || timestamp3(right.lastUsedAt) - timestamp3(left.lastUsedAt) || left.id.localeCompare(right.id);
1743
- });
1744
- }
1745
- function isLiveBrowser(session) {
1746
- return !["ending", "ended", "failed", "lost"].includes(session.lifecycle);
1747
- }
1748
- function timestamp3(value) {
1749
- const parsed = Date.parse(value);
1750
- return Number.isFinite(parsed) ? parsed : 0;
1751
- }
1752
- function mergeSession(current, workspaceId, session) {
1753
- if (current.workspaceId !== workspaceId) return current;
1754
- const sessions = current.sessions.filter((candidate) => candidate.id !== session.id);
1755
- sessions.push(session);
1756
- return { ...current, sessions: sortBrowserSessions(sessions), error: null };
1757
- }
1758
-
1759
- // src/hooks/use-site-auth-connections.ts
1760
- import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef7, useState as useState7 } from "react";
1761
- function useSiteAuthConnections(options = {}) {
1762
- const { client, workspaceId, workspaceInteractionEvent, workspaceInteractionConnectionState } = useEmbeddedBrowserInteraction(options);
1763
- const enabled = options.enabled ?? true;
1764
- const includeArchived = options.includeArchived ?? false;
1765
- const key = `${workspaceId}:${includeArchived ? "all" : "active"}`;
1766
- const [state, setState] = useState7(() => emptyState6(key, enabled));
1767
- const [mutationCount, setMutationCount] = useState7(0);
1768
- const requestRef = useRef7({
1769
- id: 0,
1770
- controller: null
1771
- });
1772
- const mountedRef = useRef7(true);
1773
- const visible = state.key === key ? state : emptyState6(key, enabled);
1774
- const cancelLoad = useCallback7(() => {
1775
- requestRef.current.controller?.abort();
1776
- requestRef.current = { id: requestRef.current.id + 1, controller: null };
1777
- }, []);
1778
- const load = useCallback7(
1779
- async (foreground) => {
1780
- if (!enabled) return;
1781
- const id = requestRef.current.id + 1;
1782
- requestRef.current.controller?.abort();
1783
- const controller = new AbortController();
1784
- requestRef.current = { id, controller };
1785
- setState((current) => ({
1786
- ...current.key === key ? current : emptyState6(key, true),
1787
- loading: foreground,
1788
- refreshing: !foreground,
1789
- error: foreground || current.key !== key ? null : current.error
1790
- }));
1791
- try {
1792
- const response = await client.listSiteAuthConnections(workspaceId, {
1793
- includeArchived,
1794
- signal: controller.signal
1795
- });
1796
- if (!mountedRef.current || requestRef.current.id !== id) return;
1797
- setState({
1798
- key,
1799
- revision: response.revision,
1800
- connections: sortConnections(response.connections),
1801
- loading: false,
1802
- refreshing: false,
1803
- error: null
1804
- });
1805
- } catch (cause) {
1806
- if (controller.signal.aborted || !mountedRef.current || requestRef.current.id !== id)
1807
- return;
1808
- setState((current) => ({
1809
- ...current.key === key ? current : emptyState6(key, true),
1810
- loading: false,
1811
- refreshing: false,
1812
- error: asError2(cause)
1813
- }));
1814
- } finally {
1815
- if (requestRef.current.id === id) requestRef.current = { id, controller: null };
1816
- }
1817
- },
1818
- [client, enabled, includeArchived, key, workspaceId]
1819
- );
1820
- const refresh = useCallback7(async () => await load(false), [load]);
1821
- useEffect7(() => {
1822
- mountedRef.current = true;
1823
- if (!enabled) {
1824
- cancelLoad();
1825
- setState(emptyState6(key, false));
1826
- return;
1827
- }
1828
- void load(true);
1829
- return () => {
1830
- mountedRef.current = false;
1831
- cancelLoad();
1832
- };
1833
- }, [cancelLoad, enabled, key, load]);
1834
- useInteractionInvalidation({
1835
- workspaceId,
1836
- key,
1837
- enabled,
1838
- event: workspaceInteractionEvent,
1839
- connectionState: workspaceInteractionConnectionState,
1840
- knownRevision: visible.revision,
1841
- refresh
1842
- });
1843
- const mutate = useCallback7(async (operation) => {
1844
- setMutationCount((count) => count + 1);
1845
- try {
1846
- return await operation();
1847
- } finally {
1848
- if (mountedRef.current) setMutationCount((count) => Math.max(0, count - 1));
1849
- }
1850
- }, []);
1851
- const merge = useCallback7(
1852
- (connection) => {
1853
- setState((current) => {
1854
- if (current.key !== key) return current;
1855
- const connections = current.connections.filter(
1856
- (candidate) => candidate.id !== connection.id
1857
- );
1858
- if (includeArchived || connection.status !== "archived") connections.push(connection);
1859
- return { ...current, connections: sortConnections(connections), error: null };
1860
- });
1861
- },
1862
- [includeArchived, key]
1863
- );
1864
- const create = useCallback7(
1865
- async (request) => await mutate(async () => {
1866
- const response = await client.createSiteAuthConnection(workspaceId, {
1867
- ...request,
1868
- operationId: request.operationId ?? crypto.randomUUID()
1869
- });
1870
- merge(response.connection);
1871
- return response;
1872
- }),
1873
- [client, merge, mutate, workspaceId]
1874
- );
1875
- const update = useCallback7(
1876
- async (connectionId, request) => await mutate(async () => {
1877
- const response = await client.updateSiteAuthConnection(workspaceId, connectionId, {
1878
- ...request,
1879
- operationId: request.operationId ?? crypto.randomUUID()
1880
- });
1881
- merge(response.connection);
1882
- return response;
1883
- }),
1884
- [client, merge, mutate, workspaceId]
1885
- );
1886
- return {
1887
- revision: visible.revision,
1888
- connections: visible.connections,
1889
- loading: visible.loading,
1890
- refreshing: visible.refreshing,
1891
- mutating: mutationCount > 0,
1892
- error: visible.error,
1893
- refresh,
1894
- create,
1895
- update
1896
- };
1897
- }
1898
- function emptyState6(key, loading) {
1899
- return {
1900
- key,
1901
- revision: 0,
1902
- connections: [],
1903
- loading,
1904
- refreshing: false,
1905
- error: null
1906
- };
1907
- }
1908
- function sortConnections(connections) {
1909
- return [...connections].sort(
1910
- (left, right) => Number(left.status === "archived") - Number(right.status === "archived") || left.name.localeCompare(right.name) || left.accountLabel.localeCompare(right.accountLabel)
1911
- );
1912
- }
1913
- function asError2(cause) {
1914
- return cause instanceof Error ? cause : new Error(String(cause));
1915
- }
1916
-
1917
- // src/components/browser-input.ts
1918
- var HUMAN_BROWSER_HOME_URL = "https://www.google.com/";
1919
- var HUMAN_BROWSER_SEARCH_URL = "https://www.google.com/search?q=";
1920
- function normalizeBrowserAddress(value) {
1921
- const trimmed = value.trim();
1922
- if (!trimmed) return null;
1923
- if (/^(?:https?|about):/iu.test(trimmed)) {
1924
- try {
1925
- const url = new URL(trimmed);
1926
- return ["http:", "https:", "about:"].includes(url.protocol) ? url.href : null;
1927
- } catch {
1928
- return `${HUMAN_BROWSER_SEARCH_URL}${encodeURIComponent(trimmed)}`;
1929
- }
1930
- }
1931
- const isLocal = /^(?:localhost|127(?:\.\d{1,3}){3}|\[::1\])(?::\d+)?(?:[/?#]|$)/iu.test(trimmed);
1932
- const looksLikeHost = !/\s/u.test(trimmed) && (isLocal || /^(?:[^./\s]+\.)+[^./\s]+(?::\d+)?(?:[/?#]|$)/u.test(trimmed));
1933
- if (!looksLikeHost) return `${HUMAN_BROWSER_SEARCH_URL}${encodeURIComponent(trimmed)}`;
1934
- try {
1935
- return new URL(`${isLocal ? "http" : "https"}://${trimmed}`).href;
1936
- } catch {
1937
- return `${HUMAN_BROWSER_SEARCH_URL}${encodeURIComponent(trimmed)}`;
1938
- }
1939
- }
1940
- function browserKey(event, hostPlatform = interactionHostPlatform()) {
1941
- if (["Alt", "AltGraph", "Control", "Meta", "Shift"].includes(event.key)) return null;
1942
- const special = /* @__PURE__ */ new Set([
1943
- "Enter",
1944
- "Tab",
1945
- "Escape",
1946
- "Backspace",
1947
- "Delete",
1948
- "ArrowUp",
1949
- "ArrowDown",
1950
- "ArrowLeft",
1951
- "ArrowRight"
1952
- ]);
1953
- const modified = event.altKey || event.ctrlKey || event.metaKey;
1954
- if (!modified && !special.has(event.key)) return null;
1955
- const parts = [];
1956
- if (event.ctrlKey) parts.push(hostPlatform === "mac" ? "Control" : "Mod");
1957
- if (event.altKey) parts.push("Alt");
1958
- if (event.metaKey) parts.push(hostPlatform === "mac" ? "Mod" : "Meta");
1959
- if (event.shiftKey) parts.push("Shift");
1960
- parts.push(event.key === " " ? "Space" : event.key);
1961
- return parts.join("+");
1962
- }
1963
-
1964
- // src/components/browser-select-control.tsx
1965
- import { useEffect as useEffect8, useLayoutEffect, useRef as useRef8, useState as useState8 } from "react";
1966
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
1967
- function focusedSelect(observation) {
1968
- if (observation.semantic?.kind !== "snapshot") return null;
1969
- const pending = [...observation.semantic.roots];
1970
- while (pending.length) {
1971
- const node = pending.pop();
1972
- if (node.children) pending.push(...node.children);
1973
- if (node.ref !== observation.focusedRef || !node.actions.includes("select") || node.native?.platform !== "dom")
1974
- continue;
1975
- const data = node.native.data;
1976
- if (!data || data.kind !== "native-select" || typeof data.multiple !== "boolean" || typeof data.disabled !== "boolean" || !Array.isArray(data.options) || data.options.length > 200)
1977
- return null;
1978
- if (data.options.some(
1979
- (option) => !option || typeof option.value !== "string" || typeof option.label !== "string" || typeof option.selected !== "boolean" || typeof option.disabled !== "boolean"
1980
- ))
1981
- return null;
1982
- return { node, control: data };
1983
- }
1984
- return null;
1985
- }
1986
- function BrowserSelectControl(props) {
1987
- const t = useOpenGeniText();
1988
- const [snapshot, setSnapshot] = useState8(null);
1989
- const [open, setOpen] = useState8(false);
1990
- const [busy, setBusy] = useState8(false);
1991
- const [error, setError] = useState8(null);
1992
- const [values, setValues] = useState8([]);
1993
- const [anchor, setAnchor] = useState8(null);
1994
- const popupRef = useRef8(null);
1995
- const [position, setPosition] = useState8(null);
1996
- const panelRef = useRef8(null);
1997
- const request = useRef8(0);
1998
- const optionKeys = useRef8(/* @__PURE__ */ new WeakMap());
1999
- const nextOptionKey = useRef8(0);
2000
- const optionKey = (option) => {
2001
- let key = optionKeys.current.get(option);
2002
- if (key === void 0) {
2003
- key = ++nextOptionKey.current;
2004
- optionKeys.current.set(option, key);
2005
- }
2006
- return key;
2007
- };
2008
- useEffect8(
2009
- () => () => {
2010
- request.current += 1;
2011
- },
2012
- []
2013
- );
2014
- useEffect8(() => {
2015
- if (props.activation === void 0) return;
2016
- ++request.current;
2017
- const observation = props.activation?.observation;
2018
- const selected2 = observation ? focusedSelect(observation) : null;
2019
- setSnapshot(selected2 && observation ? observation : null);
2020
- setAnchor(selected2 ? props.activation.anchor : null);
2021
- setOpen(Boolean(selected2));
2022
- setBusy(false);
2023
- setError(null);
2024
- setValues(
2025
- selected2?.control.options.filter((option) => option.selected).map((option) => option.value) ?? []
2026
- );
2027
- }, [props.activation]);
2028
- useEffect8(() => {
2029
- if (open && !busy) panelRef.current?.focus({ preventScroll: true });
2030
- }, [open, busy]);
2031
- useLayoutEffect(() => {
2032
- if (!anchor || !open) {
2033
- setPosition(null);
2034
- return;
2035
- }
2036
- const place = () => {
2037
- const popup = popupRef.current;
2038
- const parent = popup?.parentElement;
2039
- if (!popup || !parent) return;
2040
- setPosition({
2041
- x: Math.max(12, Math.min(anchor.x, parent.clientWidth - popup.offsetWidth - 12)),
2042
- y: Math.max(12, Math.min(anchor.y, parent.clientHeight - popup.offsetHeight - 12)),
2043
- height: Math.max(48, parent.clientHeight - 60)
2044
- });
2045
- };
2046
- place();
2047
- const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(place);
2048
- if (popupRef.current?.parentElement) observer?.observe(popupRef.current.parentElement);
2049
- if (popupRef.current) observer?.observe(popupRef.current);
2050
- return () => observer?.disconnect();
2051
- }, [anchor, open, busy, snapshot, error]);
2052
- const selected = snapshot ? focusedSelect(snapshot) : null;
2053
- const ambiguousValue = (value) => (selected?.control.options.filter((option) => option.value === value || option.label === value).length ?? 0) !== 1;
2054
- const load = async () => {
2055
- const current = ++request.current;
2056
- setOpen(true);
2057
- setBusy(true);
2058
- setSnapshot(null);
2059
- setError(null);
2060
- setAnchor(null);
2061
- try {
2062
- const observation = await props.observe();
2063
- if (current !== request.current) return;
2064
- setSnapshot(observation);
2065
- setValues(
2066
- focusedSelect(observation)?.control.options.filter((option) => option.selected).map((option) => option.value) ?? []
2067
- );
2068
- } catch (cause) {
2069
- if (current === request.current)
2070
- setError(
2071
- cause instanceof Error ? cause.message : t("browserSelectControl.couldNotReadOptions")
2072
- );
2073
- } finally {
2074
- if (current === request.current) setBusy(false);
2075
- }
2076
- };
2077
- const apply = async (next) => {
2078
- if (!snapshot || !selected || busy) return;
2079
- const current = ++request.current;
2080
- setBusy(true);
2081
- setError(null);
2082
- try {
2083
- const receipt = await props.act(
2084
- { type: "select", locator: { kind: "ref", ref: selected.node.ref }, values: next },
2085
- snapshot
2086
- );
2087
- if (receipt.state !== "completed")
2088
- throw new Error(
2089
- receipt.error?.message ?? t("browserSelectControl.selectionDidNotComplete")
2090
- );
2091
- if (current === request.current) {
2092
- setOpen(false);
2093
- setSnapshot(null);
2094
- props.onDismiss?.();
2095
- }
2096
- } catch (cause) {
2097
- if (current === request.current) {
2098
- setError(
2099
- cause instanceof Error ? cause.message : t("browserSelectControl.selectionFailedReadTheOptions")
2100
- );
2101
- setSnapshot(null);
2102
- }
2103
- } finally {
2104
- if (current === request.current) setBusy(false);
2105
- }
2106
- };
2107
- if (props.manualFallback === false && !open) return null;
2108
- return /* @__PURE__ */ jsxs(
2109
- "div",
2110
- {
2111
- ref: popupRef,
2112
- className: "absolute z-10 max-w-[calc(100%-1.5rem)] text-og-control",
2113
- style: anchor && open ? {
2114
- left: position?.x ?? anchor.x,
2115
- top: position?.y ?? anchor.y
2116
- } : { bottom: 12, left: 12 },
2117
- children: [
2118
- props.manualFallback !== false && (!anchor || !open) || error ? /* @__PURE__ */ jsx(
2119
- "button",
2120
- {
2121
- type: "button",
2122
- className: "rounded-og-sm border border-og-border bg-og-bg px-2 py-1 text-og-fg",
2123
- disabled: busy,
2124
- onClick: () => void load(),
2125
- "aria-expanded": open,
2126
- children: t("browserSelectControl.chooseOption")
2127
- }
2128
- ) : null,
2129
- open ? /* @__PURE__ */ jsxs(
2130
- "section",
2131
- {
2132
- ref: panelRef,
2133
- tabIndex: -1,
2134
- "aria-label": t("browserSelectControl.pageSelectionOptions"),
2135
- style: position ? { maxHeight: Math.min(288, position.height) } : void 0,
2136
- onKeyDown: (event) => {
2137
- if (event.key !== "Escape") return;
2138
- event.preventDefault();
2139
- event.stopPropagation();
2140
- ++request.current;
2141
- setOpen(false);
2142
- setSnapshot(null);
2143
- setBusy(false);
2144
- props.onDismiss?.();
2145
- },
2146
- className: "mt-1 max-h-72 w-72 max-w-full overflow-auto rounded-og-sm border border-og-border bg-og-bg p-3 text-og-fg shadow-lg",
2147
- children: [
2148
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
2149
- /* @__PURE__ */ jsx("strong", { children: selected?.node.name || t("browserSelectControl.pageOptions") }),
2150
- /* @__PURE__ */ jsx(
2151
- "button",
2152
- {
2153
- type: "button",
2154
- disabled: busy,
2155
- onClick: () => {
2156
- ++request.current;
2157
- setOpen(false);
2158
- setSnapshot(null);
2159
- props.onDismiss?.();
2160
- },
2161
- "aria-label": t("browserSelectControl.closePageOptions"),
2162
- children: t("browserSelectControl.close")
2163
- }
2164
- )
2165
- ] }),
2166
- busy ? /* @__PURE__ */ jsx("p", { role: "status", children: t("browserSelectControl.loading") }) : error ? /* @__PURE__ */ jsx("p", { role: "alert", children: error }) : !selected ? /* @__PURE__ */ jsx("p", { children: t("browserSelectControl.clickADropdownInThe") }) : selected.control.disabled ? /* @__PURE__ */ jsx("p", { children: t("browserSelectControl.thisControlIsDisabled") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2167
- selected.control.options.map((option) => {
2168
- const ambiguous = ambiguousValue(option.value);
2169
- const disabled = busy || option.disabled || ambiguous;
2170
- return selected.control.multiple ? /* @__PURE__ */ jsxs("label", { className: "my-1 flex items-center gap-2", children: [
2171
- /* @__PURE__ */ jsx(
2172
- "input",
2173
- {
2174
- type: "checkbox",
2175
- disabled,
2176
- checked: values.includes(option.value),
2177
- onChange: (event) => setValues(
2178
- event.target.checked ? [...values, option.value] : values.filter((value) => value !== option.value)
2179
- )
2180
- }
2181
- ),
2182
- option.label || t("browserSelectControl.empty"),
2183
- ambiguous ? ` ${t("browserSelectControl.ambiguousValue")}` : ""
2184
- ] }, optionKey(option)) : /* @__PURE__ */ jsxs(
2185
- "button",
2186
- {
2187
- type: "button",
2188
- disabled,
2189
- "aria-pressed": option.selected,
2190
- className: "my-1 block w-full rounded-og-sm border border-og-border px-2 py-1 text-left disabled:opacity-50",
2191
- onClick: () => void apply([option.value]),
2192
- children: [
2193
- option.label || t("browserSelectControl.empty"),
2194
- option.selected ? " \u2713" : "",
2195
- ambiguous ? ` ${t("browserSelectControl.ambiguousValue")}` : ""
2196
- ]
2197
- },
2198
- optionKey(option)
2199
- );
2200
- }),
2201
- selected.control.multiple ? /* @__PURE__ */ jsx(
2202
- "button",
2203
- {
2204
- type: "button",
2205
- disabled: busy || values.some(ambiguousValue),
2206
- onClick: () => void apply(values),
2207
- children: t("browserSelectControl.applySelection")
2208
- }
2209
- ) : null
2210
- ] })
2211
- ]
2212
- }
2213
- ) : null
2214
- ]
2215
- }
2216
- );
2217
- }
2218
-
2219
- // src/components/browser-viewer.tsx
2220
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
2221
- var STALE_BROWSER_END_MAX_ATTEMPTS = 3;
2222
- var STALE_BROWSER_END_RETRY_BASE_MS = 5e3;
2223
- function staleBrowserEndRetryDelayMs(cause, failedAttempts) {
2224
- const status = cause?.status;
2225
- if (typeof status === "number" && status >= 400 && status < 500) return null;
2226
- if (failedAttempts >= STALE_BROWSER_END_MAX_ATTEMPTS) return null;
2227
- return STALE_BROWSER_END_RETRY_BASE_MS * 2 ** (failedAttempts - 1);
2228
- }
2229
- function BrowserViewer({
2230
- sessionId,
2231
- enabled = true,
2232
- active = true,
2233
- showAdvancedControls = true,
2234
- className,
2235
- onNotify,
2236
- webSocketFactory,
2237
- renderEmpty,
2238
- createLinkedComputer,
2239
- onOpenComputer,
2240
- initialBrowserSessionId,
2241
- onBrowserSessionIdChange,
2242
- browserExtensionSetupUrl,
2243
- ...override
2244
- }) {
2245
- const t = useOpenGeniText();
2246
- const registry = useBrowserSessions({ ...override, sessionId, enabled });
2247
- const attached = useAttachedBrowsers({ ...override, enabled: enabled && showAdvancedControls });
2248
- const { client: configClient } = useEmbeddedBrowserInteraction(override);
2249
- const browserExtensionName = useClientConfigFlags(configClient).browserExtension?.name;
2250
- const onlineAttachedBridges = useMemo2(
2251
- () => attached.bridges.filter((bridge) => bridge.state === "online"),
2252
- [attached.bridges]
2253
- );
2254
- const profiles = useBrowserIdentities({
2255
- ...override,
2256
- enabled: enabled && showAdvancedControls,
2257
- includeArchived: true
2258
- });
2259
- const siteAuth = useSiteAuthConnections({
2260
- ...override,
2261
- enabled: enabled && showAdvancedControls && profiles.identities.length > 0
2262
- });
2263
- const createRegistryBrowser = registry.create;
2264
- const refreshRegistry = registry.refresh;
2265
- const loadProfileRevisions = profiles.revisions;
2266
- const liveSessions = useMemo2(
2267
- () => registry.sessions.filter((session) => isLiveBrowser2(session)),
2268
- [registry.sessions]
2269
- );
2270
- const attachedGenerationLoss = useMemo2(
2271
- () => attachedChromeGenerationLoss(registry.sessions),
2272
- [registry.sessions]
2273
- );
2274
- const endedGenerationLossRef = useRef9(/* @__PURE__ */ new Set());
2275
- const endStaleBrowserAttemptsRef = useRef9(/* @__PURE__ */ new Map());
2276
- const endStaleBrowser = registry.end;
2277
- useEffect9(() => {
2278
- if (!enabled) return;
2279
- for (const session of registry.sessions) {
2280
- if (session.lifecycle !== "lost" || session.failureCode !== "controller_transition_expired" || session.placement.kind !== "attached_device") {
2281
- continue;
2282
- }
2283
- if (endedGenerationLossRef.current.has(session.id)) continue;
2284
- endedGenerationLossRef.current.add(session.id);
2285
- void endStaleBrowser(session.id).catch((cause) => {
2286
- const attempts = (endStaleBrowserAttemptsRef.current.get(session.id) ?? 0) + 1;
2287
- endStaleBrowserAttemptsRef.current.set(session.id, attempts);
2288
- const delay = staleBrowserEndRetryDelayMs(cause, attempts);
2289
- if (delay === null) return;
2290
- setTimeout(() => endedGenerationLossRef.current.delete(session.id), delay);
2291
- });
2292
- }
2293
- }, [enabled, endStaleBrowser, registry.sessions]);
2294
- const relevant = useMemo2(
2295
- () => registry.relevantSessions.filter((session) => isLiveBrowser2(session)),
2296
- [registry.relevantSessions]
2297
- );
2298
- const latestRelevantBrowser = registry.relevantSessions[0];
2299
- const unavailableBrowser = latestRelevantBrowser?.lifecycle === "lost" || latestRelevantBrowser?.lifecycle === "failed" ? latestRelevantBrowser : void 0;
2300
- const [selection, setSelection] = useState9(
2301
- () => initialBrowserSessionId ? { sessionId: initialBrowserSessionId, pinned: true } : null
2302
- );
2303
- const selectBrowserSession = useCallback8(
2304
- (next) => {
2305
- setSelection(next);
2306
- onBrowserSessionIdChange?.(next?.sessionId ?? null);
2307
- },
2308
- [onBrowserSessionIdChange]
2309
- );
2310
- const interventions = useInteractionInterventions({
2311
- ...override,
2312
- enabled,
2313
- resourceKind: "browser_session"
2314
- });
2315
- const [creating, setCreating] = useState9(false);
2316
- const [savingProfile, setSavingProfile] = useState9(false);
2317
- const [baseRevisionOrdinal, setBaseRevisionOrdinal] = useState9(null);
2318
- const [profileHistory, setProfileHistory] = useState9(null);
2319
- const [resumeAttempt, setResumeAttempt] = useState9(null);
2320
- const resumeAttemptsRef = useRef9(/* @__PURE__ */ new Map());
2321
- const previousSessionIdRef = useRef9(sessionId);
2322
- const seenInterventionIdsRef = useRef9(/* @__PURE__ */ new Set());
2323
- const diagnosticRequestRef = useRef9(0);
2324
- const viewportFocusHandoffRef = useRef9(null);
2325
- const [diagnosticsView, setDiagnosticsView] = useState9(null);
2326
- const notifyError = useCallback8(
2327
- (cause, fallback) => {
2328
- const message = cause instanceof Error ? cause.message : fallback;
2329
- onNotify?.({ kind: "error", message });
2330
- },
2331
- [onNotify]
2332
- );
2333
- useEffect9(() => {
2334
- if (previousSessionIdRef.current !== sessionId) {
2335
- previousSessionIdRef.current = sessionId;
2336
- setSelection(
2337
- initialBrowserSessionId ? { sessionId: initialBrowserSessionId, pinned: true } : null
2338
- );
2339
- }
2340
- }, [initialBrowserSessionId, sessionId]);
2341
- useEffect9(() => {
2342
- if (!enabled || registry.loading) return;
2343
- const selectedStillLive = liveSessions.some((session) => session.id === selection?.sessionId);
2344
- if (selection?.pinned && selectedStillLive) return;
2345
- const preferred = relevant[0] ?? null;
2346
- if (!preferred) {
2347
- if (selection) selectBrowserSession(null);
2348
- return;
2349
- }
2350
- if (!selectedStillLive || !selection?.pinned) {
2351
- if (selection?.sessionId !== preferred.id || selection.pinned) {
2352
- selectBrowserSession({ sessionId: preferred.id, pinned: false });
2353
- }
2354
- }
2355
- }, [enabled, liveSessions, registry.loading, relevant, selectBrowserSession, selection]);
2356
- const selectedRegistrySession = useMemo2(
2357
- () => liveSessions.find((session) => session.id === selection?.sessionId) ?? null,
2358
- [liveSessions, selection?.sessionId]
2359
- );
2360
- const interventionCounts = useMemo2(
2361
- () => countInterventions(interventions.interventions),
2362
- [interventions.interventions]
2363
- );
2364
- const selectedInterventions = useMemo2(
2365
- () => interventions.interventions.filter(
2366
- (intervention) => intervention.resourceId === selection?.sessionId
2367
- ),
2368
- [interventions.interventions, selection?.sessionId]
2369
- );
2370
- const controllerReady = selectedRegistrySession?.lifecycle === "active";
2371
- const resumeSession = registry.resume;
2372
- const [hasLiveFrame, setHasLiveFrame] = useState9(false);
2373
- const wakeBrowser = useCallback8(
2374
- async (session, retry = false) => {
2375
- const current = resumeAttemptsRef.current.get(session.id);
2376
- if (current?.running || !retry && current) return;
2377
- const operationId = current && !current.terminal ? current.operationId : crypto.randomUUID();
2378
- const attempt = {
2379
- operationId,
2380
- running: true,
2381
- terminal: false,
2382
- error: null
2383
- };
2384
- resumeAttemptsRef.current.set(session.id, attempt);
2385
- setResumeAttempt({ sessionId: session.id, attempt });
2386
- try {
2387
- const response = await resumeSession(session.id, operationId);
2388
- if (response.operation.state !== "completed") {
2389
- throw Object.assign(
2390
- new Error(
2391
- response.operation.error?.message ?? t("browserViewer.browserCouldNotReopen2")
2392
- ),
2393
- { terminal: true }
2394
- );
2395
- }
2396
- resumeAttemptsRef.current.delete(session.id);
2397
- setResumeAttempt((visible) => visible?.sessionId === session.id ? null : visible);
2398
- } catch (cause) {
2399
- const error = cause instanceof Error ? cause : new Error(String(cause));
2400
- const failed = {
2401
- operationId,
2402
- running: false,
2403
- terminal: typeof cause === "object" && cause !== null && "terminal" in cause ? cause.terminal === true : false,
2404
- error
2405
- };
2406
- resumeAttemptsRef.current.set(session.id, failed);
2407
- setResumeAttempt({ sessionId: session.id, attempt: failed });
2408
- notifyError(error, t("browserViewer.couldNotReopenThisBrowser"));
2409
- }
2410
- },
2411
- [notifyError, resumeSession, t]
2412
- );
2413
- useEffect9(() => {
2414
- if (!selectedRegistrySession) return;
2415
- if (selectedRegistrySession.lifecycle === "active") {
2416
- resumeAttemptsRef.current.delete(selectedRegistrySession.id);
2417
- setResumeAttempt(
2418
- (visible) => visible?.sessionId === selectedRegistrySession.id ? null : visible
2419
- );
2420
- }
2421
- }, [selectedRegistrySession]);
2422
- const browser = useBrowserSession({
2423
- ...override,
2424
- browserSessionId: selection?.sessionId ?? null,
2425
- enabled: enabled && selection !== null && controllerReady,
2426
- semanticObservationEnabled: active && !hasLiveFrame
2427
- });
2428
- useEffect9(() => {
2429
- if (!isSourcePlacementChangedError(browser.error, "browser_session")) return;
2430
- void refreshRegistry();
2431
- }, [browser.error, refreshRegistry]);
2432
- const downloads = useBrowserDownloads({
2433
- ...override,
2434
- browserSessionId: selection?.sessionId ?? null,
2435
- enabled: enabled && showAdvancedControls && diagnosticsView !== null && controllerReady && browser.session?.capabilities.downloads === true
2436
- });
2437
- const loadBrowserDiagnostics = browser.diagnostics;
2438
- useEffect9(() => {
2439
- for (const intervention of interventions.interventions) {
2440
- if (seenInterventionIdsRef.current.has(intervention.id)) continue;
2441
- seenInterventionIdsRef.current.add(intervention.id);
2442
- onNotify?.({
2443
- kind: "info",
2444
- message: `${interventionTitle(t, intervention)}: ${intervention.reason}`
2445
- });
2446
- }
2447
- }, [interventions.interventions, onNotify, t]);
2448
- const resolveIntervention = useCallback8(
2449
- (intervention, outcome) => {
2450
- void interventions.resolve(intervention.id, {
2451
- expectedVersion: intervention.version,
2452
- outcome
2453
- }).then(() => {
2454
- onNotify?.({
2455
- kind: "info",
2456
- message: outcome === "completed" ? t("browserViewer.agentNotifiedContinuingWork") : t("browserViewer.requestCancelled")
2457
- });
2458
- }).catch((cause) => notifyError(cause, t("browserViewer.couldNotUpdateTheBrowser")));
2459
- },
2460
- [interventions, notifyError, onNotify, t]
2461
- );
2462
- const frames = useBrowserFrameStream({
2463
- ...override,
2464
- browserSessionId: selection?.sessionId ?? null,
2465
- targetId: browser.selectedTarget?.id ?? null,
2466
- enabled: enabled && selection !== null && controllerReady && browser.selectedTarget !== null && browser.session?.capabilities.liveFrames === true,
2467
- stream: { format: "jpeg", quality: 76, maxWidth: 1920, maxHeight: 1200 },
2468
- ...webSocketFactory ? { webSocketFactory } : {}
2469
- });
2470
- const receivedFrame = frameMatchesSelectedTarget(
2471
- frames.frame,
2472
- browser.session,
2473
- browser.selectedTarget
2474
- ) ? frames.frame : null;
2475
- const displayedFrame = useMemo2(
2476
- () => receivedFrame ? { ...receivedFrame, data: receivedFrame.data.slice().buffer } : null,
2477
- [receivedFrame]
2478
- );
2479
- const frameIsLive = frames.state === "live" && displayedFrame !== null;
2480
- useEffect9(() => {
2481
- setHasLiveFrame(frameIsLive);
2482
- }, [frameIsLive]);
2483
- const supportsLiveFrames = (browser.session ?? selectedRegistrySession)?.capabilities.liveFrames === true;
2484
- const controlUnavailable = isInteractionControlUnavailable(browser.error);
2485
- const connectionError = controlUnavailable ? browser.error : frames.error ?? browser.error;
2486
- const selectedPlacement = (browser.session ?? selectedRegistrySession)?.placement;
2487
- const selectedChromeGenerationLoss = selectedPlacement?.kind === "attached_device" && isAttachedChromeGenerationLossError(connectionError);
2488
- const replacementChromeDevice = selectedChromeGenerationLoss && selectedPlacement.kind === "attached_device" ? attached.devices.find((candidate) => candidate.id === selectedPlacement.deviceId) : null;
2489
- const displayConnectionState = connectionError && (!frameIsLive || controlUnavailable) ? "error" : !browser.session ? "connecting" : supportsLiveFrames ? frames.state === "live" && !displayedFrame ? "connecting" : frames.state : "semantic";
2490
- const selectedProfile = useMemo2(
2491
- () => profiles.identities.find(
2492
- (identity) => identity.id === (browser.session?.identityId ?? selectedRegistrySession?.identityId)
2493
- ) ?? null,
2494
- [browser.session?.identityId, profiles.identities, selectedRegistrySession?.identityId]
2495
- );
2496
- const selectedProfileAuth = useMemo2(
2497
- () => selectedProfile ? siteAuth.connections.filter(
2498
- (connection) => connection.preferredIdentityId === selectedProfile.id
2499
- ) : [],
2500
- [selectedProfile, siteAuth.connections]
2501
- );
2502
- useEffect9(() => {
2503
- diagnosticRequestRef.current += 1;
2504
- setDiagnosticsView(null);
2505
- }, [browser.session?.id, browser.selectedTarget?.id]);
2506
- const loadDiagnostics = useCallback8(() => {
2507
- const browserSessionId = browser.session?.id;
2508
- const targetId = browser.selectedTarget?.id;
2509
- if (!browserSessionId || !targetId) return;
2510
- const requestId = diagnosticRequestRef.current + 1;
2511
- diagnosticRequestRef.current = requestId;
2512
- setDiagnosticsView((current) => ({
2513
- browserSessionId,
2514
- targetId,
2515
- loading: true,
2516
- batch: current?.browserSessionId === browserSessionId && current.targetId === targetId ? current.batch : null,
2517
- error: null
2518
- }));
2519
- void loadBrowserDiagnostics({ limit: 100 }).then((batch) => {
2520
- if (diagnosticRequestRef.current !== requestId) return;
2521
- setDiagnosticsView({ browserSessionId, targetId, loading: false, batch, error: null });
2522
- }).catch((cause) => {
2523
- if (diagnosticRequestRef.current !== requestId) return;
2524
- setDiagnosticsView({
2525
- browserSessionId,
2526
- targetId,
2527
- loading: false,
2528
- batch: null,
2529
- error: cause instanceof Error ? cause : new Error(String(cause))
2530
- });
2531
- });
2532
- }, [browser.selectedTarget?.id, browser.session?.id, loadBrowserDiagnostics]);
2533
- const closeDiagnostics = useCallback8(() => {
2534
- diagnosticRequestRef.current += 1;
2535
- setDiagnosticsView(null);
2536
- }, []);
2537
- const refreshDiagnostics = useCallback8(() => {
2538
- loadDiagnostics();
2539
- if (browser.session?.capabilities.downloads) void downloads.refresh();
2540
- }, [browser.session?.capabilities.downloads, downloads, loadDiagnostics]);
2541
- const saveDownload = useCallback8(
2542
- async (downloadId, destinationPath, overwrite) => {
2543
- const response = await downloads.saveToWorkspace(downloadId, destinationPath, { overwrite });
2544
- onNotify?.({
2545
- kind: "info",
2546
- message: t("browserViewer.filenameSavedToDestinationpath", {
2547
- filename: response.download.filename,
2548
- destinationPath: response.destinationPath
2549
- })
2550
- });
2551
- return response;
2552
- },
2553
- [downloads, onNotify, t]
2554
- );
2555
- useEffect9(() => {
2556
- const identityId = browser.session?.identityId ?? selectedRegistrySession?.identityId;
2557
- const revisionId = browser.session?.baseRevisionId ?? selectedRegistrySession?.baseRevisionId;
2558
- if (!identityId) {
2559
- setBaseRevisionOrdinal(null);
2560
- setProfileHistory(null);
2561
- return;
2562
- }
2563
- let disposed = false;
2564
- setBaseRevisionOrdinal(null);
2565
- setProfileHistory({ identityId, loading: true, revisions: [] });
2566
- void loadProfileRevisions(identityId).then((response) => {
2567
- if (!disposed) {
2568
- setBaseRevisionOrdinal(
2569
- revisionId ? response.revisions.find((revision) => revision.id === revisionId)?.ordinal ?? null : null
2570
- );
2571
- setProfileHistory({ identityId, loading: false, revisions: response.revisions });
2572
- }
2573
- }).catch(() => {
2574
- if (!disposed) setProfileHistory({ identityId, loading: false, revisions: [] });
2575
- });
2576
- return () => {
2577
- disposed = true;
2578
- };
2579
- }, [
2580
- browser.session?.baseRevisionId,
2581
- browser.session?.identityId,
2582
- loadProfileRevisions,
2583
- selectedRegistrySession?.baseRevisionId,
2584
- selectedRegistrySession?.identityId
2585
- ]);
2586
- const createBrowser = useCallback8(
2587
- (choice = { kind: "clean" }) => {
2588
- if (creating) return;
2589
- const identity = choice.kind === "profile" ? profiles.identities.find((candidate) => candidate.id === choice.identityId) : null;
2590
- if (choice.kind === "profile" && (!identity || identity.status !== "active")) {
2591
- onNotify?.({
2592
- kind: "error",
2593
- message: t("browserViewer.thisBrowserProfileIsNo")
2594
- });
2595
- return;
2596
- }
2597
- const device = choice.kind === "attached" ? choice.device : null;
2598
- const browserName = device?.profileLabel ?? device?.name ?? (identity ? `${identity.name} browser` : t("browserViewer.browser"));
2599
- setCreating(true);
2600
- void (async () => {
2601
- let linkedComputer = null;
2602
- let computerViewUnavailable = false;
2603
- if (createLinkedComputer) {
2604
- try {
2605
- linkedComputer = await createLinkedComputer(
2606
- `${browserName} desktop`,
2607
- device ? { kind: "attached_device", deviceId: device.id } : void 0
2608
- );
2609
- } catch {
2610
- computerViewUnavailable = true;
2611
- }
2612
- }
2613
- const response = await createRegistryBrowser({
2614
- sessionId,
2615
- name: browserName,
2616
- // Human-created browsers are always ordinary visual Chromium/Chrome.
2617
- // Lightpanda remains an agent-only optimization requested explicitly
2618
- // through browser_open; if an agent creates one it is still visible in
2619
- // the shared BrowserSession switcher.
2620
- headless: false,
2621
- initialUrl: HUMAN_BROWSER_HOME_URL,
2622
- ...device ? {
2623
- placement: {
2624
- kind: "attached_device",
2625
- deviceId: device.id
2626
- }
2627
- } : {},
2628
- ...linkedComputer ? {
2629
- linkedComputerSessionId: linkedComputer.id,
2630
- placement: linkedComputer.placement
2631
- } : {},
2632
- ...identity ? {
2633
- identityId: identity.id,
2634
- ...choice.kind === "profile" && choice.baseRevisionId ? { baseRevisionId: choice.baseRevisionId } : {}
2635
- } : {}
2636
- });
2637
- selectBrowserSession({ sessionId: response.session.id, pinned: true });
2638
- if (computerViewUnavailable) {
2639
- onNotify?.({
2640
- kind: "info",
2641
- message: t("browserViewer.browserOpenedDesktopViewIs")
2642
- });
2643
- }
2644
- })().catch((cause) => notifyError(cause, t("browserViewer.couldNotOpenABrowser"))).finally(() => setCreating(false));
2645
- },
2646
- [
2647
- createLinkedComputer,
2648
- createRegistryBrowser,
2649
- creating,
2650
- notifyError,
2651
- onNotify,
2652
- selectBrowserSession,
2653
- profiles.identities,
2654
- sessionId,
2655
- t
2656
- ]
2657
- );
2658
- const saveProfileVersion = useCallback8(
2659
- async (newProfileName) => {
2660
- const session = browser.session;
2661
- if (!session || savingProfile || !session.capabilities.identityPublication) return false;
2662
- setSavingProfile(true);
2663
- try {
2664
- let identity = selectedProfile;
2665
- if (!identity) {
2666
- const name = newProfileName?.trim() ?? "";
2667
- if (!name) return false;
2668
- identity = profiles.identities.find(
2669
- (candidate) => candidate.status === "active" && candidate.revisionCount === 0 && candidate.name.localeCompare(name, void 0, { sensitivity: "base" }) === 0
2670
- ) ?? (await profiles.create({ name })).identity;
2671
- }
2672
- const response = await profiles.publish(session.id, {
2673
- identityId: identity.id,
2674
- expectedHeadGeneration: identity.headGeneration,
2675
- advanceDefault: true
2676
- });
2677
- setBaseRevisionOrdinal(response.revision.ordinal);
2678
- setProfileHistory((current) => ({
2679
- identityId: response.identity.id,
2680
- loading: false,
2681
- revisions: current?.identityId === response.identity.id ? [
2682
- ...current.revisions.filter((revision) => revision.id !== response.revision.id),
2683
- response.revision
2684
- ] : [response.revision]
2685
- }));
2686
- await Promise.all([browser.refresh(), registry.refresh()]);
2687
- onNotify?.({
2688
- kind: "info",
2689
- message: response.outcome === "saved_as_default" ? t("browserViewer.nameVersionOrdinalSavedFor", {
2690
- name: response.identity.name,
2691
- ordinal: response.revision.ordinal
2692
- }) : t("browserViewer.nameVersionOrdinalSavedAnother", {
2693
- name: response.identity.name,
2694
- ordinal: response.revision.ordinal
2695
- })
2696
- });
2697
- return true;
2698
- } catch (cause) {
2699
- notifyError(cause, t("browserViewer.couldNotSaveThisBrowser"));
2700
- return false;
2701
- } finally {
2702
- setSavingProfile(false);
2703
- }
2704
- },
2705
- [browser, notifyError, onNotify, profiles, registry, savingProfile, selectedProfile, t]
2706
- );
2707
- const updateProfile = useCallback8(
2708
- async (identity, update) => {
2709
- if (savingProfile) return false;
2710
- setSavingProfile(true);
2711
- try {
2712
- const response = await profiles.update(identity.id, {
2713
- expectedVersion: identity.version,
2714
- ...update
2715
- });
2716
- if (update.defaultRevisionId) {
2717
- const ordinal = profileHistory?.revisions.find(
2718
- (revision) => revision.id === update.defaultRevisionId
2719
- )?.ordinal;
2720
- onNotify?.({
2721
- kind: "info",
2722
- message: ordinal ? t("browserViewer.nameVersionOpensByDefault", {
2723
- name: response.identity.name,
2724
- ordinal
2725
- }) : t("browserViewer.nameOpensByDefault", { name: response.identity.name })
2726
- });
2727
- } else if (update.status === "archived") {
2728
- onNotify?.({
2729
- kind: "info",
2730
- message: t("browserViewer.nameHiddenFromNewBrowsers", { name: response.identity.name })
2731
- });
2732
- } else if (update.status === "active") {
2733
- onNotify?.({ kind: "info", message: `${response.identity.name} restored.` });
2734
- }
2735
- return true;
2736
- } catch (cause) {
2737
- notifyError(cause, t("browserViewer.couldNotUpdateThisBrowser"));
2738
- await profiles.refresh().catch(() => void 0);
2739
- return false;
2740
- } finally {
2741
- setSavingProfile(false);
2742
- }
2743
- },
2744
- [notifyError, onNotify, profileHistory?.revisions, profiles, savingProfile, t]
2745
- );
2746
- if (!enabled) return null;
2747
- if (registry.loading && liveSessions.length === 0) {
2748
- return /* @__PURE__ */ jsx2(
2749
- BrowserNotice,
2750
- {
2751
- icon: /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "animate-spin" }),
2752
- text: t("browserViewer.findingBrowsers"),
2753
- ...className ? { className } : {}
2754
- }
2755
- );
2756
- }
2757
- if (liveSessions.length === 0 || !showAdvancedControls && !selectedRegistrySession) {
2758
- if (showAdvancedControls && renderEmpty && !unavailableBrowser)
2759
- return /* @__PURE__ */ jsx2(Fragment2, { children: renderEmpty(() => createBrowser(), creating) });
2760
- return /* @__PURE__ */ jsx2(
2761
- "div",
2762
- {
2763
- className: cn("flex h-full min-h-0 items-center justify-center bg-og-bg p-6", className),
2764
- children: /* @__PURE__ */ jsxs2("div", { className: "max-w-sm text-center", children: [
2765
- /* @__PURE__ */ jsx2("span", { className: "mx-auto grid size-10 place-items-center rounded-og-md border border-og-border bg-og-surface-1 text-og-fg-muted", children: /* @__PURE__ */ jsx2(Globe2Icon, { className: "size-4.5" }) }),
2766
- unavailableBrowser && (!attachedGenerationLoss || !showAdvancedControls) ? /* @__PURE__ */ jsx2(
2767
- BrowserUnavailableNotice,
2768
- {
2769
- session: unavailableBrowser,
2770
- canOpenNewBrowser: showAdvancedControls
2771
- }
2772
- ) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
2773
- /* @__PURE__ */ jsx2("p", { className: "mt-3 text-og-menu font-medium text-og-fg", children: attachedGenerationLoss ? t("browserViewer.chromeReconnectedOpenAFresh") : t("browserViewer.noBrowserOpen") }),
2774
- /* @__PURE__ */ jsx2("p", { className: "mt-1 text-og-control leading-5 text-og-fg-muted", children: attachedGenerationLoss ? t("browserViewer.thisChromeProfileIsLive") : t("browserViewer.aBrowserAppearsHereWhen") })
2775
- ] }),
2776
- showAdvancedControls ? /* @__PURE__ */ jsx2(
2777
- BrowserLaunchMenu,
2778
- {
2779
- attachedBridges: onlineAttachedBridges,
2780
- attachedDevices: attached.devices,
2781
- identities: profiles.identities,
2782
- creating,
2783
- mutatingProfile: savingProfile,
2784
- onCreate: createBrowser,
2785
- onRestore: (identity) => updateProfile(identity, { status: "active" }),
2786
- setupUrl: browserExtensionSetupUrl,
2787
- extensionName: browserExtensionName,
2788
- prominent: true
2789
- }
2790
- ) : null,
2791
- registry.error ? /* @__PURE__ */ jsx2("p", { className: "mt-3 text-og-control text-og-danger", children: registry.error.message }) : null
2792
- ] })
2793
- }
2794
- );
2795
- }
2796
- return /* @__PURE__ */ jsxs2(
2797
- "div",
2798
- {
2799
- className: cn("relative flex h-full min-h-0 flex-col overflow-hidden bg-og-bg", className),
2800
- children: [
2801
- showAdvancedControls ? /* @__PURE__ */ jsx2(
2802
- BrowserToolbar,
2803
- {
2804
- sessions: liveSessions,
2805
- relevantSessionIds: new Set(relevant.map((session) => session.id)),
2806
- selectedSessionId: selection?.sessionId ?? null,
2807
- identities: profiles.identities,
2808
- attachedBridges: onlineAttachedBridges,
2809
- attachedDevices: attached.devices,
2810
- selectedProfile,
2811
- baseRevisionOrdinal,
2812
- profileHistory,
2813
- authConnections: selectedProfileAuth,
2814
- creating,
2815
- savingProfile,
2816
- refreshing: registry.refreshing || attached.refreshing,
2817
- interventionCounts,
2818
- onSelect: (browserSessionId) => selectBrowserSession({ sessionId: browserSessionId, pinned: true }),
2819
- onFollow: () => {
2820
- const preferred = relevant[0];
2821
- if (preferred) selectBrowserSession({ sessionId: preferred.id, pinned: false });
2822
- },
2823
- onCreate: createBrowser,
2824
- onSaveProfile: saveProfileVersion,
2825
- onUpdateProfile: updateProfile,
2826
- onOpenProfileVersion: (identityId, baseRevisionId) => createBrowser({ kind: "profile", identityId, baseRevisionId }),
2827
- onRefresh: () => void Promise.all([registry.refresh(), attached.refresh()]),
2828
- setupUrl: browserExtensionSetupUrl,
2829
- extensionName: browserExtensionName
2830
- }
2831
- ) : null,
2832
- /* @__PURE__ */ jsx2(
2833
- InteractionInterventionBanner,
2834
- {
2835
- interventions: selectedInterventions,
2836
- activeTargetId: browser.selectedTarget?.id ?? null,
2837
- mutating: interventions.mutating,
2838
- onOpen: (intervention) => void browser.selectTarget(intervention.targetId).catch((cause) => notifyError(cause, t("browserViewer.couldNotOpenTheRequested"))),
2839
- onResolve: resolveIntervention
2840
- }
2841
- ),
2842
- !selectedRegistrySession ? /* @__PURE__ */ jsx2(
2843
- BrowserUnselectedPanel,
2844
- {
2845
- unavailableBrowser,
2846
- peerCount: liveSessions.length,
2847
- creating,
2848
- onCreate: () => createBrowser()
2849
- }
2850
- ) : !controllerReady ? /* @__PURE__ */ jsx2(
2851
- BrowserLifecyclePanel,
2852
- {
2853
- session: selectedRegistrySession,
2854
- attempt: resumeAttempt?.sessionId === selectedRegistrySession.id ? resumeAttempt.attempt : null,
2855
- onResume: () => void wakeBrowser(selectedRegistrySession, true)
2856
- }
2857
- ) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
2858
- /* @__PURE__ */ jsx2(
2859
- BrowserTabs,
2860
- {
2861
- targets: browser.targets,
2862
- selectedTargetId: browser.selectedTarget?.id ?? null,
2863
- mutating: savingProfile,
2864
- tabControl: browser.session?.capabilities.tabs === true,
2865
- onSelect: (targetId) => void browser.selectTarget(targetId).catch((cause) => notifyError(cause, t("browserViewer.couldNotSwitchTabs"))),
2866
- onClose: (targetId) => void browser.closeTarget(targetId).catch((cause) => notifyError(cause, t("browserViewer.couldNotCloseTheTab"))),
2867
- onOpen: () => void browser.openTarget(HUMAN_BROWSER_HOME_URL).catch((cause) => notifyError(cause, t("browserViewer.couldNotOpenATab")))
2868
- }
2869
- ),
2870
- /* @__PURE__ */ jsx2(
2871
- BrowserAddressBar,
2872
- {
2873
- target: browser.selectedTarget,
2874
- loading: browser.loading || browser.mutating || savingProfile,
2875
- onNavigate: (url) => void browser.act({ type: "navigate", url }).catch((cause) => notifyError(cause, t("browserViewer.couldNotNavigate"))),
2876
- onHistory: async (direction) => {
2877
- try {
2878
- const action = { type: "history", direction };
2879
- if (receivedFrame) await browser.actFromFrame(action, receivedFrame);
2880
- else {
2881
- if (!browser.observation)
2882
- throw new Error("The browser page is not ready for input.");
2883
- await browser.actFromObservation(action, browser.observation);
2884
- }
2885
- } catch (cause) {
2886
- notifyError(
2887
- cause,
2888
- direction === "back" ? t("browserViewer.couldNotGoBack") : t("browserViewer.couldNotGoForward")
2889
- );
2890
- }
2891
- },
2892
- onReload: () => {
2893
- const url = browser.selectedTarget?.url;
2894
- if (url)
2895
- void browser.act({ type: "navigate", url }).catch((cause) => notifyError(cause, t("browserViewer.couldNotReload")));
2896
- }
2897
- }
2898
- ),
2899
- browser.inputFailure ? /* @__PURE__ */ jsxs2(
2900
- "div",
2901
- {
2902
- role: "alert",
2903
- "aria-label": t("browserViewer.browserInputStatus"),
2904
- className: "flex shrink-0 items-center gap-2 border-t border-og-border bg-og-surface-1 px-3 py-2 text-og-xs",
2905
- children: [
2906
- /* @__PURE__ */ jsx2(CircleAlertIcon, { className: "size-4 shrink-0 text-og-status-failed" }),
2907
- /* @__PURE__ */ jsxs2("div", { className: "min-w-0 flex-1", children: [
2908
- /* @__PURE__ */ jsx2("span", { className: "font-medium", children: browser.inputFailure.state === "failed" ? t("browserViewer.browserInputFailed") : t("browserViewer.inputResultUnknown") }),
2909
- /* @__PURE__ */ jsx2("p", { className: "text-og-fg-subtle", children: browser.inputFailure.error?.message ?? t("browserViewer.inspectThePageBeforeContinuing") })
2910
- ] }),
2911
- /* @__PURE__ */ jsx2(
2912
- "button",
2913
- {
2914
- type: "button",
2915
- onClick: () => void browser.refresh(),
2916
- className: "shrink-0 rounded border border-og-border px-2 py-1 transition hover:bg-og-surface-2",
2917
- children: t("browserViewer.checkBrowser")
2918
- }
2919
- )
2920
- ]
2921
- }
2922
- ) : null,
2923
- /* @__PURE__ */ jsxs2("div", { className: "relative flex min-h-0 min-w-0 flex-1 overflow-hidden", children: [
2924
- /* @__PURE__ */ jsx2(
2925
- BrowserViewport,
2926
- {
2927
- focusHandoffRef: viewportFocusHandoffRef,
2928
- focusScope: JSON.stringify([
2929
- selection?.sessionId,
2930
- browser.selectedTarget?.id,
2931
- browser.selectedTarget?.targetGeneration
2932
- ]),
2933
- frame: displayedFrame,
2934
- connectionState: displayConnectionState,
2935
- supportsLiveFrames,
2936
- connectionError,
2937
- controlUnavailable,
2938
- observation: browser.observation,
2939
- mutating: browser.mutating || savingProfile,
2940
- activityLabel: savingProfile ? t("browserViewer.savingBrowserVersion") : void 0,
2941
- clipboardEnabled: browser.session?.capabilities.clipboard === true,
2942
- inputBatchAttachment: frames.attachment,
2943
- onAction: async (action, frame) => {
2944
- const focusedInput = frame && action.type === "pointer" && action.action === "click" && (action.button === void 0 || action.button === "left") && frames.attachment?.focusedInputObservations === true && frames.attachment.browserSessionId === frame.browserSessionId && frames.attachment.controllerGeneration === frame.controllerGeneration && frames.attachment.targetId === frame.targetId && Date.parse(frames.attachment.expiresAt) > Date.now();
2945
- const receipt = frame ? await browser.actFromFrame(
2946
- action,
2947
- frame,
2948
- void 0,
2949
- focusedInput ? "input" : "none"
2950
- ) : await browser.act(action);
2951
- if (receipt.state !== "completed") {
2952
- throw new Error(
2953
- receipt.error?.message ?? t("browserViewer.browserInputDidNotComplete")
2954
- );
2955
- }
2956
- return receipt;
2957
- },
2958
- onReadClipboard: browser.readClipboard,
2959
- onObserveForInput: browser.observeForInput,
2960
- onSelectFromObservation: browser.actFromObservation,
2961
- onReconnect: selectedChromeGenerationLoss && showAdvancedControls ? () => {
2962
- if (replacementChromeDevice) {
2963
- createBrowser({ kind: "attached", device: replacementChromeDevice });
2964
- }
2965
- } : () => {
2966
- void browser.refresh();
2967
- frames.reconnect();
2968
- },
2969
- reconnectLabel: selectedChromeGenerationLoss && showAdvancedControls && replacementChromeDevice ? t("browserViewer.openAFreshConnectedChrome") : void 0,
2970
- reconnectMessage: selectedChromeGenerationLoss ? t("browserViewer.chromeReconnectedOpenAFresh") : void 0,
2971
- onError: (cause) => notifyError(cause, t("browserViewer.browserInputFailed2"))
2972
- },
2973
- JSON.stringify([
2974
- selection?.sessionId,
2975
- browser.selectedTarget?.id,
2976
- browser.selectedTarget?.targetGeneration,
2977
- browser.selectedTarget?.documentGeneration,
2978
- frames.attachment?.controllerGeneration
2979
- ])
2980
- ),
2981
- showAdvancedControls && diagnosticsView ? /* @__PURE__ */ jsx2(
2982
- BrowserDiagnosticsDrawer,
2983
- {
2984
- session: browser.session,
2985
- profile: selectedProfile,
2986
- target: browser.selectedTarget,
2987
- observation: browser.observation,
2988
- baseRevisionOrdinal,
2989
- state: diagnosticsView,
2990
- downloads: downloads.downloads,
2991
- downloadsEnabled: browser.session?.capabilities.downloads === true,
2992
- downloadsLoading: downloads.loading,
2993
- downloadsRefreshing: downloads.refreshing,
2994
- downloadsError: downloads.error,
2995
- savingDownloadIds: downloads.savingDownloadIds,
2996
- onSaveDownload: saveDownload,
2997
- onRefreshDownloads: () => void downloads.refresh(),
2998
- onRefresh: refreshDiagnostics,
2999
- onClose: closeDiagnostics
3000
- }
3001
- ) : null
3002
- ] }),
3003
- /* @__PURE__ */ jsx2(
3004
- BrowserStatusBar,
3005
- {
3006
- session: browser.session,
3007
- profile: selectedProfile,
3008
- showProfile: showAdvancedControls,
3009
- target: browser.selectedTarget,
3010
- observation: browser.observation,
3011
- inputFailure: browser.inputFailure,
3012
- connectionState: displayConnectionState,
3013
- refreshing: registry.refreshing,
3014
- diagnosticsOpen: diagnosticsView !== null,
3015
- onOpenComputer: browser.session?.linkedComputerSessionId && onOpenComputer ? () => {
3016
- const computerSessionId = browser.session?.linkedComputerSessionId;
3017
- if (computerSessionId) onOpenComputer(computerSessionId);
3018
- } : void 0,
3019
- onDiagnostics: showAdvancedControls ? diagnosticsView ? closeDiagnostics : loadDiagnostics : void 0
3020
- }
3021
- )
3022
- ] })
3023
- ]
3024
- }
3025
- );
3026
- }
3027
- function BrowserLifecyclePanel(props) {
3028
- const t = useOpenGeniText();
3029
- const failed = props.attempt?.error ?? null;
3030
- const label = failed ? t("browserViewer.browserCouldNotReopen") : props.session.lifecycle === "suspending" ? t("browserViewer.savingBrowserState") : props.session.lifecycle === "restoring" || props.attempt?.running ? t("browserViewer.openingBrowser") : props.session.lifecycle === "starting" ? t("browserViewer.startingBrowser") : t("browserViewer.browserIsSleeping");
3031
- const detail = failed ? failed.message : props.session.lifecycle === "suspended" ? t("browserViewer.itsPrivateStateIsSaved") : t("browserViewer.theBrowserWillReconnectHere");
3032
- return /* @__PURE__ */ jsx2("div", { className: "grid min-h-0 flex-1 place-items-center bg-og-bg p-6 text-center", children: /* @__PURE__ */ jsxs2("div", { className: "max-w-sm", children: [
3033
- /* @__PURE__ */ jsx2("span", { className: "mx-auto grid size-10 place-items-center rounded-og-md border border-og-border bg-og-surface-1 text-og-fg-muted", children: failed ? /* @__PURE__ */ jsx2(CircleAlertIcon, { className: "size-4.5 text-og-danger" }) : /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-4.5 animate-spin" }) }),
3034
- /* @__PURE__ */ jsx2("p", { className: "mt-3 text-og-menu font-medium text-og-fg", children: label }),
3035
- /* @__PURE__ */ jsx2("p", { className: "mt-1 text-og-control leading-5 text-og-fg-muted", children: detail }),
3036
- failed || props.session.lifecycle === "suspended" && !props.attempt?.running ? /* @__PURE__ */ jsx2(
3037
- "button",
3038
- {
3039
- type: "button",
3040
- onClick: props.onResume,
3041
- className: "mt-4 inline-flex h-8 items-center rounded-og-sm border border-og-primary-border bg-og-primary px-3 text-og-control font-medium text-og-primary-fg transition hover:bg-og-primary-hover",
3042
- children: t("browserViewer.openBrowser")
3043
- }
3044
- ) : null
3045
- ] }) });
3046
- }
3047
- function BrowserToolbar(props) {
3048
- const t = useOpenGeniText();
3049
- const detailsRef = useViewerMenuDismiss();
3050
- const selected = props.sessions.find((session) => session.id === props.selectedSessionId);
3051
- const current = props.sessions.filter((session) => props.relevantSessionIds.has(session.id));
3052
- const others = props.sessions.filter((session) => !props.relevantSessionIds.has(session.id));
3053
- const choose = (id) => {
3054
- props.onSelect(id);
3055
- detailsRef.current?.removeAttribute("open");
3056
- };
3057
- return /* @__PURE__ */ jsxs2("div", { className: "flex h-10 shrink-0 items-center gap-1.5 border-b border-og-border bg-og-surface-1 px-2", children: [
3058
- /* @__PURE__ */ jsxs2("details", { ref: detailsRef, className: "min-w-0", children: [
3059
- /* @__PURE__ */ jsxs2("summary", { className: "flex h-7 max-w-52 cursor-pointer list-none items-center gap-2 rounded-og-sm px-2 text-og-control text-og-fg transition hover:bg-og-surface-2 [&::-webkit-details-marker]:hidden", children: [
3060
- /* @__PURE__ */ jsx2(Globe2Icon, { className: "size-3.5 shrink-0 text-og-fg-muted" }),
3061
- /* @__PURE__ */ jsx2("span", { className: "truncate font-medium", children: selected?.name ?? t("browserViewer.browser") }),
3062
- (props.interventionCounts.get(selected?.id ?? "") ?? 0) > 0 ? /* @__PURE__ */ jsx2("span", { className: "size-1.5 shrink-0 rounded-full bg-og-status-waiting" }) : null,
3063
- /* @__PURE__ */ jsx2(ChevronDownIcon, { className: "size-3 shrink-0 text-og-fg-subtle" })
3064
- ] }),
3065
- /* @__PURE__ */ jsxs2("div", { className: "absolute left-2 top-10 z-30 flex max-h-[calc(100%-3rem)] w-72 max-w-[calc(100%-1rem)] flex-col overflow-hidden rounded-og-md border border-og-border bg-og-surface-1 p-1 shadow-xl", children: [
3066
- /* @__PURE__ */ jsxs2("div", { className: "min-h-0 max-h-96 overflow-y-auto overscroll-contain", children: [
3067
- /* @__PURE__ */ jsx2(
3068
- BrowserSessionGroup,
3069
- {
3070
- label: t("browserViewer.currentAgent"),
3071
- sessions: current,
3072
- identities: props.identities,
3073
- selectedId: props.selectedSessionId,
3074
- interventionCounts: props.interventionCounts,
3075
- onSelect: choose
3076
- }
3077
- ),
3078
- /* @__PURE__ */ jsx2(
3079
- BrowserSessionGroup,
3080
- {
3081
- label: t("browserViewer.workspaceBrowsers"),
3082
- sessions: others,
3083
- identities: props.identities,
3084
- selectedId: props.selectedSessionId,
3085
- interventionCounts: props.interventionCounts,
3086
- onSelect: choose
3087
- }
3088
- )
3089
- ] }),
3090
- /* @__PURE__ */ jsxs2("div", { className: "mt-1 flex shrink-0 gap-1 border-t border-og-border pt-1", children: [
3091
- current.length > 0 ? /* @__PURE__ */ jsx2(MenuButton, { onClick: props.onFollow, children: t("browserViewer.followAgent") }) : null,
3092
- /* @__PURE__ */ jsxs2(MenuButton, { onClick: () => props.onCreate(), disabled: props.creating, children: [
3093
- /* @__PURE__ */ jsx2(PlusIcon, { className: "size-3.5" }),
3094
- " ",
3095
- t("browserViewer.newBrowser")
3096
- ] })
3097
- ] })
3098
- ] })
3099
- ] }),
3100
- /* @__PURE__ */ jsx2("span", { className: "min-w-0 flex-1 truncate text-og-xs text-og-fg-subtle", children: placementLabel(t, selected) }),
3101
- /* @__PURE__ */ jsx2(
3102
- BrowserProfileMenu,
3103
- {
3104
- session: selected ?? null,
3105
- identity: props.selectedProfile,
3106
- baseRevisionOrdinal: props.baseRevisionOrdinal,
3107
- history: props.profileHistory,
3108
- authConnections: props.authConnections,
3109
- saving: props.savingProfile,
3110
- onSave: props.onSaveProfile,
3111
- onUpdate: props.onUpdateProfile,
3112
- onOpenVersion: props.onOpenProfileVersion
3113
- }
3114
- ),
3115
- /* @__PURE__ */ jsx2(
3116
- "button",
3117
- {
3118
- type: "button",
3119
- onClick: props.onRefresh,
3120
- className: "grid size-7 shrink-0 place-items-center rounded-og-sm text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg",
3121
- "aria-label": t("browserViewer.refreshBrowsers"),
3122
- children: /* @__PURE__ */ jsx2(RefreshCwIcon, { className: cn("size-3.5", props.refreshing && "animate-spin") })
3123
- }
3124
- ),
3125
- /* @__PURE__ */ jsx2(
3126
- BrowserLaunchMenu,
3127
- {
3128
- attachedBridges: props.attachedBridges,
3129
- attachedDevices: props.attachedDevices,
3130
- identities: props.identities,
3131
- creating: props.creating,
3132
- mutatingProfile: props.savingProfile,
3133
- onCreate: props.onCreate,
3134
- onRestore: (identity) => props.onUpdateProfile(identity, { status: "active" }),
3135
- setupUrl: props.setupUrl,
3136
- extensionName: props.extensionName
3137
- }
3138
- )
3139
- ] });
3140
- }
3141
- function BrowserUnselectedPanel(props) {
3142
- const t = useOpenGeniText();
3143
- return /* @__PURE__ */ jsx2("div", { className: "grid min-h-0 flex-1 place-items-center bg-og-bg p-6 text-center", children: /* @__PURE__ */ jsxs2("div", { className: "max-w-sm", children: [
3144
- /* @__PURE__ */ jsx2("span", { className: "mx-auto grid size-10 place-items-center rounded-og-md border border-og-border bg-og-surface-1 text-og-fg-muted", children: /* @__PURE__ */ jsx2(Globe2Icon, { className: "size-4.5" }) }),
3145
- props.unavailableBrowser ? /* @__PURE__ */ jsx2(BrowserUnavailableNotice, { session: props.unavailableBrowser }) : /* @__PURE__ */ jsx2("p", { className: "mt-3 text-og-menu font-medium text-og-fg", children: t("browserViewer.noBrowserForThisAgent") }),
3146
- /* @__PURE__ */ jsx2("p", { className: "mt-1 text-og-control leading-5 text-og-fg-muted", children: props.peerCount === 1 ? t("browserViewer.oneWorkspaceBrowserIsAvailable") : t("browserViewer.peercountWorkspaceBrowsersAreAvailable", {
3147
- peerCount: props.peerCount
3148
- }) }),
3149
- /* @__PURE__ */ jsxs2(
3150
- "button",
3151
- {
3152
- type: "button",
3153
- disabled: props.creating,
3154
- onClick: props.onCreate,
3155
- className: "mt-4 inline-flex h-8 items-center gap-1.5 rounded-og-sm border border-og-primary-border bg-og-primary px-3 text-og-control font-medium text-og-primary-fg transition hover:bg-og-primary-hover disabled:cursor-not-allowed disabled:opacity-50",
3156
- children: [
3157
- /* @__PURE__ */ jsx2(PlusIcon, { className: "size-3.5" }),
3158
- props.creating ? t("browserViewer.opening") : t("browserViewer.newBrowser")
3159
- ]
3160
- }
3161
- )
3162
- ] }) });
3163
- }
3164
- function BrowserUnavailableNotice({
3165
- session,
3166
- canOpenNewBrowser = true
3167
- }) {
3168
- const t = useOpenGeniText();
3169
- const reason = session.failureCode === "provider_deadline_rotation" ? t("browserViewer.theComputerRunningItReached") : session.failureCode === "source_placement_changed" ? t("browserViewer.thisChatMovedToAnother") : session.failureCode === "idle_released" ? t("browserViewer.itStoppedAfterItWent") : session.lifecycle === "failed" ? t("browserViewer.itStoppedUnexpectedly") : t("browserViewer.theConnectionToItWas");
3170
- return /* @__PURE__ */ jsxs2("div", { role: "status", children: [
3171
- /* @__PURE__ */ jsx2("p", { className: "mt-3 text-og-menu font-medium text-og-fg", children: t("browserViewer.browserUnavailable") }),
3172
- /* @__PURE__ */ jsx2("p", { className: "mt-1 break-words text-og-control leading-5 text-og-fg-muted", children: t(canOpenNewBrowser ? "browserViewer.nameReasonOpenANew" : "browserViewer.nameReason", {
3173
- name: session.name,
3174
- reason
3175
- }) })
3176
- ] });
3177
- }
3178
- function BrowserSessionGroup(props) {
3179
- const t = useOpenGeniText();
3180
- if (props.sessions.length === 0) return null;
3181
- return /* @__PURE__ */ jsxs2("div", { className: "py-1", children: [
3182
- /* @__PURE__ */ jsx2("p", { className: "px-2 pb-1 text-[10px] font-medium uppercase tracking-[0.12em] text-og-fg-subtle", children: props.label }),
3183
- props.sessions.map((session) => {
3184
- const identity = props.identities.find((candidate) => candidate.id === session.identityId);
3185
- const interventionCount = props.interventionCounts.get(session.id) ?? 0;
3186
- return /* @__PURE__ */ jsxs2(
3187
- "button",
3188
- {
3189
- type: "button",
3190
- "aria-label": `${session.name}${identity ? ` \xB7 ${identity.name}` : ""} \xB7 ${placementLabel(t, session)}`,
3191
- "aria-pressed": session.id === props.selectedId,
3192
- onClick: () => props.onSelect(session.id),
3193
- className: cn(
3194
- "flex w-full items-center gap-2 rounded-og-sm px-2 py-1.5 text-left transition hover:bg-og-surface-2",
3195
- session.id === props.selectedId && "bg-og-surface-2"
3196
- ),
3197
- children: [
3198
- /* @__PURE__ */ jsx2(
3199
- "span",
3200
- {
3201
- className: cn(
3202
- "size-1.5 rounded-full",
3203
- session.lifecycle === "active" ? "bg-og-status-running" : "bg-og-fg-subtle"
3204
- )
3205
- }
3206
- ),
3207
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
3208
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-control text-og-fg", children: session.name }),
3209
- /* @__PURE__ */ jsxs2("span", { className: "block truncate text-og-xs text-og-fg-subtle", children: [
3210
- identity ? `${identity.name} \xB7 ` : "",
3211
- placementLabel(t, session)
3212
- ] })
3213
- ] }),
3214
- interventionCount > 0 ? /* @__PURE__ */ jsx2("span", { className: "rounded-full bg-og-status-waiting/12 px-1.5 py-0.5 text-[10px] font-medium text-og-status-waiting", children: interventionCount }) : null
3215
- ]
3216
- },
3217
- session.id
3218
- );
3219
- })
3220
- ] });
3221
- }
3222
- function BrowserLaunchMenu(props) {
3223
- const t = useOpenGeniText();
3224
- const detailsRef = useViewerMenuDismiss();
3225
- const choose = (choice) => {
3226
- detailsRef.current?.removeAttribute("open");
3227
- props.onCreate(choice);
3228
- };
3229
- const restore = async (identity) => {
3230
- if (await props.onRestore(identity)) detailsRef.current?.removeAttribute("open");
3231
- };
3232
- const busy = props.creating || props.mutatingProfile;
3233
- const activeIdentities = props.identities.filter((identity) => identity.status === "active");
3234
- const archivedIdentities = props.identities.filter((identity) => identity.status === "archived");
3235
- return /* @__PURE__ */ jsxs2("details", { ref: detailsRef, className: cn(props.prominent && "mt-4 inline-block"), children: [
3236
- /* @__PURE__ */ jsxs2(
3237
- "summary",
3238
- {
3239
- onClick: (event) => {
3240
- if (busy) event.preventDefault();
3241
- },
3242
- className: cn(
3243
- "cursor-pointer list-none items-center justify-center gap-1.5 text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg [&::-webkit-details-marker]:hidden",
3244
- props.prominent ? "inline-flex h-8 rounded-og-sm border border-og-border bg-og-surface-1 px-3 text-og-control font-medium text-og-fg" : "grid size-7 place-items-center rounded-og-sm",
3245
- busy && "pointer-events-none opacity-50"
3246
- ),
3247
- "aria-label": t("browserViewer.newBrowser"),
3248
- children: [
3249
- busy ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ jsx2(PlusIcon, { className: "size-3.5" }),
3250
- props.prominent ? t("browserViewer.newBrowser") : null,
3251
- props.prominent ? /* @__PURE__ */ jsx2(ChevronDownIcon, { className: "size-3" }) : null
3252
- ]
3253
- }
3254
- ),
3255
- /* @__PURE__ */ jsxs2(
3256
- "div",
3257
- {
3258
- className: cn(
3259
- "absolute z-40 max-h-[calc(100%-3rem)] w-72 max-w-[calc(100%-1rem)] overflow-y-auto rounded-og-md border border-og-border bg-og-surface-1 p-1 text-left shadow-xl",
3260
- props.prominent ? "left-1/2 top-2 -translate-x-1/2" : "right-2 top-10"
3261
- ),
3262
- children: [
3263
- props.attachedDevices.length > 0 || props.attachedBridges.length > 0 ? /* @__PURE__ */ jsxs2("div", { className: "pb-1", children: [
3264
- /* @__PURE__ */ jsx2("p", { className: "px-2 pb-1 pt-1 text-[10px] font-medium uppercase tracking-[0.12em] text-og-fg-subtle", children: t("browserViewer.connectedChrome") }),
3265
- props.attachedDevices.map((device) => /* @__PURE__ */ jsxs2(
3266
- "button",
3267
- {
3268
- type: "button",
3269
- onClick: () => choose({ kind: "attached", device }),
3270
- className: "flex w-full items-center gap-2 rounded-og-sm px-2 py-2 text-left transition hover:bg-og-surface-2",
3271
- children: [
3272
- /* @__PURE__ */ jsx2(MonitorIcon, { className: "size-3.5 shrink-0 text-og-fg-muted" }),
3273
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
3274
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-control text-og-fg", children: device.profileLabel ?? device.name }),
3275
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-xs text-og-fg-subtle", children: t("browserViewer.openTabs", {
3276
- browserName: device.browserName,
3277
- count: device.tabCount
3278
- }) })
3279
- ] }),
3280
- /* @__PURE__ */ jsx2("span", { className: "size-1.5 shrink-0 rounded-full bg-og-status-running" })
3281
- ]
3282
- },
3283
- `${device.workspaceId}:${device.id}`
3284
- )),
3285
- props.attachedBridges.length > 0 ? props.setupUrl ? /* @__PURE__ */ jsxs2(
3286
- "a",
3287
- {
3288
- href: props.setupUrl,
3289
- target: "_blank",
3290
- rel: "noreferrer",
3291
- onClick: () => detailsRef.current?.removeAttribute("open"),
3292
- className: "flex w-full items-center gap-2 rounded-og-sm px-2 py-2 text-left transition hover:bg-og-surface-2",
3293
- children: [
3294
- /* @__PURE__ */ jsx2(PlusIcon, { className: "size-3.5 shrink-0 text-og-fg-muted" }),
3295
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
3296
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-control text-og-fg", children: props.attachedDevices.length > 0 ? t("browserViewer.connectAnotherChromeProfile") : t("browserViewer.connectThisChromeProfile") }),
3297
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-xs text-og-fg-subtle", children: t("browserViewer.machineConnectedChromeExtensionMissing") })
3298
- ] })
3299
- ]
3300
- }
3301
- ) : /* @__PURE__ */ jsxs2("div", { className: "flex w-full items-center gap-2 px-2 py-2 text-left", children: [
3302
- /* @__PURE__ */ jsx2(MonitorIcon, { className: "size-3.5 shrink-0 text-og-fg-muted" }),
3303
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
3304
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-control text-og-fg", children: t("browserViewer.chromeConnectionReady") }),
3305
- /* @__PURE__ */ jsx2("span", { className: "block text-og-xs leading-4 text-og-fg-subtle", children: t("browserViewer.installTheOpengeniBrowserExtension", {
3306
- extensionName: props.extensionName ?? "Opengeni Browser"
3307
- }) })
3308
- ] })
3309
- ] }) : null
3310
- ] }) : null,
3311
- /* @__PURE__ */ jsx2(
3312
- "p",
3313
- {
3314
- className: cn(
3315
- "px-2 pb-1 pt-1 text-[10px] font-medium uppercase tracking-[0.12em] text-og-fg-subtle",
3316
- (props.attachedDevices.length > 0 || props.attachedBridges.length > 0) && "border-t border-og-border"
3317
- ),
3318
- children: t("browserViewer.openIsolatedBrowser")
3319
- }
3320
- ),
3321
- /* @__PURE__ */ jsxs2(
3322
- "button",
3323
- {
3324
- type: "button",
3325
- onClick: () => choose({ kind: "clean" }),
3326
- className: "flex w-full items-center gap-2 rounded-og-sm px-2 py-2 text-left transition hover:bg-og-surface-2",
3327
- children: [
3328
- /* @__PURE__ */ jsx2(Globe2Icon, { className: "size-3.5 text-og-fg-muted" }),
3329
- /* @__PURE__ */ jsxs2("span", { children: [
3330
- /* @__PURE__ */ jsx2("span", { className: "block text-og-control text-og-fg", children: t("browserViewer.freshBrowser") }),
3331
- /* @__PURE__ */ jsx2("span", { className: "block text-og-xs text-og-fg-subtle", children: t("browserViewer.visualBrowserNoSavedState") })
3332
- ] })
3333
- ]
3334
- }
3335
- ),
3336
- activeIdentities.length > 0 ? /* @__PURE__ */ jsx2("div", { className: "mt-1 border-t border-og-border pt-1", children: activeIdentities.map((identity) => /* @__PURE__ */ jsxs2(
3337
- "button",
3338
- {
3339
- type: "button",
3340
- onClick: () => choose({ kind: "profile", identityId: identity.id }),
3341
- className: "flex w-full items-center gap-2 rounded-og-sm px-2 py-2 text-left transition hover:bg-og-surface-2",
3342
- children: [
3343
- /* @__PURE__ */ jsx2(UserRoundIcon, { className: "size-3.5 text-og-fg-muted" }),
3344
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0", children: [
3345
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-control text-og-fg", children: identity.name }),
3346
- /* @__PURE__ */ jsx2("span", { className: "block text-og-xs text-og-fg-subtle", children: identity.defaultRevisionId ? t("browserViewer.savedVersions", { count: identity.revisionCount }) : t("browserViewer.readyForFirstSignIn") })
3347
- ] })
3348
- ]
3349
- },
3350
- identity.id
3351
- )) }) : null,
3352
- archivedIdentities.length > 0 ? /* @__PURE__ */ jsxs2("details", { className: "mt-1 border-t border-og-border pt-1", children: [
3353
- /* @__PURE__ */ jsxs2("summary", { className: "flex cursor-pointer list-none items-center gap-1.5 rounded-og-sm px-2 py-1.5 text-og-xs text-og-fg-subtle transition hover:bg-og-surface-2 hover:text-og-fg [&::-webkit-details-marker]:hidden", children: [
3354
- /* @__PURE__ */ jsx2(ArchiveIcon, { className: "size-3" }),
3355
- " ",
3356
- t("browserViewer.hiddenProfilesLength", { length: archivedIdentities.length }),
3357
- /* @__PURE__ */ jsx2(ChevronDownIcon, { className: "ml-auto size-3" })
3358
- ] }),
3359
- archivedIdentities.map((identity) => /* @__PURE__ */ jsxs2(
3360
- "button",
3361
- {
3362
- type: "button",
3363
- disabled: busy,
3364
- onClick: () => void restore(identity),
3365
- className: "flex w-full items-center gap-2 rounded-og-sm px-2 py-2 text-left transition hover:bg-og-surface-2 disabled:opacity-50",
3366
- children: [
3367
- /* @__PURE__ */ jsx2(RotateCcwIcon, { className: "size-3.5 text-og-fg-muted" }),
3368
- /* @__PURE__ */ jsx2("span", { className: "min-w-0 flex-1 truncate text-og-control text-og-fg", children: t("browserViewer.restoreName", { name: identity.name }) })
3369
- ]
3370
- },
3371
- identity.id
3372
- ))
3373
- ] }) : null
3374
- ]
3375
- }
3376
- )
3377
- ] });
3378
- }
3379
- function BrowserProfileMenu(props) {
3380
- const t = useOpenGeniText();
3381
- const detailsRef = useViewerMenuDismiss();
3382
- const nameInputId = useId();
3383
- const [name, setName] = useState9("");
3384
- const attached = props.session?.placement.kind === "attached_device";
3385
- const canSave = (props.session?.capabilities.identityPublication ?? false) && props.identity?.status !== "archived";
3386
- const revisions = props.identity && props.history?.identityId === props.identity.id ? [...props.history.revisions].sort((left, right) => right.ordinal - left.ordinal) : [];
3387
- const save = async (newProfileName) => {
3388
- if (await props.onSave(newProfileName)) {
3389
- setName("");
3390
- detailsRef.current?.removeAttribute("open");
3391
- }
3392
- };
3393
- const openVersion = (identityId, baseRevisionId) => {
3394
- detailsRef.current?.removeAttribute("open");
3395
- props.onOpenVersion(identityId, baseRevisionId);
3396
- };
3397
- const versionLabel = attached ? "live" : props.identity ? props.baseRevisionOrdinal ? `v${props.baseRevisionOrdinal}` : props.session?.baseRevisionId ? "saved" : "unsaved" : "temporary";
3398
- return /* @__PURE__ */ jsxs2("details", { ref: detailsRef, className: "min-w-0", children: [
3399
- /* @__PURE__ */ jsxs2("summary", { className: "flex h-7 max-w-40 cursor-pointer list-none items-center gap-1.5 rounded-og-sm px-2 text-og-xs text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg [&::-webkit-details-marker]:hidden", children: [
3400
- props.saving ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3 animate-spin" }) : attached ? /* @__PURE__ */ jsx2(MonitorIcon, { className: "size-3" }) : /* @__PURE__ */ jsx2(UserRoundIcon, { className: "size-3" }),
3401
- /* @__PURE__ */ jsx2("span", { className: "truncate", children: attached ? props.session?.name : props.identity?.name ?? t("browserViewer.temporary") }),
3402
- attached || props.identity ? /* @__PURE__ */ jsxs2("span", { className: "shrink-0 text-og-fg-subtle", children: [
3403
- "\xB7 ",
3404
- versionLabel
3405
- ] }) : null,
3406
- /* @__PURE__ */ jsx2(ChevronDownIcon, { className: "size-3 shrink-0 text-og-fg-subtle" })
3407
- ] }),
3408
- /* @__PURE__ */ jsxs2("div", { className: "absolute right-2 top-10 z-40 max-h-[calc(100%-3rem)] w-72 max-w-[calc(100%-1rem)] overflow-y-auto rounded-og-md border border-og-border bg-og-surface-1 p-3 shadow-xl", children: [
3409
- /* @__PURE__ */ jsxs2("div", { className: "flex items-start gap-2", children: [
3410
- /* @__PURE__ */ jsx2("span", { className: "grid size-7 shrink-0 place-items-center rounded-og-sm bg-og-surface-2 text-og-fg-muted", children: attached ? /* @__PURE__ */ jsx2(MonitorIcon, { className: "size-3.5" }) : /* @__PURE__ */ jsx2(UserRoundIcon, { className: "size-3.5" }) }),
3411
- /* @__PURE__ */ jsxs2("div", { className: "min-w-0", children: [
3412
- /* @__PURE__ */ jsx2("p", { className: "truncate text-og-control font-medium text-og-fg", children: attached ? props.session?.name : props.identity?.name ?? t("browserViewer.temporaryBrowser") }),
3413
- /* @__PURE__ */ jsx2("p", { className: "mt-0.5 text-og-xs leading-4 text-og-fg-subtle", children: attached ? t("browserViewer.thisSessionDrivesTheExisting") : props.identity?.status === "archived" ? t("browserViewer.hiddenFromNewBrowsersThis") : props.identity ? props.baseRevisionOrdinal ? t("browserViewer.startedFromVersionBaserevisionordinal", {
3414
- baseRevisionOrdinal: props.baseRevisionOrdinal
3415
- }) : t("browserViewer.notSavedYet") : t("browserViewer.thisBrowserIsNotReusable") })
3416
- ] })
3417
- ] }),
3418
- props.identity && revisions.length > 0 ? /* @__PURE__ */ jsxs2("div", { className: "mt-3 border-t border-og-border pt-2", children: [
3419
- /* @__PURE__ */ jsx2("p", { className: "px-1 text-[10px] font-medium uppercase tracking-[0.12em] text-og-fg-subtle", children: t("browserViewer.savedVersions2") }),
3420
- /* @__PURE__ */ jsx2("div", { className: "mt-1 max-h-40 overflow-y-auto", children: revisions.map((revision) => {
3421
- const isDefault = revision.id === props.identity?.defaultRevisionId;
3422
- const isCurrent = revision.ordinal === props.baseRevisionOrdinal;
3423
- const materialization = revisionMaterializationSummary(t, revision);
3424
- return /* @__PURE__ */ jsxs2(
3425
- "div",
3426
- {
3427
- className: "flex w-full items-center gap-1 rounded-og-sm transition hover:bg-og-surface-2",
3428
- children: [
3429
- /* @__PURE__ */ jsxs2(
3430
- "button",
3431
- {
3432
- type: "button",
3433
- disabled: props.saving || props.identity?.status === "archived",
3434
- "aria-label": t("browserViewer.openNameVersionOrdinal", {
3435
- name: props.identity.name,
3436
- ordinal: revision.ordinal
3437
- }),
3438
- onClick: () => openVersion(props.identity.id, revision.id),
3439
- className: "flex min-w-0 flex-1 items-center gap-2 px-2 py-1.5 text-left disabled:opacity-50",
3440
- children: [
3441
- /* @__PURE__ */ jsx2("span", { className: "grid size-4 place-items-center text-og-fg-muted", children: isCurrent ? /* @__PURE__ */ jsx2(CheckIcon, { className: "size-3.5 text-og-accent" }) : null }),
3442
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
3443
- /* @__PURE__ */ jsx2("span", { className: "block text-og-control text-og-fg", children: t("browserViewer.versionOrdinal", { ordinal: revision.ordinal }) }),
3444
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-[10px] text-og-fg-subtle", children: materialization.label })
3445
- ] }),
3446
- isCurrent ? /* @__PURE__ */ jsx2("span", { className: "text-[10px] text-og-fg-subtle", children: t("browserViewer.current") }) : null
3447
- ]
3448
- }
3449
- ),
3450
- /* @__PURE__ */ jsx2(
3451
- "button",
3452
- {
3453
- type: "button",
3454
- disabled: isDefault || props.saving || props.identity?.status === "archived",
3455
- "aria-label": isDefault ? t("browserViewer.nameVersionOrdinalIsThe", {
3456
- name: props.identity.name,
3457
- ordinal: revision.ordinal
3458
- }) : t("browserViewer.useNameVersionOrdinalBy", {
3459
- name: props.identity.name,
3460
- ordinal: revision.ordinal
3461
- }),
3462
- title: isDefault ? t("browserViewer.defaultVersion") : t("browserViewer.useByDefault"),
3463
- onClick: () => void props.onUpdate(props.identity, { defaultRevisionId: revision.id }),
3464
- className: "mr-1 shrink-0 rounded-og-sm px-2 py-1 text-[10px] text-og-fg-subtle transition hover:bg-og-surface-3 hover:text-og-fg disabled:cursor-default disabled:opacity-70",
3465
- children: isDefault ? t("browserViewer.default") : t("browserViewer.makeDefault")
3466
- }
3467
- )
3468
- ]
3469
- },
3470
- revision.id
3471
- );
3472
- }) }),
3473
- /* @__PURE__ */ jsx2("p", { className: "mt-1 px-2 text-[10px] leading-4 text-og-fg-subtle", children: t("browserViewer.changingTheDefaultAffectsOnly") })
3474
- ] }) : props.identity && props.history?.identityId === props.identity.id && props.history.loading ? /* @__PURE__ */ jsxs2("p", { className: "mt-3 flex items-center gap-1.5 border-t border-og-border px-2 pt-2 text-og-xs text-og-fg-subtle", children: [
3475
- /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3 animate-spin" }),
3476
- " ",
3477
- t("browserViewer.loadingSavedVersions")
3478
- ] }) : null,
3479
- props.identity && props.authConnections.length > 0 ? /* @__PURE__ */ jsxs2("div", { className: "mt-3 border-t border-og-border pt-2", children: [
3480
- /* @__PURE__ */ jsx2("p", { className: "px-1 text-[10px] font-medium uppercase tracking-[0.12em] text-og-fg-subtle", children: t("browserViewer.loginHealth") }),
3481
- /* @__PURE__ */ jsx2("div", { className: "mt-1 space-y-1", children: props.authConnections.map((connection) => {
3482
- const health = siteAuthHealth(t, connection);
3483
- return /* @__PURE__ */ jsxs2(
3484
- "div",
3485
- {
3486
- className: "flex items-start gap-2 rounded-og-sm px-2 py-1.5",
3487
- children: [
3488
- /* @__PURE__ */ jsx2("span", { className: cn("mt-1 size-1.5 shrink-0 rounded-full", health.dotClass) }),
3489
- /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
3490
- /* @__PURE__ */ jsx2("span", { className: "block truncate text-og-control text-og-fg", children: connection.name }),
3491
- /* @__PURE__ */ jsxs2("span", { className: "block truncate text-[10px] text-og-fg-subtle", children: [
3492
- connection.accountLabel,
3493
- " \xB7 ",
3494
- health.label
3495
- ] })
3496
- ] })
3497
- ]
3498
- },
3499
- connection.id
3500
- );
3501
- }) })
3502
- ] }) : null,
3503
- canSave ? props.identity ? /* @__PURE__ */ jsxs2(
3504
- "button",
3505
- {
3506
- type: "button",
3507
- onClick: () => void save(),
3508
- disabled: props.saving,
3509
- className: "mt-3 flex h-8 w-full items-center justify-center gap-1.5 rounded-og-sm border border-og-border bg-og-surface-2 px-3 text-og-control font-medium text-og-fg transition hover:bg-og-surface-3 disabled:opacity-50",
3510
- children: [
3511
- props.saving ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ jsx2(SaveIcon, { className: "size-3.5" }),
3512
- props.saving ? t("browserViewer.savingBrowserVersion") : t("browserViewer.saveNewVersion")
3513
- ]
3514
- }
3515
- ) : /* @__PURE__ */ jsxs2(
3516
- "form",
3517
- {
3518
- className: "mt-3",
3519
- onSubmit: (event) => {
3520
- event.preventDefault();
3521
- if (name.trim()) void save(name);
3522
- },
3523
- children: [
3524
- /* @__PURE__ */ jsx2("label", { className: "text-og-xs font-medium text-og-fg-muted", htmlFor: nameInputId, children: t("browserViewer.profileName") }),
3525
- /* @__PURE__ */ jsxs2("div", { className: "mt-1 flex gap-1.5", children: [
3526
- /* @__PURE__ */ jsx2(
3527
- "input",
3528
- {
3529
- id: nameInputId,
3530
- value: name,
3531
- onInput: (event) => setName(event.currentTarget.value),
3532
- maxLength: 200,
3533
- placeholder: t("browserViewer.work"),
3534
- className: "h-8 min-w-0 flex-1 rounded-og-sm border border-og-border bg-og-bg px-2 text-og-control text-og-fg placeholder:text-og-fg-subtle focus:border-og-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent"
3535
- }
3536
- ),
3537
- /* @__PURE__ */ jsxs2(
3538
- "button",
3539
- {
3540
- type: "submit",
3541
- disabled: !name.trim() || props.saving,
3542
- className: "inline-flex h-8 items-center gap-1 rounded-og-sm border border-og-primary-border bg-og-primary text-og-primary-fg px-2.5 text-og-control font-medium transition hover:bg-og-primary-hover disabled:opacity-50",
3543
- children: [
3544
- props.saving ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ jsx2(SaveIcon, { className: "size-3.5" }),
3545
- t("browserViewer.save")
3546
- ]
3547
- }
3548
- )
3549
- ] })
3550
- ]
3551
- }
3552
- ) : /* @__PURE__ */ jsx2("p", { className: "mt-3 rounded-og-sm bg-og-surface-2 px-2.5 py-2 text-og-xs text-og-fg-subtle", children: attached ? t("browserViewer.chromeKeepsThisProfileS") : props.identity?.status === "archived" ? t("browserViewer.restoreThisProfileBeforeSaving") : t("browserViewer.thisBrowserCannotSaveReusable") }),
3553
- !attached && props.identity ? /* @__PURE__ */ jsxs2(
3554
- "button",
3555
- {
3556
- type: "button",
3557
- disabled: props.saving,
3558
- onClick: () => void props.onUpdate(props.identity, {
3559
- status: props.identity.status === "active" ? "archived" : "active"
3560
- }),
3561
- className: "mt-2 flex h-8 w-full items-center justify-center gap-1.5 rounded-og-sm px-3 text-og-control text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg disabled:opacity-50",
3562
- children: [
3563
- props.identity.status === "active" ? /* @__PURE__ */ jsx2(ArchiveIcon, { className: "size-3.5" }) : /* @__PURE__ */ jsx2(RotateCcwIcon, { className: "size-3.5" }),
3564
- props.identity.status === "active" ? t("browserViewer.hideFromNewBrowsers") : t("browserViewer.restoreProfile")
3565
- ]
3566
- }
3567
- ) : null,
3568
- canSave ? /* @__PURE__ */ jsx2("p", { className: "mt-2 text-[10px] leading-4 text-og-fg-subtle", children: t("browserViewer.savingRestartsThisBrowserSave") }) : null
3569
- ] })
3570
- ] });
3571
- }
3572
- function revisionMaterializationSummary(t, revision) {
3573
- const materializations = revision.components.map((component) => component.materialization);
3574
- const placementBound = materializations.find(
3575
- (materialization) => materialization.portability === "placement_bound"
3576
- );
3577
- if (placementBound) {
3578
- return {
3579
- label: placementBound.reason ? t("browserViewer.thisMachineOnlyReason", { reason: placementBound.reason }) : t("browserViewer.thisMachineOnly")
3580
- };
3581
- }
3582
- const providerBound = materializations.find(
3583
- (materialization) => materialization.portability === "provider_bound"
3584
- );
3585
- if (providerBound) {
3586
- return {
3587
- label: providerBound.reason ? t("browserViewer.providerBoundReason", { reason: providerBound.reason }) : t("browserViewer.providerBound")
3588
- };
3589
- }
3590
- return { label: t("browserViewer.portableBrowserData") };
3591
- }
3592
- function siteAuthHealth(t, connection) {
3593
- switch (connection.verificationState) {
3594
- case "verified":
3595
- return { label: t("browserViewer.verified"), dotClass: "bg-og-status-running" };
3596
- case "needs_repair":
3597
- return { label: t("browserViewer.signInNeedsAttention"), dotClass: "bg-og-status-waiting" };
3598
- case "failed":
3599
- return { label: t("browserViewer.verificationFailed"), dotClass: "bg-og-status-failed" };
3600
- case "unknown":
3601
- return { label: t("browserViewer.notCheckedYet"), dotClass: "bg-og-fg-subtle" };
3602
- }
3603
- }
3604
- function MenuButton(props) {
3605
- return /* @__PURE__ */ jsx2(
3606
- "button",
3607
- {
3608
- type: "button",
3609
- onClick: props.onClick,
3610
- disabled: props.disabled,
3611
- className: "flex h-7 flex-1 items-center justify-center gap-1 rounded-og-sm px-2 text-og-control text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg disabled:opacity-50",
3612
- children: props.children
3613
- }
3614
- );
3615
- }
3616
- function BrowserTabs(props) {
3617
- const t = useOpenGeniText();
3618
- const pages = props.targets.filter((target) => target.kind === "page" || target.kind === "popup");
3619
- return /* @__PURE__ */ jsxs2("div", { className: "flex h-9 shrink-0 items-end gap-px overflow-x-auto border-b border-og-border bg-og-surface-1 px-1 pt-1", children: [
3620
- pages.map((target) => /* @__PURE__ */ jsxs2(
3621
- "div",
3622
- {
3623
- className: cn(
3624
- "group flex h-8 min-w-24 max-w-48 items-center rounded-t-og-sm border border-b-0 border-transparent px-2",
3625
- target.id === props.selectedTargetId ? "border-og-border bg-og-bg text-og-fg" : "text-og-fg-muted hover:bg-og-surface-1"
3626
- ),
3627
- children: [
3628
- /* @__PURE__ */ jsx2(
3629
- "button",
3630
- {
3631
- type: "button",
3632
- onClick: () => props.onSelect(target.id),
3633
- className: "min-w-0 flex-1 truncate text-left text-og-control",
3634
- children: target.title || shortUrl(target.url)
3635
- }
3636
- ),
3637
- props.tabControl ? /* @__PURE__ */ jsx2(
3638
- "button",
3639
- {
3640
- type: "button",
3641
- onClick: () => props.onClose(target.id),
3642
- disabled: props.mutating,
3643
- className: "ml-1 grid size-4 shrink-0 place-items-center rounded opacity-0 transition hover:bg-og-surface-3 group-hover:opacity-100 focus:opacity-100 disabled:opacity-30",
3644
- "aria-label": t("browserViewer.closeTitle", { title: target.title || "tab" }),
3645
- children: /* @__PURE__ */ jsx2(XIcon, { className: "size-3" })
3646
- }
3647
- ) : null
3648
- ]
3649
- },
3650
- target.id
3651
- )),
3652
- props.tabControl ? /* @__PURE__ */ jsx2(
3653
- "button",
3654
- {
3655
- type: "button",
3656
- onClick: props.onOpen,
3657
- disabled: props.mutating,
3658
- className: "mb-1 grid size-6 shrink-0 place-items-center rounded-og-sm text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg disabled:opacity-40",
3659
- "aria-label": t("browserViewer.newTab"),
3660
- children: /* @__PURE__ */ jsx2(PlusIcon, { className: "size-3.5" })
3661
- }
3662
- ) : null
3663
- ] });
3664
- }
3665
- function BrowserAddressBar(props) {
3666
- const t = useOpenGeniText();
3667
- const [draft, setDraft] = useState9(props.target?.url ?? "");
3668
- const focusedRef = useRef9(false);
3669
- const historyPendingRef = useRef9(false);
3670
- const [historyPending, setHistoryPending] = useState9(false);
3671
- useEffect9(() => {
3672
- if (!focusedRef.current) setDraft(props.target?.url ?? "");
3673
- }, [props.target?.id, props.target?.url]);
3674
- const submit = (event) => {
3675
- event.preventDefault();
3676
- if (historyPendingRef.current) return;
3677
- const normalized = normalizeBrowserAddress(draft);
3678
- if (normalized) props.onNavigate(normalized);
3679
- };
3680
- const navigateHistory = async (direction) => {
3681
- if (!props.target || props.loading || historyPendingRef.current) return;
3682
- historyPendingRef.current = true;
3683
- setHistoryPending(true);
3684
- try {
3685
- await props.onHistory(direction);
3686
- } finally {
3687
- historyPendingRef.current = false;
3688
- setHistoryPending(false);
3689
- }
3690
- };
3691
- return /* @__PURE__ */ jsxs2(
3692
- "form",
3693
- {
3694
- onSubmit: submit,
3695
- "aria-busy": historyPending || void 0,
3696
- className: "flex h-10 shrink-0 items-center gap-1.5 border-b border-og-border bg-og-bg px-2",
3697
- children: [
3698
- ["back", "forward"].map((direction) => /* @__PURE__ */ jsx2(
3699
- "button",
3700
- {
3701
- type: "button",
3702
- onClick: () => void navigateHistory(direction),
3703
- disabled: !props.target || props.loading,
3704
- "aria-disabled": historyPending || void 0,
3705
- className: cn(
3706
- "grid size-7 shrink-0 place-items-center rounded-og-sm text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent disabled:opacity-35",
3707
- historyPending && "opacity-50"
3708
- ),
3709
- "aria-label": direction === "back" ? t("browserViewer.back") : t("browserViewer.forward"),
3710
- title: direction === "back" ? t("browserViewer.back") : t("browserViewer.forward"),
3711
- children: direction === "back" ? /* @__PURE__ */ jsx2(ArrowLeftIcon, { className: "size-3.5" }) : /* @__PURE__ */ jsx2(ArrowRightIcon, { className: "size-3.5" })
3712
- },
3713
- direction
3714
- )),
3715
- /* @__PURE__ */ jsx2(
3716
- "button",
3717
- {
3718
- type: "button",
3719
- onClick: props.onReload,
3720
- disabled: !props.target || props.loading || historyPending,
3721
- className: "grid size-7 shrink-0 place-items-center rounded-og-sm text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg disabled:opacity-35",
3722
- "aria-label": t("browserViewer.reload"),
3723
- children: /* @__PURE__ */ jsx2(
3724
- RefreshCwIcon,
3725
- {
3726
- className: cn("size-3.5", (props.loading || historyPending) && "animate-spin")
3727
- }
3728
- )
3729
- }
3730
- ),
3731
- /* @__PURE__ */ jsxs2("div", { className: "flex h-7 min-w-0 flex-1 items-center gap-2 rounded-og-sm border border-og-border bg-og-surface-1 px-2 focus-within:border-og-accent/60", children: [
3732
- /* @__PURE__ */ jsx2(Globe2Icon, { className: "size-3 shrink-0 text-og-fg-subtle" }),
3733
- /* @__PURE__ */ jsx2(
3734
- "input",
3735
- {
3736
- value: draft,
3737
- onChange: (event) => setDraft(event.target.value),
3738
- onFocus: () => {
3739
- focusedRef.current = true;
3740
- },
3741
- onBlur: () => {
3742
- focusedRef.current = false;
3743
- },
3744
- onKeyDown: (event) => {
3745
- if (event.key !== "Enter") return;
3746
- event.preventDefault();
3747
- if (historyPendingRef.current) return;
3748
- const normalized = normalizeBrowserAddress(draft);
3749
- if (normalized) props.onNavigate(normalized);
3750
- },
3751
- disabled: !props.target,
3752
- className: "min-w-0 flex-1 bg-transparent text-og-control text-og-fg placeholder:text-og-fg-subtle focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent disabled:opacity-50",
3753
- "aria-label": t("browserViewer.address"),
3754
- spellCheck: false,
3755
- placeholder: t("browserViewer.searchOrEnterAddress")
3756
- }
3757
- )
3758
- ] })
3759
- ]
3760
- }
3761
- );
3762
- }
3763
- function BrowserViewport(props) {
3764
- const t = useOpenGeniText();
3765
- const canvasRef = useRef9(null);
3766
- const inputRef = useRef9(null);
3767
- const [selectPopup, setSelectPopup] = useState9(null);
3768
- const inputSequenceRef = useRef9(0);
3769
- const dismissSelectPopup = useCallback8(() => {
3770
- inputSequenceRef.current += 1;
3771
- setSelectPopup({ observation: null, anchor: null });
3772
- }, []);
3773
- const composingRef = useRef9(false);
3774
- const pointerStartRef = useRef9(null);
3775
- const lastClickRef = useRef9(null);
3776
- const wheelRef = useRef9(null);
3777
- const pendingTextRef = useRef9(null);
3778
- const actionRef = useRef9(props.onAction);
3779
- const readClipboardRef = useRef9(props.onReadClipboard);
3780
- const observeInputRef = useRef9(props.onObserveForInput);
3781
- const errorRef = useRef9(props.onError);
3782
- const actionTailRef = useRef9(Promise.resolve());
3783
- const actionQueueEpochRef = useRef9(0);
3784
- const queuedTypingRef = useRef9(null);
3785
- const queuedFrameRef = useRef9(null);
3786
- const currentFrameRef = useRef9(props.frame);
3787
- const paintedFrameRef = useRef9(null);
3788
- const [paintedFrame, setPaintedFrame] = useState9(null);
3789
- const decodingFrameRef = useRef9(false);
3790
- const mountedRef = useRef9(true);
3791
- actionRef.current = props.onAction;
3792
- readClipboardRef.current = props.onReadClipboard;
3793
- observeInputRef.current = props.onObserveForInput;
3794
- errorRef.current = props.onError;
3795
- const clearBufferedInput = useCallback8(() => {
3796
- dismissSelectPopup();
3797
- if (wheelRef.current?.timer) clearTimeout(wheelRef.current.timer);
3798
- if (pendingTextRef.current?.timer) clearTimeout(pendingTextRef.current.timer);
3799
- wheelRef.current = null;
3800
- pendingTextRef.current = null;
3801
- queuedTypingRef.current = null;
3802
- pointerStartRef.current = null;
3803
- lastClickRef.current = null;
3804
- composingRef.current = false;
3805
- if (inputRef.current) inputRef.current.value = "";
3806
- }, [dismissSelectPopup]);
3807
- const paintQueuedFrames = useCallback8(() => {
3808
- if (decodingFrameRef.current) return;
3809
- decodingFrameRef.current = true;
3810
- void (async () => {
3811
- try {
3812
- while (mountedRef.current) {
3813
- const frame = queuedFrameRef.current;
3814
- queuedFrameRef.current = null;
3815
- if (!frame) break;
3816
- let objectUrl = null;
3817
- try {
3818
- const blob = new Blob([frame.data], {
3819
- type: frame.mediaType
3820
- });
3821
- if (typeof createImageBitmap === "function") {
3822
- const bitmap = await createImageBitmap(blob);
3823
- try {
3824
- const canvas2 = canvasRef.current;
3825
- if (mountedRef.current && canvas2 && currentFrameRef.current && sameBrowserDocument(frame, currentFrameRef.current)) {
3826
- paintCanvas(canvas2, bitmap, frame.width, frame.height);
3827
- paintedFrameRef.current = frame;
3828
- setPaintedFrame(frame);
3829
- }
3830
- } finally {
3831
- bitmap.close();
3832
- }
3833
- continue;
3834
- }
3835
- objectUrl = URL.createObjectURL(blob);
3836
- const image = await loadImage(objectUrl);
3837
- const canvas = canvasRef.current;
3838
- if (mountedRef.current && canvas && currentFrameRef.current && sameBrowserDocument(frame, currentFrameRef.current)) {
3839
- paintCanvas(canvas, image, frame.width, frame.height);
3840
- paintedFrameRef.current = frame;
3841
- setPaintedFrame(frame);
3842
- }
3843
- } catch (cause) {
3844
- if (mountedRef.current && currentFrameRef.current && sameBrowserDocument(frame, currentFrameRef.current))
3845
- errorRef.current(cause);
3846
- } finally {
3847
- if (objectUrl) URL.revokeObjectURL(objectUrl);
3848
- }
3849
- }
3850
- } finally {
3851
- decodingFrameRef.current = false;
3852
- if (mountedRef.current && queuedFrameRef.current) paintQueuedFrames();
3853
- }
3854
- })();
3855
- }, []);
3856
- useLayoutEffect2(() => {
3857
- const keyboardInput = inputRef.current;
3858
- const focusHandoff = props.focusHandoffRef;
3859
- mountedRef.current = true;
3860
- if (focusHandoff.current === props.focusScope) {
3861
- keyboardInput?.focus({ preventScroll: true });
3862
- }
3863
- focusHandoff.current = null;
3864
- return () => {
3865
- if (document.activeElement === keyboardInput) {
3866
- focusHandoff.current = props.focusScope;
3867
- }
3868
- mountedRef.current = false;
3869
- actionQueueEpochRef.current += 1;
3870
- queuedFrameRef.current = null;
3871
- clearBufferedInput();
3872
- };
3873
- }, [clearBufferedInput, props.focusHandoffRef, props.focusScope]);
3874
- useLayoutEffect2(() => {
3875
- if (currentFrameRef.current && !props.frame) {
3876
- actionQueueEpochRef.current += 1;
3877
- clearBufferedInput();
3878
- }
3879
- currentFrameRef.current = props.frame;
3880
- if (!props.frame) {
3881
- queuedFrameRef.current = null;
3882
- paintedFrameRef.current = null;
3883
- setPaintedFrame(null);
3884
- return;
3885
- }
3886
- queuedFrameRef.current = props.frame;
3887
- paintQueuedFrames();
3888
- }, [clearBufferedInput, paintQueuedFrames, props.frame]);
3889
- const enqueue = useCallback8(
3890
- (action, frame, after, selectAnchor) => {
3891
- const inputSequence = ++inputSequenceRef.current;
3892
- setSelectPopup({ observation: null, anchor: null });
3893
- frame = frame ? {
3894
- browserSessionId: frame.browserSessionId,
3895
- controllerGeneration: frame.controllerGeneration,
3896
- targetId: frame.targetId,
3897
- targetGeneration: frame.targetGeneration,
3898
- documentGeneration: frame.documentGeneration,
3899
- frameId: frame.frameId
3900
- } : null;
3901
- const epoch = actionQueueEpochRef.current;
3902
- const attachment = props.inputBatchAttachment;
3903
- const canBatchTyping = action.type === "type" && !after && frame && attachment?.fencedInputBatches === true && attachment.browserSessionId === frame.browserSessionId && attachment.controllerGeneration === frame.controllerGeneration && attachment.targetId === frame.targetId && Date.parse(attachment.expiresAt) > Date.now();
3904
- const previous = queuedTypingRef.current;
3905
- if (canBatchTyping && frame && previous && previous.epoch === epoch && sameFrameFence(previous.frame, frame) && previous.actions.length < 16) {
3906
- previous.actions.push(action);
3907
- return;
3908
- }
3909
- const typing = canBatchTyping && frame ? { actions: [action], frame, epoch } : null;
3910
- queuedTypingRef.current = typing;
3911
- actionTailRef.current = actionTailRef.current.catch(() => void 0).then(async () => {
3912
- if (!mountedRef.current || epoch !== actionQueueEpochRef.current) return;
3913
- if (queuedTypingRef.current === typing) queuedTypingRef.current = null;
3914
- const dispatchedAction = typing && typing.actions.length > 1 ? { type: "batch", actions: typing.actions, fenceEachAction: true } : action;
3915
- const receipt = await actionRef.current(dispatchedAction, frame);
3916
- if (!mountedRef.current || epoch !== actionQueueEpochRef.current) return;
3917
- const keyboardSelect = dispatchedAction.type === "press" && dispatchedAction.key === "Alt+ArrowDown";
3918
- if ((selectAnchor || keyboardSelect) && inputSequence === inputSequenceRef.current) {
3919
- const observation = keyboardSelect ? await observeInputRef.current() : receipt.observation;
3920
- if (mountedRef.current && epoch === actionQueueEpochRef.current && inputSequence === inputSequenceRef.current && observation) {
3921
- setSelectPopup({ observation, anchor: selectAnchor ?? null });
3922
- }
3923
- }
3924
- await after?.(receipt);
3925
- }).catch((cause) => {
3926
- if (!mountedRef.current || epoch !== actionQueueEpochRef.current) return;
3927
- actionQueueEpochRef.current += 1;
3928
- clearBufferedInput();
3929
- errorRef.current(cause);
3930
- });
3931
- },
3932
- [clearBufferedInput, props.inputBatchAttachment]
3933
- );
3934
- const point = useCallback8(
3935
- (frame, clientX, clientY) => browserPoint(canvasRef.current, frame, clientX, clientY),
3936
- []
3937
- );
3938
- const flushPendingText = useCallback8(() => {
3939
- const pending = pendingTextRef.current;
3940
- if (!pending) return;
3941
- clearTimeout(pending.timer);
3942
- pendingTextRef.current = null;
3943
- enqueue({ type: "type", text: pending.text }, pending.frame);
3944
- }, [enqueue]);
3945
- const flushPendingClick = useCallback8(() => {
3946
- lastClickRef.current = null;
3947
- }, []);
3948
- const flushPendingWheel = useCallback8(() => {
3949
- const batch = wheelRef.current;
3950
- if (!batch) return;
3951
- if (batch.timer) clearTimeout(batch.timer);
3952
- wheelRef.current = null;
3953
- enqueue(
3954
- {
3955
- type: "pointer",
3956
- action: "scroll",
3957
- x: batch.x,
3958
- y: batch.y,
3959
- deltaX: batch.deltaX,
3960
- deltaY: batch.deltaY
3961
- },
3962
- batch.frame
3963
- );
3964
- }, [enqueue]);
3965
- const pointerDown = (event) => {
3966
- const frame = paintedFrameRef.current;
3967
- if (!frame || event.button !== 0) return;
3968
- event.preventDefault();
3969
- dismissSelectPopup();
3970
- flushPendingWheel();
3971
- flushPendingText();
3972
- pointerStartRef.current = {
3973
- x: event.clientX,
3974
- y: event.clientY,
3975
- pointerId: event.pointerId,
3976
- frame
3977
- };
3978
- event.currentTarget.setPointerCapture?.(event.pointerId);
3979
- inputRef.current?.focus({ preventScroll: true });
3980
- };
3981
- const pointerUp = (event) => {
3982
- const start = pointerStartRef.current;
3983
- pointerStartRef.current = null;
3984
- if (!start || start.pointerId !== event.pointerId) return;
3985
- const from = point(start.frame, start.x, start.y);
3986
- const to = point(start.frame, event.clientX, event.clientY);
3987
- if (!from || !to) return;
3988
- if (Math.hypot(event.clientX - start.x, event.clientY - start.y) > 5) {
3989
- flushPendingClick();
3990
- enqueue(
3991
- {
3992
- type: "pointer",
3993
- action: "drag",
3994
- x: from.x,
3995
- y: from.y,
3996
- endX: to.x,
3997
- endY: to.y
3998
- },
3999
- start.frame
4000
- );
4001
- return;
4002
- }
4003
- const now = Date.now();
4004
- const previous = lastClickRef.current;
4005
- if (previous && now - previous.at < 280 && Math.hypot(previous.x - to.x, previous.y - to.y) < 6 && sameFrameFence(previous.frame, start.frame)) {
4006
- lastClickRef.current = null;
4007
- enqueue({ type: "pointer", action: "click", clickCount: 2, x: to.x, y: to.y }, start.frame);
4008
- return;
4009
- }
4010
- lastClickRef.current = { at: now, x: to.x, y: to.y, frame: start.frame };
4011
- const viewportBounds = canvasRef.current?.parentElement?.getBoundingClientRect();
4012
- enqueue(
4013
- { type: "pointer", action: "click", x: to.x, y: to.y },
4014
- start.frame,
4015
- void 0,
4016
- viewportBounds ? { x: event.clientX - viewportBounds.left, y: event.clientY - viewportBounds.top + 8 } : void 0
4017
- );
4018
- };
4019
- const contextMenu = (event) => {
4020
- event.preventDefault();
4021
- const frame = paintedFrameRef.current;
4022
- if (!frame) return;
4023
- flushPendingWheel();
4024
- flushPendingText();
4025
- flushPendingClick();
4026
- const at = point(frame, event.clientX, event.clientY);
4027
- if (at) enqueue({ type: "pointer", action: "click", x: at.x, y: at.y, button: "right" }, frame);
4028
- };
4029
- const wheel = (event) => {
4030
- dismissSelectPopup();
4031
- const frame = paintedFrameRef.current;
4032
- if (!frame) return;
4033
- const at = point(frame, event.clientX, event.clientY);
4034
- if (!at) return;
4035
- flushPendingText();
4036
- flushPendingClick();
4037
- event.preventDefault();
4038
- let pending = wheelRef.current;
4039
- if (pending && (!sameBrowserDocument(pending.frame, frame) || Math.hypot(pending.x - at.x, pending.y - at.y) > 6)) {
4040
- flushPendingWheel();
4041
- pending = null;
4042
- }
4043
- wheelRef.current = {
4044
- x: at.x,
4045
- y: at.y,
4046
- deltaX: (pending?.deltaX ?? 0) + event.deltaX,
4047
- deltaY: (pending?.deltaY ?? 0) + event.deltaY,
4048
- frame,
4049
- // Retain the first event's deadline so a continuous gesture keeps moving.
4050
- timer: pending?.timer ?? setTimeout(flushPendingWheel, 45)
4051
- };
4052
- };
4053
- const keyDown = (event) => {
4054
- if (composingRef.current || event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) {
4055
- return;
4056
- }
4057
- dismissSelectPopup();
4058
- flushPendingWheel();
4059
- const command = event.metaKey || event.ctrlKey;
4060
- if (props.clipboardEnabled && command && !event.altKey && ["c", "v"].includes(event.key.toLowerCase())) {
4061
- flushPendingText();
4062
- return;
4063
- }
4064
- const key = browserKey(event);
4065
- if (!key) return;
4066
- event.preventDefault();
4067
- flushPendingText();
4068
- flushPendingClick();
4069
- enqueue({ type: "press", key }, paintedFrameRef.current);
4070
- };
4071
- const finishCopy = useCallback8(async () => {
4072
- const clipboard = await readClipboardRef.current();
4073
- if (!mountedRef.current) return;
4074
- if (clipboard.text.length === 0) return;
4075
- if (!await copyTextToClipboard(clipboard.text)) {
4076
- throw new Error(t("browserViewer.browserTextCouldNotBe"));
4077
- }
4078
- }, [t]);
4079
- const copy = (event) => {
4080
- if (!props.clipboardEnabled) return;
4081
- event.preventDefault();
4082
- flushPendingWheel();
4083
- flushPendingText();
4084
- flushPendingClick();
4085
- enqueue({ type: "clipboard", operation: "copy" }, paintedFrameRef.current, finishCopy);
4086
- };
4087
- const paste = (event) => {
4088
- if (!props.clipboardEnabled) return;
4089
- event.preventDefault();
4090
- flushPendingWheel();
4091
- flushPendingText();
4092
- flushPendingClick();
4093
- enqueue(
4094
- {
4095
- type: "clipboard",
4096
- operation: "paste",
4097
- text: event.clipboardData.getData("text/plain")
4098
- },
4099
- paintedFrameRef.current
4100
- );
4101
- };
4102
- const input = (value, nativeComposing = false) => {
4103
- dismissSelectPopup();
4104
- if (composingRef.current || nativeComposing) return;
4105
- if (!value) return;
4106
- flushPendingWheel();
4107
- flushPendingClick();
4108
- const pending = pendingTextRef.current;
4109
- if (pending && sameOptionalBrowserFrame(pending.frame, paintedFrameRef.current)) {
4110
- clearTimeout(pending.timer);
4111
- pending.text += value;
4112
- pending.timer = setTimeout(flushPendingText, 16);
4113
- } else {
4114
- flushPendingText();
4115
- pendingTextRef.current = {
4116
- text: value,
4117
- frame: paintedFrameRef.current,
4118
- timer: setTimeout(flushPendingText, 16)
4119
- };
4120
- }
4121
- if (inputRef.current) inputRef.current.value = "";
4122
- };
4123
- const compositionStart = () => {
4124
- composingRef.current = true;
4125
- };
4126
- const compositionEnd = (event) => {
4127
- composingRef.current = false;
4128
- input(event.currentTarget.value || event.data);
4129
- };
4130
- const showCanvas = !props.controlUnavailable && props.frame !== null && paintedFrame !== null && sameBrowserDocument(props.frame, paintedFrame);
4131
- return /* @__PURE__ */ jsxs2("div", { className: "relative min-h-0 flex-1 overflow-hidden bg-black", children: [
4132
- /* @__PURE__ */ jsx2(
4133
- "canvas",
4134
- {
4135
- ref: canvasRef,
4136
- className: cn(
4137
- "absolute inset-0 m-auto max-h-full max-w-full touch-none focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-og-accent",
4138
- !showCanvas && "invisible"
4139
- ),
4140
- onPointerDown: pointerDown,
4141
- onPointerUp: pointerUp,
4142
- onPointerCancel: () => {
4143
- pointerStartRef.current = null;
4144
- },
4145
- onContextMenu: contextMenu,
4146
- onWheel: wheel,
4147
- "aria-label": t("browserViewer.interactiveBrowserPage")
4148
- }
4149
- ),
4150
- /* @__PURE__ */ jsx2(
4151
- "textarea",
4152
- {
4153
- ref: inputRef,
4154
- disabled: props.controlUnavailable,
4155
- defaultValue: "",
4156
- onInput: (event) => input(event.currentTarget.value, event.nativeEvent.isComposing),
4157
- onCompositionStart: compositionStart,
4158
- onCompositionEnd: compositionEnd,
4159
- onKeyDown: keyDown,
4160
- onCopy: copy,
4161
- onPaste: paste,
4162
- className: "pointer-events-none absolute left-1/2 top-1/2 size-px resize-none overflow-hidden opacity-0",
4163
- "aria-label": t("browserViewer.browserKeyboardInput"),
4164
- "aria-keyshortcuts": "Alt+ArrowDown",
4165
- autoCapitalize: "off",
4166
- autoCorrect: "off",
4167
- spellCheck: false
4168
- }
4169
- ),
4170
- !showCanvas ? /* @__PURE__ */ jsx2(
4171
- SemanticBrowserFallback,
4172
- {
4173
- observation: props.observation,
4174
- connectionState: props.connectionState,
4175
- supportsLiveFrames: props.supportsLiveFrames,
4176
- error: props.connectionError,
4177
- controlUnavailable: props.controlUnavailable,
4178
- onAction: (action) => enqueue(action, null),
4179
- onReconnect: props.onReconnect,
4180
- reconnectLabel: props.reconnectLabel,
4181
- reconnectMessage: props.reconnectMessage
4182
- }
4183
- ) : null,
4184
- showCanvas ? /* @__PURE__ */ jsx2(
4185
- BrowserSelectControl,
4186
- {
4187
- manualFallback: props.inputBatchAttachment?.focusedInputObservations !== true,
4188
- activation: selectPopup,
4189
- onDismiss: () => inputRef.current?.focus({ preventScroll: true }),
4190
- observe: async () => {
4191
- flushPendingText();
4192
- flushPendingWheel();
4193
- await actionTailRef.current;
4194
- if (!mountedRef.current) throw new Error(t("browserViewer.theBrowserPageChanged"));
4195
- return await props.onObserveForInput();
4196
- },
4197
- act: props.onSelectFromObservation
4198
- }
4199
- ) : null,
4200
- props.mutating ? /* @__PURE__ */ jsxs2("div", { className: "pointer-events-none absolute right-3 top-3 flex items-center gap-1.5 rounded-full border border-white/10 bg-black/65 px-2.5 py-1 text-[11px] text-white/80 backdrop-blur", children: [
4201
- /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3 animate-spin" }),
4202
- " ",
4203
- props.activityLabel ?? t("browserViewer.acting")
4204
- ] }) : null
4205
- ] });
4206
- }
4207
- function SemanticBrowserFallback(props) {
4208
- const t = useOpenGeniText();
4209
- const controlFailure = interactionControlFailureFromError(props.error);
4210
- const elsewhere = isSourcePlacementElsewhereError(props.error, "browser_session");
4211
- const { controlUnavailable } = props;
4212
- const generationLoss = Boolean(props.reconnectMessage);
4213
- const nodes = semanticNodes(
4214
- props.observation?.semantic?.kind === "snapshot" ? props.observation.semantic.roots : []
4215
- );
4216
- const interactive = nodes.filter((node) => node.actions.includes("click")).slice(0, 8);
4217
- return /* @__PURE__ */ jsx2("div", { className: "absolute inset-0 grid place-items-center bg-og-bg p-6", children: /* @__PURE__ */ jsxs2("div", { className: "w-full max-w-md rounded-og-lg border border-og-border bg-og-surface-1 p-4 shadow-lg", children: [
4218
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
4219
- props.error ? /* @__PURE__ */ jsx2(CircleAlertIcon, { className: "size-4 text-og-danger" }) : props.connectionState === "semantic" ? /* @__PURE__ */ jsx2(ZapIcon, { className: "size-4 text-og-fg-muted" }) : /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-4 animate-spin text-og-fg-muted" }),
4220
- /* @__PURE__ */ jsx2("p", { className: "text-og-menu font-medium text-og-fg", children: generationLoss ? t("browserViewer.chromeReconnectedOpenAFresh") : controlUnavailable ? t("browserViewer.browserControlsUnavailable") : props.error ? props.supportsLiveFrames ? t("browserViewer.liveViewDisconnected") : t("browserViewer.browserUnavailable") : props.connectionState === "semantic" ? t("browserViewer.semanticBrowser") : browserConnectionLabel(t, props.connectionState) })
4221
- ] }),
4222
- props.error || props.reconnectMessage ? /* @__PURE__ */ jsx2("p", { className: "mt-2 text-og-control leading-5 text-og-fg-muted", children: props.reconnectMessage ?? (elsewhere ? t("browserViewer.chatIsOnAnotherComputer") : controlFailure?.message ?? props.error?.message) }) : null,
4223
- interactive.length > 0 && !controlUnavailable ? /* @__PURE__ */ jsxs2("div", { className: "mt-3 border-t border-og-border pt-3", children: [
4224
- /* @__PURE__ */ jsx2("p", { className: "mb-2 text-og-xs text-og-fg-subtle", children: props.supportsLiveFrames ? t("browserViewer.pageControlsRemainAvailable") : t("browserViewer.availablePageControls") }),
4225
- /* @__PURE__ */ jsx2("div", { className: "flex flex-wrap gap-1.5", children: interactive.map((node) => /* @__PURE__ */ jsx2(
4226
- "button",
4227
- {
4228
- type: "button",
4229
- onClick: () => props.onAction({
4230
- type: "click",
4231
- locator: { kind: "ref", ref: node.ref }
4232
- }),
4233
- className: "rounded-og-sm border border-og-border bg-og-surface-1 px-2 py-1 text-og-control text-og-fg transition hover:bg-og-surface-2",
4234
- children: node.name || node.role
4235
- },
4236
- node.ref
4237
- )) })
4238
- ] }) : null,
4239
- props.error && (!generationLoss || props.reconnectLabel) ? /* @__PURE__ */ jsx2(
4240
- "button",
4241
- {
4242
- type: "button",
4243
- onClick: props.onReconnect,
4244
- className: "mt-3 text-og-control font-medium og-link",
4245
- children: props.reconnectLabel ?? (controlFailure?.retryable === false ? t("browserViewer.tryAgain") : t("browserViewer.reconnect"))
4246
- }
4247
- ) : null
4248
- ] }) });
4249
- }
4250
- function BrowserStatusBar(props) {
4251
- const t = useOpenGeniText();
4252
- const errors = (props.observation?.diagnostics.consoleErrorCount ?? 0) + (props.observation?.diagnostics.pageErrorCount ?? 0);
4253
- const failed = props.observation?.diagnostics.failedRequestCount ?? 0;
4254
- return /* @__PURE__ */ jsxs2("div", { className: "flex h-7 shrink-0 items-center gap-2 border-t border-og-border bg-og-surface-1 px-2 text-og-xs text-og-fg-subtle", children: [
4255
- /* @__PURE__ */ jsx2(
4256
- "span",
4257
- {
4258
- className: cn(
4259
- "size-1.5 rounded-full",
4260
- props.connectionState === "live" || props.connectionState === "semantic" ? "bg-og-status-running" : "bg-og-fg-subtle"
4261
- )
4262
- }
4263
- ),
4264
- /* @__PURE__ */ jsx2("span", { children: props.connectionState === "live" ? t("browserViewer.live") : props.connectionState === "semantic" ? t("browserViewer.semantic") : browserConnectionLabel(t, props.connectionState) }),
4265
- props.inputFailure ? /* @__PURE__ */ jsx2("span", { className: "text-og-status-failed", children: props.inputFailure.state === "failed" ? t("browserViewer.inputFailed") : t("browserViewer.inputResultUnknown") }) : null,
4266
- props.showProfile ? /* @__PURE__ */ jsx2("span", { children: props.profile?.name ?? t("browserViewer.temporaryBrowser") }) : null,
4267
- /* @__PURE__ */ jsx2("span", { className: "min-w-0 flex-1 truncate", children: props.target?.title }),
4268
- props.refreshing ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3 animate-spin" }) : null,
4269
- props.onOpenComputer ? /* @__PURE__ */ jsxs2(
4270
- "button",
4271
- {
4272
- type: "button",
4273
- onClick: props.onOpenComputer,
4274
- className: "flex items-center gap-1 rounded px-1.5 py-0.5 transition hover:bg-og-surface-2 hover:text-og-fg",
4275
- "aria-label": t("browserViewer.openThisBrowserWindowIn"),
4276
- children: [
4277
- /* @__PURE__ */ jsx2(MonitorIcon, { className: "size-3" }),
4278
- t("browserViewer.desktop")
4279
- ]
4280
- }
4281
- ) : null,
4282
- props.onDiagnostics ? /* @__PURE__ */ jsxs2(
4283
- "button",
4284
- {
4285
- type: "button",
4286
- onClick: props.onDiagnostics,
4287
- "aria-expanded": props.diagnosticsOpen,
4288
- "aria-controls": "browser-diagnostics-drawer",
4289
- className: cn(
4290
- "flex items-center gap-1 rounded px-1.5 py-0.5 transition hover:bg-og-surface-2 hover:text-og-fg",
4291
- props.diagnosticsOpen && "bg-og-surface-2 text-og-fg"
4292
- ),
4293
- children: [
4294
- /* @__PURE__ */ jsx2(BugIcon, { className: "size-3" }),
4295
- errors + failed > 0 ? errors + failed : t("browserViewer.debug")
4296
- ]
4297
- }
4298
- ) : null
4299
- ] });
4300
- }
4301
- function BrowserDiagnosticsDrawer(props) {
4302
- const t = useOpenGeniText();
4303
- const session = props.session;
4304
- const diagnostics = props.observation?.diagnostics;
4305
- const semanticMode = props.observation?.semantic ? t("browserViewer.semanticPageStructureAvailable") : props.observation?.screenshot ? t("browserViewer.visualFallbackInUse") : t("browserViewer.waitingForPageObservation");
4306
- return /* @__PURE__ */ jsxs2(
4307
- "aside",
4308
- {
4309
- id: "browser-diagnostics-drawer",
4310
- role: "region",
4311
- "aria-label": t("browserViewer.browserDiagnostics"),
4312
- className: "absolute inset-y-0 right-0 z-40 flex min-h-0 w-full max-w-md flex-col border-l border-og-border bg-og-surface-1 shadow-2xl",
4313
- children: [
4314
- /* @__PURE__ */ jsxs2("div", { className: "flex min-h-11 shrink-0 items-center gap-2 border-b border-og-border px-3 py-2", children: [
4315
- /* @__PURE__ */ jsx2(BugIcon, { className: "size-4 shrink-0 text-og-fg-muted" }),
4316
- /* @__PURE__ */ jsxs2("div", { className: "min-w-0 flex-1", children: [
4317
- /* @__PURE__ */ jsx2("p", { className: "text-og-control font-semibold text-og-fg", children: t("browserViewer.browserDiagnostics") }),
4318
- /* @__PURE__ */ jsx2("p", { className: "truncate text-og-xs text-og-fg-subtle", children: props.target?.title || shortUrl(props.target?.url ?? "") || t("browserViewer.currentTab") })
4319
- ] }),
4320
- /* @__PURE__ */ jsx2(
4321
- "button",
4322
- {
4323
- type: "button",
4324
- onClick: props.onRefresh,
4325
- disabled: props.state.loading,
4326
- className: "grid size-7 shrink-0 place-items-center rounded-og-sm text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg disabled:opacity-40",
4327
- "aria-label": t("browserViewer.refreshBrowserDiagnostics"),
4328
- children: /* @__PURE__ */ jsx2(RefreshCwIcon, { className: cn("size-3.5", props.state.loading && "animate-spin") })
4329
- }
4330
- ),
4331
- /* @__PURE__ */ jsx2(
4332
- "button",
4333
- {
4334
- type: "button",
4335
- onClick: props.onClose,
4336
- className: "grid size-7 shrink-0 place-items-center rounded-og-sm text-og-fg-muted transition hover:bg-og-surface-2 hover:text-og-fg",
4337
- "aria-label": t("browserViewer.closeBrowserDiagnostics"),
4338
- children: /* @__PURE__ */ jsx2(XIcon, { className: "size-3.5" })
4339
- }
4340
- )
4341
- ] }),
4342
- /* @__PURE__ */ jsxs2("div", { className: "min-h-0 flex-1 overflow-y-auto", children: [
4343
- /* @__PURE__ */ jsxs2("section", { className: "border-b border-og-border p-3", "aria-labelledby": "browser-runtime-title", children: [
4344
- /* @__PURE__ */ jsx2(
4345
- "h3",
4346
- {
4347
- id: "browser-runtime-title",
4348
- className: "text-[10px] font-semibold uppercase tracking-[0.14em] text-og-fg-subtle",
4349
- children: t("browserViewer.runtime")
4350
- }
4351
- ),
4352
- /* @__PURE__ */ jsxs2("dl", { className: "mt-2 grid grid-cols-[7rem_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-og-xs", children: [
4353
- /* @__PURE__ */ jsx2(
4354
- DiagnosticFact,
4355
- {
4356
- label: t("browserViewer.engine"),
4357
- value: browserEngineLabel(t, session)
4358
- }
4359
- ),
4360
- /* @__PURE__ */ jsx2(
4361
- DiagnosticFact,
4362
- {
4363
- label: t("browserViewer.driver"),
4364
- value: session?.driverId ?? t("browserViewer.unavailable")
4365
- }
4366
- ),
4367
- /* @__PURE__ */ jsx2(
4368
- DiagnosticFact,
4369
- {
4370
- label: t("browserViewer.placement"),
4371
- value: placementLabel(t, session ?? void 0)
4372
- }
4373
- ),
4374
- /* @__PURE__ */ jsx2(
4375
- DiagnosticFact,
4376
- {
4377
- label: t("browserViewer.profile"),
4378
- value: props.profile ? `${props.profile.name}${props.baseRevisionOrdinal ? ` \xB7 v${props.baseRevisionOrdinal}` : ""}` : t("browserViewer.temporary")
4379
- }
4380
- ),
4381
- /* @__PURE__ */ jsx2(
4382
- DiagnosticFact,
4383
- {
4384
- label: t("browserViewer.controller"),
4385
- value: shortGeneration(t, session?.controller?.controllerGeneration)
4386
- }
4387
- ),
4388
- /* @__PURE__ */ jsx2(
4389
- DiagnosticFact,
4390
- {
4391
- label: t("browserViewer.network"),
4392
- value: session?.networkRouteId ? t("browserViewer.customRoute") : t("browserViewer.placementDefault")
4393
- }
4394
- ),
4395
- /* @__PURE__ */ jsx2(DiagnosticFact, { label: t("browserViewer.observation"), value: semanticMode })
4396
- ] })
4397
- ] }),
4398
- /* @__PURE__ */ jsxs2("section", { className: "border-b border-og-border p-3", "aria-labelledby": "browser-page-title", children: [
4399
- /* @__PURE__ */ jsx2(
4400
- "h3",
4401
- {
4402
- id: "browser-page-title",
4403
- className: "text-[10px] font-semibold uppercase tracking-[0.14em] text-og-fg-subtle",
4404
- children: t("browserViewer.tabDiagnostics")
4405
- }
4406
- ),
4407
- /* @__PURE__ */ jsx2("p", { className: "mt-1 text-og-xs text-og-fg-subtle", children: t("browserViewer.includesEarlierPagesInThis") }),
4408
- /* @__PURE__ */ jsxs2("dl", { className: "mt-2 grid grid-cols-2 gap-2", children: [
4409
- /* @__PURE__ */ jsx2(
4410
- DiagnosticCount,
4411
- {
4412
- label: t("browserViewer.consoleErrors"),
4413
- value: diagnostics?.consoleErrorCount
4414
- }
4415
- ),
4416
- /* @__PURE__ */ jsx2(
4417
- DiagnosticCount,
4418
- {
4419
- label: t("browserViewer.pageErrors"),
4420
- value: diagnostics?.pageErrorCount
4421
- }
4422
- ),
4423
- /* @__PURE__ */ jsx2(
4424
- DiagnosticCount,
4425
- {
4426
- label: t("browserViewer.failedRequests"),
4427
- value: diagnostics?.failedRequestCount
4428
- }
4429
- ),
4430
- /* @__PURE__ */ jsx2(
4431
- DiagnosticCount,
4432
- {
4433
- label: t("browserViewer.downloads"),
4434
- value: diagnostics?.downloadCount
4435
- }
4436
- )
4437
- ] }),
4438
- session?.failureCode ? /* @__PURE__ */ jsx2("p", { className: "mt-2 rounded-og-sm border border-og-danger/30 bg-og-danger/5 px-2.5 py-2 text-og-xs text-og-danger", children: t("browserViewer.browserStateFailurecode", { failureCode: session.failureCode }) }) : null
4439
- ] }),
4440
- props.downloadsEnabled ? /* @__PURE__ */ jsx2(
4441
- BrowserDownloadsPanel,
4442
- {
4443
- downloads: props.downloads,
4444
- loading: props.downloadsLoading,
4445
- refreshing: props.downloadsRefreshing,
4446
- error: props.downloadsError,
4447
- savingDownloadIds: props.savingDownloadIds,
4448
- onSave: props.onSaveDownload,
4449
- onRefresh: props.onRefreshDownloads
4450
- }
4451
- ) : null,
4452
- /* @__PURE__ */ jsxs2("section", { className: "p-3", "aria-labelledby": "browser-events-title", children: [
4453
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between gap-2", children: [
4454
- /* @__PURE__ */ jsx2(
4455
- "h3",
4456
- {
4457
- id: "browser-events-title",
4458
- className: "text-[10px] font-semibold uppercase tracking-[0.14em] text-og-fg-subtle",
4459
- children: t("browserViewer.recentEvents")
4460
- }
4461
- ),
4462
- props.state.batch?.truncated ? /* @__PURE__ */ jsx2("span", { className: "text-[10px] text-og-fg-subtle", children: t("browserViewer.newest100") }) : null
4463
- ] }),
4464
- props.state.loading && !props.state.batch ? /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 py-6 text-og-control text-og-fg-muted", children: [
4465
- /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3.5 animate-spin" }),
4466
- " ",
4467
- t("browserViewer.loadingDiagnostics")
4468
- ] }) : props.state.error ? /* @__PURE__ */ jsxs2("div", { className: "py-5", children: [
4469
- /* @__PURE__ */ jsx2("p", { className: "text-og-control text-og-danger", children: props.state.error.message }),
4470
- /* @__PURE__ */ jsx2(
4471
- "button",
4472
- {
4473
- type: "button",
4474
- onClick: props.onRefresh,
4475
- className: "mt-2 text-og-control font-medium og-link",
4476
- children: t("browserViewer.tryAgain")
4477
- }
4478
- )
4479
- ] }) : props.state.batch?.entries.length ? /* @__PURE__ */ jsx2("ol", { className: "mt-2 space-y-2", children: props.state.batch.entries.map((entry) => /* @__PURE__ */ jsxs2(
4480
- "li",
4481
- {
4482
- className: "rounded-og-sm border border-og-border bg-og-bg p-2.5",
4483
- children: [
4484
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 text-[10px] text-og-fg-subtle", children: [
4485
- /* @__PURE__ */ jsx2(
4486
- "span",
4487
- {
4488
- className: cn(
4489
- "font-semibold uppercase tracking-wide",
4490
- diagnosticTone(entry.level)
4491
- ),
4492
- children: diagnosticKindLabel(t, entry.kind)
4493
- }
4494
- ),
4495
- /* @__PURE__ */ jsx2("span", { className: "ml-auto", children: formatDiagnosticTime(t, entry.occurredAt) })
4496
- ] }),
4497
- /* @__PURE__ */ jsx2("p", { className: "mt-1 whitespace-pre-wrap break-words text-og-xs leading-5 text-og-fg", children: entry.message }),
4498
- entry.url || entry.filename || entry.method || entry.status ? /* @__PURE__ */ jsx2("p", { className: "mt-1 truncate font-og-mono text-[10px] text-og-fg-subtle", children: [entry.method, entry.status, entry.filename, entry.url].filter((value) => value !== null).join(" \xB7 ") }) : null
4499
- ]
4500
- },
4501
- entry.sequence
4502
- )) }) : /* @__PURE__ */ jsx2("p", { className: "py-6 text-og-control text-og-fg-muted", children: t("browserViewer.noDiagnosticsForThisTab") })
4503
- ] })
4504
- ] })
4505
- ]
4506
- }
4507
- );
4508
- }
4509
- function BrowserDownloadsPanel(props) {
4510
- const t = useOpenGeniText();
4511
- const [paths, setPaths] = useState9({});
4512
- const [overwrite, setOverwrite] = useState9({});
4513
- const [savedPaths, setSavedPaths] = useState9({});
4514
- const [errors, setErrors] = useState9({});
4515
- const saving = useMemo2(() => new Set(props.savingDownloadIds), [props.savingDownloadIds]);
4516
- const save = (download) => {
4517
- const destinationPath = (paths[download.id] ?? defaultDownloadDestination(download)).trim();
4518
- if (!destinationPath || saving.has(download.id)) return;
4519
- setErrors((current) => ({ ...current, [download.id]: "" }));
4520
- void props.onSave(download.id, destinationPath, overwrite[download.id] ?? false).then((response) => {
4521
- setSavedPaths((current) => ({ ...current, [download.id]: response.destinationPath }));
4522
- }).catch((cause) => {
4523
- setErrors((current) => ({
4524
- ...current,
4525
- [download.id]: cause instanceof Error ? cause.message : t("browserViewer.couldNotSaveThisDownload")
4526
- }));
4527
- });
4528
- };
4529
- return /* @__PURE__ */ jsxs2("section", { className: "border-b border-og-border p-3", "aria-labelledby": "browser-downloads-title", children: [
4530
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
4531
- /* @__PURE__ */ jsx2(DownloadIcon, { className: "size-3.5 text-og-fg-muted" }),
4532
- /* @__PURE__ */ jsx2(
4533
- "h3",
4534
- {
4535
- id: "browser-downloads-title",
4536
- className: "text-[10px] font-semibold uppercase tracking-[0.14em] text-og-fg-subtle",
4537
- children: t("browserViewer.downloads")
4538
- }
4539
- ),
4540
- props.refreshing ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "ml-auto size-3 animate-spin text-og-fg-muted" }) : null
4541
- ] }),
4542
- props.loading ? /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 py-5 text-og-control text-og-fg-muted", children: [
4543
- /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3.5 animate-spin" }),
4544
- " ",
4545
- t("browserViewer.loadingDownloads")
4546
- ] }) : props.error ? /* @__PURE__ */ jsxs2("div", { className: "py-4", children: [
4547
- /* @__PURE__ */ jsx2("p", { className: "text-og-control text-og-danger", children: props.error.message }),
4548
- /* @__PURE__ */ jsx2(
4549
- "button",
4550
- {
4551
- type: "button",
4552
- onClick: props.onRefresh,
4553
- className: "mt-2 text-og-control font-medium og-link",
4554
- children: t("browserViewer.tryAgain")
4555
- }
4556
- )
4557
- ] }) : props.downloads.length === 0 ? /* @__PURE__ */ jsx2("p", { className: "py-4 text-og-control text-og-fg-muted", children: t("browserViewer.noFilesDownloadedYet") }) : /* @__PURE__ */ jsx2("ol", { className: "mt-2 space-y-2", children: props.downloads.map((download) => {
4558
- const destinationPath = paths[download.id] ?? defaultDownloadDestination(download);
4559
- const isSaving = saving.has(download.id);
4560
- const isSaved = savedPaths[download.id] === destinationPath;
4561
- return /* @__PURE__ */ jsxs2(
4562
- "li",
4563
- {
4564
- className: "rounded-og-sm border border-og-border bg-og-bg p-2.5",
4565
- children: [
4566
- /* @__PURE__ */ jsxs2("div", { className: "flex min-w-0 items-start gap-2", children: [
4567
- /* @__PURE__ */ jsx2("span", { className: "mt-0.5 grid size-6 shrink-0 place-items-center rounded bg-og-surface-2 text-og-fg-muted", children: isSaved ? /* @__PURE__ */ jsx2(FileCheck2Icon, { className: "size-3.5 text-og-status-idle" }) : /* @__PURE__ */ jsx2(DownloadIcon, { className: "size-3.5" }) }),
4568
- /* @__PURE__ */ jsxs2("div", { className: "min-w-0 flex-1", children: [
4569
- /* @__PURE__ */ jsx2(
4570
- "p",
4571
- {
4572
- className: "truncate text-og-xs font-medium text-og-fg",
4573
- title: download.filename,
4574
- children: download.filename
4575
- }
4576
- ),
4577
- /* @__PURE__ */ jsx2("p", { className: "mt-0.5 text-[10px] text-og-fg-subtle", children: downloadStatusLabel(t, download) })
4578
- ] })
4579
- ] }),
4580
- download.status === "completed" ? /* @__PURE__ */ jsxs2("div", { className: "mt-2", children: [
4581
- /* @__PURE__ */ jsxs2("div", { className: "flex gap-1.5", children: [
4582
- /* @__PURE__ */ jsx2(
4583
- "input",
4584
- {
4585
- type: "text",
4586
- value: destinationPath,
4587
- onInput: (event) => {
4588
- const value = event.currentTarget.value;
4589
- setPaths((current) => ({ ...current, [download.id]: value }));
4590
- setErrors((current) => ({ ...current, [download.id]: "" }));
4591
- },
4592
- onKeyDown: (event) => {
4593
- if (event.key === "Enter") save(download);
4594
- },
4595
- disabled: isSaving,
4596
- "aria-label": t("browserViewer.workspacePathForFilename", {
4597
- filename: download.filename
4598
- }),
4599
- className: "h-7 min-w-0 flex-1 rounded-og-sm border border-og-border bg-og-surface-1 px-2 font-og-mono text-[10px] text-og-fg transition focus:border-og-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent disabled:opacity-50"
4600
- }
4601
- ),
4602
- /* @__PURE__ */ jsxs2(
4603
- "button",
4604
- {
4605
- type: "button",
4606
- onClick: () => save(download),
4607
- disabled: isSaving || !destinationPath.trim() || isSaved && !overwrite[download.id],
4608
- className: "inline-flex h-7 shrink-0 items-center gap-1 rounded-og-sm border border-og-border bg-og-surface-1 px-2 text-[10px] font-medium text-og-fg transition hover:bg-og-surface-2 disabled:opacity-40",
4609
- children: [
4610
- isSaving ? /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3 animate-spin" }) : /* @__PURE__ */ jsx2(SaveIcon, { className: "size-3" }),
4611
- isSaving ? t("browserViewer.saving") : isSaved ? t("browserViewer.saved") : overwrite[download.id] ? t("browserViewer.replace") : t("browserViewer.save")
4612
- ]
4613
- }
4614
- )
4615
- ] }),
4616
- /* @__PURE__ */ jsxs2("label", { className: "mt-1.5 flex w-fit items-center gap-1.5 text-[10px] text-og-fg-subtle", children: [
4617
- /* @__PURE__ */ jsx2(
4618
- "input",
4619
- {
4620
- type: "checkbox",
4621
- checked: overwrite[download.id] ?? false,
4622
- onChange: (event) => {
4623
- setOverwrite((current) => ({
4624
- ...current,
4625
- [download.id]: event.currentTarget.checked
4626
- }));
4627
- setErrors((current) => ({ ...current, [download.id]: "" }));
4628
- },
4629
- disabled: isSaving,
4630
- className: "size-3 accent-og-accent"
4631
- }
4632
- ),
4633
- t("browserViewer.replaceAnExistingWorkspaceFile")
4634
- ] }),
4635
- errors[download.id] ? /* @__PURE__ */ jsx2("p", { className: "mt-1.5 break-words text-[10px] text-og-danger", children: errors[download.id] }) : null
4636
- ] }) : null
4637
- ]
4638
- },
4639
- download.id
4640
- );
4641
- }) })
4642
- ] });
4643
- }
4644
- function downloadStatusLabel(t, download) {
4645
- if (download.status === "completed") return formatBytes(download.receivedBytes);
4646
- if (download.status === "in_progress") {
4647
- const received = formatBytes(download.receivedBytes);
4648
- return download.totalBytes === null ? t("browserViewer.downloadingReceived", { received }) : t("browserViewer.downloadingReceivedOfBytes", {
4649
- received,
4650
- bytes: formatBytes(download.totalBytes)
4651
- });
4652
- }
4653
- if (download.status === "cancelled") return t("browserViewer.cancelled");
4654
- if (download.status === "unavailable") return t("browserViewer.noLongerAvailable");
4655
- return t("browserViewer.downloadFailed");
4656
- }
4657
- function defaultDownloadDestination(download) {
4658
- const leaf = download.filename.split(/[\\/]/u).at(-1)?.trim() ?? "";
4659
- const portable = leaf.normalize("NFC").replace(/[<>:"|?*\u0000-\u001f\u007f]/gu, "-").replace(/[ .]+$/u, "");
4660
- if (portable.length === 0 || /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/iu.test(portable)) {
4661
- return `download-${download.id.slice(0, 8)}`;
4662
- }
4663
- return portable;
4664
- }
4665
- function DiagnosticFact(props) {
4666
- return /* @__PURE__ */ jsxs2(Fragment2, { children: [
4667
- /* @__PURE__ */ jsx2("dt", { className: "text-og-fg-subtle", children: props.label }),
4668
- /* @__PURE__ */ jsx2("dd", { className: "min-w-0 truncate text-og-fg", title: props.value, children: props.value })
4669
- ] });
4670
- }
4671
- function DiagnosticCount(props) {
4672
- const t = useOpenGeniText();
4673
- return /* @__PURE__ */ jsxs2("div", { className: "rounded-og-sm border border-og-border bg-og-bg px-2.5 py-2", children: [
4674
- /* @__PURE__ */ jsx2("dt", { className: "text-[10px] text-og-fg-subtle", children: props.label }),
4675
- /* @__PURE__ */ jsx2(
4676
- "dd",
4677
- {
4678
- className: cn(
4679
- "mt-0.5 text-og-sm font-semibold",
4680
- props.value ? "text-og-fg" : "text-og-fg-muted"
4681
- ),
4682
- children: props.value ?? t("browserViewer.unavailable")
4683
- }
4684
- )
4685
- ] });
4686
- }
4687
- function browserEngineLabel(t, session) {
4688
- if (!session) return t("browserViewer.unavailable");
4689
- const version = session.engineVersion ? ` ${session.engineVersion}` : "";
4690
- return `${session.engine}${version} \xB7 ${session.headless ? "headless" : "headed"}`;
4691
- }
4692
- function shortGeneration(t, value) {
4693
- if (!value) return t("browserViewer.unavailable");
4694
- return value.length > 16 ? `${value.slice(0, 8)}\u2026${value.slice(-6)}` : value;
4695
- }
4696
- function diagnosticKindLabel(t, kind) {
4697
- switch (kind) {
4698
- case "console":
4699
- return t("browserViewer.console");
4700
- case "page_error":
4701
- return t("browserViewer.pageError");
4702
- case "failed_request":
4703
- return t("browserViewer.request");
4704
- case "download":
4705
- return t("browserViewer.download");
4706
- }
4707
- }
4708
- function diagnosticTone(level) {
4709
- if (level === "error") return "text-og-danger";
4710
- if (level === "warning") return "text-og-status-waiting";
4711
- return "text-og-fg-muted";
4712
- }
4713
- function formatDiagnosticTime(t, value) {
4714
- const date = new Date(value);
4715
- return Number.isNaN(date.getTime()) ? "" : date.toLocaleTimeString(t.locale, { hour: "2-digit", minute: "2-digit", second: "2-digit" });
4716
- }
4717
- function BrowserNotice(props) {
4718
- return /* @__PURE__ */ jsx2(
4719
- "div",
4720
- {
4721
- className: cn(
4722
- "grid h-full place-items-center bg-og-bg text-og-control text-og-fg-muted",
4723
- props.className
4724
- ),
4725
- children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
4726
- props.icon,
4727
- props.text
4728
- ] })
4729
- }
4730
- );
4731
- }
4732
- function paintCanvas(canvas, image, width, height) {
4733
- canvas.width = width;
4734
- canvas.height = height;
4735
- const context = canvas.getContext("2d", { alpha: false });
4736
- if (!context) throw new Error("Browser canvas is unavailable.");
4737
- context.drawImage(image, 0, 0, width, height);
4738
- }
4739
- function loadImage(url) {
4740
- return new Promise((resolve, reject) => {
4741
- const image = new Image();
4742
- image.onload = () => resolve(image);
4743
- image.onerror = () => reject(new Error("Browser frame image could not be decoded."));
4744
- image.src = url;
4745
- });
4746
- }
4747
- function browserPoint(canvas, frame, clientX, clientY) {
4748
- if (!canvas || !frame) return null;
4749
- const rect = canvas.getBoundingClientRect();
4750
- if (rect.width <= 0 || rect.height <= 0) return null;
4751
- const pixelX = (clientX - rect.left) / rect.width * frame.width;
4752
- const pixelY = (clientY - rect.top) / rect.height * frame.height;
4753
- return {
4754
- x: Math.max(0, pixelX / frame.deviceScaleFactor),
4755
- y: Math.max(0, pixelY / frame.deviceScaleFactor)
4756
- };
4757
- }
4758
- function semanticNodes(roots) {
4759
- const result = [];
4760
- const stack = [...roots].reverse();
4761
- while (stack.length > 0) {
4762
- const node = stack.pop();
4763
- result.push(node);
4764
- if (node.children) stack.push(...[...node.children].reverse());
4765
- }
4766
- return result;
4767
- }
4768
- function frameMatchesSelectedTarget(frame, session, target) {
4769
- return Boolean(
4770
- frame && session && target && frame.browserSessionId === session.id && frame.targetId === target.id && frame.targetGeneration === target.targetGeneration && frame.documentGeneration === target.documentGeneration
4771
- );
4772
- }
4773
- function sameFrameFence(left, right) {
4774
- return sameBrowserDocument(left, right) && left.frameId === right.frameId;
4775
- }
4776
- function sameBrowserDocument(left, right) {
4777
- return left.browserSessionId === right.browserSessionId && left.controllerGeneration === right.controllerGeneration && left.targetId === right.targetId && left.targetGeneration === right.targetGeneration && left.documentGeneration === right.documentGeneration;
4778
- }
4779
- function sameOptionalBrowserFrame(left, right) {
4780
- return left === null || right === null ? left === right : sameFrameFence(left, right);
4781
- }
4782
- function isLiveBrowser2(session) {
4783
- return !["ending", "ended", "failed", "lost"].includes(session.lifecycle);
4784
- }
4785
- function attachedChromeGenerationLoss(sessions) {
4786
- const lost = sessions.find(
4787
- (session) => session.lifecycle === "lost" && session.failureCode === "controller_transition_expired" && session.placement.kind === "attached_device"
4788
- );
4789
- return lost?.placement.kind === "attached_device" ? { deviceId: lost.placement.deviceId } : null;
4790
- }
4791
- function isAttachedChromeGenerationLossError(error) {
4792
- if (!error) return false;
4793
- return /placement instance changed|controller authority changed/i.test(error.message);
4794
- }
4795
- function countInterventions(interventions) {
4796
- const counts = /* @__PURE__ */ new Map();
4797
- for (const intervention of interventions) {
4798
- counts.set(intervention.resourceId, (counts.get(intervention.resourceId) ?? 0) + 1);
4799
- }
4800
- return counts;
4801
- }
4802
- function interventionTitle(t, intervention) {
4803
- switch (intervention.kind) {
4804
- case "manual_login":
4805
- return t("browserViewer.signInNeeded");
4806
- case "mfa":
4807
- return t("browserViewer.verificationNeeded");
4808
- case "external_action":
4809
- case "confirmation":
4810
- return t("browserViewer.actionNeeded");
4811
- case "other":
4812
- return t("browserViewer.browserNeedsYourHelp");
4813
- }
4814
- }
4815
- function placementLabel(t, session) {
4816
- if (!session) return "";
4817
- switch (session.placement.kind) {
4818
- case "sandbox_group":
4819
- return t("browserViewer.agentSandbox");
4820
- case "connected_machine":
4821
- return t("browserViewer.connectedMachine");
4822
- case "attached_device":
4823
- return t("browserViewer.yourBrowser");
4824
- case "external_provider":
4825
- return t("browserViewer.cloudBrowser");
4826
- }
4827
- }
4828
- function browserConnectionLabel(t, state) {
4829
- switch (state) {
4830
- case "attaching":
4831
- return t("browserViewer.openingBrowser");
4832
- case "connecting":
4833
- return t("browserViewer.connecting");
4834
- case "reconnecting":
4835
- return t("browserViewer.reconnecting");
4836
- case "error":
4837
- return t("browserViewer.disconnected");
4838
- case "semantic":
4839
- return t("browserViewer.semantic");
4840
- default:
4841
- return t("browserViewer.waitingForBrowser");
4842
- }
4843
- }
4844
- function shortUrl(value) {
4845
- try {
4846
- return new URL(value).hostname || value;
4847
- } catch {
4848
- return value;
4849
- }
4850
- }
4851
-
4852
- export {
4853
- useBrowserFrameStream,
4854
- useAttachedBrowsers,
4855
- useBrowserIdentities,
4856
- useBrowserDownloads,
4857
- useBrowserSession,
4858
- useBrowserSessions,
4859
- useSiteAuthConnections,
4860
- staleBrowserEndRetryDelayMs,
4861
- BrowserViewer
4862
- };
4863
- //# sourceMappingURL=chunk-WZ74QHLE.js.map