dorkos 0.111.0 → 0.114.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 (192) hide show
  1. package/core-extensions/hello-world/index.ts +2 -2
  2. package/dist/bin/cli.js +13549 -1698
  3. package/dist/browser/native/package-manifest.json +1 -1
  4. package/dist/browser/source-manifest.json +1 -1
  5. package/dist/client/assets/{AboutPage-BKzqcz_A.js → AboutPage-mErbIY0l.js} +1 -1
  6. package/dist/client/assets/{ActivityErrorState-BXOZg9ve.js → ActivityErrorState-AlI4F82u.js} +1 -1
  7. package/dist/client/assets/{ActivityPage-CFN2MEAV.js → ActivityPage-CHUqb-8c.js} +1 -1
  8. package/dist/client/assets/{ActivityRow-CujXx04u.js → ActivityRow-Baqdr6cP.js} +1 -1
  9. package/dist/client/assets/AdapterIcon-C_fBZXHQ.js +1 -0
  10. package/dist/client/assets/{AdapterSetupWizard-3Bt9HEWF.js → AdapterSetupWizard-BL70qy2J.js} +2 -2
  11. package/dist/client/assets/{AgentRequestCard-CAaBGC0L.js → AgentRequestCard-CcMh6JyE.js} +3 -3
  12. package/dist/client/assets/{AppearancePage-BEe-Gssu.js → AppearancePage-t9SnSRs-.js} +1 -1
  13. package/dist/client/assets/{AttentionSignalRow-Cp0AJs73.js → AttentionSignalRow-jlgWaSSd.js} +1 -1
  14. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-CN1iW2cB.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-DHr_AhUv.js} +3 -3
  15. package/dist/client/assets/{BlintzCanvas-B7qs2dxW.js → BlintzCanvas-Bq4e7n__.js} +1 -1
  16. package/dist/client/assets/{CanvasCsvContent-DiB5zXOC.js → CanvasCsvContent-OR226CLS.js} +2 -2
  17. package/dist/client/assets/CanvasFileContent-BejM-9Wg.js +2 -0
  18. package/dist/client/assets/CanvasModel3dContent-BD-eCVsX.js +2 -0
  19. package/dist/client/assets/{CodeMirrorDiff-BJhflpbC.js → CodeMirrorDiff-D7BWMOim.js} +1 -1
  20. package/dist/client/assets/{CodeMirrorEditor-SkdXRKSN.js → CodeMirrorEditor-BodwsIG7.js} +1 -1
  21. package/dist/client/assets/{CommitmentList-DsEn6iK1.js → CommitmentList-YVb3yTvO.js} +1 -1
  22. package/dist/client/assets/{CommitmentsPage-W5h0GjRr.js → CommitmentsPage-DL_jJQbw.js} +1 -1
  23. package/dist/client/assets/{ConnectionAccessLists-DVFqelmV.js → ConnectionAccessLists-BPsgToSR.js} +1 -1
  24. package/dist/client/assets/{ConnectionsPage-CZhSh2mO.js → ConnectionsPage-D7vlYnjf.js} +2 -2
  25. package/dist/client/assets/{ConventionPage-DcDBP-vR.js → ConventionPage-BR7I3AdE.js} +3 -3
  26. package/dist/client/assets/{ExtensionPageRoute-mKN8Jqyx.js → ExtensionPageRoute-CzXGvVRm.js} +2 -2
  27. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-CGXG-x9g.js → FloatingTanStackRouterDevtools-CqogiFob-BV3h0rFa.js} +1 -1
  28. package/dist/client/assets/HandlePage-B33P0oh0.js +1 -0
  29. package/dist/client/assets/{HeartbeatPage-DFf7Udem.js → HeartbeatPage-CfjZuvtQ.js} +1 -1
  30. package/dist/client/assets/{LexicalField-vJ284m2H.js → LexicalField-Cc6wFZAZ.js} +2 -2
  31. package/dist/client/assets/{ManagesPage-mDuaA2JT.js → ManagesPage-BxHSb65X.js} +1 -1
  32. package/dist/client/assets/{Marketplace-BoiupH2Z.js → Marketplace-EgG6JmBG.js} +4 -4
  33. package/dist/client/assets/{MarketplaceSourcesView-krw9hUyu.js → MarketplaceSourcesView-D9kq9hl6.js} +1 -1
  34. package/dist/client/assets/{McpAppFrame-DmHduNgp.js → McpAppFrame-6zxszx9A.js} +2 -2
  35. package/dist/client/assets/{McpSigninBody-DoY09n4J.js → McpSigninBody-DBWSc6bm.js} +1 -1
  36. package/dist/client/assets/{Model3dViewer-BZEdR7-9.js → Model3dViewer-CgeJ2v-F.js} +1 -1
  37. package/dist/client/assets/NamePage-MfybpnwN.js +1 -0
  38. package/dist/client/assets/NewDirectMessageMenu-BnBO4aGI.js +1 -0
  39. package/dist/client/assets/{NotificationsPage-CybW1eIb.js → NotificationsPage-C5aRITCd.js} +1 -1
  40. package/dist/client/assets/{OpenMeshSwitch-DrmjsCDY.js → OpenMeshSwitch-UKMQeS7-.js} +2 -2
  41. package/dist/client/assets/{OperatorIdentityForm-byU2FeSU.js → OperatorIdentityForm-DH2au7QU.js} +1 -1
  42. package/dist/client/assets/{PermissionsPage-CP3kbqyJ.js → PermissionsPage-BgLLmdg2.js} +1 -1
  43. package/dist/client/assets/{PersonalityPopover-BLsjgaum.js → PersonalityPopover-vLDfndfo.js} +1 -1
  44. package/dist/client/assets/PhotoPage-BgyB3B2_.js +1 -0
  45. package/dist/client/assets/{PreviewRefusedNotice-fTN8MJ1h.js → PreviewRefusedNotice-Dh3SCC_A.js} +1 -1
  46. package/dist/client/assets/{PromptSuggestionChips-BZOaY5Tx.js → PromptSuggestionChips-EO_0zbzq.js} +1 -1
  47. package/dist/client/assets/{ReportsToPopover-B6JvfRt3.js → ReportsToPopover-C9Ceg1AW.js} +1 -1
  48. package/dist/client/assets/{RoomSurface-BM0QO_av.js → RoomSurface-B8ec3_at.js} +8 -8
  49. package/dist/client/assets/{RoomsPage-B-NOCLXC.js → RoomsPage-pPw8vrsB.js} +1 -1
  50. package/dist/client/assets/{RunsOnPopover-D1jQQatj.js → RunsOnPopover-CJoSj8w7.js} +1 -1
  51. package/dist/client/assets/RuntimeSetupDialog-Cqn_Grel.js +1 -0
  52. package/dist/client/assets/SessionsPage-BASybh9v.js +1 -0
  53. package/dist/client/assets/{SkillsPage-CPTFjEUe.js → SkillsPage-DL0909et.js} +1 -1
  54. package/dist/client/assets/{TasksPage-BRUqs3v5.js → TasksPage-BwUW6dia.js} +1 -1
  55. package/dist/client/assets/{ToolsPage-C25kL822.js → ToolsPage-C3xfGWdb.js} +2 -2
  56. package/dist/client/assets/{TopologyGraph-of6Cp5Kj.js → TopologyGraph-D7Ik1Xt6.js} +1 -1
  57. package/dist/client/assets/{TourHost-zwSilkjm.js → TourHost-Db0fxAXo.js} +1 -1
  58. package/dist/client/assets/{UnlinkDialog-BgwHAqdW.js → UnlinkDialog-TTK5Z_QD.js} +1 -1
  59. package/dist/client/assets/{WidgetErrorCard-BQwrR6PJ.js → WidgetErrorCard-D--KcgW1.js} +24 -29
  60. package/dist/client/assets/_shell-CGWsN6Gs.js +88 -0
  61. package/dist/client/assets/{_shell._home-BkP0NafS.js → _shell._home-CzpVyTzo.js} +1 -1
  62. package/dist/client/assets/{_shell._home.activity-BO_2ciGK.js → _shell._home.activity-BbWquOK0.js} +1 -1
  63. package/dist/client/assets/_shell._home.index-Cg0nRFMN.js +3 -0
  64. package/dist/client/assets/_shell._home.tasks-BpoOVihw.js +1 -0
  65. package/dist/client/assets/{_shell._home.workspaces-B34Uk1SP.js → _shell._home.workspaces-DVF1rM3t.js} +1 -1
  66. package/dist/client/assets/_shell.channels-CCGSs0Bn.js +10 -0
  67. package/dist/client/assets/{_shell.connections-BNbeBrxQ.js → _shell.connections-0_34lXIQ.js} +1 -1
  68. package/dist/client/assets/{_shell.feedback-requests-B71l48KB.js → _shell.feedback-requests-C6alx2ox.js} +1 -1
  69. package/dist/client/assets/_shell.marketplace-Dp-p8E3V.js +1 -0
  70. package/dist/client/assets/_shell.marketplace_.sources-SN2Fb1eb.js +1 -0
  71. package/dist/client/assets/{_shell.session-ybAc0bwn.js → _shell.session-Bt3jdQdD.js} +15 -15
  72. package/dist/client/assets/_shell.team-BIwJNdkd.js +28 -0
  73. package/dist/client/assets/_shell.x._extensionId-Bjn-MKsP.js +1 -0
  74. package/dist/client/assets/_shell.x._extensionId_._-Bjn-MKsP.js +1 -0
  75. package/dist/client/assets/{agent-browser-Cs8abkZs.js → agent-browser-CO5haI5Y.js} +1 -1
  76. package/dist/client/assets/{banner-CU2Nh3Kv.js → banner-Dh5mO27l.js} +2 -2
  77. package/dist/client/assets/{card-BTgwskmX.js → card-CKZCX8ol.js} +1 -1
  78. package/dist/client/assets/{file-DlQX-hKl.js → file-CMPbZedq.js} +1 -1
  79. package/dist/client/assets/{file-exclamation-point-Dg2iCyPM.js → file-exclamation-point-emLeXvmw.js} +1 -1
  80. package/dist/client/assets/file-text-9a0DChCq.js +6 -0
  81. package/dist/client/assets/{find-latest-widget-fence-BGiexm6r.js → find-latest-widget-fence--3kWMT1F.js} +3 -3
  82. package/dist/client/assets/{git-branch-Dq_w3Iyx.js → git-branch-hfu8isLA.js} +1 -1
  83. package/dist/client/assets/{heart-Bp14wOx6.js → heart-SRafwnSd.js} +1 -1
  84. package/dist/client/assets/{highlighted-body-KPVGNVTW-kD1HK_wk.js → highlighted-body-KPVGNVTW-Dxwd3mxT.js} +1 -1
  85. package/dist/client/assets/index-3GDQSKet.js +1 -0
  86. package/dist/client/assets/{index-BA-nPsLw.js → index-BB18IeC2.js} +1 -1
  87. package/dist/client/assets/index-BBQMqcO_.js +1 -0
  88. package/dist/client/assets/{index-CcV9S7cO.js → index-BDfoFNcA.js} +1 -1
  89. package/dist/client/assets/{index-DNglWRBB.js → index-BNn3-chz.js} +1 -1
  90. package/dist/client/assets/{index-Dm53S0up.js → index-BRGOMmOM.js} +1 -1
  91. package/dist/client/assets/{index-5OyUurJr.js → index-BTXBESRm.js} +1 -1
  92. package/dist/client/assets/{index-B8R78Nnj.js → index-BTreBsWa.js} +2 -2
  93. package/dist/client/assets/{index-kHXlTLUx.js → index-BUVKya1M.js} +8 -8
  94. package/dist/client/assets/{index-aDNEGBTK.js → index-BYp9xcmS.js} +1 -1
  95. package/dist/client/assets/{index-DnmtTIUB.js → index-BokDvdOG.js} +1 -1
  96. package/dist/client/assets/{index-BxrZwUJp.js → index-C3xuhmPa.js} +2 -2
  97. package/dist/client/assets/{index-B6_ikFYj.js → index-C4nEz6I-.js} +1 -1
  98. package/dist/client/assets/{index-Dr-0P6rd.js → index-C63bLSO4.js} +267 -262
  99. package/dist/client/assets/{index-Cc280M3V.js → index-C7BTAdSc.js} +1 -1
  100. package/dist/client/assets/{index-knGXyHhh.js → index-CAlXjm0N.js} +1 -1
  101. package/dist/client/assets/index-CTxEG5rD.js +1 -0
  102. package/dist/client/assets/{index-gu2JYnOq.js → index-CbFo-7kM.js} +1 -1
  103. package/dist/client/assets/{index-DKlxz3u7.js → index-Ch41JOI2.js} +1 -1
  104. package/dist/client/assets/{index-BxUoa3yn.js → index-CkknQ52Q.js} +5 -5
  105. package/dist/client/assets/{index-C-DN0Vg_.js → index-Cow815Qa.js} +1 -1
  106. package/dist/client/assets/{index-DO6a5Hey.js → index-Cp7oifSs.js} +1 -1
  107. package/dist/client/assets/{index--3UwFg2s.js → index-CpYs0Lli.js} +1 -1
  108. package/dist/client/assets/{index-C99173Ze.js → index-D0Nd2LA-.js} +1 -1
  109. package/dist/client/assets/{index-BeBmUxo_.js → index-D67aFWxz.js} +1 -1
  110. package/dist/client/assets/index-DFEF2MFy.css +1 -0
  111. package/dist/client/assets/{index-CAhJGlSW.js → index-DIlV08Vw.js} +1 -1
  112. package/dist/client/assets/{index-BHsZlKfx.js → index-DLNwEM2Q.js} +1 -1
  113. package/dist/client/assets/{index-PxSRtDpP.js → index-DLZi_nae.js} +1 -1
  114. package/dist/client/assets/{index-LszRbEbX.js → index-DRqEM5Wb.js} +1 -1
  115. package/dist/client/assets/{index-B0OZehWe.js → index-DX-j3Ul0.js} +1 -1
  116. package/dist/client/assets/{index-CKCMjqcu.js → index-DX7V94qe.js} +1 -1
  117. package/dist/client/assets/{index-C_uYJzKi.js → index-D_Wc_qTa.js} +3 -3
  118. package/dist/client/assets/{index-DW6zqLoM.js → index-DdsKmfEH.js} +1 -1
  119. package/dist/client/assets/{index-DHUToGjI.js → index-DmTI5Hye.js} +1 -1
  120. package/dist/client/assets/{index-DKQDBIWq.js → index-YswfjpmW.js} +1 -1
  121. package/dist/client/assets/{index-DSPs6GF4.js → index-g_5oOlG6.js} +1 -1
  122. package/dist/client/assets/{index-DS-thlE8.js → index-iD0epmn3.js} +1 -1
  123. package/dist/client/assets/{index-CDWsIVX7.js → index-lJc8v0Z3.js} +1 -1
  124. package/dist/client/assets/index-t7gsOfUI.js +1 -0
  125. package/dist/client/assets/kickoff-xkt4LpIP.js +3 -0
  126. package/dist/client/assets/{layers-B0oCOfxz.js → layers-Cy8Tme6i.js} +1 -1
  127. package/dist/client/assets/{lightbulb-D80IzMqz.js → lightbulb-tNm7gLYi.js} +1 -1
  128. package/dist/client/assets/{markdown-content-aNzh-54y.js → markdown-content-CoK3F0c0.js} +1 -1
  129. package/dist/client/assets/{mention-pill-BxMK0xuY.js → mention-pill-Bgs_yujj.js} +1 -1
  130. package/dist/client/assets/{message-square-off-D-CJXmTq.js → message-square-off-CF2Bzen3.js} +1 -1
  131. package/dist/client/assets/{owner-notice-BkrTEMDm.js → owner-notice-cgCWG4hG.js} +1 -1
  132. package/dist/client/assets/{package-CoTlAnXZ.js → package-DE8sQpId.js} +1 -1
  133. package/dist/client/assets/{page-container-CPxW5T9E.js → page-container-BoXmmBSs.js} +1 -1
  134. package/dist/client/assets/{paperclip-Cj1P85mz.js → paperclip-IgDeVFea.js} +1 -1
  135. package/dist/client/assets/{radio-DICkTr_p.js → radio-BzTkFBDD.js} +1 -1
  136. package/dist/client/assets/{room-files-source-BywWQPBN.js → room-files-source-CIIDTSTA.js} +2 -2
  137. package/dist/client/assets/{rotate-ccw-clock-cx5RyP4l.js → rotate-ccw-clock-CGcSqHnk.js} +1 -1
  138. package/dist/client/assets/{rotate-cw-DrGRGSwy.js → rotate-cw-DaduzRfP.js} +1 -1
  139. package/dist/client/assets/{scroll-area-XlDz8u4m.js → scroll-area-DW0-Liri.js} +1 -1
  140. package/dist/client/assets/{search-x-LIKnWE64.js → search-x-Sme5ElYi.js} +1 -1
  141. package/dist/client/assets/{shield-x-DioB6qH_.js → shield-x-Bh5xap8N.js} +1 -1
  142. package/dist/client/assets/{soul-file-C7YgkNET.js → soul-file-NcuTUIiB.js} +1 -1
  143. package/dist/client/assets/{table-P4N5xQn2.js → table-BEtvgYmW.js} +1 -1
  144. package/dist/client/assets/{use-connector-management-pgVHbXoO.js → use-connector-management-Cohvs7jD.js} +1 -1
  145. package/dist/client/assets/{use-delete-binding-DxEiOjjh.js → use-delete-binding-C19umm_i.js} +1 -1
  146. package/dist/client/assets/{use-dev-links-BImQrE6g.js → use-dev-links-DRnLdl--.js} +1 -1
  147. package/dist/client/assets/{use-external-adapter-catalog-D8KHMSZU.js → use-external-adapter-catalog-BOn9aj72.js} +1 -1
  148. package/dist/client/assets/use-full-activity-feed-BpQANbns.js +1 -0
  149. package/dist/client/assets/use-is-below-desktop-5LlietdR.js +1 -0
  150. package/dist/client/assets/{use-jump-back-in-D9tBJ4v5.js → use-jump-back-in-CkFErfWY.js} +3 -3
  151. package/dist/client/assets/{use-mesh-topology-DBeqzUoy.js → use-mesh-topology-CIsDeAY0.js} +1 -1
  152. package/dist/client/assets/use-panel-tab-placements-AFrWTQ0a.js +1 -0
  153. package/dist/client/assets/use-pending-read-Dol8yvIx.js +1 -0
  154. package/dist/client/assets/{use-personality-commit-Gfoi__sT.js → use-personality-commit-fUtuc2lC.js} +1 -1
  155. package/dist/client/assets/{use-promo-activation-Bv1gnqKq.js → use-promo-activation-Dxt-1yuT.js} +3 -3
  156. package/dist/client/assets/{use-pulse-freshness-SFRdnugS.js → use-pulse-freshness-DRRM5Hza.js} +1 -1
  157. package/dist/client/assets/{use-room-follow-claim-Cf20JiJ_.js → use-room-follow-claim-huRfaa4e.js} +1 -1
  158. package/dist/client/assets/{use-roving-tab-list-3Pb7ps4E.js → use-roving-tab-list-BZIBAGgJ.js} +1 -1
  159. package/dist/client/assets/{use-session-canvas-BaXuEhw8.js → use-session-canvas-CZIsr9qL.js} +4 -4
  160. package/dist/client/assets/{use-session-diagnostics-7xxJ6zQQ.js → use-session-diagnostics-C41hV7rK.js} +4 -4
  161. package/dist/client/assets/{use-unclaimed-chats-D4k-EK_f.js → use-unclaimed-chats-BMlFQ2v1.js} +1 -1
  162. package/dist/client/index.html +2 -2
  163. package/dist/server/index.js +123677 -118335
  164. package/dist/server/index.js.map +2 -2
  165. package/package.json +7 -8
  166. package/dist/client/assets/AdapterIcon-BdM7K69W.js +0 -1
  167. package/dist/client/assets/CanvasFileContent-CDNfnWMW.js +0 -2
  168. package/dist/client/assets/CanvasModel3dContent-C7EINmuq.js +0 -2
  169. package/dist/client/assets/HandlePage-Bun58ePo.js +0 -1
  170. package/dist/client/assets/NamePage-CXyClUPJ.js +0 -1
  171. package/dist/client/assets/NewDirectMessageMenu-BjqYwnXW.js +0 -1
  172. package/dist/client/assets/PhotoPage-hn5b42qN.js +0 -1
  173. package/dist/client/assets/RuntimeSetupDialog-ufwCvCJB.js +0 -1
  174. package/dist/client/assets/SessionsPage-CBE1KHYg.js +0 -1
  175. package/dist/client/assets/_shell-bcx2y7VT.js +0 -88
  176. package/dist/client/assets/_shell._home.index-B-OFwU9u.js +0 -3
  177. package/dist/client/assets/_shell._home.tasks-jAQczH7j.js +0 -1
  178. package/dist/client/assets/_shell.channels-CGzsxvXD.js +0 -10
  179. package/dist/client/assets/_shell.marketplace-3YAsNaRk.js +0 -1
  180. package/dist/client/assets/_shell.marketplace_.sources-cI3nNBXr.js +0 -1
  181. package/dist/client/assets/_shell.team-BE_60YS4.js +0 -28
  182. package/dist/client/assets/_shell.x._extensionId-jiyP599c.js +0 -1
  183. package/dist/client/assets/_shell.x._extensionId_._-jiyP599c.js +0 -1
  184. package/dist/client/assets/index-B2JJZXsq.js +0 -1
  185. package/dist/client/assets/index-BAjUSKoJ.js +0 -1
  186. package/dist/client/assets/index-BpDY3eoD.js +0 -1
  187. package/dist/client/assets/index-ExcAk4pE.css +0 -1
  188. package/dist/client/assets/index-F7Lcwnfm.js +0 -1
  189. package/dist/client/assets/kickoff-Btbza7bw.js +0 -3
  190. package/dist/client/assets/use-full-activity-feed-2o7GNAMe.js +0 -1
  191. package/dist/client/assets/use-is-below-desktop-DBet5zg_.js +0 -1
  192. package/dist/client/assets/use-pending-read-DmrlNHS0.js +0 -1
@@ -1 +1 @@
1
- import{ae as b,aj as z,gW as h,gX as g,af as w,ag as $,cQ as M,an as W,j as e,r as d,df as O,Z as N,B as j,at as I,dD as y,dg as C,fR as q,fS as K,fT as Q,fU as U,fV as Y,fW as G,fX as X,fY as J,h as H,l as E,e3 as V,ad as Z,e as A,e6 as ee,gY as R,aa as L}from"./index-Dr-0P6rd.js";import{B as P}from"./banner-CU2Nh3Kv.js";import{P as T}from"./package-CoTlAnXZ.js";function D(s){const t=b();return z({queryKey:h.status(s),queryFn:()=>t.getHarnessStatus(s),staleTime:3e4,refetchOnMount:"always"})}const se={native:"reads it",projected:"shared",drifted:"out of date",dropped:"can’t see it",warned:"may not work",conflict:"blocked","pending-approval":"needs your OK"},te={native:"neutral",projected:"neutral",drifted:"info",dropped:"muted",warned:"warning",conflict:"warning","pending-approval":"warning"},k="\0",ne=new Set(["native","projected"]);function _(s){return`${s.scope??"project"}${k}${s.artifact}${k}${s.source??""}${k}${s.name}`}function ae(s,t){return`${g[s]} ${se[t]}`}function re(s){return s.reason??s.target}function B(s,t){return t.flatMap(n=>{const a=s.cells[n];return a===void 0?[]:[{harness:n,cell:a}]})}function le(s,t){if(t.length===0)return!1;const n=B(s,t);return n.length===t.length&&n.every(({cell:a})=>{var r;return ne.has(a.state)&&!((r=a.warnings)!=null&&r.length)})}function S(s){return`${s} ${s===1?"file":"files"}`}function ie(s){return s===1?"One package is waiting for your approval.":`${s} packages are waiting for your approval.`}function oe(s){return`Shared with all ${s}`}function ce(s){return s===1?"1 agent file":`${s} agent files`}function de(s){return`Agent files ${s} can’t see: skills, rules, commands and more.`}function ue(s){return s===1?"1 entry":`${s} entries`}function xe(s,t){return t.flatMap(n=>{const a=s.flatMap(r=>{const l=r.cells[n];return l===void 0||l.state!=="dropped"?[]:[{key:_(r),artifact:r.artifact,name:r.name,...l.reason===void 0?{}:{reason:l.reason}}]});return a.length===0?[]:[{harness:n,label:g[n],entries:a}]})}const fe={drop:"Not shared",warning:"Couldn’t read",write:"Will be written",notice:"Notice"};function me(s){return`${fe[s.kind]} · ${s.artifact} ${s.name}`}function pe(s){const t=b(),n=w();return $({mutationFn:()=>t.syncHarness(s),meta:{errorLabel:"Couldn’t share your agent files"},onSuccess:a=>{n.setQueryData(h.status(s),a.status),M.success("Agent files updated.")}})}function he(s){const t=w();W("approval_resolved",()=>{t.invalidateQueries({queryKey:h.status(s)})})}function ge({result:s,onDismiss:t}){const{applied:n,removals:a,askedAbout:r}=s;return e.jsx(P,{variant:"neutral",onDismiss:t,dismissLabel:"Dismiss what changed","data-slot":"harness-sync-summary",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Agent files updated."}),n>0&&e.jsxs(e.Fragment,{children:[" ",S(n)," written."]})]}),a.length>0&&e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("p",{className:"font-medium",children:["Removed ",S(a.length)," DorkOS put here:"]}),e.jsx("ul",{className:"flex flex-col gap-0.5",children:a.map(({path:l,reason:c})=>e.jsxs("li",{className:"text-3xs flex flex-col",children:[e.jsx("code",{className:"font-mono",children:l}),e.jsx("span",{className:"opacity-80",children:c})]},l))})]}),r.length>0&&e.jsx("p",{children:ie(r.length)})]})})}function je(s){const{counts:t,sweepPreview:n}=s;return t.drifted>0||n.length>0?{message:"Some agent files are out of date.",variant:n.length>0?"warning":"info",actionable:!0}:t.conflicts>0?{message:"DorkOS can’t update some files. Something blocks them.",variant:"warning",actionable:!1}:t.adoptable>0?{message:"Some skills only reach a few of your agents.",variant:"info",actionable:!1}:null}function ve({projectPath:s}){return he(s),null}function Ne({projectPath:s}){const{data:t}=D(s),n=pe(s),[a,r]=d.useState(!1),[l,c]=d.useState(!1);if(t===void 0||t.state!=="ready")return null;const u=e.jsx(ve,{projectPath:s});if(n.data!==void 0&&!l)return e.jsxs(e.Fragment,{children:[u,e.jsx(ge,{result:n.data,onDismiss:()=>c(!0)})]});const o=je(t);if(o===null)return u;const{removals:x,sweepPreview:m}=t,i=m.length;return e.jsxs(e.Fragment,{children:[u,e.jsx(P,{variant:o.variant,"data-slot":"harness-drift-banner",detailsOpen:a,details:i===0?void 0:e.jsx("ul",{className:"flex flex-col gap-0.5",children:x.map(({path:f,reason:v})=>e.jsxs("li",{className:"text-3xs flex flex-col",children:[e.jsx("code",{className:"font-mono",children:f}),e.jsx("span",{className:"opacity-80",children:v})]},f))}),actions:o.actionable?e.jsx(j,{size:"sm",variant:"outline",className:"h-6 text-xs",disabled:n.isPending,onClick:()=>{c(!1),n.mutate()},children:n.isPending?"Syncing…":"Sync now"}):void 0,children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("p",{children:o.message}),i>0&&e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>r(f=>!f),className:"text-3xs flex w-fit items-center gap-1 underline underline-offset-2 opacity-90 hover:opacity-100",children:["Syncing also removes ",S(i)," DorkOS put here",e.jsx(O,{"aria-hidden":!0,className:N("size-3 transition-transform",a&&"rotate-180")})]})]})})]})}function ye(s){const t=b(),n=w();return $({mutationFn:a=>t.adoptHarness(s,a),meta:{errorLabel:"Couldn’t move that skill"},onSuccess:a=>{n.setQueryData(h.status(s),a.status),n.setQueriesData({queryKey:h.all,predicate:r=>{var l;return((l=r.state.data)==null?void 0:l.projectPath)===a.status.projectPath}},a.status)}})}const ke={neutral:y.neutral,info:y.info,warning:y.warning,muted:"border border-dashed border-border text-muted-foreground"};function Se({harness:s,cell:t}){var l;const n=ae(s,t.state),a=re(t),r=(l=t.warnings)!=null&&l.length?t.warnings.join(" · "):void 0;return e.jsxs("li",{"aria-label":n,...a===void 0?{}:{title:a},className:N("text-3xs inline-flex items-center gap-1 rounded-full px-2 py-0.5 leading-tight",ke[te[t.state]]),children:[n,r!==void 0&&e.jsx("span",{role:"img","aria-label":"May not work",title:r,className:"inline-flex",children:e.jsx(I,{"aria-hidden":!0,className:"text-status-warning-fg size-2.5"})})]})}function be(s){const t=s===void 0?-1:s.lastIndexOf("/"),n=t>0?s==null?void 0:s.slice(0,t):void 0;return n===void 0?"Only some agents can see it. Move it to .agents/skills to share it.":`Lives in ${n}. Move it to .agents/skills to share it.`}function we(s,t){return`dorkos harness adopt ${s} --project ${t}`}const Ce="Share with every agent";function De(s,t,n){const a=`It moves from ${t} to .agents/skills/${s}`;return n?`${a}. A link stays behind for Claude Code.`:`${a}, where every agent reads it.`}const Ae="for all your projects";function $e({row:s,enabled:t,projectPath:n,showEveryHarness:a}){var v;const[r,l]=d.useState(!1),[c,u]=d.useState(!1),o=ye(n),x=B(s,t),m=le(s,t)&&!a,i=m&&!r,f=(v=o.data)==null?void 0:v.refusals[0];return e.jsxs("div",{role:"group","aria-label":s.name,className:"flex flex-col gap-1 py-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx("span",{className:"min-w-0 shrink truncate text-xs font-medium",children:s.name}),s.scope==="global"&&e.jsx("span",{className:"text-muted-foreground text-3xs shrink-0",children:Ae}),s.source!==void 0&&e.jsx("span",{dir:"rtl",title:s.source,className:"text-muted-foreground text-3xs ml-auto min-w-0 truncate text-left font-mono",children:e.jsx("bdi",{dir:"ltr",children:s.source})})]}),e.jsxs("ul",{"aria-label":"Agent tools",className:"flex flex-wrap items-center gap-1",children:[m&&e.jsx("li",{children:e.jsxs("button",{type:"button","aria-expanded":!i,title:x.map(({harness:p})=>g[p]).join(" · "),onClick:()=>l(p=>!p),className:"bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground text-3xs focus-visible:ring-ring inline-flex items-center gap-1 rounded-full px-2 py-0.5 leading-tight transition-colors focus-visible:ring-2 focus-visible:outline-none",children:[oe(x.length),e.jsx(O,{"aria-hidden":!0,className:N("size-2.5 transition-transform",i&&"-rotate-90")})]})}),!i&&x.map(({harness:p,cell:F})=>e.jsx(Se,{harness:p,cell:F},p))]}),s.adoptable&&e.jsxs(e.Fragment,{children:[e.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground text-3xs",children:(f==null?void 0:f.reason)||be(s.source)}),e.jsxs("p",{className:"text-muted-foreground text-3xs",children:["Run: ",e.jsx(C,{children:we(s.name,n)})]}),e.jsx("div",{children:e.jsx(j,{size:"sm",variant:"outline",className:"h-6 text-xs",disabled:o.isPending,onClick:()=>u(!0),children:Ce})}),e.jsx(q,{open:c,onOpenChange:u,children:e.jsxs(K,{children:[e.jsxs(Q,{children:[e.jsxs(U,{children:["Move ",s.name," so every agent can read it?"]}),e.jsx(Y,{children:De(s.name,s.source??"",t.includes("claude-code"))})]}),e.jsxs(G,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(J,{onClick:()=>o.mutate(s.name),children:"Move it"})]})]})})]})]})}const Oe="https://dorkos.ai/docs/guides/cli-usage#agent-files";function He(){return e.jsxs(e.Fragment,{children:[e.jsx("span",{role:"status",className:"sr-only",children:"Loading skills…"}),e.jsx("div",{"aria-hidden":!0,className:"flex flex-col gap-3 py-1",children:[0,1,2].map(s=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(A,{className:"h-3 w-32"}),e.jsx(A,{className:"h-3 w-48"})]},s))})]})}function Ee({projectPath:s,showBrowseLink:t=!0}){const{data:n,isPending:a,error:r,refetch:l}=D(s),[c,u]=d.useState(!1),o=d.useId(),x=H();if(a)return e.jsx(He,{});if(r)return e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx("p",{className:"text-destructive text-xs",children:"Couldn’t load skills."}),e.jsx(j,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>void l(),children:"Retry"})]});if(n.state!=="ready")return e.jsx(Re,{status:n});const m=n.rows.filter(i=>i.artifact==="skill");return m.length===0?e.jsxs("div",{className:"flex flex-col items-start gap-1 py-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"No skills here yet."}),t&&x&&e.jsxs(j,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-6 px-1 text-xs",onClick:()=>void x({...E.marketplace(),search:{type:"skill-pack"}}),children:[e.jsx(T,{"aria-hidden":!0,className:"mr-1.5 size-3.5"}),"Browse skill-packs"]})]}):e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 pb-1",children:[e.jsx(V,{htmlFor:o,className:"text-muted-foreground text-3xs",children:"Show every agent tool"}),e.jsx(Z,{id:o,size:"sm",checked:c,onCheckedChange:u})]}),e.jsx("div",{className:"divide-border divide-y",children:m.map(i=>e.jsx($e,{row:i,enabled:n.enabled,projectPath:n.projectPath,showEveryHarness:c},_(i)))})]})}function Re({status:s}){return s.state==="not-set-up"?e.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"DorkOS isn’t sharing agent files for this folder yet."}),e.jsxs("p",{className:"text-muted-foreground text-3xs",children:["Run ",e.jsx(C,{children:"dorkos harness sync --fix"})," in this folder to set it up."]}),e.jsx(ee,{href:Oe,className:"text-3xs text-muted-foreground hover:text-foreground underline underline-offset-2",children:"How agent file sharing works"})]}):s.state==="unreadable"?e.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"DorkOS can’t read this folder’s agent file settings."}),s.detail!==void 0&&e.jsx("p",{className:"text-muted-foreground text-3xs",children:s.detail})]}):e.jsx("p",{className:"text-muted-foreground py-2 text-xs",children:"Agent file sharing runs in the DorkOS app."})}function Le({group:s}){const[t,n]=d.useState(!1);return e.jsxs(R,{open:t,onOpenChange:n,trigger:e.jsxs("span",{className:"text-xs",children:["Not shared with ",s.label]}),badge:e.jsx(L,{variant:"secondary",size:"xs",className:"whitespace-nowrap",children:ce(s.entries.length)}),children:[e.jsx("p",{className:"text-muted-foreground text-3xs px-4 pt-3",children:de(s.label)}),e.jsx("ul",{className:"space-y-2 px-4 pt-2 pb-3",children:s.entries.map(a=>e.jsxs("li",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"text-3xs font-medium",children:[a.artifact," ",a.name]}),a.reason!==void 0&&e.jsx("span",{className:"text-muted-foreground text-3xs",children:a.reason})]},a.key))})]})}function Pe({rows:s,enabled:t}){const n=xe(s,t);return n.length===0?null:e.jsx("div",{className:"flex flex-col gap-1.5",children:n.map(a=>e.jsx(Le,{group:a},a.harness))})}function Te({entries:s}){const[t,n]=d.useState(!1);return s.length===0?null:e.jsx(R,{open:t,onOpenChange:n,trigger:e.jsx("span",{className:"text-xs",children:"Project-level notices"}),badge:e.jsx(L,{variant:"secondary",size:"xs",className:"whitespace-nowrap",children:ue(s.length)}),children:e.jsx("ul",{className:"space-y-2 px-4 pb-3",children:s.map(a=>e.jsxs("li",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:N("text-3xs font-medium",a.kind==="notice"&&"text-muted-foreground font-normal"),children:me(a)}),e.jsx("span",{className:"text-muted-foreground text-3xs",children:a.reason})]},`${a.kind} ${a.artifact} ${a.source??""} ${a.name}`))})})}function _e({command:s}){return e.jsx(C,{className:"break-normal",children:s.split(" ").map((t,n)=>e.jsxs(d.Fragment,{children:[n>0&&" ",e.jsx("span",{className:"whitespace-nowrap",children:t})]},`${n}-${t}`))})}function Be({notEnabled:s}){return s.length===0?null:e.jsx("div",{className:"flex flex-col gap-1.5 py-1",children:s.map(({harness:t,why:n,signal:a})=>e.jsxs("div",{title:a,className:"flex flex-col gap-0.5",children:[e.jsx("p",{className:"text-xs font-medium",children:n==="dorkos-runtime"?`DorkOS runs ${g[t]} here, but isn’t sharing to it.`:`${g[t]} files are here, but DorkOS isn’t sharing to it.`}),e.jsxs("p",{className:"text-muted-foreground text-3xs",children:["Run ",e.jsx(_e,{command:`dorkos harness sync --fix --enable ${t}`})," in this folder to turn it on."]})]},t))})}function Fe({projectPath:s}){const t=H(),{data:n}=D(s),a=(n==null?void 0:n.state)==="ready"?n:null;return e.jsxs("div",{className:"flex flex-col gap-2","data-slot":"profile-skills",children:[e.jsx(Ne,{projectPath:s}),a&&e.jsx(Be,{notEnabled:a.notEnabled}),e.jsx(Ee,{projectPath:s,showBrowseLink:!1}),a&&e.jsx(Pe,{rows:a.rows,enabled:a.enabled}),a&&e.jsx(Te,{entries:a.projectLevel}),t&&e.jsxs(j,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground w-full",onClick:()=>void t({...E.marketplace(),search:{type:"skill-pack"}}),children:[e.jsx(T,{"aria-hidden":!0,className:"mr-1.5 size-3.5"}),"Browse skill-packs"]})]})}function Ie({member:s}){var n;const t=((n=s.agent)==null?void 0:n.projectPath)??null;return t===null?e.jsx("p",{className:"text-muted-foreground text-sm",children:"This agent’s folder isn’t known here."}):e.jsx(Fe,{projectPath:t})}export{Ie as SkillsPage};
1
+ import{ae as b,aj as z,hc as p,hd as g,af as w,ag as $,cT as M,an as I,j as e,r as d,di as O,Z as N,B as j,aw as q,dG as y,dj as C,gb as K,gc as W,gd as Q,ge as U,gf as G,gg as Y,gh as J,gi as Z,h as H,l as E,e5 as V,ad as X,e as A,e8 as ee,he as R,aa as L}from"./index-C63bLSO4.js";import{B as P}from"./banner-Dh5mO27l.js";import{P as T}from"./package-DE8sQpId.js";function D(s){const t=b();return z({queryKey:p.status(s),queryFn:()=>t.getHarnessStatus(s),staleTime:3e4,refetchOnMount:"always"})}const se={native:"reads it",projected:"shared",drifted:"out of date",dropped:"can’t see it",warned:"may not work",conflict:"blocked","pending-approval":"needs your OK"},te={native:"neutral",projected:"neutral",drifted:"info",dropped:"muted",warned:"warning",conflict:"warning","pending-approval":"warning"},k="\0",ne=new Set(["native","projected"]);function _(s){return`${s.scope??"project"}${k}${s.artifact}${k}${s.source??""}${k}${s.name}`}function ae(s,t){return`${g[s]} ${se[t]}`}function re(s){return s.reason??s.target}function B(s,t){return t.flatMap(n=>{const a=s.cells[n];return a===void 0?[]:[{harness:n,cell:a}]})}function ie(s,t){if(t.length===0)return!1;const n=B(s,t);return n.length===t.length&&n.every(({cell:a})=>{var r;return ne.has(a.state)&&!((r=a.warnings)!=null&&r.length)})}function S(s){return`${s} ${s===1?"file":"files"}`}function le(s){return s===1?"One package is waiting for your approval.":`${s} packages are waiting for your approval.`}function oe(s){return`Shared with all ${s}`}function ce(s){return s===1?"1 agent file":`${s} agent files`}function de(s){return`Agent files ${s} can’t see: skills, rules, commands and more.`}function ue(s){return s===1?"1 entry":`${s} entries`}function xe(s,t){return t.flatMap(n=>{const a=s.flatMap(r=>{const i=r.cells[n];return i===void 0||i.state!=="dropped"?[]:[{key:_(r),artifact:r.artifact,name:r.name,...i.reason===void 0?{}:{reason:i.reason}}]});return a.length===0?[]:[{harness:n,label:g[n],entries:a}]})}const fe={drop:"Not shared",warning:"Couldn’t read",write:"Will be written",notice:"Notice"};function me(s){return`${fe[s.kind]} · ${s.artifact} ${s.name}`}function he(s){const t=b(),n=w();return $({mutationFn:()=>t.syncHarness(s),meta:{errorLabel:"Couldn’t share your agent files"},onSuccess:a=>{n.setQueryData(p.status(s),a.status),M.success("Agent files updated.")}})}function pe(s){const t=w();I("approval_resolved",()=>{t.invalidateQueries({queryKey:p.status(s)})})}function ge({result:s,onDismiss:t}){const{applied:n,removals:a,askedAbout:r}=s;return e.jsx(P,{variant:"neutral",onDismiss:t,dismissLabel:"Dismiss what changed","data-slot":"harness-sync-summary",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Agent files updated."}),n>0&&e.jsxs(e.Fragment,{children:[" ",S(n)," written."]})]}),a.length>0&&e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("p",{className:"font-medium",children:["Removed ",S(a.length)," DorkOS put here:"]}),e.jsx("ul",{className:"flex flex-col gap-0.5",children:a.map(({path:i,reason:c})=>e.jsxs("li",{className:"text-3xs flex flex-col",children:[e.jsx("code",{className:"font-mono",children:i}),e.jsx("span",{className:"opacity-80",children:c})]},i))})]}),r.length>0&&e.jsx("p",{children:le(r.length)})]})})}function je(s){const{counts:t,sweepPreview:n}=s;return t.drifted>0||n.length>0?{message:"Some agent files are out of date.",variant:n.length>0?"warning":"info",actionable:!0}:t.conflicts>0?{message:"DorkOS can’t update some files. Something blocks them.",variant:"warning",actionable:!1}:t.adoptable>0?{message:"Some skills only reach a few of your agents.",variant:"info",actionable:!1}:null}function ve({projectPath:s}){return pe(s),null}function Ne({projectPath:s}){const{data:t}=D(s),n=he(s),[a,r]=d.useState(!1),[i,c]=d.useState(!1);if(t===void 0||t.state!=="ready")return null;const u=e.jsx(ve,{projectPath:s});if(n.data!==void 0&&!i)return e.jsxs(e.Fragment,{children:[u,e.jsx(ge,{result:n.data,onDismiss:()=>c(!0)})]});const o=je(t);if(o===null)return u;const{removals:x,sweepPreview:m}=t,l=m.length;return e.jsxs(e.Fragment,{children:[u,e.jsx(P,{variant:o.variant,"data-slot":"harness-drift-banner",detailsOpen:a,details:l===0?void 0:e.jsx("ul",{className:"flex flex-col gap-0.5",children:x.map(({path:f,reason:v})=>e.jsxs("li",{className:"text-3xs flex flex-col",children:[e.jsx("code",{className:"font-mono",children:f}),e.jsx("span",{className:"opacity-80",children:v})]},f))}),actions:o.actionable?e.jsx(j,{size:"sm",variant:"outline",className:"h-6 text-xs",disabled:n.isPending,onClick:()=>{c(!1),n.mutate()},children:n.isPending?"Syncing…":"Sync now"}):void 0,children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("p",{children:o.message}),l>0&&e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>r(f=>!f),className:"text-3xs flex w-fit items-center gap-1 underline underline-offset-2 opacity-90 hover:opacity-100",children:["Syncing also removes ",S(l)," DorkOS put here",e.jsx(O,{"aria-hidden":!0,className:N("size-3 transition-transform",a&&"rotate-180")})]})]})})]})}function ye(s){const t=b(),n=w();return $({mutationFn:a=>t.adoptHarness(s,a),meta:{errorLabel:"Couldn’t move that skill"},onSuccess:a=>{n.setQueryData(p.status(s),a.status),n.setQueriesData({queryKey:p.all,predicate:r=>{var i;return((i=r.state.data)==null?void 0:i.projectPath)===a.status.projectPath}},a.status)}})}const ke={neutral:y.neutral,info:y.info,warning:y.warning,muted:"border border-dashed border-border text-muted-foreground"};function Se({harness:s,cell:t}){var i;const n=ae(s,t.state),a=re(t),r=(i=t.warnings)!=null&&i.length?t.warnings.join(" · "):void 0;return e.jsxs("li",{"aria-label":n,...a===void 0?{}:{title:a},className:N("text-3xs inline-flex items-center gap-1 rounded-full px-2 py-0.5 leading-tight",ke[te[t.state]]),children:[n,r!==void 0&&e.jsx("span",{role:"img","aria-label":"May not work",title:r,className:"inline-flex",children:e.jsx(q,{"aria-hidden":!0,className:"text-status-warning-fg size-2.5"})})]})}function be(s){const t=s===void 0?-1:s.lastIndexOf("/"),n=t>0?s==null?void 0:s.slice(0,t):void 0;return n===void 0?"Only some agents can see it. Move it to .agents/skills to share it.":`Lives in ${n}. Move it to .agents/skills to share it.`}function we(s,t){return`dorkos harness adopt ${s} --project ${t}`}const Ce="Share with every agent";function De(s,t,n){const a=`It moves from ${t} to .agents/skills/${s}`;return n?`${a}. A link stays behind for Claude Code.`:`${a}, where every agent reads it.`}const Ae="for all your projects";function $e({row:s,enabled:t,projectPath:n,showEveryHarness:a}){var v;const[r,i]=d.useState(!1),[c,u]=d.useState(!1),o=ye(n),x=B(s,t),m=ie(s,t)&&!a,l=m&&!r,f=(v=o.data)==null?void 0:v.refusals[0];return e.jsxs("div",{role:"group","aria-label":s.name,className:"flex flex-col gap-1 py-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx("span",{className:"min-w-0 shrink truncate text-xs font-medium",children:s.name}),s.scope==="global"&&e.jsx("span",{className:"text-muted-foreground text-3xs shrink-0",children:Ae}),s.source!==void 0&&e.jsx("span",{dir:"rtl",title:s.source,className:"text-muted-foreground text-3xs ml-auto min-w-0 truncate text-left font-mono",children:e.jsx("bdi",{dir:"ltr",children:s.source})})]}),e.jsxs("ul",{"aria-label":"Agent tools",className:"flex flex-wrap items-center gap-1",children:[m&&e.jsx("li",{children:e.jsxs("button",{type:"button","aria-expanded":!l,title:x.map(({harness:h})=>g[h]).join(" · "),onClick:()=>i(h=>!h),className:"bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground text-3xs focus-visible:ring-ring inline-flex items-center gap-1 rounded-full px-2 py-0.5 leading-tight transition-colors focus-visible:ring-2 focus-visible:outline-none",children:[oe(x.length),e.jsx(O,{"aria-hidden":!0,className:N("size-2.5 transition-transform",l&&"-rotate-90")})]})}),!l&&x.map(({harness:h,cell:F})=>e.jsx(Se,{harness:h,cell:F},h))]}),s.adoptable&&e.jsxs(e.Fragment,{children:[e.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground text-3xs",children:(f==null?void 0:f.reason)||be(s.source)}),e.jsxs("p",{className:"text-muted-foreground text-3xs",children:["Run: ",e.jsx(C,{children:we(s.name,n)})]}),e.jsx("div",{children:e.jsx(j,{size:"sm",variant:"outline",className:"h-6 text-xs",disabled:o.isPending,onClick:()=>u(!0),children:Ce})}),e.jsx(K,{open:c,onOpenChange:u,children:e.jsxs(W,{children:[e.jsxs(Q,{children:[e.jsxs(U,{children:["Move ",s.name," so every agent can read it?"]}),e.jsx(G,{children:De(s.name,s.source??"",t.includes("claude-code"))})]}),e.jsxs(Y,{children:[e.jsx(J,{children:"Cancel"}),e.jsx(Z,{onClick:()=>o.mutate(s.name),children:"Move it"})]})]})})]})]})}const Oe="https://dorkos.ai/docs/guides/cli-usage#agent-files";function He(){return e.jsxs(e.Fragment,{children:[e.jsx("span",{role:"status",className:"sr-only",children:"Loading skills…"}),e.jsx("div",{"aria-hidden":!0,className:"flex flex-col gap-3 py-1",children:[0,1,2].map(s=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(A,{className:"h-3 w-32"}),e.jsx(A,{className:"h-3 w-48"})]},s))})]})}function Ee({projectPath:s,showBrowseLink:t=!0}){const{data:n,isPending:a,error:r,refetch:i}=D(s),[c,u]=d.useState(!1),o=d.useId(),x=H();if(a)return e.jsx(He,{});if(r)return e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx("p",{className:"text-destructive text-xs",children:"Couldn’t load skills."}),e.jsx(j,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>void i(),children:"Retry"})]});if(n.state!=="ready")return e.jsx(Re,{status:n});const m=n.rows.filter(l=>l.artifact==="skill");return m.length===0?e.jsxs("div",{className:"flex flex-col items-start gap-1 py-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"No skills here yet."}),t&&x&&e.jsxs(j,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-6 px-1 text-xs",onClick:()=>void x({...E.marketplace(),search:{type:"skill-pack"}}),children:[e.jsx(T,{"aria-hidden":!0,className:"mr-1.5 size-3.5"}),"Browse skill-packs"]})]}):e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 pb-1",children:[e.jsx(V,{htmlFor:o,className:"text-muted-foreground text-3xs",children:"Show every agent tool"}),e.jsx(X,{id:o,size:"sm",checked:c,onCheckedChange:u})]}),e.jsx("div",{className:"divide-border divide-y",children:m.map(l=>e.jsx($e,{row:l,enabled:n.enabled,projectPath:n.projectPath,showEveryHarness:c},_(l)))})]})}function Re({status:s}){return s.state==="not-set-up"?e.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"DorkOS isn’t sharing agent files for this folder yet."}),e.jsxs("p",{className:"text-muted-foreground text-3xs",children:["Run ",e.jsx(C,{children:"dorkos harness sync --fix"})," in this folder to set it up."]}),e.jsx(ee,{href:Oe,className:"text-3xs text-muted-foreground hover:text-foreground underline underline-offset-2",children:"How agent file sharing works"})]}):s.state==="unreadable"?e.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"DorkOS can’t read this folder’s agent file settings."}),s.detail!==void 0&&e.jsx("p",{className:"text-muted-foreground text-3xs",children:s.detail})]}):e.jsx("p",{className:"text-muted-foreground py-2 text-xs",children:"Agent file sharing runs in the DorkOS app."})}function Le({group:s}){const[t,n]=d.useState(!1);return e.jsxs(R,{open:t,onOpenChange:n,trigger:e.jsxs("span",{className:"text-xs",children:["Not shared with ",s.label]}),badge:e.jsx(L,{variant:"secondary",size:"xs",className:"whitespace-nowrap",children:ce(s.entries.length)}),children:[e.jsx("p",{className:"text-muted-foreground text-3xs px-4 pt-3",children:de(s.label)}),e.jsx("ul",{className:"space-y-2 px-4 pt-2 pb-3",children:s.entries.map(a=>e.jsxs("li",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"text-3xs font-medium",children:[a.artifact," ",a.name]}),a.reason!==void 0&&e.jsx("span",{className:"text-muted-foreground text-3xs",children:a.reason})]},a.key))})]})}function Pe({rows:s,enabled:t}){const n=xe(s,t);return n.length===0?null:e.jsx("div",{className:"flex flex-col gap-1.5",children:n.map(a=>e.jsx(Le,{group:a},a.harness))})}function Te({entries:s}){const[t,n]=d.useState(!1);return s.length===0?null:e.jsx(R,{open:t,onOpenChange:n,trigger:e.jsx("span",{className:"text-xs",children:"Project-level notices"}),badge:e.jsx(L,{variant:"secondary",size:"xs",className:"whitespace-nowrap",children:ue(s.length)}),children:e.jsx("ul",{className:"space-y-2 px-4 pb-3",children:s.map(a=>e.jsxs("li",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:N("text-3xs font-medium",a.kind==="notice"&&"text-muted-foreground font-normal"),children:me(a)}),e.jsx("span",{className:"text-muted-foreground text-3xs",children:a.reason})]},`${a.kind} ${a.artifact} ${a.source??""} ${a.name}`))})})}function _e({command:s}){return e.jsx(C,{className:"break-normal",children:s.split(" ").map((t,n)=>e.jsxs(d.Fragment,{children:[n>0&&" ",e.jsx("span",{className:"whitespace-nowrap",children:t})]},`${n}-${t}`))})}function Be({notEnabled:s}){return s.length===0?null:e.jsx("div",{className:"flex flex-col gap-1.5 py-1",children:s.map(({harness:t,why:n,signal:a})=>e.jsxs("div",{title:a,className:"flex flex-col gap-0.5",children:[e.jsx("p",{className:"text-xs font-medium",children:n==="dorkos-runtime"?`DorkOS runs ${g[t]} here, but isn’t sharing to it.`:`${g[t]} files are here, but DorkOS isn’t sharing to it.`}),e.jsxs("p",{className:"text-muted-foreground text-3xs",children:["Run ",e.jsx(_e,{command:`dorkos harness sync --fix --enable ${t}`})," in this folder to turn it on."]})]},t))})}function Fe({projectPath:s}){const t=H(),{data:n}=D(s),a=(n==null?void 0:n.state)==="ready"?n:null;return e.jsxs("div",{className:"flex flex-col gap-2","data-slot":"profile-skills",children:[e.jsx(Ne,{projectPath:s}),a&&e.jsx(Be,{notEnabled:a.notEnabled}),e.jsx(Ee,{projectPath:s,showBrowseLink:!1}),a&&e.jsx(Pe,{rows:a.rows,enabled:a.enabled}),a&&e.jsx(Te,{entries:a.projectLevel}),t&&e.jsxs(j,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground w-full",onClick:()=>void t({...E.marketplace(),search:{type:"skill-pack"}}),children:[e.jsx(T,{"aria-hidden":!0,className:"mr-1.5 size-3.5"}),"Browse skill-packs"]})]})}function qe({member:s}){var n;const t=((n=s.agent)==null?void 0:n.projectPath)??null;return t===null?e.jsx("p",{className:"text-muted-foreground text-sm",children:"This agent’s folder isn’t known here."}):e.jsx(Fe,{projectPath:t})}export{qe as SkillsPage};
@@ -1 +1 @@
1
- import{aR as F,aN as w,aS as U,aT as D,aU as L,aV as $,aW as X,r as o,j as e,aX as _,aY as p,aZ as f,a_ as j,a$ as g,b0 as k,F as E,b1 as N,b2 as B,b3 as G,b4 as O,b5 as P,b6 as V,b7 as W,b8 as Y}from"./index-Dr-0P6rd.js";import{S as Z}from"./scroll-area-XlDz8u4m.js";const q=5;function H({status:t}){switch(t){case"running":return e.jsx(E,{size:"xs",className:"text-status-info shrink-0"});case"completed":return e.jsx(W,{className:"text-status-success size-3 shrink-0","aria-hidden":!0});case"failed":return e.jsx(V,{className:"text-destructive size-3 shrink-0","aria-hidden":!0});case"cancelled":return e.jsx(P,{className:"text-muted-foreground size-3 shrink-0","aria-hidden":!0});case"skipped":return e.jsx(O,{className:"text-muted-foreground size-3 shrink-0","aria-hidden":!0});case"blocked":return e.jsx(G,{className:"text-status-warning-dot size-3 shrink-0","aria-hidden":!0});default:return null}}function J(t){if(t===null)return"";if(t<1e3)return"< 1s";const n=Math.floor(t/1e3);if(n<60)return`${n}s`;const a=Math.floor(n/60),i=n%60;return`${a}m ${i}s`}function K({run:t,scheduleName:n}){return e.jsx(g,{children:e.jsxs(k,{className:"text-sm",children:[e.jsx(E,{size:"xs",className:"text-status-info shrink-0"}),e.jsx("span",{className:"truncate",children:n}),t.startedAt&&e.jsx("span",{className:"text-muted-foreground/50 ml-auto shrink-0 text-xs",children:N(t.startedAt)})]})})}function Q({schedule:t,onEdit:n}){return e.jsx(g,{children:e.jsxs(k,{onClick:()=>n(t.id),className:"text-sm",children:[e.jsx(B,{className:"text-muted-foreground/50 size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:t.name}),t.nextRun&&e.jsx("span",{className:"text-muted-foreground/50 ml-auto shrink-0 text-xs",children:N(t.nextRun)})]})})}function ee({run:t,scheduleName:n}){const a=t.status==="running"&&t.finishedAt?t.error?"failed":"completed":t.status;return e.jsx(g,{children:e.jsxs(k,{className:"text-sm",children:[e.jsx(H,{status:a}),e.jsx("span",{className:"truncate",children:n}),e.jsxs("span",{className:"text-muted-foreground/50 ml-auto flex shrink-0 items-center gap-1.5 text-xs",children:[t.durationMs!==null&&e.jsx("span",{children:J(t.durationMs)}),t.finishedAt&&e.jsx("span",{children:N(t.finishedAt)})]})]})})}function se({available:t,agentId:n}){const a=F(),i=w(s=>s.setTasksAgentFilter),R=w(s=>s.setTasksEditScheduleId),u=t,{data:x=[]}=U(u),{data:I=0}=D(u),{data:b=[]}=L(void 0,u),{data:T=[]}=$(),{openWithTemplate:y}=X(),S=[T[0],T[2]].filter(Boolean),l=o.useMemo(()=>n?x.filter(s=>s.agentId===n):x,[n,x]),d=o.useMemo(()=>{const s=new Map;for(const r of l)s.set(r.id,r.name);return s},[l]),v=o.useMemo(()=>b.filter(s=>d.has(s.scheduleId)),[b,d]),{runningRuns:A,recentRuns:M}=o.useMemo(()=>{const s=[],r=[];for(const c of v)c.finishedAt!=null||c.status!=="running"?r.push(c):s.push(c);return r.sort((c,h)=>(h.finishedAt??h.createdAt).localeCompare(c.finishedAt??c.createdAt)),{runningRuns:s,recentRuns:r.slice(0,q)}},[v]),C=o.useMemo(()=>l.filter(s=>s.enabled&&s.status==="active"&&s.nextRun).sort((s,r)=>(s.nextRun??"").localeCompare(r.nextRun??"")),[l]),m=()=>{n&&(i(n),R(null)),a.open()},z=s=>{R(s),i(null),a.open()};return l.length===0?e.jsxs("div",{className:"flex flex-col gap-3 px-3 py-4",children:[e.jsx("p",{className:"text-muted-foreground/70 text-xs",children:"No schedules yet."}),S.length>0&&e.jsx("div",{className:"space-y-2",children:S.map(s=>e.jsxs("div",{className:"rounded-lg border p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsx("p",{className:"text-muted-foreground text-xs",children:_(s.cron)}),e.jsx("button",{type:"button",onClick:()=>{y(s),m()},className:"text-primary mt-2 text-xs hover:underline",children:"+ Use preset"})]},s.id))}),e.jsx("button",{onClick:m,className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:"Open schedules →"})]}):e.jsx(Z,{type:"scroll",className:"h-full",children:e.jsxs("div",{className:"pr-1",children:[A.length>0&&e.jsxs(p,{children:[e.jsxs(f,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:["Running",e.jsx("span",{className:"text-muted-foreground/50 ml-auto text-xs font-normal normal-case",children:I})]}),e.jsx(j,{children:A.map(s=>e.jsx(K,{run:s,scheduleName:d.get(s.scheduleId)??"Unknown"},s.id))})]}),C.length>0&&e.jsxs(p,{children:[e.jsx(f,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Upcoming"}),e.jsx(j,{children:C.map(s=>e.jsx(Q,{schedule:s,onEdit:z},s.id))})]}),M.length>0&&e.jsxs(p,{children:[e.jsx(f,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Recent runs"}),e.jsx(j,{children:M.map(s=>e.jsx(ee,{run:s,scheduleName:d.get(s.scheduleId)??"Unknown"},s.id))})]}),e.jsx("div",{className:"px-3 py-2",children:e.jsx("button",{onClick:m,className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:"Open schedules →"})})]})})}function ae({member:t}){var i;const n=Y(),a=((i=t.agent)==null?void 0:i.manifestId)??null;return e.jsx("div",{className:"min-h-0 flex-1","data-slot":"profile-tasks",children:e.jsx(se,{available:n,agentId:a})})}export{ae as TasksPage};
1
+ import{aU as F,aQ as w,aV as U,aW as D,aX as L,aY as $,aZ as X,r as o,j as e,a_ as _,a$ as p,b0 as f,b1 as j,b2 as g,b3 as k,F as E,b4 as N,b5 as B,b6 as G,b7 as O,b8 as P,b9 as V,ba as W,bb as Q}from"./index-C63bLSO4.js";import{S as Y}from"./scroll-area-DW0-Liri.js";const Z=5;function q({status:t}){switch(t){case"running":return e.jsx(E,{size:"xs",className:"text-status-info shrink-0"});case"completed":return e.jsx(W,{className:"text-status-success size-3 shrink-0","aria-hidden":!0});case"failed":return e.jsx(V,{className:"text-destructive size-3 shrink-0","aria-hidden":!0});case"cancelled":return e.jsx(P,{className:"text-muted-foreground size-3 shrink-0","aria-hidden":!0});case"skipped":return e.jsx(O,{className:"text-muted-foreground size-3 shrink-0","aria-hidden":!0});case"blocked":return e.jsx(G,{className:"text-status-warning-dot size-3 shrink-0","aria-hidden":!0});default:return null}}function H(t){if(t===null)return"";if(t<1e3)return"< 1s";const n=Math.floor(t/1e3);if(n<60)return`${n}s`;const a=Math.floor(n/60),i=n%60;return`${a}m ${i}s`}function J({run:t,scheduleName:n}){return e.jsx(g,{children:e.jsxs(k,{className:"text-sm",children:[e.jsx(E,{size:"xs",className:"text-status-info shrink-0"}),e.jsx("span",{className:"truncate",children:n}),t.startedAt&&e.jsx("span",{className:"text-muted-foreground/50 ml-auto shrink-0 text-xs",children:N(t.startedAt)})]})})}function K({schedule:t,onEdit:n}){return e.jsx(g,{children:e.jsxs(k,{onClick:()=>n(t.id),className:"text-sm",children:[e.jsx(B,{className:"text-muted-foreground/50 size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:t.name}),t.nextRun&&e.jsx("span",{className:"text-muted-foreground/50 ml-auto shrink-0 text-xs",children:N(t.nextRun)})]})})}function ee({run:t,scheduleName:n}){const a=t.status==="running"&&t.finishedAt?t.error?"failed":"completed":t.status;return e.jsx(g,{children:e.jsxs(k,{className:"text-sm",children:[e.jsx(q,{status:a}),e.jsx("span",{className:"truncate",children:n}),e.jsxs("span",{className:"text-muted-foreground/50 ml-auto flex shrink-0 items-center gap-1.5 text-xs",children:[t.durationMs!==null&&e.jsx("span",{children:H(t.durationMs)}),t.finishedAt&&e.jsx("span",{children:N(t.finishedAt)})]})]})})}function se({available:t,agentId:n}){const a=F(),i=w(s=>s.setTasksAgentFilter),b=w(s=>s.setTasksEditScheduleId),u=t,{data:x=[]}=U(u),{data:I=0}=D(u),{data:R=[]}=L(void 0,u),{data:T=[]}=$(),{openWithTemplate:y}=X(),S=[T[0],T[2]].filter(Boolean),l=o.useMemo(()=>n?x.filter(s=>s.agentId===n):x,[n,x]),d=o.useMemo(()=>{const s=new Map;for(const r of l)s.set(r.id,r.name);return s},[l]),v=o.useMemo(()=>R.filter(s=>d.has(s.scheduleId)),[R,d]),{runningRuns:A,recentRuns:M}=o.useMemo(()=>{const s=[],r=[];for(const c of v)c.finishedAt!=null||c.status!=="running"?r.push(c):s.push(c);return r.sort((c,h)=>(h.finishedAt??h.createdAt).localeCompare(c.finishedAt??c.createdAt)),{runningRuns:s,recentRuns:r.slice(0,Z)}},[v]),C=o.useMemo(()=>l.filter(s=>s.enabled&&s.status==="active"&&s.nextRun).sort((s,r)=>(s.nextRun??"").localeCompare(r.nextRun??"")),[l]),m=()=>{n&&(i(n),b(null)),a.open()},z=s=>{b(s),i(null),a.open()};return l.length===0?e.jsxs("div",{className:"flex flex-col gap-3 px-3 py-4",children:[e.jsx("p",{className:"text-muted-foreground/70 text-xs",children:"No schedules yet."}),S.length>0&&e.jsx("div",{className:"space-y-2",children:S.map(s=>e.jsxs("div",{className:"rounded-lg border p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsx("p",{className:"text-muted-foreground text-xs",children:_(s.cron)}),e.jsx("button",{type:"button",onClick:()=>{y(s),m()},className:"text-primary mt-2 text-xs hover:underline",children:"+ Use preset"})]},s.id))}),e.jsx("button",{onClick:m,className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:"Open schedules →"})]}):e.jsx(Y,{type:"scroll",className:"h-full",children:e.jsxs("div",{className:"pr-1",children:[A.length>0&&e.jsxs(p,{children:[e.jsxs(f,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:["Running",e.jsx("span",{className:"text-muted-foreground/50 ml-auto text-xs font-normal normal-case",children:I})]}),e.jsx(j,{children:A.map(s=>e.jsx(J,{run:s,scheduleName:d.get(s.scheduleId)??"Unknown"},s.id))})]}),C.length>0&&e.jsxs(p,{children:[e.jsx(f,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Upcoming"}),e.jsx(j,{children:C.map(s=>e.jsx(K,{schedule:s,onEdit:z},s.id))})]}),M.length>0&&e.jsxs(p,{children:[e.jsx(f,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Recent runs"}),e.jsx(j,{children:M.map(s=>e.jsx(ee,{run:s,scheduleName:d.get(s.scheduleId)??"Unknown"},s.id))})]}),e.jsx("div",{className:"px-3 py-2",children:e.jsx("button",{onClick:m,className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:"Open schedules →"})})]})})}function ae({member:t}){var i;const n=Q(),a=((i=t.agent)==null?void 0:i.manifestId)??null;return e.jsx("div",{className:"min-h-0 flex-1","data-slot":"profile-tasks",children:e.jsx(se,{available:n,agentId:a})})}export{ae as TasksPage};
@@ -1,2 +1,2 @@
1
- import{ae as W,aj as Fe,ag as se,af as he,e2 as De,r as l,j as n,cw as F,cx as D,B as f,f as pe,h4 as te,e3 as _,I as G,dY as _e,dZ as Le,d_ as $e,d$ as Ke,e0 as Be,gJ as ce,bX as Ue,fo as Ve,C as X,Z as le,ao as ae,cr as fe,cs as xe,aa as qe,ct as je,bY as L,e5 as Ye,h5 as de,F as ee,fI as He,fJ as Ge,fK as Qe,fL as We,fM as J,fO as Ze,ad as Je,h6 as Xe,g$ as en,h7 as nn,h8 as sn,G as tn,e as ne,h9 as an,b as rn}from"./index-Dr-0P6rd.js";import{a as on}from"./agent-browser-Cs8abkZs.js";import{u as ve,M as Ne}from"./McpSigninBody-DoY09n4J.js";import{R as cn}from"./rotate-cw-DrGRGSwy.js";function ln(e,s){const t=W();return Fe({queryKey:["mcp-config",e,s??null],queryFn:()=>t.getMcpConfig(e,{runtime:s??void 0}),enabled:!!e,staleTime:3e4})}function be(e,s){e.invalidateQueries({queryKey:De.mcpServers(s)}),e.invalidateQueries({queryKey:["mcp-config"]})}function Se(e){const s=W(),t=he();return se({mutationFn:async({input:i,approval:a})=>a?(await s.grantApproval(a.approvalId),e(s,i,a.approvalToken)):e(s,i),onSuccess:(i,{input:a})=>{i.status==="ok"&&be(t,a.agentId)}})}function ye(){return Se((e,s,t)=>e.addAgentMcpServer(s,t?{approvalToken:t}:void 0))}function dn(){return Se((e,s,t)=>e.importAgentMcpServer(s,t?{approvalToken:t}:void 0))}function re(e){const s=W(),t=he();return se({mutationFn:({agentId:i,name:a})=>e(s,i,a),onSuccess:(i,{agentId:a})=>be(t,a)})}function un(){return re((e,s,t)=>e.removeAgentMcpServer(s,t))}function mn(){return re((e,s,t)=>e.enableAgentMcpServer(s,t))}function gn(){return re((e,s,t)=>e.disableAgentMcpServer(s,t))}function hn(){const e=W();return se({mutationFn:({agentId:s,name:t})=>e.testAgentMcpServer(s,t)})}function pn({agentId:e,serverName:s,onDone:t}){const i=ve(e,s),{start:a}=i,r=l.useRef(!1);return l.useEffect(()=>{r.current||(r.current=!0,a())},[a]),n.jsx(F,{children:n.jsxs(D,{className:"space-y-2",children:[n.jsxs("p",{className:"text-sm font-medium",children:["Sign in to ",s]}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Sign in so your agent can use this server."}),n.jsx(Ne,{flow:i,serverName:s,failedActions:n.jsxs(n.Fragment,{children:[n.jsx(f,{variant:"secondary",size:"sm",onClick:()=>i.start(),className:"focus-visible:ring-2",children:"Try again"}),n.jsx(f,{variant:"ghost",size:"sm",onClick:t,className:"focus-visible:ring-2",children:"Later"})]}),connectedActions:n.jsx(f,{variant:"ghost",size:"sm",onClick:t,className:"focus-visible:ring-2",children:"Done"})}),i.state.step!=="failed"&&i.state.step!=="connected"&&n.jsx(f,{variant:"ghost",size:"sm",onClick:t,className:"focus-visible:ring-2",children:"Later"})]})})}const fn=["stdio","http","sse"],xn=/^[a-zA-Z0-9_-]+$/;function ue(e){const s={};for(const t of e.split(`
2
- `)){const i=t.trim();if(!i)continue;const a=i.indexOf("=");if(a===-1)continue;const r=i.slice(0,a).trim();r&&(s[r]=i.slice(a+1).trim())}return s}function me(e){return e.trim().length?e.trim().split(/\s+/):[]}function jn(e,s){if(e.status!=="ok")return!1;const t=e.servers.find(a=>a.name===s),i=t==null?void 0:t.connection;return i!==void 0&&"authKind"in i&&i.authKind==="oauth2"}function vn({agentId:e,agentLabel:s,supportedTransports:t,onAdded:i,oauthDetectedFor:a=null}){const r=ye(),[c,u]=l.useState(!1),[g,x]=l.useState(""),[p,m]=l.useState(t[0]??"stdio"),o=t.includes(p)?p:t[0]??"stdio",[j,C]=l.useState(""),[b,k]=l.useState(""),[v,z]=l.useState(""),[y,M]=l.useState(""),[P,A]=l.useState(""),[O,R]=l.useState(null),[T,I]=l.useState(null),[Z,U]=l.useState(null),[K,V]=l.useState(null),B=xn.test(g)&&g.length<=64,q=o==="stdio"?j.trim().length>0:y.trim().length>0,d=B&&q&&!r.isPending,N=l.useCallback(()=>o==="stdio"?{transport:"stdio",command:j.trim(),args:me(b),env:ue(v)}:{transport:o,url:y.trim(),headers:ue(P)},[o,j,b,v,y,P]),w=l.useCallback(()=>({agentId:e,name:g.trim(),connection:N()}),[e,g,N]),E=l.useCallback(()=>{u(!1),R(null),I(null),x(""),m(t[0]??"stdio"),C(""),k(""),z(""),M(""),A("")},[t]),oe=l.useCallback(h=>{i({name:h.name,transport:h.connection.transport}),E()},[i,E]),Y=l.useCallback((h,S)=>{const Ie=jn(h,S.name);oe(S),Ie&&U(S.name)},[oe]),Ee=l.useCallback(async()=>{I(null);const h=w();try{const S=await r.mutateAsync({input:h});S.status==="approval_required"?R(S.approval):Y(S,h)}catch(S){I(S instanceof Error?S.message:"Couldn’t add the server.")}},[r,w,Y]),ze=l.useCallback(async()=>{if(!O)return;I(null);const h=w();try{const S=await r.mutateAsync({input:h,approval:O});S.status==="ok"?Y(S,h):I("The server still needs approval. Try again.")}catch(S){I(S instanceof Error?S.message:"Couldn’t add the server.")}},[r,w,O,Y]),H=Z??(a&&a!==K?a:null),Pe=l.useCallback(()=>{V(H),U(null)},[H]),Re=l.useMemo(()=>[j.trim(),...me(b)].filter(Boolean).join(" "),[j,b]);return H?n.jsx(pn,{agentId:e,serverName:H,onDone:Pe}):c?O?n.jsx(F,{children:n.jsxs(D,{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(te,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("p",{className:"text-sm font-medium",children:["Add this server to ",s,"?"]}),n.jsx("p",{className:"text-muted-foreground text-xs",children:o==="stdio"?"Runs on this computer when a chat starts.":"The agent connects here when a chat starts."})]})]}),n.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded-md px-3 py-2 font-mono text-xs",children:o==="stdio"?Re:y.trim()}),T&&n.jsx("p",{className:"text-destructive text-xs",children:T}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>R(null),disabled:r.isPending,className:"focus-visible:ring-2",children:"Back"}),n.jsx(f,{size:"sm",onClick:ze,disabled:r.isPending,className:"focus-visible:ring-2",children:r.isPending?"Adding…":"Add server"})]})]})}):n.jsx(F,{children:n.jsxs(D,{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-name",children:"Name"}),n.jsx(G,{id:"mcp-name",value:g,onChange:h=>x(h.target.value),placeholder:"my-server","aria-invalid":g.length>0&&!B}),g.length>0&&!B&&n.jsx("p",{className:"text-destructive text-xs",children:"Letters, numbers, dashes, underscores only."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-transport",children:"Transport"}),n.jsxs(_e,{value:o,onValueChange:h=>m(h),children:[n.jsx(Le,{id:"mcp-transport",className:"w-full",children:n.jsx($e,{})}),n.jsx(Ke,{children:t.map(h=>n.jsx(Be,{value:h,children:h},h))})]})]}),o==="stdio"?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-command",children:"Command"}),n.jsx(G,{id:"mcp-command",value:j,onChange:h=>C(h.target.value),placeholder:"npx",className:"font-mono"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-args",children:"Arguments"}),n.jsx(G,{id:"mcp-args",value:b,onChange:h=>k(h.target.value),placeholder:"-y @modelcontextprotocol/server-filesystem",className:"font-mono"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-env",children:"Environment (KEY=VALUE per line)"}),n.jsx(ce,{id:"mcp-env",value:v,onChange:h=>z(h.target.value),placeholder:"API_KEY=…",rows:2,className:"font-mono text-xs"})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-url",children:"URL"}),n.jsx(G,{id:"mcp-url",value:y,onChange:h=>M(h.target.value),placeholder:"https://example.com/mcp",className:"font-mono"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-headers",children:"Headers (KEY=VALUE per line)"}),n.jsx(ce,{id:"mcp-headers",value:P,onChange:h=>A(h.target.value),placeholder:"Authorization=Bearer …",rows:2,className:"font-mono text-xs"})]})]}),T&&n.jsx("p",{className:"text-destructive text-xs",children:T}),n.jsx(Ue,{}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(f,{variant:"ghost",size:"sm",onClick:E,className:"focus-visible:ring-2",children:"Cancel"}),n.jsx(f,{size:"sm",onClick:Ee,disabled:!d,className:"focus-visible:ring-2",children:"Continue"})]})]})}):n.jsxs(f,{variant:"outline",size:"sm",onClick:()=>u(!0),className:"focus-visible:ring-2",children:[n.jsx(pe,{className:"size-4"}),"Add server"]})}const Nn={connected:"connected","needs-auth":"needs-sign-in",pending:"connecting",disabled:"off"},bn=["validation","invalid config","invalid configuration","missing required","command not found","enoent"];function ie(e){if(!e)return"cant-reach";const s=e.toLowerCase();return bn.some(t=>s.includes(t))?"setup-problem":"cant-reach"}function Ce(e){return e.transport==="stdio"||e.authKind==="oauth2"?!1:Object.keys(e.headers).some(s=>s.toLowerCase()==="authorization")}function Sn(e){const{connection:s,authStatus:t}=e;return s.transport!=="stdio"&&s.authKind==="oauth2"?!0:t!==void 0}function we(e){const{enabled:s,testedOk:t,signedInNow:i,runtimeStatus:a,runtimeError:r,authStatus:c,ownKey:u}=e;return s?t?"connected":i?"signed-in":a==="failed"?ie(r):c==="connected"&&a==="needs-auth"?"signed-in":c==="needs-auth"&&(a==="connected"||a==="pending")?"needs-sign-in":a?Nn[a]:c==="connected"?"signed-in":c==="needs-auth"?"needs-sign-in":u?"uses-your-key":"not-checked":"off"}function yn(e){const{statusKey:s,testResult:t,signedInNow:i}=e;return s==="off"||i?!1:(t==null?void 0:t.needsAuth)===!0?!0:s==="needs-sign-in"}function Cn(e){const{stamped:s,signedInNow:t,authStatus:i,rosterUpdatedAt:a}=e;if(!s)return;const{result:r}=s;if(!(t&&r.needsAuth===!0)&&!(s.at<=a&&(i==="needs-auth"&&r.ok||i==="connected"&&r.needsAuth===!0)))return r}function wn(e){const{status:s,probe:t}=e;return s==="off"||!t||t.ok?s:t.needsAuth===!0?"needs-sign-in":ie(t.error)}const Q={attention:0,working:1,elsewhere:2,off:3};function kn(e){return e==="off"?Q.off:e==="needs-sign-in"||e==="cant-reach"||e==="setup-problem"?Q.attention:Q.working}function An(e){const{managed:s,live:t,discovered:i}=e;return[...s.map(r=>{var c,u;return{name:r.name,band:kn(we({enabled:r.enabled,testedOk:!1,signedInNow:!1,runtimeStatus:(c=t.get(r.name))==null?void 0:c.status,runtimeError:(u=t.get(r.name))==null?void 0:u.error,authStatus:r.authStatus,ownKey:Ce(r.connection)}))}}),...i.map(r=>({name:r.name,band:Q.elsewhere}))].map((r,c)=>({entry:r,index:c})).sort((r,c)=>r.entry.band-c.entry.band||r.index-c.index).map(({entry:r})=>r.name)}function Tn(e){const{frozen:s,present:t}=e,i=new Set(t),a=new Set(s);return{ordered:s.filter(r=>i.has(r)),added:t.filter(r=>!a.has(r))}}function Mn(){const e=Ve(null);return({bothSettled:s,managed:t,live:i,discovered:a,present:r})=>{e.read()===null&&s&&r.length>0&&e.write(An({managed:t,live:i,discovered:a}));const{ordered:c,added:u}=Tn({frozen:e.read()??[],present:r});return u.length>0&&e.read()!==null&&e.write([...c,...u]),[...c,...u]}}const ke={"needs-sign-in":{label:"Needs sign-in",tooltip:"Sign in to use it.",tone:"attention"},"signing-in":{label:"Signing in…",tooltip:"Finish in the new tab.",tone:"attention"},connected:{label:"Connected",tooltip:"It answered. Its tools are ready.",tone:"calm"},"signed-in":{label:"Signed in",tooltip:"Signed in, not tested yet.",tone:"calm"},"uses-your-key":{label:"Uses your key",tooltip:"Uses a key you added.",tone:"calm"},"cant-reach":{label:"Can’t reach",tooltip:"No answer. See Details.",tone:"error"},"setup-problem":{label:"Setup problem",tooltip:"Couldn’t start. See Details.",tone:"error"},connecting:{label:"Connecting…",tooltip:"Connecting to this server.",tone:"calm"},"not-checked":{label:"Not checked yet",tooltip:"Nothing has checked it yet.",tone:"calm"},off:{label:"Off",tooltip:"Hidden from the agent.",tone:"calm"}},On={"needs-sign-in":"sign-in","signing-in":"none",connected:"none","signed-in":"test","uses-your-key":"test","cant-reach":"try-again","setup-problem":"try-again",connecting:"none","not-checked":"test",off:"none"};function En(e){return On[e]}function zn({toolCount:e,justSignedIn:s}){const t=s?"Signed in just now. ":"";return e===null?`${t||"This server answered. "}Its tools are available.`:`${t}${e} tool${e===1?"":"s"} available.`}function Pn(e,s){switch(e){case"needs-sign-in":return`Sign in to ${s.displayName} to use its tools.`;case"signing-in":return null;case"connected":return zn(s);case"signed-in":return s.justSignedIn?"Signed in just now. Test to check it answers.":"Signed in. Test to check it answers.";case"uses-your-key":return"You added an access key when setting this up.";case"cant-reach":return"This server didn’t answer. It may be down.";case"setup-problem":return"This server’s setup has a problem.";case"connecting":return"Connecting to this server.";case"not-checked":return"Nothing has checked this server yet.";case"off":return"Turned off. The agent doesn’t see this server."}}function Rn(e){const{connection:s,authStatus:t,clientOrigin:i}=e;return s.transport==="stdio"?"None. This server doesn’t need one.":s.authKind==="oauth2"?i==="manual"?`Your own app credentials, ${t==="connected"?"signed in, renews automatically":"not signed in yet"}. DorkOS holds the key, not the agent.`:t==="connected"?"Signed in, and it renews automatically. DorkOS holds the key, not the agent.":"DorkOS will hold the key, not the agent.":Object.keys(s.headers).some(r=>r.toLowerCase()==="authorization")?"Access key: you added a key when setting this up.":t===void 0?"Nothing has checked this yet.":"None. This server doesn’t need one."}function In(e){if(e.transport==="stdio")return`Runs \`${e.command}\` on this computer`;const s=Fn(e.url);return s?`${s} (web service)`:`${e.url} (web service)`}function Fn(e){try{return new URL(e).host}catch{return null}}const Dn={agent:"Added to this agent through DorkOS",project:"From this project’s config files",plugin:"Comes with a plugin",computer:"From your computer-wide config"},_n={agent:"Added to this agent through DorkOS.",project:"From this project’s config. Add it to manage it here.",plugin:"Comes with a plugin. Add it to manage it here.",computer:"From your computer-wide config. Add it to manage it here."},Ln=[{runtime:"claude-code",pattern:/^plugin:([^:]+):(.+)$/,read:e=>({pluginName:e[1],displayName:e[2]})},{runtime:"claude-code",pattern:/^plugin:(.+)$/,read:e=>({pluginName:e[1],displayName:e[1]})}];function Ae(e){for(const s of Ln){const t=e.match(s.pattern);if(!t)continue;const{displayName:i,pluginName:a}=s.read(t);if(!(!i||!a))return{displayName:i,pluginName:a,rawName:e}}return{displayName:e,pluginName:null,rawName:e}}function $n(e,s){return s.pluginName?"plugin":e.scope==="project"||e.scope==="local"?"project":e.scope==="user"?"computer":null}const Kn="Loaded from outside DorkOS. Add it to manage it here.";function Te(e,s){return e==="plugin"&&s?`Comes with the ${s} plugin`:Dn[e]}function Bn(e,s){return e===null?Kn:e==="plugin"&&s?`Comes with the ${s} plugin. Add it to manage it here.`:_n[e]}const Un=ae("border-border/60 relative overflow-hidden rounded-md border px-3 py-2.5 transition-colors",{variants:{managed:{true:"bg-card",false:"bg-muted/30"},dimmed:{true:"opacity-65",false:""}},defaultVariants:{managed:!0,dimmed:!1}}),Vn=ae("pointer-events-none absolute inset-y-0 left-0 w-0.5",{variants:{tone:{calm:"hidden",attention:"bg-status-warning",error:"bg-status-error"}},defaultVariants:{tone:"calm"}}),qn=ae("shrink-0 rounded-full px-2 py-0.5 text-2xs leading-4 font-medium whitespace-nowrap",{variants:{chip:{success:"bg-status-success-bg text-status-success-fg",info:"bg-status-info-bg text-status-info-fg",warning:"bg-status-warning-bg text-status-warning-fg",error:"bg-status-error-bg text-status-error-fg",neutral:"bg-muted text-muted-foreground"}},defaultVariants:{chip:"neutral"}}),Yn={connected:"success","signed-in":"info","needs-sign-in":"warning","signing-in":"warning","cant-reach":"error","setup-problem":"error","uses-your-key":"neutral",connecting:"neutral","not-checked":"neutral",off:"neutral"};function Hn({status:e}){const s=ke[e];return n.jsxs(fe,{children:[n.jsx(xe,{asChild:!0,children:n.jsx("span",{className:qn({chip:Yn[e]}),children:s.label})}),n.jsx(je,{children:s.tooltip})]})}function Gn({scope:e,pluginName:s}){return n.jsxs(fe,{children:[n.jsx(xe,{asChild:!0,children:n.jsx(qe,{size:"xs",tone:"neutral",variant:"secondary",className:"shrink-0 font-normal",children:e})}),n.jsx(je,{children:Te(e,s)})]})}function Me({displayName:e,rawName:s,scope:t,pluginName:i,status:a,sentence:r,managed:c,toggle:u,actions:g,children:x,details:p,defaultDetailsOpen:m=!1}){const[o,j]=l.useState(m),C=l.useId(),b=ke[a].tone;return n.jsxs("div",{"data-mcp-server":s,className:le(Un({managed:c,dimmed:a==="off"}),"mb-2 last:mb-0"),children:[n.jsx("span",{className:Vn({tone:b}),"aria-hidden":!0}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e}),t&&n.jsx(Gn,{scope:t,pluginName:i}),n.jsx(Hn,{status:a}),u]}),r&&n.jsx("p",{className:"text-muted-foreground mt-1 text-xs leading-relaxed",children:r}),x,g&&n.jsx("div",{className:"mt-2 flex items-center gap-1",children:g}),p&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",onClick:()=>j(k=>!k),"aria-expanded":o,"aria-controls":C,className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs focus-visible:ring-2",children:[n.jsx(X,{className:le("size-3 transition-transform",o&&"rotate-90"),"aria-hidden":!0}),"Details"]}),o&&n.jsxs("div",{id:C,children:[p,n.jsxs("button",{type:"button",onClick:()=>j(!1),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs focus-visible:ring-2",children:[n.jsx(X,{className:"size-3 -rotate-90","aria-hidden":!0}),"Collapse details"]})]})]})]})}const Qn=3,$="text-muted-foreground/70";function Wn({tools:e}){const[s,t]=l.useState(!1),i=s?e:e.slice(0,Qn),a=e.length-i.length;return n.jsxs("div",{className:"mt-1.5",children:[i.map(r=>n.jsxs("div",{className:"border-border/40 flex items-baseline gap-2 border-b py-1 last:border-b-0",children:[n.jsx("code",{className:"text-foreground text-2xs shrink-0 font-mono",children:r.name}),r.description&&n.jsx("span",{className:"text-muted-foreground text-2xs truncate",children:r.description})]},r.name)),a>0&&n.jsxs("button",{type:"button",onClick:()=>t(!0),className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs focus-visible:ring-2",children:[n.jsx(X,{className:"size-3","aria-hidden":!0}),"Show ",a," more"]})]})}function Zn(e){const{scope:s,pluginName:t,connection:i}=e;return s==="plugin"&&t?`Comes with the ${t} plugin`:i?In(i):s?Te(s,t):null}function Oe({connection:e,authStatus:s,authClientOrigin:t,scope:i,pluginName:a,rawName:r,displayName:c,toolCount:u,tools:g,serverInfo:x,alsoUsedBy:p,error:m}){const o=Zn({scope:i,pluginName:a,connection:e});return n.jsxs("div",{className:"border-border/60 text-muted-foreground mt-2 space-y-1 border-t pt-2 text-xs leading-relaxed",children:[e&&n.jsx(L,{label:"Sign-in",align:"start",wrap:!0,labelClassName:$,children:n.jsxs("span",{className:"inline-flex items-start gap-1.5",children:[n.jsx(Ye,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),Rn({connection:e,authStatus:s,clientOrigin:t})]})}),o&&n.jsx(L,{label:"Source",align:"start",wrap:!0,labelClassName:$,children:o}),r!==c&&n.jsx(L,{label:"Raw id",align:"start",wrap:!0,labelClassName:$,children:n.jsx("code",{className:"text-2xs font-mono",children:r})}),x&&n.jsx(L,{label:"Server",align:"start",wrap:!0,labelClassName:$,children:x}),p&&n.jsx(L,{label:"Also used by",align:"start",wrap:!0,labelClassName:$,children:p}),typeof u=="number"&&n.jsx(L,{label:"Tools",align:"start",labelClassName:$,children:u}),g&&g.length>0&&n.jsx(Wn,{tools:g}),m&&n.jsx(L,{label:"Error",align:"start",wrap:!0,labelClassName:$,children:n.jsx("code",{className:"text-2xs font-mono break-all",children:m})})]})}function Jn({flow:e,serverName:s}){return n.jsxs(n.Fragment,{children:[n.jsx(Ne,{flow:e,serverName:s,failedActions:n.jsxs(n.Fragment,{children:[n.jsx(f,{variant:"secondary",size:"sm",onClick:()=>e.start(),className:"focus-visible:ring-2",children:"Try again"}),n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>e.reset(),className:"focus-visible:ring-2",children:"Dismiss"})]}),connectedActions:n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>e.reset(),className:"focus-visible:ring-2",children:"Dismiss"})}),(e.state.step==="disclosure"||e.state.step==="waiting")&&n.jsx("div",{className:"mt-2",children:n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>e.reset(),"aria-label":`Cancel signing in to ${s}`,className:"focus-visible:ring-2",children:"Cancel"})})]})}function Xn({server:e,agentId:s,live:t,testResult:i,rosterUpdatedAt:a,testing:r,busy:c,onToggle:u,onTest:g,onRemove:x}){const p=ve(s,e.name),m=p.state.step==="connected",o=Cn({stamped:i,signedInNow:m,authStatus:e.authStatus,rosterUpdatedAt:a}),j=Ce(e.connection),C=we({enabled:e.enabled,testedOk:(o==null?void 0:o.ok)===!0,signedInNow:m,runtimeStatus:t==null?void 0:t.status,runtimeError:t==null?void 0:t.error,authStatus:e.authStatus,ownKey:j}),b=p.state.step==="starting",k=p.state.step==="disclosure"||p.state.step==="waiting"||b,v=k?"signing-in":C,z=yn({statusKey:C,testResult:o,signedInNow:m})&&(p.state.step==="idle"||b),y=Ae(e.name),M=o!=null&&o.ok?o.toolCount??null:p.state.toolCount,P=k?v:wn({status:v,probe:o}),A=Pn(P,{displayName:y.displayName,toolCount:M,justSignedIn:m}),O=k?"none":En(P),R=Sn({connection:e.connection,authStatus:e.authStatus});return n.jsx(Me,{displayName:y.displayName,rawName:e.name,scope:"agent",pluginName:y.pluginName,status:v,sentence:A,managed:!0,toggle:n.jsx(Je,{checked:e.enabled,onCheckedChange:T=>u(e.name,T),disabled:c,"aria-label":`Enable ${e.name}`}),actions:n.jsxs(n.Fragment,{children:[z&&n.jsxs(f,{variant:"default",size:"sm",onClick:()=>p.start(),disabled:c||b,"aria-label":`Sign in to ${e.name}`,className:"gap-1.5 focus-visible:ring-2",children:[n.jsx(de,{className:"size-3.5","aria-hidden":!0}),"Sign in"]}),!z&&O==="try-again"&&n.jsxs(f,{variant:"outline",size:"sm",onClick:()=>g(e.name),disabled:r||c,"aria-label":`Try ${e.name} again`,className:"gap-1.5 focus-visible:ring-2",children:[r?n.jsx(ee,{size:"xs"}):null,"Try again"]}),!z&&O==="test"&&n.jsx(f,{variant:"outline",size:"sm",onClick:()=>g(e.name),disabled:r||c,className:"focus-visible:ring-2",children:r?n.jsx(ee,{size:"xs"}):"Test"}),n.jsxs(He,{children:[n.jsx(Ge,{asChild:!0,children:n.jsx(f,{variant:"ghost",size:"sm","aria-label":`More actions for ${e.name}`,className:"ml-auto focus-visible:ring-2",children:n.jsx(Qe,{className:"size-4","aria-hidden":!0})})}),n.jsxs(We,{align:"end",children:[n.jsxs(J,{onSelect:()=>g(e.name),disabled:r||c,children:[n.jsx(cn,{className:"size-3.5","aria-hidden":!0}),"Test"]}),R&&n.jsxs(J,{onSelect:()=>p.start(),disabled:c,children:[n.jsx(de,{className:"size-3.5","aria-hidden":!0}),"Sign in again"]}),n.jsx(Ze,{}),n.jsx(J,{variant:"destructive",onSelect:()=>x(e.name),disabled:c,children:"Remove"})]})]})]}),details:n.jsx(Oe,{connection:e.connection,authStatus:e.authStatus,authClientOrigin:e.authClientOrigin,scope:"agent",pluginName:y.pluginName,rawName:y.rawName,displayName:y.displayName,toolCount:M,error:(o==null?void 0:o.ok)===!1?o.error:t==null?void 0:t.error}),children:n.jsx(Jn,{flow:p,serverName:y.displayName})})}function es(e){switch(e.status){case"connected":return"connected";case"failed":return ie(e.error);case"needs-auth":return"needs-sign-in";case"pending":return"connecting";case"disabled":return"off";default:return"not-checked"}}function ns(e){const{displayName:s,scope:t,pluginName:i}=e,a=ss(t,i);return`${s} ${a}. Manage it here to enable, disable, or sign in from DorkOS.`}function ss(e,s){return e==="plugin"&&s?`comes with the ${s} plugin`:e==="project"?"comes from this project’s own config":e==="computer"?"comes from your computer-wide config":"is loaded from outside DorkOS"}function ts({entry:e,agentId:s,agentLabel:t,canImport:i}){const a=dn(),[r,c]=l.useState(null),[u,g]=l.useState(null),x=l.useCallback(async()=>{g(null);try{const v=await a.mutateAsync({input:{agentId:s,name:e.name}});v.status==="approval_required"&&c(v.approval)}catch(v){g(v instanceof Error?v.message:"Couldn’t add the server.")}},[a,s,e.name]),p=l.useCallback(async()=>{if(r){g(null);try{(await a.mutateAsync({input:{agentId:s,name:e.name},approval:r})).status!=="ok"&&g("Adding it still needs approval. Try again.")}catch(v){g(v instanceof Error?v.message:"Couldn’t add the server.")}}},[a,s,e.name,r]),m=Ae(e.name),o=$n(e,m),j=o!==null,C=m.rawName!==m.displayName,b=e.error!==void 0,k=j||C||b;return r?n.jsxs("div",{className:"border-border/60 mb-2 space-y-3 rounded-md border p-3 last:mb-0",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(te,{className:"text-status-warning mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("p",{className:"text-sm font-medium",children:["Add “",m.displayName,"” to ",t,"?"]}),n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:ns({displayName:m.displayName,scope:o,pluginName:m.pluginName})})]})]}),u&&n.jsx("p",{className:"text-destructive text-xs",children:u}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>c(null),disabled:a.isPending,className:"focus-visible:ring-2",children:"Cancel"}),n.jsx(f,{size:"sm",onClick:p,disabled:a.isPending,className:"focus-visible:ring-2",children:a.isPending?"Adding…":"Add to agent"})]})]}):n.jsx(Me,{displayName:m.displayName,rawName:e.name,scope:o,pluginName:m.pluginName,status:es(e),sentence:Bn(o,m.pluginName),managed:!1,actions:i?n.jsxs(n.Fragment,{children:[n.jsxs(f,{variant:"outline",size:"sm",onClick:x,disabled:a.isPending,"aria-label":`Add ${e.name} to agent`,className:"gap-1.5 focus-visible:ring-2",children:[a.isPending?n.jsx(ee,{size:"xs"}):n.jsx(pe,{className:"size-(--size-icon-xs)","aria-hidden":!0}),"Add to agent"]}),u&&n.jsx("p",{className:"text-destructive text-xs",children:u})]}):void 0,details:k?n.jsx(Oe,{scope:o,pluginName:m.pluginName,rawName:m.rawName,displayName:m.displayName,error:e.error}):void 0})}function as(e,s){return{agentId:e,name:s.server.name,connection:s.server.connection}}function rs(e){const s=e.sites.filter(t=>!t.expired).map(t=>t.site);return s.length<=3?s.join(", "):`${s.slice(0,3).join(", ")} and ${s.length-3} more`}function is({agentId:e,agentLabel:s}){const t=Xe(),i=ye(),[a,r]=l.useState(null),[c,u]=l.useState(null),g=l.useCallback(async o=>{if(t.data){u(null);try{const j=await i.mutateAsync({input:as(e,t.data),...o?{approval:o}:{}});j.status!=="approval_required"?r(null):o?u("The browser still needs approval. Try again."):r(j.approval)}catch(j){u(j instanceof Error?j.message:"Couldn’t add the browser.")}}},[i,e,t.data]);if(!t.data)return null;const x=t.data,p=rs(x),m=`${x.loginCommand} <site>`;return n.jsx(F,{children:n.jsxs(D,{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[a?n.jsx(te,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}):n.jsx(en,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsxs("div",{className:"min-w-0 space-y-1",children:[n.jsx("p",{className:"text-sm font-medium",children:a?`Give ${s} the signed-in browser?`:"Signed-in browser"}),a?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground text-xs",children:"Runs on this computer when a chat starts."}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Each chat gets its own browser."})]}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"Starts signed in to your saved sites. The agent never sees your passwords."}),x.saved?n.jsxs("p",{className:"text-xs",children:["Signed in to ",p,"."]}):n.jsxs("p",{className:"text-status-warning-fg text-xs",children:["Starts signed out. Run ",n.jsx("code",{className:"font-mono",children:m}),n.jsx(nn,{value:m,label:"Copy the sign-in command",size:"xs",className:"mx-0.5 inline-flex align-middle"})," ","in a terminal first."]})]})]}),a&&n.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded-md px-3 py-2 font-mono text-xs",children:[x.server.connection.command,...x.server.connection.args].join(" ")}),c&&n.jsx("p",{className:"text-destructive text-xs",children:c}),n.jsxs("div",{className:"flex justify-end gap-2",children:[a&&n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>r(null),disabled:i.isPending,className:"focus-visible:ring-2",children:"Back"}),n.jsx(f,{variant:a?"default":"outline",size:"sm",onClick:()=>void g(a??void 0),disabled:i.isPending,className:"focus-visible:ring-2",children:i.isPending?"Adding…":a?"Add browser":"Give it the browser"})]})]})})}const os={codex:["stdio","http"],opencode:["stdio","http"]};function ge(e){return os[e]??fn}function cs(){const{open:e}=an();return n.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:["Want other apps to use DorkOS’s tools?"," ",n.jsx(f,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>e("tools","external-mcp"),children:"See Settings → Advanced → Tools"})]})}function ls({agent:e,projectPath:s}){var q;const t=sn(e.id),i=ln(s,e.runtime),a=i.data,r=tn(e.runtime),c=(r==null?void 0:r.supportsManagedMcpServers)??!0,u=mn(),g=gn(),x=un(),p=hn(),[m,o]=l.useState({}),[j,C]=l.useState(null),[b,k]=l.useState(null),v=Mn(),z=l.useCallback((d,N)=>{(N?u:g).mutate({agentId:e.id,name:d})},[e.id,u,g]),y=l.useCallback(d=>{x.mutate({agentId:e.id,name:d}),o(N=>{const w={...N};return delete w[d],w})},[e.id,x]),M=l.useCallback(async d=>{C(d);try{const N=await p.mutateAsync({agentId:e.id,name:d});o(w=>({...w,[d]:{result:N,at:Date.now()}}))}finally{C(null)}},[e.id,p]),P=l.useCallback(({name:d,transport:N})=>{k(d),N!=="stdio"&&M(d).catch(()=>{})},[M]),A=t.data??[],O=new Set(A.map(d=>d.name)),R=new Map(((a==null?void 0:a.servers)??[]).map(d=>[d.name,d])),T=((a==null?void 0:a.servers)??[]).filter(d=>!O.has(d.name)),I=u.isPending||g.isPending||x.isPending,Z=A.some(d=>on(d.connection)!==void 0),U=c&&!t.isPending&&!Z&&ge(e.runtime).includes("stdio"),K=new Map;A.forEach((d,N)=>K.set(d.name,{kind:"managed",index:N})),T.forEach((d,N)=>K.set(d.name,{kind:"discovered",index:N}));const V=v({bothSettled:!t.isPending&&!i.isPending,managed:A,live:R,discovered:T,present:[...A.map(d=>d.name),...T.map(d=>d.name)]});function B(d){const N=K.get(d);if(!N)return null;if(N.kind==="managed"){const E=A[N.index];return n.jsx(Xn,{server:E,agentId:e.id,live:R.get(E.name),testResult:m[E.name],rosterUpdatedAt:t.dataUpdatedAt,testing:j===E.name,busy:I,onToggle:z,onTest:M,onRemove:y},E.name)}const w=T[N.index];return n.jsx(ts,{entry:w,agentId:e.id,agentLabel:e.displayName??e.name,canImport:c},w.name)}return n.jsxs("section",{className:"space-y-3","aria-label":"MCP servers",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h3",{className:"text-sm font-semibold",children:"MCP Servers"}),c&&n.jsx(vn,{agentId:e.id,agentLabel:e.displayName??e.name,supportedTransports:ge(e.runtime),onAdded:P,oauthDetectedFor:b&&((q=m[b])==null?void 0:q.result.needsAuth)===!0?b:null})]}),n.jsx(cs,{}),U&&n.jsx(is,{agentId:e.id,agentLabel:e.displayName??e.name}),!c&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"This agent can’t use added servers yet. View only."}),t.isLoading?n.jsx(F,{children:n.jsxs(D,{className:"space-y-2",children:[n.jsx(ne,{className:"h-5 w-full"}),n.jsx(ne,{className:"h-5 w-3/4"})]})}):t.isError?n.jsx(F,{children:n.jsxs(D,{className:"flex items-center justify-between gap-2",children:[n.jsx("p",{className:"text-destructive text-sm",children:"Couldn’t load managed servers."}),n.jsx(f,{variant:"outline",size:"sm",onClick:()=>t.refetch(),className:"focus-visible:ring-2",children:"Try again"})]})}):V.length===0?n.jsx(F,{children:n.jsx(D,{children:n.jsxs("p",{className:"text-muted-foreground text-sm",children:["No MCP servers yet."," ",c?"Add one for more tools.":"This agent can’t use them yet."]})})}):n.jsx(F,{children:n.jsx(D,{children:V.map(B)})})]})}function hs({member:e}){const{agent:s,projectPath:t,isPending:i}=rn(e);return i?n.jsx(ne,{className:"h-32 w-full"}):!s||t===null?n.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t read this agent’s MCP servers."}):n.jsx(ls,{agent:s,projectPath:t})}export{hs as ToolsPage};
1
+ import{ae as W,aj as Fe,ag as se,af as he,e4 as _e,r as l,j as n,cz as F,cA as _,B as f,f as pe,hm as te,e5 as D,I as G,d_ as De,d$ as Le,e0 as $e,e1 as Ke,e2 as Be,g$ as ce,b_ as Ue,fM as Ve,C as X,Z as le,ao as ae,cu as fe,cv as xe,aa as qe,cw as je,b$ as L,e7 as He,hn as de,F as ee,g2 as Ye,g3 as Ge,g4 as Qe,g5 as We,g6 as J,g8 as Ze,ad as Je,ho as Xe,hh as en,hp as nn,hq as sn,G as tn,e as ne,fk as an,b as rn}from"./index-C63bLSO4.js";import{a as on}from"./agent-browser-CO5haI5Y.js";import{u as ve,M as Ne}from"./McpSigninBody-DBWSc6bm.js";import{R as cn}from"./rotate-cw-DaduzRfP.js";function ln(e,s){const t=W();return Fe({queryKey:["mcp-config",e,s??null],queryFn:()=>t.getMcpConfig(e,{runtime:s??void 0}),enabled:!!e,staleTime:3e4})}function be(e,s){e.invalidateQueries({queryKey:_e.mcpServers(s)}),e.invalidateQueries({queryKey:["mcp-config"]})}function Se(e){const s=W(),t=he();return se({mutationFn:async({input:i,approval:a})=>a?(await s.grantApproval(a.approvalId),e(s,i,a.approvalToken)):e(s,i),onSuccess:(i,{input:a})=>{i.status==="ok"&&be(t,a.agentId)}})}function ye(){return Se((e,s,t)=>e.addAgentMcpServer(s,t?{approvalToken:t}:void 0))}function dn(){return Se((e,s,t)=>e.importAgentMcpServer(s,t?{approvalToken:t}:void 0))}function re(e){const s=W(),t=he();return se({mutationFn:({agentId:i,name:a})=>e(s,i,a),onSuccess:(i,{agentId:a})=>be(t,a)})}function un(){return re((e,s,t)=>e.removeAgentMcpServer(s,t))}function mn(){return re((e,s,t)=>e.enableAgentMcpServer(s,t))}function gn(){return re((e,s,t)=>e.disableAgentMcpServer(s,t))}function hn(){const e=W();return se({mutationFn:({agentId:s,name:t})=>e.testAgentMcpServer(s,t)})}function pn({agentId:e,serverName:s,onDone:t}){const i=ve(e,s),{start:a}=i,r=l.useRef(!1);return l.useEffect(()=>{r.current||(r.current=!0,a())},[a]),n.jsx(F,{children:n.jsxs(_,{className:"space-y-2",children:[n.jsxs("p",{className:"text-sm font-medium",children:["Sign in to ",s]}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Sign in so your agent can use this server."}),n.jsx(Ne,{flow:i,serverName:s,failedActions:n.jsxs(n.Fragment,{children:[n.jsx(f,{variant:"secondary",size:"sm",onClick:()=>i.start(),className:"focus-visible:ring-2",children:"Try again"}),n.jsx(f,{variant:"ghost",size:"sm",onClick:t,className:"focus-visible:ring-2",children:"Later"})]}),connectedActions:n.jsx(f,{variant:"ghost",size:"sm",onClick:t,className:"focus-visible:ring-2",children:"Done"})}),i.state.step!=="failed"&&i.state.step!=="connected"&&n.jsx(f,{variant:"ghost",size:"sm",onClick:t,className:"focus-visible:ring-2",children:"Later"})]})})}const fn=["stdio","http","sse"],xn=/^[a-zA-Z0-9_-]+$/;function ue(e){const s={};for(const t of e.split(`
2
+ `)){const i=t.trim();if(!i)continue;const a=i.indexOf("=");if(a===-1)continue;const r=i.slice(0,a).trim();r&&(s[r]=i.slice(a+1).trim())}return s}function me(e){return e.trim().length?e.trim().split(/\s+/):[]}function jn(e,s){if(e.status!=="ok")return!1;const t=e.servers.find(a=>a.name===s),i=t==null?void 0:t.connection;return i!==void 0&&"authKind"in i&&i.authKind==="oauth2"}function vn({agentId:e,agentLabel:s,supportedTransports:t,onAdded:i,oauthDetectedFor:a=null}){const r=ye(),[c,u]=l.useState(!1),[g,x]=l.useState(""),[p,m]=l.useState(t[0]??"stdio"),o=t.includes(p)?p:t[0]??"stdio",[j,C]=l.useState(""),[b,k]=l.useState(""),[v,E]=l.useState(""),[y,M]=l.useState(""),[P,A]=l.useState(""),[O,R]=l.useState(null),[T,I]=l.useState(null),[Z,U]=l.useState(null),[K,V]=l.useState(null),B=xn.test(g)&&g.length<=64,q=o==="stdio"?j.trim().length>0:y.trim().length>0,d=B&&q&&!r.isPending,N=l.useCallback(()=>o==="stdio"?{transport:"stdio",command:j.trim(),args:me(b),env:ue(v)}:{transport:o,url:y.trim(),headers:ue(P)},[o,j,b,v,y,P]),w=l.useCallback(()=>({agentId:e,name:g.trim(),connection:N()}),[e,g,N]),z=l.useCallback(()=>{u(!1),R(null),I(null),x(""),m(t[0]??"stdio"),C(""),k(""),E(""),M(""),A("")},[t]),oe=l.useCallback(h=>{i({name:h.name,transport:h.connection.transport}),z()},[i,z]),H=l.useCallback((h,S)=>{const Ie=jn(h,S.name);oe(S),Ie&&U(S.name)},[oe]),ze=l.useCallback(async()=>{I(null);const h=w();try{const S=await r.mutateAsync({input:h});S.status==="approval_required"?R(S.approval):H(S,h)}catch(S){I(S instanceof Error?S.message:"Couldn’t add the server.")}},[r,w,H]),Ee=l.useCallback(async()=>{if(!O)return;I(null);const h=w();try{const S=await r.mutateAsync({input:h,approval:O});S.status==="ok"?H(S,h):I("The server still needs approval. Try again.")}catch(S){I(S instanceof Error?S.message:"Couldn’t add the server.")}},[r,w,O,H]),Y=Z??(a&&a!==K?a:null),Pe=l.useCallback(()=>{V(Y),U(null)},[Y]),Re=l.useMemo(()=>[j.trim(),...me(b)].filter(Boolean).join(" "),[j,b]);return Y?n.jsx(pn,{agentId:e,serverName:Y,onDone:Pe}):c?O?n.jsx(F,{children:n.jsxs(_,{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(te,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("p",{className:"text-sm font-medium",children:["Add this server to ",s,"?"]}),n.jsx("p",{className:"text-muted-foreground text-xs",children:o==="stdio"?"Runs on this computer when a chat starts.":"The agent connects here when a chat starts."})]})]}),n.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded-md px-3 py-2 font-mono text-xs",children:o==="stdio"?Re:y.trim()}),T&&n.jsx("p",{className:"text-destructive text-xs",children:T}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>R(null),disabled:r.isPending,className:"focus-visible:ring-2",children:"Back"}),n.jsx(f,{size:"sm",onClick:Ee,disabled:r.isPending,className:"focus-visible:ring-2",children:r.isPending?"Adding…":"Add server"})]})]})}):n.jsx(F,{children:n.jsxs(_,{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(D,{htmlFor:"mcp-name",children:"Name"}),n.jsx(G,{id:"mcp-name",value:g,onChange:h=>x(h.target.value),placeholder:"my-server","aria-invalid":g.length>0&&!B}),g.length>0&&!B&&n.jsx("p",{className:"text-destructive text-xs",children:"Letters, numbers, dashes, underscores only."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(D,{htmlFor:"mcp-transport",children:"Transport"}),n.jsxs(De,{value:o,onValueChange:h=>m(h),children:[n.jsx(Le,{id:"mcp-transport",className:"w-full",children:n.jsx($e,{})}),n.jsx(Ke,{children:t.map(h=>n.jsx(Be,{value:h,children:h},h))})]})]}),o==="stdio"?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(D,{htmlFor:"mcp-command",children:"Command"}),n.jsx(G,{id:"mcp-command",value:j,onChange:h=>C(h.target.value),placeholder:"npx",className:"font-mono"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(D,{htmlFor:"mcp-args",children:"Arguments"}),n.jsx(G,{id:"mcp-args",value:b,onChange:h=>k(h.target.value),placeholder:"-y @modelcontextprotocol/server-filesystem",className:"font-mono"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(D,{htmlFor:"mcp-env",children:"Environment (KEY=VALUE per line)"}),n.jsx(ce,{id:"mcp-env",value:v,onChange:h=>E(h.target.value),placeholder:"API_KEY=…",rows:2,className:"font-mono text-xs"})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(D,{htmlFor:"mcp-url",children:"URL"}),n.jsx(G,{id:"mcp-url",value:y,onChange:h=>M(h.target.value),placeholder:"https://example.com/mcp",className:"font-mono"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(D,{htmlFor:"mcp-headers",children:"Headers (KEY=VALUE per line)"}),n.jsx(ce,{id:"mcp-headers",value:P,onChange:h=>A(h.target.value),placeholder:"Authorization=Bearer …",rows:2,className:"font-mono text-xs"})]})]}),T&&n.jsx("p",{className:"text-destructive text-xs",children:T}),n.jsx(Ue,{}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(f,{variant:"ghost",size:"sm",onClick:z,className:"focus-visible:ring-2",children:"Cancel"}),n.jsx(f,{size:"sm",onClick:ze,disabled:!d,className:"focus-visible:ring-2",children:"Continue"})]})]})}):n.jsxs(f,{variant:"outline",size:"sm",onClick:()=>u(!0),className:"focus-visible:ring-2",children:[n.jsx(pe,{className:"size-4"}),"Add server"]})}const Nn={connected:"connected","needs-auth":"needs-sign-in",pending:"connecting",disabled:"off"},bn=["validation","invalid config","invalid configuration","missing required","command not found","enoent"];function ie(e){if(!e)return"cant-reach";const s=e.toLowerCase();return bn.some(t=>s.includes(t))?"setup-problem":"cant-reach"}function Ce(e){return e.transport==="stdio"||e.authKind==="oauth2"?!1:Object.keys(e.headers).some(s=>s.toLowerCase()==="authorization")}function Sn(e){const{connection:s,authStatus:t}=e;return s.transport!=="stdio"&&s.authKind==="oauth2"?!0:t!==void 0}function we(e){const{enabled:s,testedOk:t,signedInNow:i,runtimeStatus:a,runtimeError:r,authStatus:c,ownKey:u}=e;return s?t?"connected":i?"signed-in":a==="failed"?ie(r):c==="connected"&&a==="needs-auth"?"signed-in":c==="needs-auth"&&(a==="connected"||a==="pending")?"needs-sign-in":a?Nn[a]:c==="connected"?"signed-in":c==="needs-auth"?"needs-sign-in":u?"uses-your-key":"not-checked":"off"}function yn(e){const{statusKey:s,testResult:t,signedInNow:i}=e;return s==="off"||i?!1:(t==null?void 0:t.needsAuth)===!0?!0:s==="needs-sign-in"}function Cn(e){const{stamped:s,signedInNow:t,authStatus:i,rosterUpdatedAt:a}=e;if(!s)return;const{result:r}=s;if(!(t&&r.needsAuth===!0)&&!(s.at<=a&&(i==="needs-auth"&&r.ok||i==="connected"&&r.needsAuth===!0)))return r}function wn(e){const{status:s,probe:t}=e;return s==="off"||!t||t.ok?s:t.needsAuth===!0?"needs-sign-in":ie(t.error)}const Q={attention:0,working:1,elsewhere:2,off:3};function kn(e){return e==="off"?Q.off:e==="needs-sign-in"||e==="cant-reach"||e==="setup-problem"?Q.attention:Q.working}function An(e){const{managed:s,live:t,discovered:i}=e;return[...s.map(r=>{var c,u;return{name:r.name,band:kn(we({enabled:r.enabled,testedOk:!1,signedInNow:!1,runtimeStatus:(c=t.get(r.name))==null?void 0:c.status,runtimeError:(u=t.get(r.name))==null?void 0:u.error,authStatus:r.authStatus,ownKey:Ce(r.connection)}))}}),...i.map(r=>({name:r.name,band:Q.elsewhere}))].map((r,c)=>({entry:r,index:c})).sort((r,c)=>r.entry.band-c.entry.band||r.index-c.index).map(({entry:r})=>r.name)}function Tn(e){const{frozen:s,present:t}=e,i=new Set(t),a=new Set(s);return{ordered:s.filter(r=>i.has(r)),added:t.filter(r=>!a.has(r))}}function Mn(){const e=Ve(null);return({bothSettled:s,managed:t,live:i,discovered:a,present:r})=>{e.read()===null&&s&&r.length>0&&e.write(An({managed:t,live:i,discovered:a}));const{ordered:c,added:u}=Tn({frozen:e.read()??[],present:r});return u.length>0&&e.read()!==null&&e.write([...c,...u]),[...c,...u]}}const ke={"needs-sign-in":{label:"Needs sign-in",tooltip:"Sign in to use it.",tone:"attention"},"signing-in":{label:"Signing in…",tooltip:"Finish in the new tab.",tone:"attention"},connected:{label:"Connected",tooltip:"It answered. Its tools are ready.",tone:"calm"},"signed-in":{label:"Signed in",tooltip:"Signed in, not tested yet.",tone:"calm"},"uses-your-key":{label:"Uses your key",tooltip:"Uses a key you added.",tone:"calm"},"cant-reach":{label:"Can’t reach",tooltip:"No answer. See Details.",tone:"error"},"setup-problem":{label:"Setup problem",tooltip:"Couldn’t start. See Details.",tone:"error"},connecting:{label:"Connecting…",tooltip:"Connecting to this server.",tone:"calm"},"not-checked":{label:"Not checked yet",tooltip:"Nothing has checked it yet.",tone:"calm"},off:{label:"Off",tooltip:"Hidden from the agent.",tone:"calm"}},On={"needs-sign-in":"sign-in","signing-in":"none",connected:"none","signed-in":"test","uses-your-key":"test","cant-reach":"try-again","setup-problem":"try-again",connecting:"none","not-checked":"test",off:"none"};function zn(e){return On[e]}function En({toolCount:e,justSignedIn:s}){const t=s?"Signed in just now. ":"";return e===null?`${t||"This server answered. "}Its tools are available.`:`${t}${e} tool${e===1?"":"s"} available.`}function Pn(e,s){switch(e){case"needs-sign-in":return`Sign in to ${s.displayName} to use its tools.`;case"signing-in":return null;case"connected":return En(s);case"signed-in":return s.justSignedIn?"Signed in just now. Test to check it answers.":"Signed in. Test to check it answers.";case"uses-your-key":return"You added an access key when setting this up.";case"cant-reach":return"This server didn’t answer. It may be down.";case"setup-problem":return"This server’s setup has a problem.";case"connecting":return"Connecting to this server.";case"not-checked":return"Nothing has checked this server yet.";case"off":return"Turned off. The agent doesn’t see this server."}}function Rn(e){const{connection:s,authStatus:t,clientOrigin:i}=e;return s.transport==="stdio"?"None. This server doesn’t need one.":s.authKind==="oauth2"?i==="manual"?`Your own app credentials, ${t==="connected"?"signed in, renews automatically":"not signed in yet"}. DorkOS holds the key, not the agent.`:t==="connected"?"Signed in, and it renews automatically. DorkOS holds the key, not the agent.":"DorkOS will hold the key, not the agent.":Object.keys(s.headers).some(r=>r.toLowerCase()==="authorization")?"Access key: you added a key when setting this up.":t===void 0?"Nothing has checked this yet.":"None. This server doesn’t need one."}function In(e){if(e.transport==="stdio")return`Runs \`${e.command}\` on this computer`;const s=Fn(e.url);return s?`${s} (web service)`:`${e.url} (web service)`}function Fn(e){try{return new URL(e).host}catch{return null}}const _n={agent:"Added to this agent through DorkOS",project:"From this project’s config files",plugin:"Comes with a plugin",computer:"From your computer-wide config"},Dn={agent:"Added to this agent through DorkOS.",project:"From this project’s config. Add it to manage it here.",plugin:"Comes with a plugin. Add it to manage it here.",computer:"From your computer-wide config. Add it to manage it here."},Ln=[{runtime:"claude-code",pattern:/^plugin:([^:]+):(.+)$/,read:e=>({pluginName:e[1],displayName:e[2]})},{runtime:"claude-code",pattern:/^plugin:(.+)$/,read:e=>({pluginName:e[1],displayName:e[1]})}];function Ae(e){for(const s of Ln){const t=e.match(s.pattern);if(!t)continue;const{displayName:i,pluginName:a}=s.read(t);if(!(!i||!a))return{displayName:i,pluginName:a,rawName:e}}return{displayName:e,pluginName:null,rawName:e}}function $n(e,s){return s.pluginName?"plugin":e.scope==="project"||e.scope==="local"?"project":e.scope==="user"?"computer":null}const Kn="Loaded from outside DorkOS. Add it to manage it here.";function Te(e,s){return e==="plugin"&&s?`Comes with the ${s} plugin`:_n[e]}function Bn(e,s){return e===null?Kn:e==="plugin"&&s?`Comes with the ${s} plugin. Add it to manage it here.`:Dn[e]}const Un=ae("border-border/60 relative overflow-hidden rounded-md border px-3 py-2.5 transition-colors",{variants:{managed:{true:"bg-card",false:"bg-muted/30"},dimmed:{true:"opacity-65",false:""}},defaultVariants:{managed:!0,dimmed:!1}}),Vn=ae("pointer-events-none absolute inset-y-0 left-0 w-0.5",{variants:{tone:{calm:"hidden",attention:"bg-status-warning",error:"bg-status-error"}},defaultVariants:{tone:"calm"}}),qn=ae("shrink-0 rounded-full px-2 py-0.5 text-2xs leading-4 font-medium whitespace-nowrap",{variants:{chip:{success:"bg-status-success-bg text-status-success-fg",info:"bg-status-info-bg text-status-info-fg",warning:"bg-status-warning-bg text-status-warning-fg",error:"bg-status-error-bg text-status-error-fg",neutral:"bg-muted text-muted-foreground"}},defaultVariants:{chip:"neutral"}}),Hn={connected:"success","signed-in":"info","needs-sign-in":"warning","signing-in":"warning","cant-reach":"error","setup-problem":"error","uses-your-key":"neutral",connecting:"neutral","not-checked":"neutral",off:"neutral"};function Yn({status:e}){const s=ke[e];return n.jsxs(fe,{children:[n.jsx(xe,{asChild:!0,children:n.jsx("span",{className:qn({chip:Hn[e]}),children:s.label})}),n.jsx(je,{children:s.tooltip})]})}function Gn({scope:e,pluginName:s}){return n.jsxs(fe,{children:[n.jsx(xe,{asChild:!0,children:n.jsx(qe,{size:"xs",tone:"neutral",variant:"secondary",className:"shrink-0 font-normal",children:e})}),n.jsx(je,{children:Te(e,s)})]})}function Me({displayName:e,rawName:s,scope:t,pluginName:i,status:a,sentence:r,managed:c,toggle:u,actions:g,children:x,details:p,defaultDetailsOpen:m=!1}){const[o,j]=l.useState(m),C=l.useId(),b=ke[a].tone;return n.jsxs("div",{"data-mcp-server":s,className:le(Un({managed:c,dimmed:a==="off"}),"mb-2 last:mb-0"),children:[n.jsx("span",{className:Vn({tone:b}),"aria-hidden":!0}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e}),t&&n.jsx(Gn,{scope:t,pluginName:i}),n.jsx(Yn,{status:a}),u]}),r&&n.jsx("p",{className:"text-muted-foreground mt-1 text-xs leading-relaxed",children:r}),x,g&&n.jsx("div",{className:"mt-2 flex items-center gap-1",children:g}),p&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",onClick:()=>j(k=>!k),"aria-expanded":o,"aria-controls":C,className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs focus-visible:ring-2",children:[n.jsx(X,{className:le("size-3 transition-transform",o&&"rotate-90"),"aria-hidden":!0}),"Details"]}),o&&n.jsxs("div",{id:C,children:[p,n.jsxs("button",{type:"button",onClick:()=>j(!1),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs focus-visible:ring-2",children:[n.jsx(X,{className:"size-3 -rotate-90","aria-hidden":!0}),"Collapse details"]})]})]})]})}const Qn=3,$="text-muted-foreground/70";function Wn({tools:e}){const[s,t]=l.useState(!1),i=s?e:e.slice(0,Qn),a=e.length-i.length;return n.jsxs("div",{className:"mt-1.5",children:[i.map(r=>n.jsxs("div",{className:"border-border/40 flex items-baseline gap-2 border-b py-1 last:border-b-0",children:[n.jsx("code",{className:"text-foreground text-2xs shrink-0 font-mono",children:r.name}),r.description&&n.jsx("span",{className:"text-muted-foreground text-2xs truncate",children:r.description})]},r.name)),a>0&&n.jsxs("button",{type:"button",onClick:()=>t(!0),className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs focus-visible:ring-2",children:[n.jsx(X,{className:"size-3","aria-hidden":!0}),"Show ",a," more"]})]})}function Zn(e){const{scope:s,pluginName:t,connection:i}=e;return s==="plugin"&&t?`Comes with the ${t} plugin`:i?In(i):s?Te(s,t):null}function Oe({connection:e,authStatus:s,authClientOrigin:t,scope:i,pluginName:a,rawName:r,displayName:c,toolCount:u,tools:g,serverInfo:x,alsoUsedBy:p,error:m}){const o=Zn({scope:i,pluginName:a,connection:e});return n.jsxs("div",{className:"border-border/60 text-muted-foreground mt-2 space-y-1 border-t pt-2 text-xs leading-relaxed",children:[e&&n.jsx(L,{label:"Sign-in",align:"start",wrap:!0,labelClassName:$,children:n.jsxs("span",{className:"inline-flex items-start gap-1.5",children:[n.jsx(He,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),Rn({connection:e,authStatus:s,clientOrigin:t})]})}),o&&n.jsx(L,{label:"Source",align:"start",wrap:!0,labelClassName:$,children:o}),r!==c&&n.jsx(L,{label:"Raw id",align:"start",wrap:!0,labelClassName:$,children:n.jsx("code",{className:"text-2xs font-mono",children:r})}),x&&n.jsx(L,{label:"Server",align:"start",wrap:!0,labelClassName:$,children:x}),p&&n.jsx(L,{label:"Also used by",align:"start",wrap:!0,labelClassName:$,children:p}),typeof u=="number"&&n.jsx(L,{label:"Tools",align:"start",labelClassName:$,children:u}),g&&g.length>0&&n.jsx(Wn,{tools:g}),m&&n.jsx(L,{label:"Error",align:"start",wrap:!0,labelClassName:$,children:n.jsx("code",{className:"text-2xs font-mono break-all",children:m})})]})}function Jn({flow:e,serverName:s}){return n.jsxs(n.Fragment,{children:[n.jsx(Ne,{flow:e,serverName:s,failedActions:n.jsxs(n.Fragment,{children:[n.jsx(f,{variant:"secondary",size:"sm",onClick:()=>e.start(),className:"focus-visible:ring-2",children:"Try again"}),n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>e.reset(),className:"focus-visible:ring-2",children:"Dismiss"})]}),connectedActions:n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>e.reset(),className:"focus-visible:ring-2",children:"Dismiss"})}),(e.state.step==="disclosure"||e.state.step==="waiting")&&n.jsx("div",{className:"mt-2",children:n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>e.reset(),"aria-label":`Cancel signing in to ${s}`,className:"focus-visible:ring-2",children:"Cancel"})})]})}function Xn({server:e,agentId:s,live:t,testResult:i,rosterUpdatedAt:a,testing:r,busy:c,onToggle:u,onTest:g,onRemove:x}){const p=ve(s,e.name),m=p.state.step==="connected",o=Cn({stamped:i,signedInNow:m,authStatus:e.authStatus,rosterUpdatedAt:a}),j=Ce(e.connection),C=we({enabled:e.enabled,testedOk:(o==null?void 0:o.ok)===!0,signedInNow:m,runtimeStatus:t==null?void 0:t.status,runtimeError:t==null?void 0:t.error,authStatus:e.authStatus,ownKey:j}),b=p.state.step==="starting",k=p.state.step==="disclosure"||p.state.step==="waiting"||b,v=k?"signing-in":C,E=yn({statusKey:C,testResult:o,signedInNow:m})&&(p.state.step==="idle"||b),y=Ae(e.name),M=o!=null&&o.ok?o.toolCount??null:p.state.toolCount,P=k?v:wn({status:v,probe:o}),A=Pn(P,{displayName:y.displayName,toolCount:M,justSignedIn:m}),O=k?"none":zn(P),R=Sn({connection:e.connection,authStatus:e.authStatus});return n.jsx(Me,{displayName:y.displayName,rawName:e.name,scope:"agent",pluginName:y.pluginName,status:v,sentence:A,managed:!0,toggle:n.jsx(Je,{checked:e.enabled,onCheckedChange:T=>u(e.name,T),disabled:c,"aria-label":`Enable ${e.name}`}),actions:n.jsxs(n.Fragment,{children:[E&&n.jsxs(f,{variant:"default",size:"sm",onClick:()=>p.start(),disabled:c||b,"aria-label":`Sign in to ${e.name}`,className:"gap-1.5 focus-visible:ring-2",children:[n.jsx(de,{className:"size-3.5","aria-hidden":!0}),"Sign in"]}),!E&&O==="try-again"&&n.jsxs(f,{variant:"outline",size:"sm",onClick:()=>g(e.name),disabled:r||c,"aria-label":`Try ${e.name} again`,className:"gap-1.5 focus-visible:ring-2",children:[r?n.jsx(ee,{size:"xs"}):null,"Try again"]}),!E&&O==="test"&&n.jsx(f,{variant:"outline",size:"sm",onClick:()=>g(e.name),disabled:r||c,className:"focus-visible:ring-2",children:r?n.jsx(ee,{size:"xs"}):"Test"}),n.jsxs(Ye,{children:[n.jsx(Ge,{asChild:!0,children:n.jsx(f,{variant:"ghost",size:"sm","aria-label":`More actions for ${e.name}`,className:"ml-auto focus-visible:ring-2",children:n.jsx(Qe,{className:"size-4","aria-hidden":!0})})}),n.jsxs(We,{align:"end",children:[n.jsxs(J,{onSelect:()=>g(e.name),disabled:r||c,children:[n.jsx(cn,{className:"size-3.5","aria-hidden":!0}),"Test"]}),R&&n.jsxs(J,{onSelect:()=>p.start(),disabled:c,children:[n.jsx(de,{className:"size-3.5","aria-hidden":!0}),"Sign in again"]}),n.jsx(Ze,{}),n.jsx(J,{variant:"destructive",onSelect:()=>x(e.name),disabled:c,children:"Remove"})]})]})]}),details:n.jsx(Oe,{connection:e.connection,authStatus:e.authStatus,authClientOrigin:e.authClientOrigin,scope:"agent",pluginName:y.pluginName,rawName:y.rawName,displayName:y.displayName,toolCount:M,error:(o==null?void 0:o.ok)===!1?o.error:t==null?void 0:t.error}),children:n.jsx(Jn,{flow:p,serverName:y.displayName})})}function es(e){switch(e.status){case"connected":return"connected";case"failed":return ie(e.error);case"needs-auth":return"needs-sign-in";case"pending":return"connecting";case"disabled":return"off";default:return"not-checked"}}function ns(e){const{displayName:s,scope:t,pluginName:i}=e,a=ss(t,i);return`${s} ${a}. Manage it here to enable, disable, or sign in from DorkOS.`}function ss(e,s){return e==="plugin"&&s?`comes with the ${s} plugin`:e==="project"?"comes from this project’s own config":e==="computer"?"comes from your computer-wide config":"is loaded from outside DorkOS"}function ts({entry:e,agentId:s,agentLabel:t,canImport:i}){const a=dn(),[r,c]=l.useState(null),[u,g]=l.useState(null),x=l.useCallback(async()=>{g(null);try{const v=await a.mutateAsync({input:{agentId:s,name:e.name}});v.status==="approval_required"&&c(v.approval)}catch(v){g(v instanceof Error?v.message:"Couldn’t add the server.")}},[a,s,e.name]),p=l.useCallback(async()=>{if(r){g(null);try{(await a.mutateAsync({input:{agentId:s,name:e.name},approval:r})).status!=="ok"&&g("Adding it still needs approval. Try again.")}catch(v){g(v instanceof Error?v.message:"Couldn’t add the server.")}}},[a,s,e.name,r]),m=Ae(e.name),o=$n(e,m),j=o!==null,C=m.rawName!==m.displayName,b=e.error!==void 0,k=j||C||b;return r?n.jsxs("div",{className:"border-border/60 mb-2 space-y-3 rounded-md border p-3 last:mb-0",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(te,{className:"text-status-warning mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("p",{className:"text-sm font-medium",children:["Add “",m.displayName,"” to ",t,"?"]}),n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:ns({displayName:m.displayName,scope:o,pluginName:m.pluginName})})]})]}),u&&n.jsx("p",{className:"text-destructive text-xs",children:u}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>c(null),disabled:a.isPending,className:"focus-visible:ring-2",children:"Cancel"}),n.jsx(f,{size:"sm",onClick:p,disabled:a.isPending,className:"focus-visible:ring-2",children:a.isPending?"Adding…":"Add to agent"})]})]}):n.jsx(Me,{displayName:m.displayName,rawName:e.name,scope:o,pluginName:m.pluginName,status:es(e),sentence:Bn(o,m.pluginName),managed:!1,actions:i?n.jsxs(n.Fragment,{children:[n.jsxs(f,{variant:"outline",size:"sm",onClick:x,disabled:a.isPending,"aria-label":`Add ${e.name} to agent`,className:"gap-1.5 focus-visible:ring-2",children:[a.isPending?n.jsx(ee,{size:"xs"}):n.jsx(pe,{className:"size-(--size-icon-xs)","aria-hidden":!0}),"Add to agent"]}),u&&n.jsx("p",{className:"text-destructive text-xs",children:u})]}):void 0,details:k?n.jsx(Oe,{scope:o,pluginName:m.pluginName,rawName:m.rawName,displayName:m.displayName,error:e.error}):void 0})}function as(e,s){return{agentId:e,name:s.server.name,connection:s.server.connection}}function rs(e){const s=e.sites.filter(t=>!t.expired).map(t=>t.site);return s.length<=3?s.join(", "):`${s.slice(0,3).join(", ")} and ${s.length-3} more`}function is({agentId:e,agentLabel:s}){const t=Xe(),i=ye(),[a,r]=l.useState(null),[c,u]=l.useState(null),g=l.useCallback(async o=>{if(t.data){u(null);try{const j=await i.mutateAsync({input:as(e,t.data),...o?{approval:o}:{}});j.status!=="approval_required"?r(null):o?u("The browser still needs approval. Try again."):r(j.approval)}catch(j){u(j instanceof Error?j.message:"Couldn’t add the browser.")}}},[i,e,t.data]);if(!t.data)return null;const x=t.data,p=rs(x),m=`${x.loginCommand} <site>`;return n.jsx(F,{children:n.jsxs(_,{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[a?n.jsx(te,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}):n.jsx(en,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsxs("div",{className:"min-w-0 space-y-1",children:[n.jsx("p",{className:"text-sm font-medium",children:a?`Give ${s} the signed-in browser?`:"Signed-in browser"}),a?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground text-xs",children:"Runs on this computer when a chat starts."}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Each chat gets its own browser."})]}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"Starts signed in to your saved sites. The agent never sees your passwords."}),x.saved?n.jsxs("p",{className:"text-xs",children:["Signed in to ",p,"."]}):n.jsxs("p",{className:"text-status-warning-fg text-xs",children:["Starts signed out. Run ",n.jsx("code",{className:"font-mono",children:m}),n.jsx(nn,{value:m,label:"Copy the sign-in command",size:"xs",className:"mx-0.5 inline-flex align-middle"})," ","in a terminal first."]})]})]}),a&&n.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded-md px-3 py-2 font-mono text-xs",children:[x.server.connection.command,...x.server.connection.args].join(" ")}),c&&n.jsx("p",{className:"text-destructive text-xs",children:c}),n.jsxs("div",{className:"flex justify-end gap-2",children:[a&&n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>r(null),disabled:i.isPending,className:"focus-visible:ring-2",children:"Back"}),n.jsx(f,{variant:a?"default":"outline",size:"sm",onClick:()=>void g(a??void 0),disabled:i.isPending,className:"focus-visible:ring-2",children:i.isPending?"Adding…":a?"Add browser":"Give it the browser"})]})]})})}const os={codex:["stdio","http"],opencode:["stdio","http"]};function ge(e){return os[e]??fn}function cs(){const{open:e}=an();return n.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:["Want other apps to use DorkOS’s tools?"," ",n.jsx(f,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>e("tools","external-mcp"),children:"See Settings → Advanced → Tools"})]})}function ls({agent:e,projectPath:s}){var q;const t=sn(e.id),i=ln(s,e.runtime),a=i.data,r=tn(e.runtime),c=(r==null?void 0:r.supportsManagedMcpServers)??!0,u=mn(),g=gn(),x=un(),p=hn(),[m,o]=l.useState({}),[j,C]=l.useState(null),[b,k]=l.useState(null),v=Mn(),E=l.useCallback((d,N)=>{(N?u:g).mutate({agentId:e.id,name:d})},[e.id,u,g]),y=l.useCallback(d=>{x.mutate({agentId:e.id,name:d}),o(N=>{const w={...N};return delete w[d],w})},[e.id,x]),M=l.useCallback(async d=>{C(d);try{const N=await p.mutateAsync({agentId:e.id,name:d});o(w=>({...w,[d]:{result:N,at:Date.now()}}))}finally{C(null)}},[e.id,p]),P=l.useCallback(({name:d,transport:N})=>{k(d),N!=="stdio"&&M(d).catch(()=>{})},[M]),A=t.data??[],O=new Set(A.map(d=>d.name)),R=new Map(((a==null?void 0:a.servers)??[]).map(d=>[d.name,d])),T=((a==null?void 0:a.servers)??[]).filter(d=>!O.has(d.name)),I=u.isPending||g.isPending||x.isPending,Z=A.some(d=>on(d.connection)!==void 0),U=c&&!t.isPending&&!Z&&ge(e.runtime).includes("stdio"),K=new Map;A.forEach((d,N)=>K.set(d.name,{kind:"managed",index:N})),T.forEach((d,N)=>K.set(d.name,{kind:"discovered",index:N}));const V=v({bothSettled:!t.isPending&&!i.isPending,managed:A,live:R,discovered:T,present:[...A.map(d=>d.name),...T.map(d=>d.name)]});function B(d){const N=K.get(d);if(!N)return null;if(N.kind==="managed"){const z=A[N.index];return n.jsx(Xn,{server:z,agentId:e.id,live:R.get(z.name),testResult:m[z.name],rosterUpdatedAt:t.dataUpdatedAt,testing:j===z.name,busy:I,onToggle:E,onTest:M,onRemove:y},z.name)}const w=T[N.index];return n.jsx(ts,{entry:w,agentId:e.id,agentLabel:e.displayName??e.name,canImport:c},w.name)}return n.jsxs("section",{className:"space-y-3","aria-label":"MCP servers",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h3",{className:"text-sm font-semibold",children:"MCP Servers"}),c&&n.jsx(vn,{agentId:e.id,agentLabel:e.displayName??e.name,supportedTransports:ge(e.runtime),onAdded:P,oauthDetectedFor:b&&((q=m[b])==null?void 0:q.result.needsAuth)===!0?b:null})]}),n.jsx(cs,{}),U&&n.jsx(is,{agentId:e.id,agentLabel:e.displayName??e.name}),!c&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"This agent can’t use added servers yet. View only."}),t.isLoading?n.jsx(F,{children:n.jsxs(_,{className:"space-y-2",children:[n.jsx(ne,{className:"h-5 w-full"}),n.jsx(ne,{className:"h-5 w-3/4"})]})}):t.isError?n.jsx(F,{children:n.jsxs(_,{className:"flex items-center justify-between gap-2",children:[n.jsx("p",{className:"text-destructive text-sm",children:"Couldn’t load managed servers."}),n.jsx(f,{variant:"outline",size:"sm",onClick:()=>t.refetch(),className:"focus-visible:ring-2",children:"Try again"})]})}):V.length===0?n.jsx(F,{children:n.jsx(_,{children:n.jsxs("p",{className:"text-muted-foreground text-sm",children:["No MCP servers yet."," ",c?"Add one for more tools.":"This agent can’t use them yet."]})})}):n.jsx(F,{children:n.jsx(_,{children:V.map(B)})})]})}function hs({member:e}){const{agent:s,projectPath:t,isPending:i}=rn(e);return i?n.jsx(ne,{className:"h-32 w-full"}):!s||t===null?n.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t read this agent’s MCP servers."}):n.jsx(ls,{agent:s,projectPath:t})}export{hs as ToolsPage};