dorkos 0.114.0 → 0.115.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/dist/bin/cli.js +39739 -38935
  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-mErbIY0l.js → AboutPage-Cz8ijNrK.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-AlI4F82u.js → ActivityErrorState-BzmfwxSZ.js} +1 -1
  6. package/dist/client/assets/ActivityPage-BK7T3OiI.js +1 -0
  7. package/dist/client/assets/{ActivityRow-Baqdr6cP.js → ActivityRow-Ig5atv15.js} +1 -1
  8. package/dist/client/assets/AdapterIcon-BXPv5J8h.js +1 -0
  9. package/dist/client/assets/{AdapterSetupWizard-BL70qy2J.js → AdapterSetupWizard-BEziztL3.js} +2 -2
  10. package/dist/client/assets/AgentOptionRow-BqFQvFeN.js +1 -0
  11. package/dist/client/assets/AgentPicker-dCfEIsU-.js +1 -0
  12. package/dist/client/assets/{AgentRequestCard-CcMh6JyE.js → AgentRequestCard-BAhfGJxx.js} +3 -3
  13. package/dist/client/assets/AppearancePage-7qHhFeEv.js +1 -0
  14. package/dist/client/assets/ApplyToOverridesDialog-jqOFh0d1.js +1 -0
  15. package/dist/client/assets/AttentionSignalRow-3CgglXkd.js +1 -0
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-DHr_AhUv.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-BMKtHI0D.js} +3 -3
  17. package/dist/client/assets/BindingDialog-DSBxRyzA.js +1 -0
  18. package/dist/client/assets/{BlintzCanvas-Bq4e7n__.js → BlintzCanvas-CyRuqAJV.js} +1 -1
  19. package/dist/client/assets/{CanvasCsvContent-OR226CLS.js → CanvasCsvContent-Bd1c6TGx.js} +4 -4
  20. package/dist/client/assets/CanvasFileContent-DelYwSH8.js +2 -0
  21. package/dist/client/assets/CanvasModel3dContent-BExIu4RY.js +2 -0
  22. package/dist/client/assets/ChatAppsOff-SWemSaUp.js +6 -0
  23. package/dist/client/assets/{CodeMirrorDiff-D7BWMOim.js → CodeMirrorDiff-0WF4ITRZ.js} +1 -1
  24. package/dist/client/assets/{CodeMirrorEditor-BodwsIG7.js → CodeMirrorEditor-Bg7wC_Q8.js} +1 -1
  25. package/dist/client/assets/CommitmentList-CTvEGUV3.js +1 -0
  26. package/dist/client/assets/{CommitmentsPage-DL_jJQbw.js → CommitmentsPage-C68etoLe.js} +1 -1
  27. package/dist/client/assets/ConnectionAccessLists-9oeVn_GK.js +1 -0
  28. package/dist/client/assets/ConnectionsPage-CJOY4-kp.js +6 -0
  29. package/dist/client/assets/ConventionPage-DD-f5o6y.js +11 -0
  30. package/dist/client/assets/{ExtensionPageRoute-CzXGvVRm.js → ExtensionPageRoute-C6fW17AG.js} +2 -2
  31. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-BV3h0rFa.js → FloatingTanStackRouterDevtools-CqogiFob-Zccd0fv6.js} +1 -1
  32. package/dist/client/assets/HandlePage-DOxlquWl.js +1 -0
  33. package/dist/client/assets/HeartbeatPage-cJM6NuTD.js +1 -0
  34. package/dist/client/assets/KeyEntry-K5k_3TfU.js +6 -0
  35. package/dist/client/assets/{LexicalField-Cc6wFZAZ.js → LexicalField-DB5V20zv.js} +2 -2
  36. package/dist/client/assets/{ManagesPage-BxHSb65X.js → ManagesPage-Cj0-hwfr.js} +1 -1
  37. package/dist/client/assets/{Marketplace-EgG6JmBG.js → Marketplace-eWEtLmd9.js} +2 -2
  38. package/dist/client/assets/{MarketplaceSourcesView-D9kq9hl6.js → MarketplaceSourcesView-B1h70C20.js} +1 -1
  39. package/dist/client/assets/{McpAppFrame-6zxszx9A.js → McpAppFrame-BaJ_r-QR.js} +2 -2
  40. package/dist/client/assets/McpSigninBody-Coaq5Fkf.js +1 -0
  41. package/dist/client/assets/{Model3dViewer-CgeJ2v-F.js → Model3dViewer-cKa-Jnbl.js} +1 -1
  42. package/dist/client/assets/NamePage-W7Frb1yy.js +1 -0
  43. package/dist/client/assets/{NewDirectMessageMenu-BnBO4aGI.js → NewDirectMessageMenu-C4zNIv9x.js} +1 -1
  44. package/dist/client/assets/{NotificationsPage-C5aRITCd.js → NotificationsPage-gKNClvNU.js} +1 -1
  45. package/dist/client/assets/{OpenMeshSwitch-UKMQeS7-.js → OpenMeshSwitch-RzB2u6-Q.js} +2 -2
  46. package/dist/client/assets/OperatorIdentityForm-B_78Vqh8.js +1 -0
  47. package/dist/client/assets/PermissionHistory-DrtlA4YM.js +1 -0
  48. package/dist/client/assets/PermissionsPage-O7kUVaQv.js +1 -0
  49. package/dist/client/assets/{PersonalityPopover-vLDfndfo.js → PersonalityPopover-DiNuuoWu.js} +1 -1
  50. package/dist/client/assets/PhotoPage-DdBke3yj.js +1 -0
  51. package/dist/client/assets/PresetPicker-BUFwg8RS.js +19 -0
  52. package/dist/client/assets/{PreviewRefusedNotice-Dh3SCC_A.js → PreviewRefusedNotice-DXZp669C.js} +1 -1
  53. package/dist/client/assets/ProfileFields-BCfMzNcT.js +1 -0
  54. package/dist/client/assets/ProfilePanelContainer-BzC2MGdi.js +1 -0
  55. package/dist/client/assets/ProfileRolePicker-f0FKXLtu.js +1 -0
  56. package/dist/client/assets/PromptSuggestionChips-EgeMFibt.js +1 -0
  57. package/dist/client/assets/ReportsToPopover-CQ4Xxslu.js +1 -0
  58. package/dist/client/assets/RoomSurface-oDbc6jnO.js +44 -0
  59. package/dist/client/assets/{RoomsPage-pPw8vrsB.js → RoomsPage-D_EbiSZ3.js} +1 -1
  60. package/dist/client/assets/RunsOnPopover-LtmmbIsD.js +1 -0
  61. package/dist/client/assets/RuntimeConnectFlow-Kv2ytk2m.js +1 -0
  62. package/dist/client/assets/RuntimeSetupDialog-CiWxlcPc.js +1 -0
  63. package/dist/client/assets/{SessionsPage-BASybh9v.js → SessionsPage-1rDO0SGV.js} +1 -1
  64. package/dist/client/assets/SettingsDialog-_ctp2AfE.js +12 -0
  65. package/dist/client/assets/SkillsPage-gPuQHKps.js +1 -0
  66. package/dist/client/assets/TaskDialogWrapper-BPFpCgsN.js +1 -0
  67. package/dist/client/assets/TasksEmptyState-D0Jlzmed.js +3 -0
  68. package/dist/client/assets/TasksPage-DvGfg5Bk.js +1 -0
  69. package/dist/client/assets/{ToolsPage-C3xfGWdb.js → ToolsPage-B0qZ85pR.js} +2 -2
  70. package/dist/client/assets/{TopologyGraph-D7Ik1Xt6.js → TopologyGraph-q1ammgpG.js} +3 -3
  71. package/dist/client/assets/TourHost-Dc8qw1Ef.js +1 -0
  72. package/dist/client/assets/{UnlinkDialog-TTK5Z_QD.js → UnlinkDialog-DXdrLsGV.js} +1 -1
  73. package/dist/client/assets/{WidgetErrorCard-D--KcgW1.js → WidgetErrorCard-ChDNC060.js} +23 -23
  74. package/dist/client/assets/_shell-BxPza3Lx.js +88 -0
  75. package/dist/client/assets/{_shell._home-CzpVyTzo.js → _shell._home-DjGunhLV.js} +1 -1
  76. package/dist/client/assets/_shell._home.activity-B014dET1.js +1 -0
  77. package/dist/client/assets/_shell._home.index-DEmtTHZg.js +3 -0
  78. package/dist/client/assets/_shell._home.tasks-CnDEbUOd.js +1 -0
  79. package/dist/client/assets/_shell._home.workspaces-AQtMUWuu.js +1 -0
  80. package/dist/client/assets/{_shell.channels-CCGSs0Bn.js → _shell.channels-C8NOhmJd.js} +4 -4
  81. package/dist/client/assets/_shell.connections-Bxe0wxOB.js +1 -0
  82. package/dist/client/assets/{_shell.feedback-requests-C6alx2ox.js → _shell.feedback-requests-C6ku9F5_.js} +2 -2
  83. package/dist/client/assets/_shell.marketplace-CEnzWFmI.js +1 -0
  84. package/dist/client/assets/_shell.marketplace_.sources-BZq1d2ih.js +1 -0
  85. package/dist/client/assets/_shell.session-Dn0C0mEZ.js +66 -0
  86. package/dist/client/assets/{_shell.team-BIwJNdkd.js → _shell.team-DoLdOMoC.js} +4 -4
  87. package/dist/client/assets/_shell.x._extensionId-DhE3OYMF.js +1 -0
  88. package/dist/client/assets/_shell.x._extensionId_._-DhE3OYMF.js +1 -0
  89. package/dist/client/assets/access-copy-CBGtcTk0.js +1 -0
  90. package/dist/client/assets/{agent-browser-CO5haI5Y.js → agent-browser-DbcLtsAx.js} +1 -1
  91. package/dist/client/assets/{banner-Dh5mO27l.js → banner-rPsz3suJ.js} +2 -2
  92. package/dist/client/assets/{card-CKZCX8ol.js → card-BqN3lfJn.js} +1 -1
  93. package/dist/client/assets/command-ZTLTCj0l.js +1 -0
  94. package/dist/client/assets/cpu-D70xMHl2.js +11 -0
  95. package/dist/client/assets/dead-letter-reasons-DtBHju9v.js +1 -0
  96. package/dist/client/assets/empty-state-yl1dLwLN.js +1 -0
  97. package/dist/client/assets/execution-config-BbBEe6FO.js +1 -0
  98. package/dist/client/assets/{file-CMPbZedq.js → file-CGg2M6ED.js} +1 -1
  99. package/dist/client/assets/{file-exclamation-point-emLeXvmw.js → file-exclamation-point-DZrVsShR.js} +1 -1
  100. package/dist/client/assets/{file-text-9a0DChCq.js → file-text-BYq_4IAt.js} +1 -1
  101. package/dist/client/assets/{find-latest-widget-fence--3kWMT1F.js → find-latest-widget-fence-CWs9nr10.js} +3 -3
  102. package/dist/client/assets/form-vPuXuaYT.js +1 -0
  103. package/dist/client/assets/format-cron-D02Tnupo.js +1 -0
  104. package/dist/client/assets/{git-branch-hfu8isLA.js → git-branch-DbjXDO_F.js} +1 -1
  105. package/dist/client/assets/{heart-SRafwnSd.js → heart-Dblp_miM.js} +1 -1
  106. package/dist/client/assets/{highlighted-body-KPVGNVTW-Dxwd3mxT.js → highlighted-body-KPVGNVTW-CaMXMak-.js} +1 -1
  107. package/dist/client/assets/index-B-WvQ24u.js +23 -0
  108. package/dist/client/assets/{index-Ch41JOI2.js → index-BKuzoeSn.js} +1 -1
  109. package/dist/client/assets/{index-DdsKmfEH.js → index-BOL391En.js} +1 -1
  110. package/dist/client/assets/{index-DLZi_nae.js → index-BPqkuMIa.js} +1 -1
  111. package/dist/client/assets/{index-BTXBESRm.js → index-BPwUl0Bz.js} +1 -1
  112. package/dist/client/assets/{index-DIlV08Vw.js → index-BV0tZnYg.js} +1 -1
  113. package/dist/client/assets/{index-3GDQSKet.js → index-BW98owO8.js} +1 -1
  114. package/dist/client/assets/{index-BTreBsWa.js → index-Bd23EYYT.js} +2 -2
  115. package/dist/client/assets/{index-BYp9xcmS.js → index-BdVOtoFr.js} +1 -1
  116. package/dist/client/assets/{index-CpYs0Lli.js → index-Bi7Um5RU.js} +1 -1
  117. package/dist/client/assets/{index-BRGOMmOM.js → index-BiIbMZ6d.js} +36 -36
  118. package/dist/client/assets/{index-C7BTAdSc.js → index-BxqUb-n7.js} +1 -1
  119. package/dist/client/assets/{index-DmTI5Hye.js → index-BzczIyv5.js} +1 -1
  120. package/dist/client/assets/index-C6NUjpzQ.js +38 -0
  121. package/dist/client/assets/{index-D67aFWxz.js → index-C88NZagl.js} +1 -1
  122. package/dist/client/assets/{index-BDfoFNcA.js → index-CHvi6xUU.js} +1 -1
  123. package/dist/client/assets/{index-CbFo-7kM.js → index-CMWMhbec.js} +1 -1
  124. package/dist/client/assets/{index-BB18IeC2.js → index-CN9fywRC.js} +1 -1
  125. package/dist/client/assets/{index-iD0epmn3.js → index-CRZXSh_q.js} +1 -1
  126. package/dist/client/assets/{index-YswfjpmW.js → index-CWNsRK97.js} +1 -1
  127. package/dist/client/assets/index-CaLw69VE.js +1 -0
  128. package/dist/client/assets/index-CdKpQ1hI.js +1018 -0
  129. package/dist/client/assets/{index-Cp7oifSs.js → index-CrK4rKAq.js} +1 -1
  130. package/dist/client/assets/{index-D_Wc_qTa.js → index-D16KF-iC.js} +3 -3
  131. package/dist/client/assets/index-D6m2SWHr.js +1 -0
  132. package/dist/client/assets/index-DDYi817r.js +1 -0
  133. package/dist/client/assets/{index-BokDvdOG.js → index-Db2EOzA3.js} +1 -1
  134. package/dist/client/assets/index-DdbHrvr0.js +1 -0
  135. package/dist/client/assets/index-Dg_bax15.js +17 -0
  136. package/dist/client/assets/index-DwUdUliR.js +1 -0
  137. package/dist/client/assets/{index-D0Nd2LA-.js → index-DzeYt-GT.js} +1 -1
  138. package/dist/client/assets/{index-lJc8v0Z3.js → index-Gq3gqBhY.js} +1 -1
  139. package/dist/client/assets/index-O_HMols_.js +1 -0
  140. package/dist/client/assets/{index-Cow815Qa.js → index-P5j6zmcN.js} +1 -1
  141. package/dist/client/assets/{index-BNn3-chz.js → index-XE46wAj9.js} +1 -1
  142. package/dist/client/assets/{index-C4nEz6I-.js → index-Z8YcKwIB.js} +1 -1
  143. package/dist/client/assets/{index-DFEF2MFy.css → index-kktlr1TJ.css} +1 -1
  144. package/dist/client/assets/{index-CAlXjm0N.js → index-lNMJBFB0.js} +1 -1
  145. package/dist/client/assets/{index-DX7V94qe.js → index-oWLYcpm4.js} +1 -1
  146. package/dist/client/assets/{index-DRqEM5Wb.js → index-vRc1D4KI.js} +1 -1
  147. package/dist/client/assets/inline-code-Cvn43Gqu.js +1 -0
  148. package/dist/client/assets/{layers-Cy8Tme6i.js → layers-Bmz62WF4.js} +1 -1
  149. package/dist/client/assets/{lightbulb-tNm7gLYi.js → lightbulb-CAd6slmc.js} +1 -1
  150. package/dist/client/assets/link-2-C0mn8T24.js +6 -0
  151. package/dist/client/assets/list-runtime-types-DxwGcKLx.js +1 -0
  152. package/dist/client/assets/{markdown-content-CoK3F0c0.js → markdown-content-1-B7PdbY.js} +1 -1
  153. package/dist/client/assets/{mention-pill-Bgs_yujj.js → mention-pill-D_-KXznh.js} +1 -1
  154. package/dist/client/assets/{message-square-off-CF2Bzen3.js → message-square-off-Di7kQvfe.js} +1 -1
  155. package/dist/client/assets/more-details-C6UGVeDE.js +1 -0
  156. package/dist/client/assets/{owner-notice-cgCWG4hG.js → owner-notice-CudDDBX4.js} +1 -1
  157. package/dist/client/assets/{package-DE8sQpId.js → package-D2eMoFCI.js} +1 -1
  158. package/dist/client/assets/{page-container-BoXmmBSs.js → page-container-CDHAACRA.js} +1 -1
  159. package/dist/client/assets/{paperclip-IgDeVFea.js → paperclip-p0W24D54.js} +1 -1
  160. package/dist/client/assets/path-input-j04LMj9z.js +1 -0
  161. package/dist/client/assets/primer-trigger-DkCcHf2Q.js +3 -0
  162. package/dist/client/assets/profile-errors-CqflLCzu.js +1 -0
  163. package/dist/client/assets/progress-BcuH4Eod.js +6 -0
  164. package/dist/client/assets/query-error-state-CEZs7dhg.js +1 -0
  165. package/dist/client/assets/{radio-BzTkFBDD.js → radio-DGWfQ5Rf.js} +1 -1
  166. package/dist/client/assets/registry-ChxwU0f4.js +1 -0
  167. package/dist/client/assets/relay-trace-schemas-y0nd8fzi.js +6 -0
  168. package/dist/client/assets/{room-files-source-CIIDTSTA.js → room-files-source-C1TCg4W_.js} +2 -2
  169. package/dist/client/assets/{rotate-ccw-clock-CGcSqHnk.js → rotate-ccw-clock-DcBojy-0.js} +1 -1
  170. package/dist/client/assets/{rotate-cw-DaduzRfP.js → rotate-cw-D0vUyeR2.js} +1 -1
  171. package/dist/client/assets/runtime-connect-Dn0T5YWv.js +1 -0
  172. package/dist/client/assets/{scroll-area-DW0-Liri.js → scroll-area-CQ9lO56h.js} +1 -1
  173. package/dist/client/assets/{search-x-Sme5ElYi.js → search-x-EJGj73JB.js} +2 -2
  174. package/dist/client/assets/settings-for-runtime-BoOa-ZFG.js +1 -0
  175. package/dist/client/assets/shield-check-Bp58y9u7.js +6 -0
  176. package/dist/client/assets/{shield-x-Bh5xap8N.js → shield-x-jF_NCCvp.js} +1 -1
  177. package/dist/client/assets/soul-file-Cag2i87x.js +1 -0
  178. package/dist/client/assets/{table-BEtvgYmW.js → table-D89CWVJX.js} +1 -1
  179. package/dist/client/assets/terminal-BUhNMZAt.js +6 -0
  180. package/dist/client/assets/trust-posture-15DMDZTA.js +1 -0
  181. package/dist/client/assets/unplug-opnrSXAi.js +6 -0
  182. package/dist/client/assets/unverified-catalog-notice-DHM5Coia.js +1 -0
  183. package/dist/client/assets/use-adapter-catalog-ClMqVelU.js +1 -0
  184. package/dist/client/assets/use-bindings-Ch6UUBvz.js +1 -0
  185. package/dist/client/assets/use-composer-prefs-Qn7KRpYe.js +1 -0
  186. package/dist/client/assets/{use-connector-management-Cohvs7jD.js → use-connector-management-dX_4x0d3.js} +1 -1
  187. package/dist/client/assets/use-deep-link-scroll-BV2fY4gy.js +1 -0
  188. package/dist/client/assets/use-delete-binding-BklxjB_c.js +1 -0
  189. package/dist/client/assets/{use-dev-links-DRnLdl--.js → use-dev-links-D4Bqam6F.js} +1 -1
  190. package/dist/client/assets/use-external-adapter-catalog-nHiD8BKZ.js +1 -0
  191. package/dist/client/assets/use-full-activity-feed-vYU7wQWT.js +1 -0
  192. package/dist/client/assets/use-is-below-desktop-G-mTu2Ga.js +1 -0
  193. package/dist/client/assets/{use-jump-back-in-CkFErfWY.js → use-jump-back-in-BVunjzyr.js} +3 -3
  194. package/dist/client/assets/use-mesh-topology-NaUKSKol.js +1 -0
  195. package/dist/client/assets/use-mounted-ref-BWpQ8f91.js +1 -0
  196. package/dist/client/assets/use-notification-prefs-qO1zRRFN.js +1 -0
  197. package/dist/client/assets/{use-panel-tab-placements-AFrWTQ0a.js → use-panel-tab-placements-Db6p2vLD.js} +1 -1
  198. package/dist/client/assets/use-pending-read-DUqJZUza.js +1 -0
  199. package/dist/client/assets/use-personality-commit-DUEKxHt_.js +1 -0
  200. package/dist/client/assets/{use-promo-activation-Dxt-1yuT.js → use-promo-activation-CnGaw39P.js} +2 -2
  201. package/dist/client/assets/use-promo-dismissals-bkSHhGhj.js +1 -0
  202. package/dist/client/assets/{use-pulse-freshness-DRRM5Hza.js → use-pulse-freshness-Oc_1gs-Y.js} +1 -1
  203. package/dist/client/assets/use-relay-config-Ba-S4wxY.js +1 -0
  204. package/dist/client/assets/{use-room-follow-claim-huRfaa4e.js → use-room-follow-claim-DqE5b95Z.js} +1 -1
  205. package/dist/client/assets/{use-roving-tab-list-BZIBAGgJ.js → use-roving-tab-list-DnMqliqf.js} +1 -1
  206. package/dist/client/assets/{use-session-canvas-CZIsr9qL.js → use-session-canvas-OdljtBE8.js} +4 -4
  207. package/dist/client/assets/{use-session-diagnostics-C41hV7rK.js → use-session-diagnostics-CtjxsM8_.js} +4 -4
  208. package/dist/client/assets/use-unclaimed-chats-5RCD5wIp.js +1 -0
  209. package/dist/client/assets/use-update-config-xkznZMHr.js +1 -0
  210. package/dist/client/assets/useMutationState-Mjr_y4xX.js +1 -0
  211. package/dist/client/index.html +2 -2
  212. package/dist/server/index.js +11367 -9690
  213. package/dist/server/index.js.map +2 -2
  214. package/package.json +4 -4
  215. package/dist/client/assets/ActivityPage-CHUqb-8c.js +0 -1
  216. package/dist/client/assets/AdapterIcon-C_fBZXHQ.js +0 -1
  217. package/dist/client/assets/AppearancePage-t9SnSRs-.js +0 -1
  218. package/dist/client/assets/AttentionSignalRow-jlgWaSSd.js +0 -1
  219. package/dist/client/assets/CanvasFileContent-BejM-9Wg.js +0 -2
  220. package/dist/client/assets/CanvasModel3dContent-BD-eCVsX.js +0 -2
  221. package/dist/client/assets/CommitmentList-YVb3yTvO.js +0 -1
  222. package/dist/client/assets/ConnectionAccessLists-BPsgToSR.js +0 -1
  223. package/dist/client/assets/ConnectionsPage-D7vlYnjf.js +0 -6
  224. package/dist/client/assets/ConventionPage-BR7I3AdE.js +0 -11
  225. package/dist/client/assets/HandlePage-B33P0oh0.js +0 -1
  226. package/dist/client/assets/HeartbeatPage-CfjZuvtQ.js +0 -1
  227. package/dist/client/assets/McpSigninBody-DBWSc6bm.js +0 -1
  228. package/dist/client/assets/NamePage-MfybpnwN.js +0 -1
  229. package/dist/client/assets/OperatorIdentityForm-DH2au7QU.js +0 -1
  230. package/dist/client/assets/PermissionsPage-BgLLmdg2.js +0 -1
  231. package/dist/client/assets/PhotoPage-BgyB3B2_.js +0 -1
  232. package/dist/client/assets/PromptSuggestionChips-EO_0zbzq.js +0 -1
  233. package/dist/client/assets/ReportsToPopover-C9Ceg1AW.js +0 -1
  234. package/dist/client/assets/RoomSurface-B8ec3_at.js +0 -44
  235. package/dist/client/assets/RunsOnPopover-CJoSj8w7.js +0 -1
  236. package/dist/client/assets/RuntimeSetupDialog-Cqn_Grel.js +0 -1
  237. package/dist/client/assets/SkillsPage-DL0909et.js +0 -1
  238. package/dist/client/assets/TasksPage-BwUW6dia.js +0 -1
  239. package/dist/client/assets/TourHost-Db0fxAXo.js +0 -1
  240. package/dist/client/assets/_shell-CGWsN6Gs.js +0 -88
  241. package/dist/client/assets/_shell._home.activity-BbWquOK0.js +0 -1
  242. package/dist/client/assets/_shell._home.index-Cg0nRFMN.js +0 -3
  243. package/dist/client/assets/_shell._home.tasks-BpoOVihw.js +0 -1
  244. package/dist/client/assets/_shell._home.workspaces-DVF1rM3t.js +0 -1
  245. package/dist/client/assets/_shell.connections-0_34lXIQ.js +0 -1
  246. package/dist/client/assets/_shell.marketplace-Dp-p8E3V.js +0 -1
  247. package/dist/client/assets/_shell.marketplace_.sources-SN2Fb1eb.js +0 -1
  248. package/dist/client/assets/_shell.session-Bt3jdQdD.js +0 -66
  249. package/dist/client/assets/_shell.x._extensionId-Bjn-MKsP.js +0 -1
  250. package/dist/client/assets/_shell.x._extensionId_._-Bjn-MKsP.js +0 -1
  251. package/dist/client/assets/index-BBQMqcO_.js +0 -1
  252. package/dist/client/assets/index-BUVKya1M.js +0 -23
  253. package/dist/client/assets/index-C3xuhmPa.js +0 -38
  254. package/dist/client/assets/index-C63bLSO4.js +0 -1099
  255. package/dist/client/assets/index-CTxEG5rD.js +0 -1
  256. package/dist/client/assets/index-CkknQ52Q.js +0 -17
  257. package/dist/client/assets/index-DLNwEM2Q.js +0 -1
  258. package/dist/client/assets/index-DX-j3Ul0.js +0 -1
  259. package/dist/client/assets/index-g_5oOlG6.js +0 -1
  260. package/dist/client/assets/index-t7gsOfUI.js +0 -1
  261. package/dist/client/assets/kickoff-xkt4LpIP.js +0 -3
  262. package/dist/client/assets/soul-file-NcuTUIiB.js +0 -1
  263. package/dist/client/assets/use-delete-binding-C19umm_i.js +0 -1
  264. package/dist/client/assets/use-external-adapter-catalog-BOn9aj72.js +0 -1
  265. package/dist/client/assets/use-full-activity-feed-BpQANbns.js +0 -1
  266. package/dist/client/assets/use-is-below-desktop-5LlietdR.js +0 -1
  267. package/dist/client/assets/use-mesh-topology-CIsDeAY0.js +0 -1
  268. package/dist/client/assets/use-pending-read-Dol8yvIx.js +0 -1
  269. package/dist/client/assets/use-personality-commit-fUtuc2lC.js +0 -1
  270. package/dist/client/assets/use-unclaimed-chats-BMlFQ2v1.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a4 as Oe,ae as Y,as as De,aL as O,aj as ln,af as xe,ag as fe,jM as ae,jN as ze,r as v,jO as K,jP as un,j as n,a6 as q,fk as pe,B as b,jQ as hn,jR as gn,e as z,Z as P,dG as Me,cD as Ve,cE as Ke,C as mn,cF as qe,a8 as xn,hm as se,dg as re,$ as ye,jS as We,i3 as Be,i4 as le,e5 as F,iK as Ue,aa as fn,aw as Se,dz as pn,eR as yn,eS as vn,jT as ue,jU as jn,i as Nn,gl as kn,hj as bn,d_ as U,d$ as G,e0 as Q,e1 as H,e2 as V,I as he,jV as Sn,jW as Cn,jX as In,jY as wn,jZ as An,e8 as Ge,e9 as Qe,j_ as $n,a7 as Rn,l as En,j$ as _n,k0 as Ln,k1 as Fn,k2 as Ce,k3 as Tn,di as Pn,k4 as He,ac as On,ab as Dn,a9 as zn}from"./index-C63bLSO4.js";import{u as Mn,a as Vn,b as Kn,c as qn,d as Wn,e as Bn}from"./use-connector-management-Cohvs7jD.js";/**
1
+ import{a2 as Oe,a8 as Y,aB as De,aW as O,a9 as ln,aa as xe,ab as fe,jS as ae,r as v,jT as K,jU as un,j as n,f7 as pe,B as b,jV as hn,e as z,Q as P,dP as ze,Y as Me,Z as Ve,C as gn,a0 as Ke,a4 as mn,ho as se,dE as re,R as ye,ic as We,id as le,e1 as F,g8 as qe,a5 as xn,a7 as Se,cB as fn,eL as pn,eM as yn,jW as ue,jX as vn,i as jn,hn as Nn,dW as U,dX as Q,dY as G,dZ as H,d_ as V,I as he,jY as kn,e3 as Be,e4 as Ue,jZ as bn,a3 as Sn,l as Cn,j_ as In,$ as wn}from"./index-CdKpQ1hI.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-CBGtcTk0.js";import{u as Pn,a as On,b as Dn,c as zn,d as Mn,e as Vn}from"./use-connector-management-dX_4x0d3.js";import{Q as W}from"./query-error-state-CEZs7dhg.js";import{u as Kn}from"./use-bindings-Ch6UUBvz.js";import{u as Wn,a as qn,K as Ce,b as Bn}from"./KeyEntry-K5k_3TfU.js";/**
2
2
  * @license lucide-react v1.48.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -8,5 +8,5 @@ import{a4 as Oe,ae as Y,as as De,aL as O,aj as ln,af as xe,ag as fe,jM as ae,jN
8
8
  *
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
- */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 Gn(e,t=!0){const s=Y();return De({queryKey:O.eventDefinitions(e??""),queryFn:({pageParam:a})=>s.listConnectionEventDefinitions(e??"",a),initialPageParam:void 0,getNextPageParam:a=>a.nextCursor,enabled:t&&!!e})}function ts(e,t=!0){const s=Y();return De({queryKey:O.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 ss(){const e=Y(),t=xe();return fe({mutationFn:({connectionId:s,input:a})=>e.createConnectionEventSubscription(s,a),meta:{suppressErrorToast:!0},onSuccess:(s,{connectionId:a})=>{t.invalidateQueries({queryKey:O.eventSubscriptions(a)}),t.invalidateQueries({queryKey:O.connection(a)})}})}function as(){const e=Y(),t=xe();return fe({mutationFn:({connectionId:s,subscriptionId:a})=>e.deleteConnectionEventSubscription(s,a),meta:{suppressErrorToast:!0},onSettled:async(s,a,{connectionId:i})=>{await t.invalidateQueries({queryKey:O.eventSubscriptions(i)}),await t.invalidateQueries({queryKey:O.connection(i)})}})}function Qn(e,t){const s=Y();return ln({queryKey:O.eventSource(e??""),queryFn:()=>s.getConnectionEventSource(e??""),enabled:!!e})}function Hn(){const e=Y(),t=xe();return fe({mutationFn:({connectionId:s,input:a})=>e.configureConnectionEventSource(s,a),meta:{suppressErrorToast:!0},onSuccess:(s,{connectionId:a})=>{t.setQueryData(O.eventSource(a),s),t.invalidateQueries({queryKey:O.connection(a)}),t.invalidateQueries({queryKey:O.eventDefinitions(a)}),t.invalidateQueries({queryKey:O.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 ee(e){if(e)return e.logo??null}function W(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 is(e,t){const s=W(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 T(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 ge(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=W(e),i=o=>{if(T(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=W(e),d=a?{operationRevisionIds:ae(e.candidates,a),level:a}:null,l=new Set(t),m=[],f=[],h=[];let g=!1;for(const j of e.agents){if(!l.has(j.agentId))continue;const x=c[j.agentId]??{operationRevisionIds:[]},u=T(x);let p;s.has(j.agentId)?u==="none"?(d||(g=!0),p=d??x):u==="custom"||!i||!d?p=x:u==="read-write"&&a==="read"?(p=o?d:x,o&&h.push(j.agentId)):p=d:(p={operationRevisionIds:[]},u!=="none"&&f.push(j.agentId)),en(x,p)||m.push({agentId:j.agentId,...p})}return{changes:m,removedAgentIds:f,downgradedAgentIds:h,needsLevel:g}}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=T(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=ae(e.candidates,s);return i===s||o.length===0?{needsLevel:!1}:{everyAgent:{operationRevisionIds:o,level:s},needsLevel:!1}}function nt(e){const t=T(e.everyAgent);return t==="custom"?null:ge([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 ie(e,t,s=!0){const a=T(W(e)[t]),i=s&&e.everyAgent.available?T(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=Mn(),i=Vn(),o=ze(e,!1),[c,d]=v.useState(!1),[l,m]=v.useState(null),f=v.useRef(s);v.useEffect(()=>{f.current=s});const h=()=>{e&&(a.reset(),i.reset(),a.mutate({connectionId:e},{onSuccess:N=>{var y;return(y=f.current)==null?void 0:y.call(f,N)}}))};v.useEffect(()=>{!t||!e||h()},[t,e]);const g=a.data,j=()=>{d(!1),m(null),h()},x=(N,y,A={})=>{if(!(!g||N.length===0&&!y&&!A.confirm)){if(Date.parse(g.expiresAt)<=Date.now()){d(!0);return}i.mutate({previewId:g.previewId,grants:N,...y&&{everyAgent:y}},{onSuccess:I=>{var $;if(I.connectionId!==g.connection.connectionId||!we(N,I.grants)||!Ae(y==null?void 0:y.operationRevisionIds,($=I.everyAgent)==null?void 0:$.operationRevisionIds)){d(!0),a.reset();return}m(I)},onError:()=>{d(!0),a.reset()}})}},u=()=>{o.refetch().then(N=>{var R,L;if(!N.data||!l||!e)return;const y=l.grants,A=y.map(k=>{var C;return{agentId:k.agentId,operationRevisionIds:((C=N.data.agents.find(D=>D.agentId===k.agentId))==null?void 0:C.operationRevisionIds)??[],...k.level&&{level:k.level}}});if(N.data.connection.connectionId!==e||l.connectionId!==e||!we(y,A)||l.everyAgent!==void 0&&!Ae(l.everyAgent.operationRevisionIds,((R=N.data.connection.everyAgent)==null?void 0:R.operationRevisionIds)??[])){d(!0),m(null),a.reset();return}const I=y.flatMap(k=>{const C=N.data.agents.find(D=>D.agentId===k.agentId);return C?[C]:[]}),$=N.data.connection.reconciliationStatus!=="ready"?N.data.connection.reconciliationStatus:((L=I.find(k=>k.reconciliationStatus!=="ready"))==null?void 0:L.reconciliationStatus)??"ready",_=[N.data.connection.authoritySync,...I.map(k=>k.authoritySync)],w=_.find(k=>k.status==="failed")??(_.some(k=>k.status==="pending")?{status:"pending"}:{status:"ready"});m({...l,reconciliationStatus:$,authoritySync:w})})},p=(l==null?void 0:l.reconciliationStatus)==="ready"&&l.authoritySync.status==="ready",S=l!==null&&l.reconciliationStatus!=="ready";return{preview:g,isLoading:a.isPending,loadFailed:a.isError,loadError:a.error,isSaving:i.isPending,needsRefresh:c,saveOutcome:l,saved:p,needsReconciliation:S,isCheckingSync:o.isFetching,syncCheckFailed:o.isError,refresh:j,apply:x,checkSync:u}}const it=6;function me(e){return e==="read"?"look":"change"}function ve(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=>me(o.capabilityClassification)==="look"),i=s.filter(o=>me(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(ve(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 oe={read:"Read","read-write":"Read and write"},Re={...oe,custom:"Exact actions"};function ce(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(q,{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=pe();return n.jsx(b,{...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 h;const i=v.useId(),o=gn(e,s),c=((h=o.data)==null?void 0:h.status)==="listed"?o.data:null,d=a&&a.candidates.length>0?a:null,l=(d==null?void 0:d.level)??null,m=l?`With “${oe[l]}”, agents can`:`What ${t} offers agents`;let f;if(d)f=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))f=n.jsxs("p",{className:"text-muted-foreground text-sm",children:["Shows once DorkOS can reach ",t,"."]});else if(o.isPending)f=n.jsx(Ee,{});else if(o.isError){const g=Xe(o.error);f=n.jsxs("p",{className:"text-muted-foreground flex flex-wrap items-center gap-x-2 text-sm",children:[g?`${g.title}. ${g.description}`:`Couldn’t load what ${t} offers agents.`,n.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>void o.refetch(),disabled:o.isFetching,children:"Try again"}),(g==null?void 0:g.action)==="relink"&&n.jsx(nn,{variant:"link",size:"xs",className:"h-auto p-0"})]})}else c?f=n.jsx(_e,{actions:c.actions,completeness:c.completeness,toolkit:e,appName:t,level:null}):f=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:m}),f]})}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:P("rounded-full px-2.5 py-0.5 text-xs",e==="look"?"bg-muted text-foreground":Me.warning),children:ve(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(Ve,{children:[n.jsxs(Ke,{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(mn,{className:"size-3.5 transition-transform group-data-[state=open]/all:rotate-90","aria-hidden":!0})]}),n.jsx(qe,{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=me(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:ve(i,s)}),n.jsx("span",{className:P("mt-0.5 shrink-0 rounded-full px-2 py-0 text-xs",o==="look"?"bg-muted text-muted-foreground":Me.warning),children:tn[o]})]},`${i.operationSlug}-${i.capabilityClassification}`)})})})]})}function pt(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function J({titleId:e,toolkit:t,serviceName:s,logo:a,title:i,subtitle:o,variant:c="card",className:d,children:l}){const m=c==="embedded";return n.jsxs("section",{"aria-labelledby":e,"data-testid":"connection-access-card",className:P(m?"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:[!m&&n.jsx(xn,{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(se,{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(b,{size:"sm",variant:"secondary",className:"h-auto min-h-9 whitespace-normal",onClick:e.refresh,children:[n.jsx(re,{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(ye,{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(se,{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(se,{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 g;const s=v.useId(),a=We(),i=sn(((g=a.data)==null?void 0:g.connections)??[],e.toolkit),[o,c]=v.useState(null),[d,l]=v.useState(null),m=i.length===1?i[0].connectionId:null,f=d??(m?{id:m,picked:!1}:null);if(v.useEffect(()=>{!d&&m&&l({id:m,picked:!1})},[d,m]),f)return t(f.id,f.picked?()=>l(null):void 0);const h=`Which ${e.serviceName} account?`;return n.jsxs(J,{titleId:s,toolkit:e.toolkit,serviceName:e.serviceName,logo:e.logo,title:h,className:e.className,children:[a.isPending?n.jsx(z,{className:"h-16 rounded-lg","aria-label":"Loading accounts"}):a.isError?n.jsx(q,{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(Be,{"aria-labelledby":s,value:o??"",onValueChange:c,className:"gap-2",children:i.map(j=>{const x=`${s}-${j.connectionId}`;return n.jsxs("div",{className:"bg-muted/40 flex min-h-11 items-center gap-3 rounded-lg px-3",children:[n.jsx(le,{id:x,value:j.connectionId}),n.jsxs(F,{htmlFor:x,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:j.label}),j.identityHint&&n.jsx("span",{className:"text-muted-foreground block max-w-full truncate text-xs",children:j.identityHint})]})]},j.connectionId)})}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.onSkip&&n.jsx(b,{variant:"ghost",onClick:e.onSkip,children:"Not now"}),i.length>1&&n.jsx(b,{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 m=v.useId(),f=W(e),h=Jn(e,{preferredAgentIds:s,systemAgentIds:a}),g=d?h:h.filter((x,u)=>u<Yn||i.has(x.agentId)||T(f[x.agentId])!=="none"),j=x=>{var u;return(u=e.agents.find(p=>p.agentId===x))==null?void 0:u.displayName};return n.jsxs("fieldset",{className:"space-y-1",children:[n.jsxs("legend",{className:"sr-only",children:["Agents that can use ",t]}),g.map(x=>{const u=`${m}-${x.agentId}`,p=T(f[x.agentId]),S=c.removedAgentIds.includes(x.agentId)||c.downgradedAgentIds.includes(x.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(Ue,{id:u,"aria-describedby":S?`${u}-loss`:void 0,checked:i.has(x.agentId),onCheckedChange:N=>{const y=new Set(i);N===!0?y.add(x.agentId):y.delete(x.agentId),o(y)}}),n.jsx(F,{htmlFor:u,className:"min-w-0 flex-1 cursor-pointer py-2 font-normal",children:n.jsx("span",{className:"truncate",children:x.displayName})}),p!=="none"&&n.jsx(fn,{size:"xs",variant:"secondary","aria-label":`Now: ${Re[p]}`,children:Re[p]})]},x.agentId)}),g.length<h.length&&n.jsxs(b,{variant:"ghost",size:"sm",onClick:()=>l(!0),children:["Show all ",h.length]}),n.jsxs("div",{"aria-live":"polite",className:"space-y-1",children:[c.removedAgentIds.map(x=>n.jsxs("p",{id:`${m}-${x}-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}),j(x)," will lose access to ",t,"."]},x)),c.downgradedAgentIds.map(x=>n.jsxs("p",{id:`${m}-${x}-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}),j(x)," will lose write access."]},x))]})]})}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(se,{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 f;const{preview:t,serviceName:s,decision:a,level:i}=e,o=h=>{var g;return((g=t.agents.find(j=>j.agentId===h))==null?void 0:g.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(h=>e.picked.has(h.agentId)).map(h=>h.displayName),d=[c.length>0?`${ce(c)} can use ${s}.`:`No agent can use ${s}.`];((f=e.every.everyAgent)==null?void 0:f.operationRevisionIds.length)===0&&d.push(`${s} is no longer shared with every agent.`);const l=a.downgradedAgentIds.map(o);l.length>0&&d.push(`${ce(l)} can now only read.`);const m=a.removedAgentIds.map(o);return m.length>0&&d.push(`${ce(m)} can no longer use it.`),d.join(" ")}function Ct({connectionId:e,serviceName:t}){var i;const s=ze(e,!0),a=Kn();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(b,{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=v.useId();return n.jsxs(Be,{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(le,{value:"picked",id:`${a}-picked`}),n.jsx(F,{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(le,{value:"every",id:`${a}-every`,disabled:!s,"aria-describedby":s?void 0:`${a}-every-unavailable`,className:"mt-0.5"}),n.jsxs(F,{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 k;const t=v.useId(),[s,a]=v.useState(new Set),[i,o]=v.useState("read"),[c,d]=v.useState("picked"),[l,m]=v.useState(!1),[f,h]=v.useState(!1),{data:g}=pn(void 0,e.mode==="page"),[j,x]=v.useState(null),u=at({connectionId:e.connectionId,active:!0,onPreview:C=>{x(C.connection);const D=W(C),Z=e.mode==="agent"?[e.agentId]:C.agents.map(M=>M.agentId).filter(M=>T(D[M])!=="none");a(new Set(e.mode==="agent"?[e.agentId]:Z));const ne=e.mode==="page"?Xn(C):"picked";d(ne);const X=ne==="every"?nt(C):e.mode==="agent"?ge([ie(C,e.agentId,!!e.onAllowed)]):ge(Z.map(M=>T(D[M]))),te=e.mode==="agent"&&e.request?e.request.access:null;o(te==="read-write"||X==="read-write"?"read-write":X),m(!1)}}),{preview:p}=u,S=e.mode==="agent"?e.agentId:null,N=v.useMemo(()=>p?Zn(p,{scope:S?[S]:c==="every"?[]:p.agents.map(C=>C.agentId),picked:s,level:i,levelTouched:S!==null||l,allowDowngrade:S===null}):{changes:[],removedAgentIds:[],downgradedAgentIds:[],needsLevel:!1},[p,s,i,l,S,c]),y=v.useMemo(()=>p&&S===null?et(p,{who:c,level:i,levelTouched:l}):{needsLevel:!1},[p,S,c,i,l]),A=p&&S?ie(p,S,e.mode==="agent"&&!!e.onAllowed):"none",I=e.mode==="agent"?e.onAllowed:void 0,$=I!==void 0&&p!==void 0&&(N.changes.length===0||A===i||A==="read-write")&&!N.needsLevel&&A!=="none"&&p.agents.some(C=>C.agentId===S),_=v.useRef(!1);v.useEffect(()=>{!u.saved||!I||_.current||(_.current=!0,I(e.connectionId))},[u.saveOutcome,u.saved,I,e.connectionId]);const r=e.mode==="agent"?(k=p==null?void 0:p.agents.find(C=>C.agentId===e.agentId))==null?void 0:k.displayName:void 0,w=e.mode==="page"?`Who can use ${e.serviceName}?`:`Let ${r??"this agent"} use ${e.serviceName}?`,R=u.needsRefresh||u.saveOutcome!==null,L=(j||e.onChangeAccount)&&n.jsxs("span",{className:"flex flex-wrap items-center gap-x-2",children:[j&&n.jsx("span",{className:"truncate",children:j.label}),e.onChangeAccount&&!R&&n.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:e.onChangeAccount,children:"Change account"})]});return n.jsxs(J,{titleId:t,toolkit:(j==null?void 0:j.toolkit)??(e.mode==="agent"?e.toolkit:void 0),serviceName:e.serviceName,logo:e.logo,title:w,subtitle:e.variant==="embedded"?void 0:L,variant:e.variant,className:e.className,children:[u.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"})]}):u.loadFailed?n.jsxs("div",{className:"space-y-2",children:[n.jsx(gt,{error:u.loadError,title:"Couldn’t load who can use it",description:"Nothing changed. Try again.",onRetry:u.refresh,isRetrying:u.isLoading}),e.mode==="page"&&n.jsx(Ct,{connectionId:e.connectionId,serviceName:e.serviceName}),e.onEditExactActions&&n.jsx(an,{onClick:()=>{var C;return(C=e.onEditExactActions)==null?void 0:C.call(e,e.connectionId)}})]}):R?n.jsx(yt,{access:u,savedDetail:p?St({mode:e.mode,...e.mode==="agent"&&{agentId:e.agentId},serviceName:e.serviceName,preview:p,picked:s,level:i,decision:N,who:c,every:y}):void 0}):p?n.jsx(At,{props:e,preview:p,picked:s,setPicked:a,who:c,setWho:d,decision:N,level:i,setLevel:C=>{o(C),m(!0)},showAll:f,setShowAll:h,systemAgentIds:((g==null?void 0:g.agents)??[]).filter(C=>C.isSystem).map(C=>C.id)}):null,n.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[u.needsReconciliation?n.jsx(b,{variant:"secondary",onClick:u.refresh,children:"Reload current access"}):u.saveOutcome&&!u.saved?n.jsxs(b,{variant:"secondary",onClick:u.checkSync,disabled:u.isCheckingSync,children:[n.jsx(re,{className:"size-4","aria-hidden":!0}),u.isCheckingSync?"Checking…":"Check if it’s done"]}):null,R?e.onFinished?n.jsx(b,{variant:u.saved?"default":"ghost",onClick:e.onFinished,children:u.saved?"Done":"Close"}):u.saveOutcome&&n.jsx(b,{variant:"ghost",onClick:u.refresh,children:"Edit again"}):p&&n.jsxs(n.Fragment,{children:[e.onSkip&&n.jsx(b,{variant:"ghost",onClick:e.onSkip,children:e.mode==="page"?"Skip":"Not now"}),n.jsx(b,{onClick:()=>$?I==null?void 0:I(e.connectionId):u.apply(N.changes,y.everyAgent),disabled:!$&&(N.changes.length===0&&!y.everyAgent||N.needsLevel||y.needsLevel||u.isSaving),children:u.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:m,setShowAll:f,systemAgentIds:h}){var _;const g=v.useId(),j=W(t),x=ae(t.candidates,"read"),u=ae(t.candidates,"read-write"),p=u.length>x.length?["read","read-write"]:["read"],S=e.mode==="agent"&&ie(t,e.agentId,!!e.onAllowed)==="read-write"?p.filter(r=>r==="read-write"):p,N=u.length===0,y=e.onEditExactActions&&n.jsx(an,{onClick:()=>{var r;return(r=e.onEditExactActions)==null?void 0:r.call(e,e.connectionId)}});let A;if(e.mode==="agent"){const r=t.agents.find(k=>k.agentId===e.agentId),w=T(j[e.agentId]),R=ie(t,e.agentId,!!e.onAllowed);A=r?w==="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."]}):w===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"?A=null:t.agents.length===0?A=n.jsx("p",{className:"text-muted-foreground text-sm",children:"No agents yet. Add one first."}):A=n.jsx(jt,{preview:t,serviceName:e.serviceName,preferredAgentIds:e.preferredAgentIds,systemAgentIds:h,picked:s,setPicked:a,decision:c,showAll:m,setShowAll:f});const I=e.mode==="agent"&&!t.agents.some(r=>r.agentId===e.agentId),$=e.mode==="agent"&&T(j[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:((_=t.agents.find(r=>r.agentId===e.agentId))==null?void 0:_.displayName)??"The agent",serviceName:e.serviceName,reason:e.request.reason,access:e.request.access,level:d}),A,N?n.jsxs("p",{className:"text-muted-foreground text-sm",children:[e.serviceName," has no actions for agents yet."]}):!I&&!$&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("p",{id:`${g}-level`,className:"text-muted-foreground text-xs font-medium",children:e.mode==="page"?"They can":"It can"}),S.length>1?n.jsx(yn,{"aria-labelledby":`${g}-level`,value:d??"",onValueChange:r=>l(r),children:S.map(r=>n.jsx(vn,{value:r,className:"min-h-9",children:oe[r]},r))}):n.jsx("p",{className:"text-sm",children:oe[S[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:N?null:d}}),(e.mode==="page"||y)&&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."}),y]})]})}function an({onClick:e}){return n.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:e,children:"Choose exact actions"})}function de(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=ue(a.filterSchema);if(!i)return null;const o=jn(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 $,_;const d=(o==null?void 0:o.id)??s.agentId,l=t.find(r=>r.id===s.definitionId),m=l?ue(l.filterSchema):[],f=Nn(d||null,{enabled:s.destinationKind==="room"}),h=kn(),g=bn(s.destinationKind==="channel"),j=v.useMemo(()=>new Set((g.data??[]).filter(r=>r.config.enabled).map(r=>r.config.id)),[g.data]),x=v.useMemo(()=>(h.data??[]).filter(r=>r.agentId===d&&r.enabled&&r.canInitiate&&!!r.chatId&&j.has(r.adapterId)),[d,h.data,j]),u=r=>{a({...s,...r,...o?{agentId:o.id}:{}})},p=r=>{if(r===s.definitionId)return;const w=t.find(L=>L.id===r),R=w?ue(w.filterSchema):[];u({definitionId:r,filterValues:Sn(R??[])})},S=`${e}-event`,N=`${e}-agent`,y=`${e}-destination-kind`,A=`${e}-room`,I=`${e}-channel`;return n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(F,{htmlFor:S,children:"Account activity"}),n.jsxs(U,{value:s.definitionId,onValueChange:p,children:[n.jsx(G,{id:S,"aria-label":"Account activity",children:n.jsx(Q,{placeholder:"Choose activity"})}),n.jsx(H,{children:t.map(r=>n.jsx(V,{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:N,className:"bg-muted/40 mt-1 rounded-md px-3 py-2 text-sm",children:o.displayName})]}):n.jsxs(n.Fragment,{children:[n.jsx(F,{htmlFor:N,children:"Agent"}),n.jsxs(U,{value:s.agentId,onValueChange:r=>u({agentId:r,destinationId:""}),children:[n.jsx(G,{id:N,"aria-label":"Agent",children:n.jsx(Q,{placeholder:"Choose agent"})}),n.jsx(H,{children:(i??[]).map(r=>n.jsx(V,{value:r.id,children:r.displayName},r.id))})]})]})}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(F,{htmlFor:y,children:"Send to"}),n.jsxs(U,{value:s.destinationKind,onValueChange:r=>u({destinationKind:r,destinationId:""}),children:[n.jsx(G,{id:y,"aria-label":"Send to",children:n.jsx(Q,{})}),n.jsxs(H,{children:[n.jsx(V,{value:"agent",children:"Agent"}),n.jsx(V,{value:"room",children:"Room"}),n.jsx(V,{value:"channel",children:"Messaging channel"})]})]})]})]}),s.destinationKind==="room"&&d&&n.jsxs("div",{className:"space-y-1",children:[n.jsx(F,{htmlFor:A,children:"Room"}),n.jsxs(U,{value:s.destinationId,onValueChange:r=>u({destinationId:r}),children:[n.jsx(G,{id:A,"aria-label":"Room",children:n.jsx(Q,{placeholder:"Choose a room"})}),n.jsx(H,{children:((($=f.data)==null?void 0:$.rooms)??[]).map(r=>n.jsx(V,{value:r.id,children:r.slug?`#${r.slug}`:r.name},r.id))})]}),f.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(b,{type:"button",size:"sm",variant:"ghost",onClick:()=>void f.refetch(),children:"Try again"})]}):!f.isPending&&(((_=f.data)==null?void 0:_.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(F,{htmlFor:I,children:"Messaging channel"}),n.jsxs(U,{value:s.destinationId,onValueChange:r=>u({destinationId:r}),children:[n.jsx(G,{id:I,"aria-label":"Messaging channel",children:n.jsx(Q,{placeholder:"Choose a channel"})}),n.jsx(H,{children:x.map(r=>n.jsx(V,{value:r.id,children:r.label||r.chatId},r.id))})]}),h.isError||g.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(b,{type:"button",size:"sm",variant:"ghost",onClick:()=>{h.refetch(),g.refetch()},children:"Try again"})]}):!h.isPending&&!g.isPending&&x.length===0?n.jsx("p",{className:"text-muted-foreground text-xs",children:"No channels this agent can start."}):null]}),l&&m===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."}),m==null?void 0:m.map(r=>{var L;const w=`${e}-filter-${r.name}`,R=(L=r.examples)!=null&&L.length?`${w}-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(Ue,{id:w,"aria-describedby":R,checked:s.filterValues[r.name]===!0,onCheckedChange:k=>u({filterValues:{...s.filterValues,[r.name]:k===!0}})}),n.jsx(F,{htmlFor:w,children:r.label})]}):r.options?n.jsxs(n.Fragment,{children:[n.jsx(F,{htmlFor:w,children:r.label}),n.jsxs(U,{value:typeof s.filterValues[r.name]=="string"?String(r.options.indexOf(String(s.filterValues[r.name]))):"",onValueChange:k=>u({filterValues:{...s.filterValues,[r.name]:r.options[Number(k)]}}),children:[n.jsx(G,{id:w,"aria-label":r.label,"aria-describedby":R,children:n.jsx(Q,{placeholder:`Choose ${r.label.toLowerCase()}`})}),n.jsx(H,{children:r.options.map((k,C)=>n.jsx(V,{value:String(C),children:k===""?"Leave blank":k},k))})]})]}):n.jsxs(n.Fragment,{children:[n.jsx(F,{htmlFor:w,children:r.label}),n.jsx(he,{id:w,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:k=>u({filterValues:{...s.filterValues,[r.name]:k.target.value}})})]}),R&&n.jsxs("p",{id:R,className:"text-muted-foreground text-xs break-words",children:["Examples (not selected):"," ",r.examples.map(k=>JSON.stringify(k)).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]=v.useState(""),[c,d]=v.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 m=`${s}-public-origin`,f=`${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(F,{htmlFor:m,children:"Public DorkOS address"}),n.jsx(he,{id:m,type:"url",placeholder:"https://your-dorkos.example",value:i,onChange:h=>o(h.target.value)})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(F,{htmlFor:f,children:"Signing secret"}),n.jsx(he,{id:f,type:"password",autoComplete:"off",value:c,onChange:h=>d(h.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(b,{type:"button",size:"sm",variant:"secondary",disabled:a.isPending||c.length<16||!_t(i.trim()),onClick:()=>{const h=c;d(""),a.mutate({connectionId:e,input:{publicOrigin:i.trim(),webhookSecret:h}})},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=Gn(e),o=Qn(e),c=v.useMemo(()=>[...new Set(t)],[t]),[d,l]=v.useState(()=>Object.fromEntries(c.map(h=>[h,de(s.id)]))),m=v.useMemo(()=>{var h;return((h=i.data)==null?void 0:h.pages.flatMap(g=>g.definitions))??[]},[i.data]),f=v.useMemo(()=>{if(!o.data||!Lt(o.data))return null;const h=c.map(g=>Rt({connectionId:e,definitions:m.filter(j=>j.eventType===g),draft:d[g]??de(s.id)}));return h.every(g=>g!==null)?h:null},[s.id,e,m,d,c,o.data]);return v.useEffect(()=>a(f),[a,f]),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(q,{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(q,{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((h,g)=>{const j=m.filter(x=>x.eventType===h);return n.jsxs("section",{"aria-labelledby":`agent-request-event-${g}`,className:"bg-muted/30 space-y-3 rounded-lg p-3",children:[n.jsx("div",{children:n.jsx("h3",{id:`agent-request-event-${g}`,className:"text-sm font-medium",children:Tt(h)})}),j.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-${g}`,definitions:j,draft:d[h]??de(s.id),onChange:x=>l(u=>({...u,[h]:x})),fixedAgent:s,sourceStatus:o.data})]},h)}),i.hasNextPage&&n.jsx(b,{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 A,I,$;const d=v.useId(),l=pe(),m=Cn(),f=In(),h=wn(),[g,j]=v.useState(null),x=An(g),u=(A=x.data)==null?void 0:A.state,p=u!==void 0&&Ot.has(u),S=((I=x.data)==null?void 0:I.state)==="pending"?x.data.authorizeUrl:void 0,N=m.isError||f.isError||p,y=($=e.readiness.fix)==null?void 0:$.action;return n.jsxs(J,{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}),S&&n.jsx(b,{asChild:!0,className:"w-full sm:w-auto",children:n.jsxs(Ge,{href:S,children:["Sign in to ",t,n.jsx(Qe,{className:"size-4","aria-hidden":!0})]})}),g&&!S&&!p&&u!=="connected"&&n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(re,{className:"size-4 animate-spin motion-reduce:animate-none","aria-hidden":!0}),"Getting the sign-in page ready…"]}),N&&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(b,{variant:"ghost",onClick:i,disabled:o,children:"Not now"}),y==="resume"&&n.jsx(b,{onClick:()=>m.mutate({connectionId:e.connectionId,input:void 0}),disabled:m.isPending,children:m.isPending?"Resuming…":"Resume"}),y==="sign_in_again"&&(!g||p)&&n.jsx(b,{onClick:()=>f.mutate({connectionId:e.connectionId},{onSuccess:_=>j(_.flowId)}),disabled:f.isPending,children:"Sign in again"}),y==="retry"&&n.jsx(b,{variant:"secondary",onClick:()=>h.mutate(),disabled:h.isPending,children:h.isPending?"Checking…":"Check again"}),y==="fix_key"&&n.jsx(b,{variant:"secondary",onClick:()=>l.open("connections","ways"),children:"Fix the key"}),y==="connect_new"&&n.jsxs(b,{onClick:c,children:["Connect ",t," again"]}),y==="review_access"&&n.jsx(b,{asChild:!0,variant:"secondary",children:n.jsxs($n,{...En.connections(),search:{app:e.connectionId},children:["Open Connections",n.jsx(Rn,{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 Vt(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 _n(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 qt(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 Wt({reason:e,onLeave:t}){var S;const s=Ln(),a=Fn(),i=pe(),[o,c]=v.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(q,{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"),m=(S=a.data)==null?void 0:S.newApps,f=(m==null?void 0:m.status)==="setup_needed"?m.reason:null,h=f==="dorkos_account_unlinked"||f==="dorkos_account_unavailable",g=f==="nothing_set_up",j=f==="own_key_unavailable",x=h||g||j,u=()=>{t==null||t(),i.open("account")},p=h?n.jsx(b,{size:"lg",variant:"outline",className:"w-full",onClick:u,children:"Link my DorkOS account again"}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(b,{size:"lg",variant:g?"default":"outline",className:"w-full",onClick:u,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}),x&&!j&&p,d&&(o?n.jsx(Ce,{status:d}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs(b,{size:"lg",variant:h||g?"outline":"default",className:"w-full",onClick:()=>c(!0),children:[n.jsx(Tn,{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."})]})),x&&j&&p,l&&n.jsxs(Ve,{children:[n.jsxs(Ke,{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(Pn,{className:"size-4 transition-transform group-data-[state=open]:rotate-180","aria-hidden":!0})]}),n.jsxs(qe,{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,deciding:o,className:c}){var R;const d=v.useId(),[l,m]=v.useState(null),[f,h]=v.useState(!1),g=qn(e.requestId),j=Wn(e.requestId,l),x=He(e.serviceSlug),u=(R=x.data)==null?void 0:R.pages[0],p=u==null?void 0:u.appConnections,S=on(s),N=zt(S,p==null?void 0:p.newApps),y=j.data??g.data,A=!y&&Mt(s),I=Kt(N,s),$=(y==null?void 0:y.state)==="connected"?y.connectionId:null;v.useEffect(()=>{$&&a($)},[$,a]);const _=()=>{if(A){h(!0);return}N&&g.mutate({providerInstanceId:N.providerInstanceId},{onSuccess:L=>m(L.flowId)})},r=(y==null?void 0:y.state)==="starting"||(y==null?void 0:y.state)==="pending";let w;return x.isPending&&!s?w=n.jsx(z,{className:"h-10 rounded-lg","aria-label":`Loading ${t}`}):A&&f?w=S.length===0&&Vt(u)&&(p==null?void 0:p.newApps.status)==="ready"?n.jsx(q,{title:`Couldn’t reach ${t} just now`,description:`${rn(p.newApps.way)} didn’t answer. Try again soon.`,onRetry:()=>void x.refetch(),isRetrying:x.isFetching}):n.jsx(Wt,{reason:qt(p,s)}):r?w=n.jsxs("div",{className:"space-y-3",children:[I&&n.jsx("p",{className:"text-sm",children:I}),y.state==="pending"&&y.authorizeUrl?n.jsx(b,{asChild:!0,className:"w-full sm:w-auto",children:n.jsxs(Ge,{href:y.authorizeUrl,children:["Sign in to ",t,n.jsx(Qe,{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(re,{className:"size-4 animate-spin motion-reduce:animate-none","aria-hidden":!0}),y.state==="starting"?"Getting the sign-in page ready…":`Finish signing in to ${t}…`]})]}):w=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}),g.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t start sign-in. Try again."})]}),n.jsxs(J,{titleId:d,toolkit:e.serviceSlug,serviceName:t,logo:ee(s),title:`Connect ${t}`,subtitle:`So ${e.agent.displayName} can use it`,className:c,children:[w,n.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[n.jsx(b,{variant:"ghost",onClick:i,disabled:o,children:"Not now"}),!r&&!(A&&f)&&n.jsx(b,{onClick:_,disabled:g.isPending||o||!A&&!N,children:g.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 Gt({request:e,serviceName:t,className:s}){const a=e.status==="granted",i=e.status==="access_pending",o=a?ye:i?Je:Un;return n.jsxs("p",{role:"status","data-testid":"agent-request-receipt","data-status":e.status,className:P("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:P("mt-0.5 size-4 shrink-0",a&&"text-status-success"),"aria-hidden":!0}),n.jsx("span",{className:P("min-w-0",a&&"text-foreground"),children:Ut(e,t)})]})}const Qt="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 os({request:e,onEditExactActions:t,className:s}){var te,M,je,Ne,ke;const a=Bn(),i=On(e.sessionId),o=Ht(a.error)?e.sessionId:null,c=Dn(o),d=We(),m=((te=He(e.serviceSlug,e.status==="awaiting_owner").data)==null?void 0:te.pages.flatMap(E=>E.services).find(E=>E.serviceSlug===e.serviceSlug))??null,f=(m==null?void 0:m.displayName)??zn(e.serviceSlug),h=e.agent.displayName,[g,j]=v.useState(null),[x,u]=v.useState(null),[p,S]=v.useState([]),[N,y]=v.useState(!1),[A,I]=v.useState(!1),[$,_]=v.useState(null),r=v.useCallback(()=>{u(null),a.mutate({requestId:e.requestId,decision:{decision:"denied"}})},[a,e.requestId]),w=v.useCallback((E,B=[])=>{u(E),S(B),a.mutate({requestId:e.requestId,decision:{decision:"current_access",connectionId:E,eventScopes:B}})},[a,e.requestId]),R=e.requestedEvents.length>0,L=v.useCallback(E=>R?_(E):w(E),[w,R]),k=P("max-w-xl",s);if(x&&a.isError){const{reason:E,fix:B}=Jt(a.error,h,f),cn=B==="updates"&&$!==null,be=B==="turn_on"&&((Ne=(je=(M=c.data)==null?void 0:M.connections.find(dn=>dn.connectionId===x))==null?void 0:je.readiness.fix)==null?void 0:Ne.action)==="turn_on_for_this_chat";return n.jsxs(J,{titleId:`agent-request-unanswered-${e.requestId}`,toolkit:e.serviceSlug,serviceName:f,logo:ee(m),title:`${h} can now use ${f}`,className:k,children:[n.jsxs("div",{role:"alert",className:"space-y-1 text-sm","data-testid":"agent-request-unanswered",children:[n.jsxs("p",{children:[n.jsx(ye,{className:"text-status-success mr-1.5 inline size-4 align-text-bottom","aria-hidden":!0}),"Access saved, but ",h,"’s request wasn’t answered."]}),n.jsxs("p",{children:[E,be&&" Turning it on only affects this chat."]})]}),cn?n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(b,{variant:"ghost",onClick:()=>w(x,[]),disabled:a.isPending,children:"Answer without updates"}),n.jsx(b,{onClick:()=>a.reset(),disabled:a.isPending,children:"Pick updates again"})]}):B==="retry"&&n.jsx("div",{className:"flex justify-end",children:n.jsx(b,{onClick:()=>w(x,p),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(b,{onClick:()=>i.mutate({connectionId:x,on:!0},{onSuccess:()=>w(x,p)}),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(Gt,{request:e,serviceName:f,className:k});const C=a.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:Qt});if($)return n.jsx(Xt,{request:e,connectionId:$,serviceName:f,logo:ee(m),onAnswer:E=>w($,E),deciding:a.isPending,className:k},$);if(d.isPending)return n.jsx(z,{className:P("h-28 rounded-xl",k),"aria-label":"Loading accounts"});if(d.isError)return n.jsx("div",{className:k,children:n.jsx(q,{title:"Couldn’t load your accounts",description:"Nothing changed. Try again.",onRetry:()=>void d.refetch(),isRetrying:d.isFetching})});const D=((ke=d.data)==null?void 0:ke.connections)??[],Z=D.filter(E=>E.toolkit===e.serviceSlug&&E.readiness.state!=="gone"),ne=sn(D,e.serviceSlug),X=N||!!g||ne.length>0;if(!X&&(Z.length===0||A))return n.jsxs("div",{className:P("space-y-2",k),children:[n.jsx(Bt,{request:e,serviceName:f,service:m,onConnected:j,onDecline:r,deciding:a.isPending}),C]});if(!X){const E=Z[0];return n.jsxs("div",{className:P("space-y-2",k),children:[n.jsx(Dt,{account:E,serviceName:f,logo:ee(m),agentName:h,onDecline:r,deciding:a.isPending,onConnectAgain:()=>I(!0)}),C]})}return n.jsx(Zt,{onShown:y,children:n.jsxs("div",{className:P("space-y-2",k),"data-testid":"agent-request-access",children:[n.jsx(wt,{mode:"agent",agentId:e.agent.id,toolkit:e.serviceSlug,serviceName:f,logo:ee(m),...g?{connectionId:g}:{},request:{reason:e.reason,access:e.access},...t?{onEditExactActions:t}:{},onSkip:r,onAllowed:L}),C]})})}function Zt({onShown:e,children:t}){return v.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]=v.useState(null);return n.jsxs(J,{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(b,{variant:"ghost",onClick:()=>i([]),disabled:o,children:"No updates"}),n.jsx(b,{onClick:()=>d&&i(d),disabled:o||!d,children:o?"Sending…":"Send updates"})]})]})}export{os as A,Ft as C,Wt as F,gt as L,nn as R,Gn as a,ts as b,ss as c,as as d,de as e,Rt as f,Et as g,$t as h,Lt as i,ce as j,wt as k,on as l,zt as m,Mt as n,Kt as o,Vt as p,qt as q,mt as r,ee as s,at as t,Qn as u,W as v,rn as w,is as x,yt as y};
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=Y();return De({queryKey:O.eventDefinitions(e??""),queryFn:({pageParam:a})=>s.listConnectionEventDefinitions(e??"",a),initialPageParam:void 0,getNextPageParam:a=>a.nextCursor,enabled:t&&!!e})}function os(e,t=!0){const s=Y();return De({queryKey:O.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 rs(){const e=Y(),t=xe();return fe({mutationFn:({connectionId:s,input:a})=>e.createConnectionEventSubscription(s,a),meta:{suppressErrorToast:!0},onSuccess:(s,{connectionId:a})=>{t.invalidateQueries({queryKey:O.eventSubscriptions(a)}),t.invalidateQueries({queryKey:O.connection(a)})}})}function cs(){const e=Y(),t=xe();return fe({mutationFn:({connectionId:s,subscriptionId:a})=>e.deleteConnectionEventSubscription(s,a),meta:{suppressErrorToast:!0},onSettled:async(s,a,{connectionId:i})=>{await t.invalidateQueries({queryKey:O.eventSubscriptions(i)}),await t.invalidateQueries({queryKey:O.connection(i)})}})}function Gn(e,t){const s=Y();return ln({queryKey:O.eventSource(e??""),queryFn:()=>s.getConnectionEventSource(e??""),enabled:!!e})}function Hn(){const e=Y(),t=xe();return fe({mutationFn:({connectionId:s,input:a})=>e.configureConnectionEventSource(s,a),meta:{suppressErrorToast:!0},onSuccess:(s,{connectionId:a})=>{t.setQueryData(O.eventSource(a),s),t.invalidateQueries({queryKey:O.connection(a)}),t.invalidateQueries({queryKey:O.eventDefinitions(a)}),t.invalidateQueries({queryKey:O.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 ee(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 ds(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 T(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 ge(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(T(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:ae(e.candidates,a),level:a}:null,l=new Set(t),m=[],f=[],h=[];let g=!1;for(const j of e.agents){if(!l.has(j.agentId))continue;const x=c[j.agentId]??{operationRevisionIds:[]},u=T(x);let p;s.has(j.agentId)?u==="none"?(d||(g=!0),p=d??x):u==="custom"||!i||!d?p=x:u==="read-write"&&a==="read"?(p=o?d:x,o&&h.push(j.agentId)):p=d:(p={operationRevisionIds:[]},u!=="none"&&f.push(j.agentId)),en(x,p)||m.push({agentId:j.agentId,...p})}return{changes:m,removedAgentIds:f,downgradedAgentIds:h,needsLevel:g}}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=T(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=ae(e.candidates,s);return i===s||o.length===0?{needsLevel:!1}:{everyAgent:{operationRevisionIds:o,level:s},needsLevel:!1}}function nt(e){const t=T(e.everyAgent);return t==="custom"?null:ge([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 ie(e,t,s=!0){const a=T(q(e)[t]),i=s&&e.everyAgent.available?T(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]=v.useState(!1),[l,m]=v.useState(null),f=v.useRef(s);v.useEffect(()=>{f.current=s});const h=()=>{e&&(a.reset(),i.reset(),a.mutate({connectionId:e},{onSuccess:N=>{var y;return(y=f.current)==null?void 0:y.call(f,N)}}))};v.useEffect(()=>{!t||!e||h()},[t,e]);const g=a.data,j=()=>{d(!1),m(null),h()},x=(N,y,A={})=>{if(!(!g||N.length===0&&!y&&!A.confirm)){if(Date.parse(g.expiresAt)<=Date.now()){d(!0);return}i.mutate({previewId:g.previewId,grants:N,...y&&{everyAgent:y}},{onSuccess:I=>{var $;if(I.connectionId!==g.connection.connectionId||!we(N,I.grants)||!Ae(y==null?void 0:y.operationRevisionIds,($=I.everyAgent)==null?void 0:$.operationRevisionIds)){d(!0),a.reset();return}m(I)},onError:()=>{d(!0),a.reset()}})}},u=()=>{o.refetch().then(N=>{var R,L;if(!N.data||!l||!e)return;const y=l.grants,A=y.map(k=>{var C;return{agentId:k.agentId,operationRevisionIds:((C=N.data.agents.find(D=>D.agentId===k.agentId))==null?void 0:C.operationRevisionIds)??[],...k.level&&{level:k.level}}});if(N.data.connection.connectionId!==e||l.connectionId!==e||!we(y,A)||l.everyAgent!==void 0&&!Ae(l.everyAgent.operationRevisionIds,((R=N.data.connection.everyAgent)==null?void 0:R.operationRevisionIds)??[])){d(!0),m(null),a.reset();return}const I=y.flatMap(k=>{const C=N.data.agents.find(D=>D.agentId===k.agentId);return C?[C]:[]}),$=N.data.connection.reconciliationStatus!=="ready"?N.data.connection.reconciliationStatus:((L=I.find(k=>k.reconciliationStatus!=="ready"))==null?void 0:L.reconciliationStatus)??"ready",_=[N.data.connection.authoritySync,...I.map(k=>k.authoritySync)],w=_.find(k=>k.status==="failed")??(_.some(k=>k.status==="pending")?{status:"pending"}:{status:"ready"});m({...l,reconciliationStatus:$,authoritySync:w})})},p=(l==null?void 0:l.reconciliationStatus)==="ready"&&l.authoritySync.status==="ready",S=l!==null&&l.reconciliationStatus!=="ready";return{preview:g,isLoading:a.isPending,loadFailed:a.isError,loadError:a.error,isSaving:i.isPending,needsRefresh:c,saveOutcome:l,saved:p,needsReconciliation:S,isCheckingSync:o.isFetching,syncCheckFailed:o.isError,refresh:j,apply:x,checkSync:u}}const it=6;function me(e){return e==="read"?"look":"change"}function ve(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=>me(o.capabilityClassification)==="look"),i=s.filter(o=>me(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(ve(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 oe={read:"Read","read-write":"Read and write"},Re={...oe,custom:"Exact actions"};function ce(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(W,{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=pe();return n.jsx(b,{...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 h;const i=v.useId(),o=An(e,s),c=((h=o.data)==null?void 0:h.status)==="listed"?o.data:null,d=a&&a.candidates.length>0?a:null,l=(d==null?void 0:d.level)??null,m=l?`With “${oe[l]}”, agents can`:`What ${t} offers agents`;let f;if(d)f=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))f=n.jsxs("p",{className:"text-muted-foreground text-sm",children:["Shows once DorkOS can reach ",t,"."]});else if(o.isPending)f=n.jsx(Ee,{});else if(o.isError){const g=Xe(o.error);f=n.jsxs("p",{className:"text-muted-foreground flex flex-wrap items-center gap-x-2 text-sm",children:[g?`${g.title}. ${g.description}`:`Couldn’t load what ${t} offers agents.`,n.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>void o.refetch(),disabled:o.isFetching,children:"Try again"}),(g==null?void 0:g.action)==="relink"&&n.jsx(nn,{variant:"link",size:"xs",className:"h-auto p-0"})]})}else c?f=n.jsx(_e,{actions:c.actions,completeness:c.completeness,toolkit:e,appName:t,level:null}):f=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:m}),f]})}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:P("rounded-full px-2.5 py-0.5 text-xs",e==="look"?"bg-muted text-foreground":ze.warning),children:ve(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(Ve,{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=me(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:ve(i,s)}),n.jsx("span",{className:P("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 J({titleId:e,toolkit:t,serviceName:s,logo:a,title:i,subtitle:o,variant:c="card",className:d,children:l}){const m=c==="embedded";return n.jsxs("section",{"aria-labelledby":e,"data-testid":"connection-access-card",className:P(m?"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:[!m&&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(se,{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(b,{size:"sm",variant:"secondary",className:"h-auto min-h-9 whitespace-normal",onClick:e.refresh,children:[n.jsx(re,{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(ye,{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(se,{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(se,{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 g;const s=v.useId(),a=Ge(),i=sn(((g=a.data)==null?void 0:g.connections)??[],e.toolkit),[o,c]=v.useState(null),[d,l]=v.useState(null),m=i.length===1?i[0].connectionId:null,f=d??(m?{id:m,picked:!1}:null);if(v.useEffect(()=>{!d&&m&&l({id:m,picked:!1})},[d,m]),f)return t(f.id,f.picked?()=>l(null):void 0);const h=`Which ${e.serviceName} account?`;return n.jsxs(J,{titleId:s,toolkit:e.toolkit,serviceName:e.serviceName,logo:e.logo,title:h,className:e.className,children:[a.isPending?n.jsx(z,{className:"h-16 rounded-lg","aria-label":"Loading accounts"}):a.isError?n.jsx(W,{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(We,{"aria-labelledby":s,value:o??"",onValueChange:c,className:"gap-2",children:i.map(j=>{const x=`${s}-${j.connectionId}`;return n.jsxs("div",{className:"bg-muted/40 flex min-h-11 items-center gap-3 rounded-lg px-3",children:[n.jsx(le,{id:x,value:j.connectionId}),n.jsxs(F,{htmlFor:x,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:j.label}),j.identityHint&&n.jsx("span",{className:"text-muted-foreground block max-w-full truncate text-xs",children:j.identityHint})]})]},j.connectionId)})}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.onSkip&&n.jsx(b,{variant:"ghost",onClick:e.onSkip,children:"Not now"}),i.length>1&&n.jsx(b,{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 m=v.useId(),f=q(e),h=Jn(e,{preferredAgentIds:s,systemAgentIds:a}),g=d?h:h.filter((x,u)=>u<Yn||i.has(x.agentId)||T(f[x.agentId])!=="none"),j=x=>{var u;return(u=e.agents.find(p=>p.agentId===x))==null?void 0:u.displayName};return n.jsxs("fieldset",{className:"space-y-1",children:[n.jsxs("legend",{className:"sr-only",children:["Agents that can use ",t]}),g.map(x=>{const u=`${m}-${x.agentId}`,p=T(f[x.agentId]),S=c.removedAgentIds.includes(x.agentId)||c.downgradedAgentIds.includes(x.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:u,"aria-describedby":S?`${u}-loss`:void 0,checked:i.has(x.agentId),onCheckedChange:N=>{const y=new Set(i);N===!0?y.add(x.agentId):y.delete(x.agentId),o(y)}}),n.jsx(F,{htmlFor:u,className:"min-w-0 flex-1 cursor-pointer py-2 font-normal",children:n.jsx("span",{className:"truncate",children:x.displayName})}),p!=="none"&&n.jsx(xn,{size:"xs",variant:"secondary","aria-label":`Now: ${Re[p]}`,children:Re[p]})]},x.agentId)}),g.length<h.length&&n.jsxs(b,{variant:"ghost",size:"sm",onClick:()=>l(!0),children:["Show all ",h.length]}),n.jsxs("div",{"aria-live":"polite",className:"space-y-1",children:[c.removedAgentIds.map(x=>n.jsxs("p",{id:`${m}-${x}-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}),j(x)," will lose access to ",t,"."]},x)),c.downgradedAgentIds.map(x=>n.jsxs("p",{id:`${m}-${x}-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}),j(x)," will lose write access."]},x))]})]})}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(se,{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 f;const{preview:t,serviceName:s,decision:a,level:i}=e,o=h=>{var g;return((g=t.agents.find(j=>j.agentId===h))==null?void 0:g.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(h=>e.picked.has(h.agentId)).map(h=>h.displayName),d=[c.length>0?`${ce(c)} can use ${s}.`:`No agent can use ${s}.`];((f=e.every.everyAgent)==null?void 0:f.operationRevisionIds.length)===0&&d.push(`${s} is no longer shared with every agent.`);const l=a.downgradedAgentIds.map(o);l.length>0&&d.push(`${ce(l)} can now only read.`);const m=a.removedAgentIds.map(o);return m.length>0&&d.push(`${ce(m)} 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(b,{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=v.useId();return n.jsxs(We,{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(le,{value:"picked",id:`${a}-picked`}),n.jsx(F,{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(le,{value:"every",id:`${a}-every`,disabled:!s,"aria-describedby":s?void 0:`${a}-every-unavailable`,className:"mt-0.5"}),n.jsxs(F,{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 k;const t=v.useId(),[s,a]=v.useState(new Set),[i,o]=v.useState("read"),[c,d]=v.useState("picked"),[l,m]=v.useState(!1),[f,h]=v.useState(!1),{data:g}=fn(void 0,e.mode==="page"),[j,x]=v.useState(null),u=at({connectionId:e.connectionId,active:!0,onPreview:C=>{x(C.connection);const D=q(C),Z=e.mode==="agent"?[e.agentId]:C.agents.map(M=>M.agentId).filter(M=>T(D[M])!=="none");a(new Set(e.mode==="agent"?[e.agentId]:Z));const ne=e.mode==="page"?Xn(C):"picked";d(ne);const X=ne==="every"?nt(C):e.mode==="agent"?ge([ie(C,e.agentId,!!e.onAllowed)]):ge(Z.map(M=>T(D[M]))),te=e.mode==="agent"&&e.request?e.request.access:null;o(te==="read-write"||X==="read-write"?"read-write":X),m(!1)}}),{preview:p}=u,S=e.mode==="agent"?e.agentId:null,N=v.useMemo(()=>p?Zn(p,{scope:S?[S]:c==="every"?[]:p.agents.map(C=>C.agentId),picked:s,level:i,levelTouched:S!==null||l,allowDowngrade:S===null}):{changes:[],removedAgentIds:[],downgradedAgentIds:[],needsLevel:!1},[p,s,i,l,S,c]),y=v.useMemo(()=>p&&S===null?et(p,{who:c,level:i,levelTouched:l}):{needsLevel:!1},[p,S,c,i,l]),A=p&&S?ie(p,S,e.mode==="agent"&&!!e.onAllowed):"none",I=e.mode==="agent"?e.onAllowed:void 0,$=I!==void 0&&p!==void 0&&(N.changes.length===0||A===i||A==="read-write")&&!N.needsLevel&&A!=="none"&&p.agents.some(C=>C.agentId===S),_=v.useRef(!1);v.useEffect(()=>{!u.saved||!I||_.current||(_.current=!0,I(e.connectionId))},[u.saveOutcome,u.saved,I,e.connectionId]);const r=e.mode==="agent"?(k=p==null?void 0:p.agents.find(C=>C.agentId===e.agentId))==null?void 0:k.displayName:void 0,w=e.mode==="page"?`Who can use ${e.serviceName}?`:`Let ${r??"this agent"} use ${e.serviceName}?`,R=u.needsRefresh||u.saveOutcome!==null,L=(j||e.onChangeAccount)&&n.jsxs("span",{className:"flex flex-wrap items-center gap-x-2",children:[j&&n.jsx("span",{className:"truncate",children:j.label}),e.onChangeAccount&&!R&&n.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:e.onChangeAccount,children:"Change account"})]});return n.jsxs(J,{titleId:t,toolkit:(j==null?void 0:j.toolkit)??(e.mode==="agent"?e.toolkit:void 0),serviceName:e.serviceName,logo:e.logo,title:w,subtitle:e.variant==="embedded"?void 0:L,variant:e.variant,className:e.className,children:[u.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"})]}):u.loadFailed?n.jsxs("div",{className:"space-y-2",children:[n.jsx(gt,{error:u.loadError,title:"Couldn’t load who can use it",description:"Nothing changed. Try again.",onRetry:u.refresh,isRetrying:u.isLoading}),e.mode==="page"&&n.jsx(Ct,{connectionId:e.connectionId,serviceName:e.serviceName}),e.onEditExactActions&&n.jsx(an,{onClick:()=>{var C;return(C=e.onEditExactActions)==null?void 0:C.call(e,e.connectionId)}})]}):R?n.jsx(yt,{access:u,savedDetail:p?St({mode:e.mode,...e.mode==="agent"&&{agentId:e.agentId},serviceName:e.serviceName,preview:p,picked:s,level:i,decision:N,who:c,every:y}):void 0}):p?n.jsx(At,{props:e,preview:p,picked:s,setPicked:a,who:c,setWho:d,decision:N,level:i,setLevel:C=>{o(C),m(!0)},showAll:f,setShowAll:h,systemAgentIds:((g==null?void 0:g.agents)??[]).filter(C=>C.isSystem).map(C=>C.id)}):null,n.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[u.needsReconciliation?n.jsx(b,{variant:"secondary",onClick:u.refresh,children:"Reload current access"}):u.saveOutcome&&!u.saved?n.jsxs(b,{variant:"secondary",onClick:u.checkSync,disabled:u.isCheckingSync,children:[n.jsx(re,{className:"size-4","aria-hidden":!0}),u.isCheckingSync?"Checking…":"Check if it’s done"]}):null,R?e.onFinished?n.jsx(b,{variant:u.saved?"default":"ghost",onClick:e.onFinished,children:u.saved?"Done":"Close"}):u.saveOutcome&&n.jsx(b,{variant:"ghost",onClick:u.refresh,children:"Edit again"}):p&&n.jsxs(n.Fragment,{children:[e.onSkip&&n.jsx(b,{variant:"ghost",onClick:e.onSkip,children:e.mode==="page"?"Skip":"Not now"}),n.jsx(b,{onClick:()=>$?I==null?void 0:I(e.connectionId):u.apply(N.changes,y.everyAgent),disabled:!$&&(N.changes.length===0&&!y.everyAgent||N.needsLevel||y.needsLevel||u.isSaving),children:u.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:m,setShowAll:f,systemAgentIds:h}){var _;const g=v.useId(),j=q(t),x=ae(t.candidates,"read"),u=ae(t.candidates,"read-write"),p=u.length>x.length?["read","read-write"]:["read"],S=e.mode==="agent"&&ie(t,e.agentId,!!e.onAllowed)==="read-write"?p.filter(r=>r==="read-write"):p,N=u.length===0,y=e.onEditExactActions&&n.jsx(an,{onClick:()=>{var r;return(r=e.onEditExactActions)==null?void 0:r.call(e,e.connectionId)}});let A;if(e.mode==="agent"){const r=t.agents.find(k=>k.agentId===e.agentId),w=T(j[e.agentId]),R=ie(t,e.agentId,!!e.onAllowed);A=r?w==="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."]}):w===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"?A=null:t.agents.length===0?A=n.jsx("p",{className:"text-muted-foreground text-sm",children:"No agents yet. Add one first."}):A=n.jsx(jt,{preview:t,serviceName:e.serviceName,preferredAgentIds:e.preferredAgentIds,systemAgentIds:h,picked:s,setPicked:a,decision:c,showAll:m,setShowAll:f});const I=e.mode==="agent"&&!t.agents.some(r=>r.agentId===e.agentId),$=e.mode==="agent"&&T(j[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:((_=t.agents.find(r=>r.agentId===e.agentId))==null?void 0:_.displayName)??"The agent",serviceName:e.serviceName,reason:e.request.reason,access:e.request.access,level:d}),A,N?n.jsxs("p",{className:"text-muted-foreground text-sm",children:[e.serviceName," has no actions for agents yet."]}):!I&&!$&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("p",{id:`${g}-level`,className:"text-muted-foreground text-xs font-medium",children:e.mode==="page"?"They can":"It can"}),S.length>1?n.jsx(pn,{"aria-labelledby":`${g}-level`,value:d??"",onValueChange:r=>l(r),children:S.map(r=>n.jsx(yn,{value:r,className:"min-h-9",children:oe[r]},r))}):n.jsx("p",{className:"text-sm",children:oe[S[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:N?null:d}}),(e.mode==="page"||y)&&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."}),y]})]})}function an({onClick:e}){return n.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:e,children:"Choose exact actions"})}function de(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=ue(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 $,_;const d=(o==null?void 0:o.id)??s.agentId,l=t.find(r=>r.id===s.definitionId),m=l?ue(l.filterSchema):[],f=jn(d||null,{enabled:s.destinationKind==="room"}),h=Kn(),g=Nn(s.destinationKind==="channel"),j=v.useMemo(()=>new Set((g.data??[]).filter(r=>r.config.enabled).map(r=>r.config.id)),[g.data]),x=v.useMemo(()=>(h.data??[]).filter(r=>r.agentId===d&&r.enabled&&r.canInitiate&&!!r.chatId&&j.has(r.adapterId)),[d,h.data,j]),u=r=>{a({...s,...r,...o?{agentId:o.id}:{}})},p=r=>{if(r===s.definitionId)return;const w=t.find(L=>L.id===r),R=w?ue(w.filterSchema):[];u({definitionId:r,filterValues:kn(R??[])})},S=`${e}-event`,N=`${e}-agent`,y=`${e}-destination-kind`,A=`${e}-room`,I=`${e}-channel`;return n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(F,{htmlFor:S,children:"Account activity"}),n.jsxs(U,{value:s.definitionId,onValueChange:p,children:[n.jsx(Q,{id:S,"aria-label":"Account activity",children:n.jsx(G,{placeholder:"Choose activity"})}),n.jsx(H,{children:t.map(r=>n.jsx(V,{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:N,className:"bg-muted/40 mt-1 rounded-md px-3 py-2 text-sm",children:o.displayName})]}):n.jsxs(n.Fragment,{children:[n.jsx(F,{htmlFor:N,children:"Agent"}),n.jsxs(U,{value:s.agentId,onValueChange:r=>u({agentId:r,destinationId:""}),children:[n.jsx(Q,{id:N,"aria-label":"Agent",children:n.jsx(G,{placeholder:"Choose agent"})}),n.jsx(H,{children:(i??[]).map(r=>n.jsx(V,{value:r.id,children:r.displayName},r.id))})]})]})}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(F,{htmlFor:y,children:"Send to"}),n.jsxs(U,{value:s.destinationKind,onValueChange:r=>u({destinationKind:r,destinationId:""}),children:[n.jsx(Q,{id:y,"aria-label":"Send to",children:n.jsx(G,{})}),n.jsxs(H,{children:[n.jsx(V,{value:"agent",children:"Agent"}),n.jsx(V,{value:"room",children:"Room"}),n.jsx(V,{value:"channel",children:"Messaging channel"})]})]})]})]}),s.destinationKind==="room"&&d&&n.jsxs("div",{className:"space-y-1",children:[n.jsx(F,{htmlFor:A,children:"Room"}),n.jsxs(U,{value:s.destinationId,onValueChange:r=>u({destinationId:r}),children:[n.jsx(Q,{id:A,"aria-label":"Room",children:n.jsx(G,{placeholder:"Choose a room"})}),n.jsx(H,{children:((($=f.data)==null?void 0:$.rooms)??[]).map(r=>n.jsx(V,{value:r.id,children:r.slug?`#${r.slug}`:r.name},r.id))})]}),f.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(b,{type:"button",size:"sm",variant:"ghost",onClick:()=>void f.refetch(),children:"Try again"})]}):!f.isPending&&(((_=f.data)==null?void 0:_.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(F,{htmlFor:I,children:"Messaging channel"}),n.jsxs(U,{value:s.destinationId,onValueChange:r=>u({destinationId:r}),children:[n.jsx(Q,{id:I,"aria-label":"Messaging channel",children:n.jsx(G,{placeholder:"Choose a channel"})}),n.jsx(H,{children:x.map(r=>n.jsx(V,{value:r.id,children:r.label||r.chatId},r.id))})]}),h.isError||g.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(b,{type:"button",size:"sm",variant:"ghost",onClick:()=>{h.refetch(),g.refetch()},children:"Try again"})]}):!h.isPending&&!g.isPending&&x.length===0?n.jsx("p",{className:"text-muted-foreground text-xs",children:"No channels this agent can start."}):null]}),l&&m===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."}),m==null?void 0:m.map(r=>{var L;const w=`${e}-filter-${r.name}`,R=(L=r.examples)!=null&&L.length?`${w}-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:w,"aria-describedby":R,checked:s.filterValues[r.name]===!0,onCheckedChange:k=>u({filterValues:{...s.filterValues,[r.name]:k===!0}})}),n.jsx(F,{htmlFor:w,children:r.label})]}):r.options?n.jsxs(n.Fragment,{children:[n.jsx(F,{htmlFor:w,children:r.label}),n.jsxs(U,{value:typeof s.filterValues[r.name]=="string"?String(r.options.indexOf(String(s.filterValues[r.name]))):"",onValueChange:k=>u({filterValues:{...s.filterValues,[r.name]:r.options[Number(k)]}}),children:[n.jsx(Q,{id:w,"aria-label":r.label,"aria-describedby":R,children:n.jsx(G,{placeholder:`Choose ${r.label.toLowerCase()}`})}),n.jsx(H,{children:r.options.map((k,C)=>n.jsx(V,{value:String(C),children:k===""?"Leave blank":k},k))})]})]}):n.jsxs(n.Fragment,{children:[n.jsx(F,{htmlFor:w,children:r.label}),n.jsx(he,{id:w,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:k=>u({filterValues:{...s.filterValues,[r.name]:k.target.value}})})]}),R&&n.jsxs("p",{id:R,className:"text-muted-foreground text-xs break-words",children:["Examples (not selected):"," ",r.examples.map(k=>JSON.stringify(k)).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]=v.useState(""),[c,d]=v.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 m=`${s}-public-origin`,f=`${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(F,{htmlFor:m,children:"Public DorkOS address"}),n.jsx(he,{id:m,type:"url",placeholder:"https://your-dorkos.example",value:i,onChange:h=>o(h.target.value)})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(F,{htmlFor:f,children:"Signing secret"}),n.jsx(he,{id:f,type:"password",autoComplete:"off",value:c,onChange:h=>d(h.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(b,{type:"button",size:"sm",variant:"secondary",disabled:a.isPending||c.length<16||!_t(i.trim()),onClick:()=>{const h=c;d(""),a.mutate({connectionId:e,input:{publicOrigin:i.trim(),webhookSecret:h}})},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=v.useMemo(()=>[...new Set(t)],[t]),[d,l]=v.useState(()=>Object.fromEntries(c.map(h=>[h,de(s.id)]))),m=v.useMemo(()=>{var h;return((h=i.data)==null?void 0:h.pages.flatMap(g=>g.definitions))??[]},[i.data]),f=v.useMemo(()=>{if(!o.data||!Lt(o.data))return null;const h=c.map(g=>Rt({connectionId:e,definitions:m.filter(j=>j.eventType===g),draft:d[g]??de(s.id)}));return h.every(g=>g!==null)?h:null},[s.id,e,m,d,c,o.data]);return v.useEffect(()=>a(f),[a,f]),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(W,{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(W,{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((h,g)=>{const j=m.filter(x=>x.eventType===h);return n.jsxs("section",{"aria-labelledby":`agent-request-event-${g}`,className:"bg-muted/30 space-y-3 rounded-lg p-3",children:[n.jsx("div",{children:n.jsx("h3",{id:`agent-request-event-${g}`,className:"text-sm font-medium",children:Tt(h)})}),j.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-${g}`,definitions:j,draft:d[h]??de(s.id),onChange:x=>l(u=>({...u,[h]:x})),fixedAgent:s,sourceStatus:o.data})]},h)}),i.hasNextPage&&n.jsx(b,{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 A,I,$;const d=v.useId(),l=pe(),m=$n(),f=Rn(),h=En(),[g,j]=v.useState(null),x=_n(g),u=(A=x.data)==null?void 0:A.state,p=u!==void 0&&Ot.has(u),S=((I=x.data)==null?void 0:I.state)==="pending"?x.data.authorizeUrl:void 0,N=m.isError||f.isError||p,y=($=e.readiness.fix)==null?void 0:$.action;return n.jsxs(J,{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}),S&&n.jsx(b,{asChild:!0,className:"w-full sm:w-auto",children:n.jsxs(Be,{href:S,children:["Sign in to ",t,n.jsx(Ue,{className:"size-4","aria-hidden":!0})]})}),g&&!S&&!p&&u!=="connected"&&n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(re,{className:"size-4 animate-spin motion-reduce:animate-none","aria-hidden":!0}),"Getting the sign-in page ready…"]}),N&&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(b,{variant:"ghost",onClick:i,disabled:o,children:"Not now"}),y==="resume"&&n.jsx(b,{onClick:()=>m.mutate({connectionId:e.connectionId,input:void 0}),disabled:m.isPending,children:m.isPending?"Resuming…":"Resume"}),y==="sign_in_again"&&(!g||p)&&n.jsx(b,{onClick:()=>f.mutate({connectionId:e.connectionId},{onSuccess:_=>j(_.flowId)}),disabled:f.isPending,children:"Sign in again"}),y==="retry"&&n.jsx(b,{variant:"secondary",onClick:()=>h.mutate(),disabled:h.isPending,children:h.isPending?"Checking…":"Check again"}),y==="fix_key"&&n.jsx(b,{variant:"secondary",onClick:()=>l.open("connections","ways"),children:"Fix the key"}),y==="connect_new"&&n.jsxs(b,{onClick:c,children:["Connect ",t," again"]}),y==="review_access"&&n.jsx(b,{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 Vt(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 In(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 Wt(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 S;const s=Wn(),a=qn(),i=pe(),[o,c]=v.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(W,{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"),m=(S=a.data)==null?void 0:S.newApps,f=(m==null?void 0:m.status)==="setup_needed"?m.reason:null,h=f==="dorkos_account_unlinked"||f==="dorkos_account_unavailable",g=f==="nothing_set_up",j=f==="own_key_unavailable",x=h||g||j,u=()=>{t==null||t(),i.open("account")},p=h?n.jsx(b,{size:"lg",variant:"outline",className:"w-full",onClick:u,children:"Link my DorkOS account again"}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(b,{size:"lg",variant:g?"default":"outline",className:"w-full",onClick:u,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}),x&&!j&&p,d&&(o?n.jsx(Ce,{status:d}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs(b,{size:"lg",variant:h||g?"outline":"default",className:"w-full",onClick:()=>c(!0),children:[n.jsx(Bn,{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."})]})),x&&j&&p,l&&n.jsxs(Me,{children:[n.jsxs(Ve,{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,deciding:o,className:c}){var R;const d=v.useId(),[l,m]=v.useState(null),[f,h]=v.useState(!1),g=zn(e.requestId),j=Mn(e.requestId,l),x=He(e.serviceSlug),u=(R=x.data)==null?void 0:R.pages[0],p=u==null?void 0:u.appConnections,S=on(s),N=zt(S,p==null?void 0:p.newApps),y=j.data??g.data,A=!y&&Mt(s),I=Kt(N,s),$=(y==null?void 0:y.state)==="connected"?y.connectionId:null;v.useEffect(()=>{$&&a($)},[$,a]);const _=()=>{if(A){h(!0);return}N&&g.mutate({providerInstanceId:N.providerInstanceId},{onSuccess:L=>m(L.flowId)})},r=(y==null?void 0:y.state)==="starting"||(y==null?void 0:y.state)==="pending";let w;return x.isPending&&!s?w=n.jsx(z,{className:"h-10 rounded-lg","aria-label":`Loading ${t}`}):A&&f?w=S.length===0&&Vt(u)&&(p==null?void 0:p.newApps.status)==="ready"?n.jsx(W,{title:`Couldn’t reach ${t} just now`,description:`${rn(p.newApps.way)} didn’t answer. Try again soon.`,onRetry:()=>void x.refetch(),isRetrying:x.isFetching}):n.jsx(qt,{reason:Wt(p,s)}):r?w=n.jsxs("div",{className:"space-y-3",children:[I&&n.jsx("p",{className:"text-sm",children:I}),y.state==="pending"&&y.authorizeUrl?n.jsx(b,{asChild:!0,className:"w-full sm:w-auto",children:n.jsxs(Be,{href:y.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(re,{className:"size-4 animate-spin motion-reduce:animate-none","aria-hidden":!0}),y.state==="starting"?"Getting the sign-in page ready…":`Finish signing in to ${t}…`]})]}):w=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}),g.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t start sign-in. Try again."})]}),n.jsxs(J,{titleId:d,toolkit:e.serviceSlug,serviceName:t,logo:ee(s),title:`Connect ${t}`,subtitle:`So ${e.agent.displayName} can use it`,className:c,children:[w,n.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[n.jsx(b,{variant:"ghost",onClick:i,disabled:o,children:"Not now"}),!r&&!(A&&f)&&n.jsx(b,{onClick:_,disabled:g.isPending||o||!A&&!N,children:g.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?ye:i?Je:Un;return n.jsxs("p",{role:"status","data-testid":"agent-request-receipt","data-status":e.status,className:P("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:P("mt-0.5 size-4 shrink-0",a&&"text-status-success"),"aria-hidden":!0}),n.jsx("span",{className:P("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 ls({request:e,onEditExactActions:t,className:s}){var te,M,je,Ne,ke;const a=Vn(),i=Ln(e.sessionId),o=Ht(a.error)?e.sessionId:null,c=Fn(o),d=Ge(),m=((te=He(e.serviceSlug,e.status==="awaiting_owner").data)==null?void 0:te.pages.flatMap(E=>E.services).find(E=>E.serviceSlug===e.serviceSlug))??null,f=(m==null?void 0:m.displayName)??Tn(e.serviceSlug),h=e.agent.displayName,[g,j]=v.useState(null),[x,u]=v.useState(null),[p,S]=v.useState([]),[N,y]=v.useState(!1),[A,I]=v.useState(!1),[$,_]=v.useState(null),r=v.useCallback(()=>{u(null),a.mutate({requestId:e.requestId,decision:{decision:"denied"}})},[a,e.requestId]),w=v.useCallback((E,B=[])=>{u(E),S(B),a.mutate({requestId:e.requestId,decision:{decision:"current_access",connectionId:E,eventScopes:B}})},[a,e.requestId]),R=e.requestedEvents.length>0,L=v.useCallback(E=>R?_(E):w(E),[w,R]),k=P("max-w-xl",s);if(x&&a.isError){const{reason:E,fix:B}=Jt(a.error,h,f),cn=B==="updates"&&$!==null,be=B==="turn_on"&&((Ne=(je=(M=c.data)==null?void 0:M.connections.find(dn=>dn.connectionId===x))==null?void 0:je.readiness.fix)==null?void 0:Ne.action)==="turn_on_for_this_chat";return n.jsxs(J,{titleId:`agent-request-unanswered-${e.requestId}`,toolkit:e.serviceSlug,serviceName:f,logo:ee(m),title:`${h} can now use ${f}`,className:k,children:[n.jsxs("div",{role:"alert",className:"space-y-1 text-sm","data-testid":"agent-request-unanswered",children:[n.jsxs("p",{children:[n.jsx(ye,{className:"text-status-success mr-1.5 inline size-4 align-text-bottom","aria-hidden":!0}),"Access saved, but ",h,"’s request wasn’t answered."]}),n.jsxs("p",{children:[E,be&&" Turning it on only affects this chat."]})]}),cn?n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(b,{variant:"ghost",onClick:()=>w(x,[]),disabled:a.isPending,children:"Answer without updates"}),n.jsx(b,{onClick:()=>a.reset(),disabled:a.isPending,children:"Pick updates again"})]}):B==="retry"&&n.jsx("div",{className:"flex justify-end",children:n.jsx(b,{onClick:()=>w(x,p),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(b,{onClick:()=>i.mutate({connectionId:x,on:!0},{onSuccess:()=>w(x,p)}),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:f,className:k});const C=a.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:Gt});if($)return n.jsx(Xt,{request:e,connectionId:$,serviceName:f,logo:ee(m),onAnswer:E=>w($,E),deciding:a.isPending,className:k},$);if(d.isPending)return n.jsx(z,{className:P("h-28 rounded-xl",k),"aria-label":"Loading accounts"});if(d.isError)return n.jsx("div",{className:k,children:n.jsx(W,{title:"Couldn’t load your accounts",description:"Nothing changed. Try again.",onRetry:()=>void d.refetch(),isRetrying:d.isFetching})});const D=((ke=d.data)==null?void 0:ke.connections)??[],Z=D.filter(E=>E.toolkit===e.serviceSlug&&E.readiness.state!=="gone"),ne=sn(D,e.serviceSlug),X=N||!!g||ne.length>0;if(!X&&(Z.length===0||A))return n.jsxs("div",{className:P("space-y-2",k),children:[n.jsx(Bt,{request:e,serviceName:f,service:m,onConnected:j,onDecline:r,deciding:a.isPending}),C]});if(!X){const E=Z[0];return n.jsxs("div",{className:P("space-y-2",k),children:[n.jsx(Dt,{account:E,serviceName:f,logo:ee(m),agentName:h,onDecline:r,deciding:a.isPending,onConnectAgain:()=>I(!0)}),C]})}return n.jsx(Zt,{onShown:y,children:n.jsxs("div",{className:P("space-y-2",k),"data-testid":"agent-request-access",children:[n.jsx(wt,{mode:"agent",agentId:e.agent.id,toolkit:e.serviceSlug,serviceName:f,logo:ee(m),...g?{connectionId:g}:{},request:{reason:e.reason,access:e.access},...t?{onEditExactActions:t}:{},onSkip:r,onAllowed:L}),C]})})}function Zt({onShown:e,children:t}){return v.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]=v.useState(null);return n.jsxs(J,{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(b,{variant:"ghost",onClick:()=>i([]),disabled:o,children:"No updates"}),n.jsx(b,{onClick:()=>d&&i(d),disabled:o||!d,children:o?"Sending…":"Send updates"})]})]})}export{ls as A,Ft as C,qt as F,gt as L,nn as R,Qn as a,os as b,rs as c,cs as d,de as e,Rt as f,Et as g,$t as h,Lt as i,ce as j,wt as k,on as l,zt as m,Mt as n,Kt as o,Vt as p,Wt as q,mt as r,ee as s,at as t,Gn as u,q as v,rn as w,ds as x,yt as y};
@@ -0,0 +1 @@
1
+ import{j as e,cS as F,cT as U,Q as b,W as f,bF as v,cU as W,cV as $,cW as B,R as G,r as u,cX as E,B as D,X as V,cY as q,b as J,e as K,t as X,g as Y}from"./index-CdKpQ1hI.js";import{u as Q,P as Z}from"./use-personality-commit-DUEKxHt_.js";import"./dorkbot-templates-8Yu9POWJ.js";import"./sound-D3r8dGFH.js";import"./soul-file-Cag2i87x.js";const H={hidden:{},visible:{transition:{staggerChildren:.04}}},I={hidden:{opacity:0,scale:.5},visible:{opacity:1,scale:1,transition:{type:"spring",stiffness:500,damping:25}}};function _(){return e.jsx(f.span,{className:"pointer-events-none absolute inset-0 flex items-center justify-center",initial:{scale:0,opacity:1},animate:{scale:1,opacity:0},transition:{duration:.6,ease:[.34,1.56,.64,1]},"aria-hidden":!0,children:e.jsx(G,{className:"size-4 text-white drop-shadow-md",strokeWidth:3})})}function O({celebratory:s,className:t,children:a}){return s?e.jsx(f.div,{className:t,variants:H,initial:"hidden",animate:"visible",children:a}):e.jsx("div",{className:t,children:a})}function T({celebratory:s,children:t}){return s?e.jsx(f.div,{variants:I,children:t}):t}const ee=e.jsx("span",{className:"text-3xs leading-none font-bold",children:"A"}),te="ring-muted-foreground/50 ring-dashed ring-2 ring-offset-2",se="Select default color";function ae({value:s,autoColor:t,onSelect:a,onHoverChange:i,justSelectedKey:o,celebratory:n=!1,autoIcon:r=ee,autoActiveRing:c=te,autoLabel:d=se}){const x=s!=null;return e.jsxs(O,{celebratory:n,className:"flex flex-wrap items-center gap-2",children:[e.jsx(T,{celebratory:n,children:e.jsx(A,{active:!x,activeRing:c,color:t,label:d,tooltip:"Unique, derived from agent name",onClick:()=>a(null),onHoverChange:i,justSelected:o==="auto",celebratory:n,children:r})}),e.jsx("div",{className:"bg-border mx-0.5 h-5 w-px"}),F.map(l=>e.jsx(T,{celebratory:n,children:e.jsx(A,{active:s===l.hex,activeRing:"ring-foreground ring-2 ring-offset-2",color:l.hex,label:`Select ${l.name}`,tooltip:l.name,onClick:()=>a(l.hex),onHoverChange:i,justSelected:o===l.hex,celebratory:n})},l.hex))]})}function A({active:s,activeRing:t,color:a,label:i,tooltip:o,tooltipSide:n="bottom",onClick:r,onHoverChange:c,justSelected:d,celebratory:x,children:l}){const h=e.jsxs("button",{type:"button",onClick:r,onMouseEnter:()=>c==null?void 0:c(a),onMouseLeave:()=>c==null?void 0:c(null),className:b("group/swatch relative size-8 rounded-full transition-[scale,box-shadow] duration-150",s?t:"hover:scale-110"),style:{backgroundColor:a},"aria-label":i,children:[l&&e.jsx("span",{className:"bg-background/80 text-foreground absolute inset-0 flex items-center justify-center rounded-full",children:l}),x&&e.jsx("span",{className:"absolute inset-[-4px] -z-10 rounded-full opacity-0 blur-md transition-opacity duration-200 group-hover/swatch:opacity-50",style:{backgroundColor:a},"aria-hidden":!0}),e.jsx(v,{children:d&&e.jsx(_,{})})]});return x?e.jsxs(W,{children:[e.jsx($,{asChild:!0,children:h}),e.jsx(B,{side:n,className:"text-3xs",children:o})]}):h}function ne({value:s,autoEmoji:t,hasOverride:a,onSelect:i,justSelectedKey:o,celebratory:n=!1}){return e.jsx(O,{celebratory:n,className:"grid grid-cols-6 gap-1.5",children:U.map(r=>{const c=r===s,d=r===t&&!a,x=b("relative flex size-9 items-center justify-center rounded-md text-lg transition-colors duration-150",c?b(d?"bg-accent ring-muted-foreground/50 ring-1":"bg-accent ring-foreground ring-1",d&&!n&&"ring-dashed"):"hover:bg-accent/50 active:scale-90");return e.jsx(ie,{celebratory:n,onClick:()=>i(r),className:x,ariaLabel:`Select icon ${r}`,justSelected:o===`emoji-${r}`,children:r},r)})})}function ie({celebratory:s,onClick:t,className:a,ariaLabel:i,justSelected:o,children:n}){const r=e.jsx(v,{children:o&&e.jsx(_,{})});return s?e.jsxs(f.button,{type:"button",onClick:t,className:a,"aria-label":i,variants:I,whileHover:{scale:1.25},whileTap:{scale:.85},transition:{type:"spring",stiffness:500,damping:20},children:[n,r]}):e.jsxs("button",{type:"button",onClick:t,className:a,"aria-label":i,children:[n,r]})}const re=e.jsx(q,{className:"size-3"}),oe="ring-muted-foreground/50 ring-2 ring-offset-2",ce="Select unique auto-generated color",C="dorkos:avatar-first-customization",le={hidden:{},visible:{transition:{staggerChildren:.04}}},w={hidden:{opacity:0,y:4},visible:{opacity:1,y:0,transition:{duration:.2,ease:"easeOut"}}};function ue(){const[s]=u.useState(()=>Array.from({length:14},(a,i)=>{const o=Math.PI*2*i/14,n=28+Math.random()*20,r=360*i/14;return{x:Math.cos(o)*n,y:Math.sin(o)*n,size:3+Math.random()*3,hue:r,delay:i*.02}}));return e.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 overflow-visible","aria-hidden":!0,children:s.map((t,a)=>e.jsx(f.span,{className:"absolute top-1/2 left-1/2 rounded-full",style:{width:t.size,height:t.size,background:`hsl(${t.hue}, 80%, 70%)`,boxShadow:`0 0 6px hsl(${t.hue}, 80%, 70%)`},initial:{x:"-50%",y:"-50%",scale:0,opacity:1},animate:{x:t.x,y:t.y,scale:1,opacity:0},transition:{duration:.6,ease:"easeOut",delay:t.delay}},a))})}function de({agent:s,onUpdate:t,onPreviewColor:a,title:i,onClose:o}){const n=u.useMemo(()=>E(s.id),[s.id]),r=n.color,c=n.icon,d=s.icon??c,x=s.color!=null,l=s.icon!=null,h=x||l,[y,S]=u.useState(null),p=u.useRef(null),[R,k]=u.useState(!1),N=u.useRef(!1);u.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const g=u.useCallback(()=>{if(!N.current){try{if(localStorage.getItem(C))return;localStorage.setItem(C,"true")}catch{return}N.current=!0,k(!0),setTimeout(()=>k(!1),800)}},[]),j=u.useCallback(m=>{p.current&&clearTimeout(p.current),S(m),p.current=setTimeout(()=>S(null),600)},[]),z=u.useCallback(()=>{t({color:null,icon:null})},[t]),P=u.useCallback(m=>{t({color:m}),a(null),j(m??"auto"),g()},[t,a,j,g]),L=u.useCallback(m=>{t({icon:m===c?null:m}),j(`emoji-${m}`),g()},[t,c,j,g]),M=u.useCallback(m=>{a(m)},[a]);return e.jsxs("div",{className:"flex flex-1 flex-col overflow-auto","data-testid":"avatar-picker-panel",children:[(i||o||h)&&e.jsxs("div",{className:b("flex items-center justify-between px-4 py-2",(i||o)&&"border-b"),children:[i&&e.jsx("span",{className:"text-xs font-semibold",children:i}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[e.jsx(v,{children:h&&e.jsx(f.button,{type:"button",onClick:z,className:"text-muted-foreground hover:text-foreground text-3xs transition-colors",initial:{opacity:0,x:8},animate:{opacity:1,x:0},exit:{opacity:0,x:8},transition:{duration:.2},children:"Reset to defaults"})}),o&&e.jsx(D,{variant:"ghost",size:"icon-md",className:"size-6",onClick:o,"aria-label":"Close appearance picker",children:e.jsx(V,{className:"size-3.5"})})]})]}),e.jsxs(f.div,{className:"space-y-5 p-4",variants:le,initial:"hidden",animate:"visible",children:[e.jsxs(f.div,{variants:w,children:[e.jsx("div",{className:"text-muted-foreground text-3xs mb-2 font-medium tracking-wider uppercase",children:"Color"}),e.jsx(ae,{value:s.color,autoColor:r,onSelect:P,onHoverChange:M,justSelectedKey:y,celebratory:!0,autoIcon:re,autoActiveRing:oe,autoLabel:ce})]}),e.jsxs(f.div,{variants:w,children:[e.jsx("div",{className:"text-muted-foreground text-3xs mb-2 font-medium tracking-wider uppercase",children:"Icon"}),e.jsx(ne,{value:d,autoEmoji:c,hasOverride:l,onSelect:L,justSelectedKey:y,celebratory:!0})]})]}),e.jsx(v,{children:R&&e.jsx(ue,{})})]})}function xe({children:s}){return e.jsx("h3",{className:"text-muted-foreground text-3xs font-medium tracking-wider uppercase",children:s})}function be({member:s}){const{agent:t,isPending:a,update:i}=J(s),o=Q(t,i),[n,r]=u.useState(null);if(a)return e.jsx(K,{className:"h-64 w-full"});if(!t)return e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t read this agent’s appearance."});const c=X(s),d=E(t.id),x=n??t.color??d.color,l=t.icon??d.icon;return e.jsxs("div",{className:"flex flex-col gap-5","data-slot":"profile-appearance",children:[e.jsx("div",{className:"flex justify-center pt-1",children:e.jsx(Y,{size:"lg",kind:c.kind,color:x,emoji:l,fallback:c.fallback,origin:c.origin})}),e.jsx(de,{agent:t,onUpdate:i,onPreviewColor:r}),e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsx(xe,{children:"Personality"}),e.jsx(Z,{traits:o.traits,onTraitsChange:o.onTraitsChange,compact:!0})]})]})}export{be as AppearancePage};
@@ -0,0 +1 @@
1
+ import{g5 as k,a8 as A,a9 as C,g6 as x,aa as j,ab as T,aA as I,g7 as R,j as n,bG as N,bH as D,Q as P,bI as E,bK as L,r as B,cE as q,cF as _,cH as F,cI as K,cJ as O,dB as M,g8 as Q,e1 as W,dh as z,B as p}from"./index-CdKpQ1hI.js";function X(e,s){const a=new Set(e.filesAndCommands.followingAgentIds);if(s.kind==="files")return a.size;const t=e.exceptions.filter(o=>o.action===void 0),r=new Set;if(s.kind==="preset"){const o=new Map;for(const c of t){const l=o.get(c.agentId)??new Set;l.add(c.area),o.set(c.agentId,l)}for(const[c,l]of o)l.size>=k.length&&!a.has(c)&&r.add(c)}else{for(const o of t)o.area===s.area&&r.add(o.agentId);if(s.kind==="action")for(const o of e.exceptions)o.action===s.action&&r.add(o.agentId)}return Math.max(0,e.agentCount-r.size)}function Y(e){return`affects ${e} ${e===1?"agent":"agents"}`}function V(){const e=A();return C({queryKey:x.overview(),queryFn:()=>e.getPermissions()})}function Z(e){const s=A(),a=j();return T({mutationFn:async t=>{if(t.kind==="preset"){if(e.kind!=="default")throw new Error("A preset is chosen for everyone.");return s.setPermissionPreset({preset:t.preset,surface:t.surface,...t.applyToAgents?{applyToAgents:t.applyToAgents}:{}})}const r={...t.areas?{areas:t.areas}:{},...t.actions?{actions:t.actions}:{},surface:t.surface};return e.kind==="agent"?s.patchAgentPermissions(e.agentId,{...r,...t.filesAndCommands!==void 0?{filesAndCommands:t.filesAndCommands}:{}}):s.patchPermissionDefaults({...r,...t.applyToAgents?{applyToAgents:t.applyToAgents}:{}})},onSettled:()=>{a.invalidateQueries({queryKey:x.all}),a.invalidateQueries({queryKey:["mesh","agents"]}),a.invalidateQueries({queryKey:I.all})}})}const g={blocked:"Blocked",ask:"Ask",allowed:"Allowed"},v={careful:"Careful",balanced:"Balanced",full:"Full power",trusted:"Trusted"},ee={careful:"Agents ask before they change anything, and can’t reach outside DorkOS.",balanced:"Agents run their rooms and ask before anything wider.",full:"Agents do everyday work alone and ask before installs or settings changes.",trusted:"Agents work on their own, and everything they do is recorded."};function se(e,s){switch(e){case"default-area":case"default-action":return"Changed from your preset";case"preset":return`From ${v[s??"trusted"]}`;case"floor":return"Never Allowed";case"always-asks":return"Always asks, so you see the change first";default:return""}}const te="Blocked stops agents that follow the rules. It isn’t a sandbox.";function ne(e){switch(e){case"agent":return"Set for this agent";case"runtime":return"Set in Settings → Runtimes";case"default":return"The setting everyone has";case"runtime-own":return"Not set, so each AI tool uses its own default"}}function w(e){return`the default (${v[e??"trusted"]})`}function ae(e){const s=g[e.state],a=e.agentName??"this agent";switch(e.source){case"inactive":return"Blocked, because this agent’s access was turned off.";case"floor":return`${s}. This area is locked, so it’s never Allowed.`;case"always-asks":return e.fromExtension?`${s}. Extension tools that can delete things always ask.`:`${s}. It always shows you the change first, so it’s never Allowed.`}if(e.destructiveAsk)return"Ask. Actions that run someone else’s code ask unless set one by one.";switch(e.source){case"agent-area":return`${s}, set for ${a}.`;case"agent-action":return`${s}, set for this one action on ${a}.`;case"default-area":return`${s} for everyone, changed from ${w(e.preset)}.`;case"default-action":return`${s} for everyone, set for this one action.`;case"preset":return`${s}, from ${w(e.preset)}.`}}function re(e,s,a){const t=e?R(e):null;switch(s){case"agent":return`${t}, set for ${a??"this agent"}.`;case"runtime":return`${t}, set in Settings → Runtimes.`;case"default":return`${t}, the setting everyone has.`;case"runtime-own":return"Not set, so each AI tool uses its own default."}}const H={settings:" in Settings","agent-page":" on the agent’s page","control-center":" in the Control Center","request-card":" from a request card","first-run":" during setup","agent-request":" from an agent's request",api:" through the API",cli:" from the command line",upgrade:"",undo:" with Undo","file-edit":""};function U(e){return new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function G(e){if(!e)return null;const s=`on ${U(e.occurredAt)}`,a=H[e.surface];switch(e.attribution){case"signed-in":return`Changed by ${e.actorLabel.charAt(0).toLowerCase()+e.actorLabel.slice(1)} ${s}${a}.`;case"local-trust":return`Changed ${s}${a}. With login off, who is unknown.`;case"agent-request-approved":return`Changed ${s}: ${e.actorLabel}.`;case"agent":return`Changed by ${e.actorLabel} ${s}.`;case"upgrade":return`Set by an upgrade ${s}.`;case"outside":return`Changed outside DorkOS ${s}, in the agent’s settings file.`}}function oe({question:e,sentence:s,lastChange:a,className:t}){const r=G(a);return n.jsxs(N,{children:[n.jsx(D,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":e,className:P("text-muted-foreground hover:text-foreground focus-visible:ring-ring inline rounded-sm py-2 text-xs underline decoration-dotted underline-offset-2 transition-colors focus-visible:ring-2 focus-visible:outline-none md:py-0",t),children:"Why?"})}),n.jsxs(E,{className:"w-72 space-y-1.5",align:"start",children:[n.jsx(L,{className:"text-sm font-medium",children:e}),n.jsx("p",{className:"text-sm","data-testid":"permission-why-source",children:s}),r?n.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"permission-why-change",children:r}):null]})]})}function ie({open:e,onCancel:s,subject:a,title:t,next:r,agents:o,affectedCount:c,onKeep:l,onUpdate:b,pending:m=!1}){const[u,f]=B.useState(new Set),S=r in g?g[r]:r,y=o.length,$=(i,h)=>{const d=new Set(u);h?d.add(i):d.delete(i),f(d)};return n.jsx(q,{open:e,onOpenChange:i=>{i||(f(new Set),s())},children:n.jsxs(_,{className:"!min-h-0 sm:max-w-md",children:[n.jsxs(F,{children:[n.jsx(K,{children:t??`Set ${a} to ${S} for everyone?`}),n.jsxs(O,{children:[y===1?"1 agent is":`${y} agents are`," set differently. Pick any that should follow."]})]}),n.jsxs(M,{className:"space-y-3",children:[n.jsx("ul",{className:"space-y-2","aria-label":"Agents set differently",children:o.map(i=>{const h=`apply-${i.agentId}`;return n.jsxs("li",{className:"flex items-center gap-2",children:[n.jsx(Q,{id:h,checked:u.has(i.agentId),onCheckedChange:d=>$(i.agentId,d===!0)}),n.jsxs(W,{htmlFor:h,className:"text-sm font-normal",children:[i.agentName,": ",i.detail]})]},i.agentId)})}),n.jsxs("p",{className:"text-muted-foreground text-sm",children:["This affects ",c," ",c===1?"agent":"agents"," now."]})]}),n.jsxs(z,{className:"gap-2",children:[n.jsx(p,{variant:"outline",onClick:()=>{f(new Set),l()},disabled:m,children:"Keep their settings"}),n.jsx(p,{onClick:()=>{const i=[...u];f(new Set),b(i)},disabled:m||u.size===0,children:"Update selected"})]})]})})}export{ie as A,te as B,oe as P,g as S,Z as a,re as b,X as c,Y as d,v as e,ne as f,se as g,ee as h,G as l,ae as s,V as u};
@@ -0,0 +1 @@
1
+ import{aD as r,aE as n,j as e,W as i,a7 as o,B as d}from"./index-CdKpQ1hI.js";const c={initial:{opacity:0,y:8},animate:{opacity:1,y:0}};function l({signal:t}){const a=r(),s=n(t.since);return e.jsxs(i.div,{variants:c,"data-slot":"attention-signal-row",className:"hover:bg-accent/50 flex min-w-0 items-center gap-2.5 rounded-md px-2 py-1 transition-colors",children:[e.jsx("span",{className:"bg-status-error size-1.5 shrink-0 rounded-full","aria-hidden":!0}),e.jsx(o,{className:"text-status-error/70 size-3.5 shrink-0","aria-hidden":!0}),e.jsxs("span",{className:"text-foreground/90 min-w-0 flex-1 truncate text-xs",children:[t.primary,t.secondary!==void 0&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",t.secondary]})]}),e.jsx("span",{className:"text-muted-foreground shrink-0 text-xs tabular-nums",children:s}),e.jsx(d,{variant:"ghost",size:"sm",className:"relative h-6 shrink-0 px-2 text-xs after:absolute after:-inset-3 md:after:hidden","aria-label":`Open ${t.primary}`,onClick:()=>void a.navigate({href:t.deepLink}),children:"Open →"})]})}export{l as A};