@lovelybunch/api 1.0.71-alpha.2 → 1.0.71-alpha.4

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 (235) hide show
  1. package/dist/lib/file-validation.d.ts +65 -0
  2. package/dist/lib/file-validation.js +125 -0
  3. package/dist/middleware/auth.d.ts +1 -0
  4. package/dist/middleware/auth.js +13 -3
  5. package/dist/routes/api/v1/resources/route.js +10 -7
  6. package/package.json +5 -4
  7. package/static/assets/{AgentDetailPage-DwWIjGx1.js → AgentDetailPage-BkWRFbPj.js} +1 -1
  8. package/static/assets/{AgentEditPage-BvVPfYR3.js → AgentEditPage-DN0TouUG.js} +1 -1
  9. package/static/assets/{AgentsPage-D-Uy87Gh.js → AgentsPage-DW6eV7oU.js} +2 -2
  10. package/static/assets/{AgentsSettingsPage-CDuAvFxu.js → AgentsSettingsPage-BJKnn0R0.js} +1 -1
  11. package/static/assets/{ApiKeysSettingsPage-Jug0kB7Z.js → ApiKeysSettingsPage-ChFu9Eo6.js} +1 -1
  12. package/static/assets/{ArchitectureEditPage-BmAgJAMV.js → ArchitectureEditPage-DWrvSS5U.js} +1 -1
  13. package/static/assets/{ArchitecturePage-ZjbdnDA7.js → ArchitecturePage-BdQG779E.js} +1 -1
  14. package/static/assets/{AuthSettingsPage-_pXoewOB.js → AuthSettingsPage-BXMn4xXd.js} +1 -1
  15. package/static/assets/{CallbackPage-CaAOpz4z.js → CallbackPage-AxQqTxCV.js} +1 -1
  16. package/static/assets/{CodePage-DEbgr8C1.js → CodePage-CfKZ52Zo.js} +1 -1
  17. package/static/assets/{CollapsibleSection-msxUBh1L.js → CollapsibleSection-ZFq6LSXW.js} +1 -1
  18. package/static/assets/{DashboardPage-BXu-fikP.js → DashboardPage-Df-d3-fG.js} +1 -1
  19. package/static/assets/{GitPage-B7qFcP-K.js → GitPage-DAWR8rrg.js} +1 -1
  20. package/static/assets/{GitSettingsPage-D7GjdOnE.js → GitSettingsPage-CzGuiY9j.js} +1 -1
  21. package/static/assets/{IdentityPage-BR48gNhN.js → IdentityPage-DbsNwWtP.js} +1 -1
  22. package/static/assets/{ImplementationStepsEditor-BdHMNVVd.js → ImplementationStepsEditor-DZq7KcDP.js} +1 -1
  23. package/static/assets/{IntegrationsSettingsPage-B1OHGlDC.js → IntegrationsSettingsPage-qvvsp1_G.js} +1 -1
  24. package/static/assets/{KnowledgeDetailPage-DBOQQs3R.js → KnowledgeDetailPage-BMnj1qiH.js} +1 -1
  25. package/static/assets/{KnowledgeEditPage-DHJxLPwi.js → KnowledgeEditPage-BZa4E2M9.js} +1 -1
  26. package/static/assets/{KnowledgePage-CuuDTMa_.js → KnowledgePage-Dtq9BKZi.js} +2 -2
  27. package/static/assets/{LoginPage-IIU6NAG9.js → LoginPage-BnlCd8Cm.js} +1 -1
  28. package/static/assets/McpSettingsPage-COPMqimV.js +1 -0
  29. package/static/assets/{NewAgentPage-DolltGy5.js → NewAgentPage-Dtvey1oU.js} +1 -1
  30. package/static/assets/{NewKnowledgePage-_jbUZqBU.js → NewKnowledgePage-CbiRD2V3.js} +1 -1
  31. package/static/assets/{NewProposalPage-bFnfuuoA.js → NewProposalPage-B1tUJIZz.js} +1 -1
  32. package/static/assets/{ProjectEditPage-DTTjPnGj.js → ProjectEditPage-CwM8LXHy.js} +1 -1
  33. package/static/assets/{ProjectPage-DhwrnEq2.js → ProjectPage-BHa8M3vI.js} +1 -1
  34. package/static/assets/{PromptsSettingsPage-DLOVysbE.js → PromptsSettingsPage-CwGmsIAW.js} +1 -1
  35. package/static/assets/{ProposalDetailPage-KvjXUaaf.js → ProposalDetailPage-DC7NMuFi.js} +1 -1
  36. package/static/assets/{ProposalEditPage-BmzkHL9a.js → ProposalEditPage-CfUidv6D.js} +1 -1
  37. package/static/assets/{ProposalsPage-DwQr1ycd.js → ProposalsPage-V8ut_TsU.js} +1 -1
  38. package/static/assets/ResourcesPage-Cofgbx3H.js +66 -0
  39. package/static/assets/{RulesSettingsPage-CsGXFTFY.js → RulesSettingsPage-BJ72X2Y3.js} +1 -1
  40. package/static/assets/{SchedulePage-CY8GdQlp.js → SchedulePage-DBYxTZMb.js} +1 -1
  41. package/static/assets/{TagInput-CbH9zq5n.js → TagInput-Cqju3cXZ.js} +1 -1
  42. package/static/assets/{TerminalPage-DsjOLnyY.js → TerminalPage-Iow1ciWG.js} +1 -1
  43. package/static/assets/{TerminalSessionPage-DQ065WYU.js → TerminalSessionPage-CZdzhFhY.js} +1 -1
  44. package/static/assets/{UserPreferencesPage-55VTrzfQ.js → UserPreferencesPage-CAuJ7yO4.js} +1 -1
  45. package/static/assets/{UserSettingsPage-BZwb93B4.js → UserSettingsPage-0j7ha-RI.js} +1 -1
  46. package/static/assets/{UtilitiesPage-BmEW7eJ_.js → UtilitiesPage-OgkcmaOS.js} +1 -1
  47. package/static/assets/{alert-CNSGDe1U.js → alert-D2VTq6m-.js} +1 -1
  48. package/static/assets/{arrow-down-D1dapxzl.js → arrow-down-vmWOjyjO.js} +1 -1
  49. package/static/assets/{arrow-left-CEZFPQje.js → arrow-left-Do2jUSS9.js} +1 -1
  50. package/static/assets/{arrow-up-D-lB4Ah6.js → arrow-up-hMM1cdZm.js} +1 -1
  51. package/static/assets/{badge-DO6e5hC1.js → badge-D7ZZbMEG.js} +1 -1
  52. package/static/assets/browser-modal-CWDhylx7.js +6 -0
  53. package/static/assets/{calendar-DWaFMSXH.js → calendar-C5JtKp_F.js} +1 -1
  54. package/static/assets/{card-Cnz8b7Ou.js → card-D_zGBKua.js} +1 -1
  55. package/static/assets/{chevron-left-CNgc28Tc.js → chevron-left-JjvWea8A.js} +1 -1
  56. package/static/assets/{circle-alert-Dick-jNf.js → circle-alert-DQD0CPB3.js} +1 -1
  57. package/static/assets/{circle-check-big-B70gdce7.js → circle-check-big-KfJvKA9H.js} +1 -1
  58. package/static/assets/{circle-check-DDk43rYV.js → circle-check-xj41FKuF.js} +1 -1
  59. package/static/assets/{circle-play-TJEfmKde.js → circle-play-BlGnYWUU.js} +1 -1
  60. package/static/assets/{circle-x-BfR2YcXx.js → circle-x-Ds97aY1x.js} +1 -1
  61. package/static/assets/{clipboard-BTZru8wn.js → clipboard-D3NA8gb4.js} +1 -1
  62. package/static/assets/{clock-DQXbrDkQ.js → clock-9dU_D6sL.js} +1 -1
  63. package/static/assets/{download-CW_rWwud.js → download-CNckZYWh.js} +1 -1
  64. package/static/assets/{eye-Bv6mO2ld.js → eye-Dp6wEoME.js} +1 -1
  65. package/static/assets/{folder-git-2-Cv5NbBZZ.js → folder-git-2-B9ILjFN2.js} +1 -1
  66. package/static/assets/{index-BSBM4i_g.js → index-Bbxvuj4b.js} +3 -3
  67. package/static/assets/index-Ca98xZVe.css +2 -0
  68. package/static/assets/{label-vEgNxdb2.js → label-CZGCmBD7.js} +1 -1
  69. package/static/assets/{markdown-editor-O6tGYa1a.js → markdown-editor-BiM9h5iI.js} +1 -1
  70. package/static/assets/{pause-6aQLhmG9.js → pause-BNL49HvB.js} +1 -1
  71. package/static/assets/{play-DsDsjO2V.js → play-8b83f5X0.js} +1 -1
  72. package/static/assets/{plus-BfBtnncn.js → plus-Be79gWKj.js} +1 -1
  73. package/static/assets/{radio-group-D_RD_9vY.js → radio-group-DpxssBzw.js} +1 -1
  74. package/static/assets/{refresh-cw-DvFNtws1.js → refresh-cw-C0_Ot2Zc.js} +1 -1
  75. package/static/assets/registry-ANRa5WBi.js +1 -0
  76. package/static/assets/{search-kcgmZUqQ.js → search-CrIdR7ah.js} +1 -1
  77. package/static/assets/{switch-Bjq8cgQn.js → switch-BYPAX9oF.js} +1 -1
  78. package/static/assets/{tabs-DDbBXbPg.js → tabs-Ug7Ug5Ha.js} +1 -1
  79. package/static/assets/{tag-Czz-3rNY.js → tag-BgO5mxYK.js} +1 -1
  80. package/static/assets/{terminal-preview-B7iP2vUT.js → terminal-preview-CDrLQbSE.js} +1 -1
  81. package/static/assets/{use-terminal-CN3pheMp.js → use-terminal-CNk4WtA6.js} +1 -1
  82. package/static/assets/{zap-BMkP_c9R.js → zap-cD8GAJPg.js} +1 -1
  83. package/static/index.html +2 -2
  84. package/dist/lib/auth/auth-manager.d.ts.map +0 -1
  85. package/dist/lib/auth/auth-manager.js.map +0 -1
  86. package/dist/lib/gait-path.d.ts.map +0 -1
  87. package/dist/lib/gait-path.js.map +0 -1
  88. package/dist/lib/git-settings.d.ts.map +0 -1
  89. package/dist/lib/git-settings.js.map +0 -1
  90. package/dist/lib/git.d.ts.map +0 -1
  91. package/dist/lib/git.js.map +0 -1
  92. package/dist/lib/jobs/global-job-scheduler.d.ts.map +0 -1
  93. package/dist/lib/jobs/global-job-scheduler.js.map +0 -1
  94. package/dist/lib/jobs/job-runner.d.ts.map +0 -1
  95. package/dist/lib/jobs/job-runner.js.map +0 -1
  96. package/dist/lib/jobs/job-scheduler.d.ts.map +0 -1
  97. package/dist/lib/jobs/job-scheduler.js.map +0 -1
  98. package/dist/lib/jobs/job-store.d.ts.map +0 -1
  99. package/dist/lib/jobs/job-store.js.map +0 -1
  100. package/dist/lib/project-paths.d.ts.map +0 -1
  101. package/dist/lib/project-paths.js.map +0 -1
  102. package/dist/lib/storage/file-storage.d.ts.map +0 -1
  103. package/dist/lib/storage/file-storage.js.map +0 -1
  104. package/dist/lib/symlinks/symlink-manager.d.ts.map +0 -1
  105. package/dist/lib/symlinks/symlink-manager.js.map +0 -1
  106. package/dist/lib/symlinks/types.d.ts.map +0 -1
  107. package/dist/lib/symlinks/types.js.map +0 -1
  108. package/dist/lib/terminal/context-helper.d.ts.map +0 -1
  109. package/dist/lib/terminal/context-helper.js.map +0 -1
  110. package/dist/lib/terminal/global-manager.d.ts.map +0 -1
  111. package/dist/lib/terminal/global-manager.js.map +0 -1
  112. package/dist/lib/terminal/shell-utils.d.ts.map +0 -1
  113. package/dist/lib/terminal/shell-utils.js.map +0 -1
  114. package/dist/lib/terminal/terminal-manager.d.ts.map +0 -1
  115. package/dist/lib/terminal/terminal-manager.js.map +0 -1
  116. package/dist/lib/user-preferences.d.ts.map +0 -1
  117. package/dist/lib/user-preferences.js.map +0 -1
  118. package/dist/middleware/auth.d.ts.map +0 -1
  119. package/dist/middleware/auth.js.map +0 -1
  120. package/dist/routes/api/v1/agents/[id]/index.d.ts.map +0 -1
  121. package/dist/routes/api/v1/agents/[id]/index.js.map +0 -1
  122. package/dist/routes/api/v1/agents/[id]/route.d.ts.map +0 -1
  123. package/dist/routes/api/v1/agents/[id]/route.js.map +0 -1
  124. package/dist/routes/api/v1/agents/index.d.ts.map +0 -1
  125. package/dist/routes/api/v1/agents/index.js.map +0 -1
  126. package/dist/routes/api/v1/agents/route.d.ts.map +0 -1
  127. package/dist/routes/api/v1/agents/route.js.map +0 -1
  128. package/dist/routes/api/v1/ai/index.d.ts.map +0 -1
  129. package/dist/routes/api/v1/ai/index.js.map +0 -1
  130. package/dist/routes/api/v1/ai/route.d.ts.map +0 -1
  131. package/dist/routes/api/v1/ai/route.js.map +0 -1
  132. package/dist/routes/api/v1/api-keys/index.d.ts.map +0 -1
  133. package/dist/routes/api/v1/api-keys/index.js.map +0 -1
  134. package/dist/routes/api/v1/api-keys/route.d.ts.map +0 -1
  135. package/dist/routes/api/v1/api-keys/route.js.map +0 -1
  136. package/dist/routes/api/v1/auth/index.d.ts.map +0 -1
  137. package/dist/routes/api/v1/auth/index.js.map +0 -1
  138. package/dist/routes/api/v1/auth/route.d.ts.map +0 -1
  139. package/dist/routes/api/v1/auth/route.js.map +0 -1
  140. package/dist/routes/api/v1/auth-settings/index.d.ts.map +0 -1
  141. package/dist/routes/api/v1/auth-settings/index.js.map +0 -1
  142. package/dist/routes/api/v1/auth-settings/route.d.ts.map +0 -1
  143. package/dist/routes/api/v1/auth-settings/route.js.map +0 -1
  144. package/dist/routes/api/v1/chats/[id]/index.d.ts.map +0 -1
  145. package/dist/routes/api/v1/chats/[id]/index.js.map +0 -1
  146. package/dist/routes/api/v1/chats/[id]/route.d.ts.map +0 -1
  147. package/dist/routes/api/v1/chats/[id]/route.js.map +0 -1
  148. package/dist/routes/api/v1/chats/index.d.ts.map +0 -1
  149. package/dist/routes/api/v1/chats/index.js.map +0 -1
  150. package/dist/routes/api/v1/chats/route.d.ts.map +0 -1
  151. package/dist/routes/api/v1/chats/route.js.map +0 -1
  152. package/dist/routes/api/v1/config/index.d.ts.map +0 -1
  153. package/dist/routes/api/v1/config/index.js.map +0 -1
  154. package/dist/routes/api/v1/config/route.d.ts.map +0 -1
  155. package/dist/routes/api/v1/config/route.js.map +0 -1
  156. package/dist/routes/api/v1/context/architecture/route.d.ts.map +0 -1
  157. package/dist/routes/api/v1/context/architecture/route.js.map +0 -1
  158. package/dist/routes/api/v1/context/index.d.ts.map +0 -1
  159. package/dist/routes/api/v1/context/index.js.map +0 -1
  160. package/dist/routes/api/v1/context/knowledge/[filename]/index.d.ts.map +0 -1
  161. package/dist/routes/api/v1/context/knowledge/[filename]/index.js.map +0 -1
  162. package/dist/routes/api/v1/context/knowledge/[filename]/route.d.ts.map +0 -1
  163. package/dist/routes/api/v1/context/knowledge/[filename]/route.js.map +0 -1
  164. package/dist/routes/api/v1/context/knowledge/index.d.ts.map +0 -1
  165. package/dist/routes/api/v1/context/knowledge/index.js.map +0 -1
  166. package/dist/routes/api/v1/context/knowledge/route.d.ts.map +0 -1
  167. package/dist/routes/api/v1/context/knowledge/route.js.map +0 -1
  168. package/dist/routes/api/v1/context/project/route.d.ts.map +0 -1
  169. package/dist/routes/api/v1/context/project/route.js.map +0 -1
  170. package/dist/routes/api/v1/git/index.d.ts.map +0 -1
  171. package/dist/routes/api/v1/git/index.js.map +0 -1
  172. package/dist/routes/api/v1/jobs/[id]/route.d.ts.map +0 -1
  173. package/dist/routes/api/v1/jobs/[id]/route.js.map +0 -1
  174. package/dist/routes/api/v1/jobs/[id]/run/route.d.ts.map +0 -1
  175. package/dist/routes/api/v1/jobs/[id]/run/route.js.map +0 -1
  176. package/dist/routes/api/v1/jobs/index.d.ts.map +0 -1
  177. package/dist/routes/api/v1/jobs/index.js.map +0 -1
  178. package/dist/routes/api/v1/jobs/route.d.ts.map +0 -1
  179. package/dist/routes/api/v1/jobs/route.js.map +0 -1
  180. package/dist/routes/api/v1/jobs/status/route.d.ts.map +0 -1
  181. package/dist/routes/api/v1/jobs/status/route.js.map +0 -1
  182. package/dist/routes/api/v1/mcp/index.d.ts.map +0 -1
  183. package/dist/routes/api/v1/mcp/index.js.map +0 -1
  184. package/dist/routes/api/v1/mcp/route.d.ts.map +0 -1
  185. package/dist/routes/api/v1/mcp/route.js.map +0 -1
  186. package/dist/routes/api/v1/proposals/[id]/route.d.ts.map +0 -1
  187. package/dist/routes/api/v1/proposals/[id]/route.js.map +0 -1
  188. package/dist/routes/api/v1/proposals/index.d.ts.map +0 -1
  189. package/dist/routes/api/v1/proposals/index.js.map +0 -1
  190. package/dist/routes/api/v1/proposals/route.d.ts.map +0 -1
  191. package/dist/routes/api/v1/proposals/route.js.map +0 -1
  192. package/dist/routes/api/v1/resources/[id]/index.d.ts.map +0 -1
  193. package/dist/routes/api/v1/resources/[id]/index.js.map +0 -1
  194. package/dist/routes/api/v1/resources/[id]/route.js.map +0 -1
  195. package/dist/routes/api/v1/resources/[id]/thumbnail/index.d.ts.map +0 -1
  196. package/dist/routes/api/v1/resources/[id]/thumbnail/index.js.map +0 -1
  197. package/dist/routes/api/v1/resources/[id]/thumbnail/route.js.map +0 -1
  198. package/dist/routes/api/v1/resources/index.d.ts.map +0 -1
  199. package/dist/routes/api/v1/resources/index.js.map +0 -1
  200. package/dist/routes/api/v1/resources/route.d.ts.map +0 -1
  201. package/dist/routes/api/v1/resources/route.js.map +0 -1
  202. package/dist/routes/api/v1/symlinks/index.d.ts.map +0 -1
  203. package/dist/routes/api/v1/symlinks/index.js.map +0 -1
  204. package/dist/routes/api/v1/symlinks/route.d.ts.map +0 -1
  205. package/dist/routes/api/v1/symlinks/route.js.map +0 -1
  206. package/dist/routes/api/v1/terminal/[proposalId]/create/index.d.ts.map +0 -1
  207. package/dist/routes/api/v1/terminal/[proposalId]/create/index.js.map +0 -1
  208. package/dist/routes/api/v1/terminal/[proposalId]/create/route.d.ts.map +0 -1
  209. package/dist/routes/api/v1/terminal/[proposalId]/create/route.js.map +0 -1
  210. package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.d.ts.map +0 -1
  211. package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.js.map +0 -1
  212. package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.d.ts.map +0 -1
  213. package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.js.map +0 -1
  214. package/dist/routes/api/v1/terminal/[proposalId]/resize/index.d.ts.map +0 -1
  215. package/dist/routes/api/v1/terminal/[proposalId]/resize/index.js.map +0 -1
  216. package/dist/routes/api/v1/terminal/[proposalId]/resize/route.d.ts.map +0 -1
  217. package/dist/routes/api/v1/terminal/[proposalId]/resize/route.js.map +0 -1
  218. package/dist/routes/api/v1/terminal/sessions/index.d.ts.map +0 -1
  219. package/dist/routes/api/v1/terminal/sessions/index.js.map +0 -1
  220. package/dist/routes/api/v1/terminal/sessions/route.d.ts.map +0 -1
  221. package/dist/routes/api/v1/terminal/sessions/route.js.map +0 -1
  222. package/dist/routes/api/v1/user/index.d.ts.map +0 -1
  223. package/dist/routes/api/v1/user/index.js.map +0 -1
  224. package/dist/routes/api/v1/user/settings/index.d.ts.map +0 -1
  225. package/dist/routes/api/v1/user/settings/index.js.map +0 -1
  226. package/dist/routes/api/v1/user/settings/route.d.ts.map +0 -1
  227. package/dist/routes/api/v1/user/settings/route.js.map +0 -1
  228. package/dist/server-with-static.d.ts.map +0 -1
  229. package/dist/server-with-static.js.map +0 -1
  230. package/dist/server.d.ts.map +0 -1
  231. package/dist/server.js.map +0 -1
  232. package/static/assets/McpSettingsPage-iz5gLGWt.js +0 -1
  233. package/static/assets/ResourcesPage-B8Hm_j47.js +0 -66
  234. package/static/assets/browser-modal-BTxVvZIA.js +0 -6
  235. package/static/assets/index-CKwmN6yL.css +0 -2
@@ -1,2 +1,2 @@
1
- import{u as ce,H as de,r as i,j as e,B as r,k as oe,a3 as me,q as xe,s as M,X as he,g as ue,J as fe,D as ge,a as je,b as pe,d as ve,v as Ne,w as ye,x as we,y as Ce,z as S,i as Se,a5 as R,a6 as B,a7 as H,a8 as L,a9 as O,ae as G,h as be,a0 as Ae,A as I}from"./index-BSBM4i_g.js";import{C as p,b as ke,a as _,c as De}from"./card-Cnz8b7Ou.js";import{B as U}from"./badge-DO6e5hC1.js";import{u as Me}from"./use-terminal-CN3pheMp.js";import{C as Ie,a as $e,T as Pe}from"./terminal-preview-B7iP2vUT.js";import{b as Te,d as Ee,c as ze,a as Fe}from"./droid-CmYuCN_q.js";import{R as Re}from"./refresh-cw-DvFNtws1.js";import{P as Be}from"./play-DsDsjO2V.js";import"./xterm-DTxiCjtJ.js";const He=c=>c?Array.isArray(c)?c.filter(x=>typeof x=="string").map(x=>x.trim()).filter(Boolean):typeof c=="string"?c.split(",").map(x=>x.trim()).filter(Boolean):[]:[];function Xe(){const c=ce(),{sessions:x,loading:b,error:$,refreshSessions:w,createSession:V,destroySession:q}=Me(),{toast:v}=de(),[P,W]=i.useState([]),[J,X]=i.useState(!0),[g,A]=i.useState(()=>({})),[k,N]=i.useState(!1),[j,K]=i.useState("claude"),[T,Q]=i.useState(""),[D,E]=i.useState(!1),[h,Y]=i.useState([]),[f,y]=i.useState([]),[Z,ee]=i.useState({}),[u,se]=i.useState([]),[o,C]=i.useState([]),te=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const d=Math.floor(n/60);if(d<60)return`${d}m ago`;const l=Math.floor(d/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`};i.useEffect(()=>{(async()=>{try{const t=await fetch(`${I}/api/v1/proposals`);if(t.ok){const a=await t.json(),n=a.data||a;W(Array.isArray(n)?n:[])}}catch(t){console.error("Error loading proposals:",t)}finally{X(!1)}})()},[]),i.useEffect(()=>{w()},[w]),i.useEffect(()=>{if(!k)return;(async()=>{try{const t=await fetch(`${I}/api/v1/mcp`);if(t.ok){const a=await t.json();a?.success&&Array.isArray(a.servers)&&(Y(a.servers),y(n=>n.filter(d=>a.servers.includes(d))),a.mcpServers&&typeof a.mcpServers=="object"&&ee(a.mcpServers))}}catch(t){console.error("Failed to load MCP servers",t)}try{const t=await fetch(`${I}/api/v1/agents`);if(t.ok){const a=await t.json(),d=(Array.isArray(a?.documents)?a.documents:[]).map(l=>({id:l.filename,name:l?.metadata?.name||l.title||l.filename,tools:He(l?.metadata?.tools)}));se(d),C(l=>l.filter(F=>d.some(re=>re.id===F)))}}catch(t){console.error("Failed to load agents",t)}})()},[k]),i.useEffect(()=>{o.length!==0&&y(s=>{const t=new Set(s),a=h.length>0?new Set(h):void 0;return o.forEach(n=>{const d=u.find(l=>l.id===n);d&&d.tools.forEach(l=>{(!a||a.has(l))&&t.add(l)})}),Array.from(t)})},[o,u,h]);const m=i.useMemo(()=>x.filter(s=>s.proposalId?.startsWith("cp-")||s.proposalId?.startsWith("ag-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[x]);i.useEffect(()=>{A(s=>{const t={...s};return m.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[m]);const z=i.useMemo(()=>P.filter(s=>s.status==="draft"||s.status==="approved").sort((s,t)=>new Date(t.metadata.createdAt).getTime()-new Date(s.metadata.createdAt).getTime()).slice(0,3),[P]),ae=()=>{const s=m.every(a=>g[a.id]),t={};m.forEach(a=>{t[a.id]=!s}),A(t)},ie=m.length>0&&m.every(s=>g[s.id]),ne=async s=>{await q(s)?(v({title:"Session closed",description:s}),setTimeout(()=>w(),100)):v({title:"Failed to close session",description:s,variant:"destructive"})},le=async()=>{E(!0);try{const s=`cp-${Date.now()}`,t={proposalId:s,contextType:"change-proposal",cliAgent:j,mcpServersMap:Z,selectedMcpServers:f,agents:u,selectedAgentIds:o,automationEnabled:!1,customInstruction:T.trim(),includeDefaultInstructions:!1};let a="";j==="claude"?a=Te(t):j==="gemini"?a=Ee(t):j==="codex"?a=ze(t):j==="droid"&&(a=Fe(t)),await V(s,!1,a)?(v({title:"Coding session started",description:`Session ${s} created`}),N(!1),c(`/terminal/${s}`)):v({title:"Failed to start session",description:"Could not create terminal session",variant:"destructive"})}catch(s){console.error("Error starting coding session:",s),v({title:"Error",description:"Failed to start coding session",variant:"destructive"})}finally{E(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Code"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Terminal sessions and coding agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>w(),disabled:b,children:[e.jsx(Re,{className:`h-4 w-4 sm:mr-2 ${b?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),m.length>0&&e.jsx(r,{variant:"outline",size:"sm",onClick:ae,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx($e,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{size:"sm",onClick:()=>N(!0),children:[e.jsx(Be,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Interactive Session"})]})]})]}),$&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:$})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),b?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(p,{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):m.length===0?e.jsx(p,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(oe,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching an"," ",e.jsx("button",{onClick:()=>N(!0),className:"text-primary hover:underline font-medium",children:"Interactive Session"})," ","or working on a"," ",e.jsx("button",{onClick:()=>c("/proposals"),className:"text-primary hover:underline font-medium",children:"Change Proposal"})]})]})]})}):e.jsx("div",{className:"space-y-2",children:m.slice(0,10).map(s=>e.jsxs(p,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(me,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:s.proposalId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",te(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{A(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":g[s.id]?"Hide preview":"Show preview",title:g[s.id]?"Hide preview":"Show preview",children:g[s.id]?e.jsx(xe,{className:"h-4 w-4"}):e.jsx(M,{className:"h-4 w-4"})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>c(`/terminal/${s.proposalId}`),children:"Open"}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>ne(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(he,{className:"h-4 w-4"})})]})]}),g[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>c(`/terminal/${s.proposalId}`),title:"Click to open full terminal session",children:e.jsx(Pe,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Recent Proposals"}),J?e.jsx("div",{className:"space-y-3",children:[...Array(3)].map((s,t)=>e.jsx(p,{children:e.jsx(ke,{className:"py-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 animate-pulse"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/3 animate-pulse"})]}),e.jsx("div",{className:"h-5 bg-muted rounded w-16 animate-pulse"})]})})},t))}):z.length===0?e.jsx(p,{children:e.jsx(_,{className:"flex items-center justify-center py-6",children:e.jsx("div",{className:"text-center text-sm text-gray-500",children:"No draft or approved proposals found"})})}):e.jsx("div",{className:"space-y-2",children:z.map(s=>e.jsx(p,{className:"hover:shadow-md transition-all cursor-pointer hover:border-primary/50",onClick:()=>c(`/terminal/${s.id}`),children:e.jsx(_,{className:"py-4",children:e.jsx("div",{className:"flex justify-between items-start gap-4",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(De,{className:"text-base leading-tight",children:s.intent}),e.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[s.priority&&e.jsx(U,{variant:s.priority==="high"||s.priority==="critical"?"destructive":s.priority==="medium"?"secondary":"outline",className:"text-xs",children:s.priority}),e.jsx(U,{variant:"default",className:"text-xs",children:s.status})]})]}),s.content&&e.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[s.content.split(`
1
+ import{u as ce,H as de,r as i,j as e,B as r,k as oe,a3 as me,q as xe,s as M,X as he,g as ue,J as fe,D as ge,a as je,b as pe,d as ve,v as Ne,w as ye,x as we,y as Ce,z as S,i as Se,a5 as R,a6 as B,a7 as H,a8 as L,a9 as O,ae as G,h as be,a0 as Ae,A as I}from"./index-Bbxvuj4b.js";import{C as p,b as ke,a as _,c as De}from"./card-D_zGBKua.js";import{B as U}from"./badge-D7ZZbMEG.js";import{u as Me}from"./use-terminal-CNk4WtA6.js";import{C as Ie,a as $e,T as Pe}from"./terminal-preview-CDrLQbSE.js";import{b as Te,d as Ee,c as ze,a as Fe}from"./droid-CmYuCN_q.js";import{R as Re}from"./refresh-cw-C0_Ot2Zc.js";import{P as Be}from"./play-8b83f5X0.js";import"./xterm-DTxiCjtJ.js";const He=c=>c?Array.isArray(c)?c.filter(x=>typeof x=="string").map(x=>x.trim()).filter(Boolean):typeof c=="string"?c.split(",").map(x=>x.trim()).filter(Boolean):[]:[];function Xe(){const c=ce(),{sessions:x,loading:b,error:$,refreshSessions:w,createSession:V,destroySession:q}=Me(),{toast:v}=de(),[P,W]=i.useState([]),[J,X]=i.useState(!0),[g,A]=i.useState(()=>({})),[k,N]=i.useState(!1),[j,K]=i.useState("claude"),[T,Q]=i.useState(""),[D,E]=i.useState(!1),[h,Y]=i.useState([]),[f,y]=i.useState([]),[Z,ee]=i.useState({}),[u,se]=i.useState([]),[o,C]=i.useState([]),te=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const d=Math.floor(n/60);if(d<60)return`${d}m ago`;const l=Math.floor(d/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`};i.useEffect(()=>{(async()=>{try{const t=await fetch(`${I}/api/v1/proposals`);if(t.ok){const a=await t.json(),n=a.data||a;W(Array.isArray(n)?n:[])}}catch(t){console.error("Error loading proposals:",t)}finally{X(!1)}})()},[]),i.useEffect(()=>{w()},[w]),i.useEffect(()=>{if(!k)return;(async()=>{try{const t=await fetch(`${I}/api/v1/mcp`);if(t.ok){const a=await t.json();a?.success&&Array.isArray(a.servers)&&(Y(a.servers),y(n=>n.filter(d=>a.servers.includes(d))),a.mcpServers&&typeof a.mcpServers=="object"&&ee(a.mcpServers))}}catch(t){console.error("Failed to load MCP servers",t)}try{const t=await fetch(`${I}/api/v1/agents`);if(t.ok){const a=await t.json(),d=(Array.isArray(a?.documents)?a.documents:[]).map(l=>({id:l.filename,name:l?.metadata?.name||l.title||l.filename,tools:He(l?.metadata?.tools)}));se(d),C(l=>l.filter(F=>d.some(re=>re.id===F)))}}catch(t){console.error("Failed to load agents",t)}})()},[k]),i.useEffect(()=>{o.length!==0&&y(s=>{const t=new Set(s),a=h.length>0?new Set(h):void 0;return o.forEach(n=>{const d=u.find(l=>l.id===n);d&&d.tools.forEach(l=>{(!a||a.has(l))&&t.add(l)})}),Array.from(t)})},[o,u,h]);const m=i.useMemo(()=>x.filter(s=>s.proposalId?.startsWith("cp-")||s.proposalId?.startsWith("ag-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[x]);i.useEffect(()=>{A(s=>{const t={...s};return m.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[m]);const z=i.useMemo(()=>P.filter(s=>s.status==="draft"||s.status==="approved").sort((s,t)=>new Date(t.metadata.createdAt).getTime()-new Date(s.metadata.createdAt).getTime()).slice(0,3),[P]),ae=()=>{const s=m.every(a=>g[a.id]),t={};m.forEach(a=>{t[a.id]=!s}),A(t)},ie=m.length>0&&m.every(s=>g[s.id]),ne=async s=>{await q(s)?(v({title:"Session closed",description:s}),setTimeout(()=>w(),100)):v({title:"Failed to close session",description:s,variant:"destructive"})},le=async()=>{E(!0);try{const s=`cp-${Date.now()}`,t={proposalId:s,contextType:"change-proposal",cliAgent:j,mcpServersMap:Z,selectedMcpServers:f,agents:u,selectedAgentIds:o,automationEnabled:!1,customInstruction:T.trim(),includeDefaultInstructions:!1};let a="";j==="claude"?a=Te(t):j==="gemini"?a=Ee(t):j==="codex"?a=ze(t):j==="droid"&&(a=Fe(t)),await V(s,!1,a)?(v({title:"Coding session started",description:`Session ${s} created`}),N(!1),c(`/terminal/${s}`)):v({title:"Failed to start session",description:"Could not create terminal session",variant:"destructive"})}catch(s){console.error("Error starting coding session:",s),v({title:"Error",description:"Failed to start coding session",variant:"destructive"})}finally{E(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Code"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Terminal sessions and coding agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>w(),disabled:b,children:[e.jsx(Re,{className:`h-4 w-4 sm:mr-2 ${b?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),m.length>0&&e.jsx(r,{variant:"outline",size:"sm",onClick:ae,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx($e,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{size:"sm",onClick:()=>N(!0),children:[e.jsx(Be,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Interactive Session"})]})]})]}),$&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:$})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),b?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(p,{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):m.length===0?e.jsx(p,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(oe,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching an"," ",e.jsx("button",{onClick:()=>N(!0),className:"text-primary hover:underline font-medium",children:"Interactive Session"})," ","or working on a"," ",e.jsx("button",{onClick:()=>c("/proposals"),className:"text-primary hover:underline font-medium",children:"Change Proposal"})]})]})]})}):e.jsx("div",{className:"space-y-2",children:m.slice(0,10).map(s=>e.jsxs(p,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(me,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:s.proposalId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",te(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{A(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":g[s.id]?"Hide preview":"Show preview",title:g[s.id]?"Hide preview":"Show preview",children:g[s.id]?e.jsx(xe,{className:"h-4 w-4"}):e.jsx(M,{className:"h-4 w-4"})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>c(`/terminal/${s.proposalId}`),children:"Open"}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>ne(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(he,{className:"h-4 w-4"})})]})]}),g[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>c(`/terminal/${s.proposalId}`),title:"Click to open full terminal session",children:e.jsx(Pe,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Recent Proposals"}),J?e.jsx("div",{className:"space-y-3",children:[...Array(3)].map((s,t)=>e.jsx(p,{children:e.jsx(ke,{className:"py-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 animate-pulse"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/3 animate-pulse"})]}),e.jsx("div",{className:"h-5 bg-muted rounded w-16 animate-pulse"})]})})},t))}):z.length===0?e.jsx(p,{children:e.jsx(_,{className:"flex items-center justify-center py-6",children:e.jsx("div",{className:"text-center text-sm text-gray-500",children:"No draft or approved proposals found"})})}):e.jsx("div",{className:"space-y-2",children:z.map(s=>e.jsx(p,{className:"hover:shadow-md transition-all cursor-pointer hover:border-primary/50",onClick:()=>c(`/terminal/${s.id}`),children:e.jsx(_,{className:"py-4",children:e.jsx("div",{className:"flex justify-between items-start gap-4",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(De,{className:"text-base leading-tight",children:s.intent}),e.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[s.priority&&e.jsx(U,{variant:s.priority==="high"||s.priority==="critical"?"destructive":s.priority==="medium"?"secondary":"outline",className:"text-xs",children:s.priority}),e.jsx(U,{variant:"default",className:"text-xs",children:s.status})]})]}),s.content&&e.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[s.content.split(`
2
2
  `).slice(0,2).join(" ").substring(0,150),s.content.length>150?"...":""]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.id," • by ",s.author.name," • ",new Date(s.metadata.createdAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex gap-2",onClick:t=>t.stopPropagation(),children:[e.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>c(`/proposals/${s.id}`),className:"h-7 px-2 text-xs",children:[e.jsx(ue,{className:"h-3 w-3 mr-1"})," View"]}),e.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>c(`/proposals/${s.id}/edit`),className:"h-7 px-2 text-xs",children:[e.jsx(fe,{className:"h-3 w-3 mr-1"})," Edit"]})]})]})]})})})},s.id))})]}),e.jsx(ge,{open:k,onOpenChange:N,children:e.jsxs(je,{className:"max-w-lg",children:[e.jsxs(pe,{children:[e.jsx(ve,{children:"Start Coding Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Start an interactive coding session"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Coding Agent"}),e.jsxs(Ne,{value:j,onValueChange:s=>K(s),children:[e.jsx(ye,{className:"w-full",children:e.jsx(we,{placeholder:"Select coding agent"})}),e.jsxs(Ce,{children:[e.jsx(S,{value:"claude",children:"Claude Code"}),e.jsx(S,{value:"gemini",children:"Google Gemini"}),e.jsx(S,{value:"codex",children:"OpenAI Codex"}),e.jsx(S,{value:"droid",children:"Factory Droid"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Se,{className:"h-4 w-4"}),"Custom Agents"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[o.length," of ",u.length," selected"]})]}),e.jsxs(R,{children:[e.jsx(B,{asChild:!0,children:e.jsxs(r,{variant:"outline",className:"w-full justify-between",children:[o.length===0?"Select agents...":o.length===u.length?"All agents selected":`${o.length} agent${o.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(H,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(L,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Agents"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),C(u.map(t=>t.id))},children:"All"}),e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),C([])},children:"None"})]})]}),e.jsx(O,{}),u.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No agents found"}):u.map(s=>e.jsx(G,{checked:o.includes(s.id),onCheckedChange:t=>{C(a=>t?a.includes(s.id)?a:[...a,s.id]:a.filter(n=>n!==s.id))},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:s.name}),s.tools.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP servers: ",s.tools.join(", ")]}),s.tools.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inherits available MCP servers"})]})},s.id))]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4"}),"MCP Servers"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[f.length," of ",h.length," selected"]})]}),e.jsxs(R,{children:[e.jsx(B,{asChild:!0,children:e.jsxs(r,{variant:"outline",className:"w-full justify-between",children:[f.length===0?"Select MCP servers...":f.length===h.length?"All servers selected":`${f.length} server${f.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(H,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(L,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Servers"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y(h)},children:"All"}),e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y([])},children:"None"})]})]}),e.jsx(O,{}),h.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No MCP servers found"}):h.map(s=>e.jsx(G,{checked:f.includes(s),onCheckedChange:t=>{y(a=>t?a.includes(s)?a:[...a,s]:a.filter(n=>n!==s))},children:s},s))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Additional Instructions (optional)"}),e.jsx(Ae,{value:T,onChange:s=>Q(s.target.value),placeholder:"Add any custom instructions for the coding agent...",rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(r,{variant:"outline",onClick:()=>N(!1),disabled:D,children:"Cancel"}),e.jsx(r,{onClick:le,disabled:D,children:D?"Starting...":"Start Session"})]})]})]})})]})}export{Xe as default};
@@ -1 +1 @@
1
- import{r as x,j as e,f as a,s as m}from"./index-BSBM4i_g.js";function u({title:r,description:t,icon:n,defaultOpen:o=!1,children:i,className:l}){const[s,d]=x.useState(o);return e.jsxs("div",{className:a("rounded-lg border bg-card text-card-foreground",l),children:[e.jsxs("button",{type:"button",onClick:()=>d(c=>!c),className:"flex w-full items-center justify-between gap-4 px-4 py-3 text-left","aria-expanded":s,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[n,e.jsxs("div",{children:[e.jsx("p",{className:"font-medium leading-tight",children:r}),t&&e.jsx("p",{className:"text-sm text-muted-foreground leading-snug",children:t})]})]}),e.jsx(m,{className:a("h-4 w-4 shrink-0 transition-transform duration-200",s?"rotate-180":"rotate-0")})]}),s&&e.jsx("div",{className:"border-t px-4 py-4",children:i})]})}export{u as C};
1
+ import{r as x,j as e,f as a,s as m}from"./index-Bbxvuj4b.js";function u({title:r,description:t,icon:n,defaultOpen:o=!1,children:i,className:l}){const[s,d]=x.useState(o);return e.jsxs("div",{className:a("rounded-lg border bg-card text-card-foreground",l),children:[e.jsxs("button",{type:"button",onClick:()=>d(c=>!c),className:"flex w-full items-center justify-between gap-4 px-4 py-3 text-left","aria-expanded":s,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[n,e.jsxs("div",{children:[e.jsx("p",{className:"font-medium leading-tight",children:r}),t&&e.jsx("p",{className:"text-sm text-muted-foreground leading-snug",children:t})]})]}),e.jsx(m,{className:a("h-4 w-4 shrink-0 transition-transform duration-200",s?"rotate-180":"rotate-0")})]}),s&&e.jsx("div",{className:"border-t px-4 py-4",children:i})]})}export{u as C};
@@ -1,4 +1,4 @@
1
- import{c as W,j as e,r as m,D as q,a as B,F as N,b as S,d as A,e as P,f as I,S as z,B as r,C as D,L as n,g as L,h as F,i as M,k as T,A as E}from"./index-BSBM4i_g.js";import{C as c,a as l,b as f,c as j,d as R}from"./card-Cnz8b7Ou.js";import{B as Y}from"./badge-DO6e5hC1.js";import{F as _}from"./folder-git-2-Cv5NbBZZ.js";import{C as H}from"./calendar-DWaFMSXH.js";import{C as G}from"./circle-check-DDk43rYV.js";import{C as $}from"./chevron-left-CNgc28Tc.js";import{C as O}from"./clock-DQXbrDkQ.js";import{C as V}from"./circle-check-big-B70gdce7.js";import{P as U}from"./plus-BfBtnncn.js";/**
1
+ import{c as W,j as e,r as m,D as q,a as B,F as N,b as S,d as A,e as P,f as I,S as z,B as r,C as D,L as n,g as L,h as F,i as M,k as T,A as E}from"./index-Bbxvuj4b.js";import{C as c,a as l,b as f,c as j,d as R}from"./card-D_zGBKua.js";import{B as Y}from"./badge-D7ZZbMEG.js";import{F as _}from"./folder-git-2-B9ILjFN2.js";import{C as H}from"./calendar-C5JtKp_F.js";import{C as G}from"./circle-check-xj41FKuF.js";import{C as $}from"./chevron-left-JjvWea8A.js";import{C as O}from"./clock-9dU_D6sL.js";import{C as V}from"./circle-check-big-KfJvKA9H.js";import{P as U}from"./plus-Be79gWKj.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as le,A as l,bd as ws,r as n,H as vs,ag as ys,j as e,L as ee,ad as Fe,B as o,G as D,ac as Ns,X as Cs,I as k,q as Me,s as Be,T as Oe,D as se,a as te,b as ae,d as re,e as ne,aY as ks,$ as Re}from"./index-BSBM4i_g.js";import{C as ie}from"./card-Cnz8b7Ou.js";import{L as Ge}from"./label-vEgNxdb2.js";import{T as Ss,a as Ts,b as We,c as ze}from"./tabs-DDbBXbPg.js";import{C as Ps}from"./circle-check-DDk43rYV.js";import{C as As}from"./circle-x-BfR2YcXx.js";import{A as Ds}from"./arrow-down-D1dapxzl.js";import{A as $s}from"./arrow-up-D-lB4Ah6.js";import{R as Ue}from"./refresh-cw-DvFNtws1.js";import{C as ce}from"./circle-alert-Dick-jNf.js";import{F as oe}from"./folder-git-2-Cv5NbBZZ.js";/**
1
+ import{c as le,A as l,bd as ws,r as n,H as vs,ag as ys,j as e,L as ee,ad as Fe,B as o,G as D,ac as Ns,X as Cs,I as k,q as Me,s as Be,T as Oe,D as se,a as te,b as ae,d as re,e as ne,aY as ks,$ as Re}from"./index-Bbxvuj4b.js";import{C as ie}from"./card-D_zGBKua.js";import{L as Ge}from"./label-CZGCmBD7.js";import{T as Ss,a as Ts,b as We,c as ze}from"./tabs-Ug7Ug5Ha.js";import{C as Ps}from"./circle-check-xj41FKuF.js";import{C as As}from"./circle-x-Ds97aY1x.js";import{A as Ds}from"./arrow-down-vmWOjyjO.js";import{A as $s}from"./arrow-up-hMM1cdZm.js";import{R as Ue}from"./refresh-cw-C0_Ot2Zc.js";import{C as ce}from"./circle-alert-DQD0CPB3.js";import{F as oe}from"./folder-git-2-B9ILjFN2.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as Ae,r,H as He,A as u,j as e,a1 as he,aq as xe,B as o,T as Fe,n as De,aY as ze,I as U,D as W,a as q,b as B,d as J,e as K,$ as Y}from"./index-BSBM4i_g.js";import{C as pe,b as ge,c as fe,d as be,a as je}from"./card-Cnz8b7Ou.js";import{L as f}from"./label-vEgNxdb2.js";import{R as Me,a as ve}from"./radio-group-D_RD_9vY.js";import{R as T}from"./refresh-cw-DvFNtws1.js";import{C as Oe}from"./circle-check-DDk43rYV.js";import{C as Ie}from"./circle-x-BfR2YcXx.js";/**
1
+ import{c as Ae,r,H as He,A as u,j as e,a1 as he,aq as xe,B as o,T as Fe,n as De,aY as ze,I as U,D as W,a as q,b as B,d as J,e as K,$ as Y}from"./index-Bbxvuj4b.js";import{C as pe,b as ge,c as fe,d as be,a as je}from"./card-D_zGBKua.js";import{L as f}from"./label-CZGCmBD7.js";import{R as Me,a as ve}from"./radio-group-DpxssBzw.js";import{R as T}from"./refresh-cw-C0_Ot2Zc.js";import{C as Oe}from"./circle-check-xj41FKuF.js";import{C as Ie}from"./circle-x-Ds97aY1x.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as oe,H as ve,r as u,j as e,n as se,B as x,a2 as fe,Z as Ne,aV as Te,aW as Ce,I as c,a0 as O,ac as ae,a1 as ne,T as be,v as Se,w as we,x as Ae,y as ke,z as Ie,A as ie}from"./index-BSBM4i_g.js";import{C as y,b as g,c as j,d as v,a as f,e as Oe}from"./card-Cnz8b7Ou.js";import{L as o}from"./label-vEgNxdb2.js";import{B as re}from"./badge-DO6e5hC1.js";import{A as Fe,a as Pe}from"./alert-CNSGDe1U.js";import{T as Ee,a as Me,b,c as S}from"./tabs-DDbBXbPg.js";import{Z as Le}from"./zap-BMkP_c9R.js";import{E as De}from"./eye-Bv6mO2ld.js";import{P as E}from"./plus-BfBtnncn.js";import{C as _e,a as Ue}from"./clipboard-BTZru8wn.js";/**
1
+ import{c as oe,H as ve,r as u,j as e,n as se,B as x,a2 as fe,Z as Ne,aV as Te,aW as Ce,I as c,a0 as O,ac as ae,a1 as ne,T as be,v as Se,w as we,x as Ae,y as ke,z as Ie,A as ie}from"./index-Bbxvuj4b.js";import{C as y,b as g,c as j,d as v,a as f,e as Oe}from"./card-D_zGBKua.js";import{L as o}from"./label-CZGCmBD7.js";import{B as re}from"./badge-D7ZZbMEG.js";import{A as Fe,a as Pe}from"./alert-D2VTq6m-.js";import{T as Ee,a as Me,b,c as S}from"./tabs-Ug7Ug5Ha.js";import{Z as Le}from"./zap-cD8GAJPg.js";import{E as De}from"./eye-Dp6wEoME.js";import{P as E}from"./plus-Be79gWKj.js";import{C as _e,a as Ue}from"./clipboard-D3NA8gb4.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as u,j as e,f as p,B as r,T as x,I as j,v,w as y,x as S,y as f,z as g}from"./index-BSBM4i_g.js";import{L as c}from"./label-vEgNxdb2.js";import{P as b}from"./plus-BfBtnncn.js";/**
1
+ import{c as u,j as e,f as p,B as r,T as x,I as j,v,w as y,x as S,y as f,z as g}from"./index-Bbxvuj4b.js";import{L as c}from"./label-CZGCmBD7.js";import{P as b}from"./plus-Be79gWKj.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as d,aZ as T,aX as I,t as n,j as e,a1 as E,f as j,s as y,C as N,ah as v,I as k,B as r,T as b,a2 as w,aj as q,v as X,w as Z,x as Q,y as W,z as ee}from"./index-BSBM4i_g.js";import{C as U,b as Y,c as J,d as H,a as V}from"./card-Cnz8b7Ou.js";import{L as m}from"./label-vEgNxdb2.js";function re(){const[t,F]=d.useState({}),[i,_]=d.useState(!0),[z,O]=d.useState(!1),[x,R]=d.useState({}),[C,G]=d.useState({}),[M,D]=d.useState(T()[0]?.id||"openai/gpt-4o"),[l,B]=d.useState({openrouter:!1,replicate:!1,anthropic:!1,openai:!1,gemini:!1,factorydroid:!1});d.useEffect(()=>{P()},[]);const P=async()=>{try{_(!0);const s=await I("/api/v1/config?type=global");if(s.success&&s.data){const a=s.data.apiKeys||{},c={},o={};for(const A of["openrouter","replicate","anthropic","openai","gemini","factorydroid"]){const K=a[A];K&&typeof K=="string"&&K.trim()!==""?(c[A]=!0,o[A]="***"):(c[A]=!1,o[A]="")}F(o);const S=s.data.defaults&&s.data.defaults.model?String(s.data.defaults.model):void 0;D(S||T()[0]?.id||"openai/gpt-4o")}}catch(s){console.error("Failed to load API keys:",s),n({title:"Error",description:"Failed to load API keys",variant:"destructive"})}finally{_(!1)}},h=(s,a)=>{F(c=>({...c,[s]:a}))},L=async s=>{try{G(S=>({...S,[s]:!0}));const a=t[s],c={provider:s};a&&a!=="***"&&(c.key=a);const o=await I("/api/v1/config/test",{method:"POST",body:JSON.stringify(c)});o.success&&o.message?n({title:"Test Result",description:o.message}):o.success?n({title:"Test Result",description:"Success"}):n({title:"Test Failed",description:o.message||"Unknown error",variant:"destructive"})}catch(a){n({title:"Test Failed",description:a instanceof Error?a.message:"Unknown error",variant:"destructive"})}finally{G(a=>({...a,[s]:!1}))}},p=s=>{B(a=>({...a,[s]:!a[s]}))},u=async s=>{try{const a={[s]:""};await I("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),n({title:"Success",description:`${s} API key cleared`}),await P()}catch(a){console.error("Failed to clear API key:",a),n({title:"Error",description:"Failed to clear API key",variant:"destructive"})}},f=async s=>{try{R(c=>({...c,[s]:!0}));const a={[s]:t[s]};await I("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),n({title:"Success",description:`${s} API key saved`}),await P()}catch(a){console.error("Failed to save API key:",a),n({title:"Error",description:"Failed to save API key",variant:"destructive"})}finally{R(a=>({...a,[s]:!1}))}},$=async()=>{try{O(!0),await I("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({defaults:{model:M}})}),n({title:"Success",description:"Default model saved successfully"})}catch(s){console.error("Failed to save default model:",s),n({title:"Error",description:"Failed to save default model",variant:"destructive"})}finally{O(!1)}},g={openrouter:"OPENROUTER_API_KEY",replicate:"REPLICATE_API_TOKEN",anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GEMINI_API_KEY",factorydroid:"FACTORY_API_KEY"};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"AI & LLM"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Coconut's connections to LLM providers."})]}),e.jsx(E,{}),e.jsxs(U,{children:[e.jsxs(Y,{children:[e.jsx(J,{children:"API Keys & Authentication"}),e.jsx(H,{children:"Manage API keys and authentication tokens for integrated services."})]}),e.jsxs(V,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"AI Assistant API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used by the AI Assistant sidebar for chat and code suggestions."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>p("openrouter"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.openrouter&&t.openrouter!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.openrouter?e.jsx(y,{className:"h-4 w-4"}):e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenRouter"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.openrouter})]})]}),t.openrouter&&t.openrouter!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.openrouter&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openrouterKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(k,{id:"openrouterKey",type:"password",placeholder:"sk-or-v1-...",className:"flex-1",value:t.openrouter||"",onChange:s=>h("openrouter",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openrouter"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>L("openrouter"),disabled:!!C.openrouter,title:"Test API key",children:C.openrouter?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>f("openrouter"),disabled:x.openrouter||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenRouter"})]})]})]}),e.jsx(E,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Resource Creation API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used for generating images and other resources."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>p("replicate"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.replicate&&t.replicate!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.replicate?e.jsx(y,{className:"h-4 w-4"}):e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Replicate"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.replicate})]})]}),t.replicate&&t.replicate!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.replicate&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"replicateKey",children:"API Token"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(k,{id:"replicateKey",type:"password",placeholder:"r8_...",className:"flex-1",value:t.replicate||"",onChange:s=>h("replicate",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("replicate"),title:"Clear API token",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>L("replicate"),disabled:!!C.replicate,title:"Test API token",children:C.replicate?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>f("replicate"),disabled:x.replicate||i,title:"Save API token",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token from"," ",e.jsx("a",{href:"https://replicate.com/account/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Replicate"})]})]})]}),e.jsx(E,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Coding Agent API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These keys are automatically provided to coding agents when they start running."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>p("anthropic"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.anthropic&&t.anthropic!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.anthropic?e.jsx(y,{className:"h-4 w-4"}):e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Anthropic Claude"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.anthropic})]})]}),t.anthropic&&t.anthropic!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.anthropic&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"anthropicKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(k,{id:"anthropicKey",type:"password",placeholder:"sk-ant-...",className:"flex-1",value:t.anthropic||"",onChange:s=>h("anthropic",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("anthropic"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>f("anthropic"),disabled:x.anthropic||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://console.anthropic.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Anthropic Console"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>p("openai"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.openai&&t.openai!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.openai?e.jsx(y,{className:"h-4 w-4"}):e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenAI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.openai})]})]}),t.openai&&t.openai!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.openai&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openaiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(k,{id:"openaiKey",type:"password",placeholder:"sk-...",className:"flex-1",value:t.openai||"",onChange:s=>h("openai",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openai"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>f("openai"),disabled:x.openai||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenAI Platform"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>p("gemini"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.gemini&&t.gemini!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.gemini?e.jsx(y,{className:"h-4 w-4"}):e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Google Gemini"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.gemini})]})]}),t.gemini&&t.gemini!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.gemini&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"geminiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(k,{id:"geminiKey",type:"password",placeholder:"AIza...",className:"flex-1",value:t.gemini||"",onChange:s=>h("gemini",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("gemini"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>f("gemini"),disabled:x.gemini||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://makersuite.google.com/app/apikey",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Google AI Studio"})]})]})]}),e.jsxs("div",{className:"border rounded-lg mt-4",children:[e.jsxs("button",{onClick:()=>p("factorydroid"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.factorydroid&&t.factorydroid!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.factorydroid?e.jsx(y,{className:"h-4 w-4"}):e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Factory Droid"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.factorydroid})]})]}),t.factorydroid&&t.factorydroid!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.factorydroid&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"factorydroidKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(k,{id:"factorydroidKey",type:"password",placeholder:"fd-...",className:"flex-1",value:t.factorydroid||"",onChange:s=>h("factorydroid",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("factorydroid"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>f("factorydroid"),disabled:x.factorydroid||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://factorydroid.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Factory Droid"})]})]})]})]})]}),e.jsxs(U,{children:[e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-5 w-5"}),e.jsx(J,{children:"AI Assistant Settings"})]}),e.jsx(H,{children:"Configure default AI model and behavior for the AI assistant sidebar."})]}),e.jsxs(V,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"defaultModel",children:"Default AI Model"}),e.jsxs(X,{value:M,onValueChange:D,children:[e.jsx(Z,{children:e.jsx(Q,{placeholder:"Select default AI model"})}),e.jsx(W,{children:T().map(s=>e.jsx(ee,{value:s.id,children:s.label},s.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This model will be selected by default when opening the AI assistant."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(r,{onClick:$,disabled:z||i,children:z?"Saving...":"Save"})})]})]})]})}export{re as default};
1
+ import{r as d,aZ as T,aX as I,t as n,j as e,a1 as E,f as j,s as y,C as N,ah as v,I as k,B as r,T as b,a2 as w,aj as q,v as X,w as Z,x as Q,y as W,z as ee}from"./index-Bbxvuj4b.js";import{C as U,b as Y,c as J,d as H,a as V}from"./card-D_zGBKua.js";import{L as m}from"./label-CZGCmBD7.js";function re(){const[t,F]=d.useState({}),[i,_]=d.useState(!0),[z,O]=d.useState(!1),[x,R]=d.useState({}),[C,G]=d.useState({}),[M,D]=d.useState(T()[0]?.id||"openai/gpt-4o"),[l,B]=d.useState({openrouter:!1,replicate:!1,anthropic:!1,openai:!1,gemini:!1,factorydroid:!1});d.useEffect(()=>{P()},[]);const P=async()=>{try{_(!0);const s=await I("/api/v1/config?type=global");if(s.success&&s.data){const a=s.data.apiKeys||{},c={},o={};for(const A of["openrouter","replicate","anthropic","openai","gemini","factorydroid"]){const K=a[A];K&&typeof K=="string"&&K.trim()!==""?(c[A]=!0,o[A]="***"):(c[A]=!1,o[A]="")}F(o);const S=s.data.defaults&&s.data.defaults.model?String(s.data.defaults.model):void 0;D(S||T()[0]?.id||"openai/gpt-4o")}}catch(s){console.error("Failed to load API keys:",s),n({title:"Error",description:"Failed to load API keys",variant:"destructive"})}finally{_(!1)}},h=(s,a)=>{F(c=>({...c,[s]:a}))},L=async s=>{try{G(S=>({...S,[s]:!0}));const a=t[s],c={provider:s};a&&a!=="***"&&(c.key=a);const o=await I("/api/v1/config/test",{method:"POST",body:JSON.stringify(c)});o.success&&o.message?n({title:"Test Result",description:o.message}):o.success?n({title:"Test Result",description:"Success"}):n({title:"Test Failed",description:o.message||"Unknown error",variant:"destructive"})}catch(a){n({title:"Test Failed",description:a instanceof Error?a.message:"Unknown error",variant:"destructive"})}finally{G(a=>({...a,[s]:!1}))}},p=s=>{B(a=>({...a,[s]:!a[s]}))},u=async s=>{try{const a={[s]:""};await I("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),n({title:"Success",description:`${s} API key cleared`}),await P()}catch(a){console.error("Failed to clear API key:",a),n({title:"Error",description:"Failed to clear API key",variant:"destructive"})}},f=async s=>{try{R(c=>({...c,[s]:!0}));const a={[s]:t[s]};await I("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),n({title:"Success",description:`${s} API key saved`}),await P()}catch(a){console.error("Failed to save API key:",a),n({title:"Error",description:"Failed to save API key",variant:"destructive"})}finally{R(a=>({...a,[s]:!1}))}},$=async()=>{try{O(!0),await I("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({defaults:{model:M}})}),n({title:"Success",description:"Default model saved successfully"})}catch(s){console.error("Failed to save default model:",s),n({title:"Error",description:"Failed to save default model",variant:"destructive"})}finally{O(!1)}},g={openrouter:"OPENROUTER_API_KEY",replicate:"REPLICATE_API_TOKEN",anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GEMINI_API_KEY",factorydroid:"FACTORY_API_KEY"};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"AI & LLM"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Coconut's connections to LLM providers."})]}),e.jsx(E,{}),e.jsxs(U,{children:[e.jsxs(Y,{children:[e.jsx(J,{children:"API Keys & Authentication"}),e.jsx(H,{children:"Manage API keys and authentication tokens for integrated services."})]}),e.jsxs(V,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"AI Assistant API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used by the AI Assistant sidebar for chat and code suggestions."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>p("openrouter"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.openrouter&&t.openrouter!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.openrouter?e.jsx(y,{className:"h-4 w-4"}):e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenRouter"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.openrouter})]})]}),t.openrouter&&t.openrouter!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.openrouter&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openrouterKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(k,{id:"openrouterKey",type:"password",placeholder:"sk-or-v1-...",className:"flex-1",value:t.openrouter||"",onChange:s=>h("openrouter",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openrouter"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>L("openrouter"),disabled:!!C.openrouter,title:"Test API key",children:C.openrouter?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>f("openrouter"),disabled:x.openrouter||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenRouter"})]})]})]}),e.jsx(E,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Resource Creation API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used for generating images and other resources."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>p("replicate"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.replicate&&t.replicate!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.replicate?e.jsx(y,{className:"h-4 w-4"}):e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Replicate"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.replicate})]})]}),t.replicate&&t.replicate!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.replicate&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"replicateKey",children:"API Token"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(k,{id:"replicateKey",type:"password",placeholder:"r8_...",className:"flex-1",value:t.replicate||"",onChange:s=>h("replicate",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("replicate"),title:"Clear API token",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>L("replicate"),disabled:!!C.replicate,title:"Test API token",children:C.replicate?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>f("replicate"),disabled:x.replicate||i,title:"Save API token",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token from"," ",e.jsx("a",{href:"https://replicate.com/account/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Replicate"})]})]})]}),e.jsx(E,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Coding Agent API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These keys are automatically provided to coding agents when they start running."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>p("anthropic"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.anthropic&&t.anthropic!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.anthropic?e.jsx(y,{className:"h-4 w-4"}):e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Anthropic Claude"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.anthropic})]})]}),t.anthropic&&t.anthropic!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.anthropic&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"anthropicKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(k,{id:"anthropicKey",type:"password",placeholder:"sk-ant-...",className:"flex-1",value:t.anthropic||"",onChange:s=>h("anthropic",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("anthropic"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>f("anthropic"),disabled:x.anthropic||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://console.anthropic.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Anthropic Console"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>p("openai"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.openai&&t.openai!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.openai?e.jsx(y,{className:"h-4 w-4"}):e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenAI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.openai})]})]}),t.openai&&t.openai!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.openai&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openaiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(k,{id:"openaiKey",type:"password",placeholder:"sk-...",className:"flex-1",value:t.openai||"",onChange:s=>h("openai",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openai"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>f("openai"),disabled:x.openai||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenAI Platform"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>p("gemini"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.gemini&&t.gemini!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.gemini?e.jsx(y,{className:"h-4 w-4"}):e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Google Gemini"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.gemini})]})]}),t.gemini&&t.gemini!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.gemini&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"geminiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(k,{id:"geminiKey",type:"password",placeholder:"AIza...",className:"flex-1",value:t.gemini||"",onChange:s=>h("gemini",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("gemini"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>f("gemini"),disabled:x.gemini||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://makersuite.google.com/app/apikey",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Google AI Studio"})]})]})]}),e.jsxs("div",{className:"border rounded-lg mt-4",children:[e.jsxs("button",{onClick:()=>p("factorydroid"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.factorydroid&&t.factorydroid!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.factorydroid?e.jsx(y,{className:"h-4 w-4"}):e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Factory Droid"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.factorydroid})]})]}),t.factorydroid&&t.factorydroid!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.factorydroid&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"factorydroidKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(k,{id:"factorydroidKey",type:"password",placeholder:"fd-...",className:"flex-1",value:t.factorydroid||"",onChange:s=>h("factorydroid",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("factorydroid"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>f("factorydroid"),disabled:x.factorydroid||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://factorydroid.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Factory Droid"})]})]})]})]})]}),e.jsxs(U,{children:[e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-5 w-5"}),e.jsx(J,{children:"AI Assistant Settings"})]}),e.jsx(H,{children:"Configure default AI model and behavior for the AI assistant sidebar."})]}),e.jsxs(V,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"defaultModel",children:"Default AI Model"}),e.jsxs(X,{value:M,onValueChange:D,children:[e.jsx(Z,{children:e.jsx(Q,{placeholder:"Select default AI model"})}),e.jsx(W,{children:T().map(s=>e.jsx(ee,{value:s.id,children:s.label},s.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This model will be selected by default when opening the AI assistant."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(r,{onClick:$,disabled:z||i,children:z?"Saving...":"Save"})})]})]})]})}export{re as default};
@@ -1 +1 @@
1
- import{E,u as A,H as T,r,A as u,j as e,n as f,B as i,L as d,ap as F,J as L,M as $,N as P,T as S,O as z,P as B,Q as K,R as U,U as q,V as H,W as M,ah as R,ai as _,aq as I,Y as V}from"./index-BSBM4i_g.js";import{C as c,a as o,b as W,c as J}from"./card-Cnz8b7Ou.js";import{B as O}from"./badge-DO6e5hC1.js";import{c as Q}from"./clipboard-B9ndUJKl.js";import{A as p}from"./arrow-left-CEZFPQje.js";import{C as Y}from"./calendar-DWaFMSXH.js";import{T as G}from"./tag-Czz-3rNY.js";function le(){const g=E(),j=A(),{toast:n}=T(),l=g.filename,[s,w]=r.useState(null),[N,v]=r.useState(!0),[m,x]=r.useState(!1),[k,h]=r.useState(!1);r.useEffect(()=>{l&&C()},[l]);const C=async()=>{try{const a=await(await fetch(`${u}/api/v1/context/knowledge/${l}`)).json();a.success?w(a.document):n({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}catch(t){console.error("Error fetching document:",t),n({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}finally{v(!1)}},y=async()=>{if(!s)return;const t=`.nut/context/knowledge/${s.filename}`;try{await Q(t),h(!0),setTimeout(()=>h(!1),2e3),n({title:"Copied!",description:`Path copied to clipboard: ${t}`})}catch(a){console.error("Failed to copy path:",a),n({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},D=()=>{if(!s)return;const t=new CustomEvent("discuss-in-chat",{detail:{type:"knowledge",id:`knowledge-${s.filename.replace(".md","")}`,filename:s.filename,name:s.filename,path:`.nut/context/knowledge/${s.filename}`}});window.dispatchEvent(t)},b=async()=>{if(s){x(!0);try{const a=await(await fetch(`${u}/api/v1/context/knowledge/${l}`,{method:"DELETE"})).json();a.success?(n({title:"Success",description:"Knowledge document deleted successfully"}),j("/context/knowledge")):n({title:"Error",description:a.error||"Failed to delete knowledge document",variant:"destructive"})}catch(t){console.error("Error deleting document:",t),n({title:"Error",description:"Failed to delete knowledge document",variant:"destructive"})}finally{x(!1)}}};return N?e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(o,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(f,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):s?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.title}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(i,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(d,{to:"/context/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})}),e.jsxs(i,{variant:"outline",size:"sm",onClick:D,children:[e.jsx(F,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsx(i,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(d,{to:`/context/knowledge/${l}/edit`,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs($,{children:[e.jsx(P,{asChild:!0,children:e.jsxs(i,{variant:"destructive",size:"sm",children:[e.jsx(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})}),e.jsxs(z,{children:[e.jsxs(B,{children:[e.jsx(K,{children:"Delete Knowledge Document"}),e.jsxs(U,{children:["Are you sure you want to delete “",s.title,"”? This action cannot be undone."]})]}),e.jsxs(q,{children:[e.jsx(H,{children:"Cancel"}),e.jsx(M,{onClick:b,disabled:m,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:m?e.jsx(f,{className:"w-4 h-4 animate-spin"}):"Delete"})]})]})]})]})]}),e.jsx("div",{className:"text-left",children:e.jsxs("button",{type:"button",onClick:y,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono text-left",children:[e.jsxs("span",{className:"break-all",children:[".nut/context/knowledge/",s.filename]}),k?e.jsx(R,{className:"h-3.5 w-3.5 flex-shrink-0 text-green-600"}):e.jsx(_,{className:"h-3.5 w-3.5 flex-shrink-0"})]})})]}),e.jsxs("div",{className:"flex flex-col gap-2 text-sm text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Y,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Updated ",s.metadata.updated]})]}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-start gap-1.5 sm:items-center",children:[e.jsx(G,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5 sm:mt-0"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map((t,a)=>e.jsx(O,{variant:"outline",className:"text-xs",children:t},a))})]})]}),s.metadata.sources&&s.metadata.sources.length>0&&e.jsxs(c,{children:[e.jsx(W,{children:e.jsxs(J,{className:"flex items-center gap-2",children:[e.jsx(I,{className:"w-4 h-4"}),"Sources"]})}),e.jsx(o,{children:e.jsx("ul",{className:"space-y-2",children:s.metadata.sources.map((t,a)=>e.jsx("li",{children:t.startsWith("http")?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 underline",children:t}):e.jsx("span",{children:t})},a))})})]}),e.jsx(c,{children:e.jsx(o,{className:"pt-6",children:e.jsx(V,{children:s.content})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(i,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(d,{to:"/context/knowledge",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})})})]}),e.jsx(c,{children:e.jsx(o,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"The requested knowledge document could not be found."})]})})})]})}export{le as default};
1
+ import{E,u as A,H as T,r,A as u,j as e,n as f,B as i,L as d,ap as F,J as L,M as $,N as P,T as S,O as z,P as B,Q as K,R as U,U as q,V as H,W as M,ah as R,ai as _,aq as I,Y as V}from"./index-Bbxvuj4b.js";import{C as c,a as o,b as W,c as J}from"./card-D_zGBKua.js";import{B as O}from"./badge-D7ZZbMEG.js";import{c as Q}from"./clipboard-B9ndUJKl.js";import{A as p}from"./arrow-left-Do2jUSS9.js";import{C as Y}from"./calendar-C5JtKp_F.js";import{T as G}from"./tag-BgO5mxYK.js";function le(){const g=E(),j=A(),{toast:n}=T(),l=g.filename,[s,w]=r.useState(null),[N,v]=r.useState(!0),[m,x]=r.useState(!1),[k,h]=r.useState(!1);r.useEffect(()=>{l&&C()},[l]);const C=async()=>{try{const a=await(await fetch(`${u}/api/v1/context/knowledge/${l}`)).json();a.success?w(a.document):n({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}catch(t){console.error("Error fetching document:",t),n({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}finally{v(!1)}},y=async()=>{if(!s)return;const t=`.nut/context/knowledge/${s.filename}`;try{await Q(t),h(!0),setTimeout(()=>h(!1),2e3),n({title:"Copied!",description:`Path copied to clipboard: ${t}`})}catch(a){console.error("Failed to copy path:",a),n({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},D=()=>{if(!s)return;const t=new CustomEvent("discuss-in-chat",{detail:{type:"knowledge",id:`knowledge-${s.filename.replace(".md","")}`,filename:s.filename,name:s.filename,path:`.nut/context/knowledge/${s.filename}`}});window.dispatchEvent(t)},b=async()=>{if(s){x(!0);try{const a=await(await fetch(`${u}/api/v1/context/knowledge/${l}`,{method:"DELETE"})).json();a.success?(n({title:"Success",description:"Knowledge document deleted successfully"}),j("/context/knowledge")):n({title:"Error",description:a.error||"Failed to delete knowledge document",variant:"destructive"})}catch(t){console.error("Error deleting document:",t),n({title:"Error",description:"Failed to delete knowledge document",variant:"destructive"})}finally{x(!1)}}};return N?e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(o,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(f,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):s?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.title}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(i,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(d,{to:"/context/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})}),e.jsxs(i,{variant:"outline",size:"sm",onClick:D,children:[e.jsx(F,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsx(i,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(d,{to:`/context/knowledge/${l}/edit`,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs($,{children:[e.jsx(P,{asChild:!0,children:e.jsxs(i,{variant:"destructive",size:"sm",children:[e.jsx(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})}),e.jsxs(z,{children:[e.jsxs(B,{children:[e.jsx(K,{children:"Delete Knowledge Document"}),e.jsxs(U,{children:["Are you sure you want to delete “",s.title,"”? This action cannot be undone."]})]}),e.jsxs(q,{children:[e.jsx(H,{children:"Cancel"}),e.jsx(M,{onClick:b,disabled:m,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:m?e.jsx(f,{className:"w-4 h-4 animate-spin"}):"Delete"})]})]})]})]})]}),e.jsx("div",{className:"text-left",children:e.jsxs("button",{type:"button",onClick:y,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono text-left",children:[e.jsxs("span",{className:"break-all",children:[".nut/context/knowledge/",s.filename]}),k?e.jsx(R,{className:"h-3.5 w-3.5 flex-shrink-0 text-green-600"}):e.jsx(_,{className:"h-3.5 w-3.5 flex-shrink-0"})]})})]}),e.jsxs("div",{className:"flex flex-col gap-2 text-sm text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Y,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Updated ",s.metadata.updated]})]}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-start gap-1.5 sm:items-center",children:[e.jsx(G,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5 sm:mt-0"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map((t,a)=>e.jsx(O,{variant:"outline",className:"text-xs",children:t},a))})]})]}),s.metadata.sources&&s.metadata.sources.length>0&&e.jsxs(c,{children:[e.jsx(W,{children:e.jsxs(J,{className:"flex items-center gap-2",children:[e.jsx(I,{className:"w-4 h-4"}),"Sources"]})}),e.jsx(o,{children:e.jsx("ul",{className:"space-y-2",children:s.metadata.sources.map((t,a)=>e.jsx("li",{children:t.startsWith("http")?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 underline",children:t}):e.jsx("span",{children:t})},a))})})]}),e.jsx(c,{children:e.jsx(o,{className:"pt-6",children:e.jsx(V,{children:s.content})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(i,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(d,{to:"/context/knowledge",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})})})]}),e.jsx(c,{children:e.jsx(o,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"The requested knowledge document could not be found."})]})})})]})}export{le as default};
@@ -1 +1 @@
1
- import{E as B,u as M,H as z,r as n,A as C,j as e,n as S,B as x,L as D,a2 as K,X as R,I as U}from"./index-BSBM4i_g.js";import{C as d,a as l,b as h,c as g}from"./card-Cnz8b7Ou.js";import{L as p}from"./label-vEgNxdb2.js";import{M as H}from"./markdown-editor-O6tGYa1a.js";import{T as y}from"./TagInput-CbH9zq5n.js";import{A as _}from"./arrow-left-CEZFPQje.js";import"./badge-DO6e5hC1.js";function W(){const T=B(),i=M(),{toast:a}=z(),r=T.filename,[m,L]=n.useState(null),[A,b]=n.useState(!0),[u,f]=n.useState(!1),[o,j]=n.useState(""),[c,v]=n.useState(""),[w,N]=n.useState([]),[k,E]=n.useState([]);n.useEffect(()=>{r&&F()},[r]);const F=async()=>{try{const t=await(await fetch(`${C}/api/v1/context/knowledge/${r}`)).json();t.success?(L(t.document),j(t.document.title),v(t.document.content),N(t.document.metadata.tags||[]),E(t.document.metadata.sources||[])):(a({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/context/knowledge"))}catch(s){console.error("Error fetching document:",s),a({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/context/knowledge")}finally{b(!1)}},P=async()=>{if(m){if(!o.trim()){a({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!c.trim()){a({title:"Error",description:"Please provide content for the knowledge document",variant:"destructive"});return}f(!0);try{const t=await(await fetch(`${C}/api/v1/context/knowledge/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:o.trim(),content:c.trim(),metadata:{tags:w,sources:k}})})).json();if(t.success){a({title:"Success",description:"Knowledge document updated successfully"});const I=t.document.filename.replace(".md","");i(`/context/knowledge/${I}`,{replace:!0})}else a({title:"Error",description:t.error||"Failed to update knowledge document",variant:"destructive"})}catch(s){console.error("Error updating document:",s),a({title:"Error",description:"Failed to update knowledge document",variant:"destructive"})}finally{f(!1)}}},$=()=>{i(`/context/knowledge/${r}`)};return A?e.jsx("div",{className:"space-y-6",children:e.jsx(d,{children:e.jsx(l,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(S,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):m?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Knowledge Document"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:m.filename})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(x,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(D,{to:"/context/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(_,{className:"h-4 w-4"})})}),e.jsxs(x,{onClick:P,disabled:u||!o.trim()||!c.trim(),size:"sm",children:[u?e.jsx(S,{className:"w-4 h-4 animate-spin sm:mr-2"}):e.jsx(K,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:u?"Saving...":"Save"})]}),e.jsxs(x,{onClick:$,variant:"outline",size:"sm",children:[e.jsx(R,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Cancel"})]})]})]}),e.jsxs(d,{children:[e.jsx(h,{children:e.jsx(g,{children:"Basic Information"})}),e.jsx(l,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(p,{htmlFor:"title",children:"Title *"}),e.jsx(U,{id:"title",value:o,onChange:s=>j(s.target.value),placeholder:"Enter document title...",className:"text-lg"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Changing the title will rename the file"})]})})]}),e.jsxs(d,{children:[e.jsx(h,{children:e.jsx(g,{children:"Metadata"})}),e.jsxs(l,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{children:"Tags"}),e.jsx(y,{tags:w,onChange:N,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(p,{children:"Sources"}),e.jsx(y,{tags:k,onChange:E,placeholder:"Add a source (URL or name)"})]})]})]}),e.jsxs(d,{children:[e.jsx(h,{children:e.jsx(g,{children:"Content *"})}),e.jsx(l,{children:e.jsx(H,{value:c,onChange:s=>v(s||""),placeholder:"Enter your knowledge content in Markdown..."})})]})]}):null}export{W as default};
1
+ import{E as B,u as M,H as z,r as n,A as C,j as e,n as S,B as x,L as D,a2 as K,X as R,I as U}from"./index-Bbxvuj4b.js";import{C as d,a as l,b as h,c as g}from"./card-D_zGBKua.js";import{L as p}from"./label-CZGCmBD7.js";import{M as H}from"./markdown-editor-BiM9h5iI.js";import{T as y}from"./TagInput-Cqju3cXZ.js";import{A as _}from"./arrow-left-Do2jUSS9.js";import"./badge-D7ZZbMEG.js";function W(){const T=B(),i=M(),{toast:a}=z(),r=T.filename,[m,L]=n.useState(null),[A,b]=n.useState(!0),[u,f]=n.useState(!1),[o,j]=n.useState(""),[c,v]=n.useState(""),[w,N]=n.useState([]),[k,E]=n.useState([]);n.useEffect(()=>{r&&F()},[r]);const F=async()=>{try{const t=await(await fetch(`${C}/api/v1/context/knowledge/${r}`)).json();t.success?(L(t.document),j(t.document.title),v(t.document.content),N(t.document.metadata.tags||[]),E(t.document.metadata.sources||[])):(a({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/context/knowledge"))}catch(s){console.error("Error fetching document:",s),a({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/context/knowledge")}finally{b(!1)}},P=async()=>{if(m){if(!o.trim()){a({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!c.trim()){a({title:"Error",description:"Please provide content for the knowledge document",variant:"destructive"});return}f(!0);try{const t=await(await fetch(`${C}/api/v1/context/knowledge/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:o.trim(),content:c.trim(),metadata:{tags:w,sources:k}})})).json();if(t.success){a({title:"Success",description:"Knowledge document updated successfully"});const I=t.document.filename.replace(".md","");i(`/context/knowledge/${I}`,{replace:!0})}else a({title:"Error",description:t.error||"Failed to update knowledge document",variant:"destructive"})}catch(s){console.error("Error updating document:",s),a({title:"Error",description:"Failed to update knowledge document",variant:"destructive"})}finally{f(!1)}}},$=()=>{i(`/context/knowledge/${r}`)};return A?e.jsx("div",{className:"space-y-6",children:e.jsx(d,{children:e.jsx(l,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(S,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):m?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Knowledge Document"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:m.filename})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(x,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(D,{to:"/context/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(_,{className:"h-4 w-4"})})}),e.jsxs(x,{onClick:P,disabled:u||!o.trim()||!c.trim(),size:"sm",children:[u?e.jsx(S,{className:"w-4 h-4 animate-spin sm:mr-2"}):e.jsx(K,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:u?"Saving...":"Save"})]}),e.jsxs(x,{onClick:$,variant:"outline",size:"sm",children:[e.jsx(R,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Cancel"})]})]})]}),e.jsxs(d,{children:[e.jsx(h,{children:e.jsx(g,{children:"Basic Information"})}),e.jsx(l,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(p,{htmlFor:"title",children:"Title *"}),e.jsx(U,{id:"title",value:o,onChange:s=>j(s.target.value),placeholder:"Enter document title...",className:"text-lg"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Changing the title will rename the file"})]})})]}),e.jsxs(d,{children:[e.jsx(h,{children:e.jsx(g,{children:"Metadata"})}),e.jsxs(l,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{children:"Tags"}),e.jsx(y,{tags:w,onChange:N,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(p,{children:"Sources"}),e.jsx(y,{tags:k,onChange:E,placeholder:"Add a source (URL or name)"})]})]})]}),e.jsxs(d,{children:[e.jsx(h,{children:e.jsx(g,{children:"Content *"})}),e.jsx(l,{children:e.jsx(H,{value:c,onChange:s=>v(s||""),placeholder:"Enter your knowledge content in Markdown..."})})]})]}):null}export{W as default};
@@ -1,8 +1,8 @@
1
- import{c as q,j as e,S as G,Y as Q,u as W,r as p,H as X,A as P,n as Z,B as h,L as R,g as C,ap as z,ah as I,ai as K}from"./index-BSBM4i_g.js";import{C as M,a as L}from"./card-Cnz8b7Ou.js";import{B as j}from"./badge-DO6e5hC1.js";import{c as ee}from"./clipboard-B9ndUJKl.js";import{R as te,a as se,f as ne,L as B}from"./browser-modal-BTxVvZIA.js";import{P as O}from"./plus-BfBtnncn.js";import{A as ae}from"./arrow-up-D-lB4Ah6.js";import{A as re}from"./arrow-down-D1dapxzl.js";import"./search-kcgmZUqQ.js";/**
1
+ import{c as q,j as e,S as G,Y as Q,u as W,r as p,H as X,A as F,n as Z,B as h,L as P,g as C,ap as z,ah as I,ai as K}from"./index-Bbxvuj4b.js";import{C as M,a as L}from"./card-D_zGBKua.js";import{B as j}from"./badge-D7ZZbMEG.js";import{c as ee}from"./clipboard-B9ndUJKl.js";import{R as te,L as B}from"./browser-modal-CWDhylx7.js";import{R as se,f as ne}from"./registry-ANRa5WBi.js";import{P as O}from"./plus-Be79gWKj.js";import{A as ae}from"./arrow-up-hMM1cdZm.js";import{A as re}from"./arrow-down-vmWOjyjO.js";import"./search-CrIdR7ah.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
6
  */const ie=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],oe=q("arrow-up-down",ie),le=["createdAt","updatedAt","version","tags"];function U(n){if(n){if(Array.isArray(n)){const l=n.map(i=>{if(typeof i=="string")return i.trim();if(typeof i=="number")return`${i}`}).filter(i=>typeof i=="string"&&i.length>0);return l.length>0?l:void 0}if(typeof n=="string"){const l=n.split(",").map(i=>i.trim()).filter(i=>i.length>0);return l.length>0?l:void 0}}}function ce(n,l){const i=[];if(n.content&&typeof n.content=="object")for(const r of Object.values(n.content))typeof r=="string"&&r.trim().length>0&&i.push(r.trim());const s=[];return s.push(`# ${l}`),n.description?.trim()&&s.push(n.description.trim()),[...s,...i].join(`
7
7
 
8
- `).trim()}function _(n,l){const i=n.name||l.name,s={registryId:n.id,registryEndpoint:n.endpoint,registrySource:te,author:n.author,category:"general"};for(const r of le){const o=l[r];if(o!==void 0)if(r==="tags"){const m=U(o);m&&(s[r]=m)}else s[r]=o}!s.version&&n.version&&(s.version=n.version),!s.tags&&n.tags&&(s.tags=U(n.tags));const d=s.tags;if(d){const r=["knowledge","architecture","rules"],o=d.find(m=>r.includes(m.toLowerCase()));o&&(s.type=o.toLowerCase())}for(const[r,o]of Object.entries(s))o==null&&delete s[r];return{title:i,content:ce(l,i),metadata:Object.keys(s).length>0?s:void 0}}function H({open:n,onOpenChange:l,onImport:i}){return e.jsx(se,{open:n,onOpenChange:l,categoryId:"knowledge",title:"Coconut Registry – Knowledge",confirmLabel:"Import Knowledge",getDetail:s=>ne(s.endpoint),renderPreview:(s,d)=>{if(!d)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select a knowledge item to preview"});const r=_(s,d),o=r.metadata??{},m=typeof o.version=="string"?o.version:void 0,f=Array.isArray(s.tags)?s.tags:[],y=typeof o.category=="string"?o.category:"general",w=typeof o.type=="string"?o.type:void 0;return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(G,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:s.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]}),m&&e.jsxs(j,{variant:"outline",children:["v",m]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:s.id})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(j,{variant:"secondary",className:"capitalize",children:y}),w&&e.jsx(j,{variant:"outline",className:"capitalize",children:w})]}),f.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(g=>e.jsx(j,{variant:"secondary",children:g},g))})]}),e.jsx(Q,{className:"[&_.prose]:max-w-none",children:r.content})]})})})},onConfirm:async(s,d)=>{const r=_(s,d);await i({summary:s,detail:d,payload:r})}})}const Y=n=>{if(!n)return"Unknown";const l=new Date(n);if(Number.isNaN(l.getTime()))return n;const s=new Date().getTime()-l.getTime(),d=Math.floor(s/6e4),r=Math.floor(s/36e5),o=Math.floor(s/864e5);return d<1?"Just now":d<60?`${d} minute${d===1?"":"s"} ago`:r<24?`${r} hour${r===1?"":"s"} ago`:o<7?`${o} day${o===1?"":"s"} ago`:new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(l)};function we(){const n=W(),[l,i]=p.useState([]),[s,d]=p.useState(!0),[r,o]=p.useState({}),[m,f]=p.useState(!1),[y,w]=p.useState(!1),[g,J]=p.useState("updated"),[A,S]=p.useState("desc"),{toast:u}=X(),v=p.useCallback(async()=>{d(!0);try{const t=await fetch(`${P}/api/v1/context/knowledge`);if(!t.ok)throw new Error("Failed to load knowledge");const a=await t.json();i(a.documents||[])}catch(t){console.error("Failed to load knowledge:",t),i([])}finally{d(!1)}},[]);p.useEffect(()=>{v()},[v]);const N=t=>{g===t?S(a=>a==="asc"?"desc":"asc"):(J(t),S(t==="updated"?"desc":"asc"))},V=[...l].sort((t,a)=>{let c=0;switch(g){case"file":c=(t.title||t.filename).localeCompare(a.title||a.filename);break;case"category":c=(t.metadata.category||"general").localeCompare(a.metadata.category||"general");break;case"updated":{const x=new Date(t.metadata.updated||0).getTime(),E=new Date(a.metadata.updated||0).getTime();c=x-E;break}}return A==="asc"?c:-c}),b=({column:t})=>g!==t?e.jsx(oe,{className:"h-3 w-3 ml-1 opacity-50"}):A==="asc"?e.jsx(ae,{className:"h-3 w-3 ml-1"}):e.jsx(re,{className:"h-3 w-3 ml-1"}),k=async t=>{const a=`.nut/context/knowledge/${t}`;try{await ee(a),o(c=>({...c,[t]:!0})),setTimeout(()=>{o(c=>({...c,[t]:!1}))},2e3),u({title:"Path copied!",description:`Copied ${a} to clipboard`})}catch(c){console.error("Failed to copy path:",c),u({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},D=t=>{const a=new CustomEvent("discuss-in-chat",{detail:{type:"knowledge",id:`knowledge-${t.filename.replace(".md","")}`,filename:t.filename,name:t.filename,path:`.nut/context/knowledge/${t.filename}`}});window.dispatchEvent(a)},T=p.useCallback(async({payload:t})=>{let a=!1;w(!0);try{const c=await fetch(`${P}/api/v1/context/knowledge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t.title,content:t.content,metadata:t.metadata})});let x=null;try{x=await c.json()}catch($){console.error("Failed to parse registry import response:",$)}if(!(c.ok&&x?.success)){const F=(typeof x?.error=="string"?x.error:x?.error?.message)||c.statusText||"Failed to import knowledge from registry";throw u({title:"Failed to import knowledge",description:F,variant:"destructive"}),a=!0,new Error(F)}u({title:"Knowledge imported",description:`${t.title} is now available in Coconut`}),await v()}catch(c){if(!a){const x=c instanceof Error&&c.message?c.message:"Failed to import knowledge from registry";u({title:"Failed to import knowledge",description:x,variant:"destructive"})}throw c}finally{w(!1)}},[v,u]);return s?e.jsx("div",{className:"space-y-6",children:e.jsx(M,{children:e.jsx(L,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Z,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge base..."})]})})})}):l.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Knowledge Base"}),e.jsx("p",{className:"text-muted-foreground",children:"Accumulated project knowledge, patterns, and best practices"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>f(!0),disabled:y,children:[e.jsx(B,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(h,{size:"sm",asChild:!0,children:e.jsxs(R,{to:"/context/knowledge/new",children:[e.jsx(O,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx(M,{children:e.jsx(L,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Knowledge Documents Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Knowledge documents will appear here as they are created."})]})})})]}),e.jsx(H,{open:m,onOpenChange:f,onImport:T})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Knowledge Base"}),e.jsxs("p",{className:"text-muted-foreground",children:["Accumulated project knowledge, patterns, and best practices (",l.length," documents)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>f(!0),disabled:y,children:[e.jsx(B,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(h,{size:"sm",asChild:!0,children:e.jsxs(R,{to:"/context/knowledge/new",children:[e.jsx(O,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsxs("div",{className:"rounded-lg border overflow-hidden",children:[e.jsxs("div",{className:"hidden bg-muted/50 px-4 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground md:grid md:grid-cols-[minmax(0,2.5fr),minmax(0,1fr),minmax(0,1fr),auto] md:items-center md:gap-4",children:[e.jsxs("button",{type:"button",onClick:()=>N("file"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["File",e.jsx(b,{column:"file"})]}),e.jsxs("button",{type:"button",onClick:()=>N("category"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["Category",e.jsx(b,{column:"category"})]}),e.jsxs("button",{type:"button",onClick:()=>N("updated"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["Updated",e.jsx(b,{column:"updated"})]}),e.jsx("span",{className:"justify-self-end",children:"Actions"})]}),e.jsx("div",{className:"divide-y",children:V.map(t=>e.jsxs("div",{onClick:()=>n(`/context/knowledge/${t.filename.replace(".md","")}`),className:"px-3 py-3 transition-colors hover:bg-muted/60 cursor-pointer md:px-4 md:py-4 md:grid md:grid-cols-[minmax(0,2.5fr),minmax(0,1fr),minmax(0,1fr),auto] md:items-center md:gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 md:hidden",children:[e.jsx("div",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:e.jsx(C,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium text-foreground text-sm",children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(j,{variant:"secondary",className:"capitalize text-[10px] px-1.5 py-0",children:t.metadata.category||"general"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Y(t.metadata.updated)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(h,{variant:"ghost",size:"icon",onClick:a=>{a.stopPropagation(),D(t)},className:"h-7 w-7",title:"Discuss in chat",children:e.jsx(z,{className:"h-3 w-3"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:a=>{a.stopPropagation(),k(t.filename)},className:"h-7 w-7",title:"Copy file path to clipboard",children:r[t.filename]?e.jsx(I,{className:"h-3 w-3 text-green-600"}):e.jsx(K,{className:"h-3 w-3"})})]})]})})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:e.jsx(C,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("div",{className:"block truncate font-medium text-foreground",children:t.title}),e.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),k(t.filename)},className:`inline-flex max-w-full items-center overflow-hidden rounded bg-muted px-2 py-1 font-mono text-xs text-muted-foreground transition-colors hover:bg-muted/80${r[t.filename]?" ring-1 ring-primary/50 text-foreground":""}`,title:"Copy file path to clipboard",children:e.jsxs("span",{className:"truncate",children:[".nut/context/knowledge/",t.filename]})})]})]}),e.jsx("div",{className:"hidden md:block",children:e.jsx(j,{variant:"secondary",className:"capitalize",children:t.metadata.category||"general"})}),e.jsx("div",{className:"hidden text-sm text-muted-foreground md:block",children:Y(t.metadata.updated)}),e.jsxs("div",{className:"hidden md:flex items-center gap-1 justify-end",children:[e.jsx(h,{variant:"ghost",size:"icon",onClick:a=>{a.stopPropagation(),D(t)},className:"h-8 w-8",title:"Discuss in chat",children:e.jsx(z,{className:"h-3.5 w-3.5"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:a=>{a.stopPropagation(),k(t.filename)},className:"h-8 w-8",title:"Copy file path to clipboard",children:r[t.filename]?e.jsx(I,{className:"h-3 w-3 text-green-600"}):e.jsx(K,{className:"h-3 w-3"})})]})]},t.filename))})]})]}),e.jsx(H,{open:m,onOpenChange:f,onImport:T})]})}export{we as default};
8
+ `).trim()}function _(n,l){const i=n.name||l.name,s={registryId:n.id,registryEndpoint:n.endpoint,registrySource:se,author:n.author,category:"general"};for(const r of le){const o=l[r];if(o!==void 0)if(r==="tags"){const m=U(o);m&&(s[r]=m)}else s[r]=o}!s.version&&n.version&&(s.version=n.version),!s.tags&&n.tags&&(s.tags=U(n.tags));const d=s.tags;if(d){const r=["knowledge","architecture","rules"],o=d.find(m=>r.includes(m.toLowerCase()));o&&(s.type=o.toLowerCase())}for(const[r,o]of Object.entries(s))o==null&&delete s[r];return{title:i,content:ce(l,i),metadata:Object.keys(s).length>0?s:void 0}}function H({open:n,onOpenChange:l,onImport:i}){return e.jsx(te,{open:n,onOpenChange:l,categoryId:"knowledge",title:"Coconut Registry – Knowledge",confirmLabel:"Import Knowledge",getDetail:s=>ne(s.endpoint),renderPreview:(s,d)=>{if(!d)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select a knowledge item to preview"});const r=_(s,d),o=r.metadata??{},m=typeof o.version=="string"?o.version:void 0,f=Array.isArray(s.tags)?s.tags:[],y=typeof o.category=="string"?o.category:"general",w=typeof o.type=="string"?o.type:void 0;return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(G,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:s.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]}),m&&e.jsxs(j,{variant:"outline",children:["v",m]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:s.id})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(j,{variant:"secondary",className:"capitalize",children:y}),w&&e.jsx(j,{variant:"outline",className:"capitalize",children:w})]}),f.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(g=>e.jsx(j,{variant:"secondary",children:g},g))})]}),e.jsx(Q,{className:"[&_.prose]:max-w-none",children:r.content})]})})})},onConfirm:async(s,d)=>{const r=_(s,d);await i({summary:s,detail:d,payload:r})}})}const Y=n=>{if(!n)return"Unknown";const l=new Date(n);if(Number.isNaN(l.getTime()))return n;const s=new Date().getTime()-l.getTime(),d=Math.floor(s/6e4),r=Math.floor(s/36e5),o=Math.floor(s/864e5);return d<1?"Just now":d<60?`${d} minute${d===1?"":"s"} ago`:r<24?`${r} hour${r===1?"":"s"} ago`:o<7?`${o} day${o===1?"":"s"} ago`:new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(l)};function ye(){const n=W(),[l,i]=p.useState([]),[s,d]=p.useState(!0),[r,o]=p.useState({}),[m,f]=p.useState(!1),[y,w]=p.useState(!1),[g,J]=p.useState("updated"),[A,S]=p.useState("desc"),{toast:u}=X(),v=p.useCallback(async()=>{d(!0);try{const t=await fetch(`${F}/api/v1/context/knowledge`);if(!t.ok)throw new Error("Failed to load knowledge");const a=await t.json();i(a.documents||[])}catch(t){console.error("Failed to load knowledge:",t),i([])}finally{d(!1)}},[]);p.useEffect(()=>{v()},[v]);const N=t=>{g===t?S(a=>a==="asc"?"desc":"asc"):(J(t),S(t==="updated"?"desc":"asc"))},V=[...l].sort((t,a)=>{let c=0;switch(g){case"file":c=(t.title||t.filename).localeCompare(a.title||a.filename);break;case"category":c=(t.metadata.category||"general").localeCompare(a.metadata.category||"general");break;case"updated":{const x=new Date(t.metadata.updated||0).getTime(),E=new Date(a.metadata.updated||0).getTime();c=x-E;break}}return A==="asc"?c:-c}),b=({column:t})=>g!==t?e.jsx(oe,{className:"h-3 w-3 ml-1 opacity-50"}):A==="asc"?e.jsx(ae,{className:"h-3 w-3 ml-1"}):e.jsx(re,{className:"h-3 w-3 ml-1"}),k=async t=>{const a=`.nut/context/knowledge/${t}`;try{await ee(a),o(c=>({...c,[t]:!0})),setTimeout(()=>{o(c=>({...c,[t]:!1}))},2e3),u({title:"Path copied!",description:`Copied ${a} to clipboard`})}catch(c){console.error("Failed to copy path:",c),u({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},D=t=>{const a=new CustomEvent("discuss-in-chat",{detail:{type:"knowledge",id:`knowledge-${t.filename.replace(".md","")}`,filename:t.filename,name:t.filename,path:`.nut/context/knowledge/${t.filename}`}});window.dispatchEvent(a)},T=p.useCallback(async({payload:t})=>{let a=!1;w(!0);try{const c=await fetch(`${F}/api/v1/context/knowledge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t.title,content:t.content,metadata:t.metadata})});let x=null;try{x=await c.json()}catch(R){console.error("Failed to parse registry import response:",R)}if(!(c.ok&&x?.success)){const $=(typeof x?.error=="string"?x.error:x?.error?.message)||c.statusText||"Failed to import knowledge from registry";throw u({title:"Failed to import knowledge",description:$,variant:"destructive"}),a=!0,new Error($)}u({title:"Knowledge imported",description:`${t.title} is now available in Coconut`}),await v()}catch(c){if(!a){const x=c instanceof Error&&c.message?c.message:"Failed to import knowledge from registry";u({title:"Failed to import knowledge",description:x,variant:"destructive"})}throw c}finally{w(!1)}},[v,u]);return s?e.jsx("div",{className:"space-y-6",children:e.jsx(M,{children:e.jsx(L,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Z,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge base..."})]})})})}):l.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Knowledge Base"}),e.jsx("p",{className:"text-muted-foreground",children:"Accumulated project knowledge, patterns, and best practices"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>f(!0),disabled:y,children:[e.jsx(B,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(h,{size:"sm",asChild:!0,children:e.jsxs(P,{to:"/context/knowledge/new",children:[e.jsx(O,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx(M,{children:e.jsx(L,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Knowledge Documents Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Knowledge documents will appear here as they are created."})]})})})]}),e.jsx(H,{open:m,onOpenChange:f,onImport:T})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Knowledge Base"}),e.jsxs("p",{className:"text-muted-foreground",children:["Accumulated project knowledge, patterns, and best practices (",l.length," documents)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>f(!0),disabled:y,children:[e.jsx(B,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(h,{size:"sm",asChild:!0,children:e.jsxs(P,{to:"/context/knowledge/new",children:[e.jsx(O,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsxs("div",{className:"rounded-lg border overflow-hidden",children:[e.jsxs("div",{className:"hidden bg-muted/50 px-4 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground md:grid md:grid-cols-[minmax(0,2.5fr),minmax(0,1fr),minmax(0,1fr),auto] md:items-center md:gap-4",children:[e.jsxs("button",{type:"button",onClick:()=>N("file"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["File",e.jsx(b,{column:"file"})]}),e.jsxs("button",{type:"button",onClick:()=>N("category"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["Category",e.jsx(b,{column:"category"})]}),e.jsxs("button",{type:"button",onClick:()=>N("updated"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["Updated",e.jsx(b,{column:"updated"})]}),e.jsx("span",{className:"justify-self-end",children:"Actions"})]}),e.jsx("div",{className:"divide-y",children:V.map(t=>e.jsxs("div",{onClick:()=>n(`/context/knowledge/${t.filename.replace(".md","")}`),className:"px-3 py-3 transition-colors hover:bg-muted/60 cursor-pointer md:px-4 md:py-4 md:grid md:grid-cols-[minmax(0,2.5fr),minmax(0,1fr),minmax(0,1fr),auto] md:items-center md:gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 md:hidden",children:[e.jsx("div",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:e.jsx(C,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium text-foreground text-sm",children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(j,{variant:"secondary",className:"capitalize text-[10px] px-1.5 py-0",children:t.metadata.category||"general"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Y(t.metadata.updated)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(h,{variant:"ghost",size:"icon",onClick:a=>{a.stopPropagation(),D(t)},className:"h-7 w-7",title:"Discuss in chat",children:e.jsx(z,{className:"h-3 w-3"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:a=>{a.stopPropagation(),k(t.filename)},className:"h-7 w-7",title:"Copy file path to clipboard",children:r[t.filename]?e.jsx(I,{className:"h-3 w-3 text-green-600"}):e.jsx(K,{className:"h-3 w-3"})})]})]})})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:e.jsx(C,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("div",{className:"block truncate font-medium text-foreground",children:t.title}),e.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),k(t.filename)},className:`inline-flex max-w-full items-center overflow-hidden rounded bg-muted px-2 py-1 font-mono text-xs text-muted-foreground transition-colors hover:bg-muted/80${r[t.filename]?" ring-1 ring-primary/50 text-foreground":""}`,title:"Copy file path to clipboard",children:e.jsxs("span",{className:"truncate",children:[".nut/context/knowledge/",t.filename]})})]})]}),e.jsx("div",{className:"hidden md:block",children:e.jsx(j,{variant:"secondary",className:"capitalize",children:t.metadata.category||"general"})}),e.jsx("div",{className:"hidden text-sm text-muted-foreground md:block",children:Y(t.metadata.updated)}),e.jsxs("div",{className:"hidden md:flex items-center gap-1 justify-end",children:[e.jsx(h,{variant:"ghost",size:"icon",onClick:a=>{a.stopPropagation(),D(t)},className:"h-8 w-8",title:"Discuss in chat",children:e.jsx(z,{className:"h-3.5 w-3.5"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:a=>{a.stopPropagation(),k(t.filename)},className:"h-8 w-8",title:"Copy file path to clipboard",children:r[t.filename]?e.jsx(I,{className:"h-3 w-3 text-green-600"}):e.jsx(K,{className:"h-3 w-3"})})]})]},t.filename))})]})]}),e.jsx(H,{open:m,onOpenChange:f,onImport:T})]})}export{ye as default};
@@ -1 +1 @@
1
- import{u as I,l as z,m as B,r as t,j as e,n as g,I as l,B as y,t as n}from"./index-BSBM4i_g.js";import{L as c}from"./label-vEgNxdb2.js";import{C as D,b as k,c as H,d as M,a as O}from"./card-Cnz8b7Ou.js";import{T as V,a as W,b as w,c as N}from"./tabs-DDbBXbPg.js";function Q(){const i=I(),o=z(),{login:b,register:C,isAuthenticated:h,authEnabled:x,isLoading:m}=B(),[a,d]=t.useState(!1),[L,S]=t.useState("login"),[p,E]=t.useState(""),[f,T]=t.useState(""),[j,F]=t.useState(""),[u,P]=t.useState(""),[v,R]=t.useState("");t.useEffect(()=>{if(!m){if(!x)i("/");else if(h){const s=o.state?.from?.pathname||"/";i(s,{replace:!0})}}},[x,h,m,i,o]);const A=async s=>{s.preventDefault(),d(!0);try{await b(p,f),n({title:"Success",description:"Logged in successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Login failed",description:r.message||"Invalid email or password",variant:"destructive"})}finally{d(!1)}},q=async s=>{if(s.preventDefault(),u.length<8){n({title:"Invalid password",description:"Password must be at least 8 characters",variant:"destructive"});return}d(!0);try{await C(j,u,v),n({title:"Success",description:"Account created successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Registration failed",description:r.message||"Failed to create account",variant:"destructive"})}finally{d(!1)}};return m?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(g,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-background to-muted p-4",children:e.jsxs(D,{className:"w-full max-w-md",children:[e.jsxs(k,{className:"space-y-1 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("svg",{className:"h-12 w-12 text-green-600",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z"})})}),e.jsx(H,{className:"text-2xl font-bold",children:"Welcome to Coconut"}),e.jsx(M,{children:"Sign in to your account or create a new one"})]}),e.jsx(O,{children:e.jsxs(V,{value:L,onValueChange:s=>S(s),children:[e.jsxs(W,{className:"grid w-full grid-cols-2",children:[e.jsx(w,{value:"login",children:"Login"}),e.jsx(w,{value:"register",children:"Register"})]}),e.jsx(N,{value:"login",className:"space-y-4",children:e.jsxs("form",{onSubmit:A,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-email",children:"Email"}),e.jsx(l,{id:"login-email",type:"email",placeholder:"you@example.com",value:p,onChange:s=>E(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-password",children:"Password"}),e.jsx(l,{id:"login-password",type:"password",value:f,onChange:s=>T(s.target.value),required:!0,disabled:a})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Logging in..."]}):"Login"})]})}),e.jsx(N,{value:"register",className:"space-y-4",children:e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-email",children:"Email"}),e.jsx(l,{id:"register-email",type:"email",placeholder:"you@example.com",value:j,onChange:s=>F(s.target.value),required:!0,disabled:a}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only whitelisted emails can register"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-name",children:"Name"}),e.jsx(l,{id:"register-name",type:"text",placeholder:"Your name",value:v,onChange:s=>R(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-password",children:"Password"}),e.jsx(l,{id:"register-password",type:"password",value:u,onChange:s=>P(s.target.value),required:!0,disabled:a,minLength:8}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"At least 8 characters"})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating account..."]}):"Create Account"})]})})]})})]})})}export{Q as default};
1
+ import{u as I,l as z,m as B,r as t,j as e,n as g,I as l,B as y,t as n}from"./index-Bbxvuj4b.js";import{L as c}from"./label-CZGCmBD7.js";import{C as D,b as k,c as H,d as M,a as O}from"./card-D_zGBKua.js";import{T as V,a as W,b as w,c as N}from"./tabs-Ug7Ug5Ha.js";function Q(){const i=I(),o=z(),{login:b,register:C,isAuthenticated:h,authEnabled:x,isLoading:m}=B(),[a,d]=t.useState(!1),[L,S]=t.useState("login"),[p,E]=t.useState(""),[f,T]=t.useState(""),[j,F]=t.useState(""),[u,P]=t.useState(""),[v,R]=t.useState("");t.useEffect(()=>{if(!m){if(!x)i("/");else if(h){const s=o.state?.from?.pathname||"/";i(s,{replace:!0})}}},[x,h,m,i,o]);const A=async s=>{s.preventDefault(),d(!0);try{await b(p,f),n({title:"Success",description:"Logged in successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Login failed",description:r.message||"Invalid email or password",variant:"destructive"})}finally{d(!1)}},q=async s=>{if(s.preventDefault(),u.length<8){n({title:"Invalid password",description:"Password must be at least 8 characters",variant:"destructive"});return}d(!0);try{await C(j,u,v),n({title:"Success",description:"Account created successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Registration failed",description:r.message||"Failed to create account",variant:"destructive"})}finally{d(!1)}};return m?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(g,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-background to-muted p-4",children:e.jsxs(D,{className:"w-full max-w-md",children:[e.jsxs(k,{className:"space-y-1 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("svg",{className:"h-12 w-12 text-green-600",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z"})})}),e.jsx(H,{className:"text-2xl font-bold",children:"Welcome to Coconut"}),e.jsx(M,{children:"Sign in to your account or create a new one"})]}),e.jsx(O,{children:e.jsxs(V,{value:L,onValueChange:s=>S(s),children:[e.jsxs(W,{className:"grid w-full grid-cols-2",children:[e.jsx(w,{value:"login",children:"Login"}),e.jsx(w,{value:"register",children:"Register"})]}),e.jsx(N,{value:"login",className:"space-y-4",children:e.jsxs("form",{onSubmit:A,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-email",children:"Email"}),e.jsx(l,{id:"login-email",type:"email",placeholder:"you@example.com",value:p,onChange:s=>E(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-password",children:"Password"}),e.jsx(l,{id:"login-password",type:"password",value:f,onChange:s=>T(s.target.value),required:!0,disabled:a})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Logging in..."]}):"Login"})]})}),e.jsx(N,{value:"register",className:"space-y-4",children:e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-email",children:"Email"}),e.jsx(l,{id:"register-email",type:"email",placeholder:"you@example.com",value:j,onChange:s=>F(s.target.value),required:!0,disabled:a}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only whitelisted emails can register"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-name",children:"Name"}),e.jsx(l,{id:"register-name",type:"text",placeholder:"Your name",value:v,onChange:s=>R(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-password",children:"Password"}),e.jsx(l,{id:"register-password",type:"password",value:u,onChange:s=>P(s.target.value),required:!0,disabled:a,minLength:8}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"At least 8 characters"})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating account..."]}):"Create Account"})]})})]})})]})})}export{Q as default};
@@ -0,0 +1 @@
1
+ import{j as e,S as ne,Y as E,r as f,aX as B,t as C,a1 as te,aV as ie,B as j,I as p,a0 as M,J as ae,T as oe,g as ce,ad as le}from"./index-Bbxvuj4b.js";import{C as P,b as F,c as O,d as R,a as $}from"./card-D_zGBKua.js";import{L as m}from"./label-CZGCmBD7.js";import{B as J}from"./badge-D7ZZbMEG.js";import{S as I}from"./switch-BYPAX9oF.js";import{A as q,a as z}from"./alert-D2VTq6m-.js";import{R as de,L as me}from"./browser-modal-CWDhylx7.js";import{R as he}from"./registry-ANRa5WBi.js";import{C as L}from"./circle-alert-DQD0CPB3.js";import{P as Y}from"./plus-Be79gWKj.js";import{C as xe}from"./circle-check-big-KfJvKA9H.js";import"./search-CrIdR7ah.js";function U(r){if(r){if(Array.isArray(r)){const t=r.map(o=>{if(typeof o=="string")return o.trim();if(typeof o=="number")return`${o}`}).filter(o=>typeof o=="string"&&o.length>0);return t.length>0?t:void 0}if(typeof r=="string"){const t=r.split(",").map(o=>o.trim()).filter(o=>o.length>0);return t.length>0?t:void 0}}}function K(r,t){const o=r.name||t.name,h=t.description||r.description||"",i={registryId:r.id,registryEndpoint:r.endpoint,registrySource:he,author:r.author||t.author};(t.version||r.version)&&(i.version=t.version||r.version);const d=U(t.tags)||U(r.tags);d&&(i.tags=d),t.capabilities&&Array.isArray(t.capabilities)&&(i.capabilities=t.capabilities),t.requirements&&typeof t.requirements=="object"&&(i.requirements=t.requirements),t.links&&typeof t.links=="object"&&(i.links=t.links),t.metadata&&typeof t.metadata=="object"&&(i.mcpMetadata=t.metadata);for(const[a,v]of Object.entries(i))v==null&&delete i[a];return{name:o,command:t.configuration.command,args:t.configuration.args,env:t.configuration.env,enabled:!0,description:h,metadata:Object.keys(i).length>0?i:void 0}}async function ve(r){const t=r.startsWith("http")?r:`https://registry.coconut.dev${r}`,o=await fetch(t,{headers:{Accept:"application/json","User-Agent":"coconut-frontend"}});if(!o.ok)throw new Error(`Failed to fetch MCP server detail: ${o.status}`);return o.json()}function pe({open:r,onOpenChange:t,onImport:o}){return e.jsx(de,{open:r,onOpenChange:t,categoryId:"mcp-servers",title:"Coconut Registry – MCP Servers",confirmLabel:"Add Server",getDetail:h=>ve(h.endpoint),renderPreview:(h,i)=>{if(!i)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select an MCP server to preview"});const d=K(h,i),a=d.metadata??{},v=typeof a.version=="string"?a.version:void 0,N=Array.isArray(h.tags)?h.tags:[],S=Array.isArray(a.capabilities)?a.capabilities.filter(g=>typeof g=="string"):[];return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(ne,{className:"h-full",children:e.jsx("div",{className:"space-y-6 p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:h.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i.description})]}),v&&e.jsxs(J,{variant:"outline",children:["v",v]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:h.id})]}),N.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(g=>e.jsx(J,{variant:"secondary",children:g},g))}),e.jsxs("div",{className:"space-y-2 rounded-md border p-3 bg-muted/50",children:[e.jsx("div",{className:"text-sm font-medium",children:"Configuration"}),e.jsxs("div",{className:"space-y-1 text-sm font-mono",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Command:"})," ",e.jsx("span",{className:"text-foreground",children:d.command})]}),d.args&&d.args.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Args:"})," ",e.jsx("span",{className:"text-foreground",children:d.args.join(" ")})]}),d.env&&Object.keys(d.env).length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Env:"})," ",e.jsx("span",{className:"text-foreground",children:JSON.stringify(d.env)})]})]})]}),S.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Capabilities"}),e.jsx("ul",{className:"list-disc pl-5 text-sm text-muted-foreground space-y-1",children:S.map(g=>e.jsx("li",{children:g},g))})]}),i.documentation&&e.jsxs("div",{className:"space-y-3",children:[i.documentation.overview&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Overview"}),e.jsx(E,{className:"[&_.prose]:max-w-none text-sm",children:i.documentation.overview})]}),i.documentation.installation&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Installation"}),e.jsx(E,{className:"[&_.prose]:max-w-none text-sm",children:i.documentation.installation})]}),i.documentation.usage&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Usage"}),e.jsx(E,{className:"[&_.prose]:max-w-none text-sm",children:i.documentation.usage})]}),i.documentation.examples&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Examples"}),e.jsx(E,{className:"[&_.prose]:max-w-none text-sm",children:i.documentation.examples})]})]})]})})})})},onConfirm:async(h,i)=>{const d=K(h,i);await o({summary:h,detail:i,payload:d})}})}function ke(){const[r,t]=f.useState({}),[o,h]=f.useState(!0),[i,d]=f.useState(!1),[a,v]=f.useState({name:"",command:"",args:"",env:"",description:"",enabled:!0}),[N,S]=f.useState(!1),[g,A]=f.useState(null),[c,b]=f.useState({name:"",command:"",args:"",env:"",description:"",enabled:!0}),[V,T]=f.useState(!1);f.useEffect(()=>{_()},[]);const _=async()=>{try{h(!0);const s=await B("/api/v1/mcp/raw-config");t(s||{})}catch(s){console.error("Failed to load MCP config:",s),C({title:"Error",description:"Failed to load MCP configuration",variant:"destructive"})}finally{h(!1)}},w=async s=>{try{d(!0),await B("/api/v1/mcp/raw-config",{method:"PUT",body:JSON.stringify(s)}),t(s),C({title:"Success",description:"MCP configuration saved successfully"})}catch(n){console.error("Failed to save MCP config:",n),C({title:"Error",description:"Failed to save MCP configuration",variant:"destructive"})}finally{d(!1)}},G=()=>{if(!a.name||!a.command){C({title:"Error",description:"Server name and command are required",variant:"destructive"});return}const s={name:a.name,command:a.command,enabled:a.enabled,description:a.description||void 0};if(a.args.trim()&&(s.args=a.args.split(" ").filter(x=>x.trim())),a.env.trim())try{s.env=JSON.parse(a.env)}catch{C({title:"Error",description:"Invalid JSON format for environment variables",variant:"destructive"});return}const n={...r,mcpServers:{...r.mcpServers,[a.name]:s}};w(n),v({name:"",command:"",args:"",env:"",description:"",enabled:!0}),S(!1)},H=(s,n)=>{const x={...r,mcpServers:{...r.mcpServers,[s]:{...r.mcpServers[s],enabled:n}}};w(x)},W=s=>{const{[s]:n,...x}=r.mcpServers||{},y={...r,mcpServers:x};w(y)},X=s=>{const n=r.mcpServers?.[s];n&&(b({name:n.name||s,command:n.command,args:n.args?.join(" ")||"",env:n.env?JSON.stringify(n.env,null,2):"",description:n.description||"",enabled:n.enabled!==!1}),A(s))},Q=s=>{if(!c.command){C({title:"Error",description:"Command is required",variant:"destructive"});return}const n={name:c.name,command:c.command,enabled:c.enabled,description:c.description||void 0};if(c.args.trim()&&(n.args=c.args.split(" ").filter(l=>l.trim())),c.env.trim())try{n.env=JSON.parse(c.env)}catch{C({title:"Error",description:"Invalid JSON format for environment variables",variant:"destructive"});return}const{[s]:x,...y}=r.mcpServers||{},u={...r,mcpServers:{...y,[s]:n}};w(u),A(null)},Z=()=>{A(null),b({name:"",command:"",args:"",env:"",description:"",enabled:!0})},k=s=>{const n={...r,globalSettings:{...r.globalSettings,...s}};w(n)},ee=async s=>{const{payload:n}=s;let x=n.name.toLowerCase().replace(/\s+/g,"-");const y=r.mcpServers||{};let u=x,l=1;for(;y[u];)u=`${x}-${l}`,l++;const se={name:u,command:n.command,args:n.args,env:n.env,enabled:n.enabled!==!1,description:n.description},re={...r,mcpServers:{...r.mcpServers,[u]:se}};await w(re),C({title:"Success",description:`MCP server "${u}" added from registry`})};if(o)return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"MCP Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading configuration..."})]})});const D=r.mcpServers||{};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"MCP Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Model Context Protocol servers and settings."})]}),e.jsx(te,{}),Object.keys(D).length===0&&!N&&e.jsxs(q,{children:[e.jsx(L,{className:"h-4 w-4"}),e.jsx(z,{children:"No MCP servers configured yet. Add your first server to get started."})]}),e.jsxs(P,{children:[e.jsx(F,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-5 w-5"}),"MCP Servers"]}),e.jsx(R,{className:"hidden sm:block",children:"Configure and manage Model Context Protocol servers for enhanced AI capabilities."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>T(!0),children:[e.jsx(me,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsxs(j,{size:"sm",onClick:()=>S(!N),variant:N?"outline":"default",children:[e.jsx(Y,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:N?"Cancel":"Add Server"})]})]})]})}),e.jsxs($,{children:[N&&e.jsxs("div",{className:"space-y-4 p-3 sm:p-4 border rounded-lg mb-4",children:[e.jsx("h4",{className:"font-medium",children:"Add MCP Server"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"serverName",children:"Server Name"}),e.jsx(p,{id:"serverName",value:a.name,onChange:s=>v({...a,name:s.target.value}),placeholder:"e.g., filesystem-server"})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:"serverCommand",children:"Command"}),e.jsx(p,{id:"serverCommand",value:a.command,onChange:s=>v({...a,command:s.target.value}),placeholder:"e.g., npx @modelcontextprotocol/server-filesystem"})]})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:"serverArgs",children:"Arguments (space-separated)"}),e.jsx(p,{id:"serverArgs",value:a.args,onChange:s=>v({...a,args:s.target.value}),placeholder:"e.g., /path/to/allowed/directory"})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:"serverEnv",children:"Environment Variables (JSON format)"}),e.jsx(M,{id:"serverEnv",value:a.env,onChange:s=>v({...a,env:s.target.value}),placeholder:'{"KEY": "value", "ANOTHER_KEY": "another_value"}',rows:3})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:"serverDescription",children:"Description (optional)"}),e.jsx(p,{id:"serverDescription",value:a.description,onChange:s=>v({...a,description:s.target.value}),placeholder:"Brief description of what this server provides"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{id:"serverEnabled",checked:a.enabled,onCheckedChange:s=>v({...a,enabled:s})}),e.jsx(m,{htmlFor:"serverEnabled",children:"Enable server"})]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs(j,{onClick:G,disabled:i,children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),"Add Server"]}),e.jsx(j,{variant:"outline",onClick:()=>S(!1),children:"Cancel"})]})]}),e.jsx("div",{className:"space-y-4",children:Object.entries(D).map(([s,n])=>{const x=n.enabled!==!1,y=n.name||s,u=g===s;return e.jsx("div",{className:"border rounded-lg",children:u?e.jsxs("div",{className:"space-y-4 p-3 sm:p-4",children:[e.jsx("h4",{className:"font-medium",children:"Edit MCP Server"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:`edit-name-${s}`,children:"Server Name"}),e.jsx(p,{id:`edit-name-${s}`,value:c.name,onChange:l=>b({...c,name:l.target.value}),placeholder:"e.g., filesystem-server"})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:`edit-command-${s}`,children:"Command"}),e.jsx(p,{id:`edit-command-${s}`,value:c.command,onChange:l=>b({...c,command:l.target.value}),placeholder:"e.g., npx @modelcontextprotocol/server-filesystem"})]})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:`edit-args-${s}`,children:"Arguments (space-separated)"}),e.jsx(p,{id:`edit-args-${s}`,value:c.args,onChange:l=>b({...c,args:l.target.value}),placeholder:"e.g., /path/to/allowed/directory"})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:`edit-env-${s}`,children:"Environment Variables (JSON format)"}),e.jsx(M,{id:`edit-env-${s}`,value:c.env,onChange:l=>b({...c,env:l.target.value}),placeholder:'{"KEY": "value", "ANOTHER_KEY": "another_value"}',rows:3})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:`edit-description-${s}`,children:"Description (optional)"}),e.jsx(p,{id:`edit-description-${s}`,value:c.description,onChange:l=>b({...c,description:l.target.value}),placeholder:"Brief description of what this server provides"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{id:`edit-enabled-${s}`,checked:c.enabled,onCheckedChange:l=>b({...c,enabled:l})}),e.jsx(m,{htmlFor:`edit-enabled-${s}`,children:"Enable server"})]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(j,{onClick:()=>Q(s),disabled:i,children:"Save Changes"}),e.jsx(j,{variant:"outline",onClick:Z,children:"Cancel"})]})]}):e.jsx("div",{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0 flex-1",children:[x?e.jsx(xe,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"}):e.jsx(L,{className:"h-4 w-4 text-gray-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h4",{className:"font-medium text-sm sm:text-base",children:y}),e.jsx(J,{variant:x?"default":"secondary",className:"text-xs",children:x?"Enabled":"Disabled"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:n.description||n.command}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:[e.jsx("span",{className:"font-medium",children:"Command:"})," ",n.command," ",n.args?.join(" ")]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 shrink-0",children:[e.jsx(I,{checked:x,onCheckedChange:l=>H(s,l),disabled:i}),e.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(s),children:e.jsx(ae,{className:"h-4 w-4"})}),e.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>W(s),disabled:i,children:e.jsx(oe,{className:"h-4 w-4"})})]})]})})},s)})})]})]}),e.jsxs(P,{children:[e.jsxs(F,{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"}),"Configuration File"]}),e.jsxs(R,{children:["The MCP configuration is stored in ",e.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:".nut/mcp/config.json"})]})]}),e.jsxs($,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"configJson",children:"Current Configuration (JSON)"}),e.jsx(M,{id:"configJson",value:JSON.stringify(r,null,2),readOnly:!0,rows:12,className:"font-mono text-sm",placeholder:"Loading configuration..."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This is a read-only view of the current configuration. Use the forms above to make changes."})]}),e.jsxs(q,{children:[e.jsx(L,{className:"h-4 w-4"}),e.jsx(z,{children:"Configuration changes are automatically saved to the MCP config file. This file can also be edited manually if you prefer working with JSON directly."})]})]})]}),e.jsxs(P,{children:[e.jsxs(F,{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-5 w-5"}),"Global Settings"]}),e.jsx(R,{children:"Configure global MCP behavior and connection settings."})]}),e.jsx($,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"timeout",children:"Connection Timeout (ms)"}),e.jsx(p,{id:"timeout",type:"number",value:r.globalSettings?.timeout||3e4,onChange:s=>k({timeout:parseInt(s.target.value)}),placeholder:"30000"})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:"retryAttempts",children:"Retry Attempts"}),e.jsx(p,{id:"retryAttempts",type:"number",value:r.globalSettings?.retryAttempts||3,onChange:s=>k({retryAttempts:parseInt(s.target.value)}),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:"logLevel",children:"Log Level"}),e.jsxs("select",{id:"logLevel",className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",value:r.globalSettings?.logLevel||"info",onChange:s=>k({logLevel:s.target.value}),children:[e.jsx("option",{value:"debug",children:"Debug"}),e.jsx("option",{value:"info",children:"Info"}),e.jsx("option",{value:"warn",children:"Warning"}),e.jsx("option",{value:"error",children:"Error"})]})]})]})})]}),e.jsx("div",{className:"flex justify-end space-x-2",children:e.jsx(j,{variant:"outline",onClick:_,disabled:o,children:"Reload Configuration"})}),e.jsx(pe,{open:V,onOpenChange:T,onImport:ee})]})}export{ke as default};
@@ -1 +1 @@
1
- import{u as _,H as z,r as a,j as e,B as b,L as k,i as J,I as A,a0 as W,ac as Y,A as P}from"./index-BSBM4i_g.js";import{C as G,b as K,c as Q,a as V}from"./card-Cnz8b7Ou.js";import{L as d}from"./label-vEgNxdb2.js";import{B as X}from"./badge-DO6e5hC1.js";import{c as Z}from"./clipboard-B9ndUJKl.js";import{A as O}from"./arrow-left-CEZFPQje.js";import{C as ee,a as te}from"./clipboard-BTZru8wn.js";function le(){const M=_(),{toast:p}=z(),[o,j]=a.useState(!1),[v,l]=a.useState(null),[m,E]=a.useState(""),[u,L]=a.useState(""),[c,T]=a.useState("blue"),[g,C]=a.useState([]),[h,F]=a.useState(""),[y,x]=a.useState([]),[B,N]=a.useState(!0),[I,w]=a.useState(!1),D=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],$={blue:{bg:"#3b82f6",border:"#1e40af",text:"#ffffff"},green:{bg:"#22c55e",border:"#15803d",text:"#ffffff"},red:{bg:"#ef4444",border:"#b91c1c",text:"#ffffff"},emerald:{bg:"#10b981",border:"#047857",text:"#ffffff"},purple:{bg:"#a855f7",border:"#7e22ce",text:"#ffffff"},orange:{bg:"#f97316",border:"#c2410c",text:"#ffffff"},yellow:{bg:"#eab308",border:"#a16207",text:"#ffffff"},teal:{bg:"#14b8a6",border:"#0f766e",text:"#ffffff"},indigo:{bg:"#6366f1",border:"#4338ca",text:"#ffffff"},pink:{bg:"#ec4899",border:"#be185d",text:"#ffffff"},cyan:{bg:"#06b6d4",border:"#0e7490",text:"#ffffff"},slate:{bg:"#64748b",border:"#475569",text:"#ffffff"},gray:{bg:"#6b7280",border:"#4b5563",text:"#ffffff"}};a.useEffect(()=>{let t=!0;return(async()=>{N(!0);try{const n=await fetch(`${P}/api/v1/mcp`);if(!n.ok)throw new Error("Failed to fetch MCP servers");const r=await n.json();if(!r?.success||!Array.isArray(r.servers)){t&&x([]);return}const R=r.mcpServers&&typeof r.mcpServers=="object"?r.mcpServers:{},S=r.servers.map(f=>{const i=R[f]??{};return{name:f,enabled:i?.enabled!==!1,description:typeof i?.description=="string"?i.description:void 0}});t&&(x(S),C(f=>f.filter(i=>S.some(U=>U.name===i))))}catch(n){console.error("Failed to load MCP servers",n),t&&x([])}finally{t&&N(!1)}})(),()=>{t=!1}},[]);const q=async()=>{const t=".nut/config.json";try{await Z(t),w(!0),p({title:"Copied!",description:`${t} copied to clipboard`}),setTimeout(()=>w(!1),2e3)}catch(s){console.error("Failed to copy config path:",s),p({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},H=async t=>{if(t.preventDefault(),!m.trim()||!u.trim()||!h.trim()){l("Name, description, and agent instructions are required");return}try{j(!0),l(null);const s={name:m.trim(),description:u.trim(),content:h.trim(),metadata:{color:c,tools:g.length>0?g:void 0}},r=await(await fetch(`${P}/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).json();r.success?M("/agents"):l(r.error?.message||"Failed to create agent")}catch(s){l(s instanceof Error?s.message:"Unknown error")}finally{j(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Create New Agent"}),e.jsx("p",{className:"text-muted-foreground",children:"Define an AI agent for automated development workflows"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(b,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(k,{to:"/agents",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(O,{className:"h-4 w-4"})})})})]}),e.jsxs(G,{children:[e.jsx(K,{children:e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"}),"Agent Configuration"]})}),e.jsx(V,{children:e.jsxs("form",{onSubmit:H,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"name",children:"Name *"}),e.jsx(A,{id:"name",placeholder:"e.g., code-reviewer",value:m,onChange:t=>E(t.target.value),disabled:o})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"description",children:"Description *"}),e.jsx(A,{id:"description",placeholder:"When should this agent be invoked?",value:u,onChange:t=>L(t.target.value),disabled:o})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:D.map(t=>{const s=$[t];return e.jsx("button",{type:"button",onClick:()=>T(t),disabled:o,className:`w-10 h-10 rounded-md border-2 transition-all ${c===t?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:s.bg,borderColor:c===t?s.border:"hsl(var(--border))",...c===t&&{"--tw-ring-color":s.border}},title:t,children:e.jsx("span",{className:"sr-only",children:t})},t)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"content",children:"Agent Instructions *"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["System prompt or instructions for this agent's behavior."," ","Insert ",e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:".nut/config.json"})," ",e.jsx("button",{type:"button",onClick:q,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:I?e.jsx(ee,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(te,{className:"h-3.5 w-3.5 ml-0.5"})})," ","if you want the agent to be able to access its name, role, or email address."]}),e.jsx(W,{id:"content",placeholder:"You are a code review agent that focuses on...",value:h,onChange:t=>F(t.target.value),rows:8,disabled:o,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Tools (Optional)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which MCP servers this agent should be able to use. Leave empty to inherit all available servers."}),e.jsx("div",{className:"space-y-2",children:B?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers…"}):y.length===0?e.jsx("div",{className:"text-sm text-muted-foreground border border-dashed rounded-md p-3",children:"No MCP servers configured yet. Configure servers in Settings → MCP."}):y.map(t=>e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-transparent bg-muted/30 px-3 py-2 hover:border-muted transition-colors",children:[e.jsx(Y,{checked:g.includes(t.name),onCheckedChange:s=>{C(n=>s===!0?n.includes(t.name)?n:[...n,t.name]:n.filter(r=>r!==t.name))},disabled:o||!t.enabled}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",children:[t.name,!t.enabled&&e.jsx(X,{variant:"secondary",className:"ml-2 text-xs",children:"Disabled"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.enabled?t.description||"Enabled MCP server":"Enable this server in Settings to allow agents to use it"})]})]},t.name))})]}),v&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:v}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(b,{type:"button",variant:"outline",asChild:!0,disabled:o,children:e.jsx(k,{to:"/agents",children:"Cancel"})}),e.jsx(b,{type:"submit",disabled:o,children:o?"Creating...":"Create Agent"})]})]})})]})]})}export{le as default};
1
+ import{u as _,H as z,r as a,j as e,B as b,L as k,i as J,I as A,a0 as W,ac as Y,A as P}from"./index-Bbxvuj4b.js";import{C as G,b as K,c as Q,a as V}from"./card-D_zGBKua.js";import{L as d}from"./label-CZGCmBD7.js";import{B as X}from"./badge-D7ZZbMEG.js";import{c as Z}from"./clipboard-B9ndUJKl.js";import{A as O}from"./arrow-left-Do2jUSS9.js";import{C as ee,a as te}from"./clipboard-D3NA8gb4.js";function le(){const M=_(),{toast:p}=z(),[o,j]=a.useState(!1),[v,l]=a.useState(null),[m,E]=a.useState(""),[u,L]=a.useState(""),[c,T]=a.useState("blue"),[g,C]=a.useState([]),[h,F]=a.useState(""),[y,x]=a.useState([]),[B,N]=a.useState(!0),[I,w]=a.useState(!1),D=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],$={blue:{bg:"#3b82f6",border:"#1e40af",text:"#ffffff"},green:{bg:"#22c55e",border:"#15803d",text:"#ffffff"},red:{bg:"#ef4444",border:"#b91c1c",text:"#ffffff"},emerald:{bg:"#10b981",border:"#047857",text:"#ffffff"},purple:{bg:"#a855f7",border:"#7e22ce",text:"#ffffff"},orange:{bg:"#f97316",border:"#c2410c",text:"#ffffff"},yellow:{bg:"#eab308",border:"#a16207",text:"#ffffff"},teal:{bg:"#14b8a6",border:"#0f766e",text:"#ffffff"},indigo:{bg:"#6366f1",border:"#4338ca",text:"#ffffff"},pink:{bg:"#ec4899",border:"#be185d",text:"#ffffff"},cyan:{bg:"#06b6d4",border:"#0e7490",text:"#ffffff"},slate:{bg:"#64748b",border:"#475569",text:"#ffffff"},gray:{bg:"#6b7280",border:"#4b5563",text:"#ffffff"}};a.useEffect(()=>{let t=!0;return(async()=>{N(!0);try{const n=await fetch(`${P}/api/v1/mcp`);if(!n.ok)throw new Error("Failed to fetch MCP servers");const r=await n.json();if(!r?.success||!Array.isArray(r.servers)){t&&x([]);return}const R=r.mcpServers&&typeof r.mcpServers=="object"?r.mcpServers:{},S=r.servers.map(f=>{const i=R[f]??{};return{name:f,enabled:i?.enabled!==!1,description:typeof i?.description=="string"?i.description:void 0}});t&&(x(S),C(f=>f.filter(i=>S.some(U=>U.name===i))))}catch(n){console.error("Failed to load MCP servers",n),t&&x([])}finally{t&&N(!1)}})(),()=>{t=!1}},[]);const q=async()=>{const t=".nut/config.json";try{await Z(t),w(!0),p({title:"Copied!",description:`${t} copied to clipboard`}),setTimeout(()=>w(!1),2e3)}catch(s){console.error("Failed to copy config path:",s),p({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},H=async t=>{if(t.preventDefault(),!m.trim()||!u.trim()||!h.trim()){l("Name, description, and agent instructions are required");return}try{j(!0),l(null);const s={name:m.trim(),description:u.trim(),content:h.trim(),metadata:{color:c,tools:g.length>0?g:void 0}},r=await(await fetch(`${P}/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).json();r.success?M("/agents"):l(r.error?.message||"Failed to create agent")}catch(s){l(s instanceof Error?s.message:"Unknown error")}finally{j(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Create New Agent"}),e.jsx("p",{className:"text-muted-foreground",children:"Define an AI agent for automated development workflows"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(b,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(k,{to:"/agents",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(O,{className:"h-4 w-4"})})})})]}),e.jsxs(G,{children:[e.jsx(K,{children:e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"}),"Agent Configuration"]})}),e.jsx(V,{children:e.jsxs("form",{onSubmit:H,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"name",children:"Name *"}),e.jsx(A,{id:"name",placeholder:"e.g., code-reviewer",value:m,onChange:t=>E(t.target.value),disabled:o})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"description",children:"Description *"}),e.jsx(A,{id:"description",placeholder:"When should this agent be invoked?",value:u,onChange:t=>L(t.target.value),disabled:o})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:D.map(t=>{const s=$[t];return e.jsx("button",{type:"button",onClick:()=>T(t),disabled:o,className:`w-10 h-10 rounded-md border-2 transition-all ${c===t?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:s.bg,borderColor:c===t?s.border:"hsl(var(--border))",...c===t&&{"--tw-ring-color":s.border}},title:t,children:e.jsx("span",{className:"sr-only",children:t})},t)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"content",children:"Agent Instructions *"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["System prompt or instructions for this agent's behavior."," ","Insert ",e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:".nut/config.json"})," ",e.jsx("button",{type:"button",onClick:q,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:I?e.jsx(ee,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(te,{className:"h-3.5 w-3.5 ml-0.5"})})," ","if you want the agent to be able to access its name, role, or email address."]}),e.jsx(W,{id:"content",placeholder:"You are a code review agent that focuses on...",value:h,onChange:t=>F(t.target.value),rows:8,disabled:o,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Tools (Optional)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which MCP servers this agent should be able to use. Leave empty to inherit all available servers."}),e.jsx("div",{className:"space-y-2",children:B?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers…"}):y.length===0?e.jsx("div",{className:"text-sm text-muted-foreground border border-dashed rounded-md p-3",children:"No MCP servers configured yet. Configure servers in Settings → MCP."}):y.map(t=>e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-transparent bg-muted/30 px-3 py-2 hover:border-muted transition-colors",children:[e.jsx(Y,{checked:g.includes(t.name),onCheckedChange:s=>{C(n=>s===!0?n.includes(t.name)?n:[...n,t.name]:n.filter(r=>r!==t.name))},disabled:o||!t.enabled}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",children:[t.name,!t.enabled&&e.jsx(X,{variant:"secondary",className:"ml-2 text-xs",children:"Disabled"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.enabled?t.description||"Enabled MCP server":"Enable this server in Settings to allow agents to use it"})]})]},t.name))})]}),v&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:v}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(b,{type:"button",variant:"outline",asChild:!0,disabled:o,children:e.jsx(k,{to:"/agents",children:"Cancel"})}),e.jsx(b,{type:"submit",disabled:o,children:o?"Creating...":"Create Agent"})]})]})})]})]})}export{le as default};
@@ -1,4 +1,4 @@
1
- import{u as S,H as E,r as a,j as e,B as p,n as L,a2 as T,L as b,I as A,A as I}from"./index-BSBM4i_g.js";import{C as i,b as c,c as l,a as d}from"./card-Cnz8b7Ou.js";import{L as m}from"./label-vEgNxdb2.js";import{M as B}from"./markdown-editor-O6tGYa1a.js";import{T as g}from"./TagInput-CbH9zq5n.js";import{A as P}from"./arrow-left-CEZFPQje.js";import"./badge-DO6e5hC1.js";function O(){const f=S(),{toast:s}=E(),[u,x]=a.useState(!1),[r,v]=a.useState(""),[n,w]=a.useState(""),[h,C]=a.useState([]),[j,k]=a.useState([]),N=async()=>{if(!r.trim()){s({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!n.trim()){s({title:"Error",description:"Please provide content for the knowledge document",variant:"destructive"});return}x(!0);try{const o=await(await fetch(`${I}/api/v1/context/knowledge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r.trim(),content:n.trim(),metadata:{tags:h,sources:j}})})).json();if(o.success){s({title:"Success",description:"Knowledge document created successfully"});const y=o.document.filename.replace(".md","");f(`/context/knowledge/${y}`)}else s({title:"Error",description:o.error||"Failed to create knowledge document",variant:"destructive"})}catch(t){console.error("Error creating document:",t),s({title:"Error",description:"Failed to create knowledge document",variant:"destructive"})}finally{x(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h1",{className:"text-3xl font-bold",children:"Create Knowledge Document"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(p,{onClick:N,disabled:u||!r.trim()||!n.trim(),size:"sm",children:[u?e.jsx(L,{className:"w-4 h-4 animate-spin"}):e.jsx(T,{className:"w-4 h-4"}),"Create Document"]}),e.jsx(p,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(b,{to:"/context/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(P,{className:"h-4 w-4"})})})]})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Basic Information"})}),e.jsx(d,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(m,{htmlFor:"title",children:"Title *"}),e.jsx(A,{id:"title",value:r,onChange:t=>v(t.target.value),placeholder:"Enter document title...",className:"text-lg"})]})})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Metadata"})}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{children:"Tags"}),e.jsx(g,{tags:h,onChange:C,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(m,{children:"Sources"}),e.jsx(g,{tags:j,onChange:k,placeholder:"Add a source (URL or name)"})]})]})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Content *"})}),e.jsx(d,{children:e.jsx(B,{value:n,onChange:t=>w(t||""),placeholder:`Enter your knowledge content in Markdown...
1
+ import{u as S,H as E,r as a,j as e,B as p,n as L,a2 as T,L as b,I as A,A as I}from"./index-Bbxvuj4b.js";import{C as i,b as c,c as l,a as d}from"./card-D_zGBKua.js";import{L as m}from"./label-CZGCmBD7.js";import{M as B}from"./markdown-editor-BiM9h5iI.js";import{T as g}from"./TagInput-Cqju3cXZ.js";import{A as P}from"./arrow-left-Do2jUSS9.js";import"./badge-D7ZZbMEG.js";function O(){const f=S(),{toast:s}=E(),[u,x]=a.useState(!1),[r,v]=a.useState(""),[n,w]=a.useState(""),[h,C]=a.useState([]),[j,k]=a.useState([]),N=async()=>{if(!r.trim()){s({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!n.trim()){s({title:"Error",description:"Please provide content for the knowledge document",variant:"destructive"});return}x(!0);try{const o=await(await fetch(`${I}/api/v1/context/knowledge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r.trim(),content:n.trim(),metadata:{tags:h,sources:j}})})).json();if(o.success){s({title:"Success",description:"Knowledge document created successfully"});const y=o.document.filename.replace(".md","");f(`/context/knowledge/${y}`)}else s({title:"Error",description:o.error||"Failed to create knowledge document",variant:"destructive"})}catch(t){console.error("Error creating document:",t),s({title:"Error",description:"Failed to create knowledge document",variant:"destructive"})}finally{x(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h1",{className:"text-3xl font-bold",children:"Create Knowledge Document"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(p,{onClick:N,disabled:u||!r.trim()||!n.trim(),size:"sm",children:[u?e.jsx(L,{className:"w-4 h-4 animate-spin"}):e.jsx(T,{className:"w-4 h-4"}),"Create Document"]}),e.jsx(p,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(b,{to:"/context/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(P,{className:"h-4 w-4"})})})]})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Basic Information"})}),e.jsx(d,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(m,{htmlFor:"title",children:"Title *"}),e.jsx(A,{id:"title",value:r,onChange:t=>v(t.target.value),placeholder:"Enter document title...",className:"text-lg"})]})})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Metadata"})}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{children:"Tags"}),e.jsx(g,{tags:h,onChange:C,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(m,{children:"Sources"}),e.jsx(g,{tags:j,onChange:k,placeholder:"Add a source (URL or name)"})]})]})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Content *"})}),e.jsx(d,{children:e.jsx(B,{value:n,onChange:t=>w(t||""),placeholder:`Enter your knowledge content in Markdown...
2
2
 
3
3
  You can use:
4
4
  - **Bold text**
@@ -1,4 +1,4 @@
1
- import{u as Q,H as G,m as Y,r as n,A as E,j as e,B as j,L as F,v as P,w as k,x as L,y as I,z as r,I as y,a2 as J,M as X,O as Z,P as ee,Q as te,R as se,U as ae,V as ie,W as ne}from"./index-BSBM4i_g.js";import{C as re,b as oe,c as le,a as ce}from"./card-Cnz8b7Ou.js";import{L as h}from"./label-vEgNxdb2.js";import{M as de}from"./markdown-editor-O6tGYa1a.js";import{C as he}from"./CollapsibleSection-msxUBh1L.js";import{I as ue,L as me}from"./ImplementationStepsEditor-BdHMNVVd.js";import{T as pe}from"./TagInput-CbH9zq5n.js";import{A as ge}from"./arrow-left-CEZFPQje.js";import"./plus-BfBtnncn.js";import"./badge-DO6e5hC1.js";const v={feature:{name:"New Feature",content:`## Problem Statement
1
+ import{u as Q,H as G,m as Y,r as n,A as E,j as e,B as j,L as F,v as P,w as k,x as L,y as I,z as r,I as y,a2 as J,M as X,O as Z,P as ee,Q as te,R as se,U as ae,V as ie,W as ne}from"./index-Bbxvuj4b.js";import{C as re,b as oe,c as le,a as ce}from"./card-D_zGBKua.js";import{L as h}from"./label-CZGCmBD7.js";import{M as de}from"./markdown-editor-BiM9h5iI.js";import{C as he}from"./CollapsibleSection-ZFq6LSXW.js";import{I as ue,L as me}from"./ImplementationStepsEditor-DZq7KcDP.js";import{T as pe}from"./TagInput-Cqju3cXZ.js";import{A as ge}from"./arrow-left-Do2jUSS9.js";import"./plus-Be79gWKj.js";import"./badge-D7ZZbMEG.js";const v={feature:{name:"New Feature",content:`## Problem Statement
2
2
  Describe the problem this new feature addresses.
3
3
 
4
4
  ## Proposed Solution
@@ -1,4 +1,4 @@
1
- import{u as L,H as I,r as i,A as S,j as e,B as C,L as M,a2 as A,I as p,v as B,w as D,x as T,y as O,z as j}from"./index-BSBM4i_g.js";import{C as m,a as x,b,c as P}from"./card-Cnz8b7Ou.js";import{L as l}from"./label-vEgNxdb2.js";import{M as V}from"./markdown-editor-O6tGYa1a.js";import{A as W}from"./arrow-left-CEZFPQje.js";import{C as z}from"./circle-check-big-B70gdce7.js";function K(){const E=L(),{toast:d}=I(),[a,v]=i.useState({project:{name:"",description:"",website:"",version:"1.0.0",stage:"development"}}),[u,g]=i.useState(""),[F,f]=i.useState(!0),[y,w]=i.useState(!1);i.useEffect(()=>{fetch(`${S}/api/v1/context/project`).then(t=>t.json()).then(t=>{if(t.success){const s=t.document;v({project:{name:s.metadata.project?.name||"",description:s.metadata.project?.description||"",website:s.metadata.project?.website||s.metadata.project?.repository||"",version:s.metadata.project?.version||"1.0.0",stage:s.metadata.project?.stage||"development"}}),g(s.content.trim())}f(!1)}).catch(t=>{console.error("Failed to load context:",t),d({title:"Error",description:"Failed to load project context",variant:"destructive"}),f(!1)})},[d]);const k=async()=>{w(!0);try{const s={project:Object.fromEntries(Object.entries(a.project).map(([o,r])=>[o,typeof r=="string"?r.trim():r]))},n=await(await fetch(`${S}/api/v1/context/project`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:u,metadata:s})})).json();if(n.success)d({title:"Success",description:"Project context saved successfully",action:e.jsx(z,{className:"h-4 w-4"})}),E("/context/project");else throw new Error(n.error||"Failed to save context")}catch(t){console.error("Save error:",t),d({title:"Error",description:"Failed to save project context",variant:"destructive"})}finally{w(!1)}},c=(t,s)=>{v(N=>{const n={...N},o=t.split(".");let r=n;for(let h=0;h<o.length-1;h++)r=r[o[h]];return r[o[o.length-1]]=s,n})};return F?e.jsx("div",{className:"space-y-6",children:e.jsx(m,{children:e.jsx(x,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Project Overview"}),e.jsx("p",{className:"text-muted-foreground",children:"Edit project information and documentation"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(M,{to:"/context/project",children:[e.jsx(W,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Back"})]})}),e.jsxs(C,{size:"sm",onClick:k,disabled:y,children:[e.jsx(A,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:y?"Saving...":"Save"})]})]})]}),e.jsxs(m,{children:[e.jsx(b,{children:e.jsx(P,{children:"Project Information"})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-name",children:"Project Name"}),e.jsx(p,{id:"project-name",value:a.project.name,onChange:t=>c("project.name",t.target.value),placeholder:"My Awesome Project"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-version",children:"Version"}),e.jsx(p,{id:"project-version",value:a.project.version,onChange:t=>c("project.version",t.target.value),placeholder:"1.0.0"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-description",children:"Description"}),e.jsx(p,{id:"project-description",value:a.project.description,onChange:t=>c("project.description",t.target.value),placeholder:"Brief description of what this project does"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-website",children:"Website"}),e.jsx(p,{id:"project-website",value:a.project.website,onChange:t=>c("project.website",t.target.value),placeholder:"https://yourproject.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-stage",children:"Development Stage"}),e.jsxs(B,{value:a.project.stage,onValueChange:t=>c("project.stage",t),children:[e.jsx(D,{children:e.jsx(T,{placeholder:"Select stage"})}),e.jsxs(O,{children:[e.jsx(j,{value:"prototype",children:"Prototype"}),e.jsx(j,{value:"development",children:"Development"}),e.jsx(j,{value:"mvp",children:"MVP"}),e.jsx(j,{value:"production",children:"Production"})]})]})]})]})]})]}),e.jsxs(m,{children:[e.jsx(b,{children:e.jsx(P,{children:"Documentation"})}),e.jsx(x,{children:e.jsx(V,{value:u,onChange:t=>g(t||""),placeholder:`Write your project documentation in markdown...
1
+ import{u as L,H as I,r as i,A as S,j as e,B as C,L as M,a2 as A,I as p,v as B,w as D,x as T,y as O,z as j}from"./index-Bbxvuj4b.js";import{C as m,a as x,b,c as P}from"./card-D_zGBKua.js";import{L as l}from"./label-CZGCmBD7.js";import{M as V}from"./markdown-editor-BiM9h5iI.js";import{A as W}from"./arrow-left-Do2jUSS9.js";import{C as z}from"./circle-check-big-KfJvKA9H.js";function K(){const E=L(),{toast:d}=I(),[a,v]=i.useState({project:{name:"",description:"",website:"",version:"1.0.0",stage:"development"}}),[u,g]=i.useState(""),[F,f]=i.useState(!0),[y,w]=i.useState(!1);i.useEffect(()=>{fetch(`${S}/api/v1/context/project`).then(t=>t.json()).then(t=>{if(t.success){const s=t.document;v({project:{name:s.metadata.project?.name||"",description:s.metadata.project?.description||"",website:s.metadata.project?.website||s.metadata.project?.repository||"",version:s.metadata.project?.version||"1.0.0",stage:s.metadata.project?.stage||"development"}}),g(s.content.trim())}f(!1)}).catch(t=>{console.error("Failed to load context:",t),d({title:"Error",description:"Failed to load project context",variant:"destructive"}),f(!1)})},[d]);const k=async()=>{w(!0);try{const s={project:Object.fromEntries(Object.entries(a.project).map(([o,r])=>[o,typeof r=="string"?r.trim():r]))},n=await(await fetch(`${S}/api/v1/context/project`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:u,metadata:s})})).json();if(n.success)d({title:"Success",description:"Project context saved successfully",action:e.jsx(z,{className:"h-4 w-4"})}),E("/context/project");else throw new Error(n.error||"Failed to save context")}catch(t){console.error("Save error:",t),d({title:"Error",description:"Failed to save project context",variant:"destructive"})}finally{w(!1)}},c=(t,s)=>{v(N=>{const n={...N},o=t.split(".");let r=n;for(let h=0;h<o.length-1;h++)r=r[o[h]];return r[o[o.length-1]]=s,n})};return F?e.jsx("div",{className:"space-y-6",children:e.jsx(m,{children:e.jsx(x,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Project Overview"}),e.jsx("p",{className:"text-muted-foreground",children:"Edit project information and documentation"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(M,{to:"/context/project",children:[e.jsx(W,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Back"})]})}),e.jsxs(C,{size:"sm",onClick:k,disabled:y,children:[e.jsx(A,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:y?"Saving...":"Save"})]})]})]}),e.jsxs(m,{children:[e.jsx(b,{children:e.jsx(P,{children:"Project Information"})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-name",children:"Project Name"}),e.jsx(p,{id:"project-name",value:a.project.name,onChange:t=>c("project.name",t.target.value),placeholder:"My Awesome Project"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-version",children:"Version"}),e.jsx(p,{id:"project-version",value:a.project.version,onChange:t=>c("project.version",t.target.value),placeholder:"1.0.0"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-description",children:"Description"}),e.jsx(p,{id:"project-description",value:a.project.description,onChange:t=>c("project.description",t.target.value),placeholder:"Brief description of what this project does"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-website",children:"Website"}),e.jsx(p,{id:"project-website",value:a.project.website,onChange:t=>c("project.website",t.target.value),placeholder:"https://yourproject.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-stage",children:"Development Stage"}),e.jsxs(B,{value:a.project.stage,onValueChange:t=>c("project.stage",t),children:[e.jsx(D,{children:e.jsx(T,{placeholder:"Select stage"})}),e.jsxs(O,{children:[e.jsx(j,{value:"prototype",children:"Prototype"}),e.jsx(j,{value:"development",children:"Development"}),e.jsx(j,{value:"mvp",children:"MVP"}),e.jsx(j,{value:"production",children:"Production"})]})]})]})]})]})]}),e.jsxs(m,{children:[e.jsx(b,{children:e.jsx(P,{children:"Documentation"})}),e.jsx(x,{children:e.jsx(V,{value:u,onChange:t=>g(t||""),placeholder:`Write your project documentation in markdown...
2
2
 
3
3
  ## What is this project?
4
4