@openscout/scout 0.2.96 → 0.2.97

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 (305) hide show
  1. package/bin/scoutd +0 -0
  2. package/dist/build-manifest.json +3 -3
  3. package/dist/client/assets/{ActivityScreen-BnoaUkVZ.js → ActivityScreen-y-5DLleY.js} +1 -1
  4. package/dist/client/assets/{AddProjectForm-IqOtJfRs.js → AddProjectForm-r_1tVuWk.js} +1 -1
  5. package/dist/client/assets/{AgentAvatar-6-KBVKUu.js → AgentAvatar-B7c0egdP.js} +1 -1
  6. package/dist/client/assets/{AgentConfigurationScreen-CuZJy07q.js → AgentConfigurationScreen-BD7Unt2P.js} +1 -1
  7. package/dist/client/assets/{AgentDefinitionsWorkspace-Iyl4BesU.js → AgentDefinitionsWorkspace-BbcZc9Xk.js} +1 -1
  8. package/dist/client/assets/{AgentDetailCard-C9rn3Fj5.js → AgentDetailCard-B_KLcgsP.js} +1 -1
  9. package/dist/client/assets/{AgentFloorView-YT-Jjccf.js → AgentFloorView-DMFiHs21.js} +1 -1
  10. package/dist/client/assets/{AgentInfoScreen-Dr99gQEZ.js → AgentInfoScreen-DHGLRddI.js} +1 -1
  11. package/dist/client/assets/{AgentLaneCard-DI2iW9zO.js → AgentLaneCard-ajZvcfdW.js} +1 -1
  12. package/dist/client/assets/{AgentLaneChrome-D8bARHMx.js → AgentLaneChrome-CTp39syR.js} +1 -1
  13. package/dist/client/assets/{AgentLaneDetailSheet-52un7dKC.js → AgentLaneDetailSheet-DRc-TpMB.js} +1 -1
  14. package/dist/client/assets/{AgentLaneSummaryResize-CEBjmPTa.js → AgentLaneSummaryResize-VMNDo7kD.js} +1 -1
  15. package/dist/client/assets/AgentLanesEmbedScreen-C5k_dDS8.js +1 -0
  16. package/dist/client/assets/{AgentLanesPreflight-q20mTjms.js → AgentLanesPreflight-CFadSaia.js} +1 -1
  17. package/dist/client/assets/{AgentLanesView-CetZZDyF.js → AgentLanesView-u5vpLwQf.js} +1 -1
  18. package/dist/client/assets/{AgentLiveActions-DrEJDJef.js → AgentLiveActions-CsQA3pu_.js} +1 -1
  19. package/dist/client/assets/{AgentMasterScreen-DJPnstoD.js → AgentMasterScreen-C5WlWNmk.js} +1 -1
  20. package/dist/client/assets/{AgentSessions-DCPCG4xb.js → AgentSessions-BePq5Lgc.js} +1 -1
  21. package/dist/client/assets/{AgentsConsole-CsYOoFJi.js → AgentsConsole-BuiZ_bDo.js} +1 -1
  22. package/dist/client/assets/{AgentsScreen-k8LvBuU_.js → AgentsScreen-CRi-hG2k.js} +1 -1
  23. package/dist/client/assets/AgentsSubnav-DUsya4WK.js +1 -0
  24. package/dist/client/assets/{AstronautSuit-DbjQtfD_.js → AstronautSuit-Cjjcv6yQ.js} +1 -1
  25. package/dist/client/assets/{AtopView-Daq_ob3z.js → AtopView-PxWQd-sX.js} +1 -1
  26. package/dist/client/assets/{BackToPicker-CXZjBRAe.js → BackToPicker-Cto0Ioz9.js} +1 -1
  27. package/dist/client/assets/{BriefingDetailScreen-CUCXO-KH.js → BriefingDetailScreen-C29smC5d.js} +1 -1
  28. package/dist/client/assets/{BriefingsScreen-B5oMTGKv.js → BriefingsScreen-DNyFBrPn.js} +1 -1
  29. package/dist/client/assets/{BrokerMetadataPanel-BsiU8lTD.js → BrokerMetadataPanel-DbaCQlhw.js} +1 -1
  30. package/dist/client/assets/{BrokerScreen-BPbOHhCS.js → BrokerScreen-CS0s4Gm4.js} +1 -1
  31. package/dist/client/assets/{CastPicker-_5E5hNUe.js → CastPicker-CTBHjjGw.js} +1 -1
  32. package/dist/client/assets/{ChatCollapsedStrip-D-eXhzPf.js → ChatCollapsedStrip-D4rc7wBQ.js} +1 -1
  33. package/dist/client/assets/{CodeDiffPane-n7W4iGUG.js → CodeDiffPane-QvxCUzTi.js} +1 -1
  34. package/dist/client/assets/{CodeProjectPicker-CMsbSTDq.js → CodeProjectPicker-DplkpM7f.js} +1 -1
  35. package/dist/client/assets/{CodeScreen-CeuO3EhR.js → CodeScreen-CrR2JaVj.js} +1 -1
  36. package/dist/client/assets/{ConversationComposer-CXPKx86g.js → ConversationComposer-H8_hsYSc.js} +1 -1
  37. package/dist/client/assets/{ConversationFeedRows-WrH-YI3L.js → ConversationFeedRows-hlEFlURs.js} +1 -1
  38. package/dist/client/assets/{ConversationHeader-BQWzGzLK.js → ConversationHeader-B0ZBhE_E.js} +1 -1
  39. package/dist/client/assets/{ConversationPanels-Dujvnmup.js → ConversationPanels-fMo6Uy1v.js} +2 -2
  40. package/dist/client/assets/{ConversationScreen-CR9pWB65.js → ConversationScreen-CXAHQwQ3.js} +1 -1
  41. package/dist/client/assets/{ConversationStatus-DVzSb2Hv.js → ConversationStatus-DI5GCiyW.js} +1 -1
  42. package/dist/client/assets/{CrewAvatar-BwXjyg8N.js → CrewAvatar-CXJHLNVM.js} +1 -1
  43. package/dist/client/assets/CrewWorkspaces-Bz2Dcnt4.js +1 -0
  44. package/dist/client/assets/CrewWorkspaces-Diq11KDq.css +1 -0
  45. package/dist/client/assets/{DataTable-Bp8tU9AK.js → DataTable-DXIlOlVu.js} +1 -1
  46. package/dist/client/assets/{DispatchAftermath-B-6rmXzL.js → DispatchAftermath-CrELgl2e.js} +1 -1
  47. package/dist/client/assets/{DocumentFocusViewer-Do3wQ_3Z.js → DocumentFocusViewer-DFFE85Tq.js} +1 -1
  48. package/dist/client/assets/{EmbeddableSurfacesLab-C1orRyP9.js → EmbeddableSurfacesLab-DgpewB3y.js} +1 -1
  49. package/dist/client/assets/{EmptyState-CJzXj1l5.js → EmptyState-D9X16fKq.js} +1 -1
  50. package/dist/client/assets/{FileViewerPane-Df6VzXjA.js → FileViewerPane-CY0RN78e.js} +1 -1
  51. package/dist/client/assets/{FlightObserveScreen-6mGnmWQA.js → FlightObserveScreen-qyzHzxLa.js} +1 -1
  52. package/dist/client/assets/{FollowScreen-DvnxYLVh.js → FollowScreen-wZ-z67mX.js} +1 -1
  53. package/dist/client/assets/{HarnessMark-B979GCSB.js → HarnessMark-DAaWPiT_.js} +1 -1
  54. package/dist/client/assets/{HarnessesScreen-CHTuv8p6.js → HarnessesScreen-DbKkQM4o.js} +1 -1
  55. package/dist/client/assets/{HerdrSession-B3McuYgi.js → HerdrSession-CYKRfBad.js} +1 -1
  56. package/dist/client/assets/{HomeHero-CdUVPjkG.js → HomeHero-DYyd3cpz.js} +1 -1
  57. package/dist/client/assets/{HostAdvisorView-Bok5Sk5c.js → HostAdvisorView-NtM0bsg8.js} +1 -1
  58. package/dist/client/assets/{KnowledgeSearchInspector-B7XSoJsu.js → KnowledgeSearchInspector-CU6BCFcS.js} +1 -1
  59. package/dist/client/assets/{KnowledgeSearchScreen-D3o3IODW.js → KnowledgeSearchScreen-DvbRRPQB.js} +1 -1
  60. package/dist/client/assets/{LaneToolHoverCard-HByf2ndx.js → LaneToolHoverCard-Bo2Zl-1a.js} +1 -1
  61. package/dist/client/assets/{LaneTraceDetailSheet-BUgHz-sd.js → LaneTraceDetailSheet-C3C8UjXv.js} +1 -1
  62. package/dist/client/assets/{LaneTraceEventFocus-DM-hoPxG.js → LaneTraceEventFocus-Cek_64zR.js} +1 -1
  63. package/dist/client/assets/{MeshCanvas-DCLJRsBy.js → MeshCanvas-TvsID4fe.js} +1 -1
  64. package/dist/client/assets/{MeshCanvasMinimap-cEFS9eW7.js → MeshCanvasMinimap-CxqeVVco.js} +1 -1
  65. package/dist/client/assets/{MeshScreen-BcxPkhm6.js → MeshScreen-BJ-j9YXv.js} +1 -1
  66. package/dist/client/assets/{MeshTopologyView-CCRPd8PU.js → MeshTopologyView-BjprutE8.js} +2 -2
  67. package/dist/client/assets/{MessagesScreen-Bb5l13MO.js → MessagesScreen-CyNIZ3-X.js} +1 -1
  68. package/dist/client/assets/{MissionContextRail-DF0_kiU7.js → MissionContextRail-Be0uXljQ.js} +1 -1
  69. package/dist/client/assets/{MissionControlView-E3V7bENU.js → MissionControlView-Bj7cAbZd.js} +1 -1
  70. package/dist/client/assets/{MissionFocusOverlay-h15sQFvP.js → MissionFocusOverlay-DvTw6ts5.js} +1 -1
  71. package/dist/client/assets/{MissionLeftAgentRow-KPdk9rSa.js → MissionLeftAgentRow-B0QG7Gys.js} +1 -1
  72. package/dist/client/assets/{MissionLogPane-BbdDKjUl.js → MissionLogPane-EsM_S3ro.js} +1 -1
  73. package/dist/client/assets/{NewAgentModal-DfHxad34.js → NewAgentModal-Cqiq1CE1.js} +1 -1
  74. package/dist/client/assets/{NewChatComposer-_Stj0fZy.js → NewChatComposer-C_1op4dH.js} +1 -1
  75. package/dist/client/assets/{NewChatOrigin-B1u7ki70.js → NewChatOrigin-D7hwp6dm.js} +1 -1
  76. package/dist/client/assets/{ObserveEmbedScreen-Co0xTii6.js → ObserveEmbedScreen-CGHI_hb5.js} +1 -1
  77. package/dist/client/assets/{ObserveTextFlow-ZQWwrK3i.js → ObserveTextFlow-BcrGQet8.js} +2 -2
  78. package/dist/client/assets/{ObservedTopologyPanel-BJUhDSuQ.js → ObservedTopologyPanel-BhVsvwkh.js} +1 -1
  79. package/dist/client/assets/{OpenScoutAppShell-CUd2yOLu.js → OpenScoutAppShell-BtfvMkAp.js} +1 -1
  80. package/dist/client/assets/{OpsAgentsView-DI5wu1si.js → OpsAgentsView-DBYtmLnh.js} +1 -1
  81. package/dist/client/assets/OpsScreen-CuYVgkC_.js +1 -0
  82. package/dist/client/assets/OpsSubnav-BEU4kKXm.js +1 -0
  83. package/dist/client/assets/ProjectAgentProfile-BhXAZEkW.js +1 -0
  84. package/dist/client/assets/{ProjectAgentProfileBar-k2QHHHsQ.js → ProjectAgentProfileBar-uJw9Wdfk.js} +1 -1
  85. package/dist/client/assets/{ProjectAgentProfileHero-Bpxk1ui2.js → ProjectAgentProfileHero-CIMS4Dy_.js} +1 -1
  86. package/dist/client/assets/{ProjectsInbox-C_bMHLCc.js → ProjectsInbox-JgU0lrY8.js} +1 -1
  87. package/dist/client/assets/{ProjectsRail-J-aH_pxT.js → ProjectsRail-p99BRBOa.js} +1 -1
  88. package/dist/client/assets/ProjectsScreen-BB45DU53.js +1 -0
  89. package/dist/client/assets/{ProjectsThreadAside-_ourdM-Q.js → ProjectsThreadAside-BHDTJWOz.js} +1 -1
  90. package/dist/client/assets/{Provider-CtXJeLrP.js → Provider-Bu-C8Hxc.js} +1 -1
  91. package/dist/client/assets/{RailRow-CEH2MFBw.js → RailRow-ClMmtaIE.js} +1 -1
  92. package/dist/client/assets/{RawSessionsTable-CDyrom-F.js → RawSessionsTable-BtKdQPiv.js} +1 -1
  93. package/dist/client/assets/{RealtimeVoiceScreen-DBl3DN1H.js → RealtimeVoiceScreen-KPHJgO1l.js} +1 -1
  94. package/dist/client/assets/{RepoDiffEmbedScreen-kY2pHjIs.js → RepoDiffEmbedScreen-CjZ5ew3y.js} +1 -1
  95. package/dist/client/assets/{RepoDiffPageScreen-C6LhoKrn.js → RepoDiffPageScreen-CdTFfmbk.js} +1 -1
  96. package/dist/client/assets/{RepoDiffViewer-BhcIIQQg.js → RepoDiffViewer-BFperHQg.js} +1 -1
  97. package/dist/client/assets/{RepoDiffViewerLazy-Csy_j9LD.js → RepoDiffViewerLazy-BkBmbi1Z.js} +2 -2
  98. package/dist/client/assets/{ReposScreen-B_cB0zu7.js → ReposScreen-C8dT4bK0.js} +1 -1
  99. package/dist/client/assets/{ScoutDeckSurface-CSy_fjcG.js → ScoutDeckSurface-BcJsm2Kq.js} +1 -1
  100. package/dist/client/assets/{ScoutSurface-CQVcSrin.js → ScoutSurface-DmzEtrx8.js} +1 -1
  101. package/dist/client/assets/{ScoutbotFxLab-DqGiLYNy.js → ScoutbotFxLab-DU15Plja.js} +1 -1
  102. package/dist/client/assets/{SecondaryNav-BR4VRdgh.js → SecondaryNav-BrXMtvKE.js} +1 -1
  103. package/dist/client/assets/{SessionEmbedScreen-BTlZ9gAg.js → SessionEmbedScreen-Bt4flmAx.js} +1 -1
  104. package/dist/client/assets/{SessionObserve-dQDN23pP.js → SessionObserve-BCehTlO8.js} +1 -1
  105. package/dist/client/assets/{SessionObserveEvidence-BRBGKAgd.js → SessionObserveEvidence-Bb6U-dem.js} +1 -1
  106. package/dist/client/assets/{SessionRefScreen-COVQMbtE.js → SessionRefScreen-C8BiRVPx.js} +1 -1
  107. package/dist/client/assets/SessionsScreen-BNvjUflN.js +1 -0
  108. package/dist/client/assets/{SettingsDrawer-RGVK_bmE.js → SettingsDrawer-BieUmb8g.js} +1 -1
  109. package/dist/client/assets/{SettingsScreen-CCxzy5IU.js → SettingsScreen-3JvX1WFL.js} +1 -1
  110. package/dist/client/assets/{ShikiPane-DYI9Hkge.js → ShikiPane-DPWsVNtn.js} +1 -1
  111. package/dist/client/assets/{SlidePanel-B9ugxWgA.js → SlidePanel-BMRIR6bH.js} +1 -1
  112. package/dist/client/assets/{SpriteAvatar-z5hHesx9.js → SpriteAvatar-56DTXxSV.js} +1 -1
  113. package/dist/client/assets/{StatusPill-BFvMjmZV.js → StatusPill-BcuYUgsD.js} +1 -1
  114. package/dist/client/assets/{TailView-0uEIj2JH.js → TailView-BDy8c2VB.js} +1 -1
  115. package/dist/client/assets/{Terminal-DouZeNxc.js → Terminal-BlUQY9_Z.js} +1 -1
  116. package/dist/client/assets/{TerminalEmbedScreen-dMNUbzXr.js → TerminalEmbedScreen-DTjxktyr.js} +1 -1
  117. package/dist/client/assets/{TerminalHeaderMount-BL07cd0q.js → TerminalHeaderMount-Cy-uxkey.js} +1 -1
  118. package/dist/client/assets/{TextDocumentSurface-BflAwXeZ.js → TextDocumentSurface-BeSwe3Yl.js} +1 -1
  119. package/dist/client/assets/{TmuxPeek-BTnjOQi0.js → TmuxPeek-B4no_aGI.js} +1 -1
  120. package/dist/client/assets/{VoicePermissionsPanel-CgQ6GGS-.js → VoicePermissionsPanel-Bd16scwz.js} +1 -1
  121. package/dist/client/assets/{WorkDetailScreen-CaLG-zDs.js → WorkDetailScreen-DIFQufak.js} +1 -1
  122. package/dist/client/assets/{WorkFilesViewer-B9Sil_No.js → WorkFilesViewer-CT5XEFGf.js} +1 -1
  123. package/dist/client/assets/{activity-DcrMApUY.js → activity-CqZafWfx.js} +1 -1
  124. package/dist/client/assets/{addon-fit-DMVrz5Sv.js → addon-fit-CM6F_JRD.js} +1 -1
  125. package/dist/client/assets/{addon-webgl-BYvpZUyu.js → addon-webgl-DRTiePFC.js} +1 -1
  126. package/dist/client/assets/{agent-autocomplete-B-5QTeas.js → agent-autocomplete-DXUBnlkN.js} +1 -1
  127. package/dist/client/assets/{agent-essentials-D7KRGYvF.js → agent-essentials-vytdybaX.js} +1 -1
  128. package/dist/client/assets/{agent-master-model-DqjrVI2h.js → agent-master-model-DAZL92oe.js} +1 -1
  129. package/dist/client/assets/{agent-specialization-BujJVUTD.js → agent-specialization-BtxLN4UR.js} +1 -1
  130. package/dist/client/assets/agents-project-DgbqDc65.css +1 -0
  131. package/dist/client/assets/{arc.es-NHqHWohb.js → arc.es-Bh84oHJ7.js} +1 -1
  132. package/dist/client/assets/{arrow-down-CKtSUjmW.js → arrow-down-DvTsLokL.js} +1 -1
  133. package/dist/client/assets/{arrow-left-Czpf-AE4.js → arrow-left-DHfdXJVZ.js} +1 -1
  134. package/dist/client/assets/{arrow-right-BuzMnLYP.js → arrow-right-BBsrogWf.js} +1 -1
  135. package/dist/client/assets/{arrow-up-right-C6Wl-1uw.js → arrow-up-right-CY0Vw_67.js} +1 -1
  136. package/dist/client/assets/{bot-rd0awxD3.js → bot-DzkOUFBb.js} +1 -1
  137. package/dist/client/assets/{check-ofKUE8yH.js → check-DbIkldnK.js} +1 -1
  138. package/dist/client/assets/{chevron-down-wciXnOQz.js → chevron-down-C475vltS.js} +1 -1
  139. package/dist/client/assets/{chevron-right-D-HdlPg8.js → chevron-right-CnZRSd-V.js} +1 -1
  140. package/dist/client/assets/{chunk-HRAB3GC3-Tyv9rzx7.js → chunk-HRAB3GC3-DLNT8aOo.js} +1 -1
  141. package/dist/client/assets/{chunk-JTPDIGGW-BC2Mandc.js → chunk-JTPDIGGW-Ci5j4vzV.js} +3 -3
  142. package/dist/client/assets/{chunk-T65CQEWV-C1AWTYZZ.js → chunk-T65CQEWV-BtNvicWs.js} +1 -1
  143. package/dist/client/assets/{chunk-YOZR3KYS-DwHPHa6f.js → chunk-YOZR3KYS-DN5EJulq.js} +1 -1
  144. package/dist/client/assets/{clock-B88r8OrZ.js → clock-DVvENUU5.js} +1 -1
  145. package/dist/client/assets/{code-xml-D7pOQM9l.js → code-xml-CvKBY3KA.js} +1 -1
  146. package/dist/client/assets/{compass-Dt1AMXz2.js → compass-BcRI_YXo.js} +1 -1
  147. package/dist/client/assets/content--T3p6akp.js +1 -0
  148. package/dist/client/assets/content-4nFMLuzF.js +1 -0
  149. package/dist/client/assets/content-BJ4nHvcu.js +1 -0
  150. package/dist/client/assets/{content-nkx0swDe.js → content-BNyAjpUl.js} +1 -1
  151. package/dist/client/assets/content-BmGp9wNl.js +1 -0
  152. package/dist/client/assets/content-CBWhwaRo.js +1 -0
  153. package/dist/client/assets/{content-C9ijJxyl.js → content-CQlykFbe.js} +1 -1
  154. package/dist/client/assets/content-CevL0DgF.js +1 -0
  155. package/dist/client/assets/content-Ch8pf2bj.js +1 -0
  156. package/dist/client/assets/content-Cpvdcm_l.js +1 -0
  157. package/dist/client/assets/content-DfS3vgAu.js +1 -0
  158. package/dist/client/assets/content-DpQdNePJ.js +1 -0
  159. package/dist/client/assets/content-Dqpibejl.js +1 -0
  160. package/dist/client/assets/content-TV0nd6-r.js +1 -0
  161. package/dist/client/assets/{content-BWPNyXJ0.js → content-odbb5H4U.js} +1 -1
  162. package/dist/client/assets/content-uXHLPHe0.js +1 -0
  163. package/dist/client/assets/{conversation-icons-tp9BX6X2.js → conversation-icons-CBMKBGHd.js} +1 -1
  164. package/dist/client/assets/{conversation-model-Dc02NsGp.js → conversation-model-QsJVfSeG.js} +1 -1
  165. package/dist/client/assets/conversation-motion-features-BFLHX2eg.js +1 -0
  166. package/dist/client/assets/{copy-CWWAJ75H.js → copy-Cj-owMb-.js} +1 -1
  167. package/dist/client/assets/{cpu-DrqejfkB.js → cpu-DuD3RFX5.js} +1 -1
  168. package/dist/client/assets/{createLucideIcon-DezKXSG2.js → createLucideIcon-DthwWQIg.js} +1 -1
  169. package/dist/client/assets/{discover-C2CZO4Tk.js → discover-B3uQlh5L.js} +2 -2
  170. package/dist/client/assets/embed-entry-DkRcHKTh.js +2 -0
  171. package/dist/client/assets/{external-link-Dp_a2vRZ.js → external-link-C_nxk0MJ.js} +1 -1
  172. package/dist/client/assets/{eye-BRyD0jno.js → eye-FnaaPfja.js} +1 -1
  173. package/dist/client/assets/{file-code-corner-muIVH_xO.js → file-code-corner-DDPq4Cur.js} +1 -1
  174. package/dist/client/assets/{file-text-CqJgwxmv.js → file-text--hfhwZH1.js} +1 -1
  175. package/dist/client/assets/{gauge-hU--hKVP.js → gauge-BVEknshP.js} +1 -1
  176. package/dist/client/assets/{gestures-DN4hEeqv.js → gestures-3gw5VgUS.js} +1 -1
  177. package/dist/client/assets/{git-branch-CK5v8F2v.js → git-branch-DJyvr0k-.js} +1 -1
  178. package/dist/client/assets/{home-moving-signal-BjDtEJUP.js → home-moving-signal-BPqBoNSm.js} +1 -1
  179. package/dist/client/assets/{home-now-card-nF8OotI-.js → home-now-card-UspVW2-2.js} +1 -1
  180. package/dist/client/assets/{home-now-card-nano-C-r_bBg5.js → home-now-card-nano-G8kMB32m.js} +1 -1
  181. package/dist/client/assets/{hooks-D46bABUP.js → hooks-BMsQzo9j.js} +1 -1
  182. package/dist/client/assets/{index-DvLtl7rV.js → index-BI9AljSD.js} +2 -2
  183. package/dist/client/assets/{index-kL1WLbeS.js → index-C-v0Z6ZS.js} +1 -1
  184. package/dist/client/assets/{index-CPrU5q04.js → index-D9DzUORB.js} +1 -1
  185. package/dist/client/assets/index-DfsTyYDx.js +1 -0
  186. package/dist/client/assets/{inspector-panel-Dkc7rLvY.js → inspector-panel-CFSArQ8Y.js} +1 -1
  187. package/dist/client/assets/{keyboard-nav-BLYDhL3Z.js → keyboard-nav-e6yGeorb.js} +1 -1
  188. package/dist/client/assets/{lane-roster-store-DOdI1O13.js → lane-roster-store-Q7pcblY5.js} +1 -1
  189. package/dist/client/assets/{layers-CSsg3JVP.js → layers-Dz2dKOnU.js} +1 -1
  190. package/dist/client/assets/{layout-grid-DOChPJdZ.js → layout-grid-Bvs5fdB4.js} +1 -1
  191. package/dist/client/assets/{left-BNRFiRsb.js → left-B4Ak-Ibt.js} +1 -1
  192. package/dist/client/assets/{left-BggzhgXN.js → left-BMb493FZ.js} +1 -1
  193. package/dist/client/assets/{left-YT7mIGuH.js → left-BjFLvVOC.js} +1 -1
  194. package/dist/client/assets/{left-B3wSE6ql.js → left-CsXQ8Q3G.js} +1 -1
  195. package/dist/client/assets/left-FNH7faCI.js +1 -0
  196. package/dist/client/assets/{left-CARCvvxS.js → left-POkqE8gI.js} +1 -1
  197. package/dist/client/assets/{left-CpokZYHt.js → left-UulOTcWh.js} +1 -1
  198. package/dist/client/assets/{left-advisor-CCY0vkcO.js → left-advisor-CJkQS2d6.js} +1 -1
  199. package/dist/client/assets/{left-agents-trhO5sL8.js → left-agents-CFMxyEjT.js} +1 -1
  200. package/dist/client/assets/{left-default-CG33elBs.js → left-default-rnX5HANc.js} +1 -1
  201. package/dist/client/assets/{left-lanes-CitMgeTp.js → left-lanes-BpLXT_qH.js} +1 -1
  202. package/dist/client/assets/{left-mission-Zl2m_5eU.js → left-mission-B0bhseWw.js} +1 -1
  203. package/dist/client/assets/library-D1iXfda2.js +1 -0
  204. package/dist/client/assets/{loader-circle-pM56HNhR.js → loader-circle-B2W9DPG5.js} +1 -1
  205. package/dist/client/assets/{local-agents-C8xAhbO5.js → local-agents-DKr-gIDC.js} +1 -1
  206. package/dist/client/assets/{mentions-DG6OQrsc.js → mentions-DuLQnEcn.js} +1 -1
  207. package/dist/client/assets/{mesh-ops-BZ1h5RQs.js → mesh-ops-CRR-KnCG.js} +1 -1
  208. package/dist/client/assets/{mesh-view-store-ChUOASK8.js → mesh-view-store-CiET-yN8.js} +1 -1
  209. package/dist/client/assets/{message-circle-mZCv8tvB.js → message-circle-B2DoYKDO.js} +1 -1
  210. package/dist/client/assets/{message-markup-C2LQDm_k.js → message-markup-Cc_O-WdA.js} +1 -1
  211. package/dist/client/assets/{message-square-C7t_qtuj.js → message-square-O-Hu9Mk2.js} +1 -1
  212. package/dist/client/assets/{mission-control-store-nDLdUZPA.js → mission-control-store-DDAgWKUl.js} +1 -1
  213. package/dist/client/assets/{observe-BpEm1INu.js → observe-Da2mRAsc.js} +1 -1
  214. package/dist/client/assets/{page-status-E5jnk48p.js → page-status-Crtgjbq3.js} +1 -1
  215. package/dist/client/assets/{paperclip-C64lkcbM.js → paperclip-BudMKSyr.js} +1 -1
  216. package/dist/client/assets/{persistent-state-EHXw8WNy.js → persistent-state-xJz-qAFc.js} +1 -1
  217. package/dist/client/assets/{plus-Co-dqKul.js → plus-BJ1If8vj.js} +1 -1
  218. package/dist/client/assets/{profile-APxDsN2P.js → profile-B3qDSbrH.js} +1 -1
  219. package/dist/client/assets/{projects-inbox-Cg4X2lUQ.js → projects-inbox-CLek3QaG.js} +1 -1
  220. package/dist/client/assets/{proxy-BiW5suC7.js → proxy-1BABCaDb.js} +1 -1
  221. package/dist/client/assets/{radio-BOxBQX-T.js → radio-B5OpHrrK.js} +1 -1
  222. package/dist/client/assets/{refresh-cw-DMxGzDwn.js → refresh-cw-DmNAhaH0.js} +1 -1
  223. package/dist/client/assets/resolve-panes-DXw-cHaj.js +1 -0
  224. package/dist/client/assets/resolve-sidebar-context-CDdbRDEa.js +1 -0
  225. package/dist/client/assets/{right-Bmfd3pjP.js → right-BgJ4mQLf.js} +1 -1
  226. package/dist/client/assets/{right-Dz_xD0Vj.js → right-Bk6h7o-Z.js} +1 -1
  227. package/dist/client/assets/{right-CkCCPbCX.js → right-BrICCmEt.js} +1 -1
  228. package/dist/client/assets/{right-CdkcrmeD.js → right-C1QIbqFZ.js} +1 -1
  229. package/dist/client/assets/{right-BwlW6E57.js → right-CfliKiHY.js} +1 -1
  230. package/dist/client/assets/{right-BuCgE0fZ.js → right-CtOLXB9s.js} +1 -1
  231. package/dist/client/assets/{right-CimaAvQN.js → right-D8id_DWQ.js} +1 -1
  232. package/dist/client/assets/{right-C0ybUw0j.js → right-DJ34yMAi.js} +1 -1
  233. package/dist/client/assets/{right-D3eSiy41.js → right-DiFmtw6d.js} +1 -1
  234. package/dist/client/assets/{right-BqI-nr9G.js → right-Lx79pxpG.js} +1 -1
  235. package/dist/client/assets/{rocket-BQm5_CvR.js → rocket-D3-TUJ2m.js} +1 -1
  236. package/dist/client/assets/{router-B9vQkNJL.js → router-DTtux5sP.js} +1 -1
  237. package/dist/client/assets/{scope-views-1IYJdl41.js → scope-views-CPM0sBw_.js} +1 -1
  238. package/dist/client/assets/{scout-voice-BVUqGhth.js → scout-voice-BZKsdquE.js} +1 -1
  239. package/dist/client/assets/{scoutbot-markdown-BQ_Ee2Ic.js → scoutbot-markdown-CQ7Y1McC.js} +1 -1
  240. package/dist/client/assets/{scroll-text-Dze_dXtQ.js → scroll-text-kPhYbh-M.js} +1 -1
  241. package/dist/client/assets/{search-CDko0PKE.js → search-DmFM_9jm.js} +1 -1
  242. package/dist/client/assets/{secondaryNavConfig-BoQ_zYR9.js → secondaryNavConfig-C9bQ9_IA.js} +1 -1
  243. package/dist/client/assets/{selection-bridge-Din6yV3h.js → selection-bridge-Dy2mtMyi.js} +1 -1
  244. package/dist/client/assets/{send-horizontal-CSjIm6xg.js → send-horizontal-qyjNgEaV.js} +1 -1
  245. package/dist/client/assets/{server-Bzj7lPIx.js → server-nWqndnxu.js} +1 -1
  246. package/dist/client/assets/{session-catalog-DsaZJXZt.js → session-catalog-BkmktBHI.js} +1 -1
  247. package/dist/client/assets/{session-table-BQfR7u6r.js → session-table-DKSF0mrS.js} +1 -1
  248. package/dist/client/assets/{settings-Dyvpkb1D.js → settings-C6h9y5XX.js} +1 -1
  249. package/dist/client/assets/{sliders-horizontal-C8njVwfg.js → sliders-horizontal-BhHKxsCO.js} +1 -1
  250. package/dist/client/assets/{sparkles-CETYrxGA.js → sparkles-Cf8gin88.js} +1 -1
  251. package/dist/client/assets/{sse-CD9MMUxl.js → sse-DDHEHUgz.js} +1 -1
  252. package/dist/client/assets/{tail-events-Ps8KpKah.js → tail-events-BdUrO0kb.js} +1 -1
  253. package/dist/client/assets/{terminal-9GRS_Qdc.js → terminal-C3YRPfyz.js} +1 -1
  254. package/dist/client/assets/{terminal-relay-GYMIvKs1.js → terminal-relay-BFhdIstF.js} +1 -1
  255. package/dist/client/assets/{terminal-takeover-_Jyys4me.js → terminal-takeover-B6H4llRR.js} +1 -1
  256. package/dist/client/assets/{text-BP3oyl8-.js → text-Faa3ZStB.js} +1 -1
  257. package/dist/client/assets/{use-conversation-list-C9ABzjXI.js → use-conversation-list-DO5J8T1H.js} +1 -1
  258. package/dist/client/assets/{use-fleet-active-asks-DAspZQjE.js → use-fleet-active-asks-BtgNnRgK.js} +1 -1
  259. package/dist/client/assets/{use-mesh-ops-items-Dh54ymEp.js → use-mesh-ops-items-N1HHhChY.js} +1 -1
  260. package/dist/client/assets/{use-reduced-motion-x8pJMVrG.js → use-reduced-motion-8WuxLa5l.js} +1 -1
  261. package/dist/client/assets/{use-scout-dev-flags-DhCbiDK3.js → use-scout-dev-flags-B31qTy6m.js} +1 -1
  262. package/dist/client/assets/{useAgentHoverCard-DoBwV0LX.js → useAgentHoverCard-Bkv-Uz_V.js} +1 -1
  263. package/dist/client/assets/useContentSecondaryNav-Bpkc8ayb.js +1 -0
  264. package/dist/client/assets/{usePierreRuntime-ejq9dCWV.js → usePierreRuntime-BfZHKAkI.js} +1 -1
  265. package/dist/client/assets/{wrench-DjkoAOQt.js → wrench-DkxnZRlR.js} +1 -1
  266. package/dist/client/assets/{x-CAbNespN.js → x-DfRJbqrh.js} +1 -1
  267. package/dist/client/assets/{xterm-Cf-ngcGP.js → xterm-CJw8Epxv.js} +1 -1
  268. package/dist/client/assets/{zap-Cq8eWkcF.js → zap-CIo8msJB.js} +1 -1
  269. package/dist/client/index.html +1 -1
  270. package/dist/main.mjs +65 -21
  271. package/dist/pairing-runtime-controller.mjs +8 -0
  272. package/dist/runtime/broker-daemon.mjs +58 -10
  273. package/dist/scout-control-plane-web.mjs +8 -0
  274. package/package.json +2 -2
  275. package/dist/client/assets/AgentLanesEmbedScreen-Dgcm7zd_.js +0 -1
  276. package/dist/client/assets/AgentsSubnav-C4xpQhsv.js +0 -1
  277. package/dist/client/assets/CrewWorkspaces-CkQDhyie.css +0 -1
  278. package/dist/client/assets/CrewWorkspaces-NKujRzwh.js +0 -1
  279. package/dist/client/assets/OpsScreen-D8fQafCl.js +0 -1
  280. package/dist/client/assets/OpsSubnav-1K4Jaf__.js +0 -1
  281. package/dist/client/assets/ProjectAgentProfile-Bdjd_dAx.js +0 -1
  282. package/dist/client/assets/ProjectsScreen-cVUkGbPz.js +0 -1
  283. package/dist/client/assets/SessionsScreen--5OJ3p3v.js +0 -1
  284. package/dist/client/assets/agents-project-COzHxZAF.css +0 -1
  285. package/dist/client/assets/content-9K38QchR.js +0 -1
  286. package/dist/client/assets/content-BRgnyXWh.js +0 -1
  287. package/dist/client/assets/content-BdkI07v3.js +0 -1
  288. package/dist/client/assets/content-C4oWa8SB.js +0 -1
  289. package/dist/client/assets/content-CFZ4rghn.js +0 -1
  290. package/dist/client/assets/content-CIqu_Ci_.js +0 -1
  291. package/dist/client/assets/content-CnJF9DGO.js +0 -1
  292. package/dist/client/assets/content-CriW8Y8u.js +0 -1
  293. package/dist/client/assets/content-DDCyPPk_.js +0 -1
  294. package/dist/client/assets/content-DtcZeh5m.js +0 -1
  295. package/dist/client/assets/content-U9tsdtle.js +0 -1
  296. package/dist/client/assets/content-hFLK3CON.js +0 -1
  297. package/dist/client/assets/content-p00KQrtD.js +0 -1
  298. package/dist/client/assets/conversation-motion-features-D9-RmBSq.js +0 -1
  299. package/dist/client/assets/embed-entry-BSMUykuG.js +0 -2
  300. package/dist/client/assets/index-zvhpRHao.js +0 -1
  301. package/dist/client/assets/left-B-SdEJSJ.js +0 -1
  302. package/dist/client/assets/library-DkALuCh5.js +0 -1
  303. package/dist/client/assets/resolve-panes-DeVJbS9c.js +0 -1
  304. package/dist/client/assets/resolve-sidebar-context-BQe5J6xF.js +0 -1
  305. package/dist/client/assets/useContentSecondaryNav-pZe2Zfk1.js +0 -1
@@ -1 +1 @@
1
- import{r as o,j as a,a1 as _e,b as dt,y as ft,a2 as pt,a3 as ht,K as mt}from"./index-DvLtl7rV.js";import{h as $e,b as vt,au as gt}from"./router-B9vQkNJL.js";import{a as q}from"./api-Co9aQ2Jw.js";import{u as wt}from"./sse-CD9MMUxl.js";import{o as bt,i as je}from"./surface-activity-B1rgWB1i.js";import{i as yt}from"./colors-BtO5_zlx.js";import{e as Je,s as St,i as De,r as Ct,b as Et,f as kt}from"./scoutbot-BJIamJOH.js";import{F as xt,a as Tt,D as At}from"./DocumentFocusViewer-Do3wQ_3Z.js";import{c as Ke,T as Ge}from"./TextDocumentSurface-BflAwXeZ.js";import{C as Rt}from"./chevron-right-D-HdlPg8.js";import{F as It}from"./file-text-CqJgwxmv.js";import{c as Nt}from"./createLucideIcon-DezKXSG2.js";import{C as Lt}from"./code-xml-D7pOQM9l.js";import{A as Ot}from"./arrow-left-Czpf-AE4.js";import{A as _t}from"./arrow-right-BuzMnLYP.js";import{j as jt}from"./scout-voice-BVUqGhth.js";import{i as Dt}from"./keyboard-nav-BLYDhL3Z.js";import{J as Pt,N as Mt,l as ve,K as Pe,j as Me}from"./NewChatComposer-_Stj0fZy.js";import{u as Ft}from"./chunk-HRAB3GC3-Tyv9rzx7.js";const We={current:null,setMenu:null};function Tr(){return o.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),We.setMenu?.({position:{x:e.clientX,y:e.clientY},items:t})},[])}function Bt({children:e}){const[t,n]=o.useState(null),r=o.useRef(null);We.setMenu=n;const s=o.useCallback(()=>{n(null)},[]);return o.useEffect(()=>{if(!t)return;const i=d=>{d.target instanceof Node&&r.current?.contains(d.target)||s()},c=d=>{d.key==="Escape"&&s()},p=()=>s(),u=d=>{d.defaultPrevented||s()};return window.addEventListener("mousedown",i,!0),window.addEventListener("keydown",c),window.addEventListener("wheel",p,!0),window.addEventListener("contextmenu",u),()=>{window.removeEventListener("mousedown",i,!0),window.removeEventListener("keydown",c),window.removeEventListener("wheel",p,!0),window.removeEventListener("contextmenu",u)}},[t,s]),o.useLayoutEffect(()=>{if(!t||!r.current)return;const i=r.current,c=i.getBoundingClientRect(),p=window.innerWidth,u=window.innerHeight;let d=t.position.x,f=t.position.y;d+c.width>p-8&&(d=p-c.width-8),f+c.height>u-8&&(f=u-c.height-8),d<8&&(d=8),f<8&&(f=8),i.style.left=`${d}px`,i.style.top=`${f}px`,i.style.visibility="visible"},[t]),a.jsxs(a.Fragment,{children:[e,t&&a.jsx("div",{ref:r,className:"s-context-menu",style:{left:t.position.x,top:t.position.y,visibility:"hidden"},role:"menu",onMouseDown:i=>i.stopPropagation(),children:t.items.map((i,c)=>i.kind==="separator"?a.jsx("div",{className:"s-context-menu-sep",role:"separator"},c):a.jsxs("button",{type:"button",className:"s-context-menu-item",role:"menuitem",onClick:()=>{i.onSelect(),s()},children:[a.jsx("span",{className:"s-context-menu-label",children:i.label}),i.shortcut&&a.jsx("span",{className:"s-context-menu-shortcut",children:i.shortcut})]},c))})]})}function Ut(e){const t=e instanceof Error?e.message:String(e);return qt(t)?"Scout server is unreachable":t}function Vt(e){return e==="Scout server is unreachable"}function qt(e){return/failed to fetch|fetch failed|networkerror|load failed|couldn'?t connect|could not connect|connection refused|econnrefused|server is unreachable/i.test(e)}const Se="openscout.operator.name",Ht=new Set(["operator","you","user","unknown","null","undefined"]);function ze(e){const t=e?.trim();return!t||t.length>64||Ht.has(t.toLowerCase())?null:t}function $t(){if(typeof window>"u")return null;try{return ze(window.localStorage.getItem(Se))}catch{return null}}function Jt(e){if(!(typeof window>"u"))try{const t=ze(e);t?window.localStorage.setItem(Se,t):window.localStorage.removeItem(Se)}catch{}}const Kt=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Gt=Nt("chevron-up",Kt),Wt={id:"audio",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("audio/"),render:({resource:e})=>{const t=e;return a.jsx("div",{className:"s-file-preview-media-wrap",children:a.jsx("div",{className:"s-file-preview-audio-stage",children:a.jsx("audio",{className:"s-file-preview-audio",src:t.rawUrl,controls:!0})})})}},zt={id:"binary",canHandle:()=>!0,render:({resource:e})=>{const t=e;return a.jsxs("div",{className:"s-file-preview-callout",children:[a.jsxs("div",{className:"s-file-preview-callout-title",children:[t.previewReason," — open in OS"]}),a.jsxs("div",{className:"s-file-preview-callout-copy",children:["Scout can resolve this file, but it does not have an inline preview for ",t.mediaType," yet."]})]})}},Qt=new Set(["text/typescript","text/javascript","text/css","text/html","application/json","text/yaml","text/toml","text/x-shellscript","text/plain"]),Yt={id:"code",canHandle:e=>e.kind==="file"&&e.previewable&&Qt.has(e.mediaType),render:({resource:e})=>{const t=e,n=Ke({id:t.realPath,title:t.title,uri:t.realPath,mediaType:t.mediaType,value:t.content,filename:t.title,kind:"code",readOnly:!0});return a.jsx(Ge,{document:n,mode:"read",className:"s-doc-focus-document"})}},Xt={id:"directory",canHandle:e=>e.kind==="directory",render:({resource:e,openFilePreview:t})=>{const n=e,r=Zt(n.realPath,n.rootPath);return a.jsxs("div",{className:"s-file-preview-directory",children:[a.jsx("div",{className:"s-file-preview-breadcrumb","aria-label":"Directory breadcrumb",children:r.map((s,i)=>{const c=i===r.length-1;return a.jsxs("div",{className:"s-file-preview-breadcrumb-item",children:[i>0&&a.jsx(Rt,{size:12,"aria-hidden":"true"}),c?a.jsx("span",{className:"s-file-preview-breadcrumb-current",children:s.label}):a.jsx("button",{type:"button",className:"s-file-preview-breadcrumb-link",onClick:()=>t(s.path),children:s.label})]},s.path)})}),a.jsxs("div",{className:"s-file-preview-directory-list",role:"list",children:[n.entries.map(s=>a.jsxs("button",{type:"button",className:"s-file-preview-entry",onClick:()=>t(s.path),children:[a.jsx("span",{className:"s-file-preview-entry-icon","aria-hidden":"true",children:s.kind==="directory"?a.jsx(xt,{size:14}):a.jsx(It,{size:14})}),a.jsx("span",{className:"s-file-preview-entry-name",children:s.name}),a.jsx("span",{className:"s-file-preview-entry-kind",children:s.kind==="directory"?"dir":"file"})]},s.realPath)),n.entries.length===0&&a.jsx("div",{className:"s-file-preview-directory-empty",children:"This directory is empty."})]})]})}};function Zt(e,t){const n=t==="/"?"/":t.replace(/\/+$/u,""),r=e==="/"?"/":e.replace(/\/+$/u,""),s=n.split("/").filter(Boolean),i=r.split("/").filter(Boolean),c=[{label:s[s.length-1]??"/",path:n||"/"}];let p=n||"/";for(let u=s.length;u<i.length;u+=1){const d=i[u];d&&(p=p==="/"?`/${d}`:`${p}/${d}`,c.push({label:d,path:p}))}return c}const en={id:"html",canHandle:e=>e.kind==="file"&&e.previewable&&e.mediaType==="text/html",render:({resource:e})=>a.jsx("div",{className:"s-file-preview-html-wrap",children:a.jsx("iframe",{className:"s-file-preview-html-frame",src:e.kind==="file"?e.rawUrl:"",title:e.title,sandbox:"allow-forms allow-popups allow-popups-to-escape-sandbox allow-scripts",referrerPolicy:"no-referrer"})})},tn={id:"image",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("image/"),render:({resource:e})=>a.jsx("div",{className:"s-file-preview-image-wrap",children:a.jsx("div",{className:"s-file-preview-image-stage",children:a.jsx("img",{className:"s-file-preview-image",src:e.kind==="file"?e.rawUrl:"",alt:e.title})})})},nn={id:"markdown",canHandle:e=>e.kind==="file"&&e.previewable&&e.mediaType==="text/markdown",render:({resource:e})=>{const t=e,n=Ke({id:t.realPath,title:t.title,uri:t.realPath,mediaType:t.mediaType,value:t.content,filename:t.title,kind:"markdown",readOnly:!0});return a.jsx(Ge,{document:n,mode:"preview",className:"s-doc-focus-document"})}},rn={id:"video",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("video/"),render:({resource:e})=>{const t=e;return a.jsx("div",{className:"s-file-preview-media-wrap",children:a.jsx("div",{className:"s-file-preview-media-stage",children:a.jsx("video",{className:"s-file-preview-video",src:t.rawUrl,controls:!0})})})}},on=[Xt,nn,en,Yt,tn,rn,Wt,zt];function sn({path:e,onOpenPath:t,onOpenInCode:n,onClose:r}){const[s,i]=o.useState(null),[c,p]=o.useState(null),[u,d]=o.useState(!1),[f,P]=o.useState(null),D=o.useRef(null);o.useEffect(()=>{D.current=f},[f]),o.useEffect(()=>{if(!e){i(null),p(null),d(!1);return}let b=!1;return d(!0),p(null),i(null),q(`/api/file/preview?path=${encodeURIComponent(e)}`).then(y=>{b||(i(y),an(y,D.current,P))}).catch(y=>{b||p(y instanceof Error?y.message:"could not load file")}).finally(()=>{b||d(!1)}),()=>{b=!0}},[e]);const{currentIndex:M,prevPath:v,nextPath:h}=o.useMemo(()=>{if(!s||s.kind!=="file"||!f)return{currentIndex:-1,prevPath:null,nextPath:null};const b=f.files.findIndex(y=>y.realPath===s.realPath);return b<0?{currentIndex:-1,prevPath:null,nextPath:null}:{currentIndex:b,prevPath:b>0?f.files[b-1].path:null,nextPath:b<f.files.length-1?f.files[b+1].path:null}},[s,f]);if(o.useEffect(()=>{if(!e)return;const b=y=>{if(y.key==="Escape"){r();return}if(y.target instanceof HTMLElement){const g=y.target.tagName;if(g==="INPUT"||g==="TEXTAREA"||y.target.isContentEditable)return}y.metaKey||y.ctrlKey||y.altKey||(y.key==="ArrowLeft"&&v?(y.preventDefault(),t(v)):y.key==="ArrowRight"&&h?(y.preventDefault(),t(h)):y.key==="Backspace"&&f&&s?.kind==="file"&&(y.preventDefault(),t(f.dirPath)))};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[e,r,t,v,h,f,s]),!e)return null;const w=()=>{q("/api/file/reveal",{method:"POST",body:JSON.stringify({path:s?.realPath??e})}).catch(b=>{p(b instanceof Error?b.message:"reveal failed")})},I=s?on.find(b=>b.canHandle(s))??null:null,O=!!(s&&s.kind==="file"&&f&&M>=0&&f.files.length>1),k=[];O&&f&&k.push({label:`Folder: ${f.dirTitle}`,icon:a.jsx(Gt,{size:12}),onClick:()=>t(f.dirPath),title:`Back to ${f.dirTitle} (Backspace)`}),k.push({label:"Open in Code",icon:a.jsx(Lt,{size:12}),onClick:()=>{s?.kind==="file"&&n(s.realPath,s.rootPath)},title:"Continue with this file in Scout’s Code browser",disabled:s?.kind!=="file"}),k.push({label:"Show in folder",icon:a.jsx(Tt,{size:12}),onClick:w,title:"Show this file in its operating system folder",hideLabel:!0});const j=s?ln(s):[];O&&j.unshift(`${M+1} / ${f.files.length}`);const R=s&&I?I.render({resource:s,openFilePreview:t}):null;return a.jsx(At,{open:!0,kind:cn(s),document:null,title:s?.title??e.split("/").pop()??"File",eyebrow:"File preview",subtitle:s?.realPath??e,meta:j,state:u?"Loading…":null,error:c,body:R?a.jsxs("div",{className:`s-file-preview-shell${O?" s-file-preview-shell-nav":""}`,children:[O&&a.jsx("button",{type:"button",className:"s-file-preview-side-nav s-file-preview-side-nav-left",onClick:()=>v&&t(v),disabled:!v,"aria-label":"Previous file",title:"Previous file (←)",children:a.jsx(Ot,{size:18,strokeWidth:1.8,"aria-hidden":"true"})}),a.jsx("div",{className:"s-file-preview-shell-body",children:R}),O&&a.jsx("button",{type:"button",className:"s-file-preview-side-nav s-file-preview-side-nav-right",onClick:()=>h&&t(h),disabled:!h,"aria-label":"Next file",title:"Next file (→)",children:a.jsx(_t,{size:18,strokeWidth:1.8,"aria-hidden":"true"})})]}):null,actions:k,onClose:r})}function an(e,t,n){if(e.kind==="directory"){const s=e.entries.filter(i=>i.kind==="file");n({dirPath:e.path,dirTitle:e.title,files:s});return}if(!t){n(null);return}t.files.some(s=>s.realPath===e.realPath)||n(null)}function cn(e){return!e||e.kind==="directory"||e.mediaType==="text/markdown"||e.mediaType==="text/plain"?"doc":"code"}function ln(e){return e.kind==="directory"?[`${e.entries.length} ${e.entries.length===1?"entry":"entries"}`]:[...e.previewable&&e.truncated?["truncated"]:[],un(e.sizeBytes),e.mediaType]}function un(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const Qe={activity:"idle",brief:{lastDeliveredAt:null},reminders:{dueCount:0,upcomingCount:0,due:[],next:null},voice:{available:null,setupBlocked:!1,replies:!1},error:null,session:{title:null,lastActivityAt:null},conversation:{messageCount:0,loading:!0}},Q=()=>{},Ye={focusScoutbot:Q,triggerBrief:Q,triggerAskState:Q,toggleVoiceReplies:Q,openScoutbotSettings:Q,startNewChat:Q,dismissReminder:Q,askReminderStatus:Q},Ee=o.createContext(null);function dn({children:e}){const[t,n]=o.useState(Qe),r=o.useRef(Ye),s=o.useCallback(u=>{n(d=>fn(d,u)?d:u)},[]),i=o.useCallback(u=>{r.current=u},[]),c=o.useMemo(()=>({focusScoutbot:()=>r.current.focusScoutbot(),triggerBrief:()=>r.current.triggerBrief(),triggerAskState:()=>r.current.triggerAskState(),toggleVoiceReplies:()=>r.current.toggleVoiceReplies(),openScoutbotSettings:()=>r.current.openScoutbotSettings(),startNewChat:()=>r.current.startNewChat(),dismissReminder:u=>r.current.dismissReminder(u),askReminderStatus:u=>r.current.askReminderStatus(u)}),[]),p=o.useMemo(()=>({state:t,actions:c,publishState:s,registerActions:i}),[t,c,s,i]);return a.jsx(Ee.Provider,{value:p,children:e})}function Ar(){const e=o.useContext(Ee);return e?{state:e.state,actions:e.actions}:{state:Qe,actions:Ye}}function Rr(){const e=o.useContext(Ee);return e?{publishState:e.publishState,registerActions:e.registerActions}:null}function fn(e,t){return e.activity===t.activity&&e.brief.lastDeliveredAt===t.brief.lastDeliveredAt&&e.reminders.dueCount===t.reminders.dueCount&&e.reminders.upcomingCount===t.reminders.upcomingCount&&pn(e.reminders.due,t.reminders.due)&&Xe(e.reminders.next,t.reminders.next)&&e.voice.available===t.voice.available&&e.voice.setupBlocked===t.voice.setupBlocked&&e.voice.replies===t.voice.replies&&e.error===t.error&&e.session.title===t.session.title&&e.session.lastActivityAt===t.session.lastActivityAt&&e.conversation.messageCount===t.conversation.messageCount&&e.conversation.loading===t.conversation.loading}function pn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!Xe(e[n],t[n]))return!1;return!0}function Xe(e,t){return e===t?!0:!e||!t?!1:e.id===t.id&&e.body===t.body&&e.status===t.status&&e.dueAt===t.dueAt}const hn="/api/voice/realtime/call",Ze="/api/voice/realtime/lease",et="/api/voice/realtime/settings",mn="x-openscout-realtime-voice-lease",tt="surface.realtime-voice",Ir="scout:realtime-voice-stop",Ce="scout:realtime-voice-settings",vn={noise_reduction:{type:"far_field"},turn_detection:{type:"server_vad",threshold:.6,prefix_padding_ms:300,silence_duration_ms:500,create_response:!0,interrupt_response:!0}},gn={noise_reduction:{type:"near_field"},turn_detection:{type:"server_vad",threshold:.5,prefix_padding_ms:300,silence_duration_ms:500,create_response:!0,interrupt_response:!0}},wn="/api/scoutbot/chat",nt="openscout.realtime-voice-settings";function rt(e){return q(et,{signal:e,cache:"no-store"})}function Nr(e){return q(et,{method:"PUT",body:JSON.stringify({enabled:e})})}function Lr(e){if(window.dispatchEvent(new CustomEvent(Ce,{detail:e})),!("BroadcastChannel"in window))return;const t=new BroadcastChannel(nt);t.postMessage(e),t.close()}function bn(e){const t=r=>{const s=r.detail;Fe(s)&&e(s)};window.addEventListener(Ce,t);const n="BroadcastChannel"in window?new BroadcastChannel(nt):null;return n&&(n.onmessage=r=>{Fe(r.data)&&e(r.data)}),()=>{window.removeEventListener(Ce,t),n?.close()}}function Fe(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.enabled=="boolean"&&typeof t.configuredEnabled=="boolean"&&(t.source==="settings"||t.source==="environment")&&typeof t.locked=="boolean"}const yn=25e3;async function Sn(e={}){if(ee(e.signal),!globalThis.RTCPeerConnection||!navigator.mediaDevices?.getUserMedia)throw new Error("This browser does not support realtime audio calls.");if(!(await rt(e.signal)).enabled)throw new Error("Live voice is off. Turn it on in Settings → Voice before starting a call.");ee(e.signal),e.onState?.("connecting");const n=new RTCPeerConnection,r=new Audio;r.autoplay=!0;let s=!1,i=null,c=null,p=null,u=0,d=0;const f=(h,w,I="voice")=>{d+=1,e.onTrace?.({id:`voice-${d}`,at:Date.now(),kind:I,label:h,...w?{detail:w}:{}})};let P=null;const D=()=>{if(P)return P;s=!0,e.signal?.removeEventListener("abort",v),p&&clearInterval(p),p=null,i?.getTracks().forEach(w=>w.stop()),r.pause(),r.srcObject=null,n.close();const h=c;return c=null,P=(async()=>{h&&await On(h),e.onState?.("ended")})(),P},M=()=>{D().catch(h=>{e.onError?.(h instanceof Error?h.message:"Could not release the realtime voice lease."),e.onState?.("error")})},v=()=>{M()};e.signal?.addEventListener("abort",v,{once:!0}),n.ontrack=({streams:h})=>{const w=h[0];if(!w||s)return;const[I]=w.getAudioTracks();I&&I.addEventListener("ended",()=>{s||e.onError?.("Realtime voice audio ended unexpectedly.")}),r.srcObject=w,r.play().catch(()=>{e.onError?.("Browser playback was blocked. Interact with the page, then start the call again.")})},n.onconnectionstatechange=()=>{s||(n.connectionState==="connected"?(e.onState?.("live"),f("Realtime channel connected","Scoutbot bridge is ready")):(n.connectionState==="failed"||n.connectionState==="disconnected")&&(e.onError?.("Realtime voice connection ended unexpectedly."),M()))};try{i=await Nn(e.inputDeviceName,e.signal),ee(e.signal);for(const x of i.getTracks())n.addTrack(x,i);const h=n.createDataChannel("oai-events"),w=new Set;let I=Promise.resolve(),O=!1,k=null;const j=[],R=x=>{if(s||h.readyState!=="open")return!1;try{return h.send(JSON.stringify(x)),!0}catch{return e.onError?.("Realtime voice events channel closed unexpectedly."),!1}},b=()=>{if(O||k||j.length===0)return;const x=j.shift();if(x){if(k=x,!R({type:"response.create",response:{instructions:x}})){k=null,j.unshift(x);return}O=!0}},y=x=>{j.push(x),b()};h.addEventListener("open",()=>{if(s)return;const x=In(e.inputDeviceName);if(!R({type:"session.update",session:{type:"realtime",audio:{input:x}}})){e.onError?.("Could not configure Scout's realtime microphone processing.");return}f("Scoutbot bridge ready","Live fleet context is available"),y("Open with one brief audible greeting: 'Hi, I’m Scoutbot. I can check the fleet and coordinate through Scout. What would you like to work on?'")}),h.addEventListener("error",()=>{s||e.onError?.("Realtime voice events channel closed unexpectedly.")}),h.addEventListener("message",x=>{const C=En(x.data);if(C?.type==="error"){if(ot(C.message)){k&&(j.unshift(k),k=null),O=!0,f("Scoutbot reply queued","Waiting for the current spoken response to finish","scoutbot");return}e.onError?.(C.message??"OpenAI Realtime reported an error.");return}if(C?.type==="response.created"){O=!0,k=null;return}if(C?.type==="response.done"){O=!1,k=null;for(const H of kn(C))H.name!=="ask_scoutbot"||w.has(H.callId)||(w.add(H.callId),I=I.then(()=>Cn({functionCall:H,route:e.getRoute?.()??e.route,uiContext:e.getUiContext?.(),onReply:e.onScoutbotReply,onTrace:f,send:R,requestResponse:y})).catch(J=>{e.onError?.(J instanceof Error?J.message:"Scoutbot could not complete the voice request.")}));b()}});const g=await ge(n.createOffer(),e.signal);if(await ge(n.setLocalDescription(g),e.signal),!g.sdp)throw new Error("Could not create a WebRTC offer.");const T=await fetch(hn,{method:"POST",headers:{"content-type":"application/sdp"},body:g.sdp,signal:e.signal});c=T.headers.get(mn)?.trim()||null;const L=await ge(T.text(),e.signal);if(!T.ok)throw new Error(An(L,T.status));if(!c)throw new Error("Scout started the audio connection without a concurrency lease. Please try again.");return p=setInterval(()=>{if(!c||s)return;const x=c;Ln(x).then(C=>{if(!(s||x!==c)){if(C){u=0;return}e.onError?.("Realtime voice lost its server lease. Reconnect to continue safely."),M()}}).catch(()=>{u+=1,!(u<2||s)&&(e.onError?.("Realtime voice could not renew its server lease. Check the connection and try again."),M())})},yn),await ge(n.setRemoteDescription({type:"answer",sdp:L}),e.signal),ee(e.signal),{leaseId:c,stop:D}}catch(h){throw await D(),h}}async function Cn(e){const t=xn(e.functionCall.arguments);if(!t){e.onTrace("Scoutbot request could not be read",void 0,"error"),be(e,{ok:!1,error:"The voice request did not include a usable Scoutbot prompt."});return}e.onTrace("Scoutbot is checking the control plane",t,"scoutbot");try{const n=await fetch(wn,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({body:t,route:e.route,uiContext:e.uiContext})}),r=await n.text();if(!n.ok)throw new Error(Tn(r,n.status));const s=JSON.parse(r),i=typeof s.reply?.body=="string"?s.reply.body.trim():"";if(!i)throw new Error("Scoutbot returned an empty reply.");const c=Je(i).filter(d=>d.type==="ask-agent").length,p=e.onReply?await e.onReply(i):{agentRequests:{requested:c,sent:0,failed:c}},u=St(i);e.onTrace("Scoutbot reply ready",void 0,"scoutbot"),be(e,{ok:!0,reply:u,...p.agentRequests.requested>0?{agentRequests:p.agentRequests}:{}})}catch(n){const r=n instanceof Error?n.message:"Scoutbot could not complete the voice request.";e.onTrace("Scoutbot request failed",r,"error"),be(e,{ok:!1,error:r})}}function be(e,t){if(!e.send({type:"conversation.item.create",item:{type:"function_call_output",call_id:e.functionCall.callId,output:JSON.stringify(t)}}))return;const r=t.agentRequests;e.requestResponse(t.ok?r&&r.requested>0?r.failed>0?"Answer using the Scoutbot result. Say clearly that Scoutbot tried to send the agent request automatically but delivery failed, and tell the operator to check the activity log. Be concise and do not mention tools, JSON, fences, or implementation details.":"Answer using the Scoutbot result. Say clearly that the agent request was sent automatically. Do not claim the requested work is complete. Be concise and do not mention tools, JSON, fences, or implementation details.":"Answer using the Scoutbot result. Speak the useful answer naturally and concisely. Do not mention tools, JSON, fences, or implementation details.":"Briefly tell the operator that Scoutbot could not complete the live lookup and state the returned error plainly.")}function ot(e){const t=e?.toLowerCase()??"";return t.includes("active response in progress")||t.includes("conversation already has an active response")||t.includes("response is already in progress")}function En(e){if(typeof e!="string")return null;try{const t=JSON.parse(e);return{...typeof t.type=="string"?{type:t.type}:{},...typeof t.error?.message=="string"?{message:t.error.message}:{},...t.response&&typeof t.response=="object"?{response:t.response}:{}}}catch{return null}}function kn(e){return Array.isArray(e.response?.output)?e.response.output.flatMap(t=>{if(!t||typeof t!="object")return[];const n=t;return n.type!=="function_call"||typeof n.call_id!="string"||typeof n.name!="string"||typeof n.arguments!="string"?[]:[{callId:n.call_id,name:n.name,arguments:n.arguments}]}):[]}function xn(e){try{const t=JSON.parse(e);if(typeof t.request!="string")return null;const n=t.request.trim();return n?n.slice(0,8e3):null}catch{return null}}function Tn(e,t){try{const n=JSON.parse(e);if(typeof n.error=="string"&&n.error.trim())return n.error}catch{}return`Scoutbot could not complete the live lookup (HTTP ${t}).`}function An(e,t){try{const n=JSON.parse(e);if(typeof n.error=="string"&&n.error.trim())return n.error}catch{}return`Could not start realtime voice (HTTP ${t}).`}async function ge(e,t){return t?(ee(t),new Promise((n,r)=>{const s=()=>r(ke(t));t.addEventListener("abort",s,{once:!0}),e.then(i=>{t.removeEventListener("abort",s),n(i)},i=>{t.removeEventListener("abort",s),r(i)})})):e}async function Be(e,t){return t?(ee(t),new Promise((n,r)=>{let s=!1;const i=()=>{s=!0,r(ke(t))};t.addEventListener("abort",i,{once:!0}),e.then(c=>{if(t.removeEventListener("abort",i),s||t.aborted){c.getTracks().forEach(p=>p.stop());return}n(c)},c=>{t.removeEventListener("abort",i),s||r(c)})})):e}const Ue={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,channelCount:1},Rn=/\b(?:airpods?|earbuds?|earphones?|headsets?|headphones?|buds?|hands[- ]?free)\b/iu;function In(e){return Rn.test(e?.trim()??"")?gn:vn}async function Nn(e,t){const n=await Ve(e);let r=await Be(navigator.mediaDevices.getUserMedia({audio:{...Ue,...n?{deviceId:{exact:n.deviceId}}:{}}}),t);if(!n&&e?.trim()){const s=await Ve(e),i=r.getAudioTracks?.()[0]?.label?.trim().toLocaleLowerCase()??"";if(s&&s.label.trim().toLocaleLowerCase()!==i)try{const c=await Be(navigator.mediaDevices.getUserMedia({audio:{...Ue,deviceId:{exact:s.deviceId}}}),t);r.getTracks().forEach(p=>p.stop()),r=c}catch(c){if(t?.aborted)throw r.getTracks().forEach(p=>p.stop()),c}}for(const s of r.getAudioTracks?.()??[])s.contentHint="speech";return r}async function Ve(e){const t=e?.trim().toLocaleLowerCase();if(!t||typeof navigator.mediaDevices.enumerateDevices!="function")return null;try{const n=(await navigator.mediaDevices.enumerateDevices()).filter(r=>r.kind==="audioinput"&&r.deviceId&&r.label.trim());return n.find(r=>r.label.trim().toLocaleLowerCase()===t)??n.find(r=>{const s=r.label.trim().toLocaleLowerCase();return s.includes(t)||t.includes(s)})??null}catch{return null}}function ee(e){if(e?.aborted)throw ke(e)}function ke(e){return e.reason instanceof Error?e.reason:new DOMException("Realtime voice connection was cancelled.","AbortError")}async function Ln(e){return(await fetch(`${Ze}/${encodeURIComponent(e)}`,{method:"PUT"})).ok}async function On(e){const t=await fetch(`${Ze}/${encodeURIComponent(e)}`,{method:"DELETE",keepalive:!0});if(!t.ok&&t.status!==404)throw new Error(`Could not release realtime voice lease (HTTP ${t.status}).`)}const _n=[{id:"home",label:"Home",description:"Fleet overview, briefings, and recent activity.",route:{view:"inbox"}},{id:"projects",label:"Projects",description:"Projects, agents, and project-scoped work.",route:{view:"agents-v2"},deepActions:["Open a project by projectSlug.","Open an agent by agentId."]},{id:"sessions",label:"Sessions",description:"Active and recent harness sessions.",route:{view:"sessions"},deepActions:["Open a session by sessionId."]},{id:"messages",label:"Messages",description:"Direct conversations and channels.",route:{view:"messages"},deepActions:["Open a conversation by conversationId.","Filter by all, direct messages, or channels."]},{id:"dispatch",label:"Dispatch",description:"Requests, flights, work, and delivery state.",route:{view:"broker"}},{id:"search",label:"Search",description:"Knowledge and indexed workspace search.",route:{view:"search"}},{id:"operations",label:"Operations",description:"Mission Control, live activity, agent lanes, runtime, and mesh health.",route:{view:"ops",mode:"mission"}},{id:"repositories",label:"Repositories",description:"Repository and worktree status, including diffs.",route:{view:"repos"},deepActions:["Open a repository by absolute root."]},{id:"code-browser",label:"Code Browser",description:"Read files in a project or worktree.",route:{view:"code"},deepActions:["Select a project with the project field; it accepts the displayed project name or slug.","Open a file inside it with path and optional wt.","Alternatively use absolute root and file fields.","Focus a line with line and optional endLine.","Deep links: scout://{project}/{path}, scout:///{absolute/path}, or legacy scout://code/{project}/{path}."]},{id:"terminals",label:"Terminals",description:"Observe or take over terminal sessions.",route:{view:"terminal"}},{id:"settings",label:"Settings",description:"Connections, agents, communications, credentials, voice, and devices.",route:{view:"settings"}}],jn=[{id:"comms",label:"Comms",description:"Native conversations and channels.",route:{view:"messages"},deepActions:["Open a conversation by conversationId.","Open a channel by channelId."]},{id:"projects",label:"Projects",description:"Native project and agent browser.",route:{view:"agents-v2"},deepActions:["Filter to a project by projectSlug.","Select an agent by agentId."]},{id:"terminals",label:"Terminals",description:"Native terminal workspace.",route:{view:"terminal"},deepActions:["Select an agent terminal by agentId."]},{id:"tail",label:"Tail",description:"Live agent and harness activity.",route:{view:"ops",mode:"tail"}},{id:"dispatch",label:"Dispatch",description:"Dispatch and coordination overview.",route:{view:"broker"}},{id:"agent-lanes",label:"Agent Lanes",description:"Native lane overview for active agents.",route:{view:"ops",mode:"lanes"}},{id:"repositories",label:"Repositories",description:"Native repository and worktree status.",route:{view:"repos"}},{id:"code-browser",label:"Code Browser",description:"Embedded read-only project browser.",route:{view:"code"},deepActions:["Select a project with the project field; it accepts the displayed project name or slug.","Open a file inside it with path and optional wt.","Alternatively use absolute root and file fields.","Focus a line with line and optional endLine.","Deep links: scout://{project}/{path}, scout:///{absolute/path}, or legacy scout://code/{project}/{path}."]},{id:"settings",label:"Settings",description:"Native app settings; Voice is directly addressable.",route:{view:"settings"},deepActions:["Open Voice settings with section=voice."]}];function Dn(e){const t=e==="macos";return{host:e,shellLabel:t?"Scout for macOS":"OpenScout web",destinations:t?jn:_n,rules:["When asked what navigation is available, list only these human labels and short descriptions.","Never expose internal Route.view names, aliases, URL fragments, or implementation vocabulary in the human reply.","Emit only a destination route or deep action explicitly described by this host context.","If the requested destination or deep action is absent, say it is not available in this app instead of approximating it with another page."]}}const Pn="scout:scoutbot-realtime-reply",we="scout:scoutbot-session-changed",Mn={enabled:!1,open:!1,state:"idle",leaseId:null,error:null,trace:[],chatState:null,sessionAction:null,setOpen:()=>{},startCall:async()=>{},endCall:async()=>!0,startNewChat:async()=>{},switchChat:async()=>{},updatePreferredModel:async e=>e,clearTrace:()=>{},openVoiceSettings:()=>{}},st=o.createContext(Mn);function Fn({children:e}){const{route:t,applyScoutbotUiAction:n}=at(),r=$e(tt,!0),[s,i]=o.useState(!1),c=r&&s,[p,u]=o.useState(!1),[d,f]=o.useState("idle"),[P,D]=o.useState(null),[M,v]=o.useState(null),[h,w]=o.useState([]),[I,O]=o.useState(null),[k,j]=o.useState(null),R=o.useRef(null),b=o.useRef(null),y=o.useRef(null),g=o.useRef(0),T=o.useRef(!1),L=o.useRef(!1),x=o.useRef({route:t,applyScoutbotUiAction:n});x.current={route:t,applyScoutbotUiAction:n};const C=o.useCallback((m,S,A="voice")=>{w(N=>[...N,{id:`voice-ui-${Date.now()}-${N.length}`,at:Date.now(),kind:A,label:m,...S?{detail:S}:{}}].slice(-100))},[]),H=o.useCallback(()=>w([]),[]),J=o.useCallback(async()=>{const m=await q("/api/scoutbot/session");return T.current||O(m),m},[]);o.useEffect(()=>{if(!r){i(!1);return}const m=new AbortController;let S=!1;const A=bn(N=>{i(N.enabled)});return rt(m.signal).then(N=>{S||i(N.enabled)}).catch(N=>{S||qe(N)||(i(!1),v(N instanceof Error?N.message:"Could not load live voice settings."))}),()=>{S=!0,m.abort(),A()}},[r]),o.useEffect(()=>{if(!c)return;const m=()=>{J().catch(S=>{T.current||v(S instanceof Error?S.message:"Could not load Scoutbot chats.")})};return m(),window.addEventListener(we,m),()=>window.removeEventListener(we,m)},[c,J]);const $=o.useCallback(async()=>{g.current+=1;const m=y.current;b.current?.abort(),b.current=null;const S=R.current;R.current=null;try{await S?.stop(),await m}catch(A){return T.current||(f("error"),v(A instanceof Error?A.message:"Could not end realtime voice cleanly.")),!1}return T.current||(D(null),f("ended"),C("Live voice ended","Microphone and host lease released","voice")),!0},[C]);o.useEffect(()=>{c||(u(!1),(R.current||d==="connecting"||d==="live")&&$())},[c,$,d]),o.useEffect(()=>(T.current=!1,()=>{T.current=!0,g.current+=1,b.current?.abort(),b.current=null,R.current?.stop().catch(()=>{}),R.current=null}),[]);const te=o.useCallback(async m=>{window.dispatchEvent(new CustomEvent(Pn,{detail:{body:m}}));const S=m.replace(/```[\s\S]*?```/gu,"").trim();S&&C("Scoutbot replied",S.slice(0,2e3),"scoutbot");let A=0,N=0,W=0;for(const B of Je(m))if(B.type==="ask-agent")A+=1,await Vn(B,C,v)?N+=1:W+=1;else if(B.type!=="reminder"){const _=Un(B),U=B.type==="navigate"||B.type==="view-file"?"navigation":"scoutbot";C(Bn(B),_,U),x.current.applyScoutbotUiAction(B),C(De()?"Action sent to Scout for macOS":"Action applied in OpenScout",_,U)}return await J().catch(()=>null),{agentRequests:{requested:A,sent:N,failed:W}}},[C,J]),ne=o.useCallback(()=>{const m={type:"navigate",route:{view:"settings",section:"voice"}};C("Voice settings requested",void 0,"navigation"),x.current.applyScoutbotUiAction(m)},[C]),re=o.useCallback(async()=>{if(!c){v("Turn on live voice in Settings → Voice before starting a call."),u(!1);return}if(L.current||d==="connecting"||d==="live")return;L.current=!0,b.current?.abort();const m=R.current;R.current=null;try{await m?.stop(),D(null)}catch(_){f("error"),v(_ instanceof Error?_.message:"Could not end the previous realtime voice call."),L.current=!1;return}const S=new AbortController;b.current=S;const A=g.current+1;g.current=A;let N=()=>{};const W=new Promise(_=>{N=_});y.current=W;let B=!1;v(null),w([{id:"connecting",at:Date.now(),label:"Connecting secure audio"}]),f("connecting");try{const _=await jt().then(({settings:V})=>V.inputDeviceName).catch(()=>null),U=await Sn({signal:S.signal,inputDeviceName:_,getRoute:()=>x.current.route,getUiContext:()=>Dn(De()?"macos":"web"),onState:V=>{!T.current&&g.current===A&&f(V)},onError:V=>{if(!(T.current||g.current!==A)){if(ot(V)){C("Scoutbot reply queued","Waiting for the current spoken response to finish","scoutbot");return}v(V),C("Voice issue",V,"error")}},onTrace:V=>{!T.current&&g.current===A&&w(ue=>[...ue,V].slice(-100))},onScoutbotReply:V=>!T.current&&g.current===A?te(V):{agentRequests:{requested:0,sent:0,failed:0}}});if(T.current||S.signal.aborted||g.current!==A){await U.stop();return}R.current=U,D(U.leaseId),B=!0}catch(_){if(!T.current&&g.current===A&&!qe(_)){f("error");const U=_ instanceof Error?_.message:"Could not start realtime voice.";v(U),C("Live voice could not start",U,"error")}}finally{!B&&b.current===S&&(b.current=null),N(),y.current===W&&(y.current=null),L.current=!1}},[C,te,c,d]),oe=o.useCallback(async()=>{if(!k){j("new"),v(null);try{if((R.current||d==="connecting"||d==="live")&&!await $())return;if(I?.session.messages.length===0){w([{id:`voice-chat-${Date.now()}`,at:Date.now(),kind:"scoutbot",label:"New live chat ready"}]);return}const m=await q("/api/scoutbot/session/reset",{method:"POST"});O(m),w([{id:`voice-chat-${Date.now()}`,at:Date.now(),kind:"scoutbot",label:"New live chat ready"}]),window.dispatchEvent(new CustomEvent(we,{detail:{id:m.session.id}}))}catch(m){const S=m instanceof Error?m.message:"Could not start a new Scoutbot chat.";v(S),C("Could not start a new live chat",S,"error")}finally{j(null)}}},[C,I?.session.messages.length,$,k,d]),se=o.useCallback(async m=>{if(!(!m||k||m===I?.session.id)){j(m),v(null);try{if((R.current||d==="connecting"||d==="live")&&!await $())return;const S=await q("/api/scoutbot/session/switch",{method:"POST",body:JSON.stringify({id:m})});O(S),w([{id:`voice-chat-${Date.now()}`,at:Date.now(),kind:"scoutbot",label:"Live chat restored",detail:S.session.title}]),window.dispatchEvent(new CustomEvent(we,{detail:{id:S.session.id}}))}catch(S){const A=S instanceof Error?S.message:"Could not switch Scoutbot chats.";v(A),C("Could not restore the live chat",A,"error")}finally{j(null)}}},[C,I?.session.id,$,k,d]),ie=o.useCallback(async m=>{const S=m.trim();if(!S)throw new Error("Preferred model is required.");const A=await q("/api/scoutbot/config",{method:"POST",body:JSON.stringify({model:S})});return O(N=>N&&{...N,config:{...N.config,...A.config}}),C("Scoutbot preferred model updated",A.config.model,"scoutbot"),A.config.model},[C]),ae=o.useMemo(()=>({enabled:c,open:p,state:d,leaseId:P,error:M,trace:h,chatState:I,sessionAction:k,setOpen:u,startCall:re,endCall:$,startNewChat:oe,switchChat:se,updatePreferredModel:ie,clearTrace:H,openVoiceSettings:ne}),[c,p,d,P,M,h,I,k,re,$,oe,se,ie,H,ne]);return a.jsx(st.Provider,{value:ae,children:e})}function qe(e){return(e instanceof DOMException||e instanceof Error)&&e.name==="AbortError"}function Or(){return o.useContext(st)}function Bn(e){return e.type==="navigate"?"Navigation requested":e.type==="open-scoutbot"?"Scoutbot opened its panel":e.type==="refresh"?"Scoutbot refreshed live state":"Scoutbot opened the requested file"}function Un(e){return e.type==="navigate"?JSON.stringify(e.route):e.type==="view-file"?e.path:e.reason?.trim()||e.type}async function Vn(e,t,n){t("Scoutbot is coordinating",`Asking ${e.targetLabel}`,"agent");try{const r=await q("/api/scoutbot/actions/ask",{method:"POST",body:JSON.stringify({targetLabel:e.targetLabel,targetAgentId:e.targetAgentId,body:e.body,channel:e.channel})});return t("Scoutbot sent the request",r.flightId?`${r.targetAgentId??r.targetLabel} · run ${r.flightId}`:r.targetAgentId??r.targetLabel,"agent"),!0}catch(r){const s=r instanceof Error?r.message:"Could not send to agent.";return t("Scoutbot could not send the request",s,"error"),n(s),!1}}function ye(e,t){const n=t?.trim();n&&e.add(n)}function qn(e,t){const n=new Set;return ye(n,e.authorityNodeId),ye(n,e.homeNodeId),n.size===0&&ye(n,t),n}function it(e,t,n){return t?qn(e,n).has(t):!0}function Hn(e,t,n){return t?e.filter(r=>it(r,t,n)):e}function _r(e,t,n){return t?new Set(e.filter(r=>it(r,t,n)).map(r=>r.id)):null}function Y(e,t,n){return!t&&!n||n&&e.authorityNodeId===n?!0:t?e.agentId&&t.has(e.agentId)||e.actorId&&t.has(e.actorId)||e.ownerId&&t.has(e.ownerId)||e.nextMoveOwnerId&&t.has(e.nextMoveOwnerId)?!0:!!e.participantIds?.some(r=>t.has(r)):!1}function $n(e,t,n){return Y(e,t,n)}function jr(e,t,n){return!t&&!n?e:e.filter(r=>$n(r,t,n))}function Jn(e,t){return Y(e,t)}function Kn(e,t){return t?e.filter(n=>Jn(n,t)):e}function He(e,t){return Y(e,t)}function Dr(e,t){if(!e||!t)return e;const n=e.activeAsks.filter(c=>Y(c,t)),r=e.recentCompleted.filter(c=>Y(c,t)),s=e.needsAttention.filter(c=>Y(c,t)),i=Kn(e.activity,t);return{...e,totals:{active:n.length,recentCompleted:r.length,needsAttention:s.length,activity:i.length},activeAsks:n,recentCompleted:r,needsAttention:s,activity:i}}function Pr(e,t){if(!t)return e;const n=e.activeFlights.filter(i=>Y(i,t)),r=e.childWork.filter(i=>He(i,t));return He(e,t)||n.length>0||r.length>0?{...e,activeFlights:n,childWork:r}:null}function Gn(e){return!!(e&&(e.message.trim().length>0||e.files.length>0||e.forwardContext))}function Wn(e){return[e.name,e.type,e.size,e.lastModified].join(":")}function zn(e,t){const n=new Set;return[...e,...t].filter(r=>{const s=Wn(r);return n.has(s)?!1:(n.add(s),!0)})}function Qn(e,t){const n=t.intent??e?.intent??"new-task",r=n==="route-capture",s=n==="forward-message";return{intent:n,...r&&(t.agentId??e?.agentId)?{agentId:t.agentId??e?.agentId}:{},...r&&(t.conversationId??e?.conversationId)?{conversationId:t.conversationId??e?.conversationId}:{},message:t.message??e?.message??"",files:zn(e?.files??[],t.files??[]),attachmentFeedback:t.attachmentFeedback??e?.attachmentFeedback??null,mode:r?t.preferExistingChat===void 0?e?.mode??"new-session":t.preferExistingChat?"existing-chat":"new-session":"new-session",projectPath:t.projectPath??e?.projectPath??"",projectQuery:e?.projectQuery??"",...s&&(t.forwardContext??e?.forwardContext)?{forwardContext:t.forwardContext??e?.forwardContext}:{},forwardContextMode:s?t.forwardContextMode??e?.forwardContextMode??"selected-message":"selected-message"}}function Yn({request:e,onClose:t,onOpenCapture:n}){const{agents:r,route:s,navigate:i}=at(),c=vt(s),p=Hn(r,c),u=Pt(s,p),[d,f]=o.useState(0),[P,D]=o.useState(null),[M,v]=o.useState(null),h=o.useRef(0),w=e?Qn(M,e):null,I=o.useCallback((k,j)=>{if(k.length===0)return;const R=!!(u.agentId||u.conversationId);n({intent:R?"route-capture":"new-task",files:k,attachmentFeedback:j,agentId:u.agentId??void 0,conversationId:u.conversationId??void 0,preferExistingChat:u.canUseExistingChat})},[n,u]);o.useEffect(()=>{if(!P)return;const k=window.setTimeout(()=>D(null),5e3);return()=>window.clearTimeout(k)},[P]),o.useEffect(()=>{const k=g=>{ve(g.dataTransfer)&&(g.preventDefault(),h.current+=1,f(h.current))},j=g=>{ve(g.dataTransfer)&&(g.preventDefault(),g.dataTransfer&&(g.dataTransfer.dropEffect="copy"))},R=()=>{h.current!==0&&(h.current=Math.max(0,h.current-1),f(h.current))},b=g=>{if(!ve(g.dataTransfer))return;g.preventDefault();const T=Pe(g.dataTransfer),L=T.filter(Me),x=T.length-L.length;if(h.current=0,f(0),L.length===0){D(T.length===0?"Scout could not read that file. Try the attachment picker instead.":"That file type is not supported. Drop markdown, code, an image, or a video clip.");return}const C=L.length===1?`Dropped ${L[0]?.name||"1 attachment"}.`:`Dropped ${L.length} attachments.`,H=x>0?`${C} Skipped ${x} unsupported ${x===1?"file":"files"}.`:C;D(null),I(L,H)},y=g=>{if(Dt(g.target)||!ve(g.clipboardData))return;g.preventDefault();const T=Pe(g.clipboardData),L=T.filter(Me);if(L.length===0){D(T.length===0?"Scout could not read that pasted file. Try the attachment picker instead.":"That pasted file type is not supported. Paste an image or video, or attach markdown or code.");return}I(L,L.length===1?`Pasted ${L[0]?.name||"1 attachment"}.`:`Pasted ${L.length} attachments.`)};return window.addEventListener("dragenter",k),window.addEventListener("dragover",j),window.addEventListener("dragleave",R),window.addEventListener("drop",b),window.addEventListener("paste",y),()=>{window.removeEventListener("dragenter",k),window.removeEventListener("dragover",j),window.removeEventListener("dragleave",R),window.removeEventListener("drop",b),window.removeEventListener("paste",y)}},[I]);const O=d>0&&!e;return a.jsxs(a.Fragment,{children:[O?a.jsx("div",{className:"s-capture-drop",role:"presentation",children:a.jsxs("div",{className:"s-capture-drop-card",children:[a.jsx("div",{className:"s-capture-drop-title",children:"Route capture"}),a.jsx("div",{className:"s-capture-drop-copy",children:"Drop markdown, code, an image, or a video clip to send it to the right agent or chat."})]})}):null,P?a.jsx("div",{className:"s-capture-feedback",role:"alert",children:P}):null,e?a.jsx(Mt,{agents:p,route:s,navigate:i,onClose:t,initialAgentId:w?.agentId,initialConversationId:w?.conversationId,initialMessage:w?.message,initialFiles:w?.files,initialAttachmentFeedback:w?.attachmentFeedback??void 0,initialIntent:w?.intent,initialProjectPath:w?.projectPath,initialProjectQuery:w?.projectQuery,initialForwardContext:w?.forwardContext,initialForwardContextMode:w?.forwardContextMode,defaultMode:w?.mode,draftRestored:Gn(M),onDraftChange:v,onDraftConsumed:()=>v(null)}):null]})}const xe=o.createContext(null),Xn=["hello","node.upserted","actor.registered","agent.registered","agent.endpoint.upserted","invocation.requested","flight.updated","delivery.state.changed","scout.dispatched"],Zn=new Set(Xn),er=3e4,tr=250;function nr(e,t){try{return JSON.stringify(e)===JSON.stringify(t)?e:t}catch{return t}}const rr={"--hud-bg":"oklch(0.118 0.004 260)","--hud-surface":"oklch(0.205 0.005 260)","--hud-ink":"oklch(0.975 0.006 260)","--hud-muted":"oklch(0.80 0.008 260)","--hud-dim":"oklch(0.70 0.007 260)","--hud-border":"oklch(0.975 0.006 260 / 0.08)","--hud-accent":"oklch(0.86 0.17 125)","--hud-accent-soft":"oklch(0.86 0.17 125 / 0.08)","--hud-shadow-soft":"oklch(0.08 0.004 260 / 0.42)","--hud-chrome-border":"oklch(0.975 0.006 260 / 0.04)","--hud-shadow-panel":"0 12px 34px oklch(0.08 0.004 260 / 0.45)","--hud-shadow-panel-hover":"0 14px 38px oklch(0.08 0.004 260 / 0.52)","--hud-shadow-bar":"0 -10px 28px oklch(0.08 0.004 260 / 0.38)","--hud-shadow-nav":"0 8px 24px oklch(0.08 0.004 260 / 0.32)","--hud-shadow-minimap":"0 10px 24px oklch(0.08 0.004 260 / 0.38)","--hud-status-ok":"oklch(0.80 0.15 155)","--hud-status-warn":"oklch(0.82 0.15 85)","--hud-status-error":"oklch(0.72 0.18 25)","--background":"0.132 0.004 260","--foreground":"0.965 0.006 260","--card":"0.178 0.005 260","--card-foreground":"0.965 0.006 260","--popover":"0.178 0.005 260","--popover-foreground":"0.965 0.006 260","--muted-foreground":"0.72 0.008 260","--scrim":"rgba(0, 0, 0, 0.5)","--scrim-soft":"rgba(0, 0, 0, 0.3)","--info":"#62b6ff","--shadow-card":"0 8px 22px rgba(0, 0, 0, 0.22)","--shadow-card-hover":"0 14px 36px rgba(0, 0, 0, 0.30)","--cat-gold":"#d7a978","--cat-purple":"#c58cff","--cat-sky":"#38bdf8","--scout-chrome-ink-strong":"color-mix(in srgb, var(--hud-ink) 94%, transparent)","--scout-chrome-ink":"color-mix(in srgb, var(--hud-ink) 84%, transparent)","--scout-chrome-ink-soft":"color-mix(in srgb, var(--hud-ink) 68%, transparent)","--scout-chrome-ink-faint":"color-mix(in srgb, var(--hud-ink) 64%, transparent)","--scout-chrome-ink-ghost":"color-mix(in srgb, var(--hud-ink) 56%, transparent)","--scout-chrome-hover":"color-mix(in srgb, var(--hud-ink) 5%, transparent)","--scout-chrome-active":"color-mix(in srgb, var(--hud-ink) 9%, transparent)","--scout-chrome-border-soft":"color-mix(in srgb, var(--hud-ink) 8%, transparent)","--scout-chrome-avatar-ink":"#111111","--hud-font-sans":"'Inter', ui-sans-serif, system-ui, sans-serif","--hud-font-mono":"'JetBrains Mono', ui-monospace, Menlo, monospace","--hud-font-serif":"'Spectral', 'Cormorant Garamond', Georgia, serif","--hud-font-accent-title":"'Inter Tight', var(--hud-font-sans)"},or={"--hud-bg":"oklch(0.982 0.008 78)","--hud-surface":"oklch(0.994 0.006 78)","--hud-ink":"oklch(0.26 0.018 72)","--hud-muted":"oklch(0.50 0.028 70)","--hud-dim":"oklch(0.64 0.022 72)","--hud-border":"oklch(0.86 0.016 75 / 0.92)","--hud-accent":"oklch(0.72 0.16 125)","--hud-accent-soft":"oklch(0.72 0.16 125 / 0.11)","--hud-shadow-soft":"oklch(0.42 0.02 70 / 0.11)","--hud-status-ok":"oklch(0.64 0.16 155)","--hud-status-warn":"oklch(0.72 0.15 85)","--hud-status-error":"oklch(0.62 0.19 25)","--background":"0.978 0.004 85","--foreground":"0.24 0.01 80","--card":"0.992 0.003 85","--card-foreground":"0.24 0.01 80","--popover":"0.992 0.003 85","--popover-foreground":"0.24 0.01 80","--muted-foreground":"0.56 0.014 80","--scrim":"rgba(28, 24, 20, 0.30)","--scrim-soft":"rgba(28, 24, 20, 0.16)","--info":"#2f7fd6","--shadow-card":"0 8px 22px oklch(0.42 0.02 70 / 0.09)","--shadow-card-hover":"0 14px 36px oklch(0.42 0.02 70 / 0.13)","--cat-gold":"#a9824f","--cat-purple":"#8b5cf6","--cat-sky":"#0ea5e9","--scout-chrome-ink-strong":"color-mix(in srgb, var(--hud-ink) 94%, transparent)","--scout-chrome-ink":"color-mix(in srgb, var(--hud-ink) 78%, transparent)","--scout-chrome-ink-soft":"color-mix(in srgb, var(--hud-ink) 60%, transparent)","--scout-chrome-ink-faint":"color-mix(in srgb, var(--hud-ink) 56%, transparent)","--scout-chrome-ink-ghost":"color-mix(in srgb, var(--hud-ink) 50%, transparent)","--scout-chrome-hover":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-active":"color-mix(in srgb, var(--hud-ink) 8%, transparent)","--scout-chrome-border-soft":"color-mix(in srgb, var(--hud-border) 80%, transparent)","--scout-chrome-avatar-ink":"#ffffff","--hud-font-sans":"'Inter', ui-sans-serif, system-ui, sans-serif","--hud-font-mono":"'JetBrains Mono', ui-monospace, Menlo, monospace","--hud-font-serif":"'Spectral', 'Cormorant Garamond', Georgia, serif","--hud-font-accent-title":"'Inter Tight', var(--hud-font-sans)"},sr=new Set(["--hud-bg","--hud-surface","--hud-ink","--hud-muted","--hud-dim","--hud-border","--hud-accent","--hud-accent-soft","--hud-shadow-soft","--hud-chrome-border","--hud-shadow-panel","--hud-shadow-panel-hover","--hud-shadow-bar","--hud-shadow-nav","--hud-shadow-minimap","--hud-status-ok","--hud-status-warn","--hud-status-error"]);function ir(e){return Object.fromEntries(Object.entries(e==="light"?or:rr).filter(([n])=>!sr.has(n)))}function Mr(){return o.useContext(xe)}function at(){const e=o.useContext(xe);if(!e)throw new Error("useScout must be used inside ScoutProvider");return e}function Fr({children:e,initialTheme:t="dark"}){const{route:n,navigate:r,navigateBack:s,canNavigateBack:i}=gt(),c=Ft(),p=$e(tt,!0),[u,d]=o.useState([]),[f,P]=o.useState(!1),[D,M]=o.useState({status:"checking",message:null,lastCheckedAt:null}),[v,h]=o.useState(_e),[w,I]=o.useState(null),O=o.useRef(!1),[k,j]=o.useState($t),[R,b]=o.useState(!1),[y,g]=o.useState(null),[T,L]=o.useState(null),[x,C]=o.useState(""),[H,J]=o.useState(null),$=n.view==="settings",te=o.useMemo(()=>n.view!=="broker"||!n.attemptId?null:y?.id===n.attemptId?y:null,[y,n]),ne=o.useMemo(()=>n.view!=="search"||!n.hitId?null:T?.id===n.hitId?T:null,[T,n]),re=o.useMemo(()=>n.view==="agents-v2"&&n.agentId&&n.sessionId?{agentId:n.agentId,sessionId:n.sessionId}:n.view==="sessions"&&n.sessionId?{agentId:n.agentId??"",sessionId:n.sessionId}:null,[n]),oe=o.useCallback((l,E)=>{if(n.view==="agents-v2"&&n.agentId===l){r({...n,sessionId:E},{replace:!0});return}if(n.view==="sessions"){r({view:"sessions",sessionId:E,agentId:l},{replace:!0});return}r({view:"agents-v2",agentId:l,sessionId:E},{replace:!0})},[r,n]),se=o.useCallback(()=>{r({view:"settings",section:"appearance"})},[r]),ie=o.useCallback(()=>{n.view==="settings"&&r({view:"inbox"})},[r,n.view]),ae=o.useCallback(l=>{J(l??{intent:"new-task"})},[]),m=o.useCallback(()=>J(null),[]),S=o.useCallback(l=>{g(l),!(n.view==="broker"&&n.attemptId===l.id)&&r({view:"broker",attemptId:l.id,...n.view==="broker"&&n.filter?{filter:n.filter}:{}},{replace:n.view==="broker"})},[r,n]),A=o.useCallback(()=>{g(null),n.view==="broker"&&n.attemptId&&r({view:"broker",...n.filter?{filter:n.filter}:{}},{replace:!0})},[r,n]),N=o.useCallback((l,E,F)=>{if(L(l),typeof E=="string"&&C(E.trim()),n.view==="search"&&n.hitId===l.id)return;const K=F??(n.view==="search"?n.filters:void 0);r({view:"search",...n.view==="search"&&n.mode?{mode:n.mode}:{},...K?{filters:K}:{},hitId:l.id},{replace:n.view==="search"})},[r,n]),W=o.useCallback(()=>{L(null),C(""),n.view==="search"&&n.hitId&&r({view:"search",...n.mode?{mode:n.mode}:{},...n.filters?{filters:n.filters}:{}},{replace:!0})},[r,n]),B=o.useMemo(()=>dt(),[]),_=c?.resolvedTheme??t,U=c?.template??"hudson",V=o.useMemo(()=>({...ir(_),...B??{}}),[B,_]),ue=o.useCallback(l=>{h(E=>({...E,...l}))},[]);o.useEffect(()=>{!f||u.length===0||h(l=>{const E=ft(l.agentCharacters,u);return E===l.agentCharacters?l:{...l,agentCharacters:E}})},[u,f]),o.useEffect(()=>{pt(_,U,v),ht(v)},[U,v,_]),o.useEffect(()=>{const l=E=>{E.key!==null&&E.key!==mt||h(_e())};return window.addEventListener("storage",l),()=>window.removeEventListener("storage",l)},[]);const Te=o.useMemo(()=>Ct(u),[u]),Ae=Te?.id??Et(u),Re=Te?.conversationId??null,de=o.useRef(null),X=o.useRef(null),fe=n.view==="ops"?"/api/agents":"/api/agents?detail=summary",pe=o.useCallback(()=>{M({status:"online",message:null,lastCheckedAt:Date.now()})},[]),he=o.useCallback(l=>{const E=Ut(l);M({status:Vt(E)?"offline":"degraded",message:E,lastCheckedAt:Date.now()})},[]),G=o.useCallback(async()=>{const l=de.current;if(l&&(await l.promise,l.url===fe))return;const E=(async()=>{try{const F=await q(fe);d(K=>nr(K,F)),pe()}catch(F){he(F)}finally{P(!0)}})();de.current={url:fe,promise:E};try{await E}finally{de.current?.promise===E&&(de.current=null)}},[fe,he,pe]),z=o.useCallback(async()=>{try{const l=await q("/api/onboarding/state");O.current=!1,I(l);const E=l.operatorName?.trim()||l.operatorNameSuggestion?.trim()||null;j(E),Jt(E),pe()}catch(l){he(l),O.current=!0,I({hasLocalConfig:!0,hasProjectConfig:!0,hasOperatorName:!0,localConfigPath:null,projectRoot:null,currentDirectory:null,operatorName:null,operatorNameSuggestion:null,needed:!1})}},[he,pe]),Ie=o.useCallback(()=>{b(!0),q("/api/onboarding/skip",{method:"POST",body:"{}"}).then(()=>z()).catch(()=>null)},[z]);o.useEffect(()=>{G(),z()},[G,z]),o.useEffect(()=>{const l=()=>{je()&&(G(),O.current&&z())},E=window.setInterval(l,er),F=bt(l);return()=>{window.clearInterval(E),F()}},[G,z]);const Ne=o.useMemo(()=>u.filter(l=>yt(l.state)).length,[u]),[ct,Le]=o.useState(null),ce=o.useCallback(l=>{l?.trim()&&Le(l.trim())},[]),le=o.useCallback(()=>Le(null),[]),Z=o.useCallback(l=>{if(!kt(l))switch(l.type){case"navigate":r(l.route);break;case"focus-composer":window.dispatchEvent(new CustomEvent("scout:composer-focus"));break;case"open-scoutbot":window.dispatchEvent(new CustomEvent("scout:scoutbot-panel-open",{detail:l}));break;case"refresh":G();break;case"view-file":ce(l.path);break}},[r,ce,G]),lt=o.useCallback((l,E)=>{const F=l.trim(),K=E.trim();if(!F||!K)return;const Oe=n.view==="conversation"||n.view==="messages"?n.conversationId:window.location.pathname==="/embed/thread"&&new URLSearchParams(window.location.search).get("conversationId")?.trim()||void 0;le(),Z({type:"navigate",route:{view:"code",root:K,file:F,...Oe?{returnConversationId:Oe}:{}}})},[Z,le,n]),me=o.useRef({applyScoutbotUiAction:Z});me.current={applyScoutbotUiAction:Z},wt(l=>{je()&&Zn.has(l.kind)&&(X.current!==null&&window.clearTimeout(X.current),X.current=window.setTimeout(()=>{X.current=null,G()},tr))}),o.useEffect(()=>()=>{X.current!==null&&window.clearTimeout(X.current)},[]),o.useEffect(()=>{const l=E=>{const F=E.detail,K=F&&typeof F=="object"&&"type"in F?F:null;K&&me.current.applyScoutbotUiAction(K)};return window.addEventListener("scout:scoutbot-ui-action",l),window.scoutScoutbot={applyUiAction:E=>me.current.applyScoutbotUiAction(E),navigate:E=>me.current.applyScoutbotUiAction({type:"navigate",route:E})},()=>{window.removeEventListener("scout:scoutbot-ui-action",l),window.scoutScoutbot?.applyUiAction&&delete window.scoutScoutbot}},[]);const ut=o.useMemo(()=>({route:n,navigate:r,navigateBack:s,canNavigateBack:i,agents:u,agentsLoaded:f,onlineCount:Ne,apiConnection:D,reload:G,appearanceDetails:v,updateAppearanceDetails:ue,onboarding:w,operatorName:k,refreshOnboarding:z,onboardingSkipped:R,skipOnboarding:Ie,settingsOpen:$,openSettings:se,closeSettings:ie,scoutbotAgentId:Ae,scoutbotConversationId:Re,applyScoutbotUiAction:Z,selectedBrokerAttempt:te,inspectBrokerAttempt:S,clearBrokerAttempt:A,selectedKnowledgeHit:ne,selectedKnowledgeQuery:x,inspectKnowledgeHit:N,clearKnowledgeHit:W,focusedSession:re,focusSession:oe,openFilePreview:ce,closeFilePreview:le,openContextCapture:ae,closeContextCapture:m}),[n,r,s,i,u,f,Ne,D,G,v,ue,w,k,z,R,Ie,$,se,ie,Ae,Re,Z,te,S,A,ne,x,N,W,re,oe,ce,le,ae,m]);return a.jsx(xe.Provider,{value:ut,children:a.jsx("div",{"data-scout-theme-mode":_,"data-scout-palette":v.palette,"data-scout-contrast":v.contrast,"data-scout-accent":v.accent,"data-scout-shell":v.shell,"data-scout-avatar-style":v.avatarStyle,"data-hudson-theme":_,"data-hudson-template":U,style:{...V},children:a.jsx("div",{"data-scout-theme":_,style:{display:"contents"},children:a.jsx(Bt,{children:a.jsxs(dn,{children:[p?a.jsx(Fn,{children:e}):e,a.jsx(sn,{path:ct,onOpenPath:ce,onOpenInCode:lt,onClose:le}),a.jsx(Yn,{request:H,onClose:m,onOpenCapture:ae})]})})})})})}export{Bt as C,rr as D,or as L,xe as S,Tr as a,Kn as b,Mr as c,Hn as d,jr as e,Ut as f,Dr as g,Fr as h,Vt as i,Pr as j,Gt as k,Rr as l,_r as m,tt as n,Or as o,we as p,Pn as q,Ir as r,Dn as s,Ar as t,at as u,rt as v,Nr as w,Lr as x};
1
+ import{r as o,j as a,a1 as _e,b as dt,y as ft,a2 as pt,a3 as ht,K as mt}from"./index-BI9AljSD.js";import{h as $e,b as vt,au as gt}from"./router-DTtux5sP.js";import{a as q}from"./api-Co9aQ2Jw.js";import{u as wt}from"./sse-DDHEHUgz.js";import{o as bt,i as je}from"./surface-activity-B1rgWB1i.js";import{i as yt}from"./colors-BtO5_zlx.js";import{e as Je,s as St,i as De,r as Ct,b as Et,f as kt}from"./scoutbot-BJIamJOH.js";import{F as xt,a as Tt,D as At}from"./DocumentFocusViewer-DFFE85Tq.js";import{c as Ke,T as Ge}from"./TextDocumentSurface-BeSwe3Yl.js";import{C as Rt}from"./chevron-right-CnZRSd-V.js";import{F as It}from"./file-text--hfhwZH1.js";import{c as Nt}from"./createLucideIcon-DthwWQIg.js";import{C as Lt}from"./code-xml-CvKBY3KA.js";import{A as Ot}from"./arrow-left-DHfdXJVZ.js";import{A as _t}from"./arrow-right-BBsrogWf.js";import{j as jt}from"./scout-voice-BZKsdquE.js";import{i as Dt}from"./keyboard-nav-e6yGeorb.js";import{J as Pt,N as Mt,l as ve,K as Pe,j as Me}from"./NewChatComposer-C_1op4dH.js";import{u as Ft}from"./chunk-HRAB3GC3-DLNT8aOo.js";const We={current:null,setMenu:null};function Tr(){return o.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),We.setMenu?.({position:{x:e.clientX,y:e.clientY},items:t})},[])}function Bt({children:e}){const[t,n]=o.useState(null),r=o.useRef(null);We.setMenu=n;const s=o.useCallback(()=>{n(null)},[]);return o.useEffect(()=>{if(!t)return;const i=d=>{d.target instanceof Node&&r.current?.contains(d.target)||s()},c=d=>{d.key==="Escape"&&s()},p=()=>s(),u=d=>{d.defaultPrevented||s()};return window.addEventListener("mousedown",i,!0),window.addEventListener("keydown",c),window.addEventListener("wheel",p,!0),window.addEventListener("contextmenu",u),()=>{window.removeEventListener("mousedown",i,!0),window.removeEventListener("keydown",c),window.removeEventListener("wheel",p,!0),window.removeEventListener("contextmenu",u)}},[t,s]),o.useLayoutEffect(()=>{if(!t||!r.current)return;const i=r.current,c=i.getBoundingClientRect(),p=window.innerWidth,u=window.innerHeight;let d=t.position.x,f=t.position.y;d+c.width>p-8&&(d=p-c.width-8),f+c.height>u-8&&(f=u-c.height-8),d<8&&(d=8),f<8&&(f=8),i.style.left=`${d}px`,i.style.top=`${f}px`,i.style.visibility="visible"},[t]),a.jsxs(a.Fragment,{children:[e,t&&a.jsx("div",{ref:r,className:"s-context-menu",style:{left:t.position.x,top:t.position.y,visibility:"hidden"},role:"menu",onMouseDown:i=>i.stopPropagation(),children:t.items.map((i,c)=>i.kind==="separator"?a.jsx("div",{className:"s-context-menu-sep",role:"separator"},c):a.jsxs("button",{type:"button",className:"s-context-menu-item",role:"menuitem",onClick:()=>{i.onSelect(),s()},children:[a.jsx("span",{className:"s-context-menu-label",children:i.label}),i.shortcut&&a.jsx("span",{className:"s-context-menu-shortcut",children:i.shortcut})]},c))})]})}function Ut(e){const t=e instanceof Error?e.message:String(e);return qt(t)?"Scout server is unreachable":t}function Vt(e){return e==="Scout server is unreachable"}function qt(e){return/failed to fetch|fetch failed|networkerror|load failed|couldn'?t connect|could not connect|connection refused|econnrefused|server is unreachable/i.test(e)}const Se="openscout.operator.name",Ht=new Set(["operator","you","user","unknown","null","undefined"]);function ze(e){const t=e?.trim();return!t||t.length>64||Ht.has(t.toLowerCase())?null:t}function $t(){if(typeof window>"u")return null;try{return ze(window.localStorage.getItem(Se))}catch{return null}}function Jt(e){if(!(typeof window>"u"))try{const t=ze(e);t?window.localStorage.setItem(Se,t):window.localStorage.removeItem(Se)}catch{}}const Kt=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Gt=Nt("chevron-up",Kt),Wt={id:"audio",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("audio/"),render:({resource:e})=>{const t=e;return a.jsx("div",{className:"s-file-preview-media-wrap",children:a.jsx("div",{className:"s-file-preview-audio-stage",children:a.jsx("audio",{className:"s-file-preview-audio",src:t.rawUrl,controls:!0})})})}},zt={id:"binary",canHandle:()=>!0,render:({resource:e})=>{const t=e;return a.jsxs("div",{className:"s-file-preview-callout",children:[a.jsxs("div",{className:"s-file-preview-callout-title",children:[t.previewReason," — open in OS"]}),a.jsxs("div",{className:"s-file-preview-callout-copy",children:["Scout can resolve this file, but it does not have an inline preview for ",t.mediaType," yet."]})]})}},Qt=new Set(["text/typescript","text/javascript","text/css","text/html","application/json","text/yaml","text/toml","text/x-shellscript","text/plain"]),Yt={id:"code",canHandle:e=>e.kind==="file"&&e.previewable&&Qt.has(e.mediaType),render:({resource:e})=>{const t=e,n=Ke({id:t.realPath,title:t.title,uri:t.realPath,mediaType:t.mediaType,value:t.content,filename:t.title,kind:"code",readOnly:!0});return a.jsx(Ge,{document:n,mode:"read",className:"s-doc-focus-document"})}},Xt={id:"directory",canHandle:e=>e.kind==="directory",render:({resource:e,openFilePreview:t})=>{const n=e,r=Zt(n.realPath,n.rootPath);return a.jsxs("div",{className:"s-file-preview-directory",children:[a.jsx("div",{className:"s-file-preview-breadcrumb","aria-label":"Directory breadcrumb",children:r.map((s,i)=>{const c=i===r.length-1;return a.jsxs("div",{className:"s-file-preview-breadcrumb-item",children:[i>0&&a.jsx(Rt,{size:12,"aria-hidden":"true"}),c?a.jsx("span",{className:"s-file-preview-breadcrumb-current",children:s.label}):a.jsx("button",{type:"button",className:"s-file-preview-breadcrumb-link",onClick:()=>t(s.path),children:s.label})]},s.path)})}),a.jsxs("div",{className:"s-file-preview-directory-list",role:"list",children:[n.entries.map(s=>a.jsxs("button",{type:"button",className:"s-file-preview-entry",onClick:()=>t(s.path),children:[a.jsx("span",{className:"s-file-preview-entry-icon","aria-hidden":"true",children:s.kind==="directory"?a.jsx(xt,{size:14}):a.jsx(It,{size:14})}),a.jsx("span",{className:"s-file-preview-entry-name",children:s.name}),a.jsx("span",{className:"s-file-preview-entry-kind",children:s.kind==="directory"?"dir":"file"})]},s.realPath)),n.entries.length===0&&a.jsx("div",{className:"s-file-preview-directory-empty",children:"This directory is empty."})]})]})}};function Zt(e,t){const n=t==="/"?"/":t.replace(/\/+$/u,""),r=e==="/"?"/":e.replace(/\/+$/u,""),s=n.split("/").filter(Boolean),i=r.split("/").filter(Boolean),c=[{label:s[s.length-1]??"/",path:n||"/"}];let p=n||"/";for(let u=s.length;u<i.length;u+=1){const d=i[u];d&&(p=p==="/"?`/${d}`:`${p}/${d}`,c.push({label:d,path:p}))}return c}const en={id:"html",canHandle:e=>e.kind==="file"&&e.previewable&&e.mediaType==="text/html",render:({resource:e})=>a.jsx("div",{className:"s-file-preview-html-wrap",children:a.jsx("iframe",{className:"s-file-preview-html-frame",src:e.kind==="file"?e.rawUrl:"",title:e.title,sandbox:"allow-forms allow-popups allow-popups-to-escape-sandbox allow-scripts",referrerPolicy:"no-referrer"})})},tn={id:"image",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("image/"),render:({resource:e})=>a.jsx("div",{className:"s-file-preview-image-wrap",children:a.jsx("div",{className:"s-file-preview-image-stage",children:a.jsx("img",{className:"s-file-preview-image",src:e.kind==="file"?e.rawUrl:"",alt:e.title})})})},nn={id:"markdown",canHandle:e=>e.kind==="file"&&e.previewable&&e.mediaType==="text/markdown",render:({resource:e})=>{const t=e,n=Ke({id:t.realPath,title:t.title,uri:t.realPath,mediaType:t.mediaType,value:t.content,filename:t.title,kind:"markdown",readOnly:!0});return a.jsx(Ge,{document:n,mode:"preview",className:"s-doc-focus-document"})}},rn={id:"video",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("video/"),render:({resource:e})=>{const t=e;return a.jsx("div",{className:"s-file-preview-media-wrap",children:a.jsx("div",{className:"s-file-preview-media-stage",children:a.jsx("video",{className:"s-file-preview-video",src:t.rawUrl,controls:!0})})})}},on=[Xt,nn,en,Yt,tn,rn,Wt,zt];function sn({path:e,onOpenPath:t,onOpenInCode:n,onClose:r}){const[s,i]=o.useState(null),[c,p]=o.useState(null),[u,d]=o.useState(!1),[f,P]=o.useState(null),D=o.useRef(null);o.useEffect(()=>{D.current=f},[f]),o.useEffect(()=>{if(!e){i(null),p(null),d(!1);return}let b=!1;return d(!0),p(null),i(null),q(`/api/file/preview?path=${encodeURIComponent(e)}`).then(y=>{b||(i(y),an(y,D.current,P))}).catch(y=>{b||p(y instanceof Error?y.message:"could not load file")}).finally(()=>{b||d(!1)}),()=>{b=!0}},[e]);const{currentIndex:M,prevPath:v,nextPath:h}=o.useMemo(()=>{if(!s||s.kind!=="file"||!f)return{currentIndex:-1,prevPath:null,nextPath:null};const b=f.files.findIndex(y=>y.realPath===s.realPath);return b<0?{currentIndex:-1,prevPath:null,nextPath:null}:{currentIndex:b,prevPath:b>0?f.files[b-1].path:null,nextPath:b<f.files.length-1?f.files[b+1].path:null}},[s,f]);if(o.useEffect(()=>{if(!e)return;const b=y=>{if(y.key==="Escape"){r();return}if(y.target instanceof HTMLElement){const g=y.target.tagName;if(g==="INPUT"||g==="TEXTAREA"||y.target.isContentEditable)return}y.metaKey||y.ctrlKey||y.altKey||(y.key==="ArrowLeft"&&v?(y.preventDefault(),t(v)):y.key==="ArrowRight"&&h?(y.preventDefault(),t(h)):y.key==="Backspace"&&f&&s?.kind==="file"&&(y.preventDefault(),t(f.dirPath)))};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[e,r,t,v,h,f,s]),!e)return null;const w=()=>{q("/api/file/reveal",{method:"POST",body:JSON.stringify({path:s?.realPath??e})}).catch(b=>{p(b instanceof Error?b.message:"reveal failed")})},I=s?on.find(b=>b.canHandle(s))??null:null,O=!!(s&&s.kind==="file"&&f&&M>=0&&f.files.length>1),k=[];O&&f&&k.push({label:`Folder: ${f.dirTitle}`,icon:a.jsx(Gt,{size:12}),onClick:()=>t(f.dirPath),title:`Back to ${f.dirTitle} (Backspace)`}),k.push({label:"Open in Code",icon:a.jsx(Lt,{size:12}),onClick:()=>{s?.kind==="file"&&n(s.realPath,s.rootPath)},title:"Continue with this file in Scout’s Code browser",disabled:s?.kind!=="file"}),k.push({label:"Show in folder",icon:a.jsx(Tt,{size:12}),onClick:w,title:"Show this file in its operating system folder",hideLabel:!0});const j=s?ln(s):[];O&&j.unshift(`${M+1} / ${f.files.length}`);const R=s&&I?I.render({resource:s,openFilePreview:t}):null;return a.jsx(At,{open:!0,kind:cn(s),document:null,title:s?.title??e.split("/").pop()??"File",eyebrow:"File preview",subtitle:s?.realPath??e,meta:j,state:u?"Loading…":null,error:c,body:R?a.jsxs("div",{className:`s-file-preview-shell${O?" s-file-preview-shell-nav":""}`,children:[O&&a.jsx("button",{type:"button",className:"s-file-preview-side-nav s-file-preview-side-nav-left",onClick:()=>v&&t(v),disabled:!v,"aria-label":"Previous file",title:"Previous file (←)",children:a.jsx(Ot,{size:18,strokeWidth:1.8,"aria-hidden":"true"})}),a.jsx("div",{className:"s-file-preview-shell-body",children:R}),O&&a.jsx("button",{type:"button",className:"s-file-preview-side-nav s-file-preview-side-nav-right",onClick:()=>h&&t(h),disabled:!h,"aria-label":"Next file",title:"Next file (→)",children:a.jsx(_t,{size:18,strokeWidth:1.8,"aria-hidden":"true"})})]}):null,actions:k,onClose:r})}function an(e,t,n){if(e.kind==="directory"){const s=e.entries.filter(i=>i.kind==="file");n({dirPath:e.path,dirTitle:e.title,files:s});return}if(!t){n(null);return}t.files.some(s=>s.realPath===e.realPath)||n(null)}function cn(e){return!e||e.kind==="directory"||e.mediaType==="text/markdown"||e.mediaType==="text/plain"?"doc":"code"}function ln(e){return e.kind==="directory"?[`${e.entries.length} ${e.entries.length===1?"entry":"entries"}`]:[...e.previewable&&e.truncated?["truncated"]:[],un(e.sizeBytes),e.mediaType]}function un(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const Qe={activity:"idle",brief:{lastDeliveredAt:null},reminders:{dueCount:0,upcomingCount:0,due:[],next:null},voice:{available:null,setupBlocked:!1,replies:!1},error:null,session:{title:null,lastActivityAt:null},conversation:{messageCount:0,loading:!0}},Q=()=>{},Ye={focusScoutbot:Q,triggerBrief:Q,triggerAskState:Q,toggleVoiceReplies:Q,openScoutbotSettings:Q,startNewChat:Q,dismissReminder:Q,askReminderStatus:Q},Ee=o.createContext(null);function dn({children:e}){const[t,n]=o.useState(Qe),r=o.useRef(Ye),s=o.useCallback(u=>{n(d=>fn(d,u)?d:u)},[]),i=o.useCallback(u=>{r.current=u},[]),c=o.useMemo(()=>({focusScoutbot:()=>r.current.focusScoutbot(),triggerBrief:()=>r.current.triggerBrief(),triggerAskState:()=>r.current.triggerAskState(),toggleVoiceReplies:()=>r.current.toggleVoiceReplies(),openScoutbotSettings:()=>r.current.openScoutbotSettings(),startNewChat:()=>r.current.startNewChat(),dismissReminder:u=>r.current.dismissReminder(u),askReminderStatus:u=>r.current.askReminderStatus(u)}),[]),p=o.useMemo(()=>({state:t,actions:c,publishState:s,registerActions:i}),[t,c,s,i]);return a.jsx(Ee.Provider,{value:p,children:e})}function Ar(){const e=o.useContext(Ee);return e?{state:e.state,actions:e.actions}:{state:Qe,actions:Ye}}function Rr(){const e=o.useContext(Ee);return e?{publishState:e.publishState,registerActions:e.registerActions}:null}function fn(e,t){return e.activity===t.activity&&e.brief.lastDeliveredAt===t.brief.lastDeliveredAt&&e.reminders.dueCount===t.reminders.dueCount&&e.reminders.upcomingCount===t.reminders.upcomingCount&&pn(e.reminders.due,t.reminders.due)&&Xe(e.reminders.next,t.reminders.next)&&e.voice.available===t.voice.available&&e.voice.setupBlocked===t.voice.setupBlocked&&e.voice.replies===t.voice.replies&&e.error===t.error&&e.session.title===t.session.title&&e.session.lastActivityAt===t.session.lastActivityAt&&e.conversation.messageCount===t.conversation.messageCount&&e.conversation.loading===t.conversation.loading}function pn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!Xe(e[n],t[n]))return!1;return!0}function Xe(e,t){return e===t?!0:!e||!t?!1:e.id===t.id&&e.body===t.body&&e.status===t.status&&e.dueAt===t.dueAt}const hn="/api/voice/realtime/call",Ze="/api/voice/realtime/lease",et="/api/voice/realtime/settings",mn="x-openscout-realtime-voice-lease",tt="surface.realtime-voice",Ir="scout:realtime-voice-stop",Ce="scout:realtime-voice-settings",vn={noise_reduction:{type:"far_field"},turn_detection:{type:"server_vad",threshold:.6,prefix_padding_ms:300,silence_duration_ms:500,create_response:!0,interrupt_response:!0}},gn={noise_reduction:{type:"near_field"},turn_detection:{type:"server_vad",threshold:.5,prefix_padding_ms:300,silence_duration_ms:500,create_response:!0,interrupt_response:!0}},wn="/api/scoutbot/chat",nt="openscout.realtime-voice-settings";function rt(e){return q(et,{signal:e,cache:"no-store"})}function Nr(e){return q(et,{method:"PUT",body:JSON.stringify({enabled:e})})}function Lr(e){if(window.dispatchEvent(new CustomEvent(Ce,{detail:e})),!("BroadcastChannel"in window))return;const t=new BroadcastChannel(nt);t.postMessage(e),t.close()}function bn(e){const t=r=>{const s=r.detail;Fe(s)&&e(s)};window.addEventListener(Ce,t);const n="BroadcastChannel"in window?new BroadcastChannel(nt):null;return n&&(n.onmessage=r=>{Fe(r.data)&&e(r.data)}),()=>{window.removeEventListener(Ce,t),n?.close()}}function Fe(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.enabled=="boolean"&&typeof t.configuredEnabled=="boolean"&&(t.source==="settings"||t.source==="environment")&&typeof t.locked=="boolean"}const yn=25e3;async function Sn(e={}){if(ee(e.signal),!globalThis.RTCPeerConnection||!navigator.mediaDevices?.getUserMedia)throw new Error("This browser does not support realtime audio calls.");if(!(await rt(e.signal)).enabled)throw new Error("Live voice is off. Turn it on in Settings → Voice before starting a call.");ee(e.signal),e.onState?.("connecting");const n=new RTCPeerConnection,r=new Audio;r.autoplay=!0;let s=!1,i=null,c=null,p=null,u=0,d=0;const f=(h,w,I="voice")=>{d+=1,e.onTrace?.({id:`voice-${d}`,at:Date.now(),kind:I,label:h,...w?{detail:w}:{}})};let P=null;const D=()=>{if(P)return P;s=!0,e.signal?.removeEventListener("abort",v),p&&clearInterval(p),p=null,i?.getTracks().forEach(w=>w.stop()),r.pause(),r.srcObject=null,n.close();const h=c;return c=null,P=(async()=>{h&&await On(h),e.onState?.("ended")})(),P},M=()=>{D().catch(h=>{e.onError?.(h instanceof Error?h.message:"Could not release the realtime voice lease."),e.onState?.("error")})},v=()=>{M()};e.signal?.addEventListener("abort",v,{once:!0}),n.ontrack=({streams:h})=>{const w=h[0];if(!w||s)return;const[I]=w.getAudioTracks();I&&I.addEventListener("ended",()=>{s||e.onError?.("Realtime voice audio ended unexpectedly.")}),r.srcObject=w,r.play().catch(()=>{e.onError?.("Browser playback was blocked. Interact with the page, then start the call again.")})},n.onconnectionstatechange=()=>{s||(n.connectionState==="connected"?(e.onState?.("live"),f("Realtime channel connected","Scoutbot bridge is ready")):(n.connectionState==="failed"||n.connectionState==="disconnected")&&(e.onError?.("Realtime voice connection ended unexpectedly."),M()))};try{i=await Nn(e.inputDeviceName,e.signal),ee(e.signal);for(const x of i.getTracks())n.addTrack(x,i);const h=n.createDataChannel("oai-events"),w=new Set;let I=Promise.resolve(),O=!1,k=null;const j=[],R=x=>{if(s||h.readyState!=="open")return!1;try{return h.send(JSON.stringify(x)),!0}catch{return e.onError?.("Realtime voice events channel closed unexpectedly."),!1}},b=()=>{if(O||k||j.length===0)return;const x=j.shift();if(x){if(k=x,!R({type:"response.create",response:{instructions:x}})){k=null,j.unshift(x);return}O=!0}},y=x=>{j.push(x),b()};h.addEventListener("open",()=>{if(s)return;const x=In(e.inputDeviceName);if(!R({type:"session.update",session:{type:"realtime",audio:{input:x}}})){e.onError?.("Could not configure Scout's realtime microphone processing.");return}f("Scoutbot bridge ready","Live fleet context is available"),y("Open with one brief audible greeting: 'Hi, I’m Scoutbot. I can check the fleet and coordinate through Scout. What would you like to work on?'")}),h.addEventListener("error",()=>{s||e.onError?.("Realtime voice events channel closed unexpectedly.")}),h.addEventListener("message",x=>{const C=En(x.data);if(C?.type==="error"){if(ot(C.message)){k&&(j.unshift(k),k=null),O=!0,f("Scoutbot reply queued","Waiting for the current spoken response to finish","scoutbot");return}e.onError?.(C.message??"OpenAI Realtime reported an error.");return}if(C?.type==="response.created"){O=!0,k=null;return}if(C?.type==="response.done"){O=!1,k=null;for(const H of kn(C))H.name!=="ask_scoutbot"||w.has(H.callId)||(w.add(H.callId),I=I.then(()=>Cn({functionCall:H,route:e.getRoute?.()??e.route,uiContext:e.getUiContext?.(),onReply:e.onScoutbotReply,onTrace:f,send:R,requestResponse:y})).catch(J=>{e.onError?.(J instanceof Error?J.message:"Scoutbot could not complete the voice request.")}));b()}});const g=await ge(n.createOffer(),e.signal);if(await ge(n.setLocalDescription(g),e.signal),!g.sdp)throw new Error("Could not create a WebRTC offer.");const T=await fetch(hn,{method:"POST",headers:{"content-type":"application/sdp"},body:g.sdp,signal:e.signal});c=T.headers.get(mn)?.trim()||null;const L=await ge(T.text(),e.signal);if(!T.ok)throw new Error(An(L,T.status));if(!c)throw new Error("Scout started the audio connection without a concurrency lease. Please try again.");return p=setInterval(()=>{if(!c||s)return;const x=c;Ln(x).then(C=>{if(!(s||x!==c)){if(C){u=0;return}e.onError?.("Realtime voice lost its server lease. Reconnect to continue safely."),M()}}).catch(()=>{u+=1,!(u<2||s)&&(e.onError?.("Realtime voice could not renew its server lease. Check the connection and try again."),M())})},yn),await ge(n.setRemoteDescription({type:"answer",sdp:L}),e.signal),ee(e.signal),{leaseId:c,stop:D}}catch(h){throw await D(),h}}async function Cn(e){const t=xn(e.functionCall.arguments);if(!t){e.onTrace("Scoutbot request could not be read",void 0,"error"),be(e,{ok:!1,error:"The voice request did not include a usable Scoutbot prompt."});return}e.onTrace("Scoutbot is checking the control plane",t,"scoutbot");try{const n=await fetch(wn,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({body:t,route:e.route,uiContext:e.uiContext})}),r=await n.text();if(!n.ok)throw new Error(Tn(r,n.status));const s=JSON.parse(r),i=typeof s.reply?.body=="string"?s.reply.body.trim():"";if(!i)throw new Error("Scoutbot returned an empty reply.");const c=Je(i).filter(d=>d.type==="ask-agent").length,p=e.onReply?await e.onReply(i):{agentRequests:{requested:c,sent:0,failed:c}},u=St(i);e.onTrace("Scoutbot reply ready",void 0,"scoutbot"),be(e,{ok:!0,reply:u,...p.agentRequests.requested>0?{agentRequests:p.agentRequests}:{}})}catch(n){const r=n instanceof Error?n.message:"Scoutbot could not complete the voice request.";e.onTrace("Scoutbot request failed",r,"error"),be(e,{ok:!1,error:r})}}function be(e,t){if(!e.send({type:"conversation.item.create",item:{type:"function_call_output",call_id:e.functionCall.callId,output:JSON.stringify(t)}}))return;const r=t.agentRequests;e.requestResponse(t.ok?r&&r.requested>0?r.failed>0?"Answer using the Scoutbot result. Say clearly that Scoutbot tried to send the agent request automatically but delivery failed, and tell the operator to check the activity log. Be concise and do not mention tools, JSON, fences, or implementation details.":"Answer using the Scoutbot result. Say clearly that the agent request was sent automatically. Do not claim the requested work is complete. Be concise and do not mention tools, JSON, fences, or implementation details.":"Answer using the Scoutbot result. Speak the useful answer naturally and concisely. Do not mention tools, JSON, fences, or implementation details.":"Briefly tell the operator that Scoutbot could not complete the live lookup and state the returned error plainly.")}function ot(e){const t=e?.toLowerCase()??"";return t.includes("active response in progress")||t.includes("conversation already has an active response")||t.includes("response is already in progress")}function En(e){if(typeof e!="string")return null;try{const t=JSON.parse(e);return{...typeof t.type=="string"?{type:t.type}:{},...typeof t.error?.message=="string"?{message:t.error.message}:{},...t.response&&typeof t.response=="object"?{response:t.response}:{}}}catch{return null}}function kn(e){return Array.isArray(e.response?.output)?e.response.output.flatMap(t=>{if(!t||typeof t!="object")return[];const n=t;return n.type!=="function_call"||typeof n.call_id!="string"||typeof n.name!="string"||typeof n.arguments!="string"?[]:[{callId:n.call_id,name:n.name,arguments:n.arguments}]}):[]}function xn(e){try{const t=JSON.parse(e);if(typeof t.request!="string")return null;const n=t.request.trim();return n?n.slice(0,8e3):null}catch{return null}}function Tn(e,t){try{const n=JSON.parse(e);if(typeof n.error=="string"&&n.error.trim())return n.error}catch{}return`Scoutbot could not complete the live lookup (HTTP ${t}).`}function An(e,t){try{const n=JSON.parse(e);if(typeof n.error=="string"&&n.error.trim())return n.error}catch{}return`Could not start realtime voice (HTTP ${t}).`}async function ge(e,t){return t?(ee(t),new Promise((n,r)=>{const s=()=>r(ke(t));t.addEventListener("abort",s,{once:!0}),e.then(i=>{t.removeEventListener("abort",s),n(i)},i=>{t.removeEventListener("abort",s),r(i)})})):e}async function Be(e,t){return t?(ee(t),new Promise((n,r)=>{let s=!1;const i=()=>{s=!0,r(ke(t))};t.addEventListener("abort",i,{once:!0}),e.then(c=>{if(t.removeEventListener("abort",i),s||t.aborted){c.getTracks().forEach(p=>p.stop());return}n(c)},c=>{t.removeEventListener("abort",i),s||r(c)})})):e}const Ue={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,channelCount:1},Rn=/\b(?:airpods?|earbuds?|earphones?|headsets?|headphones?|buds?|hands[- ]?free)\b/iu;function In(e){return Rn.test(e?.trim()??"")?gn:vn}async function Nn(e,t){const n=await Ve(e);let r=await Be(navigator.mediaDevices.getUserMedia({audio:{...Ue,...n?{deviceId:{exact:n.deviceId}}:{}}}),t);if(!n&&e?.trim()){const s=await Ve(e),i=r.getAudioTracks?.()[0]?.label?.trim().toLocaleLowerCase()??"";if(s&&s.label.trim().toLocaleLowerCase()!==i)try{const c=await Be(navigator.mediaDevices.getUserMedia({audio:{...Ue,deviceId:{exact:s.deviceId}}}),t);r.getTracks().forEach(p=>p.stop()),r=c}catch(c){if(t?.aborted)throw r.getTracks().forEach(p=>p.stop()),c}}for(const s of r.getAudioTracks?.()??[])s.contentHint="speech";return r}async function Ve(e){const t=e?.trim().toLocaleLowerCase();if(!t||typeof navigator.mediaDevices.enumerateDevices!="function")return null;try{const n=(await navigator.mediaDevices.enumerateDevices()).filter(r=>r.kind==="audioinput"&&r.deviceId&&r.label.trim());return n.find(r=>r.label.trim().toLocaleLowerCase()===t)??n.find(r=>{const s=r.label.trim().toLocaleLowerCase();return s.includes(t)||t.includes(s)})??null}catch{return null}}function ee(e){if(e?.aborted)throw ke(e)}function ke(e){return e.reason instanceof Error?e.reason:new DOMException("Realtime voice connection was cancelled.","AbortError")}async function Ln(e){return(await fetch(`${Ze}/${encodeURIComponent(e)}`,{method:"PUT"})).ok}async function On(e){const t=await fetch(`${Ze}/${encodeURIComponent(e)}`,{method:"DELETE",keepalive:!0});if(!t.ok&&t.status!==404)throw new Error(`Could not release realtime voice lease (HTTP ${t.status}).`)}const _n=[{id:"home",label:"Home",description:"Fleet overview, briefings, and recent activity.",route:{view:"inbox"}},{id:"projects",label:"Projects",description:"Projects, agents, and project-scoped work.",route:{view:"agents-v2"},deepActions:["Open a project by projectSlug.","Open an agent by agentId."]},{id:"sessions",label:"Sessions",description:"Active and recent harness sessions.",route:{view:"sessions"},deepActions:["Open a session by sessionId."]},{id:"messages",label:"Messages",description:"Direct conversations and channels.",route:{view:"messages"},deepActions:["Open a conversation by conversationId.","Filter by all, direct messages, or channels."]},{id:"dispatch",label:"Dispatch",description:"Requests, flights, work, and delivery state.",route:{view:"broker"}},{id:"search",label:"Search",description:"Knowledge and indexed workspace search.",route:{view:"search"}},{id:"operations",label:"Operations",description:"Mission Control, live activity, agent lanes, runtime, and mesh health.",route:{view:"ops",mode:"mission"}},{id:"repositories",label:"Repositories",description:"Repository and worktree status, including diffs.",route:{view:"repos"},deepActions:["Open a repository by absolute root."]},{id:"code-browser",label:"Code Browser",description:"Read files in a project or worktree.",route:{view:"code"},deepActions:["Select a project with the project field; it accepts the displayed project name or slug.","Open a file inside it with path and optional wt.","Alternatively use absolute root and file fields.","Focus a line with line and optional endLine.","Deep links: scout://{project}/{path}, scout:///{absolute/path}, or legacy scout://code/{project}/{path}."]},{id:"terminals",label:"Terminals",description:"Observe or take over terminal sessions.",route:{view:"terminal"}},{id:"settings",label:"Settings",description:"Connections, agents, communications, credentials, voice, and devices.",route:{view:"settings"}}],jn=[{id:"comms",label:"Comms",description:"Native conversations and channels.",route:{view:"messages"},deepActions:["Open a conversation by conversationId.","Open a channel by channelId."]},{id:"projects",label:"Projects",description:"Native project and agent browser.",route:{view:"agents-v2"},deepActions:["Filter to a project by projectSlug.","Select an agent by agentId."]},{id:"terminals",label:"Terminals",description:"Native terminal workspace.",route:{view:"terminal"},deepActions:["Select an agent terminal by agentId."]},{id:"tail",label:"Tail",description:"Live agent and harness activity.",route:{view:"ops",mode:"tail"}},{id:"dispatch",label:"Dispatch",description:"Dispatch and coordination overview.",route:{view:"broker"}},{id:"agent-lanes",label:"Agent Lanes",description:"Native lane overview for active agents.",route:{view:"ops",mode:"lanes"}},{id:"repositories",label:"Repositories",description:"Native repository and worktree status.",route:{view:"repos"}},{id:"code-browser",label:"Code Browser",description:"Embedded read-only project browser.",route:{view:"code"},deepActions:["Select a project with the project field; it accepts the displayed project name or slug.","Open a file inside it with path and optional wt.","Alternatively use absolute root and file fields.","Focus a line with line and optional endLine.","Deep links: scout://{project}/{path}, scout:///{absolute/path}, or legacy scout://code/{project}/{path}."]},{id:"settings",label:"Settings",description:"Native app settings; Voice is directly addressable.",route:{view:"settings"},deepActions:["Open Voice settings with section=voice."]}];function Dn(e){const t=e==="macos";return{host:e,shellLabel:t?"Scout for macOS":"OpenScout web",destinations:t?jn:_n,rules:["When asked what navigation is available, list only these human labels and short descriptions.","Never expose internal Route.view names, aliases, URL fragments, or implementation vocabulary in the human reply.","Emit only a destination route or deep action explicitly described by this host context.","If the requested destination or deep action is absent, say it is not available in this app instead of approximating it with another page."]}}const Pn="scout:scoutbot-realtime-reply",we="scout:scoutbot-session-changed",Mn={enabled:!1,open:!1,state:"idle",leaseId:null,error:null,trace:[],chatState:null,sessionAction:null,setOpen:()=>{},startCall:async()=>{},endCall:async()=>!0,startNewChat:async()=>{},switchChat:async()=>{},updatePreferredModel:async e=>e,clearTrace:()=>{},openVoiceSettings:()=>{}},st=o.createContext(Mn);function Fn({children:e}){const{route:t,applyScoutbotUiAction:n}=at(),r=$e(tt,!0),[s,i]=o.useState(!1),c=r&&s,[p,u]=o.useState(!1),[d,f]=o.useState("idle"),[P,D]=o.useState(null),[M,v]=o.useState(null),[h,w]=o.useState([]),[I,O]=o.useState(null),[k,j]=o.useState(null),R=o.useRef(null),b=o.useRef(null),y=o.useRef(null),g=o.useRef(0),T=o.useRef(!1),L=o.useRef(!1),x=o.useRef({route:t,applyScoutbotUiAction:n});x.current={route:t,applyScoutbotUiAction:n};const C=o.useCallback((m,S,A="voice")=>{w(N=>[...N,{id:`voice-ui-${Date.now()}-${N.length}`,at:Date.now(),kind:A,label:m,...S?{detail:S}:{}}].slice(-100))},[]),H=o.useCallback(()=>w([]),[]),J=o.useCallback(async()=>{const m=await q("/api/scoutbot/session");return T.current||O(m),m},[]);o.useEffect(()=>{if(!r){i(!1);return}const m=new AbortController;let S=!1;const A=bn(N=>{i(N.enabled)});return rt(m.signal).then(N=>{S||i(N.enabled)}).catch(N=>{S||qe(N)||(i(!1),v(N instanceof Error?N.message:"Could not load live voice settings."))}),()=>{S=!0,m.abort(),A()}},[r]),o.useEffect(()=>{if(!c)return;const m=()=>{J().catch(S=>{T.current||v(S instanceof Error?S.message:"Could not load Scoutbot chats.")})};return m(),window.addEventListener(we,m),()=>window.removeEventListener(we,m)},[c,J]);const $=o.useCallback(async()=>{g.current+=1;const m=y.current;b.current?.abort(),b.current=null;const S=R.current;R.current=null;try{await S?.stop(),await m}catch(A){return T.current||(f("error"),v(A instanceof Error?A.message:"Could not end realtime voice cleanly.")),!1}return T.current||(D(null),f("ended"),C("Live voice ended","Microphone and host lease released","voice")),!0},[C]);o.useEffect(()=>{c||(u(!1),(R.current||d==="connecting"||d==="live")&&$())},[c,$,d]),o.useEffect(()=>(T.current=!1,()=>{T.current=!0,g.current+=1,b.current?.abort(),b.current=null,R.current?.stop().catch(()=>{}),R.current=null}),[]);const te=o.useCallback(async m=>{window.dispatchEvent(new CustomEvent(Pn,{detail:{body:m}}));const S=m.replace(/```[\s\S]*?```/gu,"").trim();S&&C("Scoutbot replied",S.slice(0,2e3),"scoutbot");let A=0,N=0,W=0;for(const B of Je(m))if(B.type==="ask-agent")A+=1,await Vn(B,C,v)?N+=1:W+=1;else if(B.type!=="reminder"){const _=Un(B),U=B.type==="navigate"||B.type==="view-file"?"navigation":"scoutbot";C(Bn(B),_,U),x.current.applyScoutbotUiAction(B),C(De()?"Action sent to Scout for macOS":"Action applied in OpenScout",_,U)}return await J().catch(()=>null),{agentRequests:{requested:A,sent:N,failed:W}}},[C,J]),ne=o.useCallback(()=>{const m={type:"navigate",route:{view:"settings",section:"voice"}};C("Voice settings requested",void 0,"navigation"),x.current.applyScoutbotUiAction(m)},[C]),re=o.useCallback(async()=>{if(!c){v("Turn on live voice in Settings → Voice before starting a call."),u(!1);return}if(L.current||d==="connecting"||d==="live")return;L.current=!0,b.current?.abort();const m=R.current;R.current=null;try{await m?.stop(),D(null)}catch(_){f("error"),v(_ instanceof Error?_.message:"Could not end the previous realtime voice call."),L.current=!1;return}const S=new AbortController;b.current=S;const A=g.current+1;g.current=A;let N=()=>{};const W=new Promise(_=>{N=_});y.current=W;let B=!1;v(null),w([{id:"connecting",at:Date.now(),label:"Connecting secure audio"}]),f("connecting");try{const _=await jt().then(({settings:V})=>V.inputDeviceName).catch(()=>null),U=await Sn({signal:S.signal,inputDeviceName:_,getRoute:()=>x.current.route,getUiContext:()=>Dn(De()?"macos":"web"),onState:V=>{!T.current&&g.current===A&&f(V)},onError:V=>{if(!(T.current||g.current!==A)){if(ot(V)){C("Scoutbot reply queued","Waiting for the current spoken response to finish","scoutbot");return}v(V),C("Voice issue",V,"error")}},onTrace:V=>{!T.current&&g.current===A&&w(ue=>[...ue,V].slice(-100))},onScoutbotReply:V=>!T.current&&g.current===A?te(V):{agentRequests:{requested:0,sent:0,failed:0}}});if(T.current||S.signal.aborted||g.current!==A){await U.stop();return}R.current=U,D(U.leaseId),B=!0}catch(_){if(!T.current&&g.current===A&&!qe(_)){f("error");const U=_ instanceof Error?_.message:"Could not start realtime voice.";v(U),C("Live voice could not start",U,"error")}}finally{!B&&b.current===S&&(b.current=null),N(),y.current===W&&(y.current=null),L.current=!1}},[C,te,c,d]),oe=o.useCallback(async()=>{if(!k){j("new"),v(null);try{if((R.current||d==="connecting"||d==="live")&&!await $())return;if(I?.session.messages.length===0){w([{id:`voice-chat-${Date.now()}`,at:Date.now(),kind:"scoutbot",label:"New live chat ready"}]);return}const m=await q("/api/scoutbot/session/reset",{method:"POST"});O(m),w([{id:`voice-chat-${Date.now()}`,at:Date.now(),kind:"scoutbot",label:"New live chat ready"}]),window.dispatchEvent(new CustomEvent(we,{detail:{id:m.session.id}}))}catch(m){const S=m instanceof Error?m.message:"Could not start a new Scoutbot chat.";v(S),C("Could not start a new live chat",S,"error")}finally{j(null)}}},[C,I?.session.messages.length,$,k,d]),se=o.useCallback(async m=>{if(!(!m||k||m===I?.session.id)){j(m),v(null);try{if((R.current||d==="connecting"||d==="live")&&!await $())return;const S=await q("/api/scoutbot/session/switch",{method:"POST",body:JSON.stringify({id:m})});O(S),w([{id:`voice-chat-${Date.now()}`,at:Date.now(),kind:"scoutbot",label:"Live chat restored",detail:S.session.title}]),window.dispatchEvent(new CustomEvent(we,{detail:{id:S.session.id}}))}catch(S){const A=S instanceof Error?S.message:"Could not switch Scoutbot chats.";v(A),C("Could not restore the live chat",A,"error")}finally{j(null)}}},[C,I?.session.id,$,k,d]),ie=o.useCallback(async m=>{const S=m.trim();if(!S)throw new Error("Preferred model is required.");const A=await q("/api/scoutbot/config",{method:"POST",body:JSON.stringify({model:S})});return O(N=>N&&{...N,config:{...N.config,...A.config}}),C("Scoutbot preferred model updated",A.config.model,"scoutbot"),A.config.model},[C]),ae=o.useMemo(()=>({enabled:c,open:p,state:d,leaseId:P,error:M,trace:h,chatState:I,sessionAction:k,setOpen:u,startCall:re,endCall:$,startNewChat:oe,switchChat:se,updatePreferredModel:ie,clearTrace:H,openVoiceSettings:ne}),[c,p,d,P,M,h,I,k,re,$,oe,se,ie,H,ne]);return a.jsx(st.Provider,{value:ae,children:e})}function qe(e){return(e instanceof DOMException||e instanceof Error)&&e.name==="AbortError"}function Or(){return o.useContext(st)}function Bn(e){return e.type==="navigate"?"Navigation requested":e.type==="open-scoutbot"?"Scoutbot opened its panel":e.type==="refresh"?"Scoutbot refreshed live state":"Scoutbot opened the requested file"}function Un(e){return e.type==="navigate"?JSON.stringify(e.route):e.type==="view-file"?e.path:e.reason?.trim()||e.type}async function Vn(e,t,n){t("Scoutbot is coordinating",`Asking ${e.targetLabel}`,"agent");try{const r=await q("/api/scoutbot/actions/ask",{method:"POST",body:JSON.stringify({targetLabel:e.targetLabel,targetAgentId:e.targetAgentId,body:e.body,channel:e.channel})});return t("Scoutbot sent the request",r.flightId?`${r.targetAgentId??r.targetLabel} · run ${r.flightId}`:r.targetAgentId??r.targetLabel,"agent"),!0}catch(r){const s=r instanceof Error?r.message:"Could not send to agent.";return t("Scoutbot could not send the request",s,"error"),n(s),!1}}function ye(e,t){const n=t?.trim();n&&e.add(n)}function qn(e,t){const n=new Set;return ye(n,e.authorityNodeId),ye(n,e.homeNodeId),n.size===0&&ye(n,t),n}function it(e,t,n){return t?qn(e,n).has(t):!0}function Hn(e,t,n){return t?e.filter(r=>it(r,t,n)):e}function _r(e,t,n){return t?new Set(e.filter(r=>it(r,t,n)).map(r=>r.id)):null}function Y(e,t,n){return!t&&!n||n&&e.authorityNodeId===n?!0:t?e.agentId&&t.has(e.agentId)||e.actorId&&t.has(e.actorId)||e.ownerId&&t.has(e.ownerId)||e.nextMoveOwnerId&&t.has(e.nextMoveOwnerId)?!0:!!e.participantIds?.some(r=>t.has(r)):!1}function $n(e,t,n){return Y(e,t,n)}function jr(e,t,n){return!t&&!n?e:e.filter(r=>$n(r,t,n))}function Jn(e,t){return Y(e,t)}function Kn(e,t){return t?e.filter(n=>Jn(n,t)):e}function He(e,t){return Y(e,t)}function Dr(e,t){if(!e||!t)return e;const n=e.activeAsks.filter(c=>Y(c,t)),r=e.recentCompleted.filter(c=>Y(c,t)),s=e.needsAttention.filter(c=>Y(c,t)),i=Kn(e.activity,t);return{...e,totals:{active:n.length,recentCompleted:r.length,needsAttention:s.length,activity:i.length},activeAsks:n,recentCompleted:r,needsAttention:s,activity:i}}function Pr(e,t){if(!t)return e;const n=e.activeFlights.filter(i=>Y(i,t)),r=e.childWork.filter(i=>He(i,t));return He(e,t)||n.length>0||r.length>0?{...e,activeFlights:n,childWork:r}:null}function Gn(e){return!!(e&&(e.message.trim().length>0||e.files.length>0||e.forwardContext))}function Wn(e){return[e.name,e.type,e.size,e.lastModified].join(":")}function zn(e,t){const n=new Set;return[...e,...t].filter(r=>{const s=Wn(r);return n.has(s)?!1:(n.add(s),!0)})}function Qn(e,t){const n=t.intent??e?.intent??"new-task",r=n==="route-capture",s=n==="forward-message";return{intent:n,...r&&(t.agentId??e?.agentId)?{agentId:t.agentId??e?.agentId}:{},...r&&(t.conversationId??e?.conversationId)?{conversationId:t.conversationId??e?.conversationId}:{},message:t.message??e?.message??"",files:zn(e?.files??[],t.files??[]),attachmentFeedback:t.attachmentFeedback??e?.attachmentFeedback??null,mode:r?t.preferExistingChat===void 0?e?.mode??"new-session":t.preferExistingChat?"existing-chat":"new-session":"new-session",projectPath:t.projectPath??e?.projectPath??"",projectQuery:e?.projectQuery??"",...s&&(t.forwardContext??e?.forwardContext)?{forwardContext:t.forwardContext??e?.forwardContext}:{},forwardContextMode:s?t.forwardContextMode??e?.forwardContextMode??"selected-message":"selected-message"}}function Yn({request:e,onClose:t,onOpenCapture:n}){const{agents:r,route:s,navigate:i}=at(),c=vt(s),p=Hn(r,c),u=Pt(s,p),[d,f]=o.useState(0),[P,D]=o.useState(null),[M,v]=o.useState(null),h=o.useRef(0),w=e?Qn(M,e):null,I=o.useCallback((k,j)=>{if(k.length===0)return;const R=!!(u.agentId||u.conversationId);n({intent:R?"route-capture":"new-task",files:k,attachmentFeedback:j,agentId:u.agentId??void 0,conversationId:u.conversationId??void 0,preferExistingChat:u.canUseExistingChat})},[n,u]);o.useEffect(()=>{if(!P)return;const k=window.setTimeout(()=>D(null),5e3);return()=>window.clearTimeout(k)},[P]),o.useEffect(()=>{const k=g=>{ve(g.dataTransfer)&&(g.preventDefault(),h.current+=1,f(h.current))},j=g=>{ve(g.dataTransfer)&&(g.preventDefault(),g.dataTransfer&&(g.dataTransfer.dropEffect="copy"))},R=()=>{h.current!==0&&(h.current=Math.max(0,h.current-1),f(h.current))},b=g=>{if(!ve(g.dataTransfer))return;g.preventDefault();const T=Pe(g.dataTransfer),L=T.filter(Me),x=T.length-L.length;if(h.current=0,f(0),L.length===0){D(T.length===0?"Scout could not read that file. Try the attachment picker instead.":"That file type is not supported. Drop markdown, code, an image, or a video clip.");return}const C=L.length===1?`Dropped ${L[0]?.name||"1 attachment"}.`:`Dropped ${L.length} attachments.`,H=x>0?`${C} Skipped ${x} unsupported ${x===1?"file":"files"}.`:C;D(null),I(L,H)},y=g=>{if(Dt(g.target)||!ve(g.clipboardData))return;g.preventDefault();const T=Pe(g.clipboardData),L=T.filter(Me);if(L.length===0){D(T.length===0?"Scout could not read that pasted file. Try the attachment picker instead.":"That pasted file type is not supported. Paste an image or video, or attach markdown or code.");return}I(L,L.length===1?`Pasted ${L[0]?.name||"1 attachment"}.`:`Pasted ${L.length} attachments.`)};return window.addEventListener("dragenter",k),window.addEventListener("dragover",j),window.addEventListener("dragleave",R),window.addEventListener("drop",b),window.addEventListener("paste",y),()=>{window.removeEventListener("dragenter",k),window.removeEventListener("dragover",j),window.removeEventListener("dragleave",R),window.removeEventListener("drop",b),window.removeEventListener("paste",y)}},[I]);const O=d>0&&!e;return a.jsxs(a.Fragment,{children:[O?a.jsx("div",{className:"s-capture-drop",role:"presentation",children:a.jsxs("div",{className:"s-capture-drop-card",children:[a.jsx("div",{className:"s-capture-drop-title",children:"Route capture"}),a.jsx("div",{className:"s-capture-drop-copy",children:"Drop markdown, code, an image, or a video clip to send it to the right agent or chat."})]})}):null,P?a.jsx("div",{className:"s-capture-feedback",role:"alert",children:P}):null,e?a.jsx(Mt,{agents:p,route:s,navigate:i,onClose:t,initialAgentId:w?.agentId,initialConversationId:w?.conversationId,initialMessage:w?.message,initialFiles:w?.files,initialAttachmentFeedback:w?.attachmentFeedback??void 0,initialIntent:w?.intent,initialProjectPath:w?.projectPath,initialProjectQuery:w?.projectQuery,initialForwardContext:w?.forwardContext,initialForwardContextMode:w?.forwardContextMode,defaultMode:w?.mode,draftRestored:Gn(M),onDraftChange:v,onDraftConsumed:()=>v(null)}):null]})}const xe=o.createContext(null),Xn=["hello","node.upserted","actor.registered","agent.registered","agent.endpoint.upserted","invocation.requested","flight.updated","delivery.state.changed","scout.dispatched"],Zn=new Set(Xn),er=3e4,tr=250;function nr(e,t){try{return JSON.stringify(e)===JSON.stringify(t)?e:t}catch{return t}}const rr={"--hud-bg":"oklch(0.118 0.004 260)","--hud-surface":"oklch(0.205 0.005 260)","--hud-ink":"oklch(0.975 0.006 260)","--hud-muted":"oklch(0.80 0.008 260)","--hud-dim":"oklch(0.70 0.007 260)","--hud-border":"oklch(0.975 0.006 260 / 0.08)","--hud-accent":"oklch(0.86 0.17 125)","--hud-accent-soft":"oklch(0.86 0.17 125 / 0.08)","--hud-shadow-soft":"oklch(0.08 0.004 260 / 0.42)","--hud-chrome-border":"oklch(0.975 0.006 260 / 0.04)","--hud-shadow-panel":"0 12px 34px oklch(0.08 0.004 260 / 0.45)","--hud-shadow-panel-hover":"0 14px 38px oklch(0.08 0.004 260 / 0.52)","--hud-shadow-bar":"0 -10px 28px oklch(0.08 0.004 260 / 0.38)","--hud-shadow-nav":"0 8px 24px oklch(0.08 0.004 260 / 0.32)","--hud-shadow-minimap":"0 10px 24px oklch(0.08 0.004 260 / 0.38)","--hud-status-ok":"oklch(0.80 0.15 155)","--hud-status-warn":"oklch(0.82 0.15 85)","--hud-status-error":"oklch(0.72 0.18 25)","--background":"0.132 0.004 260","--foreground":"0.965 0.006 260","--card":"0.178 0.005 260","--card-foreground":"0.965 0.006 260","--popover":"0.178 0.005 260","--popover-foreground":"0.965 0.006 260","--muted-foreground":"0.72 0.008 260","--scrim":"rgba(0, 0, 0, 0.5)","--scrim-soft":"rgba(0, 0, 0, 0.3)","--info":"#62b6ff","--shadow-card":"0 8px 22px rgba(0, 0, 0, 0.22)","--shadow-card-hover":"0 14px 36px rgba(0, 0, 0, 0.30)","--cat-gold":"#d7a978","--cat-purple":"#c58cff","--cat-sky":"#38bdf8","--scout-chrome-ink-strong":"color-mix(in srgb, var(--hud-ink) 94%, transparent)","--scout-chrome-ink":"color-mix(in srgb, var(--hud-ink) 84%, transparent)","--scout-chrome-ink-soft":"color-mix(in srgb, var(--hud-ink) 68%, transparent)","--scout-chrome-ink-faint":"color-mix(in srgb, var(--hud-ink) 64%, transparent)","--scout-chrome-ink-ghost":"color-mix(in srgb, var(--hud-ink) 56%, transparent)","--scout-chrome-hover":"color-mix(in srgb, var(--hud-ink) 5%, transparent)","--scout-chrome-active":"color-mix(in srgb, var(--hud-ink) 9%, transparent)","--scout-chrome-border-soft":"color-mix(in srgb, var(--hud-ink) 8%, transparent)","--scout-chrome-avatar-ink":"#111111","--hud-font-sans":"'Inter', ui-sans-serif, system-ui, sans-serif","--hud-font-mono":"'JetBrains Mono', ui-monospace, Menlo, monospace","--hud-font-serif":"'Spectral', 'Cormorant Garamond', Georgia, serif","--hud-font-accent-title":"'Inter Tight', var(--hud-font-sans)"},or={"--hud-bg":"oklch(0.982 0.008 78)","--hud-surface":"oklch(0.994 0.006 78)","--hud-ink":"oklch(0.26 0.018 72)","--hud-muted":"oklch(0.50 0.028 70)","--hud-dim":"oklch(0.64 0.022 72)","--hud-border":"oklch(0.86 0.016 75 / 0.92)","--hud-accent":"oklch(0.72 0.16 125)","--hud-accent-soft":"oklch(0.72 0.16 125 / 0.11)","--hud-shadow-soft":"oklch(0.42 0.02 70 / 0.11)","--hud-status-ok":"oklch(0.64 0.16 155)","--hud-status-warn":"oklch(0.72 0.15 85)","--hud-status-error":"oklch(0.62 0.19 25)","--background":"0.978 0.004 85","--foreground":"0.24 0.01 80","--card":"0.992 0.003 85","--card-foreground":"0.24 0.01 80","--popover":"0.992 0.003 85","--popover-foreground":"0.24 0.01 80","--muted-foreground":"0.56 0.014 80","--scrim":"rgba(28, 24, 20, 0.30)","--scrim-soft":"rgba(28, 24, 20, 0.16)","--info":"#2f7fd6","--shadow-card":"0 8px 22px oklch(0.42 0.02 70 / 0.09)","--shadow-card-hover":"0 14px 36px oklch(0.42 0.02 70 / 0.13)","--cat-gold":"#a9824f","--cat-purple":"#8b5cf6","--cat-sky":"#0ea5e9","--scout-chrome-ink-strong":"color-mix(in srgb, var(--hud-ink) 94%, transparent)","--scout-chrome-ink":"color-mix(in srgb, var(--hud-ink) 78%, transparent)","--scout-chrome-ink-soft":"color-mix(in srgb, var(--hud-ink) 60%, transparent)","--scout-chrome-ink-faint":"color-mix(in srgb, var(--hud-ink) 56%, transparent)","--scout-chrome-ink-ghost":"color-mix(in srgb, var(--hud-ink) 50%, transparent)","--scout-chrome-hover":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-active":"color-mix(in srgb, var(--hud-ink) 8%, transparent)","--scout-chrome-border-soft":"color-mix(in srgb, var(--hud-border) 80%, transparent)","--scout-chrome-avatar-ink":"#ffffff","--hud-font-sans":"'Inter', ui-sans-serif, system-ui, sans-serif","--hud-font-mono":"'JetBrains Mono', ui-monospace, Menlo, monospace","--hud-font-serif":"'Spectral', 'Cormorant Garamond', Georgia, serif","--hud-font-accent-title":"'Inter Tight', var(--hud-font-sans)"},sr=new Set(["--hud-bg","--hud-surface","--hud-ink","--hud-muted","--hud-dim","--hud-border","--hud-accent","--hud-accent-soft","--hud-shadow-soft","--hud-chrome-border","--hud-shadow-panel","--hud-shadow-panel-hover","--hud-shadow-bar","--hud-shadow-nav","--hud-shadow-minimap","--hud-status-ok","--hud-status-warn","--hud-status-error"]);function ir(e){return Object.fromEntries(Object.entries(e==="light"?or:rr).filter(([n])=>!sr.has(n)))}function Mr(){return o.useContext(xe)}function at(){const e=o.useContext(xe);if(!e)throw new Error("useScout must be used inside ScoutProvider");return e}function Fr({children:e,initialTheme:t="dark"}){const{route:n,navigate:r,navigateBack:s,canNavigateBack:i}=gt(),c=Ft(),p=$e(tt,!0),[u,d]=o.useState([]),[f,P]=o.useState(!1),[D,M]=o.useState({status:"checking",message:null,lastCheckedAt:null}),[v,h]=o.useState(_e),[w,I]=o.useState(null),O=o.useRef(!1),[k,j]=o.useState($t),[R,b]=o.useState(!1),[y,g]=o.useState(null),[T,L]=o.useState(null),[x,C]=o.useState(""),[H,J]=o.useState(null),$=n.view==="settings",te=o.useMemo(()=>n.view!=="broker"||!n.attemptId?null:y?.id===n.attemptId?y:null,[y,n]),ne=o.useMemo(()=>n.view!=="search"||!n.hitId?null:T?.id===n.hitId?T:null,[T,n]),re=o.useMemo(()=>n.view==="agents-v2"&&n.agentId&&n.sessionId?{agentId:n.agentId,sessionId:n.sessionId}:n.view==="sessions"&&n.sessionId?{agentId:n.agentId??"",sessionId:n.sessionId}:null,[n]),oe=o.useCallback((l,E)=>{if(n.view==="agents-v2"&&n.agentId===l){r({...n,sessionId:E},{replace:!0});return}if(n.view==="sessions"){r({view:"sessions",sessionId:E,agentId:l},{replace:!0});return}r({view:"agents-v2",agentId:l,sessionId:E},{replace:!0})},[r,n]),se=o.useCallback(()=>{r({view:"settings",section:"appearance"})},[r]),ie=o.useCallback(()=>{n.view==="settings"&&r({view:"inbox"})},[r,n.view]),ae=o.useCallback(l=>{J(l??{intent:"new-task"})},[]),m=o.useCallback(()=>J(null),[]),S=o.useCallback(l=>{g(l),!(n.view==="broker"&&n.attemptId===l.id)&&r({view:"broker",attemptId:l.id,...n.view==="broker"&&n.filter?{filter:n.filter}:{}},{replace:n.view==="broker"})},[r,n]),A=o.useCallback(()=>{g(null),n.view==="broker"&&n.attemptId&&r({view:"broker",...n.filter?{filter:n.filter}:{}},{replace:!0})},[r,n]),N=o.useCallback((l,E,F)=>{if(L(l),typeof E=="string"&&C(E.trim()),n.view==="search"&&n.hitId===l.id)return;const K=F??(n.view==="search"?n.filters:void 0);r({view:"search",...n.view==="search"&&n.mode?{mode:n.mode}:{},...K?{filters:K}:{},hitId:l.id},{replace:n.view==="search"})},[r,n]),W=o.useCallback(()=>{L(null),C(""),n.view==="search"&&n.hitId&&r({view:"search",...n.mode?{mode:n.mode}:{},...n.filters?{filters:n.filters}:{}},{replace:!0})},[r,n]),B=o.useMemo(()=>dt(),[]),_=c?.resolvedTheme??t,U=c?.template??"hudson",V=o.useMemo(()=>({...ir(_),...B??{}}),[B,_]),ue=o.useCallback(l=>{h(E=>({...E,...l}))},[]);o.useEffect(()=>{!f||u.length===0||h(l=>{const E=ft(l.agentCharacters,u);return E===l.agentCharacters?l:{...l,agentCharacters:E}})},[u,f]),o.useEffect(()=>{pt(_,U,v),ht(v)},[U,v,_]),o.useEffect(()=>{const l=E=>{E.key!==null&&E.key!==mt||h(_e())};return window.addEventListener("storage",l),()=>window.removeEventListener("storage",l)},[]);const Te=o.useMemo(()=>Ct(u),[u]),Ae=Te?.id??Et(u),Re=Te?.conversationId??null,de=o.useRef(null),X=o.useRef(null),fe=n.view==="ops"?"/api/agents":"/api/agents?detail=summary",pe=o.useCallback(()=>{M({status:"online",message:null,lastCheckedAt:Date.now()})},[]),he=o.useCallback(l=>{const E=Ut(l);M({status:Vt(E)?"offline":"degraded",message:E,lastCheckedAt:Date.now()})},[]),G=o.useCallback(async()=>{const l=de.current;if(l&&(await l.promise,l.url===fe))return;const E=(async()=>{try{const F=await q(fe);d(K=>nr(K,F)),pe()}catch(F){he(F)}finally{P(!0)}})();de.current={url:fe,promise:E};try{await E}finally{de.current?.promise===E&&(de.current=null)}},[fe,he,pe]),z=o.useCallback(async()=>{try{const l=await q("/api/onboarding/state");O.current=!1,I(l);const E=l.operatorName?.trim()||l.operatorNameSuggestion?.trim()||null;j(E),Jt(E),pe()}catch(l){he(l),O.current=!0,I({hasLocalConfig:!0,hasProjectConfig:!0,hasOperatorName:!0,localConfigPath:null,projectRoot:null,currentDirectory:null,operatorName:null,operatorNameSuggestion:null,needed:!1})}},[he,pe]),Ie=o.useCallback(()=>{b(!0),q("/api/onboarding/skip",{method:"POST",body:"{}"}).then(()=>z()).catch(()=>null)},[z]);o.useEffect(()=>{G(),z()},[G,z]),o.useEffect(()=>{const l=()=>{je()&&(G(),O.current&&z())},E=window.setInterval(l,er),F=bt(l);return()=>{window.clearInterval(E),F()}},[G,z]);const Ne=o.useMemo(()=>u.filter(l=>yt(l.state)).length,[u]),[ct,Le]=o.useState(null),ce=o.useCallback(l=>{l?.trim()&&Le(l.trim())},[]),le=o.useCallback(()=>Le(null),[]),Z=o.useCallback(l=>{if(!kt(l))switch(l.type){case"navigate":r(l.route);break;case"focus-composer":window.dispatchEvent(new CustomEvent("scout:composer-focus"));break;case"open-scoutbot":window.dispatchEvent(new CustomEvent("scout:scoutbot-panel-open",{detail:l}));break;case"refresh":G();break;case"view-file":ce(l.path);break}},[r,ce,G]),lt=o.useCallback((l,E)=>{const F=l.trim(),K=E.trim();if(!F||!K)return;const Oe=n.view==="conversation"||n.view==="messages"?n.conversationId:window.location.pathname==="/embed/thread"&&new URLSearchParams(window.location.search).get("conversationId")?.trim()||void 0;le(),Z({type:"navigate",route:{view:"code",root:K,file:F,...Oe?{returnConversationId:Oe}:{}}})},[Z,le,n]),me=o.useRef({applyScoutbotUiAction:Z});me.current={applyScoutbotUiAction:Z},wt(l=>{je()&&Zn.has(l.kind)&&(X.current!==null&&window.clearTimeout(X.current),X.current=window.setTimeout(()=>{X.current=null,G()},tr))}),o.useEffect(()=>()=>{X.current!==null&&window.clearTimeout(X.current)},[]),o.useEffect(()=>{const l=E=>{const F=E.detail,K=F&&typeof F=="object"&&"type"in F?F:null;K&&me.current.applyScoutbotUiAction(K)};return window.addEventListener("scout:scoutbot-ui-action",l),window.scoutScoutbot={applyUiAction:E=>me.current.applyScoutbotUiAction(E),navigate:E=>me.current.applyScoutbotUiAction({type:"navigate",route:E})},()=>{window.removeEventListener("scout:scoutbot-ui-action",l),window.scoutScoutbot?.applyUiAction&&delete window.scoutScoutbot}},[]);const ut=o.useMemo(()=>({route:n,navigate:r,navigateBack:s,canNavigateBack:i,agents:u,agentsLoaded:f,onlineCount:Ne,apiConnection:D,reload:G,appearanceDetails:v,updateAppearanceDetails:ue,onboarding:w,operatorName:k,refreshOnboarding:z,onboardingSkipped:R,skipOnboarding:Ie,settingsOpen:$,openSettings:se,closeSettings:ie,scoutbotAgentId:Ae,scoutbotConversationId:Re,applyScoutbotUiAction:Z,selectedBrokerAttempt:te,inspectBrokerAttempt:S,clearBrokerAttempt:A,selectedKnowledgeHit:ne,selectedKnowledgeQuery:x,inspectKnowledgeHit:N,clearKnowledgeHit:W,focusedSession:re,focusSession:oe,openFilePreview:ce,closeFilePreview:le,openContextCapture:ae,closeContextCapture:m}),[n,r,s,i,u,f,Ne,D,G,v,ue,w,k,z,R,Ie,$,se,ie,Ae,Re,Z,te,S,A,ne,x,N,W,re,oe,ce,le,ae,m]);return a.jsx(xe.Provider,{value:ut,children:a.jsx("div",{"data-scout-theme-mode":_,"data-scout-palette":v.palette,"data-scout-contrast":v.contrast,"data-scout-accent":v.accent,"data-scout-shell":v.shell,"data-scout-avatar-style":v.avatarStyle,"data-hudson-theme":_,"data-hudson-template":U,style:{...V},children:a.jsx("div",{"data-scout-theme":_,style:{display:"contents"},children:a.jsx(Bt,{children:a.jsxs(dn,{children:[p?a.jsx(Fn,{children:e}):e,a.jsx(sn,{path:ct,onOpenPath:ce,onOpenInCode:lt,onClose:le}),a.jsx(Yn,{request:H,onClose:m,onOpenCapture:ae})]})})})})})}export{Bt as C,rr as D,or as L,xe as S,Tr as a,Kn as b,Mr as c,Hn as d,jr as e,Ut as f,Dr as g,Fr as h,Vt as i,Pr as j,Gt as k,Rr as l,_r as m,tt as n,Or as o,we as p,Pn as q,Ir as r,Dn as s,Ar as t,at as u,rt as v,Nr as w,Lr as x};
@@ -1 +1 @@
1
- import{j as r}from"./index-DvLtl7rV.js";import{s as $,b as E}from"./colors-BtO5_zlx.js";import{A as M}from"./AgentAvatar-6-KBVKUu.js";function q({name:a,meta:i,sub:s,tone:o="neutral",agent:t,avatarName:c,avatarKind:e="user",leadingIcon:n,caret:l,active:j,selected:v,unread:N,depth:f=0,detail:d,expanded:h,activityLabel:w,worktreeLabel:u,activityTone:g="working",actions:p,pinned:x,onClick:k,onKeyDown:b,onContextMenu:y,onPointerEnter:C,onPointerLeave:P,title:R,tabIndex:z}){const A=l?l==="open":d!==void 0?!!h:void 0,B=["rr-row",f===1&&"rr-row--child",j&&"rr-row--active",v&&"rr-row--selected",N&&"rr-row--unread",h&&"rr-row--expanded",w&&"rr-row--motion",x&&"rr-row--pinned",p&&"rr-row--has-actions"].filter(Boolean).join(" ");return r.jsxs("div",{className:B,children:[r.jsxs("button",{type:"button",className:"rr-row-head",onClick:k,onKeyDown:b,onContextMenu:y,onPointerEnter:C,onPointerLeave:P,title:R,tabIndex:z,"aria-expanded":A,children:[r.jsx(T,{icon:n,tone:o,caret:l,agent:t,avatarName:c,avatarKind:e}),r.jsxs("span",{className:"rr-row-body",children:[r.jsxs("span",{className:"rr-row-name",children:[x?r.jsx("span",{className:"rr-row-pin-mark","aria-label":"Pinned",title:"Pinned",children:r.jsx(S,{})}):null,a]}),s&&r.jsx("span",{className:"rr-row-sub",children:s}),u&&r.jsx("span",{className:"rr-row-worktree",children:u}),w&&r.jsxs("span",{className:`rr-row-activity rr-row-activity--${g}`,children:[r.jsxs("span",{className:"rr-row-activity-bars","aria-hidden":!0,children:[r.jsx("span",{}),r.jsx("span",{}),r.jsx("span",{}),r.jsx("span",{})]}),r.jsx("span",{className:"rr-row-activity-label",children:w})]})]}),i&&r.jsx("span",{className:"rr-row-meta",children:i})]}),p?r.jsx("div",{className:"rr-row-actions",onClick:L=>L.stopPropagation(),children:p}):null,h&&d&&r.jsx("div",{className:"rr-row-detail",children:d})]})}function T({icon:a,tone:i,caret:s,agent:o,avatarName:t,avatarKind:c}){if(s)return r.jsx("span",{className:`rr-row-caret rr-row-caret--leading rr-row-caret--${s}`,"aria-hidden":!0,children:r.jsx(G,{open:s==="open"})});if(t||o){if(c==="channel")return r.jsx("span",{className:"rr-row-hash","aria-hidden":!0,children:"#"});const n=m(i),l=n==="active"||n==="available"||n==="working"||n==="in_turn";return r.jsx("span",{className:"rr-row-avatar-wrap","aria-hidden":!0,children:r.jsx(M,{agent:o,name:t??o?.name,placement:"row",size:20,tile:!0,presence:l})})}if(a)return r.jsx("span",{className:"rr-row-icon","aria-hidden":!0,children:a});const e=m(i);return r.jsx("span",{className:`rr-row-dot rr-row-dot--${e}`,style:e==="active"||e==="available"?{background:$(e)}:void 0,"aria-hidden":!0})}function G({open:a}){return r.jsx("svg",{className:`rr-chevron${a?" rr-chevron--open":""}`,viewBox:"0 0 12 12",width:"12",height:"12",fill:"none","aria-hidden":!0,children:r.jsx("path",{d:"M4.25 3L7.75 6L4.25 9",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function m(a){return a==="channel"||a==="dm"||a==="neutral"?a:E(a)}function S(){return r.jsx("svg",{width:"9",height:"9",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":!0,children:r.jsx("path",{d:"M9.8 1.6 14.4 6.2a1 1 0 0 1-.2 1.6l-2.7 1.1-.9 3.4a.7.7 0 0 1-1.2.3L6.3 9.5 2.8 13 1.7 11.9l3.5-3.5L2.1 5.3a.7.7 0 0 1 .3-1.2l3.4-.9 1.1-2.7a1 1 0 0 1 1.6-.2Z"})})}export{q as R};
1
+ import{j as r}from"./index-BI9AljSD.js";import{s as $,b as E}from"./colors-BtO5_zlx.js";import{A as M}from"./AgentAvatar-B7c0egdP.js";function q({name:a,meta:i,sub:s,tone:o="neutral",agent:t,avatarName:c,avatarKind:e="user",leadingIcon:n,caret:l,active:j,selected:v,unread:N,depth:f=0,detail:d,expanded:h,activityLabel:w,worktreeLabel:u,activityTone:g="working",actions:p,pinned:x,onClick:k,onKeyDown:b,onContextMenu:y,onPointerEnter:C,onPointerLeave:P,title:R,tabIndex:z}){const A=l?l==="open":d!==void 0?!!h:void 0,B=["rr-row",f===1&&"rr-row--child",j&&"rr-row--active",v&&"rr-row--selected",N&&"rr-row--unread",h&&"rr-row--expanded",w&&"rr-row--motion",x&&"rr-row--pinned",p&&"rr-row--has-actions"].filter(Boolean).join(" ");return r.jsxs("div",{className:B,children:[r.jsxs("button",{type:"button",className:"rr-row-head",onClick:k,onKeyDown:b,onContextMenu:y,onPointerEnter:C,onPointerLeave:P,title:R,tabIndex:z,"aria-expanded":A,children:[r.jsx(T,{icon:n,tone:o,caret:l,agent:t,avatarName:c,avatarKind:e}),r.jsxs("span",{className:"rr-row-body",children:[r.jsxs("span",{className:"rr-row-name",children:[x?r.jsx("span",{className:"rr-row-pin-mark","aria-label":"Pinned",title:"Pinned",children:r.jsx(S,{})}):null,a]}),s&&r.jsx("span",{className:"rr-row-sub",children:s}),u&&r.jsx("span",{className:"rr-row-worktree",children:u}),w&&r.jsxs("span",{className:`rr-row-activity rr-row-activity--${g}`,children:[r.jsxs("span",{className:"rr-row-activity-bars","aria-hidden":!0,children:[r.jsx("span",{}),r.jsx("span",{}),r.jsx("span",{}),r.jsx("span",{})]}),r.jsx("span",{className:"rr-row-activity-label",children:w})]})]}),i&&r.jsx("span",{className:"rr-row-meta",children:i})]}),p?r.jsx("div",{className:"rr-row-actions",onClick:L=>L.stopPropagation(),children:p}):null,h&&d&&r.jsx("div",{className:"rr-row-detail",children:d})]})}function T({icon:a,tone:i,caret:s,agent:o,avatarName:t,avatarKind:c}){if(s)return r.jsx("span",{className:`rr-row-caret rr-row-caret--leading rr-row-caret--${s}`,"aria-hidden":!0,children:r.jsx(G,{open:s==="open"})});if(t||o){if(c==="channel")return r.jsx("span",{className:"rr-row-hash","aria-hidden":!0,children:"#"});const n=m(i),l=n==="active"||n==="available"||n==="working"||n==="in_turn";return r.jsx("span",{className:"rr-row-avatar-wrap","aria-hidden":!0,children:r.jsx(M,{agent:o,name:t??o?.name,placement:"row",size:20,tile:!0,presence:l})})}if(a)return r.jsx("span",{className:"rr-row-icon","aria-hidden":!0,children:a});const e=m(i);return r.jsx("span",{className:`rr-row-dot rr-row-dot--${e}`,style:e==="active"||e==="available"?{background:$(e)}:void 0,"aria-hidden":!0})}function G({open:a}){return r.jsx("svg",{className:`rr-chevron${a?" rr-chevron--open":""}`,viewBox:"0 0 12 12",width:"12",height:"12",fill:"none","aria-hidden":!0,children:r.jsx("path",{d:"M4.25 3L7.75 6L4.25 9",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function m(a){return a==="channel"||a==="dm"||a==="neutral"?a:E(a)}function S(){return r.jsx("svg",{width:"9",height:"9",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":!0,children:r.jsx("path",{d:"M9.8 1.6 14.4 6.2a1 1 0 0 1-.2 1.6l-2.7 1.1-.9 3.4a.7.7 0 0 1-1.2.3L6.3 9.5 2.8 13 1.7 11.9l3.5-3.5L2.1 5.3a.7.7 0 0 1 .3-1.2l3.4-.9 1.1-2.7a1 1 0 0 1 1.6-.2Z"})})}export{q as R};
@@ -1 +1 @@
1
- import{r as o,j as n}from"./index-DvLtl7rV.js";/* empty css */import{D as O}from"./DataTable-Bp8tU9AK.js";import{p as W,a as L}from"./api-Co9aQ2Jw.js";import{t as U,n as R,f as Y}from"./time-Dhsh_2EG.js";import{u as G}from"./tail-events-Ps8KpKah.js";import{o as Q}from"./openContent-C6XO6kr5.js";import{u as X}from"./Provider-CtXJeLrP.js";/* empty css */import"./perf-PX8Rx0EP.js";import"./index-BWHgHrtv.js";import"./router-B9vQkNJL.js";import"./synthetic-agent-routing-aduMYO7P.js";import"./terminal-sessions-BQ6t92tJ.js";import"./sse-CD9MMUxl.js";import"./surface-activity-B1rgWB1i.js";import"./colors-BtO5_zlx.js";import"./scoutbot-BJIamJOH.js";import"./DocumentFocusViewer-Do3wQ_3Z.js";import"./createLucideIcon-DezKXSG2.js";import"./TextDocumentSurface-BflAwXeZ.js";import"./file-text-CqJgwxmv.js";import"./x-CAbNespN.js";import"./chevron-right-D-HdlPg8.js";import"./code-xml-D7pOQM9l.js";import"./arrow-left-Czpf-AE4.js";import"./arrow-right-BuzMnLYP.js";import"./scout-voice-BVUqGhth.js";import"./fx-z37u1o2z.js";import"./keyboard-nav-BLYDhL3Z.js";import"./NewChatComposer-_Stj0fZy.js";import"./text-BP3oyl8-.js";import"./voice-levels-Dcr3jglk.js";import"./loader-circle-pM56HNhR.js";import"./conversation-model-Dc02NsGp.js";import"./index-zvhpRHao.js";import"./HarnessMark-B979GCSB.js";import"./NewChatOrigin-B1u7ki70.js";import"./chevron-down-wciXnOQz.js";import"./search-CDko0PKE.js";import"./chunk-HRAB3GC3-Tyv9rzx7.js";const q=1e4,J=500,$=1e3,Z=6e4,D="/api/tail/discover",_=`/api/tail/recent?limit=${J}`,P=3e4,tt=[{key:"status",label:"status",cls:"s-atop-col-status",kind:"text",sortable:!1,defaultWidth:96,minWidth:70,render:t=>n.jsxs("span",{className:`s-atop-status s-atop-status--${t.status}`,children:[n.jsx("span",{className:"s-atop-status-dot","aria-hidden":"true"}),t.statusLabel]})},{key:"session",label:"session",cls:"s-atop-col-agent",kind:"text",sortable:!1,defaultWidth:168,minWidth:110,maxWidth:280,render:t=>n.jsxs("div",{className:"s-atop-agent-cell",title:t.sessionId??t.refId,children:[n.jsx("span",{className:`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${st(t.source)}`,children:t.source}),n.jsx("span",{className:"s-atop-agent-id",children:t.refId.slice(0,8)})]})},{key:"project",label:"project",cls:"s-atop-col-project",kind:"text",sortable:!1,defaultWidth:200,minWidth:96,maxWidth:360,render:t=>n.jsx("span",{title:t.cwd??t.project,children:t.project})},{key:"updated",label:"updated",cls:"s-atop-col-last",kind:"time",sortable:!1,defaultWidth:86,minWidth:64,render:t=>n.jsx("span",{title:Y(t.mtimeMs),children:U(Math.max(R(t.mtimeMs)??0,R(t.lastEvent?.ts)??0))||"-"})},{key:"size",label:"size",cls:"s-atop-col-runtime",kind:"number",sortable:!1,defaultWidth:80,minWidth:64,render:t=>nt(t.size)},{key:"path",label:"path",kind:"text",sortable:!1,defaultWidth:360,minWidth:160,maxWidth:800,render:t=>n.jsx("span",{title:t.transcriptPath,children:t.cwd??t.transcriptPath})}];function z(t){const i=t?.trim();if(!i)return null;const r=F(i);return r.endsWith(".jsonl")?r.slice(0,-6):r}function F(t){const i=t.replace(/[\\/]+$/,"");return i.split(/[\\/]/).filter(Boolean).at(-1)??i}function et(t){const r=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return r.pop(),r.at(-1)??""}function st(t){return t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function nt(t){if(!Number.isFinite(t)||t<0)return"-";if(t<1024)return`${t} B`;const i=t/1024;if(i<1024)return`${i.toFixed(i>=10?0:1)} KiB`;const r=i/1024;return`${r.toFixed(r>=10?0:1)} MiB`}function at(t,i){return i?[t.refId,t.sessionId??"",t.source,t.project,t.cwd??"",t.transcriptPath,t.lastEvent?.summary??"",t.process?.command??""].join(" ").toLowerCase().includes(i.toLowerCase()):!0}function B(t){return`${t.source}\0${t.cwd??""}`}function ot(t){return`${t.source}\0${t.cwd??""}`}function it(t,i,r){if(!t?.transcripts?.length)return[];const d=new Map;for(const s of i){const l=d.get(s.sessionId);(!l||s.ts>l.ts)&&d.set(s.sessionId,s)}const h=new Map;for(const s of t.processes){if(!s.cwd)continue;const l=h.get(B(s));(!l||s.pid<l.pid)&&h.set(B(s),s)}return t.transcripts.map(s=>{const l=z(s.sessionId)??z(s.transcriptPath);if(!l)return null;const u=s.sessionId?d.get(s.sessionId)??null:null,x=h.get(ot(s))??null,m=Math.max(s.mtimeMs,u?.ts??0),j=!!x||r-m<=Z,p=s.project?.trim()||(s.cwd?F(s.cwd):et(s.transcriptPath))||"unknown";return{refId:l,source:s.source||"unknown",project:p,cwd:s.cwd,transcriptPath:s.transcriptPath,sessionId:s.sessionId,mtimeMs:s.mtimeMs,size:s.size,status:j?"run":"idle",statusLabel:j?"active":"idle",lastEvent:u,process:x}}).filter(s=>s!==null).sort((s,l)=>{const u=Math.max(s.mtimeMs,s.lastEvent?.ts??0);return Math.max(l.mtimeMs,l.lastEvent?.ts??0)-u||s.project.localeCompare(l.project)})}function Gt({navigate:t}){const{route:i}=X(),[r]=o.useState(()=>W(D,P)),[d,h]=o.useState(r),[s,l]=o.useState(()=>W(_,P)?.events??[]),[u,x]=o.useState(r===null),[m,j]=o.useState(""),[p,S]=o.useState("all"),[y,k]=o.useState(0),[N,C]=o.useState(null),[T,V]=o.useState(Date.now()),b=o.useRef(null),I=o.useCallback(async()=>{C(null);try{h(await L(D))}catch(e){C(e instanceof Error?e.message:String(e))}finally{x(!1)}},[]);o.useEffect(()=>{I();const e=setInterval(()=>{I()},q);return()=>clearInterval(e)},[I]),o.useEffect(()=>{let e=!1;return(async()=>{try{const a=await L(_);e||l(a.events??[])}catch{}})(),()=>{e=!0}},[]),G(e=>{l(a=>a.length>=$?[...a.slice(a.length-$+1),e]:[...a,e])}),o.useEffect(()=>{const e=setInterval(()=>V(Date.now()),15e3);return()=>clearInterval(e)},[]);const f=o.useMemo(()=>it(d,s,T),[d,s,T]),H=o.useMemo(()=>[...new Set(f.map(e=>e.source))].sort(),[f]),c=o.useMemo(()=>f.filter(e=>(p==="all"||e.source===p)&&at(e,m.trim())),[f,p,m]);o.useEffect(()=>{y>=c.length&&k(Math.max(0,c.length-1))},[c.length,y]);const M=o.useCallback(e=>{e&&Q(t,{view:"sessions",sessionId:e.refId},{returnTo:i})},[t,i]);o.useEffect(()=>{const e=a=>{const E=a.target,A=E instanceof HTMLInputElement||E instanceof HTMLTextAreaElement||(E?.isContentEditable??!1);if(a.key==="/"&&!A){a.preventDefault(),b.current?.focus();return}if(A){a.key==="Escape"&&E===b.current&&(j(""),b.current?.blur());return}if(a.key==="ArrowDown"||a.key==="j"){a.preventDefault(),k(w=>c.length===0?0:Math.min(c.length-1,w+1));return}if(a.key==="ArrowUp"||a.key==="k"){a.preventDefault(),k(w=>Math.max(0,w-1));return}(a.key==="Enter"||a.key==="o")&&(a.preventDefault(),M(c[y]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[c,y,M]);const K=N?[]:c,g=o.useCallback(e=>`${e.source}:${e.transcriptPath}`,[]),v=o.useMemo(()=>new Map(c.map((e,a)=>[g(e),a])),[c,g]);return n.jsxs("div",{className:"s-atop s-atop--sessions",children:[n.jsxs("div",{className:"s-atop-fbar",children:[n.jsxs("label",{className:"s-atop-search",children:[n.jsx("span",{className:"s-atop-search-prompt",children:"/"}),n.jsx("input",{ref:b,className:"s-atop-search-input",placeholder:"filter sessions",value:m,onChange:e=>j(e.target.value)}),n.jsx("kbd",{className:"s-atop-search-kbd",children:"/"})]}),n.jsx("span",{className:"s-atop-fbar-label",children:"source"}),n.jsxs("button",{type:"button",className:`s-atop-pill${p==="all"?" s-atop-pill--on":""}`,onClick:()=>S("all"),children:["all",n.jsx("span",{className:"s-atop-pill-ct",children:f.length})]}),H.map(e=>n.jsxs("button",{type:"button",className:`s-atop-pill${p===e?" s-atop-pill--on":""}`,onClick:()=>S(e),children:[e,n.jsx("span",{className:"s-atop-pill-ct",children:f.filter(a=>a.source===e).length})]},e)),n.jsx("div",{className:"s-atop-fbar-spacer"})]}),n.jsx(O,{rows:K,columns:tt,rowId:g,storageKey:"openscout.sessions.cols",rowBindings:e=>({onMouseEnter:()=>{const a=v.get(e);a!=null&&k(a)},onFocus:()=>{const a=v.get(e);a!=null&&k(a)}}),onRowClick:e=>M(e),rowClassName:e=>v.get(g(e))===y?"s-atop-row--selected":void 0,empty:N?{title:"Discovery failed",body:N}:{title:"No raw sessions",body:m?"No sessions match the current filter.":"No transcript sessions were discovered."},loading:u,density:"compact",className:"s-atop-data-table",ariaLabel:"Raw sessions"}),n.jsxs("div",{className:"s-atop-keys",children:[n.jsxs("span",{children:[n.jsx("kbd",{children:"/"}),"filter"]}),n.jsxs("span",{children:[n.jsx("kbd",{children:"j/k"}),"select"]}),n.jsxs("span",{children:[n.jsx("kbd",{children:"enter"}),"open"]}),n.jsx("span",{className:"s-atop-keys-spacer"}),n.jsxs("span",{className:"s-atop-keys-count",children:[n.jsx("strong",{children:c.length})," sessions"]})]})]})}export{Gt as RawSessionsTable};
1
+ import{r as o,j as n}from"./index-BI9AljSD.js";/* empty css */import{D as O}from"./DataTable-DXIlOlVu.js";import{p as W,a as L}from"./api-Co9aQ2Jw.js";import{t as U,n as R,f as Y}from"./time-Dhsh_2EG.js";import{u as G}from"./tail-events-BdUrO0kb.js";import{o as Q}from"./openContent-C6XO6kr5.js";import{u as X}from"./Provider-Bu-C8Hxc.js";/* empty css */import"./perf-PX8Rx0EP.js";import"./index-BWHgHrtv.js";import"./router-DTtux5sP.js";import"./synthetic-agent-routing-aduMYO7P.js";import"./terminal-sessions-BQ6t92tJ.js";import"./sse-DDHEHUgz.js";import"./surface-activity-B1rgWB1i.js";import"./colors-BtO5_zlx.js";import"./scoutbot-BJIamJOH.js";import"./DocumentFocusViewer-DFFE85Tq.js";import"./createLucideIcon-DthwWQIg.js";import"./TextDocumentSurface-BeSwe3Yl.js";import"./file-text--hfhwZH1.js";import"./x-DfRJbqrh.js";import"./chevron-right-CnZRSd-V.js";import"./code-xml-CvKBY3KA.js";import"./arrow-left-DHfdXJVZ.js";import"./arrow-right-BBsrogWf.js";import"./scout-voice-BZKsdquE.js";import"./fx-z37u1o2z.js";import"./keyboard-nav-e6yGeorb.js";import"./NewChatComposer-C_1op4dH.js";import"./text-Faa3ZStB.js";import"./voice-levels-Dcr3jglk.js";import"./loader-circle-B2W9DPG5.js";import"./conversation-model-QsJVfSeG.js";import"./index-DfsTyYDx.js";import"./HarnessMark-DAaWPiT_.js";import"./NewChatOrigin-D7hwp6dm.js";import"./chevron-down-C475vltS.js";import"./search-DmFM_9jm.js";import"./chunk-HRAB3GC3-DLNT8aOo.js";const q=1e4,J=500,$=1e3,Z=6e4,D="/api/tail/discover",_=`/api/tail/recent?limit=${J}`,P=3e4,tt=[{key:"status",label:"status",cls:"s-atop-col-status",kind:"text",sortable:!1,defaultWidth:96,minWidth:70,render:t=>n.jsxs("span",{className:`s-atop-status s-atop-status--${t.status}`,children:[n.jsx("span",{className:"s-atop-status-dot","aria-hidden":"true"}),t.statusLabel]})},{key:"session",label:"session",cls:"s-atop-col-agent",kind:"text",sortable:!1,defaultWidth:168,minWidth:110,maxWidth:280,render:t=>n.jsxs("div",{className:"s-atop-agent-cell",title:t.sessionId??t.refId,children:[n.jsx("span",{className:`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${st(t.source)}`,children:t.source}),n.jsx("span",{className:"s-atop-agent-id",children:t.refId.slice(0,8)})]})},{key:"project",label:"project",cls:"s-atop-col-project",kind:"text",sortable:!1,defaultWidth:200,minWidth:96,maxWidth:360,render:t=>n.jsx("span",{title:t.cwd??t.project,children:t.project})},{key:"updated",label:"updated",cls:"s-atop-col-last",kind:"time",sortable:!1,defaultWidth:86,minWidth:64,render:t=>n.jsx("span",{title:Y(t.mtimeMs),children:U(Math.max(R(t.mtimeMs)??0,R(t.lastEvent?.ts)??0))||"-"})},{key:"size",label:"size",cls:"s-atop-col-runtime",kind:"number",sortable:!1,defaultWidth:80,minWidth:64,render:t=>nt(t.size)},{key:"path",label:"path",kind:"text",sortable:!1,defaultWidth:360,minWidth:160,maxWidth:800,render:t=>n.jsx("span",{title:t.transcriptPath,children:t.cwd??t.transcriptPath})}];function z(t){const i=t?.trim();if(!i)return null;const r=F(i);return r.endsWith(".jsonl")?r.slice(0,-6):r}function F(t){const i=t.replace(/[\\/]+$/,"");return i.split(/[\\/]/).filter(Boolean).at(-1)??i}function et(t){const r=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return r.pop(),r.at(-1)??""}function st(t){return t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function nt(t){if(!Number.isFinite(t)||t<0)return"-";if(t<1024)return`${t} B`;const i=t/1024;if(i<1024)return`${i.toFixed(i>=10?0:1)} KiB`;const r=i/1024;return`${r.toFixed(r>=10?0:1)} MiB`}function at(t,i){return i?[t.refId,t.sessionId??"",t.source,t.project,t.cwd??"",t.transcriptPath,t.lastEvent?.summary??"",t.process?.command??""].join(" ").toLowerCase().includes(i.toLowerCase()):!0}function B(t){return`${t.source}\0${t.cwd??""}`}function ot(t){return`${t.source}\0${t.cwd??""}`}function it(t,i,r){if(!t?.transcripts?.length)return[];const d=new Map;for(const s of i){const l=d.get(s.sessionId);(!l||s.ts>l.ts)&&d.set(s.sessionId,s)}const h=new Map;for(const s of t.processes){if(!s.cwd)continue;const l=h.get(B(s));(!l||s.pid<l.pid)&&h.set(B(s),s)}return t.transcripts.map(s=>{const l=z(s.sessionId)??z(s.transcriptPath);if(!l)return null;const u=s.sessionId?d.get(s.sessionId)??null:null,x=h.get(ot(s))??null,m=Math.max(s.mtimeMs,u?.ts??0),j=!!x||r-m<=Z,p=s.project?.trim()||(s.cwd?F(s.cwd):et(s.transcriptPath))||"unknown";return{refId:l,source:s.source||"unknown",project:p,cwd:s.cwd,transcriptPath:s.transcriptPath,sessionId:s.sessionId,mtimeMs:s.mtimeMs,size:s.size,status:j?"run":"idle",statusLabel:j?"active":"idle",lastEvent:u,process:x}}).filter(s=>s!==null).sort((s,l)=>{const u=Math.max(s.mtimeMs,s.lastEvent?.ts??0);return Math.max(l.mtimeMs,l.lastEvent?.ts??0)-u||s.project.localeCompare(l.project)})}function Gt({navigate:t}){const{route:i}=X(),[r]=o.useState(()=>W(D,P)),[d,h]=o.useState(r),[s,l]=o.useState(()=>W(_,P)?.events??[]),[u,x]=o.useState(r===null),[m,j]=o.useState(""),[p,S]=o.useState("all"),[y,k]=o.useState(0),[N,C]=o.useState(null),[T,V]=o.useState(Date.now()),b=o.useRef(null),I=o.useCallback(async()=>{C(null);try{h(await L(D))}catch(e){C(e instanceof Error?e.message:String(e))}finally{x(!1)}},[]);o.useEffect(()=>{I();const e=setInterval(()=>{I()},q);return()=>clearInterval(e)},[I]),o.useEffect(()=>{let e=!1;return(async()=>{try{const a=await L(_);e||l(a.events??[])}catch{}})(),()=>{e=!0}},[]),G(e=>{l(a=>a.length>=$?[...a.slice(a.length-$+1),e]:[...a,e])}),o.useEffect(()=>{const e=setInterval(()=>V(Date.now()),15e3);return()=>clearInterval(e)},[]);const f=o.useMemo(()=>it(d,s,T),[d,s,T]),H=o.useMemo(()=>[...new Set(f.map(e=>e.source))].sort(),[f]),c=o.useMemo(()=>f.filter(e=>(p==="all"||e.source===p)&&at(e,m.trim())),[f,p,m]);o.useEffect(()=>{y>=c.length&&k(Math.max(0,c.length-1))},[c.length,y]);const M=o.useCallback(e=>{e&&Q(t,{view:"sessions",sessionId:e.refId},{returnTo:i})},[t,i]);o.useEffect(()=>{const e=a=>{const E=a.target,A=E instanceof HTMLInputElement||E instanceof HTMLTextAreaElement||(E?.isContentEditable??!1);if(a.key==="/"&&!A){a.preventDefault(),b.current?.focus();return}if(A){a.key==="Escape"&&E===b.current&&(j(""),b.current?.blur());return}if(a.key==="ArrowDown"||a.key==="j"){a.preventDefault(),k(w=>c.length===0?0:Math.min(c.length-1,w+1));return}if(a.key==="ArrowUp"||a.key==="k"){a.preventDefault(),k(w=>Math.max(0,w-1));return}(a.key==="Enter"||a.key==="o")&&(a.preventDefault(),M(c[y]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[c,y,M]);const K=N?[]:c,g=o.useCallback(e=>`${e.source}:${e.transcriptPath}`,[]),v=o.useMemo(()=>new Map(c.map((e,a)=>[g(e),a])),[c,g]);return n.jsxs("div",{className:"s-atop s-atop--sessions",children:[n.jsxs("div",{className:"s-atop-fbar",children:[n.jsxs("label",{className:"s-atop-search",children:[n.jsx("span",{className:"s-atop-search-prompt",children:"/"}),n.jsx("input",{ref:b,className:"s-atop-search-input",placeholder:"filter sessions",value:m,onChange:e=>j(e.target.value)}),n.jsx("kbd",{className:"s-atop-search-kbd",children:"/"})]}),n.jsx("span",{className:"s-atop-fbar-label",children:"source"}),n.jsxs("button",{type:"button",className:`s-atop-pill${p==="all"?" s-atop-pill--on":""}`,onClick:()=>S("all"),children:["all",n.jsx("span",{className:"s-atop-pill-ct",children:f.length})]}),H.map(e=>n.jsxs("button",{type:"button",className:`s-atop-pill${p===e?" s-atop-pill--on":""}`,onClick:()=>S(e),children:[e,n.jsx("span",{className:"s-atop-pill-ct",children:f.filter(a=>a.source===e).length})]},e)),n.jsx("div",{className:"s-atop-fbar-spacer"})]}),n.jsx(O,{rows:K,columns:tt,rowId:g,storageKey:"openscout.sessions.cols",rowBindings:e=>({onMouseEnter:()=>{const a=v.get(e);a!=null&&k(a)},onFocus:()=>{const a=v.get(e);a!=null&&k(a)}}),onRowClick:e=>M(e),rowClassName:e=>v.get(g(e))===y?"s-atop-row--selected":void 0,empty:N?{title:"Discovery failed",body:N}:{title:"No raw sessions",body:m?"No sessions match the current filter.":"No transcript sessions were discovered."},loading:u,density:"compact",className:"s-atop-data-table",ariaLabel:"Raw sessions"}),n.jsxs("div",{className:"s-atop-keys",children:[n.jsxs("span",{children:[n.jsx("kbd",{children:"/"}),"filter"]}),n.jsxs("span",{children:[n.jsx("kbd",{children:"j/k"}),"select"]}),n.jsxs("span",{children:[n.jsx("kbd",{children:"enter"}),"open"]}),n.jsx("span",{className:"s-atop-keys-spacer"}),n.jsxs("span",{className:"s-atop-keys-count",children:[n.jsx("strong",{children:c.length})," sessions"]})]})]})}export{Gt as RawSessionsTable};