dorkos 0.101.0 → 0.103.0

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 (208) hide show
  1. package/README.md +10 -10
  2. package/dist/bin/cli.js +2935 -1738
  3. package/dist/browser/native/package-manifest.json +1 -1
  4. package/dist/browser/source-manifest.json +1 -1
  5. package/dist/client/assets/{AboutPage-CwxCTicf.js → AboutPage-BNVLNd3q.js} +1 -1
  6. package/dist/client/assets/{ActivityRow-D0QQ0SFu.js → ActivityRow-CvjAfRBM.js} +1 -1
  7. package/dist/client/assets/AdapterIcon-wGSXBn-k.js +1 -0
  8. package/dist/client/assets/AdapterSetupWizard-CmSJ2sno.js +2 -0
  9. package/dist/client/assets/{AgentRequestCard-BLLmoAES.js → AgentRequestCard-D62XQXBM.js} +4 -4
  10. package/dist/client/assets/{AppearancePage-GqrWckTQ.js → AppearancePage-Bds0L-wm.js} +1 -1
  11. package/dist/client/assets/{AttentionSignalRow-sEhnIPBB.js → AttentionSignalRow-C6RkjCWK.js} +1 -1
  12. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-BXjzhT_D.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-CerNarG-.js} +24 -24
  13. package/dist/client/assets/{BlintzCanvas-CXi0fvcM.js → BlintzCanvas-CUqethk_.js} +24 -24
  14. package/dist/client/assets/{CanvasCsvContent-QhDSf8Pd.js → CanvasCsvContent-DdbIUPMJ.js} +1 -1
  15. package/dist/client/assets/CanvasFileContent-CX2VNF4o.js +2 -0
  16. package/dist/client/assets/CanvasModel3dContent-OprkQsgq.js +2 -0
  17. package/dist/client/assets/{CodeMirrorDiff-BMG7DBg2.js → CodeMirrorDiff-BnMdmI0K.js} +1 -1
  18. package/dist/client/assets/{CodeMirrorEditor-BYdz0ipX.js → CodeMirrorEditor-C7T-DaVA.js} +1 -1
  19. package/dist/client/assets/ConnectionAccessLists-B3QGnSxM.js +1 -0
  20. package/dist/client/assets/ConnectionsPage-E3br6maQ.js +11 -0
  21. package/dist/client/assets/{ConventionPage-y-Zq3Klp.js → ConventionPage-vMN5qEwP.js} +3 -3
  22. package/dist/client/assets/{ExtensionPageRoute-gZKKPhaj.js → ExtensionPageRoute-DFkPAzjs.js} +2 -2
  23. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-CbKIa11X.js → FloatingTanStackRouterDevtools-CqogiFob-BP4itJWW.js} +1 -1
  24. package/dist/client/assets/HandlePage-De4D_IVs.js +1 -0
  25. package/dist/client/assets/{LexicalField-Ceoa9flp.js → LexicalField-BbUXXxTw.js} +1 -1
  26. package/dist/client/assets/{ManagesPage-Dcqdm6I8.js → ManagesPage-DsNSZHug.js} +1 -1
  27. package/dist/client/assets/Marketplace-D4zHIIak.js +36 -0
  28. package/dist/client/assets/MarketplaceSourcesView-DILS8-ca.js +1 -0
  29. package/dist/client/assets/{McpAppFrame-B1ThSf2U.js → McpAppFrame-Cl_2azg-.js} +2 -2
  30. package/dist/client/assets/McpSigninBody-TpoSImsV.js +1 -0
  31. package/dist/client/assets/{Model3dViewer-DlcQ3-LS.js → Model3dViewer-C-iyu5eV.js} +1 -1
  32. package/dist/client/assets/NamePage-C-3w8oeg.js +1 -0
  33. package/dist/client/assets/NewDirectMessageMenu-bJE7b4lX.js +1 -0
  34. package/dist/client/assets/{NotificationsPage-CQQIdLtI.js → NotificationsPage-CL23qwVw.js} +1 -1
  35. package/dist/client/assets/OperatorIdentityForm-ixaqUfIO.js +1 -0
  36. package/dist/client/assets/{PermissionsPage-TX-d7aVQ.js → PermissionsPage-D4xbxTkc.js} +1 -1
  37. package/dist/client/assets/{PersonalityPicker-C_9JVOva.js → PersonalityPicker-CTvPlN-k.js} +1 -1
  38. package/dist/client/assets/{PersonalityPopover-BoTED73t.js → PersonalityPopover-Coy0eaIg.js} +1 -1
  39. package/dist/client/assets/PhotoPage-DpEEXO3e.js +1 -0
  40. package/dist/client/assets/PreviewRefusedNotice-B2GLqLYi.js +1 -0
  41. package/dist/client/assets/{PromptSuggestionChips-B_oUtFMI.js → PromptSuggestionChips-YdKEWyNT.js} +1 -1
  42. package/dist/client/assets/RoomSurface-BwIBBvYq.js +44 -0
  43. package/dist/client/assets/{RoomsPage-zOjjpHdA.js → RoomsPage-DaEXPz65.js} +1 -1
  44. package/dist/client/assets/RunsOnPopover-tvbVPKVf.js +1 -0
  45. package/dist/client/assets/SessionsPage-CAdV_XBY.js +1 -0
  46. package/dist/client/assets/SkillsPage-B4F19LmV.js +1 -0
  47. package/dist/client/assets/{TasksPage-BZapA_v6.js → TasksPage-BXcaEx3V.js} +1 -1
  48. package/dist/client/assets/ToolsPage-BYBwPql_.js +2 -0
  49. package/dist/client/assets/{TopologyGraph-BMcPxZsA.js → TopologyGraph-CZ2Y5I2e.js} +1 -1
  50. package/dist/client/assets/TourHost-BNpDrN0O.js +1 -0
  51. package/dist/client/assets/UnlinkDialog-Zyuh5qZY.js +1 -0
  52. package/dist/client/assets/{UnreadDivider-KSqqcHKN.js → UnreadDivider-Dh67_mAz.js} +1 -1
  53. package/dist/client/assets/_shell-lcu5vkQ7.js +98 -0
  54. package/dist/client/assets/{_shell._home-Bp_p1VUv.js → _shell._home-CPV1Z64k.js} +1 -1
  55. package/dist/client/assets/_shell._home.activity-CEvkKYBD.js +1 -0
  56. package/dist/client/assets/_shell._home.index-tGnRLvY-.js +3 -0
  57. package/dist/client/assets/{_shell._home.tasks-BsBH_4tZ.js → _shell._home.tasks-CtpZNevK.js} +1 -1
  58. package/dist/client/assets/_shell._home.workspaces-D6tkWdS8.js +1 -0
  59. package/dist/client/assets/{_shell.channels-DWAHkDPV.js → _shell.channels-DbrQXIVv.js} +4 -4
  60. package/dist/client/assets/_shell.connections-C3Ho4S8R.js +6 -0
  61. package/dist/client/assets/{_shell.feedback-requests-Hjv640j9.js → _shell.feedback-requests-D9l7SJi1.js} +1 -1
  62. package/dist/client/assets/_shell.marketplace-BfY-kBJk.js +1 -0
  63. package/dist/client/assets/_shell.marketplace_.sources-B0km_EUs.js +1 -0
  64. package/dist/client/assets/_shell.session-O8MC-USm.js +54 -0
  65. package/dist/client/assets/{_shell.team-ctLQztjw.js → _shell.team-DvJK7irE.js} +4 -4
  66. package/dist/client/assets/_shell.x._extensionId-_-fII74H.js +1 -0
  67. package/dist/client/assets/_shell.x._extensionId_._-_-fII74H.js +1 -0
  68. package/dist/client/assets/agent-attention-BvnWcLpc.js +5 -0
  69. package/dist/client/assets/{agent-browser-CCN16ZOz.js → agent-browser-DsDp0cSX.js} +1 -1
  70. package/dist/client/assets/{banner-DOm9_4l-.js → banner-Cja2VfwN.js} +2 -2
  71. package/dist/client/assets/{file-exclamation-point-BKzL0QhY.js → file-exclamation-point-D8KYFYSh.js} +1 -1
  72. package/dist/client/assets/{highlighted-body-KPVGNVTW-DTxMTVdP.js → highlighted-body-KPVGNVTW-Chp5pHWq.js} +1 -1
  73. package/dist/client/assets/{hover-card-qzuFUCaR.js → hover-card-FvX18DHP.js} +1 -1
  74. package/dist/client/assets/{index-Dcs6e-U_.js → index-BFPRILKF.js} +1 -1
  75. package/dist/client/assets/{index-CtOB9fS3.js → index-BKCteC7q.js} +1 -1
  76. package/dist/client/assets/index-Bbffv0TQ.js +1247 -0
  77. package/dist/client/assets/{index-BMOfHKE0.js → index-BhatJcNc.js} +1 -1
  78. package/dist/client/assets/index-BroohPSu.js +1 -0
  79. package/dist/client/assets/{index-DT_v3O-B.js → index-Bt4vTnDj.js} +1 -1
  80. package/dist/client/assets/{index-DwzSdOh3.js → index-BwkmCRvO.js} +1 -1
  81. package/dist/client/assets/{index-CTai_TxZ.js → index-BzS1K2wS.js} +1 -1
  82. package/dist/client/assets/{index-C3XnoXTY.js → index-C6F5gzX-.js} +1 -1
  83. package/dist/client/assets/{index-BaB-skF0.js → index-CIzSi3tA.js} +3 -3
  84. package/dist/client/assets/{index-BPcwoJoz.js → index-CLCbHvV5.js} +1 -1
  85. package/dist/client/assets/{index-DA-i3I4q.js → index-CXjobHw0.js} +1 -1
  86. package/dist/client/assets/{index-DgH_dl1a.js → index-CYcJ7ENW.js} +2 -2
  87. package/dist/client/assets/{index-3lQkXKcq.js → index-CeqzGl3y.js} +1 -1
  88. package/dist/client/assets/{index-DgtF-nBt.js → index-CknNaeS2.js} +1 -1
  89. package/dist/client/assets/{index-Bk98IpMn.js → index-CtK6WJzD.js} +1 -1
  90. package/dist/client/assets/{index-C8ZMfyGc.js → index-CvxLe-_3.js} +1 -1
  91. package/dist/client/assets/{index-CF9fqPef.js → index-D24Ttd-y.js} +4 -4
  92. package/dist/client/assets/{index-CIPHHziB.js → index-D6Jn2eBq.js} +1 -1
  93. package/dist/client/assets/{index-D3DXMH4x.js → index-DDibi3-x.js} +1 -1
  94. package/dist/client/assets/{index-C7B2uRgo.js → index-DElGMXW8.js} +2 -2
  95. package/dist/client/assets/{index-CmlaXay_.js → index-DGNJkiFb.js} +1 -1
  96. package/dist/client/assets/{index-WjW-NUCp.js → index-DI2T-dXr.js} +1 -1
  97. package/dist/client/assets/{index-CLhD0Bno.js → index-DZf_utaG.js} +1 -1
  98. package/dist/client/assets/{index-CTXNRyRE.js → index-D_XtXoLp.js} +1 -1
  99. package/dist/client/assets/{index-CDTumWMC.js → index-DjdQaKwP.js} +1 -1
  100. package/dist/client/assets/index-Do18O9VZ.js +1 -0
  101. package/dist/client/assets/{index-CVl132_4.js → index-Do1vOFrm.js} +1 -1
  102. package/dist/client/assets/{index-BIMClIrX.js → index-Dv1DkyeB.js} +1 -1
  103. package/dist/client/assets/{index-IgIVF9T_.js → index-DyvLJ_Z5.js} +1 -1
  104. package/dist/client/assets/index-HgvJwMGi.js +5 -0
  105. package/dist/client/assets/{index-DR1JT9Uz.js → index-OxwtxTFo.js} +3 -3
  106. package/dist/client/assets/index-QSDTjavn.js +1 -0
  107. package/dist/client/assets/{index-DOxEmnH2.js → index-ZLdoJdwS.js} +1 -1
  108. package/dist/client/assets/index-_GlgFH88.css +1 -0
  109. package/dist/client/assets/{index-CScfHuKF.js → index-euarUu2E.js} +1 -1
  110. package/dist/client/assets/{index-B-z7hA9x.js → index-jYh6X22t.js} +1 -1
  111. package/dist/client/assets/{index-CIfwPLXd.js → index-uQ1vTS05.js} +1 -1
  112. package/dist/client/assets/{index-CejezM4U.js → index-xfBvKz-h.js} +1 -1
  113. package/dist/client/assets/{index-BW5ce4t8.js → index-znQ5q2gV.js} +1 -1
  114. package/dist/client/assets/{layers-CJHXSEKK.js → layers-8-cbYlfw.js} +1 -1
  115. package/dist/client/assets/{lightbulb-DWjxw7lb.js → lightbulb-DoB0IKly.js} +1 -1
  116. package/dist/client/assets/{mention-pill-akMU3IVs.js → mention-pill-BHC6tMG9.js} +1 -1
  117. package/dist/client/assets/{message-square-off-DEagHpQY.js → message-square-off-CEHuZJtY.js} +1 -1
  118. package/dist/client/assets/{owner-notice-CLsx0s7q.js → owner-notice-dtDSKfGs.js} +1 -1
  119. package/dist/client/assets/{page-container-W7byjRmk.js → page-container-BOrdASM1.js} +1 -1
  120. package/dist/client/assets/primer-trigger-CC-cR5zN.js +3 -0
  121. package/dist/client/assets/{radio-B8Ozjv9U.js → radio-BfZPhctR.js} +1 -1
  122. package/dist/client/assets/{room-files-source-Bsc3YA91.js → room-files-source-BHupFaLE.js} +2 -2
  123. package/dist/client/assets/{rotate-ccw-clock-CNcDcTvq.js → rotate-ccw-clock-BvzfP8lR.js} +1 -1
  124. package/dist/client/assets/{rotate-cw-xvfipJLN.js → rotate-cw-BDweizfR.js} +1 -1
  125. package/dist/client/assets/{scroll-area-C95q3ss7.js → scroll-area-Dph6w3a6.js} +1 -1
  126. package/dist/client/assets/{search-x-C6SAxw7a.js → search-x-CoFJOP2l.js} +2 -2
  127. package/dist/client/assets/{shield-x-DxOGc0dW.js → shield-x-BZ6rhiT0.js} +1 -1
  128. package/dist/client/assets/{soul-file-pg0ShYy3.js → soul-file-H8fwhgiL.js} +1 -1
  129. package/dist/client/assets/use-delete-binding-CUsepFIL.js +1 -0
  130. package/dist/client/assets/use-dev-links-DYYe0vvP.js +1 -0
  131. package/dist/client/assets/{use-external-adapter-catalog-B0gcY-k7.js → use-external-adapter-catalog-CAl3MNq-.js} +1 -1
  132. package/dist/client/assets/use-full-activity-feed-Bb7BUusp.js +1 -0
  133. package/dist/client/assets/use-is-below-desktop-CIgGSgoL.js +1 -0
  134. package/dist/client/assets/use-jump-back-in-BdLBzvDr.js +11 -0
  135. package/dist/client/assets/use-mesh-topology-wYtCBbF_.js +1 -0
  136. package/dist/client/assets/use-pending-read-9UcfnDwF.js +1 -0
  137. package/dist/client/assets/{use-personality-commit-OH7d0xl_.js → use-personality-commit-CaxUHrX5.js} +1 -1
  138. package/dist/client/assets/{use-promo-activation-BgdGasXE.js → use-promo-activation-rNaAOdoh.js} +2 -2
  139. package/dist/client/assets/use-pulse-freshness-CygG3s-S.js +1 -0
  140. package/dist/client/assets/use-room-follow-claim-BIK37Iy3.js +1 -0
  141. package/dist/client/assets/{use-roving-tab-list-Be60AWK3.js → use-roving-tab-list-DQgkKGzc.js} +1 -1
  142. package/dist/client/assets/{use-session-canvas-Bqs6IQO7.js → use-session-canvas-Dpy5BEId.js} +5 -5
  143. package/dist/client/assets/use-session-diagnostics-atu9cfgr.js +16 -0
  144. package/dist/client/assets/use-unclaimed-chats-qUI5vY5K.js +1 -0
  145. package/dist/client/index.html +2 -2
  146. package/dist/drizzle/20261008170031_session_touches.sql +5 -0
  147. package/dist/drizzle/20261009171311_chat_messages.sql +41 -0
  148. package/dist/drizzle/20261009173712_started_by_report_back.sql +1 -0
  149. package/dist/drizzle/meta/20261008170031_snapshot.json +12642 -0
  150. package/dist/drizzle/meta/20261009171311_snapshot.json +12906 -0
  151. package/dist/drizzle/meta/20261009173712_snapshot.json +12914 -0
  152. package/dist/drizzle/meta/_journal.json +21 -0
  153. package/dist/server/index.js +23608 -19236
  154. package/dist/server/index.js.map +2 -2
  155. package/package.json +6 -6
  156. package/dist/client/assets/AdapterIcon-CL-MyyKy.js +0 -1
  157. package/dist/client/assets/AdapterSetupWizard-C8HOvHLF.js +0 -2
  158. package/dist/client/assets/CanvasFileContent-ZZhdofR4.js +0 -2
  159. package/dist/client/assets/CanvasModel3dContent-DMMMZh4o.js +0 -2
  160. package/dist/client/assets/ConnectionAccessLists-PW1uzcGU.js +0 -1
  161. package/dist/client/assets/ConnectionsPage-EwitZwOE.js +0 -11
  162. package/dist/client/assets/HandlePage-CL3_n1CI.js +0 -1
  163. package/dist/client/assets/Marketplace-DsU-q1ZZ.js +0 -36
  164. package/dist/client/assets/MarketplaceSourcesView-D72YoKNR.js +0 -1
  165. package/dist/client/assets/McpSigninBody-Btg3PnYN.js +0 -1
  166. package/dist/client/assets/NamePage-Bzqj4Eob.js +0 -1
  167. package/dist/client/assets/NewDirectMessageMenu-89yeGqvy.js +0 -1
  168. package/dist/client/assets/OperatorIdentityForm-BhiB9tQp.js +0 -1
  169. package/dist/client/assets/PhotoPage-C3fMlebQ.js +0 -1
  170. package/dist/client/assets/PreviewRefusedNotice-ChCgdKWN.js +0 -1
  171. package/dist/client/assets/RoomSurface-CgtNuYhl.js +0 -39
  172. package/dist/client/assets/RunsOnPopover-JTm1cYuw.js +0 -1
  173. package/dist/client/assets/SessionsPage-D4kyvHQf.js +0 -6
  174. package/dist/client/assets/SkillsPage-KYUVzuVa.js +0 -1
  175. package/dist/client/assets/ToolsPage-CWpHMlrR.js +0 -2
  176. package/dist/client/assets/TourHost-VY1-sy1Y.js +0 -1
  177. package/dist/client/assets/UnlinkDialog-3p38G_9q.js +0 -1
  178. package/dist/client/assets/_shell-DAjwimLg.js +0 -93
  179. package/dist/client/assets/_shell._home.activity-tk-XApvX.js +0 -1
  180. package/dist/client/assets/_shell._home.index-BNVhSN0y.js +0 -3
  181. package/dist/client/assets/_shell._home.workspaces-DuXnjQh0.js +0 -1
  182. package/dist/client/assets/_shell.connections-DIm3mUHy.js +0 -6
  183. package/dist/client/assets/_shell.marketplace-DF6Y7mc0.js +0 -1
  184. package/dist/client/assets/_shell.marketplace_.sources-Do8cm7kq.js +0 -1
  185. package/dist/client/assets/_shell.session-DlN8iOl-.js +0 -43
  186. package/dist/client/assets/_shell.x._extensionId-0Q1rJtud.js +0 -1
  187. package/dist/client/assets/_shell.x._extensionId_._-0Q1rJtud.js +0 -1
  188. package/dist/client/assets/agent-attention-Dn__3LQE.js +0 -5
  189. package/dist/client/assets/hand-DLUdsiuR.js +0 -6
  190. package/dist/client/assets/index-CQWqpw_G.js +0 -1
  191. package/dist/client/assets/index-D5uYwabS.js +0 -1
  192. package/dist/client/assets/index-DFMDv6qR.js +0 -1
  193. package/dist/client/assets/index-DMYBI16t.js +0 -1252
  194. package/dist/client/assets/index-DbbZNAKk.js +0 -5
  195. package/dist/client/assets/index-Dgp1LmEk.css +0 -1
  196. package/dist/client/assets/primer-trigger-DuM9vVnV.js +0 -3
  197. package/dist/client/assets/use-delete-binding-CZVeHqn0.js +0 -1
  198. package/dist/client/assets/use-dev-links-Df2WkCic.js +0 -1
  199. package/dist/client/assets/use-full-activity-feed-SYcgdMZu.js +0 -1
  200. package/dist/client/assets/use-is-below-desktop-C5_YenEp.js +0 -1
  201. package/dist/client/assets/use-jump-back-in-DWUPb1gi.js +0 -11
  202. package/dist/client/assets/use-mesh-topology-HLzZIgis.js +0 -1
  203. package/dist/client/assets/use-pending-read-BuJknrxG.js +0 -1
  204. package/dist/client/assets/use-pulse-freshness-BlD-dM_g.js +0 -1
  205. package/dist/client/assets/use-rename-session-D3MuyK-F.js +0 -1
  206. package/dist/client/assets/use-room-follow-claim-CyjhzbRJ.js +0 -1
  207. package/dist/client/assets/use-session-diagnostics-CfKdB2iY.js +0 -16
  208. package/dist/client/assets/use-unclaimed-chats-lqMhotUB.js +0 -1
@@ -1 +0,0 @@
1
- import{bM as H,ci as P,r as c,j as e,aa as x,ib as Y,bd as $,O as g,B as j,X as B,fp as N,ic as k,am as G,a3 as L,df as R,di as O,e as v,cZ as W,c_ as p,aU as K,Q as z,ad as V,V as q,id as U,ie as Q,d6 as X}from"./index-DMYBI16t.js";import{P as Z}from"./page-container-W7byjRmk.js";import{u as J}from"./use-full-activity-feed-SYcgdMZu.js";import{C as b,A as ee}from"./ActivityRow-D0QQ0SFu.js";const C=["categories","actorType","actorId","since"];function w(){const s=H(),i=P({strict:!1}),t={categories:i.categories,actorType:i.actorType,actorId:i.actorId,since:i.since},n=C.some(d=>i[d]!==void 0),a={};t.categories&&(a.categories=t.categories),t.actorType&&(a.actorType=t.actorType),t.actorId&&(a.actorId=t.actorId),t.since&&(a.since=t.since);const r=c.useCallback(d=>{s({search:d})},[s]),l=c.useCallback(d=>{r(h=>{const y=h.categories?h.categories.split(","):[],A=y.includes(d)?y.filter(_=>_!==d):[...y,d];return{...h,categories:A.length>0?A.join(","):void 0}})},[r]),u=c.useCallback(d=>{r(h=>({...h,actorType:d}))},[r]),m=c.useCallback(d=>{r(h=>({...h,actorId:d}))},[r]),o=c.useCallback(d=>{r(h=>({...h,since:d}))},[r]),f=c.useCallback(()=>{r(d=>{const h={...d};for(const y of C)delete h[y];return h})},[r]);return{filters:t,queryFilters:a,isFiltered:n,toggleCategory:l,setActorType:u,setActorId:m,setSince:o,clearAll:f}}const T="dorkos:lastVisitedActivity";function te(){const[s]=c.useState(()=>localStorage.getItem(T)),i=c.useRef(!1);return c.useEffect(()=>{i.current||(localStorage.setItem(T,new Date().toISOString()),i.current=!0)},[]),s}function se(s){const i=c.useRef(null),t=c.useCallback(n=>{var u,m,o;const a=i.current;if(!a)return;const r=a.querySelectorAll("[data-activity-row]"),l=Array.from(r).findIndex(f=>f===document.activeElement||f.contains(document.activeElement));switch(n.key){case"ArrowDown":{n.preventDefault();const f=Math.min(l+1,r.length-1);(u=r[f])==null||u.focus();break}case"ArrowUp":{n.preventDefault();const f=Math.max(l-1,0);(m=r[f])==null||m.focus();break}case"Escape":{(o=document.activeElement)==null||o.blur();break}}},[s]);return{containerRef:i,handleKeyDown:t}}const ne=["Today","Yesterday","This week","Earlier"];function ie(s,i){const t=new Map;for(const n of s){const a=ae(new Date(n.occurredAt),i),r=t.get(a)??[];r.push(n),t.set(a,r)}return ne.filter(n=>t.has(n)).map(n=>({label:n,items:t.get(n)}))}function ae(s,i){const t=new Date(i);t.setHours(0,0,0,0);const n=new Date(t);n.setDate(n.getDate()-1);const a=new Date(t);return a.setDate(a.getDate()-a.getDay()),s>=t?"Today":s>=n?"Yesterday":s>=a?"This week":"Earlier"}function re({label:s,className:i}){return e.jsx("div",{"data-slot":"activity-group-header",className:x("sticky top-0 z-10 -mx-4 px-4 py-2 sm:-mx-6 sm:px-6","bg-background/95 backdrop-blur-sm",i),children:e.jsx("h3",{className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:s})})}const oe=["tasks","relay","agent","config","system","permissions"],F="group inline-flex min-h-11 shrink-0 items-center outline-none md:min-h-0",M="inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium transition-colors group-focus-visible:ring-ring group-focus-visible:ring-2 group-focus-visible:ring-offset-1";function ce({category:s,isActive:i,onToggle:t}){const n=b[s];return e.jsx(g.button,{type:"button",layout:!0,onClick:t,"aria-pressed":i,transition:{duration:.15},className:F,children:e.jsx("span",{className:x(M,i?x(n.bg,n.text):"text-muted-foreground group-hover:bg-muted group-hover:text-foreground"),children:n.label})})}function le({isActive:s,onClick:i}){return e.jsx(g.button,{type:"button",layout:!0,onClick:i,"aria-pressed":s,transition:{duration:.15},className:F,children:e.jsx("span",{className:x(M,s?"bg-foreground text-background":"text-muted-foreground group-hover:bg-muted group-hover:text-foreground"),children:"All"})})}function de({className:s}){const{filters:i,isFiltered:t,toggleCategory:n,clearAll:a}=w(),r=c.useRef(null),l=Y(r,"horizontal"),u=new Set(i.categories?i.categories.split(","):[]),m=()=>{t&&a()};return e.jsxs("div",{className:x("relative",s),children:[e.jsxs("div",{ref:r,onScroll:l.onScroll,"data-slot":"activity-filter-bar",className:"flex items-center gap-1 overflow-x-auto",children:[e.jsx(le,{isActive:!t,onClick:m}),oe.map(o=>e.jsx(ce,{category:o,isActive:u.has(o),onToggle:()=>n(o)},o)),e.jsx($,{children:t&&e.jsx(g.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15},children:e.jsxs(j,{variant:"ghost",size:"xs",className:"ml-1",onClick:a,children:[e.jsx(B,{"aria-hidden":!0}),"Clear"]})},"clear-filters")})]}),l.start&&e.jsx("div",{"aria-hidden":!0,"data-testid":"activity-filter-bar-fade-start",className:"from-background via-background/70 pointer-events-none absolute inset-y-0 left-0 w-8 bg-gradient-to-r to-transparent"}),l.end&&e.jsx("div",{"aria-hidden":!0,"data-testid":"activity-filter-bar-fade-end",className:"from-background via-background/70 pointer-events-none absolute inset-y-0 right-0 w-8 bg-gradient-to-l to-transparent"})]})}function ue({isFiltered:s=!1,className:i}){const{filters:t,clearAll:n}=w();return s?e.jsx(N,{className:i,icon:k,headline:`No ${me(t.categories)} activity found`,description:"Try other filters.",action:{label:"Clear filters",onClick:n,variant:"outline"}}):e.jsx(N,{className:i,icon:k,headline:"No activity yet",description:"Your agents’ work shows up here."})}function me(s){if(!s)return"matching";const t=s.split(",").map(r=>{var l;return((l=b[r])==null?void 0:l.label)??r});if(t.length===1)return t[0];const n=t[t.length-1];return`${t.slice(0,-1).join(", ")} or ${n}`}function fe({onRetry:s,className:i}){return e.jsxs("div",{"data-slot":"activity-error-state",className:x("flex flex-col items-center justify-center gap-3 py-16 text-center",i),children:[e.jsx("div",{className:"bg-destructive/10 rounded-xl p-3",children:e.jsx(G,{className:"text-destructive size-6","aria-hidden":"true"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-foreground text-sm font-medium",children:"Couldn’t load your activity"}),e.jsx("p",{className:"text-muted-foreground max-w-xs text-xs",children:"The DorkOS server didn’t answer. Check that it’s running."})]}),e.jsx(j,{variant:"outline",size:"sm",onClick:s,children:"Retry"})]})}function xe(s){const i=Date.now()-new Date(s).getTime(),t=Math.floor(i/36e5);return t<1?"recently":t<24?`${t}h ago`:`${Math.floor(t/24)}d ago`}function he(s,i){const t=new Date(i),n={};for(const a of s)new Date(a.occurredAt)>t&&(n[a.category]=(n[a.category]??0)+1);return n}function ge(s){const i={tasks:"scheduled run",relay:"message",agent:"agent update",config:"settings change",system:"system event",permissions:"permission change"};return Object.entries(s).filter(([,t])=>t>0).map(([t,n])=>{const a=i[t];return`${n} ${n===1?a:`${a}s`}`}).join(" · ")}function ye({lastVisitedAt:s,items:i,className:t}){if(!s)return null;const n=he(i,s);if(Object.values(n).reduce((u,m)=>u+(m??0),0)===0)return null;const r=xe(s),l=ge(n);return e.jsxs(g.div,{"data-slot":"activity-since-last-visit",initial:{opacity:0,y:-6},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},className:x("rounded-lg border px-4 py-3","bg-card border-border",t),children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:[e.jsx("span",{className:"text-foreground font-medium",children:"Since your last visit"})," ",e.jsxs("span",{children:["(",r,")"]})]}),e.jsx("p",{className:"text-foreground/80 mt-0.5 text-sm",children:l}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:Object.keys(n).map(u=>{const m=n[u];if(!m)return null;const o=b[u];return e.jsxs(L,{shape:"pill",className:x("border-transparent",o.bg,o.text),children:[m," ",o.label]},u)})})]})}const pe={initial:{opacity:0,y:6},animate:{opacity:1,y:0,transition:{duration:.2,ease:"easeOut"}}};function ve(){const s=c.useId(),i=c.useMemo(()=>`${s.split("").reduce((n,a)=>n+a.charCodeAt(0),0)%40+50}%`,[s]);return e.jsxs(W,{children:[e.jsx(p,{className:"w-28 py-1.5 pr-0 pl-2 max-sm:hidden",children:e.jsx(v,{className:"h-3 w-20"})}),e.jsx(p,{className:"w-24 py-1.5 pr-0 max-sm:hidden",children:e.jsx(v,{className:"h-5 w-20 rounded-full"})}),e.jsx(p,{className:"py-1.5 max-sm:pl-2",children:e.jsx(v,{className:"h-3 rounded",style:{width:i}})}),e.jsx(p,{className:"w-16 py-1.5 max-sm:w-10"})]})}function je(){return e.jsxs("div",{"data-slot":"activity-timeline-skeleton",className:"space-y-1",children:[e.jsx("div",{className:"py-2",children:e.jsx(v,{className:"h-3 w-16 rounded"})}),e.jsx(R,{children:e.jsx(O,{children:Array.from({length:5}).map((s,i)=>e.jsx(ve,{},i))})})]})}function be({items:s,isLoading:i,isError:t,onRetry:n,isFiltered:a,className:r}){const l=c.useMemo(()=>ie(s,new Date),[s]),{containerRef:u,handleKeyDown:m}=se(s.length);return i&&s.length===0?e.jsx("div",{"data-slot":"activity-timeline",className:x(r),children:e.jsx(je,{})}):t&&s.length===0?e.jsx("div",{"data-slot":"activity-timeline",className:x(r),children:e.jsx(fe,{onRetry:n})}):s.length===0?e.jsx("div",{"data-slot":"activity-timeline",className:x(r),children:e.jsx(ue,{isFiltered:a})}):e.jsx("div",{ref:u,onKeyDown:m,"data-slot":"activity-timeline",className:x(r),children:l.map(o=>e.jsxs("section",{children:[e.jsx(re,{label:o.label}),e.jsx(g.div,{variants:pe,initial:"initial",animate:"animate",children:e.jsx(R,{children:e.jsx(O,{children:o.items.map(f=>e.jsx(ee,{item:f},f.id))})})})]},o.label))})}function we({onLoadMore:s,isFetching:i,hasNextPage:t,className:n}){return t?e.jsx(g.div,{"data-slot":"activity-load-more",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1},className:x("flex justify-center py-4",n),children:e.jsxs(j,{variant:"outline",size:"sm",onClick:s,disabled:i,className:"gap-2",children:[i&&e.jsx(K,{size:"xs"}),"Load 50 more events"]})}):null}const S=7;function Ae(){var t;const s=z(),{data:i}=V({queryKey:q.dailyCounts(S),queryFn:()=>s.getSessionDailyCounts(S),staleTime:6e4});return!i||i.dailyCounts.length===0?null:{dailyCounts:i.dailyCounts,degraded:(((t=i.warnings)==null?void 0:t.length)??0)>0}}function Ne(s,i){const t=s.reduce((a,r)=>a+r,0),n=t===1?"session":"sessions";return i?t===0?"This week’s count is incomplete":`Your agents started at least ${t} ${n} this week`:t===0?"Your agents started no sessions this week":`Your agents started ${t} ${n} this week`}const I=10,ke=4,D=30,E=1;function Ce({data:s,className:i}){const t=Math.max(...s,1);return e.jsx("svg",{viewBox:"0 0 100 30",className:x("text-muted-foreground",i),"aria-hidden":"true",children:s.map((n,a)=>{const r=n/t*D;return e.jsx("rect",{x:a*(I+ke)+1,y:D-Math.max(r,E),width:I,height:Math.max(r,E),rx:2,fill:"currentColor",opacity:.6},a)})})}function Te(){const s=Ae();return s===null?null:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:Ne(s.dailyCounts,s.degraded)}),e.jsx(Ce,{data:s.dailyCounts,className:"h-6 w-24 shrink-0"})]})}function Se(){const s=c.useId(),i=U("dashboard.sections"),t=c.useMemo(()=>i.filter(n=>Q(n.id)&&(!n.visibleWhen||n.visibleWhen())),[i]);return t.length===0?null:e.jsxs("section",{className:"space-y-3","aria-labelledby":s,children:[e.jsx("h2",{id:s,className:"text-muted-foreground text-xs font-medium tracking-widest uppercase",children:"From your extensions"}),e.jsx("div",{className:"space-y-4",children:t.map(n=>e.jsx(n.component,{},n.id))})]})}function Ie(){const{queryFilters:s,isFiltered:i}=w(),t=te(),{data:n,isLoading:a,isError:r,refetch:l,isFetchingNextPage:u,hasNextPage:m,fetchNextPage:o}=J(s),f=c.useMemo(()=>(n==null?void 0:n.pages.flatMap(d=>d.items))??[],[n]);return e.jsxs(e.Fragment,{children:[e.jsx(X,{children:"Activity"}),e.jsxs(Z,{width:"wide",className:"space-y-4",children:[e.jsx(de,{}),e.jsx(Te,{}),e.jsx(Se,{}),e.jsx(ye,{lastVisitedAt:t,items:f}),e.jsx(be,{items:f,isLoading:a,isError:r,onRetry:()=>void l(),isFiltered:i}),e.jsx(we,{onLoadMore:()=>void o(),isFetching:u,hasNextPage:!!m})]})]})}const Fe=Ie;export{Fe as component};
@@ -1,3 +0,0 @@
1
- import{j1 as ge,j2 as fe,j as t,gn as $,go as L,gp as B,gq as q,gr as W,a3 as I,j3 as xe,al as A,cA as pe,cB as je,C as ve,cC as be,j4 as z,B as N,j5 as ye,j6 as Se,bM as H,e as C,aa as b,hw as D,hx as _,r as u,aF as Ne,j7 as ke,gb as we,fY as Re,dC as Ce,aD as Ie,X as se,j8 as Ae,j9 as Pe,aB as De,g3 as ne,ib as Oe,bd as G,O as R,dG as Me,ja as Te,jb as Ee,jc as Fe,em as $e,en as Le,jd as Be,je as qe,jf as We,jg as ze,eg as oe,ei as He,jh as _e,ci as ae,dr as Ue,ej as Ve,ji as Ge,l as ie,jj as Ke,jk as Qe,i1 as Ye,jl as re,eh as Je,b0 as Xe,aJ as Ze,hj as et,g as tt,fg as le,jm as K,ga as Q,jn as st,jo as nt,jp as ot,jq as at,Q as it,jr as rt,fj as lt,bp as dt,gZ as ct,eu as ut,js as mt,eB as T,iF as ht,d6 as gt,gF as ft,jt as xt,ju as pt,n as jt}from"./index-DMYBI16t.js";import{I as vt,i as bt,a as yt}from"./RoomSurface-CgtNuYhl.js";import{S as U}from"./scroll-area-C95q3ss7.js";import{u as St}from"./use-mesh-topology-HLzZIgis.js";import{A as Nt}from"./AttentionSignalRow-sEhnIPBB.js";import{P as kt}from"./PromptSuggestionChips-B_oUtFMI.js";import{u as wt,a as de,s as Rt,P as Ct,b as It}from"./use-promo-activation-BgdGasXE.js";import"./use-jump-back-in-DWUPb1gi.js";import"./use-room-follow-claim-CyjhzbRJ.js";import"./index-DbbZNAKk.js";import"./file-drag-GDx2qhdk.js";import"./index-CejezM4U.js";import"./UnreadDivider-KSqqcHKN.js";import"./format-duration-BCr6uzby.js";import"./hover-card-qzuFUCaR.js";import"./mention-pill-akMU3IVs.js";import"./rotate-ccw-clock-CNcDcTvq.js";import"./hand-DLUdsiuR.js";import"./message-square-off-DEagHpQY.js";import"./AgentRequestCard-BLLmoAES.js";function At({open:e,itemId:n,onClose:o}){const{data:s}=ge(),a=fe(),i=(n==null?void 0:n.indexOf("::"))??-1,r=i>=0?n.slice(0,i):void 0,l=i>=0?n.slice(i+2):void 0,d=s==null?void 0:s.find(m=>m.source===r&&m.reason===l),c=()=>{!r||!l||a.mutate({source:r,reason:l},{onSuccess:o})};return t.jsx($,{open:e,onOpenChange:m=>!m&&o(),children:t.jsxs(L,{side:"right",children:[t.jsxs(B,{children:[t.jsx(q,{children:"Messages that never arrived"}),t.jsx(W,{children:r??"Source unknown"})]}),t.jsx(U,{className:"flex-1 px-4",children:d?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-muted-foreground text-sm",children:"These never reached an agent. Clearing them doesn’t send them."}),t.jsxs("p",{className:"text-foreground text-sm",children:[d.count," message",d.count===1?"":"s"," couldn’t be delivered"]}),t.jsx(I,{variant:"secondary",children:xe(d.reason)})]}),t.jsxs("div",{className:"space-y-1 text-sm",children:[t.jsxs("p",{className:"text-muted-foreground",children:["First happened ",A(d.firstSeen)," ago"]}),t.jsxs("p",{className:"text-muted-foreground",children:["Last happened ",A(d.lastSeen)," ago"]})]}),d.sample!=null&&t.jsxs(pe,{children:[t.jsxs(je,{className:"text-muted-foreground hover:text-foreground group flex items-center gap-1 text-xs font-medium transition-colors",children:[t.jsx(ve,{className:"size-3 transition-transform group-data-[state=open]:rotate-90"}),"What one of them looked like"]}),t.jsx(be,{children:t.jsx("pre",{className:"bg-muted mt-1 overflow-x-auto rounded-md p-3 font-mono text-xs",children:JSON.stringify(d.sample,null,2)})})]})]}):t.jsx("p",{className:"text-muted-foreground py-8 text-center text-sm",children:"These are cleared already."})}),t.jsxs(z,{children:[d&&t.jsx(N,{variant:"destructive",onClick:c,disabled:a.isPending,children:a.isPending?"Clearing…":"Clear these"}),t.jsx(N,{variant:"outline",onClick:o,children:"Close"})]})]})})}function Pt(e){const n=Math.floor(e/1e3);if(n<60)return`${n}s`;const o=Math.floor(n/60),s=n%60;if(o<60)return`${o}m ${s}s`;const a=Math.floor(o/60),i=o%60;return`${a}h ${i}m`}function Dt(e){switch(e){case"blocked":return{label:"Blocked",badge:"outline",tone:"warning",heading:"What it needed",title:"Run that couldn’t use its tools"};case"failed":return{label:"Didn’t finish",badge:"destructive",tone:"error",heading:"Error",title:"Run that didn’t finish"};case"cancelled":return{label:"Cancelled",badge:"secondary",tone:"neutral",heading:"Stopped",title:"Run that was stopped"};case"skipped":return{label:"Skipped",badge:"secondary",tone:"neutral",heading:"Why",title:"Run that never started"};case"running":return{label:"Running",badge:"secondary",tone:"neutral",heading:"Latest",title:"Run that is still going"};default:return{label:"Completed",badge:"secondary",tone:"neutral",heading:"Note",title:"Run that finished"}}}const Ot={error:{box:"bg-destructive/10 border-destructive/20",heading:"text-destructive",body:"text-destructive"},warning:{box:"bg-status-warning-bg border-status-warning-border",heading:"text-status-warning-fg",body:"text-status-warning-fg"},neutral:{box:"bg-muted border-border",heading:"text-foreground",body:"text-foreground/80"}};function Mt({open:e,itemId:n,onClose:o}){const{data:s,isLoading:a,isError:i}=ye(e?n??null:null),r=Se(),l=H(),d=()=>{s!=null&&s.sessionId&&(D.getState().recordOpened("session",s.sessionId),l(_({session:s.sessionId})))},c=()=>{s&&r.mutate(s.id)},m=s?Dt(s.status):null,g=m?Ot[m.tone]:null;return t.jsx($,{open:e,onOpenChange:f=>!f&&o(),children:t.jsxs(L,{side:"right",children:[t.jsxs(B,{children:[t.jsx(q,{children:(m==null?void 0:m.title)??"Run that needs a look"}),t.jsx(W,{children:n?n.slice(0,8):"Unknown"})]}),t.jsxs(U,{className:"flex-1 px-4",children:[a&&t.jsxs("div",{className:"space-y-4",children:[t.jsx(C,{className:"h-6 w-24"}),t.jsx(C,{className:"h-4 w-48"}),t.jsx(C,{className:"h-20 w-full"})]}),i&&t.jsx("p",{className:"text-destructive py-8 text-center text-sm",children:"Couldn’t load this run."}),!a&&!i&&!s&&t.jsx("p",{className:"text-muted-foreground py-8 text-center text-sm",children:"Already resolved."}),s&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(I,{variant:m.badge,children:m.label}),t.jsx(I,{variant:"secondary",children:s.trigger==="scheduled"?"Scheduled":"Manual"})]}),t.jsxs("div",{className:"space-y-1 text-sm",children:[s.startedAt&&t.jsxs("p",{className:"text-muted-foreground",children:["Started: ",A(s.startedAt)," ago"]}),s.finishedAt&&t.jsxs("p",{className:"text-muted-foreground",children:["Finished: ",A(s.finishedAt)," ago"]}),s.durationMs!=null&&t.jsxs("p",{className:"text-muted-foreground",children:["Duration: ",Pt(s.durationMs)]})]}),s.error&&t.jsxs("div",{className:b("rounded-md border p-3",g.box),children:[t.jsx("p",{className:b("text-sm font-medium",g.heading),children:m.heading}),t.jsx("p",{className:b("mt-1 text-sm",g.body),children:s.error})]}),s.outputSummary&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Output"}),t.jsx("pre",{className:"bg-muted max-h-48 overflow-auto rounded-md p-3 font-mono text-xs",children:s.outputSummary})]})]})]}),t.jsxs(z,{children:[(s==null?void 0:s.sessionId)&&t.jsx(N,{variant:"default",onClick:d,children:"View session"}),(s==null?void 0:s.status)==="running"&&t.jsx(N,{variant:"destructive",onClick:c,disabled:r.isPending,children:r.isPending?"Cancelling…":"Cancel run"}),t.jsx(N,{variant:"outline",onClick:o,children:"Close"})]})]})})}function Tt({agent:e}){const n=ke(e,e.projectPath??"");return t.jsxs("div",{className:"flex items-center gap-3 py-2",children:[t.jsx(we,{color:n.color,emoji:n.emoji,size:"sm",className:"shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-foreground truncate text-sm font-medium",children:Re(e)}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(I,{variant:"destructive",children:"Unreachable"}),e.runtime&&t.jsx(I,{variant:"secondary",children:Ce(e.runtime).label})]})]}),e.lastSeenAt&&t.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs",children:[A(e.lastSeenAt)," ago"]})]})}function Et({open:e,onClose:n}){const{data:o}=St(void 0,e),s=u.useMemo(()=>o?o.namespaces.flatMap(a=>a.agents).filter(a=>a.healthStatus==="unreachable"):[],[o]);return t.jsx($,{open:e,onOpenChange:a=>!a&&n(),children:t.jsxs(L,{side:"right",children:[t.jsxs(B,{children:[t.jsx(q,{children:"Agents that aren’t answering"}),t.jsxs(W,{children:["DorkOS can’t reach ",s.length," agent",s.length===1?"":"s"," right now"]})]}),t.jsx(U,{className:"flex-1 px-4",children:s.length>0?t.jsx("div",{className:"divide-y",children:s.map(a=>t.jsx(Tt,{agent:a},a.id))}):t.jsxs("div",{className:"flex flex-col items-center gap-2 py-8",children:[t.jsx(Ne,{className:"text-status-success size-6"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:"All agents are online"})]})}),t.jsx(z,{children:t.jsx(N,{variant:"outline",onClick:n,children:"Close"})})]})})}function Ft(e){return e.content.suggestion!==void 0}function $t(){const e=wt(),{dismissedIds:n}=de(),o=Ie(s=>s.promoEnabled);return u.useMemo(()=>{if(!o)return null;const[s]=Rt(Ct.filter(Ft),e,n,1);return s??null},[e,n,o])}function Lt({suggestion:e,promoTitle:n,onAccept:o,onDismiss:s}){return t.jsxs("p",{"data-slot":"quiet-suggestion",className:"text-muted-foreground/70 text-2xs mt-1",children:[e.question," ",t.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground focus-ring rounded-sm font-medium underline-offset-4 transition-colors hover:underline focus-visible:underline",children:e.action}),t.jsx("button",{type:"button","aria-label":`Dismiss suggestion: ${n}`,onClick:s,className:"text-muted-foreground/60 hover:text-foreground focus-ring -my-1.5 ml-0.5 inline-flex translate-y-[3px] items-center justify-center rounded-sm p-1.5 align-baseline transition-colors",children:t.jsx(se,{className:"size-3"})})]})}function Bt({promo:e}){const{dismissPromo:n}=de(),{activate:o,dialog:s}=It(e);return t.jsxs(t.Fragment,{children:[t.jsx(Lt,{suggestion:e.content.suggestion,promoTitle:e.content.title,onAccept:o,onDismiss:()=>n(e.id)}),s]})}function qt(){const e=$t();return e===null?null:t.jsx(Bt,{promo:e},e.id)}const Wt=["report.daily"];function ce(){const{notifications:e}=Ae({kinds:Wt,unread:!0});return u.useMemo(()=>e[0],[e])}function zt({questions:e,requests:n,schedules:o,approvalsUnavailable:s,attention:a}){const i=[],r=[],l=e+n+o;return l>0?(i.push(`${Pe(e,n,o)} ${l===1?"is":"are"} waiting on you.`),r.push(`${l} waiting`)):s&&(i.push("Couldn’t read approvals."),r.push("Couldn’t read approvals")),a===1?(i.push("1 thing needs attention."),r.push("1 needs attention")):a>1&&(i.push(`${a} things need attention.`),r.push(`${a} need attention`)),{spoken:i.join(" "),compact:r.join(" · ")}}function Ht({notification:e,onDismiss:n}){return t.jsxs("div",{"data-slot":"shift-report-card",className:"border-border/60 bg-background/60 relative rounded-lg border p-3 pr-8",children:[t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsx(De,{"aria-hidden":!0,className:"text-muted-foreground mt-0.5 size-3.5 shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-foreground text-xs font-medium",children:e.title}),e.body!==void 0&&t.jsx("p",{className:"text-muted-foreground mt-1 text-xs leading-relaxed",children:e.body})]})]}),t.jsx("button",{type:"button",onClick:n,"aria-label":"Dismiss",className:"text-muted-foreground hover:text-foreground focus-ring absolute top-2 right-2 rounded-md p-1 transition-colors",children:t.jsx(se,{className:"size-3.5"})})]})}const _t="max-h-[40svh] sm:max-h-[50svh]",Ut={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}};function E({title:e,tone:n="waiting",children:o}){const s=u.useId();return t.jsxs("section",{"aria-labelledby":s,className:"min-w-0",children:[t.jsx("h2",{id:s,className:b("mb-2 text-xs font-medium",n==="waiting"?"text-status-warning-fg":"text-muted-foreground"),children:e}),o]})}function Y({edge:e}){return t.jsx("div",{"aria-hidden":"true","data-slot":`pinned-triage-fade-${e}`,className:b("from-background/95 via-background/65 pointer-events-none absolute inset-x-0 h-6 to-transparent",e==="bottom"?"bottom-0 bg-gradient-to-t":"top-0 bg-gradient-to-b")})}const J={animate:{transition:{staggerChildren:.04}}};function Vt(e){return e?0:.18}function Gt({approvals:e,asks:n,settlingAsks:o,askAgentNames:s,onOpenSession:a,approvalsUnavailable:i,onRetryApprovals:r,scheduleApprovals:l,errorSignals:d,activityItems:c,onOpenActivity:m,shiftReport:g,presence:f,condensed:p,onExpand:j,className:h}){const x=ne(),v=u.useRef(null),S=Oe(v),k=e.length>0||n.length>0||o.length>0||l.length>0||i,P=d.length>0,w=c.length>0,me=k||P||w||g!==void 0||(f==null?void 0:f.occupied)===!0,M=zt({questions:n.length,requests:e.length,schedules:l.length,approvalsUnavailable:i,attention:d.length+c.length}),he=p===!0&&M.compact!=="";return t.jsxs(t.Fragment,{children:[t.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:M.spoken}),t.jsxs(G,{initial:!1,children:[he&&t.jsx(R.div,{"data-slot":"pinned-triage-summary",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:Vt(x===!0)},className:b("bg-background/95 border-border/60 shrink-0 border-b backdrop-blur-sm",h),children:t.jsxs("button",{type:"button",onClick:j,className:"text-muted-foreground hover:text-foreground flex min-h-11 w-full min-w-0 items-center gap-2 px-[var(--msg-padding-x)] text-left text-xs",children:[t.jsx("span",{className:"bg-status-warning-dot size-1.5 shrink-0 rounded-full","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:M.compact}),t.jsx(Me,{className:"size-3.5 shrink-0","aria-hidden":!0})]})},"triage-summary"),me&&p!==!0&&t.jsxs(R.div,{"data-slot":"pinned-triage-header",...Ut,transition:{duration:x?0:.25,ease:[0,0,.2,1]},className:b("bg-background/95 border-border/60 relative shrink-0 overflow-hidden border-b backdrop-blur-sm",h),children:[t.jsxs("div",{ref:v,onScroll:S.onScroll,"data-slot":"pinned-triage-scroller",className:b("flex w-full min-w-0 scroll-py-6 flex-col gap-3 overflow-y-auto overscroll-contain px-[var(--msg-padding-x)] py-3",_t),children:[k&&t.jsxs(E,{title:"Waiting on you",children:[(n.length>0||o.length>0)&&t.jsx(Te,{asks:n,agentNames:s,onOpenSession:a,emptyState:t.jsx("p",{className:"text-muted-foreground text-xs",children:"Nothing needs you"})}),e.length>0&&t.jsx(Ee,{approvals:e}),e.length===0&&i&&t.jsx(Fe,{onRetry:r}),t.jsx(G,{initial:!1,children:l.map(y=>t.jsx($e,{task:y,className:"mt-2"},y.id))})]}),P&&t.jsx(E,{title:"Needs attention",children:t.jsx("div",{className:"border-status-warning-border/40 bg-background/60 rounded-lg border p-2",children:t.jsx(R.div,{variants:J,initial:"initial",animate:"animate",children:d.map(y=>t.jsx(Nt,{signal:y},y.id))})})}),g&&t.jsx(Ht,{notification:g.notification,onDismiss:g.onDismiss}),w&&t.jsx(E,{title:"Recent activity",tone:"neutral",children:t.jsx("div",{className:"border-border/60 bg-background/60 rounded-lg border p-2",children:t.jsx(R.div,{variants:J,initial:"initial",animate:"animate",children:c.map(y=>t.jsx(Le,{notification:y,onOpen:()=>m(y)},y.id))})})}),f==null?void 0:f.node]}),S.start&&t.jsx(Y,{edge:"top"}),S.end&&t.jsx(Y,{edge:"bottom"})]},"triage-header")]})]})}function Kt({presence:e,composerFocused:n,onExpand:o,className:s}){const{approvals:a,isError:i,retry:r}=Be(),{interactions:l}=qe(),d=We(),c=ze(l),{schedules:m,errors:g,activity:f}=oe(),p=He(),j=ce(),{mutate:h}=_e(),x=ae({strict:!1}),v=H(),S=Ue(),k=Ve(m),P=Ge(a),w=u.useCallback(()=>{v({...ie.home(),search:{}})},[v]);return t.jsxs(t.Fragment,{children:[t.jsx(Gt,{approvals:P,asks:l,settlingAsks:d,askAgentNames:c,onOpenSession:V=>{v(_({session:V}))},approvalsUnavailable:i&&a.length===0,onRetryApprovals:r,scheduleApprovals:k,errorSignals:g,activityItems:f,onOpenActivity:p,shiftReport:j===void 0?void 0:{notification:j,onDismiss:()=>h(j.id)},presence:e,condensed:S&&n===!0,onExpand:o,className:s}),t.jsx(At,{open:x.detail==="dead-letter",itemId:x.itemId,onClose:w}),t.jsx(Mt,{open:x.detail==="failed-run",itemId:x.itemId,onClose:w}),t.jsx(Et,{open:x.detail==="offline-agent",onClose:w})]})}const Qt=["What can you help with?","Make my first agent","What’s in this project?","Set up a daily run"];function Yt({roomId:e}){const n=u.useCallback(o=>{Ke.getState().set(e,o),Qe.getState().requestFocus(e)},[e]);return t.jsx("div",{className:"w-full px-[var(--msg-padding-x)] pb-1",children:t.jsx(kt,{suggestions:Qt,onChipClick:n,ariaLabel:"Ways to start",size:"comfortable"})})}function Jt(e){var i;const{data:n}=Ye(e),o=((i=n==null?void 0:n.members.find(r=>r.author.id===n.viewerAuthorId))==null?void 0:i.lastReadSeq)??null,[s,a]=u.useState({roomId:null,seq:null});return s.roomId===e?s.seq:o===null?null:(a({roomId:e,seq:o}),o)}function Xt(e,n){if(e===void 0)return null;let o=null,s=1/0;for(const a of e){if(!a.enabled||a.status!=="active")continue;const i=a.nextRun;if(i==null)continue;const r=Date.parse(i);Number.isNaN(r)||r<=n||r>=s||(s=r,o={name:a.displayName??a.name,at:i})}return o}function Zt(e,n){const o=new Date(e),s=o.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),a=es(new Date(n),o);return a===0?`today at ${s}`:a===1?`tomorrow at ${s}`:`on ${o.toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})} at ${s}`}function es(e,n){const o=s=>new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime();return Math.round((o(n)-o(e))/864e5)}function ts(e,n){return e===null?null:`Next up: ${e.name} runs ${Zt(e.at,n)}.`}function ss({forwardLook:e,suggestion:n}){return t.jsx(R.div,{"data-slot":"home-quiet-state",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},className:"border-border/60 shrink-0 border-b",children:t.jsxs("div",{className:"w-full px-[var(--msg-padding-x)] py-2",children:[t.jsxs("p",{className:"text-muted-foreground text-xs",children:[t.jsx("span",{className:"text-foreground/80 font-medium",children:"All quiet."}),e!==null&&t.jsxs(t.Fragment,{children:[" ",e]})]}),n]})})}function ns({roomId:e,presenceOccupied:n}){const o=re(e),s=Jt(e),{items:a,isLoading:i,isAnyError:r}=Je(),{total:l}=oe(),d=ce(),c=o!==void 0&&o.length>0,m=s!==null&&o!==void 0&&o.every(k=>k.seq<=s),g=a.length>0||i||r||l>0||d!==void 0||n,f=c&&m&&!g,[p,j]=u.useState("waiting");f&&p==="waiting"?j("shown"):!f&&p==="shown"&&j("retired");const h=f&&p!=="retired",x=Xe(),{data:v}=Ze(x&&h),S=et();return h?t.jsx(ss,{forwardLook:ts(Xt(v,S),S),suggestion:t.jsx(qt,{})}):null}const ue="dorkos:home-opened-on";function X(){const e=new Date,n=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0");return`${e.getFullYear()}-${n}-${o}`}function os(){try{return localStorage.getItem(ue)}catch{return null}}function as(e){try{localStorage.setItem(ue,e)}catch{}}function is(){const[e]=u.useState(()=>os()!==X());return u.useEffect(()=>{e&&as(X())},[e]),e}function rs({children:e}){const n=is(),o=ne(),s=n&&o!==!0;return t.jsx(R.div,{className:"h-full",initial:s?{opacity:0}:!1,animate:{opacity:1},transition:{duration:.45,ease:[0,0,.2,1]},children:e})}const ls=5,ds="relative after:absolute after:-inset-x-1 after:-inset-y-2.5 md:after:hidden";function cs(e,n){return e===null||n===null?null:Math.max(0,n-Date.parse(e))}function us({row:e,onFollow:n,onViewProfile:o}){const[s,a]=u.useState(null),i=cs(e.since,s),r=e.profileMemberId,l=o===void 0||r===null?void 0:()=>o(r);return t.jsx(vt,{onViewProfile:l,identity:{kind:e.face.kind,displayName:e.name,...e.handle!==null?{handle:e.handle}:{},color:e.face.color,...e.face.emoji!==void 0?{emoji:e.face.emoji}:{},...e.face.imageUrl!==void 0?{imageUrl:e.face.imageUrl}:{},...e.face.origin!==void 0?{origin:e.face.origin}:{},...e.face.kind==="agent"?{agent:{...e.runtime!==null?{runtime:e.runtime}:{},...i!==null?{working:{...e.roomTitle!==null?{room:e.roomTitle}:{},forMs:i}}:{}}}:{}},children:t.jsxs("button",{type:"button","aria-label":e.detail===null?`Watch ${e.name}`:`Watch ${e.name}: ${e.detail}`,onClick:()=>n(e.follow),onPointerEnter:()=>a(Date.now()),onPointerLeave:()=>a(null),onFocus:()=>a(Date.now()),onBlur:()=>a(null),className:b("focus-ring group/identity hover:bg-muted/60 flex min-w-0 items-center gap-1.5 rounded-full py-1 pr-2.5 pl-1 text-xs transition-colors",ds),children:[t.jsx(tt,{size:"xs",kind:e.face.kind,color:e.face.color,...e.face.emoji!==void 0?{emoji:e.face.emoji}:{},...e.face.imageUrl!==void 0?{imageUrl:e.face.imageUrl}:{},...e.face.origin!==void 0?{origin:e.face.origin}:{},fallback:e.face.fallback,status:"working"}),t.jsx("span",{className:"text-foreground shrink-0 font-medium",children:e.name}),e.detail!==null&&t.jsxs("span",{"aria-hidden":!0,className:"text-muted-foreground truncate",children:["· ",e.detail]})]})})}function ms({rows:e,onFollow:n,onViewProfile:o,className:s}){if(e.length===0)return null;const a=e.slice(0,ls),i=e.length-a.length;return t.jsxs("ul",{"data-testid":"presence-strip","aria-label":"Working right now",className:b("flex items-center gap-x-2 overflow-hidden",s),children:[a.map(r=>t.jsx("li",{className:"min-w-0",children:t.jsx(us,{row:r,onFollow:n,onViewProfile:o})},r.id)),i>0&&t.jsx("li",{"aria-label":i===1?"1 more agent is working":`${i} more agents are working`,className:"text-muted-foreground shrink-0 text-xs",children:t.jsxs("span",{"aria-hidden":!0,children:["+",i," more"]})})]})}function hs(e){return`replying in ${e}`}const gs="working in a session";function fs(e,n){var a;const o=n.rosters[e];if(o!==void 0)return o.members.map(i=>({author:i.author,origin:i.origin}));const s=(a=n.rooms[e])==null?void 0:a.participants;return s==null?[]:s.map(i=>({author:i}))}function xs(e){const n=new Map;for(const[o,s]of Object.entries(e))s!==null&&n.set(st(o),{path:o,manifest:s});return n}function Z(e){return{...e,line:ot(e.name,e.binding,e.state),detail:nt(e.binding,e.state)}}function ps(e){const n=xs(e.agents),o=new Set(e.excludeRoomIds??[]),s=[],a=new Set;for(const l of e.claims){const d=fs(l.roomId,e).find(f=>f.author.id===l.authorId);if(d===void 0)continue;const c=d.author.agentRef===void 0?void 0:n.get(d.author.agentRef);if(c!==void 0&&a.add(c.path),o.has(l.roomId))continue;const m=e.rooms[l.roomId],g=m===void 0?null:le(m);s.push(Z({id:`room:${l.roomId}:${l.authorId}`,name:d.author.displayName,handle:d.author.handle,face:K({record:d.author,override:c===void 0?null:Q(c.manifest),...d.origin!==void 0?{origin:d.origin}:{}}),binding:g===null?null:hs(g),state:l.state,since:l.since,roomTitle:g,runtime:(c==null?void 0:c.manifest.runtime)??null,profileMemberId:c===void 0?null:e.meshIdByPath[c.path]??null,follow:{kind:"room",roomId:l.roomId}}))}const i=new Set(a),r=[];for(const l of e.sessions){if(i.has(l.cwd))continue;const d=e.agents[l.cwd];if(d==null)continue;i.add(l.cwd);const c=d.displayName??d.name;r.push(Z({id:`session:${l.sessionId}`,name:c,handle:null,face:K({record:{id:d.id,kind:"agent",displayName:c},override:Q(d)}),binding:gs,state:"working",since:null,roomTitle:null,runtime:d.runtime,profileMemberId:e.meshIdByPath[l.cwd]??null,follow:{kind:"session",sessionId:l.sessionId,cwd:l.cwd}}))}return r.sort((l,d)=>l.name.localeCompare(d.name)||l.id.localeCompare(d.id)),[...s,...r]}function js(e,n,o){var i;const s=new Set(at(Object.keys(n),Object.values(o))),a=[];for(const[r,l]of Object.entries(n))((i=e[r])==null?void 0:i.lifecycle)==="streaming"&&s.has(r)&&a.push({sessionId:r,cwd:l});return a}const ee=[],vs=[],te="\0",O="";function bs(){const e=T(u.useCallback(a=>a.statuses,[])),n=T(u.useCallback(a=>a.statusCwds,[])),o=T(u.useCallback(a=>a.sessions,[])),s=u.useMemo(()=>js(e,n,o).map(a=>`${a.sessionId}${te}${a.cwd}`).sort().join(O),[e,n,o]);return u.useMemo(()=>s.length===0?vs:s.split(O).map(a=>{const[i,r]=a.split(te);return{sessionId:i,cwd:r}}),[s])}function ys(e=[]){const n=it(),o=rt(),s=bs(),{data:a}=lt(),{data:i}=dt(),r=u.useMemo(()=>[...new Set(o.map(h=>h.roomId))].sort().join(`
2
- `),[o]),l=u.useMemo(()=>r.length===0?[]:r.split(`
3
- `),[r]),d=ct({queries:l.map(h=>({queryKey:ut.detail(h),queryFn:()=>n.getRoom(h)})),combine:h=>{const x={};for(const v of h)v.data!==void 0&&(x[v.data.id]=v.data);return x}}),c=u.useMemo(()=>{const h={};for(const x of a??[])h[x.id]=x;return h},[a]),m=u.useMemo(()=>((i==null?void 0:i.agents)??[]).map(h=>h.projectPath),[i]),{data:g}=mt(m),f=u.useMemo(()=>g??{},[g]),p=u.useMemo(()=>{const h={};for(const x of(i==null?void 0:i.agents)??[])h[x.projectPath]=x.id;return h},[i]),j=e.join(O);return u.useMemo(()=>{if(o.length===0&&s.length===0)return ee;const h=ps({claims:o,rosters:d,rooms:c,sessions:s,agents:f,meshIdByPath:p,excludeRoomIds:j.length===0?[]:j.split(O)});return h.length===0?ee:h},[o,d,c,s,f,p,j])}function Ss(e=[]){const n=ys(e),o=H(),{open:s}=ht(),a=u.useCallback(r=>{if(r.kind==="room"){D.getState().recordOpened("room",r.roomId),o({...ie.channels(),search:{id:r.roomId}});return}D.getState().recordOpened("session",r.sessionId),r.cwd&&D.getState().recordOpened("agent",r.cwd),o(_({session:r.sessionId,dir:r.cwd}))},[o]),i=u.useMemo(()=>t.jsx(ms,{rows:n,onFollow:a,onViewProfile:s}),[n,a,s]);return{occupied:n.length>0,node:i}}function F({title:e,children:n,action:o}){return t.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-2 p-10 text-center text-sm",children:[t.jsx(jt,{className:"text-muted-foreground/50 size-10","aria-hidden":!0}),t.jsx("p",{className:"text-foreground font-medium",children:e}),t.jsx("p",{className:"max-w-sm",children:n}),o]})}function Ns(){return t.jsxs(t.Fragment,{children:[t.jsx(gt,{children:"Home"}),t.jsx(ks,{})]})}function ks(){var g,f;const e=ft(),[n,o]=u.useState(!1),s=u.useCallback(()=>{const p=document.activeElement;bt(p)&&p.blur()},[]),{thread:a,entry:i}=ae({strict:!1}),r=xt(),l=Ss(e.room===null?[]:[e.room.id]),d=re(((g=e.room)==null?void 0:g.id)??null),c=pt(((f=e.room)==null?void 0:f.id)??null,null),m=d!==void 0&&d.length===0&&c.length===0;if(e.status==="loading")return t.jsxs("div",{className:"flex h-full flex-col","aria-busy":!0,children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-3",children:[t.jsx(C,{className:"size-7 rounded-full"}),t.jsx(C,{className:"h-4 w-40"})]}),t.jsx("div",{className:"flex-1"})]});if(e.status==="error")return t.jsx(F,{title:"Couldn’t load your team room",action:t.jsx(N,{variant:"outline",size:"sm",className:"mt-2",onClick:e.retry,children:"Try again"}),children:"Its messages are safe."});if(e.status==="missing")return t.jsx(F,{title:"Your team room isn’t open yet",children:"DorkOS opens it at startup. Still missing? Restart DorkOS."});if(e.status==="archived"){const p=e.room;return t.jsx(F,{title:`${le(p)} is archived`,action:t.jsx(N,{variant:"outline",size:"sm",className:"mt-2",disabled:r.isPending,onClick:()=>r.mutate({roomId:p.id}),children:r.isPending?"Bringing it back…":"Bring it back"}),children:"Its messages are safe."})}return t.jsx(rs,{children:t.jsx(yt,{roomId:e.room.id,threadId:a,entrySeq:i,threadRoute:"/",offerJumpBackIn:!0,onComposerFocusChange:o,aboveTimeline:t.jsxs(t.Fragment,{children:[t.jsx(Kt,{presence:l,composerFocused:n,onExpand:s}),t.jsx(ns,{roomId:e.room.id,presenceOccupied:l.occupied})]}),aboveComposer:m?t.jsx(Yt,{roomId:e.room.id}):void 0})})}const Us=Ns;export{Us as component};
@@ -1 +0,0 @@
1
- import{Q as j,ad as g,r as f,j as e,d6 as N,dc as i,am as b,dd as y,de as w,a3 as u,df as C,dg as T,cZ as p,dh as c,di as v,c_ as o,dj as S,aV as k}from"./index-DMYBI16t.js";import{P as L}from"./page-container-W7byjRmk.js";const F=["workspaces","scan"],P=6e4;function A(){var a,r,l;const s=j(),t=g({queryKey:F,queryFn:()=>s.scanWorktrees(),staleTime:P});return{root:((a=t.data)==null?void 0:a.root)??null,worktrees:((r=t.data)==null?void 0:r.worktrees)??[],warnings:((l=t.data)==null?void 0:l.warnings)??[],isLoading:t.isLoading,isError:t.isError}}const m="—";function B(s){return s.changedFiles===null?m:s.changedFiles===0?"Clean":`${s.changedFiles} changed`}function E(s){const{ahead:t,behind:a,upstreamGone:r}=s;return r?"Branch merged or deleted":t===null||a===null?m:t===0&&a===0?"In sync":[t>0&&`${t} ahead`,a>0&&`${a} behind`].filter(Boolean).join(" · ")}function W({worktree:s}){const t=(s.changedFiles??0)>0;return e.jsxs(p,{children:[e.jsxs(o,{className:"max-w-0",children:[e.jsx("div",{className:"truncate font-medium",children:s.name}),e.jsx("div",{className:"text-muted-foreground truncate text-xs",title:s.path,children:i(s.path)})]}),e.jsx(o,{className:"max-w-0",children:s.readable?s.branch?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(S,{className:"text-muted-foreground size-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:s.branch})]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No branch"}):e.jsx(u,{variant:"outline",title:"DorkOS couldn’t read this folder with git.",children:"Can’t read"})}),e.jsx(o,{className:t?"text-status-warning-fg":"text-muted-foreground",children:e.jsx("span",{className:"text-xs whitespace-nowrap",children:B(s)})}),e.jsx(o,{className:"text-muted-foreground hidden md:table-cell",children:e.jsx("span",{className:"text-xs whitespace-nowrap",children:E(s)})}),e.jsx(o,{className:"text-muted-foreground hidden sm:table-cell",children:e.jsx("span",{className:"text-xs whitespace-nowrap",children:s.lastCommitAt?k(s.lastCommitAt):m})})]})}function H({project:s,worktrees:t}){return e.jsxs("section",{children:[e.jsxs("h2",{className:"mb-3 flex items-center gap-2 text-sm font-semibold",children:[s,e.jsx(u,{variant:"secondary",children:t.length})]}),e.jsx("div",{className:"bg-card rounded-lg border",children:e.jsxs(C,{children:[e.jsx(T,{children:e.jsxs(p,{children:[e.jsx(c,{children:"Folder"}),e.jsx(c,{children:"Branch"}),e.jsx(c,{children:"Changes"}),e.jsx(c,{className:"hidden md:table-cell",children:"Compared to remote"}),e.jsx(c,{className:"hidden sm:table-cell",children:"Last commit"})]})}),e.jsx(v,{children:t.map(a=>e.jsx(W,{worktree:a},a.path))})]})})]})}function R(){const{root:s,worktrees:t,warnings:a,isLoading:r,isError:l}=A(),x=f.useMemo(()=>{const n=new Map;for(const d of t){const h=n.get(d.project)??[];h.push(d),n.set(d.project,h)}return[...n.entries()]},[t]);return e.jsxs(L,{width:"wide",children:[e.jsx(N,{children:"Workspaces"}),e.jsx("p",{className:"text-muted-foreground mb-6 text-sm",children:"Copies of your code, per agent."}),a.length>0&&e.jsxs("div",{className:"mb-6 rounded-lg border border-amber-600/40 bg-amber-500/10 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Some folders couldn’t be read"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"This list may be missing what’s inside them."}),e.jsx("ul",{className:"text-muted-foreground mt-2 space-y-0.5 text-xs",children:a.map(n=>e.jsxs("li",{className:"truncate",title:n.path,children:[i(n.path)," (",n.reason,")"]},n.path))})]}),r?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Looking for your worktrees…"}):l?e.jsxs("div",{className:"bg-card rounded-xl border p-10 text-center",children:[e.jsx(b,{className:"text-muted-foreground/60 mx-auto size-8"}),e.jsx("p",{className:"mt-3 font-medium",children:"Couldn’t check your worktrees"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"The scan didn’t finish. DorkOS tries again on its own."})]}):x.length===0?e.jsxs("div",{className:"bg-card rounded-xl border p-10 text-center",children:[e.jsx(y,{className:"text-muted-foreground/60 mx-auto size-8"}),e.jsx("p",{className:"mt-3 font-medium",children:"No worktrees yet"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"A worktree is a copy of your project, so agents’ edits never collide."}),s&&e.jsxs("p",{className:"text-muted-foreground mt-3 truncate text-xs",title:s,"data-slot":"workspaces-root-path",children:["Looking in ",e.jsx(w,{children:i(s)})]})]}):e.jsx("div",{className:"flex flex-col gap-8",children:x.map(([n,d])=>e.jsx(H,{project:n,worktrees:d},n))})]})}const G=R;export{G as component};
@@ -1,6 +0,0 @@
1
- import{Y as tt,jX as pn,j as e,aa as B,B as b,aU as J,a1 as xn,a3 as K,be as fn,C as X,r as j,d4 as st,hv as at,I as Oe,e as P,$ as W,jY as it,Q as jn,R as Le,U as ot,a7 as rt,jZ as ct,ah as Ze,ad as lt,cR as Z,cS as ee,cT as ne,cU as te,cV as se,ew as ae,cW as ge,W as D,jC as yn,jU as le,j_ as vn,a8 as bn,fT as pe,d7 as ie,fY as V,jz as Te,aV as De,br as dt,hA as ut,iA as Nn,h as kn,i as ht,jH as mt,fa as gt,hx as Cn,eI as pt,am as wn,cA as de,cB as ue,dG as xt,cC as he,j$ as Sn,k0 as An,jK as ze,k1 as ft,ep as Fe,k2 as jt,k3 as In,fG as xe,fH as fe,fI as je,fJ as ye,fK as ve,fL as be,fM as Ne,fN as ke,jx as yt,jL as Rn,k4 as vt,hM as Me,jM as bt,er as qe,es as Be,k5 as Nt,bp as kt,aB as Ct,k6 as wt,a2 as oe,hG as St,k7 as At,k8 as Tn,k9 as It,jN as $n,dX as Rt,e6 as _n,a$ as Tt,fp as $t,dQ as _t,dH as En,dI as Pn,dJ as On,dK as Ln,dL as $e,bM as Ue,l as Dn,jw as Et,ka as Pt,cr as we,cs as Se,hq as Ot,ct as Ae,kb as Lt,H as zn,kc as Dt,i1 as zt,a6 as Ft,gH as Mt,cO as qt,fP as Bt,fQ as Ut,fR as Wt,kd as Kt,ke as Yt,kf as Ht,kg as Gt,kh as Qt,fU as Vt,fX as Jt,f as Xt,fW as Zt,ki as es,ic as ns,kj as ts,dr as ss,i$ as as,j0 as is,gn as os,kk as rs,kl as cs,gq as ls,km as ds,gr as us,ab as hs,kn as ms,ko as Fn,kp as gs,ci as ps,d6 as xs,kq as fs}from"./index-DMYBI16t.js";import{P as js}from"./page-container-W7byjRmk.js";import{s as We,u as ys,a as vs,b as Mn,c as bs,d as Ns,e as en,f as ks,i as Cs,C as ws,g as Ss,h as As,j as Is,k as Rs,L as qn,l as Bn,m as Ts,n as nn,o as $s,A as _s,p as Es,q as Ps,r as Os,t as Ls,v as Ds,w as zs,x as Fs,y as Ms,z as qs,F as Bs,B as Us,D as Ws,R as Ks,E as Ys,G as Hs,H as Gs,I as Qs}from"./AgentRequestCard-BLLmoAES.js";import{u as Un,a as Vs,b as Js,c as Xs,d as Zs,e as ea,U as na}from"./use-unclaimed-chats-lqMhotUB.js";import{u as ta}from"./use-delete-binding-CZVeHqn0.js";import{u as Ke,A as Wn}from"./AdapterSetupWizard-C8HOvHLF.js";import{s as sa}from"./session-strategy-labels-C7Wduch3.js";import{M as aa}from"./message-square-off-DEagHpQY.js";/**
2
- * @license lucide-react v1.48.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Kn={name:"ban",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]};Kn.node;const ia=tt(Kn);function Ce(n,t){var s;return((s=t.get(n))==null?void 0:s.displayName)??pn(n)}function oa(n){return n===0?"No agents yet":n===1?"1 agent":`${n} agents`}function ra(n){return n.length<=1?n[0]??"":n.length===2?`${n[0]} and ${n[1]}`:`${n[0]} and ${n.length-1} more`}function ca(n){if(!(n.label.toLowerCase()!==n.toolkit.toLowerCase()))return{account:n.identityHint??n.label,identity:null};const s=n.identityHint&&n.identityHint!==n.label?n.identityHint:null;return{account:n.label,identity:s}}function Yn(n,t){const s=We(t.get(n));return s===void 0?{}:{logo:s}}const la={ready:"ready",needs_you:"broken",unavailable:"broken",finishing:"busy",paused:"off",gone:"off"},da={sign_in_again:"sign-in-again",resume:"resume",review_access:"review",fix_key:"fix-key",connect_new:"connect-again"};function ua(n,t){var o;const{readiness:s}=n,a=ca(n),i=la[s.state],c=(o=s.fix)==null?void 0:o.action,r=s.state==="gone"||!c?null:da[c]??null;return{id:n.connectionId,kind:"account",name:Ce(n.toolkit,t),iconKey:n.toolkit,toolkit:n.toolkit,...Yn(n.toolkit,t),...a,waiting:0,tone:i,action:r,detail:s.state==="ready"?`${a.account} · ${n.everyAgent?"Every agent":oa(n.agentCount)}`:i==="broken"?s.copy.owner:`${a.account} · ${s.copy.owner}`}}function ha(n,t){if(t.label)return t.label;const s=t.status.displayName;return s&&s!==n.manifest.displayName?s:null}function ma(n,t,s){const a=n.manifest,i=ha(n,t),c={id:t.id,kind:"chat",name:a.displayName,iconKey:a.iconId??a.type,account:i,identity:null,waiting:s.waitingByChatApp[t.id]??0,deprecated:a.deprecated===!0},r=h=>i?`${i} · ${h}`:h;if(!t.enabled)return{...c,tone:"off",action:"resume",detail:"Paused · no messages in or out"};if(t.status.state==="error"||t.status.state==="disconnected")return{...c,tone:"broken",action:"fix",detail:"Stopped working. Messages aren’t getting through."};if(t.status.state!=="connected")return{...c,tone:"busy",action:null,detail:r("Connecting…")};const o=[...new Set(s.bindings.filter(h=>h.adapterId===t.id).map(h=>s.agentNames[h.agentId]??h.agentId))];if(o.length===0)return{...c,tone:"attention",action:null,detail:r("No agent answers yet")};const u=o.length===1?"answers":"answer";return{...c,tone:"ready",action:null,detail:r(`${ra(o)} ${u}`)}}const tn={broken:1,attention:2,busy:3,ready:3,off:4};function ga(n){return n.manifest.category==="internal"}function pa(n){const t=n.connections.map(r=>ua(r,n.services));for(const r of n.chatApps)if(!ga(r))for(const o of r.instances)t.push(ma(r,o,n));const s=t.map((r,o)=>({row:r,index:o})).sort((r,o)=>tn[r.row.tone]-tn[o.row.tone]||r.row.name.localeCompare(o.row.name)||r.index-o.index).map(({row:r})=>r),a=n.pendingSignIn;if(!a)return s;const i=n.services.get(a.toolkit),c=(i==null?void 0:i.displayName)??pn(a.toolkit);return[{id:a.flowId,kind:"connecting",name:c,iconKey:a.toolkit,...Yn(a.toolkit,n.services),account:null,identity:null,detail:`Finish signing in on ${(i==null?void 0:i.signInName)??c}…`,tone:"busy",action:"cancel",waiting:0},...s]}function Ye(n){const t=n.intents.find(s=>s.kind==="messages");return{account:n.intents.some(s=>s.kind==="account"),chatType:(t==null?void 0:t.kind)==="messages"?t.relayAdapterType:null}}function xa(n,t){return{accounts:new Set(n.filter(s=>s.lifecycle!=="disconnected").map(s=>s.toolkit)),chatApps:new Set(t.filter(s=>s.instances.length>0).map(s=>s.manifest.type))}}function Hn(n,t){const s=Ye(n);return{account:s.account&&!t.accounts.has(n.serviceSlug),chatType:s.chatType&&!t.chatApps.has(s.chatType)?s.chatType:null}}const Gn={popular:"Popular",email:"Email",calendar:"Calendar",chat:"Chat",docs:"Docs",files:"Files",code:"Code",tasks:"Tasks",sales:"Sales",all:"All"};function fa(n){const t=new Set(n.map(a=>a.category));return["popular",...Object.keys(Gn).filter(a=>a!=="popular"&&a!=="all"&&t.has(a)),"all"]}function ja(n,t){const s=n.filter(a=>a.category!=="developer");return t==="all"?s:t==="popular"?s.filter(a=>a.popular):s.filter(a=>a.category===t)}function ya(n,t){const s=t.trim().toLowerCase();return s===""?!0:`${n.name} ${n.detail}`.toLowerCase().includes(s)}const sn={"sign-in-again":"Sign in again",resume:"Resume",cancel:"Cancel",review:"Review",fix:"Fix","fix-key":"Fix the key","connect-again":"Connect again"};function va(){return e.jsx(K,{size:"xs",variant:"secondary",className:"shrink-0",children:"Chat"})}function Qn({name:n,iconKey:t,logo:s,detail:a,chat:i,deprecated:c=!1,wrapDetail:r=!1,detailClassName:o}){return e.jsxs(e.Fragment,{children:[e.jsx(xn,{iconKey:t,displayName:n,logo:s}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:n}),i&&e.jsx(va,{}),c&&e.jsx(K,{size:"xs",variant:"outline",tone:"warning",className:"shrink-0",children:"Deprecated"})]}),e.jsx("span",{className:B("text-muted-foreground block text-xs",r?"line-clamp-2":"truncate",o),children:a})]})]})}function ba({row:n,onOpen:t,onAction:s,actionPending:a=!1}){const i=n.tone==="off";return e.jsxs("li",{"data-testid":`app-row-${n.id}`,"data-tone":n.tone,className:B("group/row flex items-center rounded-lg transition-colors",n.tone==="broken"?"bg-status-warning-bg/70 hover:bg-status-warning-bg":"hover:bg-muted/50"),children:[e.jsxs("button",{type:"button",onClick:()=>t(n),className:"focus-ring flex min-h-14 min-w-0 flex-1 items-center gap-3 rounded-lg px-3 py-2 text-left",children:[e.jsx("span",{className:B("flex min-w-0 flex-1 items-center gap-3",i&&"opacity-55"),children:e.jsx(Qn,{name:n.name,iconKey:n.iconKey,logo:n.logo,detail:n.detail,chat:n.kind==="chat",deprecated:n.deprecated,wrapDetail:n.tone==="broken",detailClassName:n.tone==="broken"?"text-status-warning-fg":void 0})}),!n.action&&e.jsx(Na,{row:n})]}),n.action&&e.jsx("div",{className:"flex shrink-0 items-center pr-3",children:e.jsxs(b,{size:"sm",variant:n.tone==="broken"?"default":"outline",disabled:a,onClick:()=>s(n),"aria-label":`${sn[n.action]}: ${n.name}`,children:[a&&e.jsx(J,{size:"xs"}),sn[n.action]]})})]})}function Na({row:n}){return n.waiting>0?e.jsxs(K,{shape:"pill",tone:"warning",variant:"outline",className:"shrink-0",children:[n.waiting," waiting"]}):n.tone==="busy"?e.jsx(J,{size:"xs",className:"text-muted-foreground shrink-0"}):n.tone==="ready"?e.jsxs("span",{className:"flex shrink-0 items-center",children:[e.jsx("span",{className:B("size-2 rounded-full",fn.success),"aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:"Connected"})]}):e.jsx(X,{className:"text-muted-foreground size-4 shrink-0 opacity-0 transition-opacity group-focus-within/row:opacity-100 group-hover/row:opacity-100","aria-hidden":!0})}function ka({service:n,chat:t,actionLabel:s,onConnect:a,unavailableLabel:i}){const c=n.description??Ca(n),r=e.jsx(Qn,{name:n.displayName,iconKey:n.iconKey,logo:We(n),detail:c,chat:t,wrapDetail:!0});return a?e.jsx("li",{"data-testid":`catalog-app-${n.serviceSlug}`,children:e.jsxs("button",{type:"button",onClick:()=>a(n),"aria-label":`${s} ${n.displayName}`,className:"group/row hover:bg-muted/50 focus-ring flex min-h-14 w-full items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors",children:[r,e.jsx("span",{"aria-hidden":!0,className:"border-border bg-background group-hover/row:bg-muted shrink-0 rounded-md border px-3 py-1.5 text-xs font-medium shadow-xs transition-colors",children:s})]})}):e.jsxs("li",{"data-testid":`catalog-app-${n.serviceSlug}`,className:"flex min-h-14 items-center gap-3 px-3 py-2",children:[e.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-3 opacity-55",children:r}),e.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:i})]})}function Ca(n){const t=n.intents.some(a=>a.kind==="messages"),s=n.intents.some(a=>a.kind==="account");return t&&s?`Talk to your agents in ${n.displayName}, or let them use it.`:t?`Talk to your agents in ${n.displayName}.`:`Let agents use your ${n.displayName} account.`}function wa({query:n,onQueryChange:t,data:s,onOpenRow:a,onRowAction:i,pendingRowId:c=null,onConnect:r}){var $,Y,S,R;const[o,u]=j.useState("popular"),h=n.trim()!=="",{catalog:d,relay:f}=s,l=f.enabled,m=s.available.filter(w=>w.category!=="developer"),x=s.available.filter(w=>w.category==="developer"),y=fa(m),N=y.includes(o)?o:"popular",k=h?m:ja(m,N),A=(($=d.data)==null?void 0:$.pages.flatMap(w=>w.warnings))??[],p=(R=(S=(Y=d.data)==null?void 0:Y.pages[0])==null?void 0:S.appConnections)==null?void 0:R.newApps,g=h&&!d.isPending&&s.yours.length===0&&s.available.length===0,C=(w,E)=>{const z=Ye(w),I=z.chatType!==null&&!z.account&&!l;return e.jsx(ka,{service:w,chat:z.chatType!==null,actionLabel:E,onConnect:I?void 0:r,unavailableLabel:"Turned off"},w.serviceSlug)};return e.jsxs("div",{className:"space-y-8","data-testid":st.relayIntegrations,children:[e.jsxs("div",{className:"relative",children:[e.jsx(at,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2","aria-hidden":!0}),e.jsx(Oe,{type:"search",value:n,onChange:w=>t(w.target.value),className:"pl-9","aria-label":"Search apps",placeholder:"Search apps","data-testid":"app-search"})]}),s.yoursLoading?e.jsxs("div",{className:"space-y-2","aria-label":"Loading your apps",children:[e.jsx(P,{className:"h-14 rounded-lg"}),e.jsx(P,{className:"h-14 rounded-lg"})]}):s.yoursError?e.jsx(W,{title:"Couldn’t load your apps",description:"Nothing changed. Try again.",onRetry:s.retryYours}):s.yours.length>0&&e.jsxs("section",{"aria-labelledby":"connections-yours",className:"space-y-2",children:[e.jsx("h2",{id:"connections-yours",className:"text-sm font-semibold",children:"Yours"}),e.jsx("ul",{className:"-mx-3 space-y-0.5","data-testid":"yours-list",children:s.yours.map(w=>e.jsx(ba,{row:w,onOpen:a,onAction:i,actionPending:c===w.id},w.id))})]}),g?e.jsxs("div",{className:"bg-muted/40 rounded-xl p-6 text-center",children:[e.jsxs("p",{className:"text-sm font-medium",children:["No app matches “",n.trim(),"”"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:Aa(p)})]}):e.jsxs("section",{"aria-labelledby":"connections-all-apps",className:"space-y-3",children:[e.jsx("h2",{id:"connections-all-apps",className:"text-sm font-semibold",children:h?"Apps":"All apps"}),!h&&y.length>2&&e.jsx("div",{role:"group","aria-label":"Show apps by kind",className:"-mx-4 flex scrollbar-none gap-1.5 overflow-x-auto px-4 sm:mx-0 sm:flex-wrap sm:px-0",children:y.map(w=>e.jsx("button",{type:"button","aria-pressed":w===N,onClick:()=>u(w),className:B("focus-ring shrink-0 rounded-full px-3 py-1 text-xs font-medium transition-colors",w===N?"bg-foreground text-background":"bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:Gn[w]},w))}),d.isPending?e.jsxs("div",{className:"space-y-2","aria-label":"Loading apps",children:[e.jsx(P,{className:"h-14 rounded-lg"}),e.jsx(P,{className:"h-14 rounded-lg"}),e.jsx(P,{className:"h-14 rounded-lg"})]}):d.isError?e.jsx(W,{title:"Couldn’t load the app list",description:"Your apps are unchanged. Try again.",onRetry:()=>void d.refetch(),isRetrying:d.isFetching}):e.jsxs(e.Fragment,{children:[k.length>0&&e.jsx("ul",{className:"-mx-3 space-y-0.5","data-testid":"all-apps-list",children:k.map(w=>C(w,"Connect"))}),(h||N==="all")&&d.hasNextPage&&e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>void d.fetchNextPage(),disabled:d.isFetchingNextPage,children:d.isFetchingNextPage?"Loading…":"Show more apps"})]}),e.jsx(Sa,{data:s}),A.map(w=>e.jsx("p",{className:"text-muted-foreground text-xs",children:w.message},`${w.code}-${w.message}`))]}),x.length>0&&!d.isPending&&e.jsxs("section",{"aria-labelledby":"connections-developers",className:"space-y-2",children:[e.jsx("h2",{id:"connections-developers",className:"text-muted-foreground text-xs font-semibold",children:"For developers"}),e.jsx("ul",{className:"-mx-3 space-y-0.5",children:x.map(w=>C(w,"Set up"))})]})]})}function Sa({data:n}){const{relay:t}=n;return n.chatAppsError?e.jsxs("p",{className:"text-muted-foreground flex flex-wrap items-center gap-x-2 text-xs",children:["Couldn’t load your chat apps.",e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:n.retryChatApps,children:"Try again"})]}):t.isError?e.jsxs("p",{className:"text-muted-foreground flex flex-wrap items-center gap-x-2 text-xs",children:["Couldn’t check chat apps.",e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:t.retry,disabled:t.isRetrying,children:t.isRetrying?"Checking…":"Try again"})]}):e.jsx(it,{relay:t,variant:"line"})}function Aa(n){if((n==null?void 0:n.status)!=="setup_needed")return"Try another name.";switch(n.reason){case"nothing_set_up":return"Only popular apps show until you connect one. Then search finds every app.";case"own_key_unavailable":return"Only popular apps show while your saved key isn’t working.";case"dorkos_account_unavailable":return"Only popular apps show while your DorkOS account can’t connect apps.";case"dorkos_account_unlinked":return"Only popular apps show while your DorkOS account isn’t linked."}}function Ia(){const n=jn(),t=Le();return ot({mutationFn:({id:s,agentId:a})=>n.moveBinding(s,a),meta:{errorLabel:"Couldn’t move the chat"},onSuccess:()=>{t.invalidateQueries({queryKey:[...rt]})}})}function Ra(n,t){const s=Le(),{connectionState:a,failedAttempts:i}=ct();return Ze("relay_message",()=>{n&&s.invalidateQueries({queryKey:["relay","conversations"]})}),Ze("relay_signal",()=>{n&&s.invalidateQueries({queryKey:["relay","conversations"]})}),{connectionState:a,failedAttempts:i}}function Vn(n){const t=jn();return lt({queryKey:["relay","adapters",n,"events"],queryFn:()=>t.getAdapterEvents(n),enabled:!!n,refetchInterval:5e3})}function _e(n,t){var r;const s=n;if(!s||s.code!=="CHAT_ALREADY_BOUND")return null;const a=(r=s.body)==null?void 0:r.conflict,i=typeof(a==null?void 0:a.bindingId)=="string"?a.bindingId:null;if(!i)return null;const c=typeof(a==null?void 0:a.agentId)=="string"?a.agentId:"another agent";return{bindingId:i,currentAgentName:c,nextAgentId:t.id,nextAgentName:t.name}}function Jn({conflict:n,onClose:t,onMoved:s}){return e.jsx(Z,{open:n!==null,onOpenChange:a=>!a&&t(),children:e.jsx(ee,{className:"sm:max-w-md",children:n&&e.jsx(Ta,{conflict:n,onClose:t,onMoved:s})})})}function Ta({conflict:n,onClose:t,onMoved:s}){const a=Ia();return e.jsxs(e.Fragment,{children:[e.jsxs(ne,{children:[e.jsx(te,{children:"This chat already reaches someone"}),e.jsx(se,{children:"A chat goes to one agent at a time."})]}),e.jsxs(ae,{className:"pb-2",children:[e.jsxs("p",{className:"text-sm leading-relaxed",children:["This chat reaches ",e.jsx("span",{className:"font-medium",children:n.currentAgentName}),". Move it to ",e.jsx("span",{className:"font-medium",children:n.nextAgentName}),"?"]}),e.jsxs("p",{className:"text-muted-foreground mt-2 text-xs leading-relaxed",children:["Past messages stay with ",n.currentAgentName,". ",n.nextAgentName," starts fresh."]})]}),e.jsxs(ge,{children:[e.jsx(b,{variant:"outline",onClick:t,disabled:a.isPending,children:"Leave it"}),e.jsx(b,{disabled:a.isPending,onClick:()=>a.mutate({id:n.bindingId,agentId:n.nextAgentId},{onSuccess:()=>{D.success(`${n.nextAgentName} answers this chat now.`),t(),s==null||s()}}),children:a.isPending?"Moving…":`Move it to ${n.nextAgentName}`})]})]})}function $a(n,t){const s=n.trim()!=="",a=yn(),i=le(""),c=le(n,s),r=vn(),o=bn(r.enabled),{data:u}=pe(),{data:h}=Un("pending",r.enabled),{data:d}=ie(),f=j.useMemo(()=>{var p;return new Map((((p=i.data)==null?void 0:p.pages.flatMap(g=>g.services))??[]).map(g=>[g.serviceSlug,g]))},[i.data]),l=j.useMemo(()=>Object.fromEntries(((d==null?void 0:d.agents)??[]).map(p=>[p.id,V(p)])),[d]),m=j.useMemo(()=>r.enabled?o.data??[]:[],[r.enabled,o.data]),x=j.useMemo(()=>{var p;return((p=a.data)==null?void 0:p.connections)??[]},[a.data]),y=j.useMemo(()=>{const p={};for(const g of h??[])p[g.adapterId]=(p[g.adapterId]??0)+1;return pa({connections:x,chatApps:m,bindings:u??[],waitingByChatApp:p,agentNames:l,services:f,pendingSignIn:t})},[x,m,u,h,l,f,t]),N=s?c:i,k=j.useMemo(()=>xa(x,m),[x,m]),A=j.useMemo(()=>{var p;return(((p=N.data)==null?void 0:p.pages.flatMap(g=>g.services))??[]).filter(g=>{const C=Hn(g,k);return C.account||C.chatType!==null})},[N.data,k]);return{yours:y.filter(p=>ya(p,n)),allYours:y,chatApps:m,owned:k,available:A,services:f,agentNames:l,yoursLoading:a.isPending||r.isLoading||r.enabled&&o.isPending,yoursError:a.isError,yoursRefreshing:a.isFetching,retryYours:()=>void a.refetch(),catalog:N,relay:r,chatAppsError:r.enabled&&o.isError,retryChatApps:()=>void o.refetch()}}function Xn(n){switch(n&&typeof n=="object"&&"code"in n?n.code:void 0){case"connection_cleanup_pending":return"DorkOS is still removing this app’s earlier access. Try again in a few minutes.";case"connection_not_disconnected":return"Disconnect this app before removing it.";case"connection_not_found":return"This app is no longer connected. Pick it again from the list.";case"provider_not_found":case"authentication_unavailable":return"Sign-in isn’t available for this app. Check Settings › Connections, then try again.";case"idempotency_conflict":return"This sign-in was already used. Start again.";default:return"Couldn’t confirm that change. Check the app before trying again."}}const _a={gmail:["Summarise today’s Gmail inbox","Which of my Gmail emails need a reply?"],outlook:["Summarise today’s Outlook inbox","Which of my Outlook emails need a reply?"],googlecalendar:["What’s on my Google Calendar today?","Find a free hour on my Google Calendar this week"],slack:["Summarise what I missed in Slack today","Which Slack messages mention me?"],notion:["What changed in my Notion this week?","Summarise my most recent Notion page"],googledocs:["Summarise my most recent Google Doc"],googlesheets:["What’s in my most recent Google Sheet?"],airtable:["List my Airtable bases and what each one tracks"],googledrive:["Which Google Drive files did I change this week?"],dropbox:["Which Dropbox files did I add this week?"],github:["Which GitHub pull requests need my review?","Summarise my open GitHub issues"],linear:["Which Linear issues are assigned to me?","What changed in my Linear issues today?"],jira:["Which Jira issues are assigned to me?"],asana:["Which Asana tasks are due this week?"],todoist:["What’s on my Todoist list today?"],hubspot:["Which HubSpot deals changed this week?"]};function Ea(n){return _a[n]??[]}const Pa={gmail:"When a new email arrives…",outlook:"When a new email arrives…",googlecalendar:"When an event changes…",slack:"When a new message arrives…",github:"When something changes on GitHub…",linear:"When an issue changes…",jira:"When an issue changes…"};function Oa(n,t){return Pa[n]??`When something new happens in ${t}…`}function La(n,t){if(n.agentId&&t[n.agentId])return t[n.agentId];switch(n.actorKind){case"operator":return"You";case"program":return"A program";case"event":return"A notification";default:return"An agent"}}function Da(n,t,s){const a=`${La(n,s)} · ${Te(n.operationSlug,t)}`;return n.outcome===void 0?n.completedAt?a:`${a} (in progress)`:n.outcome==="success"?a:n.outcome==="outcome_unknown"?`${a} (result unknown)`:`${a} (didn’t finish)`}function za(n,t=new Date){const s=new Date(n);if(s.getTime()<=t.getTime())return"Trying again now.";const a=s.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return s.toDateString()===t.toDateString()?`Trying again at ${a}.`:`Trying again ${s.toLocaleDateString([],{weekday:"long"})} at ${a}.`}function Fa(n){const t=n.replaceAll(/([a-z0-9])([A-Z])/gu,"$1 $2").replaceAll(/[_-]+/gu," ").trim().toLowerCase();return t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:n}function Zn(n){return typeof n=="boolean"?n?"yes":"no":typeof n=="string"||typeof n=="number"?String(n):Array.isArray(n)&&n.every(t=>typeof t!="object"||t===null)?n.map(t=>Zn(t)).join(", "):"a custom value"}function Ma(n,t=null){const s=Object.entries(n).filter(([,a])=>a!==""&&a!==void 0&&a!==null).map(([a,i])=>{var r;return`${((r=t==null?void 0:t.find(o=>o.name===a))==null?void 0:r.label)??Fa(a)} is ${Zn(i)}`});return s.length>0?`Only when ${s.join(" and ")}`:null}function et(n,t,s){const a=u=>({text:u,tone:"plain",checkInChat:!1}),i=(u,h=!1)=>({text:u,tone:"problem",checkInChat:h});switch(n.state){case"pending":return a("Setting up. DorkOS keeps trying on its own.");case"unavailable":return i("Paused because this account can’t be used. Fix it above to restart.");case"revoked":return i("Stopped for good. Remove it and set it up again.")}const c=n.lastDelivery;if(!c)return a(s);const r=De(c.receivedAt);switch(c.outcome){case"delivered":return a(`Last one delivered · ${r}`);case"sending":return a(`Newest one on its way · ${r}`);case"retrying":return a(`Newest one hasn’t reached ${t} yet. DorkOS is trying again.`)}const o=n.destination.kind==="agent";switch(c.problem){case"unknown_outcome":return i(o?`DorkOS can’t tell if ${t} got the newest one (${r}). Open the chat to check.`:`DorkOS can’t tell if the newest one reached ${t} (${r}). Check there.`,o);case"refused":return i(`${t} turned away the newest one (${r}). Check this agent can still post there.`);case"changed":return i(`Newest one (${r}) held back because this notification changed. Nothing to do.`);case"cancelled":return i(`Newest one (${r}) cancelled before ${t} read it. Nothing to do.`);case"expired":return i(`Newest one (${r}) expired and wasn’t sent. If it repeats, remove it and add it again.`);case"unreachable":case null:return i(`Newest one (${r}) didn’t reach ${t}. If it repeats, remove it and add it again.`)}}function qa(n){const t=n.filter(s=>et(s,"","").tone==="problem").length;if(t!==0)return t===1?"1 notification needs a look":`${t} notifications need a look`}function Ba(n,t){const s=n.find(i=>i.id===t);return s?n.some(i=>i.id!==s.id&&i.displayName===s.displayName)&&s.handle?`${s.displayName} (@${s.handle})`:s.displayName:"an agent that’s no longer here"}function Ua(n){const t=n==null?void 0:n.code,s=n==null?void 0:n.status;return t==="invalid_filter"?"Check the filter values, then try again.":t==="destination_unavailable"?"That place can’t take notifications now. Pick another.":s===409?"Something changed while you were choosing. Check your choices, then try again.":"Couldn’t finish setting this up. Try again."}function Wa({subscription:n,agents:t,definition:s,channelLabel:a,removing:i,onRemove:c}){var k,A,p;const r=kn(),o=ht(n.agentId,{enabled:n.destination.kind==="room"}),u=Ba(t,n.agentId),h=(k=o.data)==null?void 0:k.rooms.find(g=>g.id===n.destination.id);let d=u,f=`Goes to ${u}, all in one chat`;n.destination.kind==="room"?(d=h?h.slug?`#${h.slug}`:h.name:"a room this agent left",f=`Goes to ${d}, for ${u}`):n.destination.kind==="channel"&&(d=a??"a chat that’s no longer set up",f=`Goes to ${d}, for ${u}`);const l=Ma(n.filter,s?mt(s.filterSchema):null),m=et(n,d,As(n)),x=(p=(A=t.find(g=>g.id===n.agentId))==null?void 0:A.agent)==null?void 0:p.projectPath,y=n.chatSessionId,N=l?`${f}. ${l}`:f;return e.jsxs("li",{className:"bg-muted/40 flex min-h-11 items-start justify-between gap-2 rounded-lg px-3 py-2","data-state":n.state,children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium break-words",children:n.displayName}),e.jsx("p",{className:"text-muted-foreground text-xs break-words",children:f}),l&&e.jsx("p",{className:"text-muted-foreground text-xs break-words",children:l}),e.jsx("p",{className:B("text-xs break-words",m.tone==="problem"?"text-destructive":"text-muted-foreground"),"data-testid":"notification-status",children:m.text})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[y&&r&&e.jsxs(b,{type:"button",size:"sm",variant:m.checkInChat?"secondary":"ghost",className:"gap-1.5","aria-label":`Open the chat for ${n.displayName}: ${N}`,onClick:()=>void r(Cn({session:y,...x&&{dir:x}})),children:[e.jsx(gt,{className:"size-3.5","aria-hidden":!0}),e.jsx("span",{className:"max-sm:sr-only",children:"Open chat"})]}),e.jsx(b,{type:"button",size:"icon-sm",variant:"ghost","aria-label":`Remove ${n.displayName}: ${N}`,"aria-busy":i,disabled:i,onClick:c,children:i?e.jsx(J,{size:"sm"}):e.jsx(pt,{className:"size-4"})})]})]})}function Ka({connectionId:n}){return e.jsx(Ya,{connectionId:n},n)}function Ya({connectionId:n}){var w,E,z,U;const t=ys(n),s=t.data!==void 0&&t.data.setupMode!=="unavailable",a=vs(n,s),i=Mn(n),c=dt(),r=pe(),o=bs(),u=Ns(),[h,d]=j.useState(()=>en()),[f,l]=j.useState(!1),[m,x]=j.useState(()=>new Set),y=I=>{x(L=>new Set(L).add(I)),u.mutate({connectionId:n,subscriptionId:I},{onSettled:()=>x(L=>{const O=new Set(L);return O.delete(I),O})})},N=j.useRef(null),k=((w=a.data)==null?void 0:w.pages.flatMap(I=>I.definitions))??[],A=((E=i.data)==null?void 0:E.pages.flatMap(I=>I.subscriptions))??[],p=(((z=c.data)==null?void 0:z.members)??[]).filter(I=>I.kind==="agent"),g=ks({connectionId:n,definitions:k,draft:h}),C=t.data?Cs(t.data):!1,$=!!(g&&C),Y=()=>{N.current=null,o.reset()},S=I=>{d(I),Y()},R=()=>{if(!g)return;const I={definitionId:g.definitionId,filter:g.filter,agentId:g.agentId,destination:g.destination,manageExistingTrigger:f},L=JSON.stringify({connectionId:n,decision:I}),O=N.current,F=(O==null?void 0:O.signature)===L?O.requestId:crypto.randomUUID();N.current={signature:L,requestId:F},o.mutate({connectionId:n,input:{...I,requestId:F}},{onSuccess:()=>{N.current=null,d(en()),l(!1)}})};return e.jsxs("section",{"aria-labelledby":"connection-notifications",className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("h3",{id:"connection-notifications",className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(ut,{className:"size-4","aria-hidden":"true"}),"Tell an agent"]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Send new activity to an agent, a room or a chat app."})]}),t.isPending?e.jsx(P,{className:"h-20 rounded-lg","aria-label":"Loading delivery setup"}):t.isError?e.jsx(W,{title:"Couldn’t check notifications for this account",description:"Try again before adding one.",onRetry:()=>void t.refetch(),isRetrying:t.isFetching}):t.data?e.jsx(ws,{connectionId:n,status:t.data}):null,i.isPending?e.jsx(P,{className:"h-20 rounded-lg","aria-label":"Loading notifications"}):i.isError?e.jsx(W,{title:"Couldn’t load notifications",description:"Try again. Nothing was changed.",onRetry:()=>void i.refetch(),isRetrying:i.isFetching}):A.length===0?s&&e.jsx("p",{className:"bg-muted/40 rounded-lg p-3 text-sm",children:"No notifications set up."}):e.jsxs("div",{className:"space-y-2","data-testid":"connection-notification-list",children:[e.jsx("ul",{className:"space-y-1.5",children:A.map(I=>{var O;const L=(O=r.data)==null?void 0:O.find(F=>F.id===I.destination.id);return e.jsx(Wa,{subscription:I,agents:p,definition:k.find(F=>F.id===I.definitionId),channelLabel:L?L.label||"a chat app conversation":void 0,removing:m.has(I.id),onRemove:()=>y(I.id)},I.id)})}),i.hasNextPage&&e.jsx(b,{type:"button",size:"sm",variant:"ghost",disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:i.isFetchingNextPage?"Loading…":"Load more notifications"})]}),o.data&&!A.some(I=>I.id===o.data.id)&&e.jsx("p",{className:"bg-muted/40 rounded-lg p-3 text-sm",role:"status",children:o.data.state==="pending"?`${o.data.displayName} is being set up. DorkOS keeps trying.`:`${o.data.displayName} is on.`}),u.isError&&e.jsx("p",{role:"alert",className:"border-destructive/30 bg-destructive/10 text-foreground rounded-md border p-3 text-sm",children:"Couldn’t confirm the removal. Check the list."}),s&&e.jsxs("div",{className:"space-y-3 rounded-lg border p-3","data-testid":"notification-setup",children:[e.jsx("p",{className:"text-sm font-medium",children:"Add a notification"}),a.isPending?e.jsx(P,{className:"h-20 rounded-md","aria-label":"Loading available notifications"}):a.isError?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 text-sm",children:[e.jsx("p",{className:"text-muted-foreground",children:"Notifications aren’t available right now."}),e.jsx(b,{type:"button",variant:"link",size:"xs",className:"h-auto p-0",disabled:a.isFetching,onClick:()=>void a.refetch(),children:a.isFetching?"Checking…":"Check again"})]}):k.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"This app offers no notifications yet."}):c.isPending?e.jsx(P,{className:"h-20 rounded-md","aria-label":"Loading agents"}):c.isError?e.jsx(W,{title:"Couldn’t load agents",description:"Try again before choosing who gets this.",onRetry:()=>void c.refetch(),isRetrying:c.isFetching}):p.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Notifications go to an agent. Add one first."}):e.jsxs(e.Fragment,{children:[e.jsx(Ss,{idPrefix:"notification",definitions:k,draft:h,onChange:S,agents:p,sourceStatus:t.data}),((U=t.data)==null?void 0:U.setupMode)==="byo_webhook"&&e.jsxs("div",{className:"flex min-h-11 items-center gap-2",children:[e.jsx(Nn,{id:"notification-manage-existing",checked:f,onCheckedChange:I=>{l(I===!0),Y()}}),e.jsx("label",{htmlFor:"notification-manage-existing",className:"text-sm",children:"Take over a matching one already in Composio"})]}),o.isError&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:Ua(o.error)}),e.jsx(b,{type:"button",size:"sm",disabled:!$||o.isPending,onClick:R,children:o.isPending?"Saving…":"Set up notification"})]}),a.hasNextPage&&e.jsx(b,{type:"button",size:"sm",variant:"ghost",disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:a.isFetchingNextPage?"Loading…":"Load more activity"})]})]})}function me({title:n,description:t,action:s,children:a,testId:i}){const c=`panel-section-${n.toLowerCase().replaceAll(/\s+/gu,"-")}`;return e.jsxs("section",{"aria-labelledby":c,className:"space-y-2.5","data-testid":i,children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{id:c,className:"text-sm font-semibold",children:n}),t&&e.jsx("p",{className:"text-muted-foreground text-xs",children:t})]}),s]}),a]})}function Ee({message:n,detail:t,action:s,onAction:a,pending:i=!1,secondary:c,technicalDetail:r}){return e.jsxs("div",{role:"status","data-testid":"app-panel-fix",className:"bg-status-warning-bg flex flex-col gap-3 rounded-xl p-3.5",children:[e.jsxs("p",{className:"text-status-warning-fg flex items-start gap-2 text-sm",children:[e.jsx(wn,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),e.jsxs("span",{children:[n,t&&e.jsx("span",{className:"mt-1 block",children:t})]})]}),(s&&a||c)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s&&a&&e.jsxs(b,{size:"sm",onClick:a,disabled:i,className:"h-auto min-h-8 max-w-full whitespace-normal",children:[i&&e.jsx(J,{size:"xs"}),s]}),c]}),r&&e.jsxs(de,{children:[e.jsxs(ue,{className:"group/details text-status-warning-fg/80 hover:text-status-warning-fg focus-ring flex items-center gap-1 rounded text-xs",children:[e.jsx(xt,{className:"size-3 -rotate-90 transition-transform group-data-[state=open]/details:rotate-0","aria-hidden":!0}),"Details"]}),e.jsx(he,{children:e.jsx("pre",{className:"bg-muted/50 mt-1 max-h-40 overflow-auto rounded p-2 text-xs whitespace-pre-wrap",children:r})})]})]})}function M({label:n,hint:t,destructive:s=!1,className:a,ref:i,...c}){return e.jsxs("button",{ref:i,type:"button",className:B("group/more-row hover:bg-muted/50 focus-ring flex min-h-10 w-full items-center gap-3 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-50",a),...c,children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:B("block text-sm",s&&"text-destructive"),children:n}),t&&e.jsx("span",{className:"text-muted-foreground block text-xs",children:t})]}),e.jsx(X,{className:"text-muted-foreground size-4 shrink-0 transition-transform group-data-[state=open]/more-row:rotate-90","aria-hidden":!0})]})}function Ha({detail:n,appName:t,onEditExactActions:s,onSignInAgain:a,signingIn:i,onAddAnother:c,onClose:r}){var A;const{connection:o,provider:u}=n,h=Sn({payer:o.payer,custody:u.custody}),d=o.connectionId,f=An(),l=ze(),m=Is(),x=Mn(d,o.lifecycle!=="disconnected"),[y,N]=j.useState(!1),k=o.lifecycle==="disconnected";return e.jsxs(de,{children:[e.jsxs(ue,{className:"group/more text-muted-foreground hover:text-foreground focus-ring flex w-full items-center justify-between rounded-md py-1 text-sm font-semibold",children:["More",e.jsx(X,{className:"size-4 transition-transform group-data-[state=open]/more:rotate-90","aria-hidden":!0})]}),e.jsxs(he,{className:"-mx-2 space-y-1 pt-2","data-testid":"app-panel-more",children:[!k&&e.jsx(Ga,{detail:n}),!k&&e.jsxs(de,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(M,{label:Oa(o.toolkit,t),hint:qa(((A=x.data)==null?void 0:A.pages.flatMap(p=>p.subscriptions))??[])})}),e.jsx(he,{className:"px-2 pt-2 pb-3",children:e.jsx(Ka,{connectionId:d})})]}),o.everyAgent&&e.jsx(M,{label:"Stop sharing with every agent",hint:"Agents picked by name keep access",disabled:m.isPending,onClick:()=>m.mutate({connectionId:d})}),m.isError&&e.jsx("p",{role:"alert",className:"text-destructive px-2 text-xs",children:"Couldn’t stop sharing. Try again."}),!k&&e.jsx(M,{label:"Exact actions per agent",onClick:()=>s(d)}),o.lifecycle==="connected"&&e.jsx(M,{label:"Pause",hint:"Agents stop until you resume",disabled:f.isPending,onClick:()=>f.mutate({connectionId:d,input:void 0})}),o.lifecycle==="paused"&&e.jsx(M,{label:"Resume",disabled:l.isPending,onClick:()=>l.mutate({connectionId:d,input:void 0})}),!k&&e.jsx(M,{label:"Sign in again",hint:"Who can use it stays the same",disabled:i,onClick:a}),e.jsx(M,{label:`Connect another ${t} account`,onClick:()=>c(o.toolkit)}),e.jsxs("div",{className:"px-2 py-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"How it’s connected"}),e.jsxs("p",{className:"text-muted-foreground mt-0.5 text-xs leading-relaxed",children:[u.displayName,". ",u.disclosure]}),h&&e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:h})]}),!k&&e.jsx(M,{label:"Disconnect…",destructive:!0,onClick:()=>N(!0)})]}),e.jsx(Qa,{detail:n,appName:t,open:y,onOpenChange:N,onDisconnected:r})]})}function Ga({detail:n}){const t=ft(),[s,a]=j.useState(n.connection.label),i=`connection-name-${n.connection.connectionId}`,c=s.trim()===""||s.trim()===n.connection.label;return e.jsxs("form",{className:"flex items-end gap-2 px-2 py-2",onSubmit:r=>{r.preventDefault(),!c&&t.mutate({connectionId:n.connection.connectionId,input:{label:s.trim()}})},children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx(Fe,{htmlFor:i,children:"Name"}),e.jsx(Oe,{id:i,value:s,onChange:r=>a(r.target.value)})]}),e.jsx(b,{type:"submit",variant:"secondary",disabled:c||t.isPending,children:t.isPending?"Saving…":"Save"})]})}function Qa({detail:n,appName:t,open:s,onOpenChange:a,onDisconnected:i}){const c=n.connection.connectionId,r=jt(c,s),o=In(),u=n.agents.map(h=>h.displayName);return e.jsx(xe,{open:s,onOpenChange:a,children:e.jsxs(fe,{children:[e.jsxs(je,{children:[e.jsxs(ye,{children:["Disconnect ",t,"?"]}),e.jsx(ve,{children:r.isPending?"Checking who will lose access…":r.data?Va(u,r.data):"Who loses access isn’t known yet."})]}),r.isError&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t check who loses access. Try again."}),e.jsxs(be,{children:[e.jsx(Ne,{children:"Keep connected"}),e.jsx(ke,{disabled:!r.data||o.isPending,className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",onClick:h=>{h.preventDefault(),o.mutate({connectionId:c,input:void 0},{onSuccess:()=>{a(!1),i()}})},children:o.isPending?"Disconnecting…":"Disconnect"})]})]})})}function Va(n,t){const s=[];return t.everyAgent?s.push("Every agent will lose access."):n.length>0?s.push(`${Rs(n)} will lose access.`):t.affectedAgentCount>0?s.push(`${t.affectedAgentCount} ${t.affectedAgentCount===1?"agent":"agents"} will lose access.`):s.push("No agent uses it right now."),t.affectedSessionCount>0&&s.push(`${t.affectedSessionCount} open ${t.affectedSessionCount===1?"chat":"chats"} will stop using it.`),t.affectedSubscriptionCount>0&&s.push(`${t.affectedSubscriptionCount} ${t.affectedSubscriptionCount===1?"notification stops":"notifications stop"}.`),t.pendingDeliveryCount>0&&s.push(`${t.pendingDeliveryCount} waiting ${t.pendingDeliveryCount===1?"delivery":"deliveries"} won’t be sent.`),s.join(" ")}const an=3;function Ja(n){const t=yt(n.connectionId);return t.isPending?e.jsxs("div",{className:"space-y-3","aria-label":"Loading app details",children:[e.jsx(P,{className:"h-28 rounded-lg"}),e.jsx(P,{className:"h-20 rounded-lg"})]}):t.isError?e.jsx(qn,{error:t.error,title:"Couldn’t load this app",description:"Nothing changed. Try again.",onRetry:()=>void t.refetch(),isRetrying:t.isFetching}):e.jsx(Xa,{...n,detail:t.data})}function Xa({connectionId:n,detail:t,onSignInStarted:s,onEditExactActions:a,onAddAnother:i,onClose:c}){var A;const{connection:r}=t,o=le(""),u=new Map((((A=o.data)==null?void 0:A.pages.flatMap(p=>p.services))??[]).map(p=>[p.serviceSlug,p])),h=Ce(r.toolkit,u),d=Rn(),f=An(),l=ze(),m=In(),x=vt(),y=d.error??f.error??l.error??m.error??x.error,N=()=>d.mutate({connectionId:n},{onSuccess:p=>s(p.flowId)}),k=r.readiness.state==="gone";return e.jsxs("div",{className:"space-y-7",children:[e.jsx(Za,{detail:t,appName:h,onSignInAgain:N,reconnecting:d.isPending,onResume:()=>l.mutate({connectionId:n,input:void 0}),resuming:l.isPending,onReview:()=>a(n),onConnectNew:()=>i(r.toolkit),onRemove:()=>x.mutate({connectionId:n,input:void 0},{onSuccess:()=>c()}),removing:x.isPending,onRetryDisconnect:()=>m.mutate({connectionId:n,input:void 0}),retryingDisconnect:m.isPending}),y&&e.jsx("p",{role:"alert",className:"text-destructive bg-destructive/5 rounded-lg p-3 text-sm",children:Xn(y)}),!k&&e.jsx(Bn,{mode:"page",variant:"embedded",connectionId:n,serviceName:h,onEditExactActions:a,appActions:{toolkit:r.toolkit,providerInstanceId:r.providerInstanceId}}),e.jsx(ei,{detail:t}),r.readiness.state==="ready"&&e.jsx(ni,{detail:t}),e.jsx(Ha,{detail:t,onSignInAgain:N,signingIn:d.isPending,appName:h,onEditExactActions:a,onAddAnother:i,onClose:c})]})}function Za({detail:n,appName:t,onSignInAgain:s,reconnecting:a,onResume:i,resuming:c,onReview:r,onConnectNew:o,onRemove:u,removing:h,onRetryDisconnect:d,retryingDisconnect:f}){const l=Me(),m=bt(),[x,y]=j.useState(!1),{readiness:N}=n.connection;if(N.state==="ready")return null;const k=N.fix,A=k!=null&&k.retryAt?za(k.retryAt):void 0,p=N.copy.owner,g=N.state==="gone",C=(()=>{switch(k==null?void 0:k.action){case"sign_in_again":return{action:"Sign in again",onAction:s,pending:a};case"connect_again":return{action:"Connect again",onAction:s,pending:a};case"connect_new":return{action:`Connect ${t} again`,onAction:o};case"resume":return{action:"Resume",onAction:i,pending:c};case"review_access":return{action:"Check who can use it",onAction:r};case"fix_key":return{action:"Fix the key",onAction:()=>l.open("connections","ways")};case"retry":return g?{action:"Try again now",onAction:d,pending:f}:{action:"Check again",onAction:()=>m.mutate(),pending:m.isPending};case"remove":return{action:"Remove from your apps",onAction:()=>y(!0),pending:h};case"wait":case"turn_on_for_this_chat":case void 0:return null}})(),$=N.serviceAccessPage;return e.jsxs(e.Fragment,{children:[e.jsx(Ee,{message:p,detail:A,...C??{},secondary:g&&e.jsxs(e.Fragment,{children:[$&&e.jsx(b,{asChild:!0,size:"sm",variant:"ghost",className:"h-auto min-h-8 max-w-full whitespace-normal","data-testid":"service-access-page",children:e.jsxs(qe,{href:$.url,children:["Open ",$.service," settings",e.jsx(Be,{className:"size-3.5","aria-hidden":!0})]})}),(k==null?void 0:k.action)!=="remove"&&e.jsx(b,{size:"sm",variant:"ghost",className:"h-auto min-h-8 max-w-full whitespace-normal",onClick:()=>y(!0),disabled:h,"data-testid":"remove-account",children:"Remove from your apps"})]})}),g&&e.jsx(xe,{open:x,onOpenChange:y,children:e.jsxs(fe,{children:[e.jsxs(je,{children:[e.jsxs(ye,{children:["Remove ",t," from your apps?"]}),e.jsx(ve,{asChild:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:"It leaves this list. Its activity history is kept."}),e.jsx("p",{children:"Connect it again later and you choose who can use it."}),N.reason==="disconnect_finishing"&&e.jsx("p",{children:"DorkOS still finishes removing its access at the service."})]})})]}),e.jsxs(be,{children:[e.jsx(Ne,{children:"Keep it"}),e.jsx(ke,{disabled:h,onClick:u,children:"Remove app"})]})]})})]})}function ei({detail:n}){var d,f;const{connection:t}=n,s=Nt(t.connectionId),{data:a}=ie(),[i,c]=j.useState(!1),r=Object.fromEntries(n.agents.map(l=>[l.agentId,l.displayName]));for(const l of(a==null?void 0:a.agents)??[])r[d=l.id]??(r[d]=V(l));const o=((f=s.data)==null?void 0:f.items)??[],u=i?o:o.slice(0,an);let h;return t.usage.status==="unavailable"?h=e.jsx("p",{className:"text-muted-foreground text-sm",children:"Activity isn’t available right now."}):s.isPending?h=e.jsx(P,{className:"h-16 rounded-lg"}):s.isError?h=e.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:["Couldn’t load what agents did.",e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>void s.refetch(),children:"Try again"})]}):o.length===0?h=e.jsx("p",{className:"text-muted-foreground text-sm",children:"Nothing yet."}):h=e.jsx("ul",{className:"space-y-1.5",children:u.map(l=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3 text-sm",children:[e.jsx("span",{className:"min-w-0 truncate",children:Da(l,t.toolkit,r)}),e.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:De(l.startedAt)})]},`${l.logicalOperationId}-${l.attemptIndex}`))}),e.jsx(me,{title:"Recently",action:o.length>an&&e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>c(l=>!l),children:i?"Show less":"See all"}),children:h})}function ni({detail:n}){const t=Ea(n.connection.toolkit),{data:s}=ie(),{data:a}=kt(),i=kn();if(t.length===0)return null;const c=(a==null?void 0:a.agents)??[],r=d=>c.find(f=>f.id===d)??null,o=((s==null?void 0:s.agents)??[]).find(d=>d.isSystem),u=n.agents.map(d=>r(d.agentId)).find(d=>d!==null)??r(o==null?void 0:o.id),h=u?u.displayName??u.name:null;return e.jsx(me,{title:"Try it",description:h?`Opens a chat with ${h}, ready to send.`:void 0,children:e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(d=>e.jsxs(b,{variant:"outline",size:"sm",className:"h-auto min-h-8 justify-start py-1.5 text-left whitespace-normal",disabled:!u||!i,onClick:()=>u&&i&&void i(Cn({session:crypto.randomUUID(),agentId:u.id,draft:"1",prompt:d})),children:[e.jsx(Ct,{className:"text-muted-foreground size-3.5","aria-hidden":!0}),d]},d))})})}function ti(n){return n.requesterKind==="program"?"A program":"Something using your sign-in"}function G(n,t,s){const a=Ce(n,s);return t?`${a} (${t})`:a}function on(n){return n===1?"1 action":`${n} actions`}function si(n,t){const s=ti(n),a=n.context;switch(a.kind){case"unavailable":return{title:`${s} asks to change a connection`,detail:"Open it to see the request."};case"connect":return{title:`${s} asks to connect ${G(a.toolkit,a.label,t)}`,detail:"You sign in first. No agent gets it until you choose."};case"edit":return{title:`${s} asks to rename ${G(a.connection.toolkit,a.connection.label,t)}`,detail:"Only its name changes."};case"pause":return{title:`${s} asks to pause ${G(a.connection.toolkit,a.connection.label,t)}`,detail:"Agents can’t use it until you resume it."};case"resume":return{title:`${s} asks to resume ${G(a.connection.toolkit,a.connection.label,t)}`,detail:"Agents it’s shared with get it back."};case"disconnect":return{title:`${s} asks to disconnect ${G(a.connection.toolkit,a.connection.label,t)}`,detail:a.everyAgent?"Every agent loses access.":a.affectedAgentCount===0?"No agent uses it right now.":`${a.affectedAgentCount===1?"1 agent loses":`${a.affectedAgentCount} agents lose`} access.`};case"set_agent_access":return{title:`${s} asks to let ${a.agent.displayName} use ${G(a.connection.toolkit,a.connection.label,t)}`,detail:`${on(a.requestedOperations.length)} to review.`};case"remove_agent_access":return{title:`${s} asks to stop ${a.agent.displayName} using ${G(a.connection.toolkit,a.connection.label,t)}`,detail:a.keptThroughEveryAgent.length>0?`Still shared with every agent, so it keeps ${on(a.keptThroughEveryAgent.length)}.`:"It loses access to this app."}}}function ai(n,t){if(n.state!=="approved")return null;const s=n.context,a=s.kind==="connect"?G(s.toolkit,s.label,t):s.kind==="unavailable"?"the connection":G(s.connection.toolkit,s.connection.label,t);return n.resolution.kind==="connect_authentication_required"?{title:`Approved: finish signing in to ${a}`,detail:"Open it to finish signing in."}:n.resolution.kind==="outcome_unknown"?{title:`Check ${a} before another change`,detail:"Couldn’t confirm the approved change took effect."}:null}const ii=10080*60*1e3,oi=wt,ri=60*1e3;function ci({services:n,onOpenRequest:t,onOpenReview:s}){var d,f;const a=Ts("pending"),i=nn("pending"),c=nn("resolved"),r=li(),o=(c.data??[]).filter(l=>l.state==="approved"&&(l.resolution.kind==="connect_authentication_required"&&r-Date.parse(l.resolvedAt)<oi||l.resolution.kind==="outcome_unknown"&&r-Date.parse(l.resolvedAt)<ii)),u=[a,i,c].filter(l=>l.isError);return!((((d=a.data)==null?void 0:d.length)??0)+(((f=i.data)==null?void 0:f.length)??0)+o.length>0)&&u.length===0?null:e.jsxs("section",{"aria-labelledby":"connections-needs-you","data-testid":"needs-you",className:"bg-status-warning-bg/60 rounded-xl p-1.5",children:[e.jsx("h2",{id:"connections-needs-you",className:"text-status-warning-fg px-2.5 pt-1.5 pb-1 text-xs font-semibold",children:"Needs you"}),e.jsxs("ul",{children:[(a.data??[]).map(l=>e.jsx(Ie,{testId:`needs-you-request-${l.requestId}`,line:{title:`${l.agent.displayName} wants to use ${Ce(l.serviceSlug,n)}`,detail:l.reason},onOpen:()=>t(l.requestId)},`request-${l.requestId}`)),(i.data??[]).map(l=>e.jsx(Ie,{testId:`needs-you-review-${l.reviewRequestId}`,line:si(l,n),onOpen:()=>s(l.reviewRequestId)},`review-${l.reviewRequestId}`)),o.map(l=>{const m=ai(l,n);return m?e.jsx(Ie,{testId:`needs-you-review-${l.reviewRequestId}`,line:m,onOpen:()=>s(l.reviewRequestId)},`review-${l.reviewRequestId}`):null})]}),u.length>0&&e.jsxs("p",{className:"text-muted-foreground flex flex-wrap items-center gap-x-2 px-2.5 pb-1.5 text-xs",children:["Couldn’t check for waiting requests.",e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>u.forEach(l=>void l.refetch()),children:"Try again"})]})]})}function li(){const[n,t]=j.useState(()=>Date.now());return j.useEffect(()=>{const s=setInterval(()=>t(Date.now()),ri);return()=>clearInterval(s)},[]),n}function Ie({testId:n,line:t,onOpen:s}){return e.jsx("li",{children:e.jsxs("button",{type:"button","data-testid":n,onClick:s,className:"hover:bg-background/60 focus-ring flex min-h-12 w-full items-center gap-3 rounded-lg px-2.5 py-2 text-left transition-colors",children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"line-clamp-2 block text-sm font-medium sm:line-clamp-1",children:t.title}),e.jsx("span",{className:"text-muted-foreground line-clamp-2 block text-xs sm:line-clamp-1",children:t.detail})]}),e.jsxs("span",{className:"text-muted-foreground flex shrink-0 items-center gap-0.5 text-xs font-medium",children:["Review",e.jsx(X,{className:"size-3.5","aria-hidden":!0})]})]})})}function di({requestId:n,open:t,onOpenChange:s,onEditExactActions:a,onCloseAutoFocus:i}){const c=$s(n),r=c.data?`${c.data.agent.displayName} asked to use ${oe(c.data.serviceSlug)}`:"An agent’s request";return e.jsx(Z,{open:t,onOpenChange:s,children:e.jsxs(ee,{"data-testid":"agent-request-dialog",onCloseAutoFocus:i,className:"max-h-[90vh] sm:max-w-xl",children:[e.jsxs(ne,{className:"sr-only",children:[e.jsx(te,{children:r}),e.jsx(se,{children:"Answer it here, as in the chat."})]}),e.jsx(ae,{className:"pb-4",children:c.isPending?e.jsx(P,{className:"h-40 rounded-xl","aria-label":"Loading the request"}):c.isError?e.jsx(W,{title:"Couldn’t load this request",description:"Nothing changed. Try again.",onRetry:()=>void c.refetch(),isRetrying:c.isFetching}):c.data?e.jsx(_s,{request:c.data,className:"max-w-none",...a?{onEditExactActions:a}:{}},c.data.requestId):null})]})})}function ui(n){const t=n.context;if(t.kind==="unavailable")return{title:"Older connection request",approveLabel:"Approve"};switch(t.kind){case"connect":return{title:`Connect ${oe(t.toolkit)}${t.label?` (${t.label})`:""}`,approveLabel:"Approve and continue"};case"edit":return{title:`Rename ${t.connection.label}`,approveLabel:"Approve rename"};case"pause":return{title:`Pause ${t.connection.label}`,approveLabel:"Approve pause"};case"resume":return{title:`Resume ${t.connection.label}`,approveLabel:"Approve resume"};case"disconnect":return{title:`Disconnect ${t.connection.label}`,approveLabel:"Approve disconnect"};case"set_agent_access":return{title:`Change access for ${t.agent.displayName}`,approveLabel:"Approve access"};case"remove_agent_access":return{title:`Remove access for ${t.agent.displayName}`,approveLabel:"Approve removal"}}}function hi(n){return(n.split(".").at(-1)??n).replaceAll("_"," ").replace(/\b\w/g,s=>s.toUpperCase())}function nt(n){const t=new Map;for(const s of n){const a=t.get(s.operationSlug);(!a||s.toolkitVersion.localeCompare(a.toolkitVersion,void 0,{numeric:!0})>0)&&t.set(s.operationSlug,s)}return new Set(n.filter(s=>s.toolkitVersion.localeCompare(t.get(s.operationSlug).toolkitVersion,void 0,{numeric:!0})<0).map(s=>s.operationRevisionId))}function mi({reviewRequestId:n,open:t,onOpenChange:s,onCloseAutoFocus:a}){var k;const i=Es(n),c=Ps(),[r,o]=j.useState(!1),[u,h]=j.useState(!1),d=i.data,f=(d==null?void 0:d.state)==="approved"&&d.resolution.kind==="connect_authentication_required"?d.resolution.authentication:null,l=r||!!(f&&!f.authorizeUrl),m=Os((f==null?void 0:f.flowId)??null,l),x=m.isError?"check_failed":((k=m.data)==null?void 0:k.state)??(l?"checking":"required"),y=j.useMemo(()=>d?ui(d):null,[d]),N=A=>{!n||u||c.mutate({reviewRequestId:n,decision:A},{onError:()=>{h(!0)}})};return e.jsx(Z,{open:t,onOpenChange:s,children:e.jsxs(ee,{"data-testid":"connector-review-dialog",onCloseAutoFocus:a,className:"max-h-[90vh] sm:max-w-xl [&>[data-slot=dialog-content-close]]:absolute [&>[data-slot=dialog-content-close]]:top-4 [&>[data-slot=dialog-content-close]]:right-4 [&>[data-slot=dialog-content-close]]:m-0 [&>[data-slot=dialog-content-close]]:opacity-100",children:[e.jsxs(ne,{children:[e.jsx(te,{children:(y==null?void 0:y.title)??"Review connection request"}),e.jsx(se,{className:"text-foreground",children:"Check the account, agent and actions first."})]}),e.jsx(ae,{className:"space-y-4 pb-4",children:i.isLoading?e.jsx(P,{className:"h-48 rounded-lg"}):i.isError?e.jsx(W,{title:"Couldn’t load this request",description:"It may have expired or belong to another owner.",onRetry:()=>void i.refetch(),isRetrying:i.isFetching}):d&&y?e.jsxs(e.Fragment,{children:[e.jsx(gi,{context:d.context}),d.targetStatus==="unavailable"&&d.state==="pending"&&e.jsxs("div",{className:"border-status-warning/30 bg-status-warning/5 flex gap-3 rounded-lg border p-3",children:[e.jsx(St,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0","aria-hidden":!0}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"This request can’t be approved"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"The account, agent or app setup changed since. You can still deny it."})]})]}),d.state!=="pending"&&e.jsx(xi,{review:d}),u&&e.jsxs("div",{role:"alert",className:"border-destructive/30 bg-destructive/5 rounded-lg border p-3",children:[e.jsx("p",{className:"text-sm font-medium",children:"Couldn’t confirm your decision"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Reload the request to see what was recorded."})]}),f&&e.jsxs("div",{"aria-live":"polite",className:"space-y-3 rounded-lg border p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:x==="connected"?"Account connected":x==="failed"||x==="expired"||x==="start_unknown"?"Sign-in didn’t finish":x==="pending"||x==="starting"?"Waiting for sign-in":x==="checking"?"Checking sign-in":x==="check_failed"?"Couldn’t check sign-in":"Sign-in still required"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:x==="connected"?"Sign-in finished and the account is ready.":x==="expired"?"The sign-in timed out. Connect it yourself on the Connections page.":x==="start_unknown"?"DorkOS can’t tell if the sign-in started. Connect it on the Connections page.":x==="failed"?"Sign-in didn’t finish. Connect it yourself on the Connections page.":x==="pending"||x==="starting"||x==="checking"?"Finish signing in. This page updates when the account is ready.":x==="check_failed"?"The account may be connected. Check again before another request.":"No account connected yet. Continue to the service to sign in."}),x==="check_failed"?e.jsx(b,{onClick:()=>void m.refetch(),disabled:m.isFetching,children:m.isFetching?"Checking…":"Check again"}):x!=="connected"&&x!=="failed"&&x!=="expired"&&x!=="start_unknown"&&f.authorizeUrl?e.jsx(b,{asChild:!0,children:e.jsxs(qe,{href:f.authorizeUrl,onOpened:()=>o(!0),children:["Continue to sign in",e.jsx(Be,{className:"size-4","aria-hidden":!0})]})}):x==="required"?e.jsx(b,{onClick:()=>o(!0),children:"Check connection"}):null]})]}):null}),e.jsx(ge,{children:(d==null?void 0:d.state)==="pending"&&u?e.jsx(b,{onClick:()=>{i.refetch().then(A=>{A.isError||(h(!1),c.reset())})},disabled:i.isFetching,children:i.isFetching?"Reloading request…":"Reload request"}):(d==null?void 0:d.state)==="pending"?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"outline",onClick:()=>N("denied"),disabled:c.isPending,children:"Deny"}),d.targetStatus==="available"&&d.context.kind!=="unavailable"&&e.jsx(b,{onClick:()=>N("approved"),disabled:c.isPending,children:c.isPending?"Saving decision…":y==null?void 0:y.approveLabel})]}):e.jsx(b,{variant:"secondary",onClick:()=>s(!1),children:"Done"})})]})})}function gi({context:n}){if(n.kind==="unavailable")return e.jsx("p",{className:"text-muted-foreground rounded-lg border p-4 text-sm",children:"This older request lacks the detail to approve safely."});if(n.kind==="connect")return e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 rounded-lg border p-4 text-sm",children:[e.jsx("dt",{children:"App"}),e.jsx("dd",{className:"font-medium",children:oe(n.toolkit)}),e.jsx("dt",{children:"Connected through"}),e.jsx("dd",{children:n.providerDisplayName}),n.label&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Label"}),e.jsx("dd",{children:n.label})]})]});const t=n.kind==="set_agent_access"?n.requestedOperations:n.kind==="remove_agent_access"||n.kind==="disconnect"?n.affectedOperations:[],s=nt(t),a=n.kind==="set_agent_access"||n.kind==="remove_agent_access"?n.agent:null;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 rounded-lg border p-4 text-sm",children:[e.jsx("dt",{children:"Account"}),e.jsx("dd",{className:"font-medium",children:n.connection.label}),e.jsx("dt",{children:"App"}),e.jsx("dd",{children:oe(n.connection.toolkit)}),e.jsx("dt",{children:"Status"}),e.jsx("dd",{children:At[n.connection.status]}),e.jsx("dt",{children:"Sign-in"}),e.jsx("dd",{"data-testid":"connector-review-custody",children:pi(n.connection)}),a&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Agent"}),e.jsx("dd",{children:a.displayName})]})]}),n.kind==="disconnect"&&e.jsx("p",{"data-testid":"connector-review-impact",className:"text-sm font-medium",children:n.everyAgent?"Every agent loses this account. It’s shared with every agent now.":`Removes this account from ${n.affectedAgentCount} ${n.affectedAgentCount===1?"agent":"agents"}.`}),n.kind==="remove_agent_access"&&n.keptThroughEveryAgent.length>0&&e.jsxs("div",{role:"note","data-testid":"connector-review-every-agent-kept",className:"bg-muted/40 space-y-1 rounded-lg p-3 text-sm",children:[e.jsxs("p",{children:[n.agent.displayName," keeps ",n.keptThroughEveryAgent.length," ",n.keptThroughEveryAgent.length===1?"action":"actions"," on"," ",n.connection.label," through “Every agent”."]}),e.jsxs("p",{children:["Approving removes only what ",n.agent.displayName," has by name."]}),e.jsxs("p",{children:["To remove it all, stop sharing ",n.connection.label," with every agent in Connections."]})]}),t.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-sm font-medium",children:"Exact actions"}),e.jsx("ul",{className:"space-y-2",children:t.map(i=>e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("span",{className:"text-sm",children:[hi(i.operationSlug),s.has(i.operationRevisionId)&&e.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:"Older version"})]}),e.jsx(K,{size:"xs",variant:i.capabilityClassification==="destructive"?"destructive":"secondary",children:Tn[i.capabilityClassification]})]},i.operationRevisionId))})]})]})}function pi(n){switch(n.custody){case"managed":return"Kept in Composio’s vault";case"self-host":return"Kept on your own Nango server";case"external":return"Handled by the app’s own server"}}function xi({review:n}){if(n.state==="pending")return null;if(n.state==="resolving")return e.jsxs("div",{"data-testid":"connector-review-outcome","data-outcome":"resolving",className:"bg-muted/40 rounded-lg border p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Applying change"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Still applying. Check again before another change."})]});const t=n.state==="denied"?"Denied":n.state==="expired"?"Expired":n.resolution.kind==="applied"?"Approved and applied":n.resolution.kind==="outcome_unknown"?"Outcome unknown":"Approved",s=n.state==="expired"?"This request can no longer change access.":n.state==="denied"?"No requested change was made.":n.resolution.kind==="applied"?"The requested change was applied.":n.resolution.kind==="outcome_unknown"?"It may have been applied. Check the connection before another change.":"Finish signing in to connect the account.";return e.jsxs("div",{"data-testid":"connector-review-outcome","data-outcome":n.state==="approved"?n.resolution.kind:n.state,className:"bg-muted/40 rounded-lg border p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:t}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:s})]})}function fi(n,t){switch(n){case"service_not_ready":return{title:`${t} can’t be connected yet`,description:"This isn’t something you can fix here.",canRetry:!1};case"account_link_required":return{title:"This computer isn’t linked to DorkOS",description:"Link your DorkOS account again, then connect.",canRetry:!1,action:"relink"};case"service_unavailable":return{title:`${t} isn’t available right now`,description:"Nothing was connected. Try again in a few minutes.",canRetry:!0}}}const ji=new Set(["provider_not_found","authentication_unavailable"]);function yi(n,t){const s=typeof n=="object"&&n!==null&&"code"in n?n.code:void 0;return typeof s=="string"&&ji.has(s)?{title:"Couldn’t start the connection",description:`The way DorkOS reaches ${t} isn’t working. Check Settings › Connections.`,canRetry:!1}:{title:"Couldn’t start the connection",description:"Nothing was connected. Try again in a moment.",canRetry:!0}}function vi(n,t){const s=n.authenticationSetup;return s?s.source==="configured"?`${t} uses its own sign-in page.`:s.kind==="oauth"?`A ${t} sign-in page opens next.`:s.kind==="fields"&&n.mode==="managed"?`Enter your ${t} details on dorkos.ai. DorkOS doesn’t save them.`:s.kind==="none"&&n.mode==="managed"?`Confirm this ${t} connection on dorkos.ai. No account details needed.`:null:null}function rn(n,t){var s,a,i;return(n==null?void 0:n.mode)==="managed"&&((s=n.authenticationSetup)==null?void 0:s.kind)==="fields"?"Enter account details":(n==null?void 0:n.mode)==="managed"&&((a=n.authenticationSetup)==null?void 0:a.kind)==="none"?"Review and confirm":((i=n==null?void 0:n.authenticationSetup)==null?void 0:i.source)==="configured"?"Continue":t==="authorize"?"Open sign-in":(n==null?void 0:n.authKind)==="none"?"Check connection":"Continue"}function cn({copy:n,onRetry:t,isRetrying:s=!1,onClose:a}){return n.canRetry&&t?e.jsx(W,{title:n.title,description:n.description,onRetry:t,isRetrying:s}):e.jsxs("div",{"data-testid":"connect-refusal",className:"space-y-2",children:[e.jsx($t,{icon:wn,tone:"destructive",headline:n.title,description:n.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.action==="relink"&&e.jsx(Ks,{variant:"outline",size:"sm"}),a&&e.jsx(b,{variant:"secondary",size:"sm",onClick:a,children:"Close"})]})]})}function bi({service:n,flowId:t,onFlowIdChange:s,onClose:a,onChooseAccess:i,onConnected:c}){var re,ce,_;const[r,o]=j.useState(!!(n||t)),[u,h]=j.useState(""),[d,f]=j.useState(null),[l,m]=j.useState(!1),x=It(),y=$n(t),N=((re=y.data)==null?void 0:re.toolkit)??(n==null?void 0:n.serviceSlug)??"",k=le(N),A=(ce=k.data)==null?void 0:ce.pages.flatMap(T=>T.services).find(T=>T.serviceSlug===N),p=(_=k.data)==null?void 0:_.pages[0],g=p==null?void 0:p.appConnections,C=A??n??null,$=Ls(C),Y=$.filter(T=>T.capabilities.authentication.status==="available").length,S=$.find(T=>T.providerInstanceId===d)??(y.data?$.find(T=>T.providerInstanceId===y.data.providerInstanceId):null)??Ds($,g==null?void 0:g.newApps),R=y.data??x.data,w=!R&&zs(C),E=(C==null?void 0:C.displayName)??oe((R==null?void 0:R.toolkit)??"service"),z=S?vi(S,E):null,U=S?Sn(S):null,I=Fs(S,C),L=()=>{o(!1),a()},O=()=>{s(null),L()},F=()=>{if(!C||!S)return;const T={providerInstanceId:S.providerInstanceId,...u.trim()&&{label:u.trim()}};x.mutate({...T,toolkit:C.serviceSlug,idempotencyKey:crypto.randomUUID()},{onSuccess:H=>s(H.flowId)})};return e.jsx(e.Fragment,{children:e.jsx(Z,{open:r,onOpenChange:T=>{T?o(!0):L()},children:e.jsxs(ee,{"data-testid":"connect-auth-dialog",className:B("max-h-[90vh] sm:max-w-lg [&>[data-slot=dialog-content-close]]:absolute [&>[data-slot=dialog-content-close]]:top-4 [&>[data-slot=dialog-content-close]]:right-4 [&>[data-slot=dialog-content-close]]:m-0 [&>[data-slot=dialog-content-close]]:opacity-100",w&&"min-h-0"),children:[e.jsxs(ne,{children:[e.jsxs(te,{children:["Connect ",E]}),e.jsx(se,{children:R?"Finish, then choose which agents can use it.":w?"First, pick how DorkOS reaches your apps. You only do this once.":"Name the account and check who handles sign-in."})]}),e.jsx(ae,{className:"space-y-4 pb-4",children:w&&$.length===0&&Ms(p)&&(g==null?void 0:g.newApps.status)==="ready"?e.jsx(W,{title:`Couldn’t reach ${E} just now`,description:`${qs(g.newApps.way)} didn’t answer. Try again in a moment.`,onRetry:()=>void k.refetch(),isRetrying:k.isFetching}):w?e.jsx(Bs,{reason:Us(g,C),onLeave:L}):R?R.state==="starting"||R.state==="pending"?e.jsxs("div",{className:"space-y-4",children:[S&&e.jsxs("div",{"data-testid":"connect-disclosure",className:"bg-muted/40 space-y-1.5 rounded-lg p-3",children:[e.jsx("p",{className:"text-sm font-medium",children:S.displayName}),e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:S.disclosure}),z&&e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:z}),U&&e.jsx("p",{className:"text-muted-foreground text-xs",children:U})]}),R.state==="pending"&&R.authorizeUrl?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:I??`Continue to sign in to ${E}.`}),e.jsx(b,{asChild:!0,className:"w-full",children:e.jsxs(qe,{href:R.authorizeUrl,keepOpener:(S==null?void 0:S.mode)==="managed",children:[rn(S,"authorize"),e.jsx(Be,{className:"size-4","aria-hidden":!0})]})})]}):e.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[e.jsx(_n,{className:"size-4 animate-spin","aria-hidden":!0}),R.state==="starting"?"Starting the connection…":"Waiting for sign-in…"]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"You can reload or leave without starting over."}),y.isError&&e.jsx(W,{title:"Couldn’t check the connection",description:"Sign-in may still finish. Check again.",onRetry:()=>void y.refetch(),isRetrying:y.isFetching})]}):R.state==="connected"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Tt,{className:"text-status-success size-4","aria-hidden":!0}),e.jsxs("span",{children:[E," is connected"]})]}),e.jsx(Bn,{mode:"page",connectionId:R.connectionId,serviceName:E,logo:We(C),onSkip:()=>{O(),c==null||c(R.connectionId)},onFinished:()=>{O(),c==null||c(R.connectionId)},onEditExactActions:T=>{i(T),O()}})]}):R.state==="failed"&&R.failureCode?(()=>{const T=fi(R.failureCode,E);return e.jsx(cn,{copy:T,onRetry:T.canRetry?()=>{s(null),x.reset()}:void 0,onClose:O})})():e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{role:"alert",className:"text-destructive text-sm font-medium",children:R.state==="expired"?"This connection request expired.":"The connection didn’t finish."}),"reason"in R&&e.jsx("p",{className:"text-muted-foreground text-xs",children:R.reason}),e.jsx(b,{variant:"secondary",onClick:()=>{s(null),x.reset()},children:"Start again"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Fe,{htmlFor:"connection-label",children:"Account label"}),e.jsx(Oe,{id:"connection-label",value:u,onChange:T=>h(T.target.value),placeholder:"Work, personal, support…",autoComplete:"off"}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Tells several ",E," accounts apart."]})]}),I&&e.jsx("p",{"data-testid":"connect-sign-in-line",className:"text-sm",children:I}),S?e.jsxs("div",{"data-testid":"connect-disclosure",className:"bg-muted/40 space-y-2 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rt,{className:"text-muted-foreground size-4","aria-hidden":!0}),e.jsx("p",{className:"text-sm font-medium",children:S.displayName})]}),Y>1&&e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>m(T=>!T),children:"Connect another way"})]}),e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:S.disclosure}),z&&e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:z}),U&&e.jsx("p",{className:"text-muted-foreground text-xs",children:U})]}):null,e.jsx(Ws,{toolkit:N,appName:E,providerInstanceId:(S==null?void 0:S.providerInstanceId)??null}),l&&e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"text-xs font-medium",children:"Ways to connect"}),$.map(T=>{const H=T.capabilities.authentication.status==="available";return e.jsxs("button",{type:"button",disabled:!H,onClick:()=>{f(T.providerInstanceId),m(!1)},className:"bg-muted/40 focus-visible:ring-ring flex min-h-11 w-full items-center justify-between rounded-lg px-3 py-2 text-left focus-visible:ring-2 focus-visible:outline-none disabled:opacity-50",children:[e.jsx("span",{children:e.jsx("span",{className:"block text-sm font-medium",children:T.displayName})}),!H&&e.jsx("span",{className:"text-muted-foreground text-xs",children:"Unavailable"})]},T.providerInstanceId)})]}),x.isError&&e.jsx(cn,{copy:yi(x.error,E),onRetry:F,isRetrying:x.isPending})]})}),!R&&e.jsxs(ge,{children:[e.jsx(b,{variant:"ghost",onClick:L,children:"Cancel"}),!w&&e.jsx(b,{onClick:F,disabled:!S||x.isPending,children:x.isPending?"Starting…":rn(S,"start")})]})]})})})}function Ni(n){var s,a;const t=((s=n.senderName)==null?void 0:s.trim())||"Someone";if(n.chatKind==="group"){const i=(a=n.chatTitle)==null?void 0:a.trim();return i?`${t} added your bot to “${i}”`:`${t} added your bot to a group`}return`${t} messaged your bot`}function ln(n){return n.chatKind==="group"?"Which agent should join?":"Which agent should answer?"}function ki(n){return n.chatKind==="group"&&n.platformChatType==="channel"}function Ci({chat:n,agentOptions:t,onClaim:s,onIgnore:a,onBlock:i,onLeave:c,isDeciding:r=!1}){var f;const[o,u]=j.useState(t.length===1?((f=t[0])==null?void 0:f.id)??"":""),h=n.chatKind==="group",d=ki(n);return e.jsxs(_t,{"data-testid":`claim-card-${n.id}`,gap:"sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:Ni(n)}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:[n.messageCount===1?"One message so far.":`${n.messageCount} messages so far.`," ","Not read or answered yet."]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[!d&&e.jsxs(En,{value:o,onValueChange:u,disabled:r,children:[e.jsx(Pn,{className:"w-full sm:w-56","aria-label":ln(n),"data-testid":`claim-agent-${n.id}`,children:e.jsx(On,{placeholder:ln(n)})}),e.jsx(Ln,{children:t.map(l=>e.jsx($e,{value:l.id,children:V(l)},l.id))})]}),d?null:h?e.jsx(b,{size:"sm",disabled:!o||r,onClick:()=>s(o,!0),children:"Join"}):e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"sm",disabled:!o||r,onClick:()=>s(o,!0),children:"Answer in a channel"}),e.jsx(b,{size:"sm",variant:"outline",disabled:!o||r,onClick:()=>s(o,!1),children:"Answer privately"})]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:r,onClick:a,children:"Ignore"}),h?e.jsx(b,{size:"sm",variant:"ghost",disabled:r,onClick:c,children:"Leave"}):e.jsx(b,{size:"sm",variant:"ghost",disabled:r,onClick:i,children:"Block"})]}),d?e.jsx("p",{className:"text-muted-foreground text-xs",children:"Broadcast channel: no one to answer. Ignore hides it. Leave removes the bot."}):h?e.jsx("p",{className:"text-muted-foreground text-xs",children:"Ignore hides this quietly. Leave removes the bot, so nothing more arrives."}):e.jsxs("div",{className:"text-muted-foreground space-y-0.5 text-xs",children:[e.jsx("p",{children:"A channel gives you a room to see and reply from."}),e.jsx("p",{children:"Answering privately keeps this chat as it is."}),e.jsx("p",{children:"Ignore hides this quietly. Block stops recording this chat."})]})]})}function wi({enabled:n,adapterId:t}){Vs();const{data:s,isLoading:a}=Un("pending",n),{data:i}=ie(),c=Js(),r=Xs(),o=Zs(),u=ea(),h=Ue(),[d,f]=j.useState(null),l=(i==null?void 0:i.agents)??[],m=(s??[]).filter(y=>!t||y.adapterId===t),x=c.isPending||r.isPending||o.isPending||u.isPending;return n?a?e.jsx(P,{className:"h-28 w-full rounded-lg"}):m.length===0?null:e.jsxs("section",{"aria-labelledby":"connections-waiting",className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"connections-waiting",className:"text-sm font-semibold",children:"Waiting on you"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:m.length===1?"Someone messaged a bot with no agent to answer.":`${m.length} chats reached a bot with no agent to answer.`})]}),m.map(y=>e.jsx(Ci,{chat:y,agentOptions:l,isDeciding:x,onClaim:(N,k)=>{var p;const A=((p=l.find(g=>g.id===N))==null?void 0:p.name)??N;c.mutate({id:y.id,input:{agentId:N,bridge:k}},{onSuccess:({binding:g,bridgeError:C})=>{if(C){D.warning(`${A} will answer this chat privately: ${C}`);return}if(k&&g.roomId){D.success(`${A} will answer in a new channel.`),h({...Dn.channels(),search:{id:g.roomId}});return}D.success(`${A} will answer this chat.`)},onError:g=>{const C=_e(g,{id:N,name:A});if(C){f(C);return}D.error(g instanceof Error?g.message:"Couldn’t set an agent to answer")}})},onIgnore:()=>r.mutate(y.id,{onSuccess:()=>D.success("Ignored. This chat won’t show again.")}),onBlock:()=>o.mutate(y.id,{onSuccess:()=>D.success("Blocked. This chat is no longer recorded.")}),onLeave:()=>u.mutate(y.id,{onSuccess:()=>D.success("Left the group. It’s no longer recorded.")})},y.id)),e.jsx(Jn,{conflict:d,onClose:()=>f(null)})]}):null}function Si({connectionId:n,open:t,onOpenChange:s}){var A,p;const[a,i]=j.useState({}),[c,r]=j.useState(null),o=Ys({connectionId:n,active:t,onPreview:g=>i(Hs(g))}),{preview:u,saveOutcome:h,saved:d,needsReconciliation:f,needsRefresh:l}=o,m=(p=(A=yn().data)==null?void 0:A.connections.find(g=>g.connectionId===n))==null?void 0:p.readiness,x=(m==null?void 0:m.reason)==="needs_review"||(m==null?void 0:m.reason)==="access_update_failed",y=j.useMemo(()=>u?Gs(u,a):[],[u,a]),N=l||h!==null,k=x&&y.length===0;return e.jsx(Z,{open:t,onOpenChange:s,children:e.jsxs(ee,{"data-testid":"connector-access-dialog",className:"max-h-[90vh] sm:max-w-3xl [&>[data-slot=dialog-content-close]]:absolute [&>[data-slot=dialog-content-close]]:top-4 [&>[data-slot=dialog-content-close]]:right-4 [&>[data-slot=dialog-content-close]]:m-0 [&>[data-slot=dialog-content-close]]:opacity-100",children:[e.jsxs(ne,{children:[e.jsx(te,{children:"Choose agent access"}),e.jsx(se,{children:"Pick the actions each agent may take. Current access stays selected."})]}),e.jsx(ae,{className:"space-y-4 pb-4",children:o.isLoading?e.jsxs("div",{className:"space-y-3","aria-label":"Loading account actions",children:[e.jsx(P,{className:"h-20 rounded-lg"}),e.jsx(P,{className:"h-36 rounded-lg"})]}):o.loadFailed?e.jsx(qn,{error:o.loadError,title:"Couldn’t load account actions",description:"Nothing changed. Try again.",onRetry:o.refresh,isRetrying:o.isLoading}):N?e.jsx(Qs,{access:o}):u?e.jsxs(e.Fragment,{children:[x&&m&&e.jsxs("p",{"data-testid":"access-dialog-cause",className:"bg-status-warning-bg text-status-warning-fg rounded-lg p-3 text-sm",children:[m.copy.owner," If this looks right, confirm it."]}),e.jsx(Ai,{preview:u,selections:a,setSelections:i,advancedAgentId:c,setAdvancedAgentId:r})]}):null}),e.jsxs(ge,{children:[e.jsx(b,{variant:"ghost",onClick:()=>s(!1),children:d?"Done":h?"Close":"Cancel"}),f?e.jsx(b,{variant:"secondary",onClick:o.refresh,children:"Reload current access"}):h&&!d?e.jsxs(b,{variant:"secondary",onClick:o.checkSync,disabled:o.isCheckingSync,children:[e.jsx(_n,{className:"size-4","aria-hidden":!0}),o.isCheckingSync?"Checking…":"Check if it’s done"]}):!l&&u&&!d?e.jsx(b,{onClick:()=>o.apply(y,void 0,{confirm:k}),disabled:y.length===0&&!x||o.isSaving,children:o.isSaving?"Saving…":k?"Confirm access":"Save access"}):null]})]})})}function Ai({preview:n,selections:t,setSelections:s,advancedAgentId:a,setAdvancedAgentId:i}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:n.connection.label}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Pick a level for each agent. Use Advanced for single actions."})]}),n.everyAgent.operationRevisionIds.length>0&&e.jsxs("div",{"data-testid":"exact-editor-every-agent",className:"bg-muted/40 space-y-1 rounded-lg p-3 text-sm",children:[e.jsxs("p",{children:["Every agent, even future ones, also has ",n.everyAgent.operationRevisionIds.length," ",n.everyAgent.operationRevisionIds.length===1?"action":"actions"," here."]}),e.jsx("p",{className:"text-muted-foreground",children:"The levels below don’t include them. To remove them, stop sharing with every agent."})]}),n.agents.length===0?e.jsx("p",{className:"bg-muted/40 rounded-lg p-4 text-sm",children:"No agents yet. Add one first."}):e.jsx("div",{className:"space-y-2",children:n.agents.map(c=>{const r=nt(n.candidates),o=t[c.agentId],u=new Set((o==null?void 0:o.operationRevisionIds)??[]),h=(o==null?void 0:o.level)==="read"?"Read":(o==null?void 0:o.level)==="read-write"?"Read + write":u.size===0?"No access":"Custom access",d=a===c.agentId,f=l=>s({...t,[c.agentId]:{operationRevisionIds:Et(n.candidates,l),...l!=="none"&&{level:l}}});return e.jsxs("fieldset",{className:"bg-muted/40 rounded-lg p-3",children:[e.jsxs("legend",{className:"sr-only",children:["Access for ",c.displayName]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:c.displayName}),e.jsx("p",{className:"text-muted-foreground text-xs",children:h})]}),e.jsx(b,{size:"sm",variant:"ghost","aria-expanded":d,onClick:()=>i(d?null:c.agentId),children:"Advanced"})]}),e.jsx("div",{className:"mt-2 grid grid-cols-3 gap-1.5","aria-label":`Quick access for ${c.displayName}`,children:[["none","No access"],["read","Read"],["read-write","Read + write"]].map(([l,m])=>e.jsx(b,{size:"sm",variant:h===m?"secondary":"outline","aria-pressed":h===m,onClick:()=>f(l),className:"px-2 text-xs",children:m},l))}),d&&e.jsx("ul",{className:"mt-3 space-y-1.5","data-testid":`advanced-access-${c.agentId}`,children:n.candidates.map(l=>{const m=u.has(l.operationRevisionId),x=!l.supported&&!m;return e.jsxs("li",{className:"bg-background flex gap-3 rounded-md p-2.5",children:[e.jsx(Nn,{"aria-label":`${Te(l.operationSlug,n.connection.toolkit)} for ${c.displayName}`,checked:m,disabled:x,onCheckedChange:y=>{const N=new Set(u);y===!0?N.add(l.operationRevisionId):N.delete(l.operationRevisionId),s({...t,[c.agentId]:{operationRevisionIds:[...N].sort()}})}}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-medium",children:Te(l.operationSlug,n.connection.toolkit)}),e.jsx(K,{size:"xs",variant:l.capabilityClassification==="destructive"?"destructive":"secondary",children:Tn[l.capabilityClassification]}),!l.supported&&e.jsx(K,{size:"xs",variant:"outline",children:"No longer available"}),r.has(l.operationRevisionId)&&e.jsx("span",{className:"text-muted-foreground text-xs",children:"Older version"})]})})]},l.operationRevisionId)})})]},c.agentId)})})]})}function Ii({agentName:n,sessionStrategy:t,chatId:s,channelType:a,canInitiate:i=!1,canReply:c=!0,canReceive:r=!0}){return e.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"truncate",children:n}),t!=="per-chat"&&e.jsx(K,{variant:"secondary",className:"shrink-0",children:sa(t)}),s&&e.jsx(K,{variant:"outline",className:"shrink-0 truncate",children:a?`#${s}`:s}),e.jsxs(Pt,{children:[i&&e.jsxs(we,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(Ot,{className:"size-3 shrink-0 text-amber-500","aria-label":"Can start conversations"})}),e.jsx(Ae,{children:"Can start conversations"})]}),!c&&e.jsxs(we,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(aa,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Can’t reply"})}),e.jsx(Ae,{children:"Can’t reply"})]}),!r&&e.jsxs(we,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(Lt,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Doesn’t receive messages"})}),e.jsx(Ae,{children:"Doesn’t receive messages"})]})]})]})}const Ri=["People you may not know can put text in front of your agent.","Permissions are the real limit. A bridged chat asks before acting by default.","Raise that only if you trust everyone in the chat.","The channel keeps the whole record: every message that reached your agent, for good."];function Ti({binding:n,onDone:t}){const s=Ke({errorLabel:"Couldn’t bridge that chat"}),a=Ue();if(n.bridge==="room")return e.jsx($i,{binding:n,onDone:t});if(!n.chatId)return e.jsx(Re,{reason:"This reaches every chat here. Point it at one chat first."});if(n.platformChatType==="channel")return e.jsx(Re,{reason:"This is a broadcast channel, not a two-way conversation. Your agent can’t reply."});const i=n.channelType==null||n.channelType==="dm";if(!(n.platformChatType==="private"||n.platformChatType==="group"||n.platformChatType==="supergroup"||n.platformChatType==null&&i))return e.jsx(Re,{reason:"DorkOS doesn’t know what kind of chat this is. Reconnect it from a new message."});async function r(){try{const o=await s.mutateAsync({id:n.id,updates:{bridge:"room"}});o.roomId&&a({...Dn.channels(),search:{id:o.roomId}}),t==null||t()}catch{}}return e.jsxs("section",{className:"border-border/60 space-y-3 rounded-lg border p-3","aria-labelledby":"bridge-heading",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zn,{className:"text-muted-foreground size-4"}),e.jsx("h4",{id:"bridge-heading",className:"text-sm font-medium",children:"Bridge to a channel"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Messages land in a channel your agent reads. You can reply from there too."}),e.jsx("ul",{className:"text-muted-foreground space-y-1.5 text-xs",children:Ri.map(o=>e.jsxs("li",{className:"flex gap-1.5",children:[e.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60",children:"•"}),e.jsx("span",{children:o})]},o))}),e.jsxs(b,{size:"sm",onClick:r,disabled:s.isPending,children:[s.isPending&&e.jsx(J,{size:"xs",className:"mr-1.5"}),"Bridge to a channel"]})]})}function $i({binding:n,onDone:t}){const s=Ke({errorLabel:"Couldn’t un-bridge that chat"}),a=Dt(),{data:i}=zt(n.roomId??null),c=i!==void 0,r=(i==null?void 0:i.deliverNotices)??!1;async function o(){try{await s.mutateAsync({id:n.id,updates:{bridge:"off"}}),D.success("This chat is private again"),t==null||t()}catch{}}return e.jsxs("section",{className:"border-border/60 space-y-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zn,{className:"text-muted-foreground size-4"}),e.jsx("p",{className:"text-sm font-medium",children:"This chat is a channel"})]}),n.roomId&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Fe,{htmlFor:"bridge-deliver-notices",className:"cursor-pointer text-xs font-normal",children:"Tell this chat when your agent stops early"}),e.jsx(Ft,{id:"bridge-deliver-notices",checked:r,disabled:!c||a.isPending,onCheckedChange:u=>a.mutate({roomId:n.roomId,deliverNotices:u}),"aria-label":"Tell this chat when your agent stops early"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"People in this chat see a short note."})]}),e.jsxs(xe,{children:[e.jsx(Mt,{asChild:!0,children:e.jsx(b,{variant:"ghost",size:"sm",className:"text-muted-foreground",children:"Un-bridge this chat"})}),e.jsxs(fe,{children:[e.jsxs(je,{children:[e.jsx(ye,{children:"Un-bridge this chat?"}),e.jsx(ve,{children:"Its channel is archived. The chat goes back to a private, one-to-one line."})]}),e.jsxs(qt,{children:[e.jsx("p",{children:"The channel and everything in it are kept."}),e.jsx("p",{children:"Bridging this chat again brings its history back."}),e.jsx("p",{children:"For a clean start with no old messages, archive the channel, then bridge again."})]}),e.jsxs(be,{children:[e.jsx(Ne,{children:"Keep it bridged"}),e.jsx(ke,{onClick:o,children:"Un-bridge"})]})]})]})]})}function Re({reason:n}){return e.jsxs("section",{className:"border-border/60 bg-muted/30 flex gap-2 rounded-lg border p-3",children:[e.jsx(ia,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Can’t bridge this chat"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:n})]})]})}function _i({adapterId:n,onQuickBind:t,onAdvanced:s,isPending:a,children:i}){const[c,r]=j.useState(!1),{data:o}=ie(),{data:u=[]}=pe(),h=j.useMemo(()=>new Set(u.filter(m=>m.adapterId===n).map(m=>m.agentId)),[u,n]),d=j.useMemo(()=>((o==null?void 0:o.agents)??[]).filter(m=>!h.has(m.id)),[o,h]);async function f(m){await t(m),r(!1)}function l(){r(!1),s()}return e.jsxs(Bt,{open:c,onOpenChange:r,children:[e.jsx(Ut,{asChild:!0,children:i}),e.jsxs(Wt,{className:"w-56 p-0",align:"start",children:[e.jsxs(Kt,{children:[e.jsx(Yt,{placeholder:"Search agents…"}),e.jsxs(Ht,{children:[e.jsx(Gt,{children:"No agents to add"}),d.map(m=>e.jsxs(Qt,{value:m.id,keywords:[V(m)],onSelect:()=>f(m.id),disabled:a,children:[a?e.jsx(J,{size:"xs",className:"mr-2"}):null,V(m)]},m.id))]})]}),e.jsx("div",{className:"border-t px-2 py-1.5",children:e.jsx(b,{variant:"ghost",size:"sm",className:"text-muted-foreground w-full text-xs",onClick:l,children:"Advanced…"})})]})]})}function Ei({instance:n,appName:t,emphasizePick:s=!0}){const{data:a=[]}=pe(),{data:i}=ie(),c=Vt({suppressErrorToast:!0}),r=Ke({suppressErrorToast:!0}),o=ta(),[u,h]=j.useState(null),[d,f]=j.useState(null),l=(i==null?void 0:i.agents)??[],m=g=>{const C=l.find($=>$.id===g);return C?V(C):g},x=a.filter(g=>g.adapterId===n.id);async function y(g){try{await c.mutateAsync({adapterId:n.id,agentId:g,sessionStrategy:"per-chat",label:""}),D.success(`${m(g)} answers ${t} now`)}catch(C){const $=_e(C,{id:g,name:m(g)});if($){f($);return}D.error(C instanceof Error?C.message:"Couldn’t set who answers")}}async function N(g){if(u)try{u.mode==="edit"?(await r.mutateAsync({id:u.binding.id,updates:Zt(g)}),D.success("Saved")):(await c.mutateAsync(es(g)),D.success(`${m(g.agentId)} answers ${t} now`)),h(null)}catch(C){const $=_e(C,{id:g.agentId,name:m(g.agentId)});if($){f($);return}D.error(C instanceof Error?C.message:"Couldn’t save that")}}async function k(g){try{await o.mutateAsync(g),D.success("Removed"),h(null)}catch{}}const A=(g,C)=>e.jsx(_i,{adapterId:n.id,onQuickBind:y,onAdvanced:()=>h({mode:"create"}),isPending:c.isPending,children:e.jsxs(b,{variant:C,size:"sm",children:[e.jsx(Xt,{className:"size-3.5","aria-hidden":!0}),g]})}),p=(u==null?void 0:u.mode)==="edit"?u.binding:null;return e.jsxs("div",{className:"space-y-2","data-testid":"chat-app-answerers",children:[x.length===0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"No agent answers yet. Messages wait until you pick one."}),A("Pick who answers",s?"default":"outline")]}):e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"-mx-2 space-y-0.5",children:x.map(g=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>h({mode:"edit",binding:g}),className:"group/row hover:bg-muted/50 focus-ring flex min-h-10 w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors",children:[e.jsx(Ii,{agentName:m(g.agentId),sessionStrategy:g.sessionStrategy,chatId:g.chatId,channelType:g.channelType,canInitiate:g.canInitiate,canReply:g.canReply,canReceive:g.canReceive}),e.jsx(X,{className:"text-muted-foreground ml-auto size-4 shrink-0","aria-hidden":!0})]})},g.id))}),A("Add an agent","ghost")]}),u&&e.jsx(Jt,{open:!0,onOpenChange:g=>{g||h(null)},mode:u.mode,initialValues:p?{adapterId:p.adapterId,agentId:p.agentId,sessionStrategy:p.sessionStrategy,label:p.label??"",permissionMode:p.permissionMode,chatId:p.chatId,channelType:p.channelType,canInitiate:p.canInitiate,canReply:p.canReply,canReceive:p.canReceive}:{adapterId:n.id},adapterName:t,agentName:p?m(p.agentId):void 0,onConfirm:N,onDelete:p?k:void 0,bindingId:p==null?void 0:p.id,isPending:c.isPending||r.isPending||o.isPending,bridged:(p==null?void 0:p.bridge)==="room",bridgeSlot:p?e.jsx(Ti,{binding:p,onDone:()=>h(null)}):void 0}),e.jsx(Jn,{conflict:d,onClose:()=>f(null),onMoved:()=>h(null)})]})}const Pi={"adapter.connected":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","adapter.message_sent":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","adapter.disconnected":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","adapter.error":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","adapter.message_received":"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200","adapter.status_change":"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200"},Pe={"adapter.connected":"Connected","adapter.disconnected":"Disconnected","adapter.message_received":"Received","adapter.message_sent":"Sent","adapter.error":"Error","adapter.status_change":"Status"},Oi=Object.keys(Pe);function Li({adapterId:n}){const{data:t,isLoading:s}=Vn(n),[a,i]=j.useState("all"),c=j.useRef(null),[r,o]=j.useState(!0),u=j.useCallback(()=>{const l=c.current;if(!l)return;o(l.scrollHeight-l.scrollTop-l.clientHeight<20)},[]);j.useEffect(()=>{r&&c.current&&(c.current.scrollTop=c.current.scrollHeight)},[t,r]);const h=()=>{c.current&&(c.current.scrollTop=c.current.scrollHeight,o(!0))};if(s)return e.jsx("div",{className:"space-y-2 p-3",children:[1,2,3,4].map(l=>e.jsx(P,{className:"h-6 w-full"},l))});const d=(t==null?void 0:t.events)??[],f=a==="all"?d:d.filter(l=>l.subject===a);return d.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-6 text-center",children:[e.jsx(ns,{className:"text-muted-foreground size-6"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"No events yet"})]}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[e.jsx("h4",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Events"}),e.jsxs(En,{value:a,onValueChange:i,children:[e.jsx(Pn,{responsive:!1,className:"h-7 w-[130px] text-xs",children:e.jsx(On,{})}),e.jsxs(Ln,{children:[e.jsx($e,{value:"all",children:"All types"}),Oi.map(l=>e.jsx($e,{value:l,children:Pe[l]},l))]})]})]}),e.jsx("div",{ref:c,onScroll:u,className:"flex-1 overflow-y-auto p-2",children:f.map(l=>{const m=l.metadata?JSON.parse(l.metadata):null,x=new Date(l.sentAt).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsxs("div",{className:"flex items-start gap-2 py-1",children:[e.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-xs tabular-nums",children:x}),e.jsx(K,{size:"xs",variant:"secondary",className:B("shrink-0",Pi[l.subject]??""),children:Pe[l.subject]??l.subject}),e.jsx("span",{className:"text-xs break-words",children:(m==null?void 0:m.message)??l.subject})]},l.id)})}),!r&&e.jsx("div",{className:"flex justify-center border-t py-1",children:e.jsxs(b,{variant:"ghost",size:"sm",onClick:h,className:"h-6 text-xs",children:[e.jsx(ts,{className:"mr-1 size-3"}),"Jump to bottom"]})})]})}const Di=3,zi={"adapter.message_received":"A message came in","adapter.message_sent":"A reply went out","adapter.connected":"Connected","adapter.disconnected":"Disconnected","adapter.status_change":"Its status changed"};function Fi(n){if(!n)return null;try{return JSON.parse(n)}catch{return null}}function Mi(n,t){if(n==="adapter.error"){const s=Fi(t);return s!=null&&s.message?`Something went wrong: ${s.message}`:"Something went wrong"}return zi[n]??n}function qi({adapterId:n}){const{data:t,isPending:s,isError:a,refetch:i}=Vn(n),[c,r]=j.useState(!1),o=(t==null?void 0:t.events)??[],[u,h]=j.useState(null);return s?e.jsx(P,{className:"h-16 rounded-lg"}):a?e.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:["Couldn’t load what happened here.",e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>void i(),children:"Try again"})]}):o.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Nothing yet."}):c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"bg-muted/30 h-72 overflow-hidden rounded-lg",children:e.jsx(Li,{adapterId:n})}),e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>r(!1),children:"Show less"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("ul",{className:"space-y-1.5",children:o.slice(0,Di).map(d=>{const f=Mi(d.subject,d.metadata),l=u===d.id,m=e.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:De(d.sentAt)});return d.subject==="adapter.error"?e.jsx("li",{children:e.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>h(l?null:d.id),className:"focus-ring hover:bg-muted/50 -mx-1 flex w-full items-baseline justify-between gap-3 rounded px-1 text-left text-sm",children:[e.jsx("span",{className:B("min-w-0",l?"break-words":"truncate"),children:f}),m]})},d.id):e.jsxs("li",{className:"flex items-baseline justify-between gap-3 text-sm",children:[e.jsx("span",{className:"min-w-0 truncate",children:f}),m]},d.id)})}),e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>r(!0),children:"See all"})]})}function Bi({row:n,open:t,onOpenChange:s,onCloseAutoFocus:a,children:i}){const c=ss(),[r,o]=j.useState({open:t,mobile:c});let u=r.mobile;(r.open!==t||!t&&r.mobile!==c)&&(o({open:t,mobile:c}),u=c);const h=n&&e.jsxs("div",{className:"flex items-center gap-3 pr-8",children:[e.jsx(xn,{iconKey:n.iconKey,displayName:n.name,logo:n.logo,className:"size-10 rounded-lg"}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs(un,{mobile:u,className:"flex items-center gap-2 text-base font-semibold",children:[e.jsx("span",{className:"truncate",children:n.name}),n.kind==="chat"&&e.jsx(K,{size:"xs",variant:"secondary",children:"Chat"})]}),e.jsxs(hn,{mobile:u,className:"text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs",children:[n.account&&e.jsx("span",{className:"truncate",children:n.identity?`${n.account} · ${n.identity}`:n.account}),n.tone==="ready"&&e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[n.account&&e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:B("size-2 rounded-full",fn.success),"aria-hidden":!0}),"Connected"]})]})]})]}),d=e.jsxs(e.Fragment,{children:[e.jsx(un,{mobile:u,className:"sr-only",children:"App details"}),e.jsx(hn,{mobile:u,className:"sr-only",children:"Loading this app."})]});return u?e.jsx(as,{open:t,onOpenChange:s,children:e.jsxs(is,{className:"max-h-[88vh] outline-none","data-testid":"app-panel",onOpenAutoFocus:dn,onCloseAutoFocus:a,children:[e.jsx("div",{className:"px-4 pt-3 pb-3",children:h??d}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-6",children:i})]})}):e.jsx(os,{open:t,onOpenChange:s,children:e.jsxs(rs,{className:"w-full gap-0 outline-none","data-testid":"app-panel",onOpenAutoFocus:dn,onCloseAutoFocus:a,children:[e.jsx("div",{className:"px-6 pt-5 pb-4",children:h??d}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-8",children:i})]})})}function dn(n){var t;n.preventDefault(),(t=n.currentTarget)==null||t.focus()}function un({mobile:n,className:t,children:s}){return n?e.jsx(cs,{className:t,children:s}):e.jsx(ls,{className:t,children:s})}function hn({mobile:n,className:t,children:s}){return n?e.jsx(ds,{className:t,children:s}):e.jsx(us,{className:t,children:s})}function Ui({service:n,onClose:t,onChooseChat:s,onChooseAccount:a}){const i=(n==null?void 0:n.displayName)??"";return e.jsx(Z,{open:n!==null,onOpenChange:c=>!c&&t(),children:e.jsxs(ee,{className:"min-h-0 sm:max-w-md","data-testid":"app-use-choice",children:[e.jsxs(ne,{children:[e.jsxs(te,{children:["Connect ",i]}),e.jsx(se,{children:"What do you want to do?"})]}),e.jsxs(ae,{className:"space-y-2 pb-5",children:[e.jsx(mn,{icon:e.jsx(hs,{className:"size-4","aria-hidden":!0}),title:`Talk to my agents in ${i}`,detail:`Your agents get a ${i} bot. You message it, they answer.`,onClick:()=>n&&s(n)}),e.jsx(mn,{icon:e.jsx(ms,{className:"size-4","aria-hidden":!0}),title:`Let agents use my ${i}`,detail:"Agents can read and post as you.",onClick:()=>n&&a(n)})]})]})})}function mn({icon:n,title:t,detail:s,onClick:a}){return e.jsxs("button",{type:"button",onClick:a,className:"bg-muted/40 hover:bg-muted/70 focus-ring flex w-full items-start gap-3 rounded-xl p-3.5 text-left transition-colors",children:[e.jsx("span",{className:"bg-background text-muted-foreground flex size-8 shrink-0 items-center justify-center rounded-lg",children:n}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium",children:t}),e.jsx("span",{className:"text-muted-foreground block text-xs",children:s})]})]})}function Wi({entry:n,instance:t,onClose:s}){const{manifest:a}=n,i=Fn(),c=gs(),r=Le(),[o,u]=j.useState(null),[h,d]=j.useState(!1),f=t.status.state==="error"||t.status.state==="disconnected",l=m=>i.mutate({id:t.id,enabled:m});return e.jsxs("div",{className:"space-y-7",children:[t.enabled?f?e.jsx(Ee,{message:"Stopped working. Messages aren’t getting through.",technicalDetail:t.status.lastError,action:"Check its settings",onAction:()=>u("edit")}):null:e.jsx(Ee,{message:"Paused. No messages go in or out.",action:"Resume",pending:i.isPending,onAction:()=>l(!0)}),e.jsx(me,{title:"Who answers",children:e.jsx(Ei,{instance:t,appName:a.displayName,emphasizePick:t.enabled&&!f})}),e.jsx(wi,{enabled:!0,adapterId:t.id}),e.jsx(me,{title:"Recently",children:e.jsx(qi,{adapterId:t.id})}),e.jsxs(de,{children:[e.jsxs(ue,{className:"group/more text-muted-foreground hover:text-foreground focus-ring flex w-full items-center justify-between rounded-md py-1 text-sm font-semibold",children:["More",e.jsx(X,{className:"size-4 transition-transform group-data-[state=open]/more:rotate-90","aria-hidden":!0})]}),e.jsxs(he,{className:"-mx-2 space-y-1 pt-2","data-testid":"app-panel-more",children:[e.jsx(M,{label:"Settings",hint:"Who can message it, group chats, and its token",onClick:()=>u("edit")}),t.enabled?e.jsx(M,{label:"Pause",hint:"No messages in or out until you resume",disabled:i.isPending,onClick:()=>l(!1)}):e.jsx(M,{label:"Resume",disabled:i.isPending,onClick:()=>l(!0)}),a.multiInstance&&e.jsx(M,{label:`Set up another ${a.displayName}`,onClick:()=>u("add")}),e.jsx(M,{label:"Remove…",destructive:!0,onClick:()=>d(!0)})]})]}),o&&e.jsx(Wn,{open:!0,onOpenChange:m=>{m||u(null)},manifest:a,existingInstance:o==="edit"?t:void 0,existingAdapterIds:n.instances.map(m=>m.id)}),e.jsx(xe,{open:h,onOpenChange:d,children:e.jsxs(fe,{children:[e.jsxs(je,{children:[e.jsxs(ye,{children:["Remove ",a.displayName,"?"]}),e.jsx(ve,{asChild:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:"It stops working and its settings are deleted."}),e.jsx("p",{children:"So are its recent deliveries."}),e.jsx("p",{children:"Its list of people who messaged it is deleted, names included."}),e.jsx("p",{children:"That includes anyone ignored or blocked."}),e.jsx("p",{children:"Messages sent to it after that reach nobody."}),e.jsx("p",{children:"If you set it up again, block anyone you blocked again."})]})})]}),e.jsxs(be,{children:[e.jsx(Ne,{children:"Keep it"}),e.jsxs(ke,{className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",onClick:()=>{c.mutate(t.id,{onSuccess:()=>{r.invalidateQueries({queryKey:[...na]}),s()}})},children:["Remove ",a.displayName]})]})]})})]})}function Ki(){var r;const n=vn(),t=bn(n.enabled),[s,a]=j.useState(null),i=j.useCallback(o=>{var h;const u=n.enabled?(h=t.data)==null?void 0:h.find(d=>d.manifest.type===o):void 0;if(u&&(u.instances.length===0||u.manifest.multiInstance)){a(u.manifest);return}D.error("Chat apps aren’t ready. Try again in a moment.")},[t.data,n.enabled]),c=s?e.jsx(Wn,{open:!0,onOpenChange:o=>{o||a(null)},manifest:s,existingAdapterIds:(r=t.data)==null?void 0:r.flatMap(o=>o.instances.map(u=>u.id))}):null;return{open:i,dialog:c}}function Yi(){var He,Ge,Qe,Ve,Je;const n=ps({from:"/_shell/connections"}),t=Ue({from:"/connections"}),s=j.useCallback(v=>void t({search:q=>{const Q={...q,...v};for(const Xe of Object.keys(v))Q[Xe]===void 0&&delete Q[Xe];return Q}}),[t]),[a,i]=j.useState(""),c=j.useDeferredValue(a),[r,o]=j.useState(null),[u,h]=j.useState(!!n.flow),[d,f]=j.useState(null),[l,m]=j.useState(null),x=Ki(),y=j.useRef(null),N=v=>gn(v,y),k=j.useRef(null),A=v=>gn(v,k),p=n.request?null:n.flow??null,g=$n(p),C=(He=g.data)==null?void 0:He.state,$=(Ge=g.data)==null?void 0:Ge.toolkit,Y=j.useMemo(()=>!u&&p&&$&&(C==="starting"||C==="pending")?{flowId:p,toolkit:$}:null,[u,p,C,$]),S=$a(c,Y),{relay:R}=S;Ra(R.enabled);const w=Rn(),E=ze(),z=Fn(),U=Me(),I=w.error??E.error,L=w.isPending&&((Qe=w.variables)==null?void 0:Qe.connectionId)||E.isPending&&((Ve=E.variables)==null?void 0:Ve.connectionId)||z.isPending&&((Je=z.variables)==null?void 0:Je.id)||null,O=v=>{o(null),s({flow:v,app:void 0}),h(!0)},F=v=>{o(v),h(!0)},re=v=>{const q=Hn(v,S.owned),Q=R.enabled?q.chatType:null;if(q.account&&Q){m(v);return}if(Q){x.open(Q);return}F(v)},ce=v=>{switch(v.action){case"sign-in-again":w.mutate({connectionId:v.id},{onSuccess:q=>O(q.flowId)});return;case"resume":v.kind==="chat"?z.mutate({id:v.id,enabled:!0}):E.mutate({connectionId:v.id,input:void 0});return;case"cancel":s({flow:void 0});return;case"review":f(v.id);return;case"fix":s({app:v.id});return;case"fix-key":U.open("connections","ways");return;case"connect-again":{const q=v.toolkit?S.services.get(v.toolkit):void 0;q?F(q):s({app:v.id});return}case null:return}},_=n.app?S.allYours.find(v=>v.id===n.app&&v.kind!=="connecting")??null:null,T=(_==null?void 0:_.kind)==="chat"?Hi(S.chatApps,_.id):null;j.useEffect(()=>{n.app&&!S.yoursLoading&&!S.yoursRefreshing&&!S.yoursError&&!_&&s({app:void 0})},[n.app,S.yoursLoading,S.yoursRefreshing,S.yoursError,_,s]);const H=()=>s({app:void 0});return e.jsxs(js,{width:"reading",children:[e.jsxs("header",{className:"mb-6",children:[e.jsx(xs,{children:"Connections"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Apps your agents use, and where you reach them."})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsx(ci,{services:S.services,onOpenRequest:v=>{y.current=document.activeElement,s({request:v})},onOpenReview:v=>{y.current=document.activeElement,s({review:v})}}),I&&e.jsx("p",{role:"alert","data-testid":"row-action-error",className:"text-destructive bg-destructive/5 rounded-lg p-3 text-sm",children:Xn(I)}),e.jsx(wa,{query:a,onQueryChange:i,data:S,onOpenRow:v=>{if(v.kind==="connecting"){h(!0);return}k.current=document.activeElement,s({app:v.id})},onRowAction:ce,pendingRowId:L,onConnect:re}),e.jsx(Qi,{})]}),e.jsxs(Bi,{row:_,open:_!==null,onOpenChange:v=>{v||H()},onCloseAutoFocus:A,children:[(_==null?void 0:_.kind)==="account"&&e.jsx(Ja,{connectionId:_.id,onSignInStarted:O,onEditExactActions:f,onAddAnother:v=>{H(),F(S.services.get(v)??Gi(v,_.name))},onClose:H},_.id),(_==null?void 0:_.kind)==="chat"&&T&&e.jsx(Wi,{entry:T.entry,instance:T.instance,onClose:H},_.id)]}),u&&e.jsx(bi,{service:r,flowId:n.flow??null,onFlowIdChange:v=>s({flow:v??void 0}),onClose:()=>{h(!1),o(null)},onChooseAccess:f,onConnected:v=>s({app:v})},n.flow??(r==null?void 0:r.serviceSlug)??"idle"),e.jsx(di,{requestId:n.request??null,open:!!n.request&&!u,onOpenChange:v=>{v||s({request:void 0})},onEditExactActions:v=>{s({request:void 0}),f(v)},onCloseAutoFocus:N}),e.jsx(mi,{reviewRequestId:n.review??null,open:!!n.review,onOpenChange:v=>{v||s({review:void 0})},onCloseAutoFocus:N},n.review??"closed"),e.jsx(Si,{connectionId:d,open:d!==null,onOpenChange:v=>{v||f(null)}},d??"closed"),e.jsx(Ui,{service:l,onClose:()=>m(null),onChooseChat:v=>{m(null);const q=Ye(v).chatType;q&&x.open(q)},onChooseAccount:v=>{m(null),F(v)}}),x.dialog]})}function gn(n,t){n.preventDefault();const s=t.current;t.current=null,s!=null&&s.isConnected?s.focus():fs()}function Hi(n,t){for(const s of n){const a=s.instances.find(i=>i.id===t);if(a)return{entry:s,instance:a}}return null}function Gi(n,t){return{serviceSlug:n,displayName:t,iconKey:n,intents:[{kind:"account",displayName:`Use a ${t} account`,routes:[]}]}}function Qi(){const n=Me();return e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Prefer your own Composio or Nango account?"," ",e.jsx(b,{variant:"link",className:"h-auto p-0 text-xs",onClick:()=>n.open("connections","ways"),children:"Set it up in Settings › Connections"})]})}const ao=Yi;export{ao as component};
@@ -1 +0,0 @@
1
- import{j as t}from"./index-DMYBI16t.js";import{M as o}from"./Marketplace-DsU-q1ZZ.js";import{P as r}from"./page-container-W7byjRmk.js";import"./PreviewRefusedNotice-ChCgdKWN.js";import"./shield-x-DxOGc0dW.js";import"./use-unclaimed-chats-lqMhotUB.js";import"./UnlinkDialog-3p38G_9q.js";import"./use-dev-links-Df2WkCic.js";import"./file-exclamation-point-BKzL0QhY.js";import"./rotate-ccw-clock-CNcDcTvq.js";function i(){return t.jsx(r,{width:"wide",children:t.jsx(o,{})})}const l=i;export{l as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-DMYBI16t.js";import{P as r}from"./page-container-W7byjRmk.js";import{M as e}from"./MarketplaceSourcesView-D72YoKNR.js";import"./use-pending-read-BuJknrxG.js";function t(){return o.jsx(r,{width:"reading",children:o.jsx(e,{})})}const s=t;export{s as component};