dorkos 0.124.0 → 0.124.1

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 (311) hide show
  1. package/dist/bin/cli.js +935 -551
  2. package/dist/browser/native/package-manifest.json +1 -1
  3. package/dist/browser/source-manifest.json +1 -1
  4. package/dist/client/assets/{AboutPage-BH8Ndn3e.js → AboutPage-DHaZvsJE.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-K5Mew9EX.js → ActivityErrorState-BP-qFk2S.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-BB20L5HU.js → ActivityPage-Bme3TzdQ.js} +1 -1
  7. package/dist/client/assets/{ActivityRow-C5O7rnmS.js → ActivityRow-BRZyW9MA.js} +1 -1
  8. package/dist/client/assets/{AdapterIcon-Bmybvrzb.js → AdapterIcon-BcfquTja.js} +1 -1
  9. package/dist/client/assets/{AdapterSetupWizard-CkdV7Hhh.js → AdapterSetupWizard-B4I23pBg.js} +1 -1
  10. package/dist/client/assets/{AgentOptionRow-BA2cDa7r.js → AgentOptionRow-Cb34LtmH.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-CsIIPGZJ.js → AgentPicker-ouNRFSDh.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-0fOxvaoe.js → AgentRequestCard-B6MHIsxa.js} +2 -2
  13. package/dist/client/assets/{AppearancePage-XOjkkoli.js → AppearancePage-CutehigK.js} +1 -1
  14. package/dist/client/assets/ApplyToOverridesDialog-B-wIUI27.js +1 -0
  15. package/dist/client/assets/{AttentionSignalRow-CjjZobp7.js → AttentionSignalRow-B1aMjgX_.js} +1 -1
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-9TVHyRPJ.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-CdWF4WLz.js} +1 -1
  17. package/dist/client/assets/{BindingDialog-DLoAQauL.js → BindingDialog-BAdueON5.js} +1 -1
  18. package/dist/client/assets/{BlintzCanvas-CYHsXAcY.js → BlintzCanvas-b30dG4gx.js} +3 -3
  19. package/dist/client/assets/{CanvasCsvContent--Gr7Fe_U.js → CanvasCsvContent-DGHgSikG.js} +1 -1
  20. package/dist/client/assets/{CanvasFileContent-estXyAbr.js → CanvasFileContent-D1bFaUeh.js} +2 -2
  21. package/dist/client/assets/{CanvasModel3dContent-CkOo930M.js → CanvasModel3dContent-dST7g1v2.js} +2 -2
  22. package/dist/client/assets/{ChatAppsOff-D4L1zJVN.js → ChatAppsOff-DiObvmJS.js} +1 -1
  23. package/dist/client/assets/{CodeMirrorDiff-DY_6ju-z.js → CodeMirrorDiff-BncI1OY1.js} +1 -1
  24. package/dist/client/assets/{CodeMirrorEditor-BUoDBsBv.js → CodeMirrorEditor-DV6psv19.js} +1 -1
  25. package/dist/client/assets/{CommitmentList-wDkcVP9c.js → CommitmentList-Dx_Ek_Gl.js} +1 -1
  26. package/dist/client/assets/{CommitmentsPage-CzSM6b8R.js → CommitmentsPage-Bca8NMUa.js} +1 -1
  27. package/dist/client/assets/{ComputerResourceView-cERD9H2L.js → ComputerResourceView-DNVNFTdn.js} +1 -1
  28. package/dist/client/assets/{ComputerViewer-rMcfbk2_.js → ComputerViewer-D8SxJdMm.js} +1 -1
  29. package/dist/client/assets/{ConnectionAccessLists-f7QeQbQo.js → ConnectionAccessLists-Bhj1YT15.js} +1 -1
  30. package/dist/client/assets/{ConnectionsPage-BmjtA6pw.js → ConnectionsPage-B20JZxoK.js} +1 -1
  31. package/dist/client/assets/{ConventionPage-CH-ah6nI.js → ConventionPage-De645wxU.js} +1 -1
  32. package/dist/client/assets/{ExtensionPageRoute-CJIxa6ST.js → ExtensionPageRoute-nTeiOBRQ.js} +1 -1
  33. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-BP7EJ2JL.js → FloatingTanStackRouterDevtools-CqogiFob-DM79UITv.js} +1 -1
  34. package/dist/client/assets/HandlePage-B08V-om7.js +1 -0
  35. package/dist/client/assets/{HeartbeatPage-BUsf-qrU.js → HeartbeatPage-CBoUxz6t.js} +1 -1
  36. package/dist/client/assets/{KeyEntry-C2kWdN8q.js → KeyEntry-Cug8ocpX.js} +1 -1
  37. package/dist/client/assets/{LexicalField-CR8ulsI_.js → LexicalField-Bv_ogmAq.js} +1 -1
  38. package/dist/client/assets/{ManagesPage-DTtsIOGi.js → ManagesPage-DfJBQKK3.js} +1 -1
  39. package/dist/client/assets/{Marketplace-iaV5XAzv.js → Marketplace-swCVUbdY.js} +2 -2
  40. package/dist/client/assets/{MarketplaceSourcesView-6tgzUfFj.js → MarketplaceSourcesView-CDZDChpV.js} +1 -1
  41. package/dist/client/assets/{McpAppFrame-C7eYYdI9.js → McpAppFrame-BM9cNPPd.js} +1 -1
  42. package/dist/client/assets/{McpSigninBody-BDyGbJ7I.js → McpSigninBody-DKyUKrEE.js} +1 -1
  43. package/dist/client/assets/{Model3dViewer-BujDNuVS.js → Model3dViewer-rXSL5y2P.js} +1 -1
  44. package/dist/client/assets/NamePage-JwMDK1JD.js +1 -0
  45. package/dist/client/assets/{NewDirectMessageMenu-D4e-z2Jt.js → NewDirectMessageMenu-GCEMS5oV.js} +1 -1
  46. package/dist/client/assets/{NotificationsPage-CkDeTaJp.js → NotificationsPage-DSWsOVLa.js} +1 -1
  47. package/dist/client/assets/{OpenMeshSwitch-CtbOt3r5.js → OpenMeshSwitch-BTuctDj4.js} +1 -1
  48. package/dist/client/assets/{OperatorIdentityForm-Vr4qZnmM.js → OperatorIdentityForm-ODDMd2YN.js} +1 -1
  49. package/dist/client/assets/PermissionHistory-41a58Se7.js +1 -0
  50. package/dist/client/assets/{PermissionsPage-f4QaX8oM.js → PermissionsPage-DefmymZ6.js} +1 -1
  51. package/dist/client/assets/{PersonalityPopover-BkZruwF-.js → PersonalityPopover-7zPVBI1I.js} +1 -1
  52. package/dist/client/assets/PhotoPage-DlOVhkW9.js +1 -0
  53. package/dist/client/assets/{PreviewRefusedNotice-BXC2K0tx.js → PreviewRefusedNotice-CwGlBJ7U.js} +1 -1
  54. package/dist/client/assets/{ProfileFields-BebX5oiv.js → ProfileFields-DVMkpJSb.js} +1 -1
  55. package/dist/client/assets/{ProfilePanelContainer-DZoL65zQ.js → ProfilePanelContainer-RrhoPD3T.js} +1 -1
  56. package/dist/client/assets/{ProfileRolePicker-D9H7wsuT.js → ProfileRolePicker-CXRVBCAu.js} +1 -1
  57. package/dist/client/assets/{PromptSuggestionChips-B5fDmc-g.js → PromptSuggestionChips-bBroJdTi.js} +1 -1
  58. package/dist/client/assets/{ReportsToPopover-uVYhSqj7.js → ReportsToPopover-CfPatsWM.js} +1 -1
  59. package/dist/client/assets/{RoomSurface-Bg5WV4Ep.js → RoomSurface-CdgCdV6h.js} +11 -11
  60. package/dist/client/assets/{RoomsPage-yflYFulU.js → RoomsPage-C3dDp1Mb.js} +1 -1
  61. package/dist/client/assets/{RunsOnPopover-DtGrX1Vq.js → RunsOnPopover-BcKjfQi-.js} +1 -1
  62. package/dist/client/assets/{RuntimeConnectFlow-DjReuQ-T.js → RuntimeConnectFlow-DCIRnvOH.js} +1 -1
  63. package/dist/client/assets/{RuntimeSetupDialog-Cr4GRi8c.js → RuntimeSetupDialog-Bg-0b-LC.js} +1 -1
  64. package/dist/client/assets/SeenDevices-nMsGUQTv.js +19 -0
  65. package/dist/client/assets/{SessionsPage-BWu-en78.js → SessionsPage-Cqfx4FGW.js} +1 -1
  66. package/dist/client/assets/SettingsDialog-C8r2igJ_.js +12 -0
  67. package/dist/client/assets/{SkillsPage-BdUb9SZy.js → SkillsPage-BleHQavF.js} +1 -1
  68. package/dist/client/assets/{TaskDialogWrapper-qYJPEoSR.js → TaskDialogWrapper-BhTEvf-u.js} +1 -1
  69. package/dist/client/assets/{TasksEmptyState-Bgcg9vxF.js → TasksEmptyState-Bprx1k8M.js} +2 -2
  70. package/dist/client/assets/{TasksPage-Ch5W2WQS.js → TasksPage-Dub39yEJ.js} +1 -1
  71. package/dist/client/assets/{TeamComputerEntry-CPwSIMRw.js → TeamComputerEntry-CJ-NG0u5.js} +1 -1
  72. package/dist/client/assets/ToolsPage-IsD6M-ZW.js +2 -0
  73. package/dist/client/assets/{TopologyGraph-I4_mkMHM.js → TopologyGraph-CwyasvFI.js} +14 -14
  74. package/dist/client/assets/{TourHost-BPaSwh9I.js → TourHost-BYfztuPb.js} +1 -1
  75. package/dist/client/assets/{UnlinkDialog-BUWZUu5P.js → UnlinkDialog-BKhgxVdF.js} +1 -1
  76. package/dist/client/assets/{WidgetErrorCard-cS8yMCxU.js → WidgetErrorCard-1NyzIJBj.js} +6 -6
  77. package/dist/client/assets/_shell-Ct2Bz7D0.js +80 -0
  78. package/dist/client/assets/{_shell._home-DCA5k-jb.js → _shell._home-xWj7wO5z.js} +1 -1
  79. package/dist/client/assets/{_shell._home.activity-BX4nFLna.js → _shell._home.activity-BqcLoaB1.js} +1 -1
  80. package/dist/client/assets/{_shell._home.index-C8t8cw72.js → _shell._home.index-D4sQsKKk.js} +1 -1
  81. package/dist/client/assets/{_shell._home.tasks-BgUeEvhK.js → _shell._home.tasks--UhQB6h3.js} +1 -1
  82. package/dist/client/assets/{_shell._home.workspaces-BPBdnkRt.js → _shell._home.workspaces-BPFD8Of2.js} +1 -1
  83. package/dist/client/assets/{_shell.channels-CX4kki7G.js → _shell.channels-CnFdvRzc.js} +4 -4
  84. package/dist/client/assets/{_shell.connections-0vP7g7E4.js → _shell.connections-Ik01wS5M.js} +1 -1
  85. package/dist/client/assets/{_shell.feedback-requests-TsuaO4eR.js → _shell.feedback-requests-Czu42kzo.js} +1 -1
  86. package/dist/client/assets/_shell.marketplace-Cezv-i16.js +1 -0
  87. package/dist/client/assets/_shell.marketplace_.sources-BTENmr4W.js +1 -0
  88. package/dist/client/assets/_shell.session-BjevHF_O.js +63 -0
  89. package/dist/client/assets/{_shell.team-Bm6cOBhR.js → _shell.team-UfaJqohh.js} +3 -3
  90. package/dist/client/assets/_shell.x._extensionId-0OO_Xr72.js +1 -0
  91. package/dist/client/assets/_shell.x._extensionId_._-0OO_Xr72.js +1 -0
  92. package/dist/client/assets/{abnfDiagram-WEYOIA3C-CrvoN15x.js → abnfDiagram-WEYOIA3C-oxkfGyl6.js} +1 -1
  93. package/dist/client/assets/{access-copy-B3yNZ7Gz.js → access-copy-Dggxx2cX.js} +1 -1
  94. package/dist/client/assets/{arc-CuT6QA_y.js → arc-CqQdP0Qe.js} +1 -1
  95. package/dist/client/assets/{architectureDiagram-ZHVYKT53-CPXCZ9H4.js → architectureDiagram-ZHVYKT53-89xM7zJD.js} +1 -1
  96. package/dist/client/assets/{banner-DRumuw3F.js → banner-DqJ2pM0Y.js} +1 -1
  97. package/dist/client/assets/{blockDiagram-RJAE7QA3-CM0rka9p.js → blockDiagram-RJAE7QA3-CcxwDmZC.js} +1 -1
  98. package/dist/client/assets/{c4Diagram-XDPPPE54-D4j2cXRy.js → c4Diagram-XDPPPE54-DCIhIyXa.js} +1 -1
  99. package/dist/client/assets/{card-B3CtfC3R.js → card-DT-vFAns.js} +1 -1
  100. package/dist/client/assets/channel-Ngk70nQZ.js +1 -0
  101. package/dist/client/assets/{chunk-2E7WHVMD-KGyqhVpO.js → chunk-2E7WHVMD-BfWEXcCj.js} +1 -1
  102. package/dist/client/assets/{chunk-2Q5K7J3B-Dl0BHoqK.js → chunk-2Q5K7J3B-KLXLZXlR.js} +1 -1
  103. package/dist/client/assets/{chunk-4EMNKR2T-Da7vH6Kv.js → chunk-4EMNKR2T-CL5Gttmj.js} +1 -1
  104. package/dist/client/assets/{chunk-55XCU76K-DgBUEROO.js → chunk-55XCU76K-cfAl84Mv.js} +1 -1
  105. package/dist/client/assets/{chunk-5VM5RSS4-BQ4mn-_I.js → chunk-5VM5RSS4-BqUyGgoH.js} +1 -1
  106. package/dist/client/assets/{chunk-JWPE2WC7-8LPR3mXf.js → chunk-JWPE2WC7-BWr2ST9i.js} +1 -1
  107. package/dist/client/assets/{chunk-VQ5W62QI-BkIVXi4W.js → chunk-VQ5W62QI-V5zYx50O.js} +1 -1
  108. package/dist/client/assets/{chunk-XXDRQBXY-DQXJx06h.js → chunk-XXDRQBXY-gnvheN_J.js} +1 -1
  109. package/dist/client/assets/{chunk-ZCHMQSOR-DzCE7qlD.js → chunk-ZCHMQSOR-ClGxxZvV.js} +2 -2
  110. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-C_cZra7c.js → classDiagram-v2-4MYWR3UA-DvmHzDb5.js} +1 -1
  111. package/dist/client/assets/{command-CDKbyppr.js → command-CNx4L11m.js} +1 -1
  112. package/dist/client/assets/{cose-bilkent-JH36ORCC-DlXHdGwT.js → cose-bilkent-JH36ORCC-Df8nXBRj.js} +1 -1
  113. package/dist/client/assets/{cpu-B7xLO7jn.js → cpu-D8KJEkdh.js} +1 -1
  114. package/dist/client/assets/{cynefin-EF2NZ3EQ-HhP4ArLc.js → cynefin-EF2NZ3EQ-CAn6ufHs.js} +1 -1
  115. package/dist/client/assets/{cynefinDiagram-WF24UDRP-D4GgWnZV.js → cynefinDiagram-WF24UDRP-Cep_NrRw.js} +1 -1
  116. package/dist/client/assets/{dagre-NK4GIZVX-SZ_OI2Zi.js → dagre-NK4GIZVX-sWD3z9wf.js} +1 -1
  117. package/dist/client/assets/{diagram-CBK3MWTC-BN-_Ja5m.js → diagram-CBK3MWTC-CUpaBATr.js} +1 -1
  118. package/dist/client/assets/{diagram-I5XIIV2D-t7AK6xnL.js → diagram-I5XIIV2D-BejWB2ry.js} +1 -1
  119. package/dist/client/assets/{diagram-ODIL2UCW-C1V7szSc.js → diagram-ODIL2UCW-BGKJfNk9.js} +1 -1
  120. package/dist/client/assets/{diagram-PFBEJUXE-DPtraQ2g.js → diagram-PFBEJUXE-V0dP8H8k.js} +1 -1
  121. package/dist/client/assets/{diagram-RJA3I4VV-D2XNRB2b.js → diagram-RJA3I4VV-Bf5dVsFX.js} +1 -1
  122. package/dist/client/assets/{diagram-TYUNFSNR-BieaRy38.js → diagram-TYUNFSNR-CLrMSqb4.js} +1 -1
  123. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-Bwki86UY.js → ebnfDiagram-V4P3TTPT-BGG4CWA0.js} +1 -1
  124. package/dist/client/assets/{elk-QONTBCTQ-WEXSAyHB.js → elk-QONTBCTQ-bf9D6f0w.js} +1 -1
  125. package/dist/client/assets/{empty-state-J-UJ0BUU.js → empty-state-CDoXnrKn.js} +1 -1
  126. package/dist/client/assets/{erDiagram-KYQIGQAA-DIKASnoc.js → erDiagram-KYQIGQAA-fEUv-33P.js} +1 -1
  127. package/dist/client/assets/{execution-config-ILQiJAmy.js → execution-config-Ca9MDOtV.js} +1 -1
  128. package/dist/client/assets/{file-D40js1Zx.js → file-CiyVL55_.js} +1 -1
  129. package/dist/client/assets/{file-exclamation-point-Dg3ZpiAe.js → file-exclamation-point-DaFRIKco.js} +1 -1
  130. package/dist/client/assets/{file-text-DgdvRfMk.js → file-text-DsnD-A8g.js} +1 -1
  131. package/dist/client/assets/{find-latest-widget-fence-D4kBWC_1.js → find-latest-widget-fence-CNsnCgbB.js} +1 -1
  132. package/dist/client/assets/{flowDiagram-IUGLLWBU-CoavNw0M.js → flowDiagram-IUGLLWBU-CRbeSDod.js} +1 -1
  133. package/dist/client/assets/{form-DlPwEgQH.js → form-Cru78aT-.js} +1 -1
  134. package/dist/client/assets/{format-cron-BrK8RzgT.js → format-cron-9K38-tn1.js} +1 -1
  135. package/dist/client/assets/{ganttDiagram-R7GPNTJY-DccKAz7f.js → ganttDiagram-R7GPNTJY-Mkk7zgs_.js} +1 -1
  136. package/dist/client/assets/{git-branch-BpxhecMq.js → git-branch-CONwEYiR.js} +1 -1
  137. package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-DEbo_dgQ.js → gitGraphDiagram-PDYL7XHY-Drre0vyA.js} +1 -1
  138. package/dist/client/assets/{graph-DROgI3M3.js → graph-BJlnKWgo.js} +1 -1
  139. package/dist/client/assets/{heart-c7u4Ezxt.js → heart-CqwUlIUG.js} +1 -1
  140. package/dist/client/assets/{highlighted-body-KPVGNVTW-CrATNdTR.js → highlighted-body-KPVGNVTW-e4LXC_pS.js} +1 -1
  141. package/dist/client/assets/{image-lightbox-DE_fHkw-.js → image-lightbox-DHDtzoja.js} +1 -1
  142. package/dist/client/assets/{image-off-BExgZjfM.js → image-off-DZuLkaRJ.js} +1 -1
  143. package/dist/client/assets/{index-D0eJtRlK.js → index-1yEXEZiH.js} +1 -1
  144. package/dist/client/assets/{index-Be0OJLWK.js → index-A41zxoWk.js} +1 -1
  145. package/dist/client/assets/{index-DeRDq7bD.js → index-B25gvCK_.js} +1 -1
  146. package/dist/client/assets/index-B9bZYNKR.js +1 -0
  147. package/dist/client/assets/{index-DaZ1I8s-.js → index-BBmkfbXd.js} +1 -1
  148. package/dist/client/assets/{index-DNGNMW3c.js → index-BDD2EyoW.js} +1 -1
  149. package/dist/client/assets/{index-Ccf1XBTs.js → index-BFNy-Yp3.js} +1 -1
  150. package/dist/client/assets/{index-DksjixUS.js → index-BIB-maE5.js} +1 -1
  151. package/dist/client/assets/{index-CbHCZsbE.js → index-BKp2B9JS.js} +1 -1
  152. package/dist/client/assets/{index-DCJQGDZk.js → index-BLP5O7X9.js} +1 -1
  153. package/dist/client/assets/{index-DhHobJd3.js → index-BTjZIgFn.js} +1 -1
  154. package/dist/client/assets/{index-BVqSmajJ.js → index-BV2Ezdxv.js} +1 -1
  155. package/dist/client/assets/{index-C7B3eSOP.js → index-B_0LYi32.js} +1 -1
  156. package/dist/client/assets/{index-DDgOoXP1.js → index-Bd7vUYhr.js} +1 -1
  157. package/dist/client/assets/{index-BlyoyIck.js → index-Bo7x9IkO.js} +1 -1
  158. package/dist/client/assets/{index-D150FXCC.js → index-BtDxwJsM.js} +1 -1
  159. package/dist/client/assets/{index-DswGXheF.js → index-By58MgcZ.js} +1 -1
  160. package/dist/client/assets/index-C3cvP8Fo.js +1033 -0
  161. package/dist/client/assets/{index-C5or4L_3.js → index-CVuEUzi5.js} +1 -1
  162. package/dist/client/assets/{index-BkoMsjtM.js → index-CoWJD3Jg.js} +2 -2
  163. package/dist/client/assets/{index-CqPRAM_6.js → index-CyVH876g.js} +1 -1
  164. package/dist/client/assets/{index-BGqvci3k.js → index-D67Kfy-M.js} +1 -1
  165. package/dist/client/assets/{index-D3YeRrne.js → index-DAlpmAIA.js} +1 -1
  166. package/dist/client/assets/{index-BEkYBuOq.js → index-DDNwNOHF.js} +1 -1
  167. package/dist/client/assets/{index-CD8aw6Jb.js → index-DL8ISRMH.js} +1 -1
  168. package/dist/client/assets/{index-AzyLwYS_.js → index-DabU6r9W.js} +3 -3
  169. package/dist/client/assets/{index-CT_pFeX_.js → index-DdJBZE0H.js} +1 -1
  170. package/dist/client/assets/{index-B3eeEDWj.js → index-DijWcSDZ.js} +1 -1
  171. package/dist/client/assets/index-DyRGZyur.css +1 -0
  172. package/dist/client/assets/{index-DINk1YfD.js → index-DzwZJuO1.js} +1 -1
  173. package/dist/client/assets/{index-CZmqtJWZ.js → index-HR8BYVRQ.js} +1 -1
  174. package/dist/client/assets/{index-J3Hh1MnL.js → index-LEcodwyW.js} +1 -1
  175. package/dist/client/assets/index-UPF8suf2.js +1 -0
  176. package/dist/client/assets/{index-DT7pv2iW.js → index-Vz7VUm9l.js} +1 -1
  177. package/dist/client/assets/index-YW-v746p.js +1 -0
  178. package/dist/client/assets/{index-2wezsLA_.js → index-cI2u8WZS.js} +1 -1
  179. package/dist/client/assets/{index-InEBtYxw.js → index-iTQUa_b2.js} +6 -6
  180. package/dist/client/assets/{index-CYy1cjtq.js → index-mZqojApH.js} +1 -1
  181. package/dist/client/assets/{index-dyAahqKe.js → index-pVFjKNjX.js} +1 -1
  182. package/dist/client/assets/{index-DxiRRZRo.js → index-skAhJyIF.js} +1 -1
  183. package/dist/client/assets/{index-BizvylBV.js → index-vJy88bwb.js} +1 -1
  184. package/dist/client/assets/index-wY5OcS4a.js +43 -0
  185. package/dist/client/assets/{index-mwf7ZNk2.js → index-x1yAu9zJ.js} +1 -1
  186. package/dist/client/assets/{index-F-vqXYqa.js → index-xAgihCJ7.js} +1 -1
  187. package/dist/client/assets/{index.esm-BFJ9SG0n.js → index.esm-BUPoRUaG.js} +1 -1
  188. package/dist/client/assets/{infoDiagram-MVDRKAX5-VL8q5pKx.js → infoDiagram-MVDRKAX5-B_Wyzufh.js} +1 -1
  189. package/dist/client/assets/{inline-code-BE9ckzPs.js → inline-code-BIzGDx6z.js} +1 -1
  190. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-BLKkPYF-.js → ishikawaDiagram-HPEHV2GE-BDk2-6Pd.js} +1 -1
  191. package/dist/client/assets/{journeyDiagram-BOSHW7O7-CSYpRobu.js → journeyDiagram-BOSHW7O7-7qf9KWEQ.js} +1 -1
  192. package/dist/client/assets/{kanban-definition-FNSA4HC5-HilAqtZo.js → kanban-definition-FNSA4HC5-CFYDQmXn.js} +1 -1
  193. package/dist/client/assets/{layers-Cm7coqdo.js → layers-C9tVVcXg.js} +1 -1
  194. package/dist/client/assets/{lightbulb-DqdWS75d.js → lightbulb-f4jtsAh0.js} +1 -1
  195. package/dist/client/assets/{link-2-CDJapTSa.js → link-2-ZNlK1BG1.js} +1 -1
  196. package/dist/client/assets/{list-runtime-types-CP82p1u4.js → list-runtime-types-CqO-QFYD.js} +1 -1
  197. package/dist/client/assets/{markdown-content-m_qereFc.js → markdown-content-DaEVxezf.js} +1 -1
  198. package/dist/client/assets/{mention-pill-DV5HIG5Q.js → mention-pill-BiCPflY-.js} +1 -1
  199. package/dist/client/assets/{mermaid.core-zxW6MBr-.js → mermaid.core-SX8SzrsU.js} +4 -4
  200. package/dist/client/assets/{message-square-off-YVtpbaJ0.js → message-square-off-_qbedNGF.js} +1 -1
  201. package/dist/client/assets/{mindmap-definition-6OY57UG3-IAYemvOg.js → mindmap-definition-6OY57UG3-BloJIArH.js} +1 -1
  202. package/dist/client/assets/{more-details-ReA2ZFBn.js → more-details-CdJT0Ehl.js} +1 -1
  203. package/dist/client/assets/{owner-notice-M4hn_1ep.js → owner-notice-BDafFD_I.js} +1 -1
  204. package/dist/client/assets/{package-CUuTl39E.js → package-Cb7lEm7t.js} +1 -1
  205. package/dist/client/assets/{page-container-BnmNikNZ.js → page-container-DsRgIMAL.js} +1 -1
  206. package/dist/client/assets/{paperclip-C6fYq5Zf.js → paperclip-DNu1VtoX.js} +1 -1
  207. package/dist/client/assets/{path-input-DHn9-XaE.js → path-input-D3O71b-X.js} +1 -1
  208. package/dist/client/assets/{pegDiagram-ECIUJNBX-CojaUwe7.js → pegDiagram-ECIUJNBX-Di48kPNu.js} +1 -1
  209. package/dist/client/assets/{pieDiagram-GNMPY74T-CjP3pw6V.js → pieDiagram-GNMPY74T-DY8B_SPD.js} +1 -1
  210. package/dist/client/assets/{plug-DHQcxt7N.js → plug-IIS_cL9-.js} +1 -1
  211. package/dist/client/assets/{primer-trigger-BmV5wjek.js → primer-trigger-DurKYe8C.js} +2 -2
  212. package/dist/client/assets/{profile-errors-BSCuj3rT.js → profile-errors-BdhZfdvZ.js} +1 -1
  213. package/dist/client/assets/{progress-4FQQfnS6.js → progress-g5kkqvlR.js} +1 -1
  214. package/dist/client/assets/{quadrantDiagram-D57K4MC3-OP0Z8zcR.js → quadrantDiagram-D57K4MC3-Depv_dON.js} +1 -1
  215. package/dist/client/assets/{query-error-state-BkUdxenP.js → query-error-state-PuLGD7Jp.js} +1 -1
  216. package/dist/client/assets/{radio-ta5Bw763.js → radio-QOLZSBz1.js} +1 -1
  217. package/dist/client/assets/{railroadDiagram-Y72NRBL7-CT3NCb9b.js → railroadDiagram-Y72NRBL7-BfD2AiZM.js} +1 -1
  218. package/dist/client/assets/registry-Ck8p6n1T.js +1 -0
  219. package/dist/client/assets/{relay-trace-schemas-DwUuyxao.js → relay-trace-schemas-DF_DfZ7s.js} +1 -1
  220. package/dist/client/assets/{requirementDiagram-EQYSW5RA-tde4lYGp.js → requirementDiagram-EQYSW5RA-B1iTjrkD.js} +1 -1
  221. package/dist/client/assets/{room-files-source-CZWhaaOy.js → room-files-source-g1th8mWs.js} +2 -2
  222. package/dist/client/assets/{rotate-ccw-clock-RfbbgUa4.js → rotate-ccw-clock-BGwYMaGL.js} +1 -1
  223. package/dist/client/assets/{rotate-cw-B3rB_YSw.js → rotate-cw-B4Y0q4GY.js} +1 -1
  224. package/dist/client/assets/{sankeyDiagram-SY24JHO5-sdCzIA7-.js → sankeyDiagram-SY24JHO5-D5TzVJrQ.js} +1 -1
  225. package/dist/client/assets/{scroll-area-B4WB7Q40.js → scroll-area-BvScZKSa.js} +1 -1
  226. package/dist/client/assets/{search-x-DCUmWW2_.js → search-x-CqN5twBj.js} +1 -1
  227. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-DvzTJcKu.js → sequenceDiagram-BLEHNHQU-BhUahaNf.js} +1 -1
  228. package/dist/client/assets/{shield-x-CANziVLc.js → shield-x-DHJrwtKp.js} +1 -1
  229. package/dist/client/assets/signed-in-BmywDpR5.js +1 -0
  230. package/dist/client/assets/{sizeCapture-INFHLROL-DuDA7TKE.js → sizeCapture-INFHLROL-D2Vi1Kq9.js} +1 -1
  231. package/dist/client/assets/{soul-file-Co_8f1qw.js → soul-file-BMpVFN7U.js} +1 -1
  232. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-BJPX5JTC.js → stateDiagram-v2-A6IESKWZ-b9gSbZnF.js} +1 -1
  233. package/dist/client/assets/{swimlanes-B3ENRKFQ-CiLSffGv.js → swimlanes-B3ENRKFQ-i47jxLY6.js} +1 -1
  234. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-CA9gW19w.js +8 -0
  235. package/dist/client/assets/{table-BSAvOYPp.js → table-CN2HCi4p.js} +1 -1
  236. package/dist/client/assets/{terminal-6CdY-T1V.js → terminal-BORQniao.js} +1 -1
  237. package/dist/client/assets/{timeline-definition-JXYKGLGB-5oq8sl82.js → timeline-definition-JXYKGLGB-eY5gj0js.js} +1 -1
  238. package/dist/client/assets/{trust-posture-D-Yjm6ot.js → trust-posture-Bcyy5Fub.js} +1 -1
  239. package/dist/client/assets/{unplug-Bq_1WdV7.js → unplug-lkD35Rwp.js} +1 -1
  240. package/dist/client/assets/{unverified-catalog-notice-CEzu54YH.js → unverified-catalog-notice-DiCIrrhU.js} +1 -1
  241. package/dist/client/assets/{use-adapter-catalog-Tn3ZbPAj.js → use-adapter-catalog-BrqVd-47.js} +1 -1
  242. package/dist/client/assets/{use-bindings-Bz9YRgO7.js → use-bindings-CU2RSXOy.js} +1 -1
  243. package/dist/client/assets/{use-composer-prefs-D9oKJSQN.js → use-composer-prefs-Dy2oTM8Y.js} +1 -1
  244. package/dist/client/assets/{use-connector-management-CLYFraXN.js → use-connector-management-5oRqzydY.js} +1 -1
  245. package/dist/client/assets/{use-deep-link-scroll-DkS713kG.js → use-deep-link-scroll-Bg5nW8qq.js} +1 -1
  246. package/dist/client/assets/{use-delete-binding-CukKpHBK.js → use-delete-binding-qeyRkvR1.js} +1 -1
  247. package/dist/client/assets/{use-dev-links-DQ32IcGe.js → use-dev-links-FY4J_PjA.js} +1 -1
  248. package/dist/client/assets/{use-external-adapter-catalog-D-FO_XW6.js → use-external-adapter-catalog-HiWFZZrW.js} +1 -1
  249. package/dist/client/assets/{use-full-activity-feed-BNxcyb1j.js → use-full-activity-feed-K1uk9Wya.js} +1 -1
  250. package/dist/client/assets/use-is-below-desktop-Cu_jKnft.js +1 -0
  251. package/dist/client/assets/use-is-hub-BX7ypNRJ.js +1 -0
  252. package/dist/client/assets/{use-jump-back-in-Bibj5tVk.js → use-jump-back-in-BjZ8EswV.js} +1 -1
  253. package/dist/client/assets/{use-local-browser-xg7WXAVK.js → use-local-browser-CTFiF0wf.js} +1 -1
  254. package/dist/client/assets/{use-mesh-topology-BgCSFw8s.js → use-mesh-topology-CafidaIH.js} +1 -1
  255. package/dist/client/assets/{use-mounted-ref-qRbdZfOU.js → use-mounted-ref-B38uSLCx.js} +1 -1
  256. package/dist/client/assets/{use-notification-prefs-B-4kZR7I.js → use-notification-prefs-m9XSNB6W.js} +1 -1
  257. package/dist/client/assets/{use-panel-tab-placements-CCq-mZlY.js → use-panel-tab-placements-D9n6rNJ1.js} +1 -1
  258. package/dist/client/assets/use-pending-read-BoV-UI1E.js +1 -0
  259. package/dist/client/assets/{use-personality-commit-DwSisUfF.js → use-personality-commit-ChLQfLrK.js} +1 -1
  260. package/dist/client/assets/{use-promo-activation-Botoso6l.js → use-promo-activation-DbJDgp4_.js} +1 -1
  261. package/dist/client/assets/{use-promo-dismissals-RJXp-r_J.js → use-promo-dismissals-Csw0j0N0.js} +1 -1
  262. package/dist/client/assets/{use-pulse-freshness-B3390hGg.js → use-pulse-freshness-BIZ7daHW.js} +1 -1
  263. package/dist/client/assets/{use-relay-config-BV0xcLwS.js → use-relay-config-hUB3lVFv.js} +1 -1
  264. package/dist/client/assets/{use-room-follow-claim-Du4hKHIJ.js → use-room-follow-claim-BpKzhniV.js} +1 -1
  265. package/dist/client/assets/{use-roving-tab-list-g2hO6Ruz.js → use-roving-tab-list-BtM0bZL7.js} +1 -1
  266. package/dist/client/assets/{use-session-canvas-i30oMO_Q.js → use-session-canvas-DRrkNRcL.js} +3 -3
  267. package/dist/client/assets/use-session-diagnostics-BTNgouum.js +16 -0
  268. package/dist/client/assets/{use-unclaimed-chats-B92om889.js → use-unclaimed-chats-BbMZtNG9.js} +1 -1
  269. package/dist/client/assets/use-update-config-CkWwKNkY.js +1 -0
  270. package/dist/client/assets/{useMutationState-DdOGdpjP.js → useMutationState-CVpvw27W.js} +1 -1
  271. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-Di5pJvcw.js → usecaseDiagram-WPOLBNNX-CHcpeLg4.js} +1 -1
  272. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-K7KAf26T.js → vennDiagram-Q3Y3IDCW-gQbZL_A6.js} +1 -1
  273. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-DVTaxQt9.js → wardleyDiagram-IVAIDKWA-BFH_WHzZ.js} +1 -1
  274. package/dist/client/assets/{xychartDiagram-4URNHDU4-x-lSJm_B.js → xychartDiagram-4URNHDU4-B0QpyqeZ.js} +1 -1
  275. package/dist/client/index.html +2 -2
  276. package/dist/drizzle/20261019185620_dor3037_wifi_holds.sql +8 -0
  277. package/dist/drizzle/meta/20261019185620_snapshot.json +14079 -0
  278. package/dist/drizzle/meta/_journal.json +7 -0
  279. package/dist/server/extension-child.cjs +18 -2
  280. package/dist/server/index.js +55523 -26605
  281. package/dist/server/index.js.map +2 -2
  282. package/package.json +6 -6
  283. package/dist/client/assets/ApplyToOverridesDialog-CoO6V1G4.js +0 -1
  284. package/dist/client/assets/HandlePage-Cg8H3mQS.js +0 -1
  285. package/dist/client/assets/NamePage-Bx8T98OF.js +0 -1
  286. package/dist/client/assets/PermissionHistory-DzU1rf2B.js +0 -1
  287. package/dist/client/assets/PhotoPage-CmrOIRjf.js +0 -1
  288. package/dist/client/assets/SeenDevices-SPWkdzoK.js +0 -19
  289. package/dist/client/assets/SettingsDialog-_dEXUhHe.js +0 -12
  290. package/dist/client/assets/ToolsPage-Idimrn3o.js +0 -2
  291. package/dist/client/assets/_shell-ClVN2pUj.js +0 -80
  292. package/dist/client/assets/_shell.marketplace-CiL6YRbl.js +0 -1
  293. package/dist/client/assets/_shell.marketplace_.sources-C0sI8e21.js +0 -1
  294. package/dist/client/assets/_shell.session-_hhBvFc6.js +0 -63
  295. package/dist/client/assets/_shell.x._extensionId-BWy5v1YE.js +0 -1
  296. package/dist/client/assets/_shell.x._extensionId_._-BWy5v1YE.js +0 -1
  297. package/dist/client/assets/channel-DjBlTcCV.js +0 -1
  298. package/dist/client/assets/index-7jby-RRg.js +0 -1
  299. package/dist/client/assets/index-BqIHtiaE.js +0 -1
  300. package/dist/client/assets/index-Cga0qx1T.js +0 -1033
  301. package/dist/client/assets/index-Ct4At33X.js +0 -1
  302. package/dist/client/assets/index-DITPwUa9.js +0 -38
  303. package/dist/client/assets/index-DUZrTFYD.css +0 -1
  304. package/dist/client/assets/registry-Dc102rws.js +0 -1
  305. package/dist/client/assets/signed-in-DctJ2IWe.js +0 -1
  306. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-Dv1-QS9J.js +0 -8
  307. package/dist/client/assets/use-is-below-desktop-gTvJDvw4.js +0 -1
  308. package/dist/client/assets/use-is-hub-B1vPpkYU.js +0 -1
  309. package/dist/client/assets/use-pending-read-C8L_v4Zw.js +0 -1
  310. package/dist/client/assets/use-session-diagnostics-a4b83F5J.js +0 -16
  311. package/dist/client/assets/use-update-config-Tbn3SodN.js +0 -1
@@ -1 +1 @@
1
- {"version":1,"controllerSHA256":"4ee17f656b624116988397b1610339bae4eac1c46f722dee8c476c1b2cee838d","nativeManifestSHA256":"19fb0607902e9c30bc693f3a8f7e80601f6ccfd090ffa412a5a38614e6eb7c00","platform":"darwin","arch":"arm64","availability":"available","workers":[{"name":"darwin-journal-worker.mjs","sha256":"739958b3515b48dda8cf40366aa6e34cf65366662c96dba1c951f38bc2f97603","bytes":88486},{"name":"darwin-supervisor-worker.mjs","sha256":"83b9b1e6d8969f5f909b43ebcf2d3ae6830601908bd2e4e4b2747d9ee7e55b77","bytes":74686}]}
1
+ {"version":1,"controllerSHA256":"1f3a5b16721e2356da157154f674b7ce618bc7598f4aa4b9902474a173c9a51e","nativeManifestSHA256":"19fb0607902e9c30bc693f3a8f7e80601f6ccfd090ffa412a5a38614e6eb7c00","platform":"darwin","arch":"arm64","availability":"available","workers":[{"name":"darwin-journal-worker.mjs","sha256":"739958b3515b48dda8cf40366aa6e34cf65366662c96dba1c951f38bc2f97603","bytes":88486},{"name":"darwin-supervisor-worker.mjs","sha256":"83b9b1e6d8969f5f909b43ebcf2d3ae6830601908bd2e4e4b2747d9ee7e55b77","bytes":74686}]}
@@ -1 +1 @@
1
- {"schemaVersion":1,"controllerSHA256":"4ee17f656b624116988397b1610339bae4eac1c46f722dee8c476c1b2cee838d","verifierSHA256":"5cb8f248a264a0602757ad2c0971c1b1e84bcf3185a2b8d706230d2cfac0703c"}
1
+ {"schemaVersion":1,"controllerSHA256":"1f3a5b16721e2356da157154f674b7ce618bc7598f4aa4b9902474a173c9a51e","verifierSHA256":"5cb8f248a264a0602757ad2c0971c1b1e84bcf3185a2b8d706230d2cfac0703c"}
@@ -1 +1 @@
1
- import{b as N,d as v,j as e,e as w,r as d,X as C,I as k,B as D,f as S}from"./index-Cga0qx1T.js";function j({children:i}){return e.jsx("div",{className:"text-muted-foreground text-3xs font-medium tracking-wider uppercase",children:i})}function A({agent:i,onUpdate:t}){const[a,l]=d.useState(!1),[o,u]=d.useState(""),n=i.capabilities??[];function c(){const s=o.trim();s&&!n.includes(s)&&t({capabilities:[...n,s]}),u(""),l(!1)}return e.jsxs("div",{className:"space-y-1",children:[e.jsx(j,{children:"Capabilities"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.map(s=>e.jsxs("span",{className:"bg-accent text-accent-foreground inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs",children:[s,e.jsx("button",{type:"button",onClick:()=>t({capabilities:n.filter(p=>p!==s)}),className:"hover:text-destructive transition-colors","aria-label":`Remove capability ${s}`,children:e.jsx(C,{"aria-hidden":!0,className:"size-3"})})]},s)),a?e.jsx(k,{autoFocus:!0,value:o,onChange:s=>u(s.target.value),onBlur:c,onKeyDown:s=>{s.key==="Enter"&&c(),s.key==="Escape"&&l(!1)},className:"h-6 w-28 text-xs",placeholder:"Capability name","aria-label":"New capability"}):e.jsxs(D,{type:"button",variant:"ghost",size:"sm",onClick:()=>l(!0),className:"text-muted-foreground hover:text-foreground h-auto gap-0.5 px-1 py-0 text-xs",children:[e.jsx(S,{"aria-hidden":!0,className:"size-3"})," Add"]})]})]})}function b({label:i,value:t,placeholder:a,multiline:l,testId:o,onCommit:u}){const[n,c]=d.useState(t),[s,p]=d.useState(t),[m,f]=d.useState(null);s!==t&&(p(t),c(t));function x(){const r=n.trim();if(r===t.trim())return;const g=u(r);if(typeof g!="string")return f(null);c(t),f(g)}const h="border-input bg-background placeholder:text-muted-foreground focus-visible:ring-ring w-full rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:outline-none",y=m?e.jsx("p",{role:"status",className:"text-destructive text-xs",children:m}):null;return e.jsxs("div",{className:"space-y-1",children:[e.jsx(j,{children:i}),l?e.jsx("textarea",{value:n,rows:4,"data-testid":o,"aria-label":i,placeholder:a,onChange:r=>{f(null),c(r.target.value)},onBlur:x,onKeyDown:r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),x())},className:h}):e.jsx("input",{value:n,"data-testid":o,"aria-label":i,placeholder:a,onChange:r=>{f(null),c(r.target.value)},onBlur:x,onKeyDown:r=>{r.key==="Enter"&&x()},className:h}),y]})}function R({member:i,roster:t}){const{agent:a,isPending:l,update:o}=N(i),u=v(i,t)==="managed";return l?e.jsx(w,{className:"h-16 w-full"}):!u||!a?e.jsx(E,{member:i,agent:a}):e.jsxs("div",{className:"flex flex-col gap-4","data-slot":"profile-about",children:[e.jsx(b,{label:"Name",value:a.displayName??a.name,placeholder:"What you call this agent",testId:"agent-name-field",onCommit:n=>{if(!n)return"A name can’t be empty, so the old one was kept.";o({displayName:n})}}),e.jsx(b,{multiline:!0,label:"Description",value:a.description??"",placeholder:"What is this agent for?",testId:"agent-description-field",onCommit:n=>o({description:n})}),e.jsx(A,{agent:a,onUpdate:o})]})}function E({member:i,agent:t}){var l;const a=(l=t==null?void 0:t.description)==null?void 0:l.trim();return a?e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:a}):e.jsxs("p",{className:"text-muted-foreground text-sm",children:[i.displayName," has no description yet."]})}export{R as AboutPage};
1
+ import{b as N,d as v,j as e,e as w,r as d,X as C,I as k,B as D,f as S}from"./index-C3cvP8Fo.js";function j({children:i}){return e.jsx("div",{className:"text-muted-foreground text-3xs font-medium tracking-wider uppercase",children:i})}function A({agent:i,onUpdate:t}){const[a,l]=d.useState(!1),[o,u]=d.useState(""),n=i.capabilities??[];function c(){const s=o.trim();s&&!n.includes(s)&&t({capabilities:[...n,s]}),u(""),l(!1)}return e.jsxs("div",{className:"space-y-1",children:[e.jsx(j,{children:"Capabilities"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.map(s=>e.jsxs("span",{className:"bg-accent text-accent-foreground inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs",children:[s,e.jsx("button",{type:"button",onClick:()=>t({capabilities:n.filter(p=>p!==s)}),className:"hover:text-destructive transition-colors","aria-label":`Remove capability ${s}`,children:e.jsx(C,{"aria-hidden":!0,className:"size-3"})})]},s)),a?e.jsx(k,{autoFocus:!0,value:o,onChange:s=>u(s.target.value),onBlur:c,onKeyDown:s=>{s.key==="Enter"&&c(),s.key==="Escape"&&l(!1)},className:"h-6 w-28 text-xs",placeholder:"Capability name","aria-label":"New capability"}):e.jsxs(D,{type:"button",variant:"ghost",size:"sm",onClick:()=>l(!0),className:"text-muted-foreground hover:text-foreground h-auto gap-0.5 px-1 py-0 text-xs",children:[e.jsx(S,{"aria-hidden":!0,className:"size-3"})," Add"]})]})]})}function b({label:i,value:t,placeholder:a,multiline:l,testId:o,onCommit:u}){const[n,c]=d.useState(t),[s,p]=d.useState(t),[m,f]=d.useState(null);s!==t&&(p(t),c(t));function x(){const r=n.trim();if(r===t.trim())return;const g=u(r);if(typeof g!="string")return f(null);c(t),f(g)}const h="border-input bg-background placeholder:text-muted-foreground focus-visible:ring-ring w-full rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:outline-none",y=m?e.jsx("p",{role:"status",className:"text-destructive text-xs",children:m}):null;return e.jsxs("div",{className:"space-y-1",children:[e.jsx(j,{children:i}),l?e.jsx("textarea",{value:n,rows:4,"data-testid":o,"aria-label":i,placeholder:a,onChange:r=>{f(null),c(r.target.value)},onBlur:x,onKeyDown:r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),x())},className:h}):e.jsx("input",{value:n,"data-testid":o,"aria-label":i,placeholder:a,onChange:r=>{f(null),c(r.target.value)},onBlur:x,onKeyDown:r=>{r.key==="Enter"&&x()},className:h}),y]})}function R({member:i,roster:t}){const{agent:a,isPending:l,update:o}=N(i),u=v(i,t)==="managed";return l?e.jsx(w,{className:"h-16 w-full"}):!u||!a?e.jsx(E,{member:i,agent:a}):e.jsxs("div",{className:"flex flex-col gap-4","data-slot":"profile-about",children:[e.jsx(b,{label:"Name",value:a.displayName??a.name,placeholder:"What you call this agent",testId:"agent-name-field",onCommit:n=>{if(!n)return"A name can’t be empty, so the old one was kept.";o({displayName:n})}}),e.jsx(b,{multiline:!0,label:"Description",value:a.description??"",placeholder:"What is this agent for?",testId:"agent-description-field",onCommit:n=>o({description:n})}),e.jsx(A,{agent:a,onUpdate:o})]})}function E({member:i,agent:t}){var l;const a=(l=t==null?void 0:t.description)==null?void 0:l.trim();return a?e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:a}):e.jsxs("p",{className:"text-muted-foreground text-sm",children:[i.displayName," has no description yet."]})}export{R as AboutPage};
@@ -1 +1 @@
1
- import{es as x,a1 as o,av as u,et as f,j as a,G as c,a0 as p,B as y}from"./index-Cga0qx1T.js";const g=["Today","Yesterday","This week","Earlier"];function A(e,s){const t=new Map;for(const r of e){const n=h(new Date(r.occurredAt),s),i=t.get(n)??[];i.push(r),t.set(n,i)}return g.filter(r=>t.has(r)).map(r=>({label:r,items:t.get(r)}))}function h(e,s){const t=new Date(s);t.setHours(0,0,0,0);const r=new Date(t);r.setDate(r.getDate()-1);const n=new Date(t);return n.setDate(n.getDate()-n.getDay()),e>=t?"Today":e>=r?"Yesterday":e>=n?"This week":"Earlier"}const T={person:"user",external:"user",agent:"agent",system:"system"};function k(e){return e.source.sessionId?x({session:e.source.sessionId}):null}function v(e){return{id:e.id,occurredAt:e.at,actorType:T[e.actor.kind],actorLabel:e.actor.name,summary:e.summary,linkPath:k(e)}}const d=["audit"],l=50;function m(e){return e.pages.flatMap(s=>s.events.map(v))}function E(e={}){const s=o();return u({queryKey:[...d,"list",e],queryFn:({pageParam:t})=>s.listAuditEvents({...e,limit:l,beforeSeq:t}),initialPageParam:void 0,getNextPageParam:t=>t.nextBeforeSeq,select:m,staleTime:3e4,refetchOnWindowFocus:!0})}function P(e){const s=o();return u({queryKey:[...d,"timeline",e],queryFn:e===null?f:({pageParam:t})=>s.getAccountTimeline(e,{limit:l,beforeSeq:t}),initialPageParam:void 0,getNextPageParam:t=>t.nextBeforeSeq,select:m,staleTime:3e4,refetchOnWindowFocus:!0})}function j({label:e,className:s}){return a.jsx("div",{"data-slot":"activity-group-header",className:c("sticky top-0 z-10 -mx-4 px-4 py-2 sm:-mx-6 sm:px-6","bg-background/95 backdrop-blur-sm",s),children:a.jsx("h3",{className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:e})})}function D({onRetry:e,className:s}){return a.jsxs("div",{"data-slot":"activity-error-state",className:c("flex flex-col items-center justify-center gap-3 py-16 text-center",s),children:[a.jsx("div",{className:"bg-destructive/10 rounded-xl p-3",children:a.jsx(p,{className:"text-destructive size-6","aria-hidden":"true"})}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-foreground text-sm font-medium",children:"Couldn’t load your activity"}),a.jsx("p",{className:"text-muted-foreground max-w-xs text-xs",children:"The DorkOS server didn’t answer. Check that it’s running."})]}),a.jsx(y,{variant:"outline",size:"sm",onClick:e,children:"Retry"})]})}export{D as A,j as a,E as b,A as g,P as u};
1
+ import{es as x,a1 as o,av as u,et as f,j as a,G as c,a0 as p,B as y}from"./index-C3cvP8Fo.js";const g=["Today","Yesterday","This week","Earlier"];function A(e,s){const t=new Map;for(const r of e){const n=h(new Date(r.occurredAt),s),i=t.get(n)??[];i.push(r),t.set(n,i)}return g.filter(r=>t.has(r)).map(r=>({label:r,items:t.get(r)}))}function h(e,s){const t=new Date(s);t.setHours(0,0,0,0);const r=new Date(t);r.setDate(r.getDate()-1);const n=new Date(t);return n.setDate(n.getDate()-n.getDay()),e>=t?"Today":e>=r?"Yesterday":e>=n?"This week":"Earlier"}const T={person:"user",external:"user",agent:"agent",system:"system"};function k(e){return e.source.sessionId?x({session:e.source.sessionId}):null}function v(e){return{id:e.id,occurredAt:e.at,actorType:T[e.actor.kind],actorLabel:e.actor.name,summary:e.summary,linkPath:k(e)}}const d=["audit"],l=50;function m(e){return e.pages.flatMap(s=>s.events.map(v))}function E(e={}){const s=o();return u({queryKey:[...d,"list",e],queryFn:({pageParam:t})=>s.listAuditEvents({...e,limit:l,beforeSeq:t}),initialPageParam:void 0,getNextPageParam:t=>t.nextBeforeSeq,select:m,staleTime:3e4,refetchOnWindowFocus:!0})}function P(e){const s=o();return u({queryKey:[...d,"timeline",e],queryFn:e===null?f:({pageParam:t})=>s.getAccountTimeline(e,{limit:l,beforeSeq:t}),initialPageParam:void 0,getNextPageParam:t=>t.nextBeforeSeq,select:m,staleTime:3e4,refetchOnWindowFocus:!0})}function j({label:e,className:s}){return a.jsx("div",{"data-slot":"activity-group-header",className:c("sticky top-0 z-10 -mx-4 px-4 py-2 sm:-mx-6 sm:px-6","bg-background/95 backdrop-blur-sm",s),children:a.jsx("h3",{className:"text-muted-foreground text-xs font-medium tracking-wider uppercase",children:e})})}function D({onRetry:e,className:s}){return a.jsxs("div",{"data-slot":"activity-error-state",className:c("flex flex-col items-center justify-center gap-3 py-16 text-center",s),children:[a.jsx("div",{className:"bg-destructive/10 rounded-xl p-3",children:a.jsx(p,{className:"text-destructive size-6","aria-hidden":"true"})}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-foreground text-sm font-medium",children:"Couldn’t load your activity"}),a.jsx("p",{className:"text-muted-foreground max-w-xs text-xs",children:"The DorkOS server didn’t answer. Check that it’s running."})]}),a.jsx(y,{variant:"outline",size:"sm",onClick:e,children:"Retry"})]})}export{D as A,j as a,E as b,A as g,P as u};
@@ -1 +1 @@
1
- import{r as c,j as e,e as d,A as u,B as j,x as v}from"./index-Cga0qx1T.js";import{E as g}from"./empty-state-J-UJ0BUU.js";import{T as N,a as A}from"./table-BSAvOYPp.js";import{u as b,g as w,A as E,a as T}from"./ActivityErrorState-K5Mew9EX.js";import{A as B}from"./ActivityRow-C5O7rnmS.js";function I({member:i}){var n;const r=((n=i.agent)==null?void 0:n.manifestId)??null,{data:l,isLoading:x,isError:m,refetch:p,isFetchingNextPage:o,hasNextPage:h,fetchNextPage:f}=b(r),s=c.useMemo(()=>l??[],[l]),y=c.useMemo(()=>w(s,new Date),[s]);return r===null?e.jsx("div",{className:"min-h-0 flex-1 px-4 py-3","data-slot":"profile-activity",children:e.jsx("p",{className:"text-muted-foreground text-xs",children:"Activity is kept per agent."})}):x?e.jsxs("div",{className:"min-h-0 flex-1 space-y-2 px-4 py-3","data-slot":"profile-activity","aria-busy":"true",children:[e.jsx(d,{className:"h-3 w-16"}),Array.from({length:5}).map((t,a)=>e.jsx(d,{className:"h-4 w-full"},a))]}):m&&s.length===0?e.jsx("div",{className:"min-h-0 flex-1 px-2","data-slot":"profile-activity",children:e.jsx(E,{onRetry:()=>void p()})}):s.length===0?e.jsx("div",{className:"min-h-0 flex-1 px-4 py-8","data-slot":"profile-activity",children:e.jsx(g,{icon:u,headline:"Nothing on record yet",description:`What ${i.displayName} does shows up here.`})}):e.jsxs("div",{className:"min-h-0 flex-1 px-2 py-2","data-slot":"profile-activity",children:[y.map(t=>e.jsxs("section",{children:[e.jsx(T,{label:t.label}),e.jsx(N,{children:e.jsx(A,{children:t.items.map(a=>e.jsx(B,{item:a,compact:!0},a.id))})})]},t.label)),h&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>void f(),disabled:o,className:"gap-2",children:[o&&e.jsx(v,{size:"xs"}),"Load 50 more"]})})]})}export{I as ActivityPage};
1
+ import{r as c,j as e,e as d,A as u,B as j,x as v}from"./index-C3cvP8Fo.js";import{E as g}from"./empty-state-CDoXnrKn.js";import{T as N,a as A}from"./table-CN2HCi4p.js";import{u as b,g as w,A as E,a as T}from"./ActivityErrorState-BP-qFk2S.js";import{A as B}from"./ActivityRow-BRZyW9MA.js";function I({member:i}){var n;const r=((n=i.agent)==null?void 0:n.manifestId)??null,{data:l,isLoading:x,isError:m,refetch:p,isFetchingNextPage:o,hasNextPage:h,fetchNextPage:f}=b(r),s=c.useMemo(()=>l??[],[l]),y=c.useMemo(()=>w(s,new Date),[s]);return r===null?e.jsx("div",{className:"min-h-0 flex-1 px-4 py-3","data-slot":"profile-activity",children:e.jsx("p",{className:"text-muted-foreground text-xs",children:"Activity is kept per agent."})}):x?e.jsxs("div",{className:"min-h-0 flex-1 space-y-2 px-4 py-3","data-slot":"profile-activity","aria-busy":"true",children:[e.jsx(d,{className:"h-3 w-16"}),Array.from({length:5}).map((t,a)=>e.jsx(d,{className:"h-4 w-full"},a))]}):m&&s.length===0?e.jsx("div",{className:"min-h-0 flex-1 px-2","data-slot":"profile-activity",children:e.jsx(E,{onRetry:()=>void p()})}):s.length===0?e.jsx("div",{className:"min-h-0 flex-1 px-4 py-8","data-slot":"profile-activity",children:e.jsx(g,{icon:u,headline:"Nothing on record yet",description:`What ${i.displayName} does shows up here.`})}):e.jsxs("div",{className:"min-h-0 flex-1 px-2 py-2","data-slot":"profile-activity",children:[y.map(t=>e.jsxs("section",{children:[e.jsx(T,{label:t.label}),e.jsx(N,{children:e.jsx(A,{children:t.items.map(a=>e.jsx(B,{item:a,compact:!0},a.id))})})]},t.label)),h&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>void f(),disabled:o,className:"gap-2",children:[o&&e.jsx(v,{size:"xs"}),"Load 50 more"]})})]})}export{I as ActivityPage};
@@ -1 +1 @@
1
- import{b7 as d,d5 as x,j as e,_ as u,G as l,c6 as m,d6 as g,B as h}from"./index-Cga0qx1T.js";import{b as f,c}from"./table-BSAvOYPp.js";const k={tasks:{text:"text-purple-500",bg:"bg-purple-500/10",label:"Schedules"},relay:{text:"text-teal-500",bg:"bg-teal-500/10",label:"Messages"},agent:{text:"text-indigo-500",bg:"bg-indigo-500/10",label:"Agent"},config:{text:"text-amber-500",bg:"bg-amber-500/10",label:"Settings"},system:{text:"text-neutral-500",bg:"bg-neutral-500/10",label:"System"},permissions:{text:"text-sky-500",bg:"bg-sky-500/10",label:"Permissions"}},p={user:{text:"text-muted-foreground"},agent:{text:"text-foreground"},system:{icon:x,text:"text-neutral-500"},tasks:{icon:d,text:"text-purple-500"}};function b({actorType:s,actorLabel:r,agentColor:a,className:n}){const i=p[s],t=i.icon;return s==="user"?e.jsx(u,{shape:"pill",variant:"outline",className:l("text-muted-foreground",n),children:r}):s==="agent"?e.jsxs("span",{"data-slot":"actor-badge",className:l("inline-flex items-center gap-1.5 text-xs font-medium",i.text,n),children:[e.jsx("span",{className:"size-2 shrink-0 rounded-full",style:a?{backgroundColor:a}:void 0,"aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r})]}):e.jsxs("span",{"data-slot":"actor-badge",className:l("inline-flex items-center gap-1 text-xs font-medium",i.text,n),children:[t&&e.jsx(t,{className:"size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:r})]})}function y(s,r=new Date){const a=new Date(s),n=new Date(r);n.setHours(0,0,0,0);const i=new Date(n);i.setDate(i.getDate()-1);const t=new Date(n);t.setDate(t.getDate()-t.getDay());const o=a.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return a>=n?o:a>=i?`Yesterday ${o}`:a>=t?`${a.toLocaleDateString("en-US",{weekday:"long"})} ${o}`:a.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function v({item:s,compact:r=!1,className:a}){const n=m(),i=y(s.occurredAt),t=s.linkPath?g(s.linkPath):null;return e.jsxs(f,{"data-slot":"activity-row","data-activity-row":t?"":void 0,tabIndex:t?0:void 0,onKeyDown:t?o=>{o.key==="Enter"&&n({href:t,replace:!1})}:void 0,className:l(t?"focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none":"hover:bg-transparent",a),children:[!r&&e.jsxs(e.Fragment,{children:[e.jsx(c,{className:"w-28 py-1.5 pr-0 pl-2 max-sm:hidden",children:e.jsx("span",{className:"text-muted-foreground text-xs tabular-nums",children:i})}),e.jsx(c,{className:"w-24 py-1.5 pr-0 max-sm:hidden",children:e.jsx(b,{actorType:s.actorType,actorLabel:s.actorLabel})})]}),e.jsx(c,{className:l("max-w-0 py-1.5",r?"pl-2":"max-sm:pl-2"),children:e.jsxs("span",{className:"text-foreground/80 block truncate text-sm",children:[e.jsx("span",{className:l("text-muted-foreground mr-1 text-xs font-medium",!r&&"sm:hidden"),children:s.actorLabel}),s.summary]})}),e.jsx(c,{className:l("py-1.5 pr-2 text-right",r?"w-10":"w-16 max-sm:w-10"),children:t&&e.jsx(h,{variant:"ghost",size:"sm",className:"h-6 min-h-[44px] px-2 text-xs sm:min-h-0",onClick:()=>n({href:t,replace:!1}),children:"Open →"})})]})}export{v as A,k as C};
1
+ import{b7 as d,d5 as x,j as e,_ as u,G as l,c6 as m,d6 as g,B as h}from"./index-C3cvP8Fo.js";import{b as f,c}from"./table-CN2HCi4p.js";const k={tasks:{text:"text-purple-500",bg:"bg-purple-500/10",label:"Schedules"},relay:{text:"text-teal-500",bg:"bg-teal-500/10",label:"Messages"},agent:{text:"text-indigo-500",bg:"bg-indigo-500/10",label:"Agent"},config:{text:"text-amber-500",bg:"bg-amber-500/10",label:"Settings"},system:{text:"text-neutral-500",bg:"bg-neutral-500/10",label:"System"},permissions:{text:"text-sky-500",bg:"bg-sky-500/10",label:"Permissions"}},p={user:{text:"text-muted-foreground"},agent:{text:"text-foreground"},system:{icon:x,text:"text-neutral-500"},tasks:{icon:d,text:"text-purple-500"}};function b({actorType:s,actorLabel:r,agentColor:a,className:n}){const i=p[s],t=i.icon;return s==="user"?e.jsx(u,{shape:"pill",variant:"outline",className:l("text-muted-foreground",n),children:r}):s==="agent"?e.jsxs("span",{"data-slot":"actor-badge",className:l("inline-flex items-center gap-1.5 text-xs font-medium",i.text,n),children:[e.jsx("span",{className:"size-2 shrink-0 rounded-full",style:a?{backgroundColor:a}:void 0,"aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r})]}):e.jsxs("span",{"data-slot":"actor-badge",className:l("inline-flex items-center gap-1 text-xs font-medium",i.text,n),children:[t&&e.jsx(t,{className:"size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:r})]})}function y(s,r=new Date){const a=new Date(s),n=new Date(r);n.setHours(0,0,0,0);const i=new Date(n);i.setDate(i.getDate()-1);const t=new Date(n);t.setDate(t.getDate()-t.getDay());const o=a.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return a>=n?o:a>=i?`Yesterday ${o}`:a>=t?`${a.toLocaleDateString("en-US",{weekday:"long"})} ${o}`:a.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function v({item:s,compact:r=!1,className:a}){const n=m(),i=y(s.occurredAt),t=s.linkPath?g(s.linkPath):null;return e.jsxs(f,{"data-slot":"activity-row","data-activity-row":t?"":void 0,tabIndex:t?0:void 0,onKeyDown:t?o=>{o.key==="Enter"&&n({href:t,replace:!1})}:void 0,className:l(t?"focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none":"hover:bg-transparent",a),children:[!r&&e.jsxs(e.Fragment,{children:[e.jsx(c,{className:"w-28 py-1.5 pr-0 pl-2 max-sm:hidden",children:e.jsx("span",{className:"text-muted-foreground text-xs tabular-nums",children:i})}),e.jsx(c,{className:"w-24 py-1.5 pr-0 max-sm:hidden",children:e.jsx(b,{actorType:s.actorType,actorLabel:s.actorLabel})})]}),e.jsx(c,{className:l("max-w-0 py-1.5",r?"pl-2":"max-sm:pl-2"),children:e.jsxs("span",{className:"text-foreground/80 block truncate text-sm",children:[e.jsx("span",{className:l("text-muted-foreground mr-1 text-xs font-medium",!r&&"sm:hidden"),children:s.actorLabel}),s.summary]})}),e.jsx(c,{className:l("py-1.5 pr-2 text-right",r?"w-10":"w-16 max-sm:w-10"),children:t&&e.jsx(h,{variant:"ghost",size:"sm",className:"h-6 min-h-[44px] px-2 text-xs sm:min-h-0",onClick:()=>n({href:t,replace:!1}),children:"Open →"})})]})}export{v as A,k as C};
@@ -1 +1 @@
1
- import{bD as n,bE as r,j as c,bF as s,aS as A}from"./index-Cga0qx1T.js";const g={connected:n.success,disconnected:n.neutral,error:n.error,starting:`${n.warning} ${r}`,stopping:`${n.warning} ${r}`,reconnecting:`${n.warning} ${r}`},E={connected:"Connected",disconnected:"Ready",error:"Error",starting:"Connecting…",stopping:"Stopping…",reconnecting:"Reconnecting…"};function S({iconId:i,adapterType:a,size:t=16,className:o}){const e=s[i??""]??s[a??""];return e?c.jsx(e,{size:t,className:o}):c.jsx(A,{className:o,style:{width:t,height:t}})}export{S as A,g as a,E as b};
1
+ import{bD as n,bE as r,j as c,bF as s,aS as A}from"./index-C3cvP8Fo.js";const g={connected:n.success,disconnected:n.neutral,error:n.error,starting:`${n.warning} ${r}`,stopping:`${n.warning} ${r}`,reconnecting:`${n.warning} ${r}`},E={connected:"Connected",disconnected:"Ready",error:"Error",starting:"Connecting…",stopping:"Stopping…",reconnecting:"Reconnecting…"};function S({iconId:i,adapterType:a,size:t=16,className:o}){const e=s[i??""]??s[a??""];return e?c.jsx(e,{size:t,className:o}):c.jsx(A,{className:o,style:{width:t,height:t}})}export{S as A,g as a,E as b};
@@ -1,2 +1,2 @@
1
- import{a1 as be,a3 as Ne,a4 as ze,j as e,be as qe,bf as Ee,r as m,cT as ie,hj as Te,cU as oe,h1 as le,$ as Me,O as ce,Q as de,hk as ue,T as he,U as pe,bx as K,ar as J,hl as me,hm as We,G as U,dW as X,dX as Z,dY as ee,dZ as se,d_ as te,I as re,e2 as xe,J as $e,bw as Ve,B as k,hn as Se,e4 as De,e1 as ae,x as ke,bc as Pe,bb as Re,a0 as Oe,ak as ge,ho as Le,hp as _e,hq as Ge,hr as Ue,hs as Ie,cv as Qe,a7 as G,ew as He,ex as Ye,ey as Ke,ez as Je,eA as Xe,eB as Ze,ht as fe,hu as H}from"./index-Cga0qx1T.js";import{B as es}from"./use-bindings-Bz9YRgO7.js";import{M as I}from"./markdown-content-m_qereFc.js";import{a as ss,b as ts,c as rs}from"./use-adapter-catalog-Tn3ZbPAj.js";import{u as as}from"./form-DlPwEgQH.js";import{a as ns}from"./BindingDialog-DLoAQauL.js";import"./relay-trace-schemas-DwUuyxao.js";function zs(s={}){const t=be(),a=Ne();return ze({mutationFn:({id:r,updates:l})=>t.updateBinding(r,l),onSuccess:()=>{a.invalidateQueries({queryKey:[...es]})},meta:s.suppressErrorToast?{suppressErrorToast:!0}:{errorLabel:s.errorLabel??"Couldn’t update that connection"}})}function is({field:s,value:t,onChange:a,error:r,allValues:l}){const[i,n]=m.useState("");if(s.showWhen&&l[s.showWhen.field]!==s.showWhen.equals)return null;const o=`config-field-${s.key}`,v=s.type==="select"&&s.displayAs==="radio-cards",h=t!=null?String(t):"",x=h==="***",y=()=>{if(x){n("");return}if(s.pattern&&h&&!new RegExp(s.pattern).test(h)){n(s.patternMessage??"Check the format");return}n("")},d=r??i;if(s.type==="boolean")return e.jsxs("div",{children:[e.jsxs(ie,{orientation:"horizontal",className:"items-center justify-between gap-4",children:[e.jsxs(Te,{className:"min-w-0",children:[e.jsxs(oe,{htmlFor:o,className:"text-sm font-medium",children:[s.label,s.required&&e.jsx("span",{"aria-hidden":"true",className:"text-destructive ml-0.5",children:"*"})]}),s.description&&e.jsx(le,{className:"text-xs",children:s.description})]}),e.jsx(Me,{id:o,checked:!!t,onCheckedChange:N=>a(s.key,N)})]}),s.helpMarkdown&&e.jsxs(ce,{children:[e.jsxs(de,{className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs transition-colors",children:[e.jsx(ue,{className:"size-3"}),"Where do I find this?",e.jsx(he,{className:"size-3 transition-transform [[data-state=open]_&]:rotate-180"})]}),e.jsx(pe,{children:e.jsx("div",{className:"bg-muted/50 mt-2 rounded-md border p-3",children:e.jsx(I,{content:s.helpMarkdown,className:"text-xs"})})})]}),e.jsx(K,{children:d&&e.jsx(J.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsx(me,{className:"mt-1.5",children:d})})})]});const b=()=>{var N,C;switch(s.type){case"text":case"url":return e.jsx(re,{id:o,type:s.type==="url"?"url":"text",value:h,onChange:c=>a(s.key,c.target.value),placeholder:s.placeholder,"aria-invalid":!!d||void 0,"aria-required":s.required||void 0});case"password":return x?e.jsx(xe,{id:o,value:h,showPassword:!1,onChange:c=>{a(s.key,c.target.value.trim()),i&&n("")},onFocus:()=>a(s.key,""),onBlur:y,placeholder:"Saved · type to replace"}):e.jsx(xe,{id:o,value:h,visibleByDefault:s.visibleByDefault??!1,onChange:c=>{a(s.key,c.target.value.trim()),i&&n("")},onBlur:y,onPaste:()=>setTimeout(y,0),placeholder:s.placeholder,"aria-invalid":!!d||void 0,"aria-required":s.required||void 0});case"number":return e.jsx(re,{id:o,type:"number",value:h,onChange:c=>a(s.key,c.target.value?Number(c.target.value):void 0),placeholder:s.placeholder,"aria-invalid":!!d||void 0,"aria-required":s.required||void 0});case"select":return s.displayAs==="radio-cards"?e.jsx("div",{className:"grid grid-cols-2 gap-3",role:"radiogroup","aria-labelledby":`${o}-label`,"aria-required":s.required||void 0,children:(N=s.options)==null?void 0:N.map(c=>e.jsxs("button",{type:"button",role:"radio","aria-checked":h===c.value,onClick:()=>a(s.key,c.value),className:U("hover:bg-accent/50 focus-visible:border-ring focus-visible:ring-ring flex flex-col items-start rounded-md border p-3 text-left transition outline-none focus-visible:ring-[3px]",h===c.value&&"border-primary ring-primary bg-accent/30 ring-1"),children:[e.jsx("span",{className:"text-sm font-medium",children:c.label}),c.description&&e.jsx("span",{className:"text-muted-foreground mt-1 text-xs",children:c.description})]},c.value))}):e.jsxs(X,{value:h,onValueChange:c=>a(s.key,c),children:[e.jsx(Z,{id:o,"aria-invalid":!!d||void 0,"aria-required":s.required||void 0,children:e.jsx(ee,{placeholder:s.placeholder??"Select…"})}),e.jsx(se,{children:(C=s.options)==null?void 0:C.map(c=>e.jsx(te,{value:c.value,children:c.label},c.value))})]});case"textarea":return e.jsx(We,{id:o,value:h,onChange:c=>a(s.key,c.target.value),placeholder:s.placeholder,rows:3,"aria-invalid":!!d||void 0,"aria-required":s.required||void 0});default:return null}};return e.jsxs(ie,{children:[e.jsxs(oe,{id:`${o}-label`,htmlFor:v?void 0:o,children:[s.label,s.required&&!x&&e.jsx("span",{"aria-hidden":"true",className:"text-destructive ml-0.5",children:"*"})]}),b(),s.description&&e.jsx(le,{className:"text-xs",children:s.description}),s.helpMarkdown&&e.jsxs(ce,{children:[e.jsxs(de,{className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs transition-colors",children:[e.jsx(ue,{className:"size-3"}),"Where do I find this?",e.jsx(he,{className:"size-3 transition-transform [[data-state=open]_&]:rotate-180"})]}),e.jsx(pe,{children:e.jsx("div",{className:"bg-muted/50 mt-2 rounded-md border p-3",children:e.jsx(I,{content:s.helpMarkdown,className:"text-xs"})})})]}),e.jsx(K,{children:d&&e.jsx(J.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsx(me,{children:d})})})]})}function os(s,t){return s.showWhen?t[s.showWhen.field]===s.showWhen.equals:!0}function ls({fields:s,allValues:t,renderField:a}){const r=new Map;for(const l of s){const i=l.section;r.has(i)||r.set(i,[]),r.get(i).push(l)}return e.jsx("div",{className:"space-y-6",children:Array.from(r.entries()).map(([l,i])=>{const n=i.filter(o=>os(o,t));return n.length===0?null:e.jsxs("div",{className:"space-y-3",children:[l&&e.jsx("h4",{className:"text-sm font-semibold",children:l}),e.jsx(qe,{children:e.jsx(Ee,{children:n.map(o=>a(o))})})]},l??"__default")})})}const je=["agent","configure","test","confirm"],cs={agent:"Agent",configure:"Set up",test:"Check",confirm:"Review"};function ds({current:s,showAgentStep:t}){const a=t?je:je.filter(l=>l!=="agent"),r=a.indexOf(s);return e.jsx("div",{className:"flex items-start justify-between px-1",role:"navigation","aria-label":"Setup steps",children:a.map((l,i)=>{const n=i<r,o=i===r,v=i>r;return e.jsxs(m.Fragment,{children:[i>0&&e.jsx("div",{className:U("mt-3 h-px flex-1",n||o?"bg-primary":"border-muted-foreground/40 border-t border-dashed")}),e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:U("flex size-6 items-center justify-center rounded-full text-xs font-medium",n&&"bg-primary text-primary-foreground",o&&"bg-primary text-primary-foreground ring-primary/30 ring-2",v&&"border-muted-foreground text-muted-foreground border"),"aria-current":o?"step":void 0,children:n?e.jsx($e,{className:"size-3"}):i+1}),e.jsx("span",{className:U("text-3xs",o?"text-foreground font-medium":"text-muted-foreground"),children:cs[l]})]})]},l)})})}function us({manifest:s,label:t,onLabelChange:a,fields:r,form:l,currentSetupStep:i,hasSetupGuide:n,onOpenGuide:o}){const{Subscribe:v,AppField:h}=l;return e.jsxs("div",{className:"space-y-4",children:[s.setupInstructions&&e.jsxs("div",{className:"flex gap-2 rounded-md border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-200",children:[e.jsx(Ve,{className:"mt-0.5 size-4 shrink-0"}),e.jsx(I,{content:s.setupInstructions,className:"text-sm text-blue-800 dark:text-blue-200"})]}),(s.actionButton||n)&&e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[n&&e.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:o,children:[e.jsx(Se,{className:"mr-1.5 size-3.5"}),"Setup guide"]}),s.actionButton&&e.jsx(k,{asChild:!0,type:"button",variant:"outline",size:"sm",children:e.jsx(De,{href:s.actionButton.url,children:s.actionButton.label})})]}),i&&e.jsx("h4",{className:"text-sm font-medium",children:i.title}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ae,{htmlFor:"adapter-label",children:"Name (optional)"}),e.jsx(re,{id:"adapter-label",placeholder:s.displayName,value:t,onChange:x=>a(x.target.value)}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Helps you tell this connection apart."})]}),e.jsx(v,{selector:x=>x.values,children:x=>e.jsx(ls,{fields:r,allValues:x,renderField:y=>e.jsx(h,{name:y.key,children:d=>{var b;return e.jsx(is,{field:y,value:d.state.value,onChange:(N,C)=>d.handleChange(C),onBlur:d.handleBlur,error:d.state.meta.isTouched?(b=d.state.meta.errors[0])==null?void 0:b.toString():void 0,allValues:x})}},y.key)})})]})}function hs({isPending:s,isSuccess:t,isError:a,errorMessage:r,botUsername:l,onRetry:i}){return e.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{size:"lg",className:"text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Trying to reach it…"})]}),t&&e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Pe,{className:"text-status-success size-8"}),e.jsx("p",{className:"text-status-success-fg text-sm",children:"Reachable"}),l&&e.jsx("div",{className:"flex items-center gap-2 rounded-md border px-3 py-2 text-sm",children:e.jsxs("span",{className:"font-mono",children:["@",l]})})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{className:"text-destructive size-8"}),e.jsx("p",{className:"text-destructive text-sm",children:"Not reachable"}),r&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-xs text-red-700 dark:border-red-800 dark:bg-red-950 dark:text-red-300",children:[e.jsx(Oe,{className:"mt-0.5 size-3 shrink-0"}),e.jsx("span",{children:r})]}),e.jsx(k,{variant:"outline",size:"sm",onClick:i,children:"Retry"})]})]})}function ps(s){return s.length>8?"•••• "+s.slice(-4):"•••"}function ms({manifest:s,adapterId:t,isEditMode:a,values:r,botUsername:l,agentName:i}){return e.jsxs("div",{className:"space-y-3",children:[!a&&i&&e.jsxs("p",{className:"bg-accent/30 rounded-md border px-3 py-2 text-sm",children:["Messages here go to ",e.jsx("span",{className:"font-medium",children:i}),"."]}),!a&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Connection ID"}),e.jsx("span",{className:"font-mono",children:t})]}),s.configFields.map(n=>{if(n.showWhen&&r[n.showWhen.field]!==n.showWhen.equals)return null;const o=String(r[n.key]??""),v=n.type==="password"?ps(o):o;return e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:n.label}),e.jsx("span",{className:"max-w-[200px] truncate font-mono",children:v})]},n.key)}),l&&s.type==="telegram"&&e.jsxs("a",{href:`https://t.me/${l}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary inline-flex items-center gap-1.5 text-sm underline-offset-4 hover:underline",children:["Message @",l," in Telegram"]})]})}const ye=[{value:"per-chat",label:"One shared chat per group or channel",hint:"Everyone there shares one chat with the agent."},{value:"per-user",label:"One chat per person",hint:"Each person gets their own chat, even in a group."},{value:"stateless",label:"A fresh start every message",hint:"Nothing carries over from the message before."}];function xs({agentOptions:s,agentId:t,onAgentIdChange:a,strategy:r,onStrategyChange:l}){var n;const i=s.length===1?s[0]:void 0;return m.useEffect(()=>{i&&!t&&a(i.id)},[i,t,a]),s.length===0?e.jsx("p",{role:"alert",className:"text-muted-foreground rounded-md border border-dashed px-4 py-6 text-center text-sm",children:"No agents yet. Add one from the Team page first."}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Messages here go to this agent."}),i?e.jsxs("div",{className:"bg-accent/30 rounded-md border px-4 py-3 text-sm",children:[e.jsx("span",{className:"font-medium",children:ge(i)})," will answer."]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ae,{htmlFor:"wizard-agent",children:"Who should answer?"}),e.jsxs(X,{value:t,onValueChange:a,children:[e.jsx(Z,{id:"wizard-agent",className:"w-full",children:e.jsx(ee,{placeholder:"Pick an agent"})}),e.jsx(se,{children:s.map(o=>e.jsx(te,{value:o.id,children:ge(o)},o.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ae,{htmlFor:"wizard-memory",children:"How the agent remembers"}),e.jsxs(X,{value:r,onValueChange:o=>l(o),children:[e.jsx(Z,{id:"wizard-memory",className:"w-full",children:e.jsx(ee,{})}),e.jsx(se,{children:ye.map(o=>e.jsx(te,{value:o.value,children:o.label},o.value))})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:(n=ye.find(o=>o.value===r))==null?void 0:n.hint})]})]})}function gs({open:s,onOpenChange:t,title:a,content:r}){return e.jsx(Le,{open:s,onOpenChange:t,children:e.jsxs(_e,{side:"right",className:"w-[480px] overflow-y-auto sm:max-w-lg",children:[e.jsxs(Ge,{children:[e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx(Se,{className:"size-4"}),a," setup guide"]}),e.jsx(Ie,{children:"Step-by-step setup instructions."})]}),e.jsx("div",{className:"mt-4 px-4",children:e.jsx(I,{content:r})})]})})}function we(s){const t=s.setupSteps;if(!t||t.length===0)return[];const a=new Set(t.flatMap(r=>r.fields));return s.configFields.filter(r=>!a.has(r.key))}function fs(s,t){return typeof t=="string"||t===void 0||t===null?t:s.valueShape==="id-list"?Array.isArray(t)?t.join(`
1
+ import{a1 as be,a3 as Ne,a4 as ze,j as e,be as qe,bf as Ee,r as m,cT as ie,ho as Te,cU as oe,h2 as le,$ as Me,O as ce,Q as de,hp as ue,T as he,U as pe,bx as K,ar as J,hq as me,hr as We,G as U,dW as X,dX as Z,dY as ee,dZ as se,d_ as te,I as re,e2 as xe,J as $e,bw as Ve,B as k,hs as Se,e4 as De,e1 as ae,x as ke,bc as Pe,bb as Re,a0 as Oe,ak as ge,ht as Le,hu as _e,hv as Ge,hw as Ue,hx as Ie,cv as Qe,a7 as G,ew as He,ex as Ye,ey as Ke,ez as Je,eA as Xe,eB as Ze,hy as fe,hz as H}from"./index-C3cvP8Fo.js";import{B as es}from"./use-bindings-CU2RSXOy.js";import{M as I}from"./markdown-content-DaEVxezf.js";import{a as ss,b as ts,c as rs}from"./use-adapter-catalog-BrqVd-47.js";import{u as as}from"./form-Cru78aT-.js";import{a as ns}from"./BindingDialog-BAdueON5.js";import"./relay-trace-schemas-DF_DfZ7s.js";function zs(s={}){const t=be(),a=Ne();return ze({mutationFn:({id:r,updates:l})=>t.updateBinding(r,l),onSuccess:()=>{a.invalidateQueries({queryKey:[...es]})},meta:s.suppressErrorToast?{suppressErrorToast:!0}:{errorLabel:s.errorLabel??"Couldn’t update that connection"}})}function is({field:s,value:t,onChange:a,error:r,allValues:l}){const[i,n]=m.useState("");if(s.showWhen&&l[s.showWhen.field]!==s.showWhen.equals)return null;const o=`config-field-${s.key}`,v=s.type==="select"&&s.displayAs==="radio-cards",h=t!=null?String(t):"",x=h==="***",y=()=>{if(x){n("");return}if(s.pattern&&h&&!new RegExp(s.pattern).test(h)){n(s.patternMessage??"Check the format");return}n("")},d=r??i;if(s.type==="boolean")return e.jsxs("div",{children:[e.jsxs(ie,{orientation:"horizontal",className:"items-center justify-between gap-4",children:[e.jsxs(Te,{className:"min-w-0",children:[e.jsxs(oe,{htmlFor:o,className:"text-sm font-medium",children:[s.label,s.required&&e.jsx("span",{"aria-hidden":"true",className:"text-destructive ml-0.5",children:"*"})]}),s.description&&e.jsx(le,{className:"text-xs",children:s.description})]}),e.jsx(Me,{id:o,checked:!!t,onCheckedChange:N=>a(s.key,N)})]}),s.helpMarkdown&&e.jsxs(ce,{children:[e.jsxs(de,{className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs transition-colors",children:[e.jsx(ue,{className:"size-3"}),"Where do I find this?",e.jsx(he,{className:"size-3 transition-transform [[data-state=open]_&]:rotate-180"})]}),e.jsx(pe,{children:e.jsx("div",{className:"bg-muted/50 mt-2 rounded-md border p-3",children:e.jsx(I,{content:s.helpMarkdown,className:"text-xs"})})})]}),e.jsx(K,{children:d&&e.jsx(J.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsx(me,{className:"mt-1.5",children:d})})})]});const b=()=>{var N,C;switch(s.type){case"text":case"url":return e.jsx(re,{id:o,type:s.type==="url"?"url":"text",value:h,onChange:c=>a(s.key,c.target.value),placeholder:s.placeholder,"aria-invalid":!!d||void 0,"aria-required":s.required||void 0});case"password":return x?e.jsx(xe,{id:o,value:h,showPassword:!1,onChange:c=>{a(s.key,c.target.value.trim()),i&&n("")},onFocus:()=>a(s.key,""),onBlur:y,placeholder:"Saved · type to replace"}):e.jsx(xe,{id:o,value:h,visibleByDefault:s.visibleByDefault??!1,onChange:c=>{a(s.key,c.target.value.trim()),i&&n("")},onBlur:y,onPaste:()=>setTimeout(y,0),placeholder:s.placeholder,"aria-invalid":!!d||void 0,"aria-required":s.required||void 0});case"number":return e.jsx(re,{id:o,type:"number",value:h,onChange:c=>a(s.key,c.target.value?Number(c.target.value):void 0),placeholder:s.placeholder,"aria-invalid":!!d||void 0,"aria-required":s.required||void 0});case"select":return s.displayAs==="radio-cards"?e.jsx("div",{className:"grid grid-cols-2 gap-3",role:"radiogroup","aria-labelledby":`${o}-label`,"aria-required":s.required||void 0,children:(N=s.options)==null?void 0:N.map(c=>e.jsxs("button",{type:"button",role:"radio","aria-checked":h===c.value,onClick:()=>a(s.key,c.value),className:U("hover:bg-accent/50 focus-visible:border-ring focus-visible:ring-ring flex flex-col items-start rounded-md border p-3 text-left transition outline-none focus-visible:ring-[3px]",h===c.value&&"border-primary ring-primary bg-accent/30 ring-1"),children:[e.jsx("span",{className:"text-sm font-medium",children:c.label}),c.description&&e.jsx("span",{className:"text-muted-foreground mt-1 text-xs",children:c.description})]},c.value))}):e.jsxs(X,{value:h,onValueChange:c=>a(s.key,c),children:[e.jsx(Z,{id:o,"aria-invalid":!!d||void 0,"aria-required":s.required||void 0,children:e.jsx(ee,{placeholder:s.placeholder??"Select…"})}),e.jsx(se,{children:(C=s.options)==null?void 0:C.map(c=>e.jsx(te,{value:c.value,children:c.label},c.value))})]});case"textarea":return e.jsx(We,{id:o,value:h,onChange:c=>a(s.key,c.target.value),placeholder:s.placeholder,rows:3,"aria-invalid":!!d||void 0,"aria-required":s.required||void 0});default:return null}};return e.jsxs(ie,{children:[e.jsxs(oe,{id:`${o}-label`,htmlFor:v?void 0:o,children:[s.label,s.required&&!x&&e.jsx("span",{"aria-hidden":"true",className:"text-destructive ml-0.5",children:"*"})]}),b(),s.description&&e.jsx(le,{className:"text-xs",children:s.description}),s.helpMarkdown&&e.jsxs(ce,{children:[e.jsxs(de,{className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs transition-colors",children:[e.jsx(ue,{className:"size-3"}),"Where do I find this?",e.jsx(he,{className:"size-3 transition-transform [[data-state=open]_&]:rotate-180"})]}),e.jsx(pe,{children:e.jsx("div",{className:"bg-muted/50 mt-2 rounded-md border p-3",children:e.jsx(I,{content:s.helpMarkdown,className:"text-xs"})})})]}),e.jsx(K,{children:d&&e.jsx(J.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsx(me,{children:d})})})]})}function os(s,t){return s.showWhen?t[s.showWhen.field]===s.showWhen.equals:!0}function ls({fields:s,allValues:t,renderField:a}){const r=new Map;for(const l of s){const i=l.section;r.has(i)||r.set(i,[]),r.get(i).push(l)}return e.jsx("div",{className:"space-y-6",children:Array.from(r.entries()).map(([l,i])=>{const n=i.filter(o=>os(o,t));return n.length===0?null:e.jsxs("div",{className:"space-y-3",children:[l&&e.jsx("h4",{className:"text-sm font-semibold",children:l}),e.jsx(qe,{children:e.jsx(Ee,{children:n.map(o=>a(o))})})]},l??"__default")})})}const je=["agent","configure","test","confirm"],cs={agent:"Agent",configure:"Set up",test:"Check",confirm:"Review"};function ds({current:s,showAgentStep:t}){const a=t?je:je.filter(l=>l!=="agent"),r=a.indexOf(s);return e.jsx("div",{className:"flex items-start justify-between px-1",role:"navigation","aria-label":"Setup steps",children:a.map((l,i)=>{const n=i<r,o=i===r,v=i>r;return e.jsxs(m.Fragment,{children:[i>0&&e.jsx("div",{className:U("mt-3 h-px flex-1",n||o?"bg-primary":"border-muted-foreground/40 border-t border-dashed")}),e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:U("flex size-6 items-center justify-center rounded-full text-xs font-medium",n&&"bg-primary text-primary-foreground",o&&"bg-primary text-primary-foreground ring-primary/30 ring-2",v&&"border-muted-foreground text-muted-foreground border"),"aria-current":o?"step":void 0,children:n?e.jsx($e,{className:"size-3"}):i+1}),e.jsx("span",{className:U("text-3xs",o?"text-foreground font-medium":"text-muted-foreground"),children:cs[l]})]})]},l)})})}function us({manifest:s,label:t,onLabelChange:a,fields:r,form:l,currentSetupStep:i,hasSetupGuide:n,onOpenGuide:o}){const{Subscribe:v,AppField:h}=l;return e.jsxs("div",{className:"space-y-4",children:[s.setupInstructions&&e.jsxs("div",{className:"flex gap-2 rounded-md border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-200",children:[e.jsx(Ve,{className:"mt-0.5 size-4 shrink-0"}),e.jsx(I,{content:s.setupInstructions,className:"text-sm text-blue-800 dark:text-blue-200"})]}),(s.actionButton||n)&&e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[n&&e.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:o,children:[e.jsx(Se,{className:"mr-1.5 size-3.5"}),"Setup guide"]}),s.actionButton&&e.jsx(k,{asChild:!0,type:"button",variant:"outline",size:"sm",children:e.jsx(De,{href:s.actionButton.url,children:s.actionButton.label})})]}),i&&e.jsx("h4",{className:"text-sm font-medium",children:i.title}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ae,{htmlFor:"adapter-label",children:"Name (optional)"}),e.jsx(re,{id:"adapter-label",placeholder:s.displayName,value:t,onChange:x=>a(x.target.value)}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Helps you tell this connection apart."})]}),e.jsx(v,{selector:x=>x.values,children:x=>e.jsx(ls,{fields:r,allValues:x,renderField:y=>e.jsx(h,{name:y.key,children:d=>{var b;return e.jsx(is,{field:y,value:d.state.value,onChange:(N,C)=>d.handleChange(C),onBlur:d.handleBlur,error:d.state.meta.isTouched?(b=d.state.meta.errors[0])==null?void 0:b.toString():void 0,allValues:x})}},y.key)})})]})}function hs({isPending:s,isSuccess:t,isError:a,errorMessage:r,botUsername:l,onRetry:i}){return e.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{size:"lg",className:"text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Trying to reach it…"})]}),t&&e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Pe,{className:"text-status-success size-8"}),e.jsx("p",{className:"text-status-success-fg text-sm",children:"Reachable"}),l&&e.jsx("div",{className:"flex items-center gap-2 rounded-md border px-3 py-2 text-sm",children:e.jsxs("span",{className:"font-mono",children:["@",l]})})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{className:"text-destructive size-8"}),e.jsx("p",{className:"text-destructive text-sm",children:"Not reachable"}),r&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-xs text-red-700 dark:border-red-800 dark:bg-red-950 dark:text-red-300",children:[e.jsx(Oe,{className:"mt-0.5 size-3 shrink-0"}),e.jsx("span",{children:r})]}),e.jsx(k,{variant:"outline",size:"sm",onClick:i,children:"Retry"})]})]})}function ps(s){return s.length>8?"•••• "+s.slice(-4):"•••"}function ms({manifest:s,adapterId:t,isEditMode:a,values:r,botUsername:l,agentName:i}){return e.jsxs("div",{className:"space-y-3",children:[!a&&i&&e.jsxs("p",{className:"bg-accent/30 rounded-md border px-3 py-2 text-sm",children:["Messages here go to ",e.jsx("span",{className:"font-medium",children:i}),"."]}),!a&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Connection ID"}),e.jsx("span",{className:"font-mono",children:t})]}),s.configFields.map(n=>{if(n.showWhen&&r[n.showWhen.field]!==n.showWhen.equals)return null;const o=String(r[n.key]??""),v=n.type==="password"?ps(o):o;return e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:n.label}),e.jsx("span",{className:"max-w-[200px] truncate font-mono",children:v})]},n.key)}),l&&s.type==="telegram"&&e.jsxs("a",{href:`https://t.me/${l}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary inline-flex items-center gap-1.5 text-sm underline-offset-4 hover:underline",children:["Message @",l," in Telegram"]})]})}const ye=[{value:"per-chat",label:"One shared chat per group or channel",hint:"Everyone there shares one chat with the agent."},{value:"per-user",label:"One chat per person",hint:"Each person gets their own chat, even in a group."},{value:"stateless",label:"A fresh start every message",hint:"Nothing carries over from the message before."}];function xs({agentOptions:s,agentId:t,onAgentIdChange:a,strategy:r,onStrategyChange:l}){var n;const i=s.length===1?s[0]:void 0;return m.useEffect(()=>{i&&!t&&a(i.id)},[i,t,a]),s.length===0?e.jsx("p",{role:"alert",className:"text-muted-foreground rounded-md border border-dashed px-4 py-6 text-center text-sm",children:"No agents yet. Add one from the Team page first."}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Messages here go to this agent."}),i?e.jsxs("div",{className:"bg-accent/30 rounded-md border px-4 py-3 text-sm",children:[e.jsx("span",{className:"font-medium",children:ge(i)})," will answer."]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ae,{htmlFor:"wizard-agent",children:"Who should answer?"}),e.jsxs(X,{value:t,onValueChange:a,children:[e.jsx(Z,{id:"wizard-agent",className:"w-full",children:e.jsx(ee,{placeholder:"Pick an agent"})}),e.jsx(se,{children:s.map(o=>e.jsx(te,{value:o.id,children:ge(o)},o.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ae,{htmlFor:"wizard-memory",children:"How the agent remembers"}),e.jsxs(X,{value:r,onValueChange:o=>l(o),children:[e.jsx(Z,{id:"wizard-memory",className:"w-full",children:e.jsx(ee,{})}),e.jsx(se,{children:ye.map(o=>e.jsx(te,{value:o.value,children:o.label},o.value))})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:(n=ye.find(o=>o.value===r))==null?void 0:n.hint})]})]})}function gs({open:s,onOpenChange:t,title:a,content:r}){return e.jsx(Le,{open:s,onOpenChange:t,children:e.jsxs(_e,{side:"right",className:"w-[480px] overflow-y-auto sm:max-w-lg",children:[e.jsxs(Ge,{children:[e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx(Se,{className:"size-4"}),a," setup guide"]}),e.jsx(Ie,{children:"Step-by-step setup instructions."})]}),e.jsx("div",{className:"mt-4 px-4",children:e.jsx(I,{content:r})})]})})}function we(s){const t=s.setupSteps;if(!t||t.length===0)return[];const a=new Set(t.flatMap(r=>r.fields));return s.configFields.filter(r=>!a.has(r.key))}function fs(s,t){return typeof t=="string"||t===void 0||t===null?t:s.valueShape==="id-list"?Array.isArray(t)?t.join(`
2
2
  `):t:s.valueShape==="json-object"&&typeof t=="object"?JSON.stringify(t,null,2):t}function js(s,t){const a=s.setupSteps;if(!a||a.length===0)return s.configFields;const r=a[t];if(!r)return s.configFields;const l=s.configFields.filter(i=>r.fields.includes(i.key));return t!==a.length-1?l:[...l,...we(s)]}const ys="Advanced";function Y(s){const t={};for(const[a,r]of Object.entries(s)){const l=a.split(".");let i=t;for(let n=0;n<l.length-1;n++){const o=l[n];(!(o in i)||typeof i[o]!="object"||i[o]===null)&&(i[o]={}),i=i[o]}i[l[l.length-1]]=r}return t}function ve(s,t){const a=t.split(".");let r=s;for(const l of a){if(r==null||typeof r!="object")return;r=r[l]}return r}function vs(s,t){const a={};for(const r of s.configFields){const l=t?ve(t,r.key):void 0;l!==void 0&&r.type!=="password"?a[r.key]=fs(r,l):r.type==="password"&&t&&ve(t,r.key)!==void 0?a[r.key]="***":r.default!==void 0?a[r.key]=r.default:a[r.key]=r.type==="boolean"?!1:""}return a}function bs(s,t=[]){const a=s.type;if(!t.includes(a))return a;let r=2;for(;t.includes(`${a}-${r}`);)r++;return`${a}-${r}`}function Ns({manifest:s,existingInstance:t,existingAdapterIds:a=[],onOpenChange:r}){const l=!!t,[i,n]=m.useState(t?"configure":"agent"),[o,v]=m.useState(!1),[h]=m.useState(()=>(t==null?void 0:t.id)??bs(s,a)),[x,y]=m.useState(()=>{var p;return((p=t==null?void 0:t.config)==null?void 0:p.label)??""}),[d,b]=m.useState(0),[N,C]=m.useState(""),[c,P]=m.useState(""),[M,R]=m.useState("per-chat"),E=ss(),z=ts(),S=rs(),W=ns(),{data:F}=Qe(),w=be(),q=Ne(),T=(F==null?void 0:F.agents)??[],B=s.setupSteps&&s.setupSteps.length>0,j=as({defaultValues:vs(s,t==null?void 0:t.config),validators:{onSubmit:({value:p})=>{const g={};for(const u of s.configFields)if(!(u.showWhen&&p[u.showWhen.field]!==u.showWhen.equals)&&u.required){const f=p[u.key];(f==null||f==="")&&(g[u.key]=`${u.label} is required`)}return Object.keys(g).length>0?{fields:g}:void 0}},onSubmit:async()=>{}}),$=m.useMemo(()=>{const p=new Set(we(s).map(g=>g.key));return js(s,d).map(g=>p.has(g.key)&&!g.section?{...g,section:ys}:g)},[s,d]),O=m.useCallback(()=>{const p=j.state.values;let g=!0;for(const u of $)if(!(u.showWhen&&p[u.showWhen.field]!==u.showWhen.equals)&&u.required){const f=p[u.key];(f==null||f==="")&&(j.setFieldMeta(u.key,A=>({...A,isTouched:!0,errors:[`${u.label} is required`],errorMap:{onSubmit:`${u.label} is required`}})),g=!1)}return g},[j,$]),L=m.useCallback(()=>{if(i==="agent"){if(!c)return;n("configure");return}if(i==="configure"){if(!O())return;if(B&&s.setupSteps&&d<s.setupSteps.length-1){b(u=>u+1);return}const g=j.state.values;n("test"),S.mutate({type:s.type,config:Y(g)},{onSuccess:u=>{u.botUsername&&(C(u.botUsername),x||y(`@${u.botUsername}`))}})}else i==="test"&&n("confirm")},[i,c,B,s,d,O,j,S,x]),V=m.useCallback(()=>{i==="test"?(n("configure"),S.reset()):i==="confirm"?n("test"):i==="configure"&&(B&&d>0?b(p=>p-1):l||n("agent"))},[i,B,d,S,l]),D=m.useCallback(async p=>{try{return await w.removeRelayAdapter(p),!0}catch{return!1}finally{q.invalidateQueries({queryKey:["relay"]})}},[w,q]),Q=m.useCallback(()=>{const p=j.state.values,g=Y(p),u=x?{...g,label:x}:g;if(l&&t){z.mutate({id:t.id,config:u},{onSuccess:()=>r(!1)});return}if(!c){n("agent");return}E.mutate({type:s.type,id:h,config:u},{onSuccess:()=>{W.mutate({adapterId:h,agentId:c,sessionStrategy:M,label:""},{onSuccess:()=>{var A;const f=((A=T.find(_=>_.id===c))==null?void 0:A.name)??c;G.success(`${s.displayName} is connected`,{description:`Messages here go to ${f}.`}),r(!1)},onError:f=>{n("agent"),D(h).then(A=>{A?G.error("Nothing was set up",{description:`${s.displayName} couldn’t be linked to an agent, so it wasn’t saved. ${f.message}`}):G.error("Couldn’t finish undoing",{description:`${s.displayName} was added with no agent to answer it. Remove it from Messaging. ${f.message}`})})}})},onError:f=>{var A,_,ne;(A=f.message)!=null&&A.includes("timed out")?G.error(`Couldn’t reach ${s.displayName}`,{description:"Check your token and network, then try again."}):((_=f.message)!=null&&_.includes("duplicate")||(ne=f.message)!=null&&ne.includes("exists"))&&(n("configure"),b(0))}})},[j,l,t,z,E,W,s,h,x,c,M,T,D,r]),Ce=m.useCallback(p=>{p||(n(l?"configure":"agent"),b(0),y(""),C(""),P(""),R("per-chat"),v(!1),j.reset(),S.reset()),r(p)},[r,j,S,l]),Ae=m.useCallback(()=>{S.mutate({type:s.type,config:Y(j.state.values)})},[S,s.type,j]),Fe=E.isPending||z.isPending||W.isPending,Be=B&&s.setupSteps?s.setupSteps[d]:void 0;return{step:i,isEditMode:l,adapterId:h,label:x,setLabel:y,botUsername:N,guideOpen:o,setGuideOpen:v,form:j,visibleFields:$,bindAgentId:c,setBindAgentId:P,bindStrategy:M,setBindStrategy:R,agentOptions:T,isSaving:Fe,hasSetupSteps:B,setupStepIndex:d,currentSetupStep:Be,testConnection:S,handleContinue:L,handleBack:V,handleSave:Q,handleOpenChange:Ce,handleRetryTest:Ae}}function qs({open:s,onOpenChange:t,manifest:a,existingInstance:r,existingAdapterIds:l=[]}){var L;const i=Ns({manifest:a,existingInstance:r,existingAdapterIds:l,onOpenChange:t}),{step:n,isEditMode:o,adapterId:v,label:h,setLabel:x,botUsername:y,guideOpen:d,setGuideOpen:b,form:N,visibleFields:C,bindAgentId:c,setBindAgentId:P,bindStrategy:M,setBindStrategy:R,agentOptions:E,isSaving:z,hasSetupSteps:S,setupStepIndex:W,currentSetupStep:F,testConnection:w,handleContinue:q,handleBack:T,handleSave:B,handleOpenChange:j,handleRetryTest:$}=i,O={agent:"Pick who answers messages here.",configure:(F==null?void 0:F.description)??"Fill in the settings this needs.",test:"Checking the connection…",confirm:"Check it over, then save."}[n];return e.jsxs(m.Fragment,{children:[e.jsx(He,{open:s,onOpenChange:j,children:e.jsxs(Ye,{className:"flex max-h-[85vh] max-w-lg flex-col",children:[e.jsxs(Ke,{children:[e.jsx(Je,{children:o?`Edit ${a.displayName}`:`Add ${a.displayName}`}),e.jsx(Xe,{children:O})]}),e.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto py-2",children:[e.jsx(ds,{current:n,showAgentStep:!o}),e.jsx(K,{mode:"wait",children:e.jsxs(J.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[n==="agent"&&e.jsx(xs,{agentOptions:E,agentId:c,onAgentIdChange:P,strategy:M,onStrategyChange:R}),n==="configure"&&e.jsx(us,{manifest:a,label:h,onLabelChange:x,fields:C,form:N,currentSetupStep:F,hasSetupGuide:!!a.setupGuide,onOpenGuide:()=>b(!0)}),n==="test"&&e.jsx(hs,{isPending:w.isPending,isSuccess:w.isSuccess,isError:w.isError,errorMessage:(L=w.error)==null?void 0:L.message,botUsername:y,onRetry:$}),n==="confirm"&&e.jsx(N.Subscribe,{selector:V=>V.values,children:V=>{var D;return e.jsx(ms,{manifest:a,adapterId:v,isEditMode:o,values:V,botUsername:y,agentName:((D=E.find(Q=>Q.id===c))==null?void 0:D.name)||c})}})]},n)})]}),e.jsxs(Ze,{className:"flex items-center justify-between sm:justify-between",children:[e.jsxs("div",{children:[(n==="test"||n==="confirm")&&e.jsxs(k,{variant:"ghost",onClick:T,disabled:z,children:[e.jsx(fe,{className:"mr-1 size-4"}),"Back"]}),n==="configure"&&(S?W>0:!o)&&e.jsxs(k,{variant:"ghost",onClick:T,children:[e.jsx(fe,{className:"mr-1 size-4"}),"Back"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),n==="agent"&&e.jsxs(k,{onClick:q,disabled:!c,children:["Continue",e.jsx(H,{className:"ml-1 size-4"})]}),n==="configure"&&e.jsxs(k,{onClick:q,children:["Continue",e.jsx(H,{className:"ml-1 size-4"})]}),n==="test"&&!w.isPending&&!w.isSuccess&&e.jsx(k,{variant:"ghost",onClick:q,children:"Skip"}),n==="test"&&w.isSuccess&&e.jsxs(k,{onClick:q,children:["Continue",e.jsx(H,{className:"ml-1 size-4"})]}),n==="confirm"&&e.jsxs(k,{onClick:B,disabled:z,children:[z&&e.jsx(ke,{className:"mr-2"}),o?"Save changes":"Connect"]})]})]})]})}),a.setupGuide&&e.jsx(gs,{open:d,onOpenChange:b,title:a.displayName,content:a.setupGuide})]})}export{qs as A,zs as u};
@@ -1 +1 @@
1
- import{ai as m,j as s,aj as c,ak as x,J as u,G as d}from"./index-Cga0qx1T.js";function j({agent:e,name:t,secondary:a,trailing:n,selected:i,className:r}){const{color:o,emoji:l}=m(e);return s.jsxs("div",{className:d("flex w-full min-w-0 items-center gap-2",r),children:[s.jsx(c,{color:o,emoji:l,size:"xs",className:"shrink-0"}),s.jsx("span",{className:"min-w-[8ch] flex-auto truncate text-sm font-medium",children:t??x(e)}),a!=null&&s.jsx("span",{"data-slot":"agent-option-row-secondary",className:"text-muted-foreground min-w-0 shrink truncate text-xs",children:a}),n??(i&&s.jsx(u,{className:"size-4 shrink-0","aria-hidden":!0}))]})}export{j as A};
1
+ import{ai as m,j as s,aj as c,ak as x,J as u,G as d}from"./index-C3cvP8Fo.js";function j({agent:e,name:t,secondary:a,trailing:n,selected:i,className:r}){const{color:o,emoji:l}=m(e);return s.jsxs("div",{className:d("flex w-full min-w-0 items-center gap-2",r),children:[s.jsx(c,{color:o,emoji:l,size:"xs",className:"shrink-0"}),s.jsx("span",{className:"min-w-[8ch] flex-auto truncate text-sm font-medium",children:t??x(e)}),a!=null&&s.jsx("span",{"data-slot":"agent-option-row-secondary",className:"text-muted-foreground min-w-0 shrink truncate text-xs",children:a}),n??(i&&s.jsx(u,{className:"size-4 shrink-0","aria-hidden":!0}))]})}export{j as A};
@@ -1 +1 @@
1
- import{r as l,ad as h,j as e,ae as j,af as g,ag as b,ah as v,ai as w,aj as N,ak as p,al as C,G as y,am as k}from"./index-Cga0qx1T.js";import{C as A,a as S,b as D,c as E,d as P,e as L}from"./command-CDKbyppr.js";import{A as R}from"./AgentOptionRow-BA2cDa7r.js";function u({agents:n,value:t,onSelect:a}){return e.jsxs(A,{children:[e.jsx(S,{placeholder:"Search agents…"}),e.jsxs(D,{className:"!max-h-60 !overflow-y-auto",children:[e.jsx(E,{children:"No agents found."}),e.jsx(P,{children:n.map(s=>e.jsx(L,{value:`${p(s)} ${s.name} ${s.projectPath}`,onSelect:()=>a(s.id),children:e.jsx(R,{agent:s,secondary:k(s.projectPath),selected:s.id===t})},s.id))})]})]})}function x({selectedAgent:n,open:t,onClick:a}){const s=n?w(n):null;return e.jsxs("button",{type:"button","aria-expanded":t,"aria-haspopup":"listbox",className:y("border-input ring-offset-background flex h-9 w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm shadow-xs transition-colors","focus-visible:ring-ring focus-visible:ring-1 focus-visible:outline-none","hover:bg-accent/50"),onClick:a,children:[n?e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(N,{color:s.color,emoji:s.emoji,size:"xs"}),e.jsx("span",{className:"truncate",children:p(n)})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select an agent…"}),e.jsx(C,{className:"ml-2 size-4 shrink-0 opacity-50"})]})}function $({agents:n,value:t,onValueChange:a}){const[s,o]=l.useState(!1),i=h(),c=l.useRef(null);l.useEffect(()=>{if(!s||i)return;function r(f){c.current&&!c.current.contains(f.target)&&o(!1)}return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[s,i]);const d=n.find(r=>r.id===t);function m(r){a(r===t?void 0:r),o(!1)}return n.length===0?e.jsxs("div",{className:"rounded-md border px-4 py-6 text-center",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"No agents yet"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Add one from the Team page to give it tasks."})]}):i?e.jsxs(e.Fragment,{children:[e.jsx(x,{selectedAgent:d,open:s,onClick:()=>o(!0)}),e.jsx(j,{open:s,onOpenChange:o,children:e.jsxs(g,{children:[e.jsx(b,{children:e.jsx(v,{children:"Select an agent"})}),e.jsx("div",{className:"px-4 pb-4",children:e.jsx(u,{agents:n,value:t,onSelect:m})})]})})]}):e.jsxs("div",{ref:c,className:"relative w-full",children:[e.jsx(x,{selectedAgent:d,open:s,onClick:()=>o(r=>!r)}),s&&e.jsx("div",{className:"bg-popover text-popover-foreground absolute top-full left-0 z-50 mt-1 w-full rounded-md border shadow-md",children:e.jsx(u,{agents:n,value:t,onSelect:m})})]})}export{$ as A};
1
+ import{r as l,ad as h,j as e,ae as j,af as g,ag as b,ah as v,ai as w,aj as N,ak as p,al as C,G as y,am as k}from"./index-C3cvP8Fo.js";import{C as A,a as S,b as D,c as E,d as P,e as L}from"./command-CNx4L11m.js";import{A as R}from"./AgentOptionRow-Cb34LtmH.js";function u({agents:n,value:t,onSelect:a}){return e.jsxs(A,{children:[e.jsx(S,{placeholder:"Search agents…"}),e.jsxs(D,{className:"!max-h-60 !overflow-y-auto",children:[e.jsx(E,{children:"No agents found."}),e.jsx(P,{children:n.map(s=>e.jsx(L,{value:`${p(s)} ${s.name} ${s.projectPath}`,onSelect:()=>a(s.id),children:e.jsx(R,{agent:s,secondary:k(s.projectPath),selected:s.id===t})},s.id))})]})]})}function x({selectedAgent:n,open:t,onClick:a}){const s=n?w(n):null;return e.jsxs("button",{type:"button","aria-expanded":t,"aria-haspopup":"listbox",className:y("border-input ring-offset-background flex h-9 w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm shadow-xs transition-colors","focus-visible:ring-ring focus-visible:ring-1 focus-visible:outline-none","hover:bg-accent/50"),onClick:a,children:[n?e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(N,{color:s.color,emoji:s.emoji,size:"xs"}),e.jsx("span",{className:"truncate",children:p(n)})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select an agent…"}),e.jsx(C,{className:"ml-2 size-4 shrink-0 opacity-50"})]})}function $({agents:n,value:t,onValueChange:a}){const[s,o]=l.useState(!1),i=h(),c=l.useRef(null);l.useEffect(()=>{if(!s||i)return;function r(f){c.current&&!c.current.contains(f.target)&&o(!1)}return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[s,i]);const d=n.find(r=>r.id===t);function m(r){a(r===t?void 0:r),o(!1)}return n.length===0?e.jsxs("div",{className:"rounded-md border px-4 py-6 text-center",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"No agents yet"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Add one from the Team page to give it tasks."})]}):i?e.jsxs(e.Fragment,{children:[e.jsx(x,{selectedAgent:d,open:s,onClick:()=>o(!0)}),e.jsx(j,{open:s,onOpenChange:o,children:e.jsxs(g,{children:[e.jsx(b,{children:e.jsx(v,{children:"Select an agent"})}),e.jsx("div",{className:"px-4 pb-4",children:e.jsx(u,{agents:n,value:t,onSelect:m})})]})})]}):e.jsxs("div",{ref:c,className:"relative w-full",children:[e.jsx(x,{selectedAgent:d,open:s,onClick:()=>o(r=>!r)}),s&&e.jsx("div",{className:"bg-popover text-popover-foreground absolute top-full left-0 z-50 mt-1 w-full rounded-md border shadow-md",children:e.jsx(u,{agents:n,value:t,onSelect:m})})]})}export{$ as A};
@@ -1,4 +1,4 @@
1
- import{W as Oe,a1 as J,av as De,aQ as D,a2 as ln,a3 as fe,a4 as pe,kR as ie,r as p,kS as V,kT as un,j as n,f9 as ye,B as S,kU as hn,e as z,G as O,dP as ze,O as Me,Q as We,C as gn,U as Ve,Z as mn,hR as ae,dB as ce,J as ve,k7 as Ke,k8 as ue,e1 as T,go as qe,_ as xn,a0 as Se,cv as fn,eN as pn,eO as yn,kV as he,kW as vn,i as jn,hQ as Nn,dW as Q,dX as G,dY as H,dZ as Y,d_ as W,I as ge,kX as kn,e4 as Be,e5 as Ue,gC as bn,Y as Sn,l as Cn,kY as In,T as wn}from"./index-Cga0qx1T.js";import{c as Qe,d as An,e as Ge,f as $n,g as Rn,h as En,i as _n,j as He,b as Ln,a as Fn,s as Tn}from"./access-copy-B3yNZ7Gz.js";import{u as Pn,a as On,b as Dn,c as zn,d as Mn,e as Wn}from"./use-connector-management-CLYFraXN.js";import{Q as K}from"./query-error-state-BkUdxenP.js";import{u as Vn}from"./use-bindings-Bz9YRgO7.js";import{a as Kn}from"./connection-copy--MA7AN04.js";import{u as qn,a as Bn,K as Ce}from"./KeyEntry-C2kWdN8q.js";/**
1
+ import{W as Oe,a1 as J,av as De,aQ as D,a2 as ln,a3 as fe,a4 as pe,kX as ie,r as p,kY as K,kZ as un,j as n,f9 as ye,B as S,k_ as hn,e as z,G as O,dP as ze,O as Me,Q as We,C as gn,U as Ke,Z as mn,hT as ae,dB as ce,J as ve,jY as Ve,jZ as ue,e1 as T,gS as qe,_ as xn,a0 as Se,cv as fn,eN as pn,eO as yn,k$ as he,l0 as vn,i as jn,hR as Nn,dW as Q,dX as G,dY as H,dZ as Y,d_ as W,I as ge,l1 as kn,e4 as Be,e5 as Ue,gy as bn,Y as Sn,l as Cn,l2 as In,T as wn}from"./index-C3cvP8Fo.js";import{c as Qe,d as An,e as Ge,f as $n,g as Rn,h as En,i as _n,j as He,b as Ln,a as Fn,s as Tn}from"./access-copy-Dggxx2cX.js";import{u as Pn,a as On,b as Dn,c as zn,d as Mn,e as Wn}from"./use-connector-management-5oRqzydY.js";import{Q as V}from"./query-error-state-PuLGD7Jp.js";import{u as Kn}from"./use-bindings-CU2RSXOy.js";import{a as Vn}from"./connection-copy--MA7AN04.js";import{u as qn,a as Bn,K as Ce}from"./KeyEntry-Cug8ocpX.js";/**
2
2
  * @license lucide-react v1.48.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -9,4 +9,4 @@ import{W as Oe,a1 as J,av as De,aQ as D,a2 as ln,a3 as fe,a4 as pe,kR as ie,r as
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
11
  */const Ze={name:"shield-off",size:24,node:[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]};Ze.node;const Un=Oe(Ze);function Qn(e,t=!0){const s=J();return De({queryKey:D.eventDefinitions(e??""),queryFn:({pageParam:a})=>s.listConnectionEventDefinitions(e??"",a),initialPageParam:void 0,getNextPageParam:a=>a.nextCursor,enabled:t&&!!e})}function rs(e,t=!0){const s=J();return De({queryKey:D.eventSubscriptions(e??""),queryFn:({pageParam:a})=>s.listConnectionEventSubscriptions(e??"",a),initialPageParam:void 0,getNextPageParam:a=>a.nextCursor,enabled:t&&!!e,refetchInterval:a=>{var i;return(i=a.state.data)!=null&&i.pages.some(o=>o.subscriptions.some(c=>c.state==="pending"))?2e3:!1}})}function cs(){const e=J(),t=fe();return pe({mutationFn:({connectionId:s,input:a})=>e.createConnectionEventSubscription(s,a),meta:{suppressErrorToast:!0},onSuccess:(s,{connectionId:a})=>{t.invalidateQueries({queryKey:D.eventSubscriptions(a)}),t.invalidateQueries({queryKey:D.connection(a)})}})}function ds(){const e=J(),t=fe();return pe({mutationFn:({connectionId:s,subscriptionId:a})=>e.deleteConnectionEventSubscription(s,a),meta:{suppressErrorToast:!0},onSettled:async(s,a,{connectionId:i})=>{await t.invalidateQueries({queryKey:D.eventSubscriptions(i)}),await t.invalidateQueries({queryKey:D.connection(i)})}})}function Gn(e,t){const s=J();return ln({queryKey:D.eventSource(e??""),queryFn:()=>s.getConnectionEventSource(e??""),enabled:!!e})}function Hn(){const e=J(),t=fe();return pe({mutationFn:({connectionId:s,input:a})=>e.configureConnectionEventSource(s,a),meta:{suppressErrorToast:!0},onSuccess:(s,{connectionId:a})=>{t.setQueryData(D.eventSource(a),s),t.invalidateQueries({queryKey:D.connection(a)}),t.invalidateQueries({queryKey:D.eventDefinitions(a)}),t.invalidateQueries({queryKey:D.eventSubscriptions(a)})}})}const Ie={cloud_link_required:{title:"This computer isn’t linked to DorkOS",description:"Link your DorkOS account again. Nothing changed.",action:"relink"},cloud_link_needs_update:{title:"This computer’s link needs updating",description:"Link your DorkOS account again to update it. Nothing changed.",action:"relink"},cloud_unavailable:{title:"DorkOS’s servers aren’t answering",description:"Nothing changed. Try again in a few minutes."},cloud_refused:{title:"DorkOS’s servers couldn’t finish this",description:"Nothing changed. Try again later."}};function Xe(e){const t=typeof e=="object"&&e!==null&&"code"in e?e.code:void 0;return typeof t=="string"&&Object.hasOwn(Ie,t)?Ie[t]:null}function ne(e){if(e)return e.logo??null}function q(e){return Object.fromEntries(e.agents.map(t=>{const s=e.currentGrants.find(a=>a.agentId===t.agentId);return[t.agentId,{operationRevisionIds:[...(s==null?void 0:s.operationRevisionIds)??[]].sort(),...(s==null?void 0:s.level)&&{level:s.level}}]}))}function en(e,t){const s=[...(e==null?void 0:e.operationRevisionIds)??[]].sort(),a=[...(t==null?void 0:t.operationRevisionIds)??[]].sort();return(e==null?void 0:e.level)===(t==null?void 0:t.level)&&s.length===a.length&&s.every((i,o)=>i===a[o])}function ls(e,t){const s=q(e);return e.agents.flatMap(a=>{const i=t[a.agentId];return en(s[a.agentId],i)?[]:[{agentId:a.agentId,operationRevisionIds:[...(i==null?void 0:i.operationRevisionIds)??[]].sort(),...(i==null?void 0:i.level)&&{level:i.level}}]})}const Yn=5;function P(e){var t;return(((t=e==null?void 0:e.operationRevisionIds)==null?void 0:t.length)??0)===0?"none":(e==null?void 0:e.level)??"custom"}function me(e){const t=new Set(e.filter(s=>s==="read"||s==="read-write"));return t.size===0?"read":t.size===1?[...t][0]:null}function Jn(e,{preferredAgentIds:t=[],systemAgentIds:s=[]}={}){const a=q(e),i=o=>{if(P(a[o])!=="none")return 0;const c=t.indexOf(o);return c>=0?1+c/(t.length+1):s.includes(o)?2:3};return e.agents.map((o,c)=>({agent:o,index:c,rank:i(o.agentId)})).sort((o,c)=>o.rank-c.rank||o.index-c.index).map(({agent:o})=>o)}function Zn(e,{scope:t,picked:s,level:a,levelTouched:i,allowDowngrade:o=!0}){const c=q(e),d=a?{operationRevisionIds:ie(e.candidates,a),level:a}:null,l=new Set(t),g=[],x=[],u=[];let m=!1;for(const y of e.agents){if(!l.has(y.agentId))continue;const h=c[y.agentId]??{operationRevisionIds:[]},j=P(h);let f;s.has(y.agentId)?j==="none"?(d||(m=!0),f=d??h):j==="custom"||!i||!d?f=h:j==="read-write"&&a==="read"?(f=o?d:h,o&&u.push(y.agentId)):f=d:(f={operationRevisionIds:[]},j!=="none"&&x.push(y.agentId)),en(h,f)||g.push({agentId:y.agentId,...f})}return{changes:g,removedAgentIds:x,downgradedAgentIds:u,needsLevel:m}}function Xn(e){return e.everyAgent.operationRevisionIds.length>0?"every":"picked"}function et(e,{who:t,level:s,levelTouched:a}){if(!e.everyAgent.available)return{needsLevel:!1};const i=P(e.everyAgent);if(t==="picked")return i!=="none"?{everyAgent:{operationRevisionIds:[]},needsLevel:!1}:{needsLevel:!1};if(i==="custom"&&!a)return{needsLevel:!1};if(!s)return{needsLevel:i==="none"};const o=ie(e.candidates,s);return i===s||o.length===0?{needsLevel:!1}:{everyAgent:{operationRevisionIds:o,level:s},needsLevel:!1}}function nt(e){const t=P(e.everyAgent);return t==="custom"?null:me([t])}function tt(e,t){if(t)return t==="read-write";const s=new Set(e.everyAgent.operationRevisionIds);return e.candidates.some(a=>s.has(a.operationRevisionId)&&a.capabilityClassification!=="read")}function st(e,t){if(t)return!1;const s=new Set(e.everyAgent.operationRevisionIds);return e.candidates.some(a=>s.has(a.operationRevisionId)&&a.capabilityClassification==="destructive")}function oe(e,t,s=!0){const a=P(q(e)[t]),i=s&&e.everyAgent.available?P(e.everyAgent):"none";return a==="none"?i:i==="none"?a:a==="custom"||i==="custom"?"custom":a==="read-write"||i==="read-write"?"read-write":"read"}function we(e,t){const s=a=>a.map(i=>({agentId:i.agentId,operationRevisionIds:[...i.operationRevisionIds].sort(),level:i.level??null})).sort((i,o)=>i.agentId.localeCompare(o.agentId));return JSON.stringify(s(e))===JSON.stringify(s(t))}function Ae(e,t){return e===void 0||t===void 0?e===t:JSON.stringify([...e].sort())===JSON.stringify([...t].sort())}function at({connectionId:e,active:t,onPreview:s}){const a=Pn(),i=On(),o=Qe(e,!1),[c,d]=p.useState(!1),[l,g]=p.useState(null),x=p.useRef(s);p.useEffect(()=>{x.current=s});const u=()=>{e&&(a.reset(),i.reset(),a.mutate({connectionId:e},{onSuccess:k=>{var N;return(N=x.current)==null?void 0:N.call(x,k)}}))};p.useEffect(()=>{!t||!e||u()},[t,e]);const m=a.data,y=()=>{d(!1),g(null),u()},h=(k,N,C={})=>{if(!(!m||k.length===0&&!N&&!C.confirm)){if(Date.parse(m.expiresAt)<=Date.now()){d(!0);return}i.mutate({previewId:m.previewId,grants:k,...N&&{everyAgent:N}},{onSuccess:w=>{var I;if(w.connectionId!==m.connection.connectionId||!we(k,w.grants)||!Ae(N==null?void 0:N.operationRevisionIds,(I=w.everyAgent)==null?void 0:I.operationRevisionIds)){d(!0),a.reset();return}g(w)},onError:()=>{d(!0),a.reset()}})}},j=()=>{o.refetch().then(k=>{var R,L;if(!k.data||!l||!e)return;const N=l.grants,C=N.map(b=>{var F;return{agentId:b.agentId,operationRevisionIds:((F=k.data.agents.find(A=>A.agentId===b.agentId))==null?void 0:F.operationRevisionIds)??[],...b.level&&{level:b.level}}});if(k.data.connection.connectionId!==e||l.connectionId!==e||!we(N,C)||l.everyAgent!==void 0&&!Ae(l.everyAgent.operationRevisionIds,((R=k.data.connection.everyAgent)==null?void 0:R.operationRevisionIds)??[])){d(!0),g(null),a.reset();return}const w=N.flatMap(b=>{const F=k.data.agents.find(A=>A.agentId===b.agentId);return F?[F]:[]}),I=k.data.connection.reconciliationStatus!=="ready"?k.data.connection.reconciliationStatus:((L=w.find(b=>b.reconciliationStatus!=="ready"))==null?void 0:L.reconciliationStatus)??"ready",E=[k.data.connection.authoritySync,...w.map(b=>b.authoritySync)],$=E.find(b=>b.status==="failed")??(E.some(b=>b.status==="pending")?{status:"pending"}:{status:"ready"});g({...l,reconciliationStatus:I,authoritySync:$})})},f=(l==null?void 0:l.reconciliationStatus)==="ready"&&l.authoritySync.status==="ready",v=l!==null&&l.reconciliationStatus!=="ready";return{preview:m,isLoading:a.isPending,loadFailed:a.isError,loadError:a.error,isSaving:i.isPending,needsRefresh:c,saveOutcome:l,saved:f,needsReconciliation:v,isCheckingSync:o.isFetching,syncCheckFailed:o.isError,refresh:y,apply:h,checkSync:j}}const it=6;function xe(e){return e==="read"?"look":"change"}function je(e,t){var i;const s=(i=e.displayName)==null?void 0:i.trim();return s?s.split(/\s+/u).map((o,c)=>c===0?`${o.charAt(0).toUpperCase()}${o.slice(1)}`:/[A-Z]/u.test(o.slice(1))?o:o.toLowerCase()).join(" "):un(e.operationSlug,t)}function ot(e,t){const s=new Map((t??[]).map((o,c)=>[o.operationSlug,{action:o,index:c}])),a=new Set,i=[];return e.forEach((o,c)=>{if(!o.supported)return;const d=`${o.operationSlug}
12
- ${o.capabilityClassification}`;if(a.has(d))return;a.add(d);const l=s.get(o.operationSlug);i.push({action:{operationSlug:o.operationSlug,...(l==null?void 0:l.action.displayName)!==void 0&&{displayName:l.action.displayName},capabilityClassification:o.capabilityClassification,important:(l==null?void 0:l.action.important)??!1},order:l?l.index:s.size+c})}),i.sort((o,c)=>o.order-c.order).map(({action:o})=>o)}function rt(e){return[...e.filter(t=>t.important),...e.filter(t=>!t.important)]}function ct(e,t){const s=rt(e),a=s.filter(o=>xe(o.capabilityClassification)==="look"),i=s.filter(o=>xe(o.capabilityClassification)==="change");return t===null?{look:a,change:i,addedByReadWrite:[],outsideLevels:[]}:{look:a.filter(o=>V(o.capabilityClassification,t)),change:i.filter(o=>V(o.capabilityClassification,t)),addedByReadWrite:i.filter(o=>!V(o.capabilityClassification,t)&&V(o.capabilityClassification,"read-write")),outsideLevels:i.filter(o=>!V(o.capabilityClassification,"read-write"))}}function dt(e){return e.some(t=>V(t.capabilityClassification,"read-write")&&!V(t.capabilityClassification,"read"))}function $e(e,t){const s=e.slice(0,2).map(i=>lt(je(i,t))),a=e.length-s.length;return a>0?`${s.join(", ")} and ${a} more`:s.join(" and ")}function lt(e){const t=e.split(" ")[0]??"";return/[A-Z]/u.test(t.slice(1))?e:`${e.charAt(0).toLowerCase()}${e.slice(1)}`}const re={read:"Read","read-write":"Read and write"},Re={...re,custom:"Exact actions"};function de(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const ut={gmail:"send email",outlook:"send email",slack:"send messages",googlecalendar:"change your calendar",google_calendar:"change your calendar",calendar:"change your calendar",googledrive:"change your files",google_drive:"change your files",notion:"change your pages",github:"make changes on GitHub",linear:"change your issues"};function ht(e,t,s=!1){return`Every agent, even future ones, could ${ut[e.toLowerCase()]??`make changes in ${t}`} as you${s?", including high-risk actions":""}.`}function gt({error:e,title:t,description:s,...a}){const i=Xe(e);return n.jsxs("div",{className:"space-y-2",children:[n.jsx(K,{title:(i==null?void 0:i.title)??t,description:(i==null?void 0:i.description)??s,...a}),(i==null?void 0:i.action)==="relink"&&n.jsx(nn,{variant:"outline",size:"sm"})]})}function nn(e){const t=ye();return n.jsx(S,{...e,onClick:()=>t.open("account",hn),children:"Link my DorkOS account again"})}const tn={look:"Look",change:"Change"};function mt({toolkit:e,appName:t,providerInstanceId:s,grant:a}){var u;const i=p.useId(),o=An(e,s),c=((u=o.data)==null?void 0:u.status)==="listed"?o.data:null,d=a&&a.candidates.length>0?a:null,l=(d==null?void 0:d.level)??null,g=l?`With “${re[l]}”, agents can`:`What ${t} offers agents`;let x;if(d)x=s&&o.isPending?n.jsx(Ee,{}):n.jsx(_e,{actions:ot(d.candidates,c==null?void 0:c.actions),completeness:"complete",toolkit:e,appName:t,level:l});else if(!s||xt(o.error))x=n.jsxs("p",{className:"text-muted-foreground text-sm",children:["Shows once DorkOS can reach ",t,"."]});else if(o.isPending)x=n.jsx(Ee,{});else if(o.isError){const m=Xe(o.error);x=n.jsxs("p",{className:"text-muted-foreground flex flex-wrap items-center gap-x-2 text-sm",children:[m?`${m.title}. ${m.description}`:`Couldn’t load what ${t} offers agents.`,n.jsx(S,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>void o.refetch(),disabled:o.isFetching,children:"Try again"}),(m==null?void 0:m.action)==="relink"&&n.jsx(nn,{variant:"link",size:"xs",className:"h-auto p-0"})]})}else c?x=n.jsx(_e,{actions:c.actions,completeness:c.completeness,toolkit:e,appName:t,level:null}):x=n.jsxs("p",{className:"text-muted-foreground text-sm",children:["DorkOS can’t list ",t,"’s actions. Everything agents do in ",t," counts as a change."]});return n.jsxs("section",{"aria-labelledby":i,className:"space-y-2.5","data-testid":"app-actions",children:[n.jsx("p",{id:i,className:"text-muted-foreground text-xs font-medium",children:g}),x]})}function Ee(){return n.jsxs(n.Fragment,{children:[n.jsx(z,{className:"h-16 rounded-lg"}),n.jsx("span",{className:"sr-only",children:"Loading what agents can do"})]})}function xt(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="provider_not_found"}function _e({actions:e,completeness:t,toolkit:s,appName:a,level:i}){if(e.length===0)return n.jsxs("p",{className:"text-muted-foreground text-sm",children:[a," offers no actions."]});const o=ct(e,i),c=o.outsideLevels,d=[];if(i==="read-write"&&o.change.length>0&&d.push("Pick “Read” and only Look stays."),i==="read"&&o.addedByReadWrite.length>0&&d.push(`Pick “Read and write” to also let agents ${$e(o.addedByReadWrite,s)}.`),i!==null&&c.length>0){const l=c.length>1;d.push(`${pt($e(c,s))} ${l?"aren’t":"isn’t"} part of ${dt(e)?"either level":"“Read”"}. To allow ${l?"them":"it"}, choose exact actions.`)}return t==="too_large"?d.push(`Showing the first ${e.length}. ${a} has more.`):t==="interrupted"&&d.push(`Showing the first ${e.length}. The rest didn’t load this time.`),n.jsxs("div",{className:"space-y-3",children:[o.look.length===0&&o.change.length===0?n.jsx("p",{className:"text-sm",children:"Nothing at this level."}):n.jsxs(n.Fragment,{children:[n.jsx(Le,{kind:"look",actions:o.look,toolkit:s}),n.jsx(Le,{kind:"change",actions:o.change,toolkit:s})]}),d.map(l=>n.jsx("p",{className:"text-muted-foreground text-xs",children:l},l)),n.jsx(ft,{actions:e,complete:t==="complete",toolkit:s})]})}function Le({kind:e,actions:t,toolkit:s}){if(t.length===0)return null;const a=t.slice(0,it),i=t.length-a.length;return n.jsxs("div",{className:"space-y-1.5","data-testid":`app-actions-${e}`,children:[n.jsx("p",{className:"text-sm font-medium",children:tn[e]}),n.jsxs("ul",{className:"flex flex-wrap gap-1.5",children:[a.map(o=>n.jsx("li",{className:O("rounded-full px-2.5 py-0.5 text-xs",e==="look"?"bg-muted text-foreground":ze.warning),children:je(o,s)},`${o.operationSlug}-${o.capabilityClassification}`)),i>0&&n.jsxs("li",{className:"text-muted-foreground px-1 py-0.5 text-xs",children:["+",i," more"]})]})]})}function ft({actions:e,complete:t,toolkit:s}){const a=`${e.length} ${e.length===1?"action":"actions"}`;return n.jsxs(Me,{children:[n.jsxs(We,{className:"group/all text-primary focus-ring flex items-center gap-0.5 rounded-sm text-xs font-medium hover:underline",children:[t?`See all ${a}`:`See the first ${a}`,n.jsx(gn,{className:"size-3.5 transition-transform group-data-[state=open]/all:rotate-90","aria-hidden":!0})]}),n.jsx(Ve,{children:n.jsx("ul",{className:"border-border mt-2 max-h-72 divide-y overflow-y-auto rounded-lg border","data-testid":"app-actions-all",children:e.map(i=>{const o=xe(i.capabilityClassification);return n.jsxs("li",{className:"flex items-start justify-between gap-3 px-3 py-1.5 text-sm",children:[n.jsx("span",{className:"min-w-0 break-words",children:je(i,s)}),n.jsx("span",{className:O("mt-0.5 shrink-0 rounded-full px-2 py-0 text-xs",o==="look"?"bg-muted text-muted-foreground":ze.warning),children:tn[o]})]},`${i.operationSlug}-${i.capabilityClassification}`)})})})]})}function pt(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function Z({titleId:e,toolkit:t,serviceName:s,logo:a,title:i,subtitle:o,variant:c="card",className:d,children:l}){const g=c==="embedded";return n.jsxs("section",{"aria-labelledby":e,"data-testid":"connection-access-card",className:O(g?"space-y-3":"bg-card space-y-4 rounded-xl border p-4",d),children:[n.jsxs("header",{className:"flex items-start gap-3",children:[!g&&n.jsx(mn,{iconKey:t??"",displayName:s,logo:a,className:"size-9 rounded-lg"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("h3",{id:e,className:"text-sm font-semibold",children:i}),o&&n.jsx("div",{className:"text-muted-foreground mt-0.5 text-xs",children:o})]})]}),l]})}function yt({access:e,savedDetail:t="Ready for the agents you changed."}){const{saveOutcome:s}=e,a=s==null?void 0:s.grants.some(c=>c.operationRevisionIds.length>0),i=s==null?void 0:s.grants.some(c=>c.operationRevisionIds.length===0),o=e.syncCheckFailed&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t check if the change is done. Nothing was sent twice."});return e.needsRefresh?n.jsxs("div",{className:"border-destructive/30 bg-destructive/5 space-y-3 rounded-lg border p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(ae,{className:"text-destructive mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{children:[n.jsx("p",{role:"alert",className:"text-sm font-medium",children:"Couldn’t confirm access was saved"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Reload access before another change."})]})]}),n.jsxs(S,{size:"sm",variant:"secondary",className:"h-auto min-h-9 whitespace-normal",onClick:e.refresh,children:[n.jsx(ce,{className:"size-4","aria-hidden":!0}),"Reload current access"]})]}):e.saved?n.jsxs("div",{className:"border-status-success/30 bg-status-success/5 flex items-start gap-3 rounded-lg border p-4",children:[n.jsx(ve,{className:"text-status-success mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{children:[n.jsx("p",{"data-testid":"connector-access-outcome",className:"text-sm font-medium",children:"Access updated"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:t})]})]}):e.needsReconciliation?n.jsxs("div",{className:"border-status-warning/30 bg-status-warning/5 flex items-start gap-3 rounded-lg border p-4",children:[n.jsx(ae,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{children:[n.jsx("p",{"data-testid":"connector-access-outcome",className:"text-sm font-medium",children:"Access needs review"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Available actions changed. Reload access before another change."})]})]}):(s==null?void 0:s.authoritySync.status)==="pending"?n.jsxs("div",{className:"border-status-warning/30 bg-status-warning/5 space-y-3 rounded-lg border p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(Je,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{children:[n.jsx("p",{"data-testid":"connector-access-outcome",className:"text-sm font-medium",children:"Access update pending"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:a&&i?"Removed access has ended. New access works once DorkOS finishes.":i?"Removed access has ended here. DorkOS is still removing it at the service.":"New access is saved. It works once DorkOS finishes."})]})]}),o]}):(s==null?void 0:s.authoritySync.status)==="failed"?n.jsxs("div",{className:"border-destructive/30 bg-destructive/5 space-y-3 rounded-lg border p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(ae,{className:"text-destructive mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{children:[n.jsx("p",{"data-testid":"connector-access-outcome",role:"alert",className:"text-sm font-medium",children:"Access didn’t update"}),n.jsxs("p",{className:"text-muted-foreground mt-1 text-sm",children:[s.authoritySync.reason," Agents can’t use this yet. Check your account, then try again."]})]})]}),o]}):null}function sn(e,t){return e.filter(s=>s.toolkit===t&&(s.readiness.state==="ready"||s.readiness.reason==="access_updating"))}function vt({props:e,renderAccess:t}){var m;const s=p.useId(),a=Ge(),i=sn(((m=a.data)==null?void 0:m.connections)??[],e.toolkit),[o,c]=p.useState(null),[d,l]=p.useState(null),g=i.length===1?i[0].connectionId:null,x=d??(g?{id:g,picked:!1}:null);if(p.useEffect(()=>{!d&&g&&l({id:g,picked:!1})},[d,g]),x)return t(x.id,x.picked?()=>l(null):void 0);const u=`Which ${e.serviceName} account?`;return n.jsxs(Z,{titleId:s,toolkit:e.toolkit,serviceName:e.serviceName,logo:e.logo,title:u,className:e.className,children:[a.isPending?n.jsx(z,{className:"h-16 rounded-lg","aria-label":"Loading accounts"}):a.isError?n.jsx(K,{title:"Couldn’t load your accounts",description:"Nothing changed. Try again.",onRetry:()=>void a.refetch(),isRetrying:a.isFetching}):i.length===0?n.jsxs("p",{className:"text-muted-foreground text-sm",children:["No ",e.serviceName," account is ready yet."]}):n.jsx(Ke,{"aria-labelledby":s,value:o??"",onValueChange:c,className:"gap-2",children:i.map(y=>{const h=`${s}-${y.connectionId}`;return n.jsxs("div",{className:"bg-muted/40 flex min-h-11 items-center gap-3 rounded-lg px-3",children:[n.jsx(ue,{id:h,value:y.connectionId}),n.jsxs(T,{htmlFor:h,className:"min-w-0 flex-1 cursor-pointer flex-col items-start gap-0.5 py-2 leading-snug font-normal",children:[n.jsx("span",{className:"block max-w-full truncate text-sm font-medium",children:y.label}),y.identityHint&&n.jsx("span",{className:"text-muted-foreground block max-w-full truncate text-xs",children:y.identityHint})]})]},y.connectionId)})}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.onSkip&&n.jsx(S,{variant:"ghost",onClick:e.onSkip,children:"Not now"}),i.length>1&&n.jsx(S,{disabled:!o,onClick:()=>o&&l({id:o,picked:!0}),children:"Continue"})]})]})}function jt({preview:e,serviceName:t,preferredAgentIds:s,systemAgentIds:a,picked:i,setPicked:o,decision:c,showAll:d,setShowAll:l}){const g=p.useId(),x=q(e),u=Jn(e,{preferredAgentIds:s,systemAgentIds:a}),m=d?u:u.filter((h,j)=>j<Yn||i.has(h.agentId)||P(x[h.agentId])!=="none"),y=h=>{var j;return(j=e.agents.find(f=>f.agentId===h))==null?void 0:j.displayName};return n.jsxs("fieldset",{className:"space-y-1",children:[n.jsxs("legend",{className:"sr-only",children:["Agents that can use ",t]}),m.map(h=>{const j=`${g}-${h.agentId}`,f=P(x[h.agentId]),v=c.removedAgentIds.includes(h.agentId)||c.downgradedAgentIds.includes(h.agentId);return n.jsxs("div",{className:"hover:bg-muted/60 flex min-h-11 items-center gap-3 rounded-md px-2",children:[n.jsx(qe,{id:j,"aria-describedby":v?`${j}-loss`:void 0,checked:i.has(h.agentId),onCheckedChange:k=>{const N=new Set(i);k===!0?N.add(h.agentId):N.delete(h.agentId),o(N)}}),n.jsx(T,{htmlFor:j,className:"min-w-0 flex-1 cursor-pointer py-2 font-normal",children:n.jsx("span",{className:"truncate",children:h.displayName})}),f!=="none"&&n.jsx(xn,{size:"xs",variant:"secondary","aria-label":`Now: ${Re[f]}`,children:Re[f]})]},h.agentId)}),m.length<u.length&&n.jsxs(S,{variant:"ghost",size:"sm",onClick:()=>l(!0),children:["Show all ",u.length]}),n.jsxs("div",{"aria-live":"polite",className:"space-y-1",children:[c.removedAgentIds.map(h=>n.jsxs("p",{id:`${g}-${h}-loss`,className:"text-foreground flex items-start gap-1.5 px-2 text-xs",children:[n.jsx(Se,{className:"text-status-warning-dot mt-0.5 size-3 shrink-0","aria-hidden":!0}),y(h)," will lose access to ",t,"."]},h)),c.downgradedAgentIds.map(h=>n.jsxs("p",{id:`${g}-${h}-loss`,className:"text-foreground flex items-start gap-1.5 px-2 text-xs",children:[n.jsx(Se,{className:"text-status-warning-dot mt-0.5 size-3 shrink-0","aria-hidden":!0}),y(h)," will lose write access."]},h))]})]})}function Nt({preview:e,level:t,serviceName:s}){return tt(e,t)?n.jsxs("p",{role:"note","data-testid":"every-agent-warning",className:"border-status-warning-border bg-status-warning-bg text-foreground flex items-start gap-2 rounded-lg border px-3 py-2 text-xs",children:[n.jsx(ae,{className:"text-status-warning-dot mt-0.5 size-3.5 shrink-0","aria-hidden":!0}),ht(e.connection.toolkit,s,st(e,t))]}):null}const kt={read:e=>`It wants to read ${e}.`,"read-write":e=>`It wants to read and change things in ${e}.`};function bt({agentName:e,serviceName:t,reason:s,access:a,level:i}){return n.jsxs("div",{className:"bg-muted/40 space-y-1.5 rounded-lg p-3 text-sm","data-testid":"requested-access",children:[n.jsxs("p",{children:[n.jsxs("span",{className:"text-muted-foreground",children:[e," asked: "]}),s]}),n.jsx("p",{className:"text-muted-foreground text-xs",children:kt[a](t)}),a==="read-write"&&i==="read"&&n.jsxs("p",{className:"text-xs",role:"status",children:["With Read, ",e," can’t change ",t,"."]})]})}function Fe(e,t,s){return t==="read-write"?`${e} can read and write in ${s}.`:`${e} can read ${s}.`}function St(e){var x;const{preview:t,serviceName:s,decision:a,level:i}=e,o=u=>{var m;return((m=t.agents.find(y=>y.agentId===u))==null?void 0:m.displayName)??"The agent"};if(e.mode==="agent")return Fe(o(e.agentId??""),i,s);if(e.who==="every")return Fe("Every agent",i,s);const c=t.agents.filter(u=>e.picked.has(u.agentId)).map(u=>u.displayName),d=[c.length>0?`${de(c)} can use ${s}.`:`No agent can use ${s}.`];((x=e.every.everyAgent)==null?void 0:x.operationRevisionIds.length)===0&&d.push(`${s} is no longer shared with every agent.`);const l=a.downgradedAgentIds.map(o);l.length>0&&d.push(`${de(l)} can now only read.`);const g=a.removedAgentIds.map(o);return g.length>0&&d.push(`${de(g)} can no longer use it.`),d.join(" ")}function Ct({connectionId:e,serviceName:t}){var i;const s=Qe(e,!0),a=Dn();return a.isSuccess?n.jsxs("p",{role:"status",className:"text-sm",children:["Stopped sharing ",t," with every agent."]}):(i=s.data)!=null&&i.connection.everyAgent?n.jsxs("div",{className:"bg-muted/40 flex flex-wrap items-center justify-between gap-2 rounded-lg p-3 text-sm",children:[n.jsxs("span",{children:["Every agent can use ",t," now."]}),n.jsx(S,{size:"sm",variant:"secondary",disabled:a.isPending,onClick:()=>a.mutate({connectionId:e}),children:"Stop sharing with every agent"}),a.isError&&n.jsx("p",{role:"alert",className:"text-destructive w-full text-xs",children:"Couldn’t stop sharing. Try again."})]}):null}function It({value:e,onChange:t,everyAgentAvailable:s}){const a=p.useId();return n.jsxs(Ke,{value:e,onValueChange:i=>t(i),"aria-label":"Who can use it",className:"gap-1.5",children:[n.jsxs("div",{className:"flex min-h-11 items-center gap-3 rounded-md px-2",children:[n.jsx(ue,{value:"picked",id:`${a}-picked`}),n.jsx(T,{htmlFor:`${a}-picked`,className:"flex-1 cursor-pointer py-2 font-normal",children:"Only agents you pick"})]}),n.jsxs("div",{className:"flex min-h-11 items-start gap-3 rounded-md px-2 py-2",children:[n.jsx(ue,{value:"every",id:`${a}-every`,disabled:!s,"aria-describedby":s?void 0:`${a}-every-unavailable`,className:"mt-0.5"}),n.jsxs(T,{htmlFor:`${a}-every`,className:"flex-1 cursor-pointer flex-col items-start gap-0.5 font-normal",children:[n.jsx("span",{children:"Every agent"}),n.jsx("span",{className:"text-muted-foreground text-xs",children:"Including agents you add later"}),!s&&n.jsx("span",{id:`${a}-every-unavailable`,className:"text-muted-foreground text-xs",children:"Not available here. Pick agents one by one."})]})]})]})}function wt(e){return e.mode==="agent"&&!e.connectionId?n.jsx(vt,{props:e,renderAccess:(t,s)=>n.jsx(Te,{...e,connectionId:t,onChangeAccount:s},t)}):n.jsx(Te,{...e,connectionId:e.connectionId},e.connectionId)}function Te(e){var F;const t=p.useId(),[s,a]=p.useState(new Set),[i,o]=p.useState("read"),[c,d]=p.useState("picked"),[l,g]=p.useState(!1),[x,u]=p.useState(!1),m=p.useRef(e.mode==="page"?e.startWho:void 0),{data:y}=fn(void 0,e.mode==="page"),[h,j]=p.useState(null),f=at({connectionId:e.connectionId,active:!0,onPreview:A=>{j(A.connection);const B=q(A),te=e.mode==="agent"?[e.agentId]:A.agents.map(M=>M.agentId).filter(M=>P(B[M])!=="none");a(new Set(e.mode==="agent"?[e.agentId]:te));const X=e.mode==="page"?m.current??Xn(A):"picked";m.current=void 0,d(X);const ee=X==="every"?nt(A):e.mode==="agent"?me([oe(A,e.agentId,!!e.onAllowed)]):me(te.map(M=>P(B[M]))),se=e.mode==="agent"&&e.request?e.request.access:null;o(se==="read-write"||ee==="read-write"?"read-write":ee),g(!1)}}),{preview:v}=f,k=e.mode==="agent"?e.agentId:null,N=p.useMemo(()=>v?Zn(v,{scope:k?[k]:c==="every"?[]:v.agents.map(A=>A.agentId),picked:s,level:i,levelTouched:k!==null||l,allowDowngrade:k===null}):{changes:[],removedAgentIds:[],downgradedAgentIds:[],needsLevel:!1},[v,s,i,l,k,c]),C=p.useMemo(()=>v&&k===null?et(v,{who:c,level:i,levelTouched:l}):{needsLevel:!1},[v,k,c,i,l]),w=v&&k?oe(v,k,e.mode==="agent"&&!!e.onAllowed):"none",I=e.mode==="agent"?e.onAllowed:void 0,E=I!==void 0&&v!==void 0&&(N.changes.length===0||w===i||w==="read-write")&&!N.needsLevel&&w!=="none"&&v.agents.some(A=>A.agentId===k),r=p.useRef(!1);p.useEffect(()=>{!f.saved||!I||r.current||(r.current=!0,I(e.connectionId))},[f.saveOutcome,f.saved,I,e.connectionId]);const $=e.mode==="agent"?(F=v==null?void 0:v.agents.find(A=>A.agentId===e.agentId))==null?void 0:F.displayName:void 0,R=e.mode==="page"?`Who can use ${e.serviceName}?`:`Let ${$??"this agent"} use ${e.serviceName}?`,L=f.needsRefresh||f.saveOutcome!==null,b=(h||e.onChangeAccount)&&n.jsxs("span",{className:"flex flex-wrap items-center gap-x-2",children:[h&&n.jsx("span",{className:"truncate",children:h.label}),e.onChangeAccount&&!L&&n.jsx(S,{variant:"link",size:"xs",className:"h-auto p-0",onClick:e.onChangeAccount,children:"Change account"})]});return n.jsxs(Z,{titleId:t,toolkit:(h==null?void 0:h.toolkit)??(e.mode==="agent"?e.toolkit:void 0),serviceName:e.serviceName,logo:e.logo,title:R,subtitle:e.variant==="embedded"?void 0:b,variant:e.variant,className:e.className,children:[f.isLoading?n.jsxs("div",{className:"space-y-2","aria-label":"Loading access",children:[n.jsx(z,{className:"h-10 rounded-lg"}),n.jsx(z,{className:"h-8 rounded-lg"})]}):f.loadFailed?n.jsxs("div",{className:"space-y-2",children:[n.jsx(gt,{error:f.loadError,title:"Couldn’t load who can use it",description:"Nothing changed. Try again.",onRetry:f.refresh,isRetrying:f.isLoading}),e.mode==="page"&&n.jsx(Ct,{connectionId:e.connectionId,serviceName:e.serviceName}),e.onEditExactActions&&n.jsx(an,{onClick:()=>{var A;return(A=e.onEditExactActions)==null?void 0:A.call(e,e.connectionId)}})]}):L?n.jsx(yt,{access:f,savedDetail:v?St({mode:e.mode,...e.mode==="agent"&&{agentId:e.agentId},serviceName:e.serviceName,preview:v,picked:s,level:i,decision:N,who:c,every:C}):void 0}):v?n.jsx(At,{props:e,preview:v,picked:s,setPicked:a,who:c,setWho:d,decision:N,level:i,setLevel:A=>{o(A),g(!0)},showAll:x,setShowAll:u,systemAgentIds:((y==null?void 0:y.agents)??[]).filter(A=>A.isSystem).map(A=>A.id)}):null,n.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[f.needsReconciliation?n.jsx(S,{variant:"secondary",onClick:f.refresh,children:"Reload current access"}):f.saveOutcome&&!f.saved?n.jsxs(S,{variant:"secondary",onClick:f.checkSync,disabled:f.isCheckingSync,children:[n.jsx(ce,{className:"size-4","aria-hidden":!0}),f.isCheckingSync?"Checking…":"Check if it’s done"]}):null,L?e.onFinished?n.jsx(S,{variant:f.saved?"default":"ghost",onClick:e.onFinished,children:f.saved?"Done":"Close"}):f.saveOutcome&&n.jsx(S,{variant:"ghost",onClick:f.refresh,children:"Edit again"}):v&&n.jsxs(n.Fragment,{children:[e.onSkip&&n.jsx(S,{variant:"ghost",onClick:e.onSkip,children:e.mode==="page"?"Skip":"Not now"}),n.jsx(S,{onClick:()=>E?I==null?void 0:I(e.connectionId):f.apply(N.changes,C.everyAgent),disabled:!E&&(N.changes.length===0&&!C.everyAgent||N.needsLevel||C.needsLevel||f.isSaving),children:f.isSaving?"Saving…":e.mode==="page"?"Save":"Allow"})]})]})]})}function At({props:e,preview:t,picked:s,setPicked:a,who:i,setWho:o,decision:c,level:d,setLevel:l,showAll:g,setShowAll:x,systemAgentIds:u}){var E;const m=p.useId(),y=q(t),h=ie(t.candidates,"read"),j=ie(t.candidates,"read-write"),f=j.length>h.length?["read","read-write"]:["read"],v=e.mode==="agent"&&oe(t,e.agentId,!!e.onAllowed)==="read-write"?f.filter(r=>r==="read-write"):f,k=j.length===0,N=e.onEditExactActions&&n.jsx(an,{onClick:()=>{var r;return(r=e.onEditExactActions)==null?void 0:r.call(e,e.connectionId)}});let C;if(e.mode==="agent"){const r=t.agents.find(b=>b.agentId===e.agentId),$=P(y[e.agentId]),R=oe(t,e.agentId,!!e.onAllowed);C=r?$==="custom"?n.jsxs("p",{className:"text-muted-foreground text-sm",children:[r.displayName," already has exact actions here."," ",e.onEditExactActions?"Choose exact actions to change them.":"Change them on the Connections page."]}):$===d?n.jsxs("p",{className:"text-muted-foreground text-sm",children:[r.displayName," can already do this."]}):R===d||R==="read-write"&&d==="read"?n.jsxs("p",{className:"text-muted-foreground text-sm",children:[r.displayName," already can, like every agent."]}):null:n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"This agent isn’t registered here, so it can’t get access."})}else i==="every"?C=null:t.agents.length===0?C=n.jsx("p",{className:"text-muted-foreground text-sm",children:"No agents yet. Add one first."}):C=n.jsx(jt,{preview:t,serviceName:e.serviceName,preferredAgentIds:e.preferredAgentIds,systemAgentIds:u,picked:s,setPicked:a,decision:c,showAll:g,setShowAll:x});const w=e.mode==="agent"&&!t.agents.some(r=>r.agentId===e.agentId),I=e.mode==="agent"&&P(y[e.agentId])==="custom";return n.jsxs("div",{className:"space-y-4",children:[e.mode==="page"&&n.jsx(It,{value:i,onChange:o,everyAgentAvailable:t.everyAgent.available}),e.mode==="agent"&&e.request&&n.jsx(bt,{agentName:((E=t.agents.find(r=>r.agentId===e.agentId))==null?void 0:E.displayName)??"The agent",serviceName:e.serviceName,reason:e.request.reason,access:e.request.access,level:d}),C,k?n.jsxs("p",{className:"text-muted-foreground text-sm",children:[e.serviceName," has no actions for agents yet."]}):!w&&!I&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("p",{id:`${m}-level`,className:"text-muted-foreground text-xs font-medium",children:e.mode==="page"?"They can":"It can"}),v.length>1?n.jsx(pn,{"aria-labelledby":`${m}-level`,value:d??"",onValueChange:r=>l(r),children:v.map(r=>n.jsx(yn,{value:r,className:"min-h-9",children:re[r]},r))}):n.jsx("p",{className:"text-sm",children:re[v[0]]}),d===null&&n.jsx("p",{className:"text-muted-foreground text-xs",children:i==="every"?t.everyAgent.operationRevisionIds.length>0?"Every agent has exact actions now. Pick a level to replace them.":"Pick what every agent can do.":"Your agents have different access. Pick one for every ticked agent."}),e.mode==="page"&&i==="every"&&n.jsx(Nt,{preview:t,level:d,serviceName:e.serviceName})]}),e.mode==="page"&&e.appActions&&n.jsx(mt,{toolkit:e.appActions.toolkit,appName:e.serviceName,providerInstanceId:e.appActions.providerInstanceId,grant:{candidates:t.candidates,level:k?null:d}}),(e.mode==="page"||N)&&n.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center justify-between gap-2 text-xs",children:[e.mode==="page"&&i==="picked"&&n.jsx("span",{children:"Others can still ask you in chat."}),N]})]})}function an({onClick:e}){return n.jsx(S,{variant:"link",size:"xs",className:"h-auto p-0",onClick:e,children:"Choose exact actions"})}function le(e=""){return{definitionId:"",agentId:e,destinationKind:"agent",destinationId:"",filterValues:{}}}function $t(e){if(e.deliveryMode==="webhook")return"Sent the moment it happens";if(e.deliveryMode==="unknown")return"Delivery timing unknown";if(e.expectedCadenceSeconds===null)return"Check timing unknown";if(e.expectedCadenceSeconds<60)return`Checks about every ${e.expectedCadenceSeconds} seconds`;const t=Math.round(e.expectedCadenceSeconds/60);return`Checks about every ${t} ${t===1?"minute":"minutes"}`}function Rt({connectionId:e,definitions:t,draft:s}){const a=t.find(d=>d.id===s.definitionId);if(!a||!s.agentId)return null;const i=he(a.filterSchema);if(!i)return null;const o=vn(i,s.filterValues);if(!o)return null;const c=s.destinationKind==="agent"?s.agentId:s.destinationId;return c?{connectionId:e,definitionId:a.id,filter:o,agentId:s.agentId,destination:{kind:s.destinationKind,id:c}}:null}function Et({idPrefix:e,definitions:t,draft:s,onChange:a,agents:i,fixedAgent:o,sourceStatus:c}){var I,E;const d=(o==null?void 0:o.id)??s.agentId,l=t.find(r=>r.id===s.definitionId),g=l?he(l.filterSchema):[],x=jn(d||null,{enabled:s.destinationKind==="room"}),u=Vn(),m=Nn(s.destinationKind==="channel"),y=p.useMemo(()=>new Set((m.data??[]).filter(r=>r.config.enabled).map(r=>r.config.id)),[m.data]),h=p.useMemo(()=>(u.data??[]).filter(r=>r.agentId===d&&r.enabled&&r.canInitiate&&!!r.chatId&&y.has(r.adapterId)),[d,u.data,y]),j=r=>{a({...s,...r,...o?{agentId:o.id}:{}})},f=r=>{if(r===s.definitionId)return;const $=t.find(L=>L.id===r),R=$?he($.filterSchema):[];j({definitionId:r,filterValues:kn(R??[])})},v=`${e}-event`,k=`${e}-agent`,N=`${e}-destination-kind`,C=`${e}-room`,w=`${e}-channel`;return n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(T,{htmlFor:v,children:"Account activity"}),n.jsxs(Q,{value:s.definitionId,onValueChange:f,children:[n.jsx(G,{id:v,"aria-label":"Account activity",children:n.jsx(H,{placeholder:"Choose activity"})}),n.jsx(Y,{children:t.map(r=>n.jsx(W,{value:r.id,children:r.displayName},r.id))})]}),l&&n.jsx("p",{className:"text-muted-foreground text-xs",children:$t(l)})]}),n.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[n.jsx("div",{className:"space-y-1",children:o?n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Agent"}),n.jsx("p",{id:k,className:"bg-muted/40 mt-1 rounded-md px-3 py-2 text-sm",children:o.displayName})]}):n.jsxs(n.Fragment,{children:[n.jsx(T,{htmlFor:k,children:"Agent"}),n.jsxs(Q,{value:s.agentId,onValueChange:r=>j({agentId:r,destinationId:""}),children:[n.jsx(G,{id:k,"aria-label":"Agent",children:n.jsx(H,{placeholder:"Choose agent"})}),n.jsx(Y,{children:(i??[]).map(r=>n.jsx(W,{value:r.id,children:r.displayName},r.id))})]})]})}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(T,{htmlFor:N,children:"Send to"}),n.jsxs(Q,{value:s.destinationKind,onValueChange:r=>j({destinationKind:r,destinationId:""}),children:[n.jsx(G,{id:N,"aria-label":"Send to",children:n.jsx(H,{})}),n.jsxs(Y,{children:[n.jsx(W,{value:"agent",children:"Agent"}),n.jsx(W,{value:"room",children:"Room"}),n.jsx(W,{value:"channel",children:"Messaging channel"})]})]})]})]}),s.destinationKind==="room"&&d&&n.jsxs("div",{className:"space-y-1",children:[n.jsx(T,{htmlFor:C,children:"Room"}),n.jsxs(Q,{value:s.destinationId,onValueChange:r=>j({destinationId:r}),children:[n.jsx(G,{id:C,"aria-label":"Room",children:n.jsx(H,{placeholder:"Choose a room"})}),n.jsx(Y,{children:(((I=x.data)==null?void 0:I.rooms)??[]).map(r=>n.jsx(W,{value:r.id,children:r.slug?`#${r.slug}`:r.name},r.id))})]}),x.isError?n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t load this agent’s rooms."}),n.jsx(S,{type:"button",size:"sm",variant:"ghost",onClick:()=>void x.refetch(),children:"Try again"})]}):!x.isPending&&(((E=x.data)==null?void 0:E.rooms.length)??0)===0?n.jsx("p",{className:"text-muted-foreground text-xs",children:"This agent isn’t in any rooms."}):null]}),s.destinationKind==="channel"&&d&&n.jsxs("div",{className:"space-y-1",children:[n.jsx(T,{htmlFor:w,children:"Messaging channel"}),n.jsxs(Q,{value:s.destinationId,onValueChange:r=>j({destinationId:r}),children:[n.jsx(G,{id:w,"aria-label":"Messaging channel",children:n.jsx(H,{placeholder:"Choose a channel"})}),n.jsx(Y,{children:h.map(r=>n.jsx(W,{value:r.id,children:r.label||r.chatId},r.id))})]}),u.isError||m.isError?n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t load this agent’s messaging channels."}),n.jsx(S,{type:"button",size:"sm",variant:"ghost",onClick:()=>{u.refetch(),m.refetch()},children:"Try again"})]}):!u.isPending&&!m.isPending&&h.length===0?n.jsx("p",{className:"text-muted-foreground text-xs",children:"No channels this agent can start."}):null]}),l&&g===null&&n.jsx("p",{role:"alert",className:"text-muted-foreground rounded-md border p-3 text-sm",children:"This notification’s filters can’t be shown yet."}),(l==null?void 0:l.deliveryMode)==="unknown"&&n.jsx("p",{className:"text-muted-foreground rounded-md border p-3 text-sm",children:"This service hasn’t shared its timing. Setup may stay pending."}),(c==null?void 0:c.setupMode)==="byo_webhook"&&!c.configured&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"Save delivery setup above first."}),g==null?void 0:g.map(r=>{var L;const $=`${e}-filter-${r.name}`,R=(L=r.examples)!=null&&L.length?`${$}-examples`:void 0;return n.jsxs("div",{className:"space-y-1",children:[r.type==="boolean"?n.jsxs("div",{className:"flex min-h-11 items-center gap-2",children:[n.jsx(qe,{id:$,"aria-describedby":R,checked:s.filterValues[r.name]===!0,onCheckedChange:b=>j({filterValues:{...s.filterValues,[r.name]:b===!0}})}),n.jsx(T,{htmlFor:$,children:r.label})]}):r.options?n.jsxs(n.Fragment,{children:[n.jsx(T,{htmlFor:$,children:r.label}),n.jsxs(Q,{value:typeof s.filterValues[r.name]=="string"?String(r.options.indexOf(String(s.filterValues[r.name]))):"",onValueChange:b=>j({filterValues:{...s.filterValues,[r.name]:r.options[Number(b)]}}),children:[n.jsx(G,{id:$,"aria-label":r.label,"aria-describedby":R,children:n.jsx(H,{placeholder:`Choose ${r.label.toLowerCase()}`})}),n.jsx(Y,{children:r.options.map((b,F)=>n.jsx(W,{value:String(F),children:b===""?"Leave blank":b},b))})]})]}):n.jsxs(n.Fragment,{children:[n.jsx(T,{htmlFor:$,children:r.label}),n.jsx(ge,{id:$,type:r.type==="string"?"text":"number","aria-describedby":R,required:(r.required||r.defaultValue!==void 0)&&r.type!=="string",step:r.type==="integer"?1:"any",value:typeof s.filterValues[r.name]=="string"?String(s.filterValues[r.name]):"",onChange:b=>j({filterValues:{...s.filterValues,[r.name]:b.target.value}})})]}),R&&n.jsxs("p",{id:R,className:"text-muted-foreground text-xs break-words",children:["Examples (not selected):"," ",r.examples.map(b=>JSON.stringify(b)).join(", ")]})]},r.name)})]})}function _t(e){try{const t=new URL(e);return t.protocol==="https:"&&t.username===""&&t.password===""&&t.pathname==="/"&&t.search===""&&t.hash===""}catch{return!1}}function Lt(e){return e.setupMode==="managed"||e.setupMode==="byo_webhook"&&e.configured}function Ft({connectionId:e,status:t,idPrefix:s="notification"}){const a=Hn(),[i,o]=p.useState(""),[c,d]=p.useState(""),l=a.data??t;if(l.setupMode==="managed")return null;if(l.setupMode==="unavailable")return n.jsx("p",{className:"text-muted-foreground bg-muted/40 rounded-lg p-3 text-sm",children:l.reason??"Notification setup isn’t available for this account."});const g=`${s}-public-origin`,x=`${s}-webhook-secret`;return n.jsxs("div",{className:"space-y-3 rounded-lg border p-3","data-testid":"notification-source-setup",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Service delivery"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Add your public DorkOS address and Composio’s signing secret."}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"The secret is sent once and never shown again."})]}),l.configured&&l.endpoint&&n.jsxs("div",{className:"bg-muted/40 rounded-md p-2.5",children:[n.jsx("p",{className:"text-muted-foreground text-xs",children:"Webhook endpoint"}),n.jsx("p",{className:"mt-1 font-mono text-xs break-all",children:l.endpoint})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(T,{htmlFor:g,children:"Public DorkOS address"}),n.jsx(ge,{id:g,type:"url",placeholder:"https://your-dorkos.example",value:i,onChange:u=>o(u.target.value)})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(T,{htmlFor:x,children:"Signing secret"}),n.jsx(ge,{id:x,type:"password",autoComplete:"off",value:c,onChange:u=>d(u.target.value)})]}),a.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t save delivery setup. Enter the signing secret again."}),n.jsx(S,{type:"button",size:"sm",variant:"secondary",disabled:a.isPending||c.length<16||!_t(i.trim()),onClick:()=>{const u=c;d(""),a.mutate({connectionId:e,input:{publicOrigin:i.trim(),webhookSecret:u}})},children:a.isPending?"Saving…":l.configured?"Update setup":"Save setup"})]})}function Tt(e){return(e.split(".").at(-1)??e).replaceAll("_"," ").replace(/\b\w/g,s=>s.toUpperCase())}function Pt({connectionId:e,requestedEvents:t,agent:s,onChange:a}){const i=Qn(e),o=Gn(e),c=p.useMemo(()=>[...new Set(t)],[t]),[d,l]=p.useState(()=>Object.fromEntries(c.map(u=>[u,le(s.id)]))),g=p.useMemo(()=>{var u;return((u=i.data)==null?void 0:u.pages.flatMap(m=>m.definitions))??[]},[i.data]),x=p.useMemo(()=>{if(!o.data||!Lt(o.data))return null;const u=c.map(m=>Rt({connectionId:e,definitions:g.filter(y=>y.eventType===m),draft:d[m]??le(s.id)}));return u.every(m=>m!==null)?u:null},[s.id,e,g,d,c,o.data]);return p.useEffect(()=>a(x),[a,x]),n.jsxs("fieldset",{className:"space-y-3","data-testid":"agent-request-event-scopes",children:[n.jsx("legend",{className:"text-sm font-medium",children:"Notifications"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Pick where this agent gets each kind of activity."}),o.isPending?n.jsx(z,{className:"h-20 rounded-lg","aria-label":"Loading delivery setup"}):o.isError?n.jsx(K,{title:"Couldn’t load delivery setup",description:"No access changed. Try again.",onRetry:()=>void o.refetch(),isRetrying:o.isFetching}):o.data?n.jsx(Ft,{connectionId:e,status:o.data,idPrefix:"agent-request-source"}):null,i.isPending?n.jsx(z,{className:"h-28 rounded-lg","aria-label":"Loading notification choices"}):i.isError?n.jsx(K,{title:"Couldn’t load notification choices",description:"Nothing changed. Try again.",onRetry:()=>void i.refetch(),isRetrying:i.isFetching}):n.jsxs("div",{className:"space-y-3",children:[c.map((u,m)=>{const y=g.filter(h=>h.eventType===u);return n.jsxs("section",{"aria-labelledby":`agent-request-event-${m}`,className:"bg-muted/30 space-y-3 rounded-lg p-3",children:[n.jsx("div",{children:n.jsx("h3",{id:`agent-request-event-${m}`,className:"text-sm font-medium",children:Tt(u)})}),y.length===0?n.jsx("p",{className:"text-muted-foreground text-sm",children:i.hasNextPage?"Load more options to finish.":"This account doesn’t offer this now."}):n.jsx(Et,{idPrefix:`agent-request-event-${m}`,definitions:y,draft:d[u]??le(s.id),onChange:h=>l(j=>({...j,[u]:h})),fixedAgent:s,sourceStatus:o.data})]},u)}),i.hasNextPage&&n.jsx(S,{type:"button",size:"sm",variant:"ghost",disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:i.isFetchingNextPage?"Loading…":"Load more notification options"})]})]})}const Ot=new Set(["failed","expired","start_unknown"]);function Dt({account:e,serviceName:t,logo:s,agentName:a,onDecline:i,deciding:o,onConnectAgain:c}){var C,w,I;const d=p.useId(),l=ye(),g=$n(),x=Rn(),u=En(),[m,y]=p.useState(null),h=_n(m),j=(C=h.data)==null?void 0:C.state,f=j!==void 0&&Ot.has(j),v=((w=h.data)==null?void 0:w.state)==="pending"?h.data.authorizeUrl:void 0,k=g.isError||x.isError||f,N=(I=e.readiness.fix)==null?void 0:I.action;return n.jsxs(Z,{titleId:d,toolkit:e.toolkit,serviceName:t,logo:s,title:`Let ${a} use ${t}?`,subtitle:e.label,className:"max-w-xl",children:[n.jsx("p",{className:"text-sm","data-testid":"account-attention","data-reason":e.readiness.reason,children:e.readiness.copy.owner}),v&&n.jsx(S,{asChild:!0,className:"w-full sm:w-auto",children:n.jsxs(Be,{href:v,children:["Sign in to ",t,n.jsx(Ue,{className:"size-4","aria-hidden":!0})]})}),m&&!v&&!f&&j!=="connected"&&n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(ce,{className:"size-4 animate-spin motion-reduce:animate-none","aria-hidden":!0}),"Getting the sign-in page ready…"]}),k&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t finish that. Nothing changed. Try again."}),n.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[n.jsx(S,{variant:"ghost",onClick:i,disabled:o,children:"Not now"}),N==="resume"&&n.jsx(S,{onClick:()=>g.mutate({connectionId:e.connectionId,input:void 0}),disabled:g.isPending,children:g.isPending?"Resuming…":"Resume"}),N==="sign_in_again"&&(!m||f)&&n.jsx(S,{onClick:()=>x.mutate({connectionId:e.connectionId},{onSuccess:E=>y(E.flowId)}),disabled:x.isPending,children:"Sign in again"}),N==="retry"&&n.jsx(S,{variant:"secondary",onClick:()=>u.mutate(),disabled:u.isPending,children:u.isPending?"Checking…":"Check again"}),N==="fix_key"&&n.jsx(S,{variant:"secondary",onClick:()=>l.open("connections","ways"),children:"Fix the key"}),N==="connect_new"&&n.jsxs(S,{onClick:c,children:["Connect ",t," again"]}),N==="review_access"&&n.jsx(S,{asChild:!0,variant:"secondary",children:n.jsxs(bn,{...Cn.connections(),search:{app:e.connectionId},children:["Open Connections",n.jsx(Sn,{className:"size-4","aria-hidden":!0})]})})]})]})}function on(e){var t;return((t=e==null?void 0:e.intents.find(s=>s.kind==="account"))==null?void 0:t.routes)??[]}function zt(e,t){const s=e.filter(i=>i.capabilities.authentication.status==="available");return((t==null?void 0:t.status)==="ready"?s.find(i=>i.providerInstanceId===t.way.providerInstanceId):void 0)??s.find(i=>i.mode==="managed")??s.find(i=>i.mode==="byo")??null}function Mt(e){const t=e==null?void 0:e.intents.find(s=>s.kind==="account");return(t==null?void 0:t.kind)==="account"&&!t.routes.some(s=>s.capabilities.authentication.status==="available")}function Wt(e){var t;return((e==null?void 0:e.warnings.length)??0)>0&&((t=e==null?void 0:e.appConnections)==null?void 0:t.newApps.status)==="ready"}function rn(e){return Kn(e.kind==="dorkos_account"?"dorkos-managed":e.type)}function Vt(e,t){return!(e!=null&&e.signInThrough)||e.authKind!=="oauth2"||!t?null:`${t.signInName??t.displayName} will ask you to allow ${e.signInThrough}. DorkOS connects through it.`}function Kt(e,t){const s=(t==null?void 0:t.displayName)??"this app",a=on(t).map(o=>o.capabilities.authentication).find(o=>o.status==="unsupported");if((a==null?void 0:a.status)==="unsupported")return a.reason;const i=e==null?void 0:e.newApps;if(!i)return null;if(i.status==="ready")return`${rn(i.way)} can’t reach ${s} yet.`;switch(i.reason){case"dorkos_account_unavailable":return"Your DorkOS account is linked, but it can’t connect apps right now.";case"dorkos_account_unlinked":return"Your DorkOS account isn’t linked anymore.";case"own_key_unavailable":return"Your saved key didn’t work at the last check.";case"nothing_set_up":return null}}function qt({reason:e,onLeave:t}){var v;const s=qn(),a=Bn(),i=ye(),[o,c]=p.useState(!1);if(s.isPending)return n.jsx(z,{className:"h-24 rounded-lg","aria-label":"Loading setup options"});if(s.isError)return n.jsx(K,{title:"Couldn’t load the setup options",description:"Try again. Nothing was changed.",onRetry:()=>void s.refetch(),isRetrying:s.isFetching});const d=Pe(s.data,"composio"),l=Pe(s.data,"nango"),g=(v=a.data)==null?void 0:v.newApps,x=(g==null?void 0:g.status)==="setup_needed"?g.reason:null,u=x==="dorkos_account_unlinked"||x==="dorkos_account_unavailable",m=x==="nothing_set_up",y=x==="own_key_unavailable",h=u||m||y,j=()=>{t==null||t(),i.open("account")},f=u?n.jsx(S,{size:"lg",variant:"outline",className:"w-full",onClick:j,children:"Link my DorkOS account again"}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(S,{size:"lg",variant:m?"default":"outline",className:"w-full",onClick:j,children:"Use a DorkOS account"}),n.jsx("p",{className:"text-muted-foreground text-center text-xs",children:"Sign in or create one. DorkOS connects your apps for you."})]});return n.jsxs("div",{"data-testid":"first-connect-step",className:"space-y-4",children:[e&&n.jsx("p",{role:"status",className:"bg-muted/40 rounded-lg p-3 text-sm",children:e}),h&&!y&&f,d&&(o?n.jsx(Ce,{status:d}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs(S,{size:"lg",variant:u||m?"outline":"default",className:"w-full",onClick:()=>c(!0),children:[n.jsx(In,{className:"size-4","aria-hidden":!0}),"Use my Composio key"]}),n.jsx("p",{className:"text-muted-foreground text-center text-xs",children:"Have a Composio account? Paste its key."})]})),h&&y&&f,l&&n.jsxs(Me,{children:[n.jsxs(We,{className:"text-muted-foreground hover:text-foreground focus-ring group flex items-center gap-1 rounded-md text-sm font-medium",children:["Other ways",n.jsx(wn,{className:"size-4 transition-transform group-data-[state=open]:rotate-180","aria-hidden":!0})]}),n.jsxs(Ve,{className:"space-y-2 pt-3",children:[n.jsx("p",{className:"text-muted-foreground text-xs",children:"Your own Nango server. Sign-ins stay in your database."}),n.jsx(Ce,{status:l})]})]})]})}function Pe(e,t){return e==null?void 0:e.find(s=>s.type===t)}function Bt({request:e,serviceName:t,service:s,onConnected:a,onDecline:i,onBack:o,deciding:c,className:d}){var L;const l=p.useId(),[g,x]=p.useState(null),[u,m]=p.useState(!1),y=zn(e.requestId),h=Mn(e.requestId,g),j=He(e.serviceSlug),f=(L=j.data)==null?void 0:L.pages[0],v=f==null?void 0:f.appConnections,k=on(s),N=zt(k,v==null?void 0:v.newApps),C=h.data??y.data,w=!C&&Mt(s),I=Vt(N,s),E=(C==null?void 0:C.state)==="connected"?C.connectionId:null;p.useEffect(()=>{E&&a(E)},[E,a]);const r=()=>{if(w){m(!0);return}N&&y.mutate({providerInstanceId:N.providerInstanceId},{onSuccess:b=>x(b.flowId)})},$=(C==null?void 0:C.state)==="starting"||(C==null?void 0:C.state)==="pending";let R;return j.isPending&&!s?R=n.jsx(z,{className:"h-10 rounded-lg","aria-label":`Loading ${t}`}):w&&u?R=k.length===0&&Wt(f)&&(v==null?void 0:v.newApps.status)==="ready"?n.jsx(K,{title:`Couldn’t reach ${t} just now`,description:`${rn(v.newApps.way)} didn’t answer. Try again soon.`,onRetry:()=>void j.refetch(),isRetrying:j.isFetching}):n.jsx(qt,{reason:Kt(v,s)}):$?R=n.jsxs("div",{className:"space-y-3",children:[I&&n.jsx("p",{className:"text-sm",children:I}),C.state==="pending"&&C.authorizeUrl?n.jsx(S,{asChild:!0,className:"w-full sm:w-auto",children:n.jsxs(Be,{href:C.authorizeUrl,children:["Sign in to ",t,n.jsx(Ue,{className:"size-4","aria-hidden":!0})]})}):null,n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(ce,{className:"size-4 animate-spin motion-reduce:animate-none","aria-hidden":!0}),C.state==="starting"?"Getting the sign-in page ready…":`Finish signing in to ${t}…`]})]}):R=n.jsxs("div",{className:"space-y-2",children:[n.jsxs("p",{className:"text-sm",children:[n.jsxs("span",{className:"text-muted-foreground",children:[e.agent.displayName," asked: "]}),e.reason]}),I&&n.jsx("p",{className:"text-muted-foreground text-xs",children:I}),y.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t start sign-in. Try again."})]}),n.jsxs(Z,{titleId:l,toolkit:e.serviceSlug,serviceName:t,logo:ne(s),title:`Connect ${t}`,subtitle:`So ${e.agent.displayName} can use it`,className:d,children:[R,n.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[o&&n.jsx(S,{variant:"ghost",onClick:o,disabled:c,className:"mr-auto",children:"Back"}),n.jsx(S,{variant:"ghost",onClick:i,disabled:c,children:"Not now"}),!$&&!(w&&u)&&n.jsx(S,{onClick:r,disabled:y.isPending||c||!w&&!N,children:y.isPending?"Starting…":`Connect ${t}`})]})]})}function Ut(e,t){const s=e.agent.displayName;switch(e.status){case"granted":return`Allowed ${s} to use ${t}`;case"access_pending":return`Giving ${s} access to ${t}…`;case"denied":return`${s} wasn’t given ${t}`;case"expired":return`Request for ${t} timed out. ${s} can ask again.`;case"authentication_failed":return`Signing in to ${t} didn’t finish. Nothing was shared.`;case"target_deleted":return`Request for ${t} closed. The agent or its chat is gone.`;case"awaiting_owner":return`${s} is waiting for ${t}`}}function Qt({request:e,serviceName:t,className:s}){const a=e.status==="granted",i=e.status==="access_pending",o=a?ve:i?Je:Un;return n.jsxs("p",{role:"status","data-testid":"agent-request-receipt","data-status":e.status,className:O("bg-muted/40 text-muted-foreground flex items-start gap-2 rounded-lg px-3 py-2 text-sm",s),children:[n.jsx(o,{className:O("mt-0.5 size-4 shrink-0",a&&"text-status-success"),"aria-hidden":!0}),n.jsx("span",{className:O("min-w-0",a&&"text-foreground"),children:Ut(e,t)})]})}const Gt="Couldn’t save your answer. Nothing changed. Try again.";function Ht(e){return(e==null?void 0:e.code)==="session_access_off"}const Yt="Couldn’t turn it on for this chat. Nothing changed. Try again.";function Jt(e,t,s){switch(e==null?void 0:e.code){case"session_access_off":return{reason:`This chat has ${s} turned off for ${t}.`,fix:"turn_on"};case"request_already_resolved":return{reason:`It was answered somewhere else. Ask ${t} again if it still needs this.`,fix:null};case"request_expired":return{reason:`The request ran out of time. Ask ${t} again.`,fix:null};case"request_not_found":return{reason:"The request is no longer open.",fix:null};case"authority_sync_failed":return{reason:"The access is still being set up.",fix:"retry"};case"event_selection_unavailable":case"review_conflict":case"destination_unavailable":case"definition_changed":case"invalid_filter":return{reason:"The updates you picked can’t be set up. Pick again, or answer without them.",fix:"updates"};case"selection_invalid":return{reason:"That account isn’t ready for it yet.",fix:"retry"};default:return{reason:"The answer didn’t reach DorkOS.",fix:"retry"}}}function us({request:e,onEditExactActions:t,className:s}){var ee,se,M,Ne,ke;const a=Wn(),i=Ln(e.sessionId),o=Ht(a.error)?e.sessionId:null,c=Fn(o),d=Ge(),g=((ee=He(e.serviceSlug,e.status==="awaiting_owner").data)==null?void 0:ee.pages.flatMap(_=>_.services).find(_=>_.serviceSlug===e.serviceSlug))??null,x=(g==null?void 0:g.displayName)??Tn(e.serviceSlug),u=e.agent.displayName,[m,y]=p.useState(null),[h,j]=p.useState(null),[f,v]=p.useState([]),[k,N]=p.useState(!1),[C,w]=p.useState(!1),[I,E]=p.useState(null),r=p.useCallback(()=>{j(null),a.mutate({requestId:e.requestId,decision:{decision:"denied"}})},[a,e.requestId]),$=p.useCallback((_,U=[])=>{j(_),v(U),a.mutate({requestId:e.requestId,decision:{decision:"current_access",connectionId:_,eventScopes:U}})},[a,e.requestId]),R=e.requestedEvents.length>0,L=p.useCallback(_=>R?E(_):$(_),[$,R]),b=O("max-w-xl",s);if(h&&a.isError){const{reason:_,fix:U}=Jt(a.error,u,x),cn=U==="updates"&&I!==null,be=U==="turn_on"&&((Ne=(M=(se=c.data)==null?void 0:se.connections.find(dn=>dn.connectionId===h))==null?void 0:M.readiness.fix)==null?void 0:Ne.action)==="turn_on_for_this_chat";return n.jsxs(Z,{titleId:`agent-request-unanswered-${e.requestId}`,toolkit:e.serviceSlug,serviceName:x,logo:ne(g),title:`${u} can now use ${x}`,className:b,children:[n.jsxs("div",{role:"alert",className:"space-y-1 text-sm","data-testid":"agent-request-unanswered",children:[n.jsxs("p",{children:[n.jsx(ve,{className:"text-status-success mr-1.5 inline size-4 align-text-bottom","aria-hidden":!0}),"Access saved, but ",u,"’s request wasn’t answered."]}),n.jsxs("p",{children:[_,be&&" Turning it on only affects this chat."]})]}),cn?n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(S,{variant:"ghost",onClick:()=>$(h,[]),disabled:a.isPending,children:"Answer without updates"}),n.jsx(S,{onClick:()=>a.reset(),disabled:a.isPending,children:"Pick updates again"})]}):U==="retry"&&n.jsx("div",{className:"flex justify-end",children:n.jsx(S,{onClick:()=>$(h,f),disabled:a.isPending,children:a.isPending?"Sending…":"Try again"})}),be&&n.jsxs(n.Fragment,{children:[i.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:Yt}),n.jsx("div",{className:"flex justify-end",children:n.jsx(S,{onClick:()=>i.mutate({connectionId:h,on:!0},{onSuccess:()=>$(h,f)}),disabled:i.isPending||a.isPending,children:i.isPending||a.isPending?"Turning on…":"Turn on for this chat"})})]})]})}if(e.status!=="awaiting_owner")return n.jsx(Qt,{request:e,serviceName:x,className:b});const F=a.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:Gt});if(I)return n.jsx(Xt,{request:e,connectionId:I,serviceName:x,logo:ne(g),onAnswer:_=>$(I,_),deciding:a.isPending,className:b},I);if(d.isPending)return n.jsx(z,{className:O("h-28 rounded-xl",b),"aria-label":"Loading accounts"});if(d.isError)return n.jsx("div",{className:b,children:n.jsx(K,{title:"Couldn’t load your accounts",description:"Nothing changed. Try again.",onRetry:()=>void d.refetch(),isRetrying:d.isFetching})});const A=((ke=d.data)==null?void 0:ke.connections)??[],B=A.filter(_=>_.toolkit===e.serviceSlug&&_.readiness.state!=="gone"),te=sn(A,e.serviceSlug),X=k||!!m||te.length>0;if(!m&&(C||!X&&B.length===0))return n.jsxs("div",{className:O("space-y-2",b),children:[n.jsx(Bt,{request:e,serviceName:x,service:g,onConnected:y,onDecline:r,...B.length>0?{onBack:()=>w(!1)}:{},deciding:a.isPending}),F]});if(!X){const _=B[0];return n.jsxs("div",{className:O("space-y-2",b),children:[n.jsx(Dt,{account:_,serviceName:x,logo:ne(g),agentName:u,onDecline:r,deciding:a.isPending,onConnectAgain:()=>w(!0)}),F]})}return n.jsx(Zt,{onShown:N,children:n.jsxs("div",{className:O("space-y-2",b),"data-testid":"agent-request-access",children:[n.jsx(wt,{mode:"agent",agentId:e.agent.id,toolkit:e.serviceSlug,serviceName:x,logo:ne(g),...m?{connectionId:m}:{},request:{reason:e.reason,access:e.access},...t?{onEditExactActions:t}:{},onSkip:r,onAllowed:L}),!m&&!h&&n.jsxs(S,{variant:"link",size:"sm",className:"h-auto px-0",onClick:()=>w(!0),children:["Connect another ",x," account"]}),F]})})}function Zt({onShown:e,children:t}){return p.useEffect(()=>e(!0),[e]),n.jsx(n.Fragment,{children:t})}function Xt({request:e,connectionId:t,serviceName:s,logo:a,onAnswer:i,deciding:o,className:c}){const[d,l]=p.useState(null);return n.jsxs(Z,{titleId:`agent-request-updates-${e.requestId}`,toolkit:e.serviceSlug,serviceName:s,logo:a,title:`Send ${e.agent.displayName} updates from ${s}?`,subtitle:`${e.agent.displayName} can now use ${s}`,className:c,children:[n.jsx(Pt,{connectionId:t,requestedEvents:e.requestedEvents,agent:e.agent,onChange:l}),n.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[n.jsx(S,{variant:"ghost",onClick:()=>i([]),disabled:o,children:"No updates"}),n.jsx(S,{onClick:()=>d&&i(d),disabled:o||!d,children:o?"Sending…":"Send updates"})]})]})}export{us as A,Ft as C,qt as F,gt as L,nn as R,Qn as a,rs as b,cs as c,ds as d,le as e,Rt as f,Et as g,$t as h,Lt as i,de as j,wt as k,on as l,zt as m,Mt as n,Vt as o,Wt as p,Kt as q,mt as r,ne as s,at as t,Gn as u,q as v,rn as w,ls as x,yt as y};
12
+ ${o.capabilityClassification}`;if(a.has(d))return;a.add(d);const l=s.get(o.operationSlug);i.push({action:{operationSlug:o.operationSlug,...(l==null?void 0:l.action.displayName)!==void 0&&{displayName:l.action.displayName},capabilityClassification:o.capabilityClassification,important:(l==null?void 0:l.action.important)??!1},order:l?l.index:s.size+c})}),i.sort((o,c)=>o.order-c.order).map(({action:o})=>o)}function rt(e){return[...e.filter(t=>t.important),...e.filter(t=>!t.important)]}function ct(e,t){const s=rt(e),a=s.filter(o=>xe(o.capabilityClassification)==="look"),i=s.filter(o=>xe(o.capabilityClassification)==="change");return t===null?{look:a,change:i,addedByReadWrite:[],outsideLevels:[]}:{look:a.filter(o=>K(o.capabilityClassification,t)),change:i.filter(o=>K(o.capabilityClassification,t)),addedByReadWrite:i.filter(o=>!K(o.capabilityClassification,t)&&K(o.capabilityClassification,"read-write")),outsideLevels:i.filter(o=>!K(o.capabilityClassification,"read-write"))}}function dt(e){return e.some(t=>K(t.capabilityClassification,"read-write")&&!K(t.capabilityClassification,"read"))}function $e(e,t){const s=e.slice(0,2).map(i=>lt(je(i,t))),a=e.length-s.length;return a>0?`${s.join(", ")} and ${a} more`:s.join(" and ")}function lt(e){const t=e.split(" ")[0]??"";return/[A-Z]/u.test(t.slice(1))?e:`${e.charAt(0).toLowerCase()}${e.slice(1)}`}const re={read:"Read","read-write":"Read and write"},Re={...re,custom:"Exact actions"};function de(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const ut={gmail:"send email",outlook:"send email",slack:"send messages",googlecalendar:"change your calendar",google_calendar:"change your calendar",calendar:"change your calendar",googledrive:"change your files",google_drive:"change your files",notion:"change your pages",github:"make changes on GitHub",linear:"change your issues"};function ht(e,t,s=!1){return`Every agent, even future ones, could ${ut[e.toLowerCase()]??`make changes in ${t}`} as you${s?", including high-risk actions":""}.`}function gt({error:e,title:t,description:s,...a}){const i=Xe(e);return n.jsxs("div",{className:"space-y-2",children:[n.jsx(V,{title:(i==null?void 0:i.title)??t,description:(i==null?void 0:i.description)??s,...a}),(i==null?void 0:i.action)==="relink"&&n.jsx(nn,{variant:"outline",size:"sm"})]})}function nn(e){const t=ye();return n.jsx(S,{...e,onClick:()=>t.open("account",hn),children:"Link my DorkOS account again"})}const tn={look:"Look",change:"Change"};function mt({toolkit:e,appName:t,providerInstanceId:s,grant:a}){var u;const i=p.useId(),o=An(e,s),c=((u=o.data)==null?void 0:u.status)==="listed"?o.data:null,d=a&&a.candidates.length>0?a:null,l=(d==null?void 0:d.level)??null,g=l?`With “${re[l]}”, agents can`:`What ${t} offers agents`;let x;if(d)x=s&&o.isPending?n.jsx(Ee,{}):n.jsx(_e,{actions:ot(d.candidates,c==null?void 0:c.actions),completeness:"complete",toolkit:e,appName:t,level:l});else if(!s||xt(o.error))x=n.jsxs("p",{className:"text-muted-foreground text-sm",children:["Shows once DorkOS can reach ",t,"."]});else if(o.isPending)x=n.jsx(Ee,{});else if(o.isError){const m=Xe(o.error);x=n.jsxs("p",{className:"text-muted-foreground flex flex-wrap items-center gap-x-2 text-sm",children:[m?`${m.title}. ${m.description}`:`Couldn’t load what ${t} offers agents.`,n.jsx(S,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>void o.refetch(),disabled:o.isFetching,children:"Try again"}),(m==null?void 0:m.action)==="relink"&&n.jsx(nn,{variant:"link",size:"xs",className:"h-auto p-0"})]})}else c?x=n.jsx(_e,{actions:c.actions,completeness:c.completeness,toolkit:e,appName:t,level:null}):x=n.jsxs("p",{className:"text-muted-foreground text-sm",children:["DorkOS can’t list ",t,"’s actions. Everything agents do in ",t," counts as a change."]});return n.jsxs("section",{"aria-labelledby":i,className:"space-y-2.5","data-testid":"app-actions",children:[n.jsx("p",{id:i,className:"text-muted-foreground text-xs font-medium",children:g}),x]})}function Ee(){return n.jsxs(n.Fragment,{children:[n.jsx(z,{className:"h-16 rounded-lg"}),n.jsx("span",{className:"sr-only",children:"Loading what agents can do"})]})}function xt(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="provider_not_found"}function _e({actions:e,completeness:t,toolkit:s,appName:a,level:i}){if(e.length===0)return n.jsxs("p",{className:"text-muted-foreground text-sm",children:[a," offers no actions."]});const o=ct(e,i),c=o.outsideLevels,d=[];if(i==="read-write"&&o.change.length>0&&d.push("Pick “Read” and only Look stays."),i==="read"&&o.addedByReadWrite.length>0&&d.push(`Pick “Read and write” to also let agents ${$e(o.addedByReadWrite,s)}.`),i!==null&&c.length>0){const l=c.length>1;d.push(`${pt($e(c,s))} ${l?"aren’t":"isn’t"} part of ${dt(e)?"either level":"“Read”"}. To allow ${l?"them":"it"}, choose exact actions.`)}return t==="too_large"?d.push(`Showing the first ${e.length}. ${a} has more.`):t==="interrupted"&&d.push(`Showing the first ${e.length}. The rest didn’t load this time.`),n.jsxs("div",{className:"space-y-3",children:[o.look.length===0&&o.change.length===0?n.jsx("p",{className:"text-sm",children:"Nothing at this level."}):n.jsxs(n.Fragment,{children:[n.jsx(Le,{kind:"look",actions:o.look,toolkit:s}),n.jsx(Le,{kind:"change",actions:o.change,toolkit:s})]}),d.map(l=>n.jsx("p",{className:"text-muted-foreground text-xs",children:l},l)),n.jsx(ft,{actions:e,complete:t==="complete",toolkit:s})]})}function Le({kind:e,actions:t,toolkit:s}){if(t.length===0)return null;const a=t.slice(0,it),i=t.length-a.length;return n.jsxs("div",{className:"space-y-1.5","data-testid":`app-actions-${e}`,children:[n.jsx("p",{className:"text-sm font-medium",children:tn[e]}),n.jsxs("ul",{className:"flex flex-wrap gap-1.5",children:[a.map(o=>n.jsx("li",{className:O("rounded-full px-2.5 py-0.5 text-xs",e==="look"?"bg-muted text-foreground":ze.warning),children:je(o,s)},`${o.operationSlug}-${o.capabilityClassification}`)),i>0&&n.jsxs("li",{className:"text-muted-foreground px-1 py-0.5 text-xs",children:["+",i," more"]})]})]})}function ft({actions:e,complete:t,toolkit:s}){const a=`${e.length} ${e.length===1?"action":"actions"}`;return n.jsxs(Me,{children:[n.jsxs(We,{className:"group/all text-primary focus-ring flex items-center gap-0.5 rounded-sm text-xs font-medium hover:underline",children:[t?`See all ${a}`:`See the first ${a}`,n.jsx(gn,{className:"size-3.5 transition-transform group-data-[state=open]/all:rotate-90","aria-hidden":!0})]}),n.jsx(Ke,{children:n.jsx("ul",{className:"border-border mt-2 max-h-72 divide-y overflow-y-auto rounded-lg border","data-testid":"app-actions-all",children:e.map(i=>{const o=xe(i.capabilityClassification);return n.jsxs("li",{className:"flex items-start justify-between gap-3 px-3 py-1.5 text-sm",children:[n.jsx("span",{className:"min-w-0 break-words",children:je(i,s)}),n.jsx("span",{className:O("mt-0.5 shrink-0 rounded-full px-2 py-0 text-xs",o==="look"?"bg-muted text-muted-foreground":ze.warning),children:tn[o]})]},`${i.operationSlug}-${i.capabilityClassification}`)})})})]})}function pt(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function Z({titleId:e,toolkit:t,serviceName:s,logo:a,title:i,subtitle:o,variant:c="card",className:d,children:l}){const g=c==="embedded";return n.jsxs("section",{"aria-labelledby":e,"data-testid":"connection-access-card",className:O(g?"space-y-3":"bg-card space-y-4 rounded-xl border p-4",d),children:[n.jsxs("header",{className:"flex items-start gap-3",children:[!g&&n.jsx(mn,{iconKey:t??"",displayName:s,logo:a,className:"size-9 rounded-lg"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("h3",{id:e,className:"text-sm font-semibold",children:i}),o&&n.jsx("div",{className:"text-muted-foreground mt-0.5 text-xs",children:o})]})]}),l]})}function yt({access:e,savedDetail:t="Ready for the agents you changed."}){const{saveOutcome:s}=e,a=s==null?void 0:s.grants.some(c=>c.operationRevisionIds.length>0),i=s==null?void 0:s.grants.some(c=>c.operationRevisionIds.length===0),o=e.syncCheckFailed&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t check if the change is done. Nothing was sent twice."});return e.needsRefresh?n.jsxs("div",{className:"border-destructive/30 bg-destructive/5 space-y-3 rounded-lg border p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(ae,{className:"text-destructive mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{children:[n.jsx("p",{role:"alert",className:"text-sm font-medium",children:"Couldn’t confirm access was saved"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Reload access before another change."})]})]}),n.jsxs(S,{size:"sm",variant:"secondary",className:"h-auto min-h-9 whitespace-normal",onClick:e.refresh,children:[n.jsx(ce,{className:"size-4","aria-hidden":!0}),"Reload current access"]})]}):e.saved?n.jsxs("div",{className:"border-status-success/30 bg-status-success/5 flex items-start gap-3 rounded-lg border p-4",children:[n.jsx(ve,{className:"text-status-success mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{children:[n.jsx("p",{"data-testid":"connector-access-outcome",className:"text-sm font-medium",children:"Access updated"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:t})]})]}):e.needsReconciliation?n.jsxs("div",{className:"border-status-warning/30 bg-status-warning/5 flex items-start gap-3 rounded-lg border p-4",children:[n.jsx(ae,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{children:[n.jsx("p",{"data-testid":"connector-access-outcome",className:"text-sm font-medium",children:"Access needs review"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Available actions changed. Reload access before another change."})]})]}):(s==null?void 0:s.authoritySync.status)==="pending"?n.jsxs("div",{className:"border-status-warning/30 bg-status-warning/5 space-y-3 rounded-lg border p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(Je,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{children:[n.jsx("p",{"data-testid":"connector-access-outcome",className:"text-sm font-medium",children:"Access update pending"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:a&&i?"Removed access has ended. New access works once DorkOS finishes.":i?"Removed access has ended here. DorkOS is still removing it at the service.":"New access is saved. It works once DorkOS finishes."})]})]}),o]}):(s==null?void 0:s.authoritySync.status)==="failed"?n.jsxs("div",{className:"border-destructive/30 bg-destructive/5 space-y-3 rounded-lg border p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(ae,{className:"text-destructive mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{children:[n.jsx("p",{"data-testid":"connector-access-outcome",role:"alert",className:"text-sm font-medium",children:"Access didn’t update"}),n.jsxs("p",{className:"text-muted-foreground mt-1 text-sm",children:[s.authoritySync.reason," Agents can’t use this yet. Check your account, then try again."]})]})]}),o]}):null}function sn(e,t){return e.filter(s=>s.toolkit===t&&(s.readiness.state==="ready"||s.readiness.reason==="access_updating"))}function vt({props:e,renderAccess:t}){var m;const s=p.useId(),a=Ge(),i=sn(((m=a.data)==null?void 0:m.connections)??[],e.toolkit),[o,c]=p.useState(null),[d,l]=p.useState(null),g=i.length===1?i[0].connectionId:null,x=d??(g?{id:g,picked:!1}:null);if(p.useEffect(()=>{!d&&g&&l({id:g,picked:!1})},[d,g]),x)return t(x.id,x.picked?()=>l(null):void 0);const u=`Which ${e.serviceName} account?`;return n.jsxs(Z,{titleId:s,toolkit:e.toolkit,serviceName:e.serviceName,logo:e.logo,title:u,className:e.className,children:[a.isPending?n.jsx(z,{className:"h-16 rounded-lg","aria-label":"Loading accounts"}):a.isError?n.jsx(V,{title:"Couldn’t load your accounts",description:"Nothing changed. Try again.",onRetry:()=>void a.refetch(),isRetrying:a.isFetching}):i.length===0?n.jsxs("p",{className:"text-muted-foreground text-sm",children:["No ",e.serviceName," account is ready yet."]}):n.jsx(Ve,{"aria-labelledby":s,value:o??"",onValueChange:c,className:"gap-2",children:i.map(y=>{const h=`${s}-${y.connectionId}`;return n.jsxs("div",{className:"bg-muted/40 flex min-h-11 items-center gap-3 rounded-lg px-3",children:[n.jsx(ue,{id:h,value:y.connectionId}),n.jsxs(T,{htmlFor:h,className:"min-w-0 flex-1 cursor-pointer flex-col items-start gap-0.5 py-2 leading-snug font-normal",children:[n.jsx("span",{className:"block max-w-full truncate text-sm font-medium",children:y.label}),y.identityHint&&n.jsx("span",{className:"text-muted-foreground block max-w-full truncate text-xs",children:y.identityHint})]})]},y.connectionId)})}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.onSkip&&n.jsx(S,{variant:"ghost",onClick:e.onSkip,children:"Not now"}),i.length>1&&n.jsx(S,{disabled:!o,onClick:()=>o&&l({id:o,picked:!0}),children:"Continue"})]})]})}function jt({preview:e,serviceName:t,preferredAgentIds:s,systemAgentIds:a,picked:i,setPicked:o,decision:c,showAll:d,setShowAll:l}){const g=p.useId(),x=q(e),u=Jn(e,{preferredAgentIds:s,systemAgentIds:a}),m=d?u:u.filter((h,j)=>j<Yn||i.has(h.agentId)||P(x[h.agentId])!=="none"),y=h=>{var j;return(j=e.agents.find(f=>f.agentId===h))==null?void 0:j.displayName};return n.jsxs("fieldset",{className:"space-y-1",children:[n.jsxs("legend",{className:"sr-only",children:["Agents that can use ",t]}),m.map(h=>{const j=`${g}-${h.agentId}`,f=P(x[h.agentId]),v=c.removedAgentIds.includes(h.agentId)||c.downgradedAgentIds.includes(h.agentId);return n.jsxs("div",{className:"hover:bg-muted/60 flex min-h-11 items-center gap-3 rounded-md px-2",children:[n.jsx(qe,{id:j,"aria-describedby":v?`${j}-loss`:void 0,checked:i.has(h.agentId),onCheckedChange:k=>{const N=new Set(i);k===!0?N.add(h.agentId):N.delete(h.agentId),o(N)}}),n.jsx(T,{htmlFor:j,className:"min-w-0 flex-1 cursor-pointer py-2 font-normal",children:n.jsx("span",{className:"truncate",children:h.displayName})}),f!=="none"&&n.jsx(xn,{size:"xs",variant:"secondary","aria-label":`Now: ${Re[f]}`,children:Re[f]})]},h.agentId)}),m.length<u.length&&n.jsxs(S,{variant:"ghost",size:"sm",onClick:()=>l(!0),children:["Show all ",u.length]}),n.jsxs("div",{"aria-live":"polite",className:"space-y-1",children:[c.removedAgentIds.map(h=>n.jsxs("p",{id:`${g}-${h}-loss`,className:"text-foreground flex items-start gap-1.5 px-2 text-xs",children:[n.jsx(Se,{className:"text-status-warning-dot mt-0.5 size-3 shrink-0","aria-hidden":!0}),y(h)," will lose access to ",t,"."]},h)),c.downgradedAgentIds.map(h=>n.jsxs("p",{id:`${g}-${h}-loss`,className:"text-foreground flex items-start gap-1.5 px-2 text-xs",children:[n.jsx(Se,{className:"text-status-warning-dot mt-0.5 size-3 shrink-0","aria-hidden":!0}),y(h)," will lose write access."]},h))]})]})}function Nt({preview:e,level:t,serviceName:s}){return tt(e,t)?n.jsxs("p",{role:"note","data-testid":"every-agent-warning",className:"border-status-warning-border bg-status-warning-bg text-foreground flex items-start gap-2 rounded-lg border px-3 py-2 text-xs",children:[n.jsx(ae,{className:"text-status-warning-dot mt-0.5 size-3.5 shrink-0","aria-hidden":!0}),ht(e.connection.toolkit,s,st(e,t))]}):null}const kt={read:e=>`It wants to read ${e}.`,"read-write":e=>`It wants to read and change things in ${e}.`};function bt({agentName:e,serviceName:t,reason:s,access:a,level:i}){return n.jsxs("div",{className:"bg-muted/40 space-y-1.5 rounded-lg p-3 text-sm","data-testid":"requested-access",children:[n.jsxs("p",{children:[n.jsxs("span",{className:"text-muted-foreground",children:[e," asked: "]}),s]}),n.jsx("p",{className:"text-muted-foreground text-xs",children:kt[a](t)}),a==="read-write"&&i==="read"&&n.jsxs("p",{className:"text-xs",role:"status",children:["With Read, ",e," can’t change ",t,"."]})]})}function Fe(e,t,s){return t==="read-write"?`${e} can read and write in ${s}.`:`${e} can read ${s}.`}function St(e){var x;const{preview:t,serviceName:s,decision:a,level:i}=e,o=u=>{var m;return((m=t.agents.find(y=>y.agentId===u))==null?void 0:m.displayName)??"The agent"};if(e.mode==="agent")return Fe(o(e.agentId??""),i,s);if(e.who==="every")return Fe("Every agent",i,s);const c=t.agents.filter(u=>e.picked.has(u.agentId)).map(u=>u.displayName),d=[c.length>0?`${de(c)} can use ${s}.`:`No agent can use ${s}.`];((x=e.every.everyAgent)==null?void 0:x.operationRevisionIds.length)===0&&d.push(`${s} is no longer shared with every agent.`);const l=a.downgradedAgentIds.map(o);l.length>0&&d.push(`${de(l)} can now only read.`);const g=a.removedAgentIds.map(o);return g.length>0&&d.push(`${de(g)} can no longer use it.`),d.join(" ")}function Ct({connectionId:e,serviceName:t}){var i;const s=Qe(e,!0),a=Dn();return a.isSuccess?n.jsxs("p",{role:"status",className:"text-sm",children:["Stopped sharing ",t," with every agent."]}):(i=s.data)!=null&&i.connection.everyAgent?n.jsxs("div",{className:"bg-muted/40 flex flex-wrap items-center justify-between gap-2 rounded-lg p-3 text-sm",children:[n.jsxs("span",{children:["Every agent can use ",t," now."]}),n.jsx(S,{size:"sm",variant:"secondary",disabled:a.isPending,onClick:()=>a.mutate({connectionId:e}),children:"Stop sharing with every agent"}),a.isError&&n.jsx("p",{role:"alert",className:"text-destructive w-full text-xs",children:"Couldn’t stop sharing. Try again."})]}):null}function It({value:e,onChange:t,everyAgentAvailable:s}){const a=p.useId();return n.jsxs(Ve,{value:e,onValueChange:i=>t(i),"aria-label":"Who can use it",className:"gap-1.5",children:[n.jsxs("div",{className:"flex min-h-11 items-center gap-3 rounded-md px-2",children:[n.jsx(ue,{value:"picked",id:`${a}-picked`}),n.jsx(T,{htmlFor:`${a}-picked`,className:"flex-1 cursor-pointer py-2 font-normal",children:"Only agents you pick"})]}),n.jsxs("div",{className:"flex min-h-11 items-start gap-3 rounded-md px-2 py-2",children:[n.jsx(ue,{value:"every",id:`${a}-every`,disabled:!s,"aria-describedby":s?void 0:`${a}-every-unavailable`,className:"mt-0.5"}),n.jsxs(T,{htmlFor:`${a}-every`,className:"flex-1 cursor-pointer flex-col items-start gap-0.5 font-normal",children:[n.jsx("span",{children:"Every agent"}),n.jsx("span",{className:"text-muted-foreground text-xs",children:"Including agents you add later"}),!s&&n.jsx("span",{id:`${a}-every-unavailable`,className:"text-muted-foreground text-xs",children:"Not available here. Pick agents one by one."})]})]})]})}function wt(e){return e.mode==="agent"&&!e.connectionId?n.jsx(vt,{props:e,renderAccess:(t,s)=>n.jsx(Te,{...e,connectionId:t,onChangeAccount:s},t)}):n.jsx(Te,{...e,connectionId:e.connectionId},e.connectionId)}function Te(e){var F;const t=p.useId(),[s,a]=p.useState(new Set),[i,o]=p.useState("read"),[c,d]=p.useState("picked"),[l,g]=p.useState(!1),[x,u]=p.useState(!1),m=p.useRef(e.mode==="page"?e.startWho:void 0),{data:y}=fn(void 0,e.mode==="page"),[h,j]=p.useState(null),f=at({connectionId:e.connectionId,active:!0,onPreview:A=>{j(A.connection);const B=q(A),te=e.mode==="agent"?[e.agentId]:A.agents.map(M=>M.agentId).filter(M=>P(B[M])!=="none");a(new Set(e.mode==="agent"?[e.agentId]:te));const X=e.mode==="page"?m.current??Xn(A):"picked";m.current=void 0,d(X);const ee=X==="every"?nt(A):e.mode==="agent"?me([oe(A,e.agentId,!!e.onAllowed)]):me(te.map(M=>P(B[M]))),se=e.mode==="agent"&&e.request?e.request.access:null;o(se==="read-write"||ee==="read-write"?"read-write":ee),g(!1)}}),{preview:v}=f,k=e.mode==="agent"?e.agentId:null,N=p.useMemo(()=>v?Zn(v,{scope:k?[k]:c==="every"?[]:v.agents.map(A=>A.agentId),picked:s,level:i,levelTouched:k!==null||l,allowDowngrade:k===null}):{changes:[],removedAgentIds:[],downgradedAgentIds:[],needsLevel:!1},[v,s,i,l,k,c]),C=p.useMemo(()=>v&&k===null?et(v,{who:c,level:i,levelTouched:l}):{needsLevel:!1},[v,k,c,i,l]),w=v&&k?oe(v,k,e.mode==="agent"&&!!e.onAllowed):"none",I=e.mode==="agent"?e.onAllowed:void 0,E=I!==void 0&&v!==void 0&&(N.changes.length===0||w===i||w==="read-write")&&!N.needsLevel&&w!=="none"&&v.agents.some(A=>A.agentId===k),r=p.useRef(!1);p.useEffect(()=>{!f.saved||!I||r.current||(r.current=!0,I(e.connectionId))},[f.saveOutcome,f.saved,I,e.connectionId]);const $=e.mode==="agent"?(F=v==null?void 0:v.agents.find(A=>A.agentId===e.agentId))==null?void 0:F.displayName:void 0,R=e.mode==="page"?`Who can use ${e.serviceName}?`:`Let ${$??"this agent"} use ${e.serviceName}?`,L=f.needsRefresh||f.saveOutcome!==null,b=(h||e.onChangeAccount)&&n.jsxs("span",{className:"flex flex-wrap items-center gap-x-2",children:[h&&n.jsx("span",{className:"truncate",children:h.label}),e.onChangeAccount&&!L&&n.jsx(S,{variant:"link",size:"xs",className:"h-auto p-0",onClick:e.onChangeAccount,children:"Change account"})]});return n.jsxs(Z,{titleId:t,toolkit:(h==null?void 0:h.toolkit)??(e.mode==="agent"?e.toolkit:void 0),serviceName:e.serviceName,logo:e.logo,title:R,subtitle:e.variant==="embedded"?void 0:b,variant:e.variant,className:e.className,children:[f.isLoading?n.jsxs("div",{className:"space-y-2","aria-label":"Loading access",children:[n.jsx(z,{className:"h-10 rounded-lg"}),n.jsx(z,{className:"h-8 rounded-lg"})]}):f.loadFailed?n.jsxs("div",{className:"space-y-2",children:[n.jsx(gt,{error:f.loadError,title:"Couldn’t load who can use it",description:"Nothing changed. Try again.",onRetry:f.refresh,isRetrying:f.isLoading}),e.mode==="page"&&n.jsx(Ct,{connectionId:e.connectionId,serviceName:e.serviceName}),e.onEditExactActions&&n.jsx(an,{onClick:()=>{var A;return(A=e.onEditExactActions)==null?void 0:A.call(e,e.connectionId)}})]}):L?n.jsx(yt,{access:f,savedDetail:v?St({mode:e.mode,...e.mode==="agent"&&{agentId:e.agentId},serviceName:e.serviceName,preview:v,picked:s,level:i,decision:N,who:c,every:C}):void 0}):v?n.jsx(At,{props:e,preview:v,picked:s,setPicked:a,who:c,setWho:d,decision:N,level:i,setLevel:A=>{o(A),g(!0)},showAll:x,setShowAll:u,systemAgentIds:((y==null?void 0:y.agents)??[]).filter(A=>A.isSystem).map(A=>A.id)}):null,n.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[f.needsReconciliation?n.jsx(S,{variant:"secondary",onClick:f.refresh,children:"Reload current access"}):f.saveOutcome&&!f.saved?n.jsxs(S,{variant:"secondary",onClick:f.checkSync,disabled:f.isCheckingSync,children:[n.jsx(ce,{className:"size-4","aria-hidden":!0}),f.isCheckingSync?"Checking…":"Check if it’s done"]}):null,L?e.onFinished?n.jsx(S,{variant:f.saved?"default":"ghost",onClick:e.onFinished,children:f.saved?"Done":"Close"}):f.saveOutcome&&n.jsx(S,{variant:"ghost",onClick:f.refresh,children:"Edit again"}):v&&n.jsxs(n.Fragment,{children:[e.onSkip&&n.jsx(S,{variant:"ghost",onClick:e.onSkip,children:e.mode==="page"?"Skip":"Not now"}),n.jsx(S,{onClick:()=>E?I==null?void 0:I(e.connectionId):f.apply(N.changes,C.everyAgent),disabled:!E&&(N.changes.length===0&&!C.everyAgent||N.needsLevel||C.needsLevel||f.isSaving),children:f.isSaving?"Saving…":e.mode==="page"?"Save":"Allow"})]})]})]})}function At({props:e,preview:t,picked:s,setPicked:a,who:i,setWho:o,decision:c,level:d,setLevel:l,showAll:g,setShowAll:x,systemAgentIds:u}){var E;const m=p.useId(),y=q(t),h=ie(t.candidates,"read"),j=ie(t.candidates,"read-write"),f=j.length>h.length?["read","read-write"]:["read"],v=e.mode==="agent"&&oe(t,e.agentId,!!e.onAllowed)==="read-write"?f.filter(r=>r==="read-write"):f,k=j.length===0,N=e.onEditExactActions&&n.jsx(an,{onClick:()=>{var r;return(r=e.onEditExactActions)==null?void 0:r.call(e,e.connectionId)}});let C;if(e.mode==="agent"){const r=t.agents.find(b=>b.agentId===e.agentId),$=P(y[e.agentId]),R=oe(t,e.agentId,!!e.onAllowed);C=r?$==="custom"?n.jsxs("p",{className:"text-muted-foreground text-sm",children:[r.displayName," already has exact actions here."," ",e.onEditExactActions?"Choose exact actions to change them.":"Change them on the Connections page."]}):$===d?n.jsxs("p",{className:"text-muted-foreground text-sm",children:[r.displayName," can already do this."]}):R===d||R==="read-write"&&d==="read"?n.jsxs("p",{className:"text-muted-foreground text-sm",children:[r.displayName," already can, like every agent."]}):null:n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"This agent isn’t registered here, so it can’t get access."})}else i==="every"?C=null:t.agents.length===0?C=n.jsx("p",{className:"text-muted-foreground text-sm",children:"No agents yet. Add one first."}):C=n.jsx(jt,{preview:t,serviceName:e.serviceName,preferredAgentIds:e.preferredAgentIds,systemAgentIds:u,picked:s,setPicked:a,decision:c,showAll:g,setShowAll:x});const w=e.mode==="agent"&&!t.agents.some(r=>r.agentId===e.agentId),I=e.mode==="agent"&&P(y[e.agentId])==="custom";return n.jsxs("div",{className:"space-y-4",children:[e.mode==="page"&&n.jsx(It,{value:i,onChange:o,everyAgentAvailable:t.everyAgent.available}),e.mode==="agent"&&e.request&&n.jsx(bt,{agentName:((E=t.agents.find(r=>r.agentId===e.agentId))==null?void 0:E.displayName)??"The agent",serviceName:e.serviceName,reason:e.request.reason,access:e.request.access,level:d}),C,k?n.jsxs("p",{className:"text-muted-foreground text-sm",children:[e.serviceName," has no actions for agents yet."]}):!w&&!I&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("p",{id:`${m}-level`,className:"text-muted-foreground text-xs font-medium",children:e.mode==="page"?"They can":"It can"}),v.length>1?n.jsx(pn,{"aria-labelledby":`${m}-level`,value:d??"",onValueChange:r=>l(r),children:v.map(r=>n.jsx(yn,{value:r,className:"min-h-9",children:re[r]},r))}):n.jsx("p",{className:"text-sm",children:re[v[0]]}),d===null&&n.jsx("p",{className:"text-muted-foreground text-xs",children:i==="every"?t.everyAgent.operationRevisionIds.length>0?"Every agent has exact actions now. Pick a level to replace them.":"Pick what every agent can do.":"Your agents have different access. Pick one for every ticked agent."}),e.mode==="page"&&i==="every"&&n.jsx(Nt,{preview:t,level:d,serviceName:e.serviceName})]}),e.mode==="page"&&e.appActions&&n.jsx(mt,{toolkit:e.appActions.toolkit,appName:e.serviceName,providerInstanceId:e.appActions.providerInstanceId,grant:{candidates:t.candidates,level:k?null:d}}),(e.mode==="page"||N)&&n.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center justify-between gap-2 text-xs",children:[e.mode==="page"&&i==="picked"&&n.jsx("span",{children:"Others can still ask you in chat."}),N]})]})}function an({onClick:e}){return n.jsx(S,{variant:"link",size:"xs",className:"h-auto p-0",onClick:e,children:"Choose exact actions"})}function le(e=""){return{definitionId:"",agentId:e,destinationKind:"agent",destinationId:"",filterValues:{}}}function $t(e){if(e.deliveryMode==="webhook")return"Sent the moment it happens";if(e.deliveryMode==="unknown")return"Delivery timing unknown";if(e.expectedCadenceSeconds===null)return"Check timing unknown";if(e.expectedCadenceSeconds<60)return`Checks about every ${e.expectedCadenceSeconds} seconds`;const t=Math.round(e.expectedCadenceSeconds/60);return`Checks about every ${t} ${t===1?"minute":"minutes"}`}function Rt({connectionId:e,definitions:t,draft:s}){const a=t.find(d=>d.id===s.definitionId);if(!a||!s.agentId)return null;const i=he(a.filterSchema);if(!i)return null;const o=vn(i,s.filterValues);if(!o)return null;const c=s.destinationKind==="agent"?s.agentId:s.destinationId;return c?{connectionId:e,definitionId:a.id,filter:o,agentId:s.agentId,destination:{kind:s.destinationKind,id:c}}:null}function Et({idPrefix:e,definitions:t,draft:s,onChange:a,agents:i,fixedAgent:o,sourceStatus:c}){var I,E;const d=(o==null?void 0:o.id)??s.agentId,l=t.find(r=>r.id===s.definitionId),g=l?he(l.filterSchema):[],x=jn(d||null,{enabled:s.destinationKind==="room"}),u=Kn(),m=Nn(s.destinationKind==="channel"),y=p.useMemo(()=>new Set((m.data??[]).filter(r=>r.config.enabled).map(r=>r.config.id)),[m.data]),h=p.useMemo(()=>(u.data??[]).filter(r=>r.agentId===d&&r.enabled&&r.canInitiate&&!!r.chatId&&y.has(r.adapterId)),[d,u.data,y]),j=r=>{a({...s,...r,...o?{agentId:o.id}:{}})},f=r=>{if(r===s.definitionId)return;const $=t.find(L=>L.id===r),R=$?he($.filterSchema):[];j({definitionId:r,filterValues:kn(R??[])})},v=`${e}-event`,k=`${e}-agent`,N=`${e}-destination-kind`,C=`${e}-room`,w=`${e}-channel`;return n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(T,{htmlFor:v,children:"Account activity"}),n.jsxs(Q,{value:s.definitionId,onValueChange:f,children:[n.jsx(G,{id:v,"aria-label":"Account activity",children:n.jsx(H,{placeholder:"Choose activity"})}),n.jsx(Y,{children:t.map(r=>n.jsx(W,{value:r.id,children:r.displayName},r.id))})]}),l&&n.jsx("p",{className:"text-muted-foreground text-xs",children:$t(l)})]}),n.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[n.jsx("div",{className:"space-y-1",children:o?n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Agent"}),n.jsx("p",{id:k,className:"bg-muted/40 mt-1 rounded-md px-3 py-2 text-sm",children:o.displayName})]}):n.jsxs(n.Fragment,{children:[n.jsx(T,{htmlFor:k,children:"Agent"}),n.jsxs(Q,{value:s.agentId,onValueChange:r=>j({agentId:r,destinationId:""}),children:[n.jsx(G,{id:k,"aria-label":"Agent",children:n.jsx(H,{placeholder:"Choose agent"})}),n.jsx(Y,{children:(i??[]).map(r=>n.jsx(W,{value:r.id,children:r.displayName},r.id))})]})]})}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(T,{htmlFor:N,children:"Send to"}),n.jsxs(Q,{value:s.destinationKind,onValueChange:r=>j({destinationKind:r,destinationId:""}),children:[n.jsx(G,{id:N,"aria-label":"Send to",children:n.jsx(H,{})}),n.jsxs(Y,{children:[n.jsx(W,{value:"agent",children:"Agent"}),n.jsx(W,{value:"room",children:"Room"}),n.jsx(W,{value:"channel",children:"Messaging channel"})]})]})]})]}),s.destinationKind==="room"&&d&&n.jsxs("div",{className:"space-y-1",children:[n.jsx(T,{htmlFor:C,children:"Room"}),n.jsxs(Q,{value:s.destinationId,onValueChange:r=>j({destinationId:r}),children:[n.jsx(G,{id:C,"aria-label":"Room",children:n.jsx(H,{placeholder:"Choose a room"})}),n.jsx(Y,{children:(((I=x.data)==null?void 0:I.rooms)??[]).map(r=>n.jsx(W,{value:r.id,children:r.slug?`#${r.slug}`:r.name},r.id))})]}),x.isError?n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t load this agent’s rooms."}),n.jsx(S,{type:"button",size:"sm",variant:"ghost",onClick:()=>void x.refetch(),children:"Try again"})]}):!x.isPending&&(((E=x.data)==null?void 0:E.rooms.length)??0)===0?n.jsx("p",{className:"text-muted-foreground text-xs",children:"This agent isn’t in any rooms."}):null]}),s.destinationKind==="channel"&&d&&n.jsxs("div",{className:"space-y-1",children:[n.jsx(T,{htmlFor:w,children:"Messaging channel"}),n.jsxs(Q,{value:s.destinationId,onValueChange:r=>j({destinationId:r}),children:[n.jsx(G,{id:w,"aria-label":"Messaging channel",children:n.jsx(H,{placeholder:"Choose a channel"})}),n.jsx(Y,{children:h.map(r=>n.jsx(W,{value:r.id,children:r.label||r.chatId},r.id))})]}),u.isError||m.isError?n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t load this agent’s messaging channels."}),n.jsx(S,{type:"button",size:"sm",variant:"ghost",onClick:()=>{u.refetch(),m.refetch()},children:"Try again"})]}):!u.isPending&&!m.isPending&&h.length===0?n.jsx("p",{className:"text-muted-foreground text-xs",children:"No channels this agent can start."}):null]}),l&&g===null&&n.jsx("p",{role:"alert",className:"text-muted-foreground rounded-md border p-3 text-sm",children:"This notification’s filters can’t be shown yet."}),(l==null?void 0:l.deliveryMode)==="unknown"&&n.jsx("p",{className:"text-muted-foreground rounded-md border p-3 text-sm",children:"This service hasn’t shared its timing. Setup may stay pending."}),(c==null?void 0:c.setupMode)==="byo_webhook"&&!c.configured&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"Save delivery setup above first."}),g==null?void 0:g.map(r=>{var L;const $=`${e}-filter-${r.name}`,R=(L=r.examples)!=null&&L.length?`${$}-examples`:void 0;return n.jsxs("div",{className:"space-y-1",children:[r.type==="boolean"?n.jsxs("div",{className:"flex min-h-11 items-center gap-2",children:[n.jsx(qe,{id:$,"aria-describedby":R,checked:s.filterValues[r.name]===!0,onCheckedChange:b=>j({filterValues:{...s.filterValues,[r.name]:b===!0}})}),n.jsx(T,{htmlFor:$,children:r.label})]}):r.options?n.jsxs(n.Fragment,{children:[n.jsx(T,{htmlFor:$,children:r.label}),n.jsxs(Q,{value:typeof s.filterValues[r.name]=="string"?String(r.options.indexOf(String(s.filterValues[r.name]))):"",onValueChange:b=>j({filterValues:{...s.filterValues,[r.name]:r.options[Number(b)]}}),children:[n.jsx(G,{id:$,"aria-label":r.label,"aria-describedby":R,children:n.jsx(H,{placeholder:`Choose ${r.label.toLowerCase()}`})}),n.jsx(Y,{children:r.options.map((b,F)=>n.jsx(W,{value:String(F),children:b===""?"Leave blank":b},b))})]})]}):n.jsxs(n.Fragment,{children:[n.jsx(T,{htmlFor:$,children:r.label}),n.jsx(ge,{id:$,type:r.type==="string"?"text":"number","aria-describedby":R,required:(r.required||r.defaultValue!==void 0)&&r.type!=="string",step:r.type==="integer"?1:"any",value:typeof s.filterValues[r.name]=="string"?String(s.filterValues[r.name]):"",onChange:b=>j({filterValues:{...s.filterValues,[r.name]:b.target.value}})})]}),R&&n.jsxs("p",{id:R,className:"text-muted-foreground text-xs break-words",children:["Examples (not selected):"," ",r.examples.map(b=>JSON.stringify(b)).join(", ")]})]},r.name)})]})}function _t(e){try{const t=new URL(e);return t.protocol==="https:"&&t.username===""&&t.password===""&&t.pathname==="/"&&t.search===""&&t.hash===""}catch{return!1}}function Lt(e){return e.setupMode==="managed"||e.setupMode==="byo_webhook"&&e.configured}function Ft({connectionId:e,status:t,idPrefix:s="notification"}){const a=Hn(),[i,o]=p.useState(""),[c,d]=p.useState(""),l=a.data??t;if(l.setupMode==="managed")return null;if(l.setupMode==="unavailable")return n.jsx("p",{className:"text-muted-foreground bg-muted/40 rounded-lg p-3 text-sm",children:l.reason??"Notification setup isn’t available for this account."});const g=`${s}-public-origin`,x=`${s}-webhook-secret`;return n.jsxs("div",{className:"space-y-3 rounded-lg border p-3","data-testid":"notification-source-setup",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Service delivery"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Add your public DorkOS address and Composio’s signing secret."}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"The secret is sent once and never shown again."})]}),l.configured&&l.endpoint&&n.jsxs("div",{className:"bg-muted/40 rounded-md p-2.5",children:[n.jsx("p",{className:"text-muted-foreground text-xs",children:"Webhook endpoint"}),n.jsx("p",{className:"mt-1 font-mono text-xs break-all",children:l.endpoint})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(T,{htmlFor:g,children:"Public DorkOS address"}),n.jsx(ge,{id:g,type:"url",placeholder:"https://your-dorkos.example",value:i,onChange:u=>o(u.target.value)})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(T,{htmlFor:x,children:"Signing secret"}),n.jsx(ge,{id:x,type:"password",autoComplete:"off",value:c,onChange:u=>d(u.target.value)})]}),a.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t save delivery setup. Enter the signing secret again."}),n.jsx(S,{type:"button",size:"sm",variant:"secondary",disabled:a.isPending||c.length<16||!_t(i.trim()),onClick:()=>{const u=c;d(""),a.mutate({connectionId:e,input:{publicOrigin:i.trim(),webhookSecret:u}})},children:a.isPending?"Saving…":l.configured?"Update setup":"Save setup"})]})}function Tt(e){return(e.split(".").at(-1)??e).replaceAll("_"," ").replace(/\b\w/g,s=>s.toUpperCase())}function Pt({connectionId:e,requestedEvents:t,agent:s,onChange:a}){const i=Qn(e),o=Gn(e),c=p.useMemo(()=>[...new Set(t)],[t]),[d,l]=p.useState(()=>Object.fromEntries(c.map(u=>[u,le(s.id)]))),g=p.useMemo(()=>{var u;return((u=i.data)==null?void 0:u.pages.flatMap(m=>m.definitions))??[]},[i.data]),x=p.useMemo(()=>{if(!o.data||!Lt(o.data))return null;const u=c.map(m=>Rt({connectionId:e,definitions:g.filter(y=>y.eventType===m),draft:d[m]??le(s.id)}));return u.every(m=>m!==null)?u:null},[s.id,e,g,d,c,o.data]);return p.useEffect(()=>a(x),[a,x]),n.jsxs("fieldset",{className:"space-y-3","data-testid":"agent-request-event-scopes",children:[n.jsx("legend",{className:"text-sm font-medium",children:"Notifications"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Pick where this agent gets each kind of activity."}),o.isPending?n.jsx(z,{className:"h-20 rounded-lg","aria-label":"Loading delivery setup"}):o.isError?n.jsx(V,{title:"Couldn’t load delivery setup",description:"No access changed. Try again.",onRetry:()=>void o.refetch(),isRetrying:o.isFetching}):o.data?n.jsx(Ft,{connectionId:e,status:o.data,idPrefix:"agent-request-source"}):null,i.isPending?n.jsx(z,{className:"h-28 rounded-lg","aria-label":"Loading notification choices"}):i.isError?n.jsx(V,{title:"Couldn’t load notification choices",description:"Nothing changed. Try again.",onRetry:()=>void i.refetch(),isRetrying:i.isFetching}):n.jsxs("div",{className:"space-y-3",children:[c.map((u,m)=>{const y=g.filter(h=>h.eventType===u);return n.jsxs("section",{"aria-labelledby":`agent-request-event-${m}`,className:"bg-muted/30 space-y-3 rounded-lg p-3",children:[n.jsx("div",{children:n.jsx("h3",{id:`agent-request-event-${m}`,className:"text-sm font-medium",children:Tt(u)})}),y.length===0?n.jsx("p",{className:"text-muted-foreground text-sm",children:i.hasNextPage?"Load more options to finish.":"This account doesn’t offer this now."}):n.jsx(Et,{idPrefix:`agent-request-event-${m}`,definitions:y,draft:d[u]??le(s.id),onChange:h=>l(j=>({...j,[u]:h})),fixedAgent:s,sourceStatus:o.data})]},u)}),i.hasNextPage&&n.jsx(S,{type:"button",size:"sm",variant:"ghost",disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:i.isFetchingNextPage?"Loading…":"Load more notification options"})]})]})}const Ot=new Set(["failed","expired","start_unknown"]);function Dt({account:e,serviceName:t,logo:s,agentName:a,onDecline:i,deciding:o,onConnectAgain:c}){var C,w,I;const d=p.useId(),l=ye(),g=$n(),x=Rn(),u=En(),[m,y]=p.useState(null),h=_n(m),j=(C=h.data)==null?void 0:C.state,f=j!==void 0&&Ot.has(j),v=((w=h.data)==null?void 0:w.state)==="pending"?h.data.authorizeUrl:void 0,k=g.isError||x.isError||f,N=(I=e.readiness.fix)==null?void 0:I.action;return n.jsxs(Z,{titleId:d,toolkit:e.toolkit,serviceName:t,logo:s,title:`Let ${a} use ${t}?`,subtitle:e.label,className:"max-w-xl",children:[n.jsx("p",{className:"text-sm","data-testid":"account-attention","data-reason":e.readiness.reason,children:e.readiness.copy.owner}),v&&n.jsx(S,{asChild:!0,className:"w-full sm:w-auto",children:n.jsxs(Be,{href:v,children:["Sign in to ",t,n.jsx(Ue,{className:"size-4","aria-hidden":!0})]})}),m&&!v&&!f&&j!=="connected"&&n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(ce,{className:"size-4 animate-spin motion-reduce:animate-none","aria-hidden":!0}),"Getting the sign-in page ready…"]}),k&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t finish that. Nothing changed. Try again."}),n.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[n.jsx(S,{variant:"ghost",onClick:i,disabled:o,children:"Not now"}),N==="resume"&&n.jsx(S,{onClick:()=>g.mutate({connectionId:e.connectionId,input:void 0}),disabled:g.isPending,children:g.isPending?"Resuming…":"Resume"}),N==="sign_in_again"&&(!m||f)&&n.jsx(S,{onClick:()=>x.mutate({connectionId:e.connectionId},{onSuccess:E=>y(E.flowId)}),disabled:x.isPending,children:"Sign in again"}),N==="retry"&&n.jsx(S,{variant:"secondary",onClick:()=>u.mutate(),disabled:u.isPending,children:u.isPending?"Checking…":"Check again"}),N==="fix_key"&&n.jsx(S,{variant:"secondary",onClick:()=>l.open("connections","ways"),children:"Fix the key"}),N==="connect_new"&&n.jsxs(S,{onClick:c,children:["Connect ",t," again"]}),N==="review_access"&&n.jsx(S,{asChild:!0,variant:"secondary",children:n.jsxs(bn,{...Cn.connections(),search:{app:e.connectionId},children:["Open Connections",n.jsx(Sn,{className:"size-4","aria-hidden":!0})]})})]})]})}function on(e){var t;return((t=e==null?void 0:e.intents.find(s=>s.kind==="account"))==null?void 0:t.routes)??[]}function zt(e,t){const s=e.filter(i=>i.capabilities.authentication.status==="available");return((t==null?void 0:t.status)==="ready"?s.find(i=>i.providerInstanceId===t.way.providerInstanceId):void 0)??s.find(i=>i.mode==="managed")??s.find(i=>i.mode==="byo")??null}function Mt(e){const t=e==null?void 0:e.intents.find(s=>s.kind==="account");return(t==null?void 0:t.kind)==="account"&&!t.routes.some(s=>s.capabilities.authentication.status==="available")}function Wt(e){var t;return((e==null?void 0:e.warnings.length)??0)>0&&((t=e==null?void 0:e.appConnections)==null?void 0:t.newApps.status)==="ready"}function rn(e){return Vn(e.kind==="dorkos_account"?"dorkos-managed":e.type)}function Kt(e,t){return!(e!=null&&e.signInThrough)||e.authKind!=="oauth2"||!t?null:`${t.signInName??t.displayName} will ask you to allow ${e.signInThrough}. DorkOS connects through it.`}function Vt(e,t){const s=(t==null?void 0:t.displayName)??"this app",a=on(t).map(o=>o.capabilities.authentication).find(o=>o.status==="unsupported");if((a==null?void 0:a.status)==="unsupported")return a.reason;const i=e==null?void 0:e.newApps;if(!i)return null;if(i.status==="ready")return`${rn(i.way)} can’t reach ${s} yet.`;switch(i.reason){case"dorkos_account_unavailable":return"Your DorkOS account is linked, but it can’t connect apps right now.";case"dorkos_account_unlinked":return"Your DorkOS account isn’t linked anymore.";case"own_key_unavailable":return"Your saved key didn’t work at the last check.";case"nothing_set_up":return null}}function qt({reason:e,onLeave:t}){var v;const s=qn(),a=Bn(),i=ye(),[o,c]=p.useState(!1);if(s.isPending)return n.jsx(z,{className:"h-24 rounded-lg","aria-label":"Loading setup options"});if(s.isError)return n.jsx(V,{title:"Couldn’t load the setup options",description:"Try again. Nothing was changed.",onRetry:()=>void s.refetch(),isRetrying:s.isFetching});const d=Pe(s.data,"composio"),l=Pe(s.data,"nango"),g=(v=a.data)==null?void 0:v.newApps,x=(g==null?void 0:g.status)==="setup_needed"?g.reason:null,u=x==="dorkos_account_unlinked"||x==="dorkos_account_unavailable",m=x==="nothing_set_up",y=x==="own_key_unavailable",h=u||m||y,j=()=>{t==null||t(),i.open("account")},f=u?n.jsx(S,{size:"lg",variant:"outline",className:"w-full",onClick:j,children:"Link my DorkOS account again"}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(S,{size:"lg",variant:m?"default":"outline",className:"w-full",onClick:j,children:"Use a DorkOS account"}),n.jsx("p",{className:"text-muted-foreground text-center text-xs",children:"Sign in or create one. DorkOS connects your apps for you."})]});return n.jsxs("div",{"data-testid":"first-connect-step",className:"space-y-4",children:[e&&n.jsx("p",{role:"status",className:"bg-muted/40 rounded-lg p-3 text-sm",children:e}),h&&!y&&f,d&&(o?n.jsx(Ce,{status:d}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs(S,{size:"lg",variant:u||m?"outline":"default",className:"w-full",onClick:()=>c(!0),children:[n.jsx(In,{className:"size-4","aria-hidden":!0}),"Use my Composio key"]}),n.jsx("p",{className:"text-muted-foreground text-center text-xs",children:"Have a Composio account? Paste its key."})]})),h&&y&&f,l&&n.jsxs(Me,{children:[n.jsxs(We,{className:"text-muted-foreground hover:text-foreground focus-ring group flex items-center gap-1 rounded-md text-sm font-medium",children:["Other ways",n.jsx(wn,{className:"size-4 transition-transform group-data-[state=open]:rotate-180","aria-hidden":!0})]}),n.jsxs(Ke,{className:"space-y-2 pt-3",children:[n.jsx("p",{className:"text-muted-foreground text-xs",children:"Your own Nango server. Sign-ins stay in your database."}),n.jsx(Ce,{status:l})]})]})]})}function Pe(e,t){return e==null?void 0:e.find(s=>s.type===t)}function Bt({request:e,serviceName:t,service:s,onConnected:a,onDecline:i,onBack:o,deciding:c,className:d}){var L;const l=p.useId(),[g,x]=p.useState(null),[u,m]=p.useState(!1),y=zn(e.requestId),h=Mn(e.requestId,g),j=He(e.serviceSlug),f=(L=j.data)==null?void 0:L.pages[0],v=f==null?void 0:f.appConnections,k=on(s),N=zt(k,v==null?void 0:v.newApps),C=h.data??y.data,w=!C&&Mt(s),I=Kt(N,s),E=(C==null?void 0:C.state)==="connected"?C.connectionId:null;p.useEffect(()=>{E&&a(E)},[E,a]);const r=()=>{if(w){m(!0);return}N&&y.mutate({providerInstanceId:N.providerInstanceId},{onSuccess:b=>x(b.flowId)})},$=(C==null?void 0:C.state)==="starting"||(C==null?void 0:C.state)==="pending";let R;return j.isPending&&!s?R=n.jsx(z,{className:"h-10 rounded-lg","aria-label":`Loading ${t}`}):w&&u?R=k.length===0&&Wt(f)&&(v==null?void 0:v.newApps.status)==="ready"?n.jsx(V,{title:`Couldn’t reach ${t} just now`,description:`${rn(v.newApps.way)} didn’t answer. Try again soon.`,onRetry:()=>void j.refetch(),isRetrying:j.isFetching}):n.jsx(qt,{reason:Vt(v,s)}):$?R=n.jsxs("div",{className:"space-y-3",children:[I&&n.jsx("p",{className:"text-sm",children:I}),C.state==="pending"&&C.authorizeUrl?n.jsx(S,{asChild:!0,className:"w-full sm:w-auto",children:n.jsxs(Be,{href:C.authorizeUrl,children:["Sign in to ",t,n.jsx(Ue,{className:"size-4","aria-hidden":!0})]})}):null,n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(ce,{className:"size-4 animate-spin motion-reduce:animate-none","aria-hidden":!0}),C.state==="starting"?"Getting the sign-in page ready…":`Finish signing in to ${t}…`]})]}):R=n.jsxs("div",{className:"space-y-2",children:[n.jsxs("p",{className:"text-sm",children:[n.jsxs("span",{className:"text-muted-foreground",children:[e.agent.displayName," asked: "]}),e.reason]}),I&&n.jsx("p",{className:"text-muted-foreground text-xs",children:I}),y.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t start sign-in. Try again."})]}),n.jsxs(Z,{titleId:l,toolkit:e.serviceSlug,serviceName:t,logo:ne(s),title:`Connect ${t}`,subtitle:`So ${e.agent.displayName} can use it`,className:d,children:[R,n.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[o&&n.jsx(S,{variant:"ghost",onClick:o,disabled:c,className:"mr-auto",children:"Back"}),n.jsx(S,{variant:"ghost",onClick:i,disabled:c,children:"Not now"}),!$&&!(w&&u)&&n.jsx(S,{onClick:r,disabled:y.isPending||c||!w&&!N,children:y.isPending?"Starting…":`Connect ${t}`})]})]})}function Ut(e,t){const s=e.agent.displayName;switch(e.status){case"granted":return`Allowed ${s} to use ${t}`;case"access_pending":return`Giving ${s} access to ${t}…`;case"denied":return`${s} wasn’t given ${t}`;case"expired":return`Request for ${t} timed out. ${s} can ask again.`;case"authentication_failed":return`Signing in to ${t} didn’t finish. Nothing was shared.`;case"target_deleted":return`Request for ${t} closed. The agent or its chat is gone.`;case"awaiting_owner":return`${s} is waiting for ${t}`}}function Qt({request:e,serviceName:t,className:s}){const a=e.status==="granted",i=e.status==="access_pending",o=a?ve:i?Je:Un;return n.jsxs("p",{role:"status","data-testid":"agent-request-receipt","data-status":e.status,className:O("bg-muted/40 text-muted-foreground flex items-start gap-2 rounded-lg px-3 py-2 text-sm",s),children:[n.jsx(o,{className:O("mt-0.5 size-4 shrink-0",a&&"text-status-success"),"aria-hidden":!0}),n.jsx("span",{className:O("min-w-0",a&&"text-foreground"),children:Ut(e,t)})]})}const Gt="Couldn’t save your answer. Nothing changed. Try again.";function Ht(e){return(e==null?void 0:e.code)==="session_access_off"}const Yt="Couldn’t turn it on for this chat. Nothing changed. Try again.";function Jt(e,t,s){switch(e==null?void 0:e.code){case"session_access_off":return{reason:`This chat has ${s} turned off for ${t}.`,fix:"turn_on"};case"request_already_resolved":return{reason:`It was answered somewhere else. Ask ${t} again if it still needs this.`,fix:null};case"request_expired":return{reason:`The request ran out of time. Ask ${t} again.`,fix:null};case"request_not_found":return{reason:"The request is no longer open.",fix:null};case"authority_sync_failed":return{reason:"The access is still being set up.",fix:"retry"};case"event_selection_unavailable":case"review_conflict":case"destination_unavailable":case"definition_changed":case"invalid_filter":return{reason:"The updates you picked can’t be set up. Pick again, or answer without them.",fix:"updates"};case"selection_invalid":return{reason:"That account isn’t ready for it yet.",fix:"retry"};default:return{reason:"The answer didn’t reach DorkOS.",fix:"retry"}}}function us({request:e,onEditExactActions:t,className:s}){var ee,se,M,Ne,ke;const a=Wn(),i=Ln(e.sessionId),o=Ht(a.error)?e.sessionId:null,c=Fn(o),d=Ge(),g=((ee=He(e.serviceSlug,e.status==="awaiting_owner").data)==null?void 0:ee.pages.flatMap(_=>_.services).find(_=>_.serviceSlug===e.serviceSlug))??null,x=(g==null?void 0:g.displayName)??Tn(e.serviceSlug),u=e.agent.displayName,[m,y]=p.useState(null),[h,j]=p.useState(null),[f,v]=p.useState([]),[k,N]=p.useState(!1),[C,w]=p.useState(!1),[I,E]=p.useState(null),r=p.useCallback(()=>{j(null),a.mutate({requestId:e.requestId,decision:{decision:"denied"}})},[a,e.requestId]),$=p.useCallback((_,U=[])=>{j(_),v(U),a.mutate({requestId:e.requestId,decision:{decision:"current_access",connectionId:_,eventScopes:U}})},[a,e.requestId]),R=e.requestedEvents.length>0,L=p.useCallback(_=>R?E(_):$(_),[$,R]),b=O("max-w-xl",s);if(h&&a.isError){const{reason:_,fix:U}=Jt(a.error,u,x),cn=U==="updates"&&I!==null,be=U==="turn_on"&&((Ne=(M=(se=c.data)==null?void 0:se.connections.find(dn=>dn.connectionId===h))==null?void 0:M.readiness.fix)==null?void 0:Ne.action)==="turn_on_for_this_chat";return n.jsxs(Z,{titleId:`agent-request-unanswered-${e.requestId}`,toolkit:e.serviceSlug,serviceName:x,logo:ne(g),title:`${u} can now use ${x}`,className:b,children:[n.jsxs("div",{role:"alert",className:"space-y-1 text-sm","data-testid":"agent-request-unanswered",children:[n.jsxs("p",{children:[n.jsx(ve,{className:"text-status-success mr-1.5 inline size-4 align-text-bottom","aria-hidden":!0}),"Access saved, but ",u,"’s request wasn’t answered."]}),n.jsxs("p",{children:[_,be&&" Turning it on only affects this chat."]})]}),cn?n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(S,{variant:"ghost",onClick:()=>$(h,[]),disabled:a.isPending,children:"Answer without updates"}),n.jsx(S,{onClick:()=>a.reset(),disabled:a.isPending,children:"Pick updates again"})]}):U==="retry"&&n.jsx("div",{className:"flex justify-end",children:n.jsx(S,{onClick:()=>$(h,f),disabled:a.isPending,children:a.isPending?"Sending…":"Try again"})}),be&&n.jsxs(n.Fragment,{children:[i.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:Yt}),n.jsx("div",{className:"flex justify-end",children:n.jsx(S,{onClick:()=>i.mutate({connectionId:h,on:!0},{onSuccess:()=>$(h,f)}),disabled:i.isPending||a.isPending,children:i.isPending||a.isPending?"Turning on…":"Turn on for this chat"})})]})]})}if(e.status!=="awaiting_owner")return n.jsx(Qt,{request:e,serviceName:x,className:b});const F=a.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:Gt});if(I)return n.jsx(Xt,{request:e,connectionId:I,serviceName:x,logo:ne(g),onAnswer:_=>$(I,_),deciding:a.isPending,className:b},I);if(d.isPending)return n.jsx(z,{className:O("h-28 rounded-xl",b),"aria-label":"Loading accounts"});if(d.isError)return n.jsx("div",{className:b,children:n.jsx(V,{title:"Couldn’t load your accounts",description:"Nothing changed. Try again.",onRetry:()=>void d.refetch(),isRetrying:d.isFetching})});const A=((ke=d.data)==null?void 0:ke.connections)??[],B=A.filter(_=>_.toolkit===e.serviceSlug&&_.readiness.state!=="gone"),te=sn(A,e.serviceSlug),X=k||!!m||te.length>0;if(!m&&(C||!X&&B.length===0))return n.jsxs("div",{className:O("space-y-2",b),children:[n.jsx(Bt,{request:e,serviceName:x,service:g,onConnected:y,onDecline:r,...B.length>0?{onBack:()=>w(!1)}:{},deciding:a.isPending}),F]});if(!X){const _=B[0];return n.jsxs("div",{className:O("space-y-2",b),children:[n.jsx(Dt,{account:_,serviceName:x,logo:ne(g),agentName:u,onDecline:r,deciding:a.isPending,onConnectAgain:()=>w(!0)}),F]})}return n.jsx(Zt,{onShown:N,children:n.jsxs("div",{className:O("space-y-2",b),"data-testid":"agent-request-access",children:[n.jsx(wt,{mode:"agent",agentId:e.agent.id,toolkit:e.serviceSlug,serviceName:x,logo:ne(g),...m?{connectionId:m}:{},request:{reason:e.reason,access:e.access},...t?{onEditExactActions:t}:{},onSkip:r,onAllowed:L}),!m&&!h&&n.jsxs(S,{variant:"link",size:"sm",className:"h-auto px-0",onClick:()=>w(!0),children:["Connect another ",x," account"]}),F]})})}function Zt({onShown:e,children:t}){return p.useEffect(()=>e(!0),[e]),n.jsx(n.Fragment,{children:t})}function Xt({request:e,connectionId:t,serviceName:s,logo:a,onAnswer:i,deciding:o,className:c}){const[d,l]=p.useState(null);return n.jsxs(Z,{titleId:`agent-request-updates-${e.requestId}`,toolkit:e.serviceSlug,serviceName:s,logo:a,title:`Send ${e.agent.displayName} updates from ${s}?`,subtitle:`${e.agent.displayName} can now use ${s}`,className:c,children:[n.jsx(Pt,{connectionId:t,requestedEvents:e.requestedEvents,agent:e.agent,onChange:l}),n.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[n.jsx(S,{variant:"ghost",onClick:()=>i([]),disabled:o,children:"No updates"}),n.jsx(S,{onClick:()=>d&&i(d),disabled:o||!d,children:o?"Sending…":"Send updates"})]})]})}export{us as A,Ft as C,qt as F,gt as L,nn as R,Qn as a,rs as b,cs as c,ds as d,le as e,Rt as f,Et as g,$t as h,Lt as i,de as j,wt as k,on as l,zt as m,Mt as n,Kt as o,Wt as p,Vt as q,mt as r,ne as s,at as t,Gn as u,q as v,rn as w,ls as x,yt as y};