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

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 (241) hide show
  1. package/dist/lib/auth/auth-manager.d.ts.map +1 -0
  2. package/dist/lib/auth/auth-manager.js.map +1 -0
  3. package/dist/lib/gait-path.d.ts.map +1 -0
  4. package/dist/lib/gait-path.js.map +1 -0
  5. package/dist/lib/git-settings.d.ts.map +1 -0
  6. package/dist/lib/git-settings.js.map +1 -0
  7. package/dist/lib/git.d.ts.map +1 -0
  8. package/dist/lib/git.js.map +1 -0
  9. package/dist/lib/jobs/global-job-scheduler.d.ts.map +1 -0
  10. package/dist/lib/jobs/global-job-scheduler.js.map +1 -0
  11. package/dist/lib/jobs/job-runner.d.ts.map +1 -0
  12. package/dist/lib/jobs/job-runner.js.map +1 -0
  13. package/dist/lib/jobs/job-scheduler.d.ts.map +1 -0
  14. package/dist/lib/jobs/job-scheduler.js.map +1 -0
  15. package/dist/lib/jobs/job-store.d.ts.map +1 -0
  16. package/dist/lib/jobs/job-store.js.map +1 -0
  17. package/dist/lib/project-paths.d.ts.map +1 -0
  18. package/dist/lib/project-paths.js.map +1 -0
  19. package/dist/lib/storage/file-storage.d.ts.map +1 -0
  20. package/dist/lib/storage/file-storage.js.map +1 -0
  21. package/dist/lib/symlinks/symlink-manager.d.ts.map +1 -0
  22. package/dist/lib/symlinks/symlink-manager.js.map +1 -0
  23. package/dist/lib/symlinks/types.d.ts.map +1 -0
  24. package/dist/lib/symlinks/types.js.map +1 -0
  25. package/dist/lib/terminal/context-helper.d.ts.map +1 -0
  26. package/dist/lib/terminal/context-helper.js.map +1 -0
  27. package/dist/lib/terminal/global-manager.d.ts.map +1 -0
  28. package/dist/lib/terminal/global-manager.js.map +1 -0
  29. package/dist/lib/terminal/shell-utils.d.ts.map +1 -0
  30. package/dist/lib/terminal/shell-utils.js.map +1 -0
  31. package/dist/lib/terminal/terminal-manager.d.ts.map +1 -0
  32. package/dist/lib/terminal/terminal-manager.js.map +1 -0
  33. package/dist/lib/user-preferences.d.ts.map +1 -0
  34. package/dist/lib/user-preferences.js.map +1 -0
  35. package/dist/middleware/auth.d.ts.map +1 -0
  36. package/dist/middleware/auth.js.map +1 -0
  37. package/dist/routes/api/v1/agents/[id]/index.d.ts.map +1 -0
  38. package/dist/routes/api/v1/agents/[id]/index.js.map +1 -0
  39. package/dist/routes/api/v1/agents/[id]/route.d.ts.map +1 -0
  40. package/dist/routes/api/v1/agents/[id]/route.js.map +1 -0
  41. package/dist/routes/api/v1/agents/index.d.ts.map +1 -0
  42. package/dist/routes/api/v1/agents/index.js.map +1 -0
  43. package/dist/routes/api/v1/agents/route.d.ts.map +1 -0
  44. package/dist/routes/api/v1/agents/route.js.map +1 -0
  45. package/dist/routes/api/v1/ai/index.d.ts.map +1 -0
  46. package/dist/routes/api/v1/ai/index.js.map +1 -0
  47. package/dist/routes/api/v1/ai/route.d.ts.map +1 -0
  48. package/dist/routes/api/v1/ai/route.js +6 -1
  49. package/dist/routes/api/v1/ai/route.js.map +1 -0
  50. package/dist/routes/api/v1/ai/tools.js +6 -1
  51. package/dist/routes/api/v1/api-keys/index.d.ts.map +1 -0
  52. package/dist/routes/api/v1/api-keys/index.js.map +1 -0
  53. package/dist/routes/api/v1/api-keys/route.d.ts.map +1 -0
  54. package/dist/routes/api/v1/api-keys/route.js.map +1 -0
  55. package/dist/routes/api/v1/auth/index.d.ts.map +1 -0
  56. package/dist/routes/api/v1/auth/index.js.map +1 -0
  57. package/dist/routes/api/v1/auth/route.d.ts.map +1 -0
  58. package/dist/routes/api/v1/auth/route.js.map +1 -0
  59. package/dist/routes/api/v1/auth-settings/index.d.ts.map +1 -0
  60. package/dist/routes/api/v1/auth-settings/index.js.map +1 -0
  61. package/dist/routes/api/v1/auth-settings/route.d.ts.map +1 -0
  62. package/dist/routes/api/v1/auth-settings/route.js.map +1 -0
  63. package/dist/routes/api/v1/chats/[id]/index.d.ts.map +1 -0
  64. package/dist/routes/api/v1/chats/[id]/index.js.map +1 -0
  65. package/dist/routes/api/v1/chats/[id]/route.d.ts.map +1 -0
  66. package/dist/routes/api/v1/chats/[id]/route.js.map +1 -0
  67. package/dist/routes/api/v1/chats/index.d.ts.map +1 -0
  68. package/dist/routes/api/v1/chats/index.js.map +1 -0
  69. package/dist/routes/api/v1/chats/route.d.ts.map +1 -0
  70. package/dist/routes/api/v1/chats/route.js.map +1 -0
  71. package/dist/routes/api/v1/config/index.d.ts.map +1 -0
  72. package/dist/routes/api/v1/config/index.js.map +1 -0
  73. package/dist/routes/api/v1/config/route.d.ts.map +1 -0
  74. package/dist/routes/api/v1/config/route.js.map +1 -0
  75. package/dist/routes/api/v1/context/architecture/route.d.ts.map +1 -0
  76. package/dist/routes/api/v1/context/architecture/route.js.map +1 -0
  77. package/dist/routes/api/v1/context/index.d.ts.map +1 -0
  78. package/dist/routes/api/v1/context/index.js.map +1 -0
  79. package/dist/routes/api/v1/context/knowledge/[filename]/index.d.ts.map +1 -0
  80. package/dist/routes/api/v1/context/knowledge/[filename]/index.js.map +1 -0
  81. package/dist/routes/api/v1/context/knowledge/[filename]/route.d.ts.map +1 -0
  82. package/dist/routes/api/v1/context/knowledge/[filename]/route.js +5 -2
  83. package/dist/routes/api/v1/context/knowledge/[filename]/route.js.map +1 -0
  84. package/dist/routes/api/v1/context/knowledge/index.d.ts.map +1 -0
  85. package/dist/routes/api/v1/context/knowledge/index.js.map +1 -0
  86. package/dist/routes/api/v1/context/knowledge/route.d.ts.map +1 -0
  87. package/dist/routes/api/v1/context/knowledge/route.js +5 -2
  88. package/dist/routes/api/v1/context/knowledge/route.js.map +1 -0
  89. package/dist/routes/api/v1/context/project/route.d.ts.map +1 -0
  90. package/dist/routes/api/v1/context/project/route.js.map +1 -0
  91. package/dist/routes/api/v1/events/status/route.d.ts +1 -1
  92. package/dist/routes/api/v1/git/index.d.ts.map +1 -0
  93. package/dist/routes/api/v1/git/index.js.map +1 -0
  94. package/dist/routes/api/v1/jobs/[id]/route.d.ts.map +1 -0
  95. package/dist/routes/api/v1/jobs/[id]/route.js.map +1 -0
  96. package/dist/routes/api/v1/jobs/[id]/run/route.d.ts +2 -2
  97. package/dist/routes/api/v1/jobs/[id]/run/route.d.ts.map +1 -0
  98. package/dist/routes/api/v1/jobs/[id]/run/route.js.map +1 -0
  99. package/dist/routes/api/v1/jobs/index.d.ts.map +1 -0
  100. package/dist/routes/api/v1/jobs/index.js.map +1 -0
  101. package/dist/routes/api/v1/jobs/route.d.ts.map +1 -0
  102. package/dist/routes/api/v1/jobs/route.js.map +1 -0
  103. package/dist/routes/api/v1/jobs/status/route.d.ts +1 -1
  104. package/dist/routes/api/v1/jobs/status/route.d.ts.map +1 -0
  105. package/dist/routes/api/v1/jobs/status/route.js.map +1 -0
  106. package/dist/routes/api/v1/mcp/index.d.ts.map +1 -0
  107. package/dist/routes/api/v1/mcp/index.js +6 -1
  108. package/dist/routes/api/v1/mcp/index.js.map +1 -0
  109. package/dist/routes/api/v1/mcp/route.d.ts.map +1 -0
  110. package/dist/routes/api/v1/mcp/route.js.map +1 -0
  111. package/dist/routes/api/v1/proposals/[id]/route.d.ts +8 -8
  112. package/dist/routes/api/v1/proposals/[id]/route.d.ts.map +1 -0
  113. package/dist/routes/api/v1/proposals/[id]/route.js.map +1 -0
  114. package/dist/routes/api/v1/proposals/index.d.ts.map +1 -0
  115. package/dist/routes/api/v1/proposals/index.js.map +1 -0
  116. package/dist/routes/api/v1/proposals/route.d.ts.map +1 -0
  117. package/dist/routes/api/v1/proposals/route.js.map +1 -0
  118. package/dist/routes/api/v1/resources/[id]/index.d.ts.map +1 -0
  119. package/dist/routes/api/v1/resources/[id]/index.js.map +1 -0
  120. package/dist/routes/api/v1/resources/[id]/route.js.map +1 -0
  121. package/dist/routes/api/v1/resources/[id]/thumbnail/index.d.ts.map +1 -0
  122. package/dist/routes/api/v1/resources/[id]/thumbnail/index.js.map +1 -0
  123. package/dist/routes/api/v1/resources/[id]/thumbnail/route.js.map +1 -0
  124. package/dist/routes/api/v1/resources/index.d.ts.map +1 -0
  125. package/dist/routes/api/v1/resources/index.js.map +1 -0
  126. package/dist/routes/api/v1/resources/route.d.ts.map +1 -0
  127. package/dist/routes/api/v1/resources/route.js.map +1 -0
  128. package/dist/routes/api/v1/symlinks/index.d.ts.map +1 -0
  129. package/dist/routes/api/v1/symlinks/index.js.map +1 -0
  130. package/dist/routes/api/v1/symlinks/route.d.ts.map +1 -0
  131. package/dist/routes/api/v1/symlinks/route.js.map +1 -0
  132. package/dist/routes/api/v1/terminal/[proposalId]/create/index.d.ts.map +1 -0
  133. package/dist/routes/api/v1/terminal/[proposalId]/create/index.js.map +1 -0
  134. package/dist/routes/api/v1/terminal/[proposalId]/create/route.d.ts.map +1 -0
  135. package/dist/routes/api/v1/terminal/[proposalId]/create/route.js.map +1 -0
  136. package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.d.ts.map +1 -0
  137. package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.js.map +1 -0
  138. package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.d.ts.map +1 -0
  139. package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.js.map +1 -0
  140. package/dist/routes/api/v1/terminal/[proposalId]/resize/index.d.ts.map +1 -0
  141. package/dist/routes/api/v1/terminal/[proposalId]/resize/index.js.map +1 -0
  142. package/dist/routes/api/v1/terminal/[proposalId]/resize/route.d.ts.map +1 -0
  143. package/dist/routes/api/v1/terminal/[proposalId]/resize/route.js.map +1 -0
  144. package/dist/routes/api/v1/terminal/sessions/index.d.ts.map +1 -0
  145. package/dist/routes/api/v1/terminal/sessions/index.js.map +1 -0
  146. package/dist/routes/api/v1/terminal/sessions/route.d.ts.map +1 -0
  147. package/dist/routes/api/v1/terminal/sessions/route.js.map +1 -0
  148. package/dist/routes/api/v1/user/index.d.ts.map +1 -0
  149. package/dist/routes/api/v1/user/index.js.map +1 -0
  150. package/dist/routes/api/v1/user/settings/index.d.ts.map +1 -0
  151. package/dist/routes/api/v1/user/settings/index.js.map +1 -0
  152. package/dist/routes/api/v1/user/settings/route.d.ts.map +1 -0
  153. package/dist/routes/api/v1/user/settings/route.js.map +1 -0
  154. package/dist/server-with-static.d.ts.map +1 -0
  155. package/dist/server-with-static.js.map +1 -0
  156. package/dist/server.d.ts.map +1 -0
  157. package/dist/server.js.map +1 -0
  158. package/package.json +4 -4
  159. package/static/assets/AgentDetailPage-DwWIjGx1.js +1 -0
  160. package/static/assets/AgentEditPage-BvVPfYR3.js +1 -0
  161. package/static/assets/AgentsPage-D-Uy87Gh.js +3 -0
  162. package/static/assets/AgentsSettingsPage-CDuAvFxu.js +6 -0
  163. package/static/assets/ApiKeysSettingsPage-Jug0kB7Z.js +7 -0
  164. package/static/assets/ArchitectureEditPage-BmAgJAMV.js +21 -0
  165. package/static/assets/ArchitecturePage-ZjbdnDA7.js +1 -0
  166. package/static/assets/AuthSettingsPage-_pXoewOB.js +11 -0
  167. package/static/assets/CallbackPage-CaAOpz4z.js +1 -0
  168. package/static/assets/CodePage-DEbgr8C1.js +2 -0
  169. package/static/assets/CollapsibleSection-msxUBh1L.js +1 -0
  170. package/static/assets/DashboardPage-BXu-fikP.js +11 -0
  171. package/static/assets/GitPage-B7qFcP-K.js +16 -0
  172. package/static/assets/GitSettingsPage-D7GjdOnE.js +6 -0
  173. package/static/assets/IdentityPage-BR48gNhN.js +11 -0
  174. package/static/assets/ImplementationStepsEditor-BdHMNVVd.js +6 -0
  175. package/static/assets/IntegrationsSettingsPage-B1OHGlDC.js +1 -0
  176. package/static/assets/KnowledgeDetailPage-DBOQQs3R.js +1 -0
  177. package/static/assets/KnowledgeEditPage-DHJxLPwi.js +1 -0
  178. package/static/assets/KnowledgePage-CuuDTMa_.js +8 -0
  179. package/static/assets/LoginPage-IIU6NAG9.js +1 -0
  180. package/static/assets/McpSettingsPage-iz5gLGWt.js +1 -0
  181. package/static/assets/NewAgentPage-DolltGy5.js +1 -0
  182. package/static/assets/NewKnowledgePage-_jbUZqBU.js +9 -0
  183. package/static/assets/NewProposalPage-bFnfuuoA.js +90 -0
  184. package/static/assets/ProjectEditPage-DTTjPnGj.js +11 -0
  185. package/static/assets/ProjectPage-DhwrnEq2.js +1 -0
  186. package/static/assets/PromptsSettingsPage-DLOVysbE.js +1 -0
  187. package/static/assets/ProposalDetailPage-KvjXUaaf.js +1 -0
  188. package/static/assets/ProposalEditPage-BmzkHL9a.js +1 -0
  189. package/static/assets/ProposalsPage-DwQr1ycd.js +17 -0
  190. package/static/assets/ResourcesPage-B8Hm_j47.js +66 -0
  191. package/static/assets/RulesSettingsPage-CsGXFTFY.js +16 -0
  192. package/static/assets/SchedulePage-CY8GdQlp.js +4 -0
  193. package/static/assets/TagInput-CbH9zq5n.js +1 -0
  194. package/static/assets/TerminalPage-DsjOLnyY.js +1 -0
  195. package/static/assets/TerminalSessionPage-DQ065WYU.js +13 -0
  196. package/static/assets/UserPreferencesPage-55VTrzfQ.js +1 -0
  197. package/static/assets/UserSettingsPage-BZwb93B4.js +1 -0
  198. package/static/assets/UtilitiesPage-BmEW7eJ_.js +1 -0
  199. package/static/assets/alert-CNSGDe1U.js +1 -0
  200. package/static/assets/arrow-down-D1dapxzl.js +6 -0
  201. package/static/assets/arrow-left-CEZFPQje.js +6 -0
  202. package/static/assets/arrow-up-D-lB4Ah6.js +6 -0
  203. package/static/assets/badge-DO6e5hC1.js +1 -0
  204. package/static/assets/browser-modal-BTxVvZIA.js +6 -0
  205. package/static/assets/calendar-DWaFMSXH.js +6 -0
  206. package/static/assets/card-Cnz8b7Ou.js +1 -0
  207. package/static/assets/chevron-left-CNgc28Tc.js +6 -0
  208. package/static/assets/circle-alert-Dick-jNf.js +6 -0
  209. package/static/assets/circle-check-DDk43rYV.js +6 -0
  210. package/static/assets/circle-check-big-B70gdce7.js +6 -0
  211. package/static/assets/circle-play-TJEfmKde.js +6 -0
  212. package/static/assets/circle-x-BfR2YcXx.js +6 -0
  213. package/static/assets/clipboard-B9ndUJKl.js +1 -0
  214. package/static/assets/clipboard-BTZru8wn.js +11 -0
  215. package/static/assets/clock-DQXbrDkQ.js +6 -0
  216. package/static/assets/download-CW_rWwud.js +6 -0
  217. package/static/assets/droid-CmYuCN_q.js +4 -0
  218. package/static/assets/eye-Bv6mO2ld.js +6 -0
  219. package/static/assets/folder-git-2-Cv5NbBZZ.js +6 -0
  220. package/static/assets/index-BSBM4i_g.js +458 -0
  221. package/static/assets/index-CKwmN6yL.css +2 -0
  222. package/static/assets/label-vEgNxdb2.js +1 -0
  223. package/static/assets/markdown-editor-DUEthZ0y.css +1 -0
  224. package/static/assets/markdown-editor-O6tGYa1a.js +62 -0
  225. package/static/assets/pause-6aQLhmG9.js +6 -0
  226. package/static/assets/play-DsDsjO2V.js +6 -0
  227. package/static/assets/plus-BfBtnncn.js +6 -0
  228. package/static/assets/radio-group-D_RD_9vY.js +1 -0
  229. package/static/assets/refresh-cw-DvFNtws1.js +6 -0
  230. package/static/assets/search-kcgmZUqQ.js +6 -0
  231. package/static/assets/switch-Bjq8cgQn.js +1 -0
  232. package/static/assets/tabs-DDbBXbPg.js +1 -0
  233. package/static/assets/tag-Czz-3rNY.js +6 -0
  234. package/static/assets/terminal-preview-B7iP2vUT.js +11 -0
  235. package/static/assets/use-terminal-CN3pheMp.js +1 -0
  236. package/static/assets/xterm-DTxiCjtJ.js +9 -0
  237. package/static/assets/xterm-qxJ8_QYu.css +32 -0
  238. package/static/assets/zap-BMkP_c9R.js +6 -0
  239. package/static/index.html +2 -2
  240. package/static/assets/index-B2wygg2W.css +0 -33
  241. package/static/assets/index-CYlVRUG2.js +0 -969
@@ -0,0 +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(`
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};
@@ -0,0 +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};
@@ -0,0 +1,11 @@
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";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const J=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]],Q=W("file-chart-column-increasing",J);/**
7
+ * @license lucide-react v0.542.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Z=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],K=W("rocket",Z);function X({open:d,onOpenChange:g,workflows:y}){const[a,h]=m.useState(null),[o,u]=m.useState(0),C=t=>{h(t),u(0)},s=()=>{o>0?u(o-1):h(null)},v=()=>{a&&o<a.steps.length-1&&u(o+1)},p=()=>{h(null),u(0),g(!1)},x=()=>e.jsxs("div",{className:"space-y-6",children:[e.jsxs(S,{children:[e.jsx(A,{className:"text-2xl",children:"Getting Started Wizard"}),e.jsx(P,{children:"Choose a workflow to get started with Coconut. We'll guide you through each step."})]}),e.jsx(z,{className:"h-[500px] pr-4",children:e.jsx("div",{className:"space-y-3",children:y.map(t=>e.jsx(c,{className:"cursor-pointer hover:bg-accent hover:border-accent-foreground/20 transition-colors",onClick:()=>C(t),children:e.jsx(l,{className:"p-6",children:e.jsxs("div",{className:"flex items-start space-x-4",children:[e.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-lg bg-primary/10 flex items-center justify-center text-primary",children:t.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:t.title}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:t.description}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(Y,{variant:"secondary",className:"text-xs",children:[t.steps.length," steps"]}),e.jsx(D,{className:"h-4 w-4 text-muted-foreground"})]})]})]})})},t.id))})})]}),b=()=>{if(!a)return null;const t=a.steps[o],i=o===a.steps.length-1;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(S,{children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center text-primary",children:a.icon}),e.jsxs("div",{className:"flex-1",children:[e.jsx(A,{className:"text-xl",children:a.title}),e.jsxs(P,{children:["Step ",o+1," of ",a.steps.length]})]})]}),e.jsx("div",{className:"flex items-center space-x-2 pt-2",children:a.steps.map((k,w)=>e.jsx("div",{className:I("h-1.5 flex-1 rounded-full transition-colors",w<=o?"bg-primary":"bg-muted")},w))})]}),e.jsx(z,{className:"h-[450px] pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:t.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.description})]}),t.content&&e.jsxs("div",{className:"space-y-4",children:[t.content.text&&e.jsx(c,{children:e.jsx(l,{className:"p-4",children:e.jsx("p",{className:"text-sm leading-relaxed",children:t.content.text})})}),t.content.image&&e.jsx(c,{children:e.jsx(l,{className:"p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("img",{src:t.content.image.src,alt:t.content.image.alt,className:"w-full rounded-md border"}),t.content.image.caption&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:t.content.image.caption})]})})}),t.content.video&&e.jsx(c,{children:e.jsx(l,{className:"p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"relative rounded-md overflow-hidden border bg-muted",children:e.jsx("video",{src:t.content.video.src,poster:t.content.video.poster,controls:!0,className:"w-full",children:"Your browser does not support the video tag."})}),t.content.video.caption&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:t.content.video.caption})]})})})]}),i&&e.jsx(c,{className:"bg-primary/5 border-primary/20",children:e.jsxs(l,{className:"p-4 flex items-center space-x-3",children:[e.jsx(G,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsx("p",{className:"text-sm font-medium",children:`You've completed this workflow! Click "Finish" to close this wizard.`})]})})]})}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs(r,{variant:"outline",onClick:s,children:[e.jsx($,{className:"mr-2 h-4 w-4"}),o===0?"Back to Workflows":"Previous"]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(r,{variant:"ghost",onClick:p,children:"Cancel"}),i?e.jsx(r,{onClick:p,children:"Finish"}):e.jsxs(r,{onClick:v,children:["Next",e.jsx(D,{className:"ml-2 h-4 w-4"})]})]})]})]})};return e.jsx(q,{open:d,onOpenChange:g,children:e.jsx(B,{className:"max-w-3xl max-h-[90vh]",children:a?b():x()})})}const ee=[{id:"new-project",title:"Start Developing a New Project",description:"Set up a brand new project with Coconut from scratch",icon:e.jsx(K,{className:"h-6 w-6"}),steps:[{title:"Welcome to Your New Project",description:"Let's set up your development environment and project structure",content:{text:"In this step, you'll learn how to initialize a new project with Coconut. We'll guide you through configuring your project settings, choosing your tech stack, and setting up your development environment."}},{title:"Configure Project Settings",description:"Customize your project configuration and preferences",content:{text:"Define your project name, description, and select the technologies you want to use. You can also configure advanced settings like build tools, testing frameworks, and deployment options."}},{title:"Initialize Your Workspace",description:"Create your project structure and install dependencies",content:{text:"Coconut will create the necessary files and folders for your project. This includes setting up version control, installing dependencies, and configuring your development tools."}}]},{id:"connect-project",title:"Connect an Existing Project",description:"Import and configure an existing codebase with Coconut",icon:e.jsx(_,{className:"h-6 w-6"}),steps:[{title:"Select Your Project",description:"Choose the project directory you want to connect",content:{text:"Navigate to your existing project folder or clone a repository. Coconut will analyze your project structure and detect the technologies you're using."}},{title:"Review Project Analysis",description:"Verify the detected technologies and configuration",content:{text:"Coconut has analyzed your project and detected the frameworks, libraries, and tools you're using. Review this information and make any necessary adjustments."}},{title:"Complete Integration",description:"Finalize the connection and sync your project",content:{text:"Coconut will create the necessary configuration files and integrate with your existing project. You'll be able to use all Coconut features with your codebase."}}]},{id:"analyze-code",title:"Analyze Code and Generate a Report",description:"Get insights, metrics, and recommendations for your codebase",icon:e.jsx(Q,{className:"h-6 w-6"}),steps:[{title:"Choose Analysis Scope",description:"Select what parts of your codebase to analyze",content:{text:"You can analyze your entire codebase or focus on specific directories, files, or modules. Choose the scope that best fits your needs."}},{title:"Configure Analysis Parameters",description:"Select the types of analysis you want to run",content:{text:"Choose from code quality checks, security scans, performance analysis, dependency reviews, and more. Customize the analysis to focus on what matters most to you."}},{title:"Review and Export Results",description:"View your analysis report and take action on findings",content:{text:"Coconut will generate a comprehensive report with actionable insights. You can export the report in various formats, share it with your team, or create change proposals to address issues."}}]},{id:"create-proposal",title:"Create a Change Proposal and Assign a Coding Agent",description:"Define a change and let AI agents help implement it",icon:e.jsx(N,{className:"h-6 w-6"}),steps:[{title:"Describe Your Change",description:"Define what you want to build or modify",content:{text:"Clearly describe the feature, bug fix, or refactoring you want to implement. Provide context, requirements, and any relevant technical details."}},{title:"Select an AI Agent",description:"Choose the right agent for your task",content:{text:"Pick from specialized agents based on your needs - frontend development, backend APIs, database changes, testing, documentation, and more. Each agent has unique capabilities and expertise."}},{title:"Review and Launch",description:"Confirm your proposal and start the implementation",content:{text:"Review your change proposal details and agent assignment. Once you're ready, launch the agent to start working on your change. You can monitor progress and provide feedback throughout."}}]},{id:"schedule-job",title:"Schedule an Agent Job",description:"Set up automated tasks and recurring agent workflows",icon:e.jsx(H,{className:"h-6 w-6"}),steps:[{title:"Define Your Job",description:"Specify what task the agent should perform",content:{text:"Describe the task you want to automate - code reviews, dependency updates, security scans, report generation, or custom workflows. Provide clear instructions for the agent."}},{title:"Set Schedule and Triggers",description:"Configure when and how often the job should run",content:{text:"Choose a schedule (daily, weekly, monthly, or custom cron expression) or set up event-based triggers like commits, pull requests, or deployments."}},{title:"Configure Notifications",description:"Decide how you want to be notified about job results",content:{text:"Set up notifications for job completion, failures, or important findings. Choose your preferred channels - email, Slack, GitHub, or in-app notifications."}}]}];function me(){const[d,g]=m.useState({total:0,inReview:0,approved:0}),[y,a]=m.useState([]),[h,o]=m.useState(!0),[u,C]=m.useState(!1);return m.useEffect(()=>{(async()=>{try{const p=await(await fetch(`${E}/api/v1/proposals`)).json();if(p.success&&p.data){const x=p.data,b={total:x.length,inReview:x.filter(i=>i.status==="in-review").length,approved:x.filter(i=>i.status==="approved"||i.status==="code-complete").length},t=x.sort((i,k)=>{const w=new Date(i.metadata?.updatedAt||i.metadata?.createdAt||0);return new Date(k.metadata?.updatedAt||k.metadata?.createdAt||0).getTime()-w.getTime()}).slice(0,5);g(b),a(t)}}catch(v){console.error("Failed to fetch proposal stats:",v)}finally{o(!1)}})()},[]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Home"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage change proposals, brainstorm, and take quick actions."})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(n,{to:"/proposals",children:e.jsxs(c,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(f,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(j,{className:"text-sm font-medium",children:"All Proposals"}),e.jsx(N,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(l,{children:[e.jsx("div",{className:"text-2xl font-bold",children:h?"...":d.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.total===0?"No proposals yet":`${d.total} proposal${d.total!==1?"s":""}`})]})]})}),e.jsx(n,{to:"/proposals?status=in-review",children:e.jsxs(c,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(f,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(j,{className:"text-sm font-medium",children:"In Review"}),e.jsx(O,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(l,{children:[e.jsx("div",{className:"text-2xl font-bold",children:h?"...":d.inReview}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting approval"})]})]})}),e.jsx(n,{to:"/proposals?status=approved",children:e.jsxs(c,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(f,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(j,{className:"text-sm font-medium",children:"Approved / Code Complete"}),e.jsx(V,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(l,{children:[e.jsx("div",{className:"text-2xl font-bold",children:h?"...":d.approved}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ready to implement"})]})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(c,{children:[e.jsxs(f,{children:[e.jsx(j,{children:"Recent Proposals"}),e.jsx(R,{children:"Latest change proposals in your project"})]}),e.jsx(l,{children:h?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(s=>e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-2"})]},s))}):y.length>0?e.jsxs("div",{className:"space-y-4 overflow-hidden",children:[y.map(s=>e.jsx(n,{to:`/proposals/${s.id}`,className:"block",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 p-3 rounded-lg border hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(Y,{variant:s.status==="approved"||s.status==="code-complete"?"default":s.status==="in-review"?"secondary":s.status==="draft"?"outline":"destructive",children:s.status})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"text-sm font-medium line-clamp-2 sm:truncate",children:s.intent}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[s.author.name," • ",new Date(s.metadata?.updatedAt||s.metadata?.createdAt||"").toLocaleDateString()]})]})]})},s.id)),e.jsx("div",{className:"pt-2",children:e.jsx(r,{variant:"outline",size:"sm",asChild:!0,className:"w-full",children:e.jsx(n,{to:"/proposals",children:"View All Proposals"})})})]}):e.jsxs("div",{className:"text-center py-6",children:[e.jsx(N,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No proposals yet"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create your first change proposal to get started."}),e.jsx(r,{asChild:!0,className:"mt-4",children:e.jsxs(n,{to:"/proposals/new",children:[e.jsx(U,{className:"mr-2 h-4 w-4"}),"New Proposal"]})})]})})]}),e.jsxs(c,{className:"flex flex-col",children:[e.jsxs(f,{children:[e.jsx(j,{children:"Quick Actions"}),e.jsx(R,{children:"Common tasks and operations"})]}),e.jsx(l,{className:"flex flex-col flex-1",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{asChild:!0,variant:"default",className:"w-full justify-start",children:e.jsxs(n,{to:"/proposals/new",children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),"New Proposal"]})}),e.jsx(r,{asChild:!0,variant:"outline",className:"w-full justify-start",children:e.jsxs(n,{to:"/context/project/edit",children:[e.jsx(L,{className:"mr-2 h-4 w-4"}),"Update Project Overview"]})}),e.jsx(r,{asChild:!0,variant:"outline",className:"w-full justify-start",children:e.jsxs(n,{to:"/context/architecture/edit",children:[e.jsx(F,{className:"mr-2 h-4 w-4"}),"Update Technical Architecture"]})}),e.jsx(r,{asChild:!0,variant:"outline",className:"w-full justify-start",children:e.jsxs(n,{to:"/agents/new",children:[e.jsx(M,{className:"mr-2 h-4 w-4"}),"Create New Agent"]})}),e.jsx(r,{asChild:!0,variant:"outline",className:"w-full justify-start",children:e.jsxs(n,{to:"/code",children:[e.jsx(T,{className:"mr-2 h-4 w-4"}),"Start Coding Agent"]})})]})})]})]}),e.jsx(X,{open:u,onOpenChange:C,workflows:ee})]})}export{me as default};
@@ -0,0 +1,16 @@
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";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Es=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],Fs=le("git-commit-horizontal",Es);/**
7
+ * @license lucide-react v0.542.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Ms=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],Ie=le("git-merge",Ms);/**
12
+ * @license lucide-react v0.542.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Bs=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],Le=le("git-pull-request",Bs);let S;async function Os(){if(S!==void 0)return S;try{const m=await fetch(`${l}/api/v1/config`);if(!m.ok)return S=null,null;const r=(await m.json())?.data||{},f=r?.coconut?.id||r?.cloud?.coconutId||r?.cloud?.coconut_id;return S=typeof f=="string"&&f.trim()?f.trim():null,S}catch(m){return console.error("[github-token] Failed to load Coconut ID",m),S=null,null}}async function Rs(m){const x=await fetch(`${ws}/api/v1/git/token`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({coconutId:m})});if(!x.ok){let T="Failed to request GitHub token from control plane";if(x.status===401||x.status===403)throw new Error("Please sign in to app.coconut.dev and then retry the action.");try{const y=await x.json();T=y?.error?.message||y?.message||T}catch{}throw new Error(T)}const r=await x.json(),f=r?.token||r?.data?.token,b=r?.expiresAt||r?.data?.expiresAt;if(!f||!b)throw new Error("Control plane response missing token or expiresAt");return{token:f,expiresAt:b}}async function Gs(m,x){const r=await fetch(`${l}/api/v1/git/providers/github/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:m,expiresAt:x})}),f=await r.json().catch(()=>({}));if(!r.ok||!f?.success){const b=f?.error?.message||"Failed to store GitHub token on Coconut";throw new Error(b)}}async function Ws(){const m=await Os();if(!m)throw new Error("Coconut ID not configured. Reconnect via Settings → Git.");const{token:x,expiresAt:r}=await Rs(m);return await Gs(x,r),{tokenFetched:!0,message:r}}function Ys(){const[m,x]=n.useState(!0),[r,f]=n.useState(null),[b,T]=n.useState([]),[y,_e]=n.useState([]),[$,de]=n.useState(""),[g,E]=n.useState(""),[me,He]=n.useState("main"),[ue,c]=n.useState(null),{toast:i}=vs(),{refresh:H}=ys(),[he,xe]=n.useState(!1),[F,M]=n.useState(!1),[P,ge]=n.useState(null),[A,fe]=n.useState(null),[Je,pe]=n.useState(null),[be,je]=n.useState(null),[we,ve]=n.useState(null),[qe,ye]=n.useState(null),[B,Ve]=n.useState("merge"),[J,Ke]=n.useState("merge"),[Xe,Ye]=n.useState("../worktrees"),[O,Qe]=n.useState("github"),[h,Ne]=n.useState(null),[Ze,w]=n.useState(!1),[es,R]=n.useState(!1),[G,q]=n.useState(""),[W,V]=n.useState(""),[Ce,ke]=n.useState(!1),[v,K]=n.useState(""),[z,U]=n.useState(!1),[p,N]=n.useState(new Set),[I,ss]=n.useState(!1),[L,ts]=n.useState(!1),[as,_]=n.useState(!1),[C,X]=n.useState(null),[Y,Se]=n.useState(null),Te=n.useCallback(async()=>{if(O!=="github"||h?.provider!=="github")return!0;if(h?.authenticated&&h?.expiresAt){const t=new Date(h.expiresAt).getTime(),a=Date.now(),d=300*1e3;if(t>a+d)return!0}const s=i({title:"Fetching GitHub token",description:"Contacting control plane…"});try{const{message:t}=await Ws();return i({title:"GitHub token ready",description:t?`Valid until ${new Date(t).toLocaleString()}`:"Token fetched successfully."}),Ne(a=>({...a,authenticated:!0,error:void 0,expiresAt:t??a?.expiresAt,provider:"github"})),!0}catch(t){const a=t?.message?`${t.message} Visit Settings → Git to reconnect.`:"Visit Settings → Git to connect GitHub.";return i({title:"GitHub token unavailable",description:a,variant:"destructive"}),c(t?.message||"GitHub authorization required. Visit Settings → Git to reconnect."),!1}finally{s?.dismiss?.()}},[O,h?.provider,h?.authenticated,h?.expiresAt,i]),u=async()=>{x(!0),c(null);try{const[s,t,a,d,Z]=await Promise.all([fetch(`${l}/api/v1/git/status`).then(j=>j.json()),fetch(`${l}/api/v1/git/branches`).then(j=>j.json()),fetch(`${l}/api/v1/git/worktrees`).then(j=>j.json()),fetch(`${l}/api/v1/git/settings`).then(j=>j.json()).catch(()=>null),fetch(`${l}/api/v1/git/auth-status`).then(j=>j.json()).catch(()=>null)]);s.success&&f(s.data),t.success&&T(t.data),a.success&&_e(a.data),d&&d.success&&d.data?.defaultWorktreePath&&(Ye(d.data.defaultWorktreePath),d.data.authMode&&Qe(d.data.authMode)),Z&&Z.success&&Ne(Z.data)}catch(s){c(s.message),i({title:"Failed to refresh",description:s.message,variant:"destructive"})}finally{x(!1)}};n.useEffect(()=>{u()},[]);const Pe=n.useMemo(()=>{const s=r?.branch?.toLowerCase();return s==="main"||s==="master"},[r?.branch]),Q=n.useMemo(()=>{const s=!!v.trim(),t=p.size>0;return s&&t},[v,p]),rs=s=>s==="??"||s.includes("U")?"U":s.includes("R")?"R":s.includes("C")?"C":s.includes("D")?"D":s.includes("A")?"A":s.includes("M")?"M":s||"?",ns=(s,t)=>{N(a=>{const d=new Set(a);return t?d.add(s):d.delete(s),d})},is=()=>{r?.changes&&N(new Set(r.changes.map(s=>s.path)))},cs=()=>{N(new Set)},os=()=>{r?.changes&&(r.changes.every(t=>p.has(t.path))?cs():is())},ls=n.useMemo(()=>!r?.changes||r.changes.length===0?!1:r.changes.every(s=>p.has(s.path)),[r?.changes,p]),ds=s=>{X(s),_(!0)},ms=async()=>{if(C){Se(C),c(null);try{const s=await fetch(`${l}/api/v1/git/discard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:C})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to discard file");N(t=>{const a=new Set(t);return a.delete(C),a}),i({title:"File discarded",description:C}),_(!1),X(null),await u(),await H()}catch(s){c(s.message),i({title:"Discard failed",description:s.message,variant:"destructive"})}finally{Se(null)}}},us=async()=>{if($.trim()){xe(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/worktrees`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:$,from:"main"})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to create worktree");de(""),await u(),i({title:"Worktree created",description:s.data?.added?.branch})}catch(s){c(s.message),i({title:"Create failed",description:s.message,variant:"destructive"})}xe(!1)}},Ae=async s=>{if(c(null),!(O==="github"&&h?.provider==="github"&&!await Te())){try{ge(s||"");const t=s?`/api/v1/git/worktrees/${encodeURIComponent(s)}/push`:"/api/v1/git/push",a=await fetch(`${l}${t}`,{method:"POST"}).then(d=>d.json());if(!a.success)throw new Error(a.error?.message||"Push failed");i({title:"Pushed",description:s?`Worktree ${s}`:"Current branch"}),await u()}catch(t){const a=t.message||"",d=a.includes("Authentication")||a.includes("could not read Username")||a.includes("could not read Password")||a.includes("terminal prompts disabled");c(a),i({title:"Push failed",description:a,variant:"destructive"}),d&&w(!0)}ge(null)}},De=async s=>{if(c(null),!(O==="github"&&h?.provider==="github"&&!await Te())){try{fe(s||"");const t=s?`/api/v1/git/worktrees/${encodeURIComponent(s)}/pull`:"/api/v1/git/pull",a=await fetch(`${l}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({strategy:J})}).then(d=>d.json());if(!a.success)throw new Error(a.error?.message||"Pull failed");await u(),i({title:"Pulled",description:`${s?`Worktree ${s}`:"Current branch"} (${J})`})}catch(t){const a=t.message||"",d=a.includes("Authentication")||a.includes("could not read Username")||a.includes("could not read Password")||a.includes("terminal prompts disabled");c(a),i({title:"Pull failed",description:a,variant:"destructive"}),d&&w(!0)}fe(null)}},hs=async s=>{if(confirm(`Remove worktree ${s}?`)){c(null);try{pe(s);const t=await fetch(`${l}/api/v1/git/worktrees/${encodeURIComponent(s)}`,{method:"DELETE"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to remove worktree");await u(),i({title:"Worktree removed",description:s})}catch(t){c(t.message),i({title:"Remove failed",description:t.message,variant:"destructive"})}pe(t=>t===s?null:t)}},xs=async()=>{if(!G||!W){i({title:"Error",description:"Username and password are required",variant:"destructive"});return}ke(!0);try{const t=await(await fetch(`${l}/api/v1/git/credentials`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:G,password:W})})).json();if(!t.success)throw new Error(t.error?.message||"Failed to save credentials");i({title:"Success",description:"Credentials saved successfully"}),w(!1),q(""),V(""),await u()}catch(s){i({title:"Error",description:s?.message||"Failed to save credentials",variant:"destructive"})}finally{ke(!1)}},gs=async()=>{if(g.trim()){M(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,from:me})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to create branch");E(""),await u(),i({title:"Branch created",description:g})}catch(s){c(s.message),i({title:"Create failed",description:s.message,variant:"destructive"})}M(!1)}},fs=async s=>{je(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}/switch`,{method:"POST"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to switch branch");await u(),i({title:"Switched branch",description:s})}catch(t){c(t.message),i({title:"Switch failed",description:t.message,variant:"destructive"})}je(null)},ps=async s=>{if(confirm(`Delete branch ${s}?`)){ye(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}`,{method:"DELETE"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to delete branch");await u(),i({title:"Branch deleted",description:s})}catch(t){c(t.message),i({title:"Delete failed",description:t.message,variant:"destructive"})}ye(null)}},bs=async s=>{ve(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}/merge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({strategy:B})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to merge branch");await u(),i({title:"Branch merged",description:`${s} (${B})`})}catch(t){c(t.message),i({title:"Merge failed",description:t.message,variant:"destructive"})}ve(null)},$e=async()=>{if(Q){if(Pe){R(!0);return}U(!0),c(null);try{const s=Array.from(p),t=await fetch(`${l}/api/v1/git/commits`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:v,files:s.length>0?s:void 0})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Commit failed");K(""),N(new Set),await u(),await H(),i({title:"Committed",description:v})}catch(s){c(s.message),i({title:"Commit failed",description:s.message,variant:"destructive"})}U(!1)}},js=async()=>{R(!1),U(!0),c(null);try{const s=Array.from(p),t=await fetch(`${l}/api/v1/git/commits`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:v,files:s.length>0?s:void 0})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Commit failed");K(""),N(new Set),await u(),await H(),i({title:"Committed",description:v})}catch(s){c(s.message),i({title:"Commit failed",description:s.message,variant:"destructive"})}U(!1)},Ee=async()=>{if(g.trim()){R(!1),M(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,from:r?.branch})}).then(a=>a.json());if(!s.success)throw new Error(s.error?.message||"Failed to create branch");const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(g)}/switch`,{method:"POST"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to switch branch");E(""),await u(),i({title:"Branch created & switched",description:g})}catch(s){c(s.message),i({title:"Failed",description:s.message,variant:"destructive"})}M(!1)}};return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Source Control"}),h&&e.jsx(ee,{to:"/settings/git",className:"flex items-center gap-1.5 text-xs rounded-full px-2.5 py-1 border hover:bg-muted transition-colors",title:h.authenticated?"Authenticated with remote":"Authentication required - click to configure",children:h.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(Ps,{className:"h-3 w-3 text-green-600"}),e.jsx("span",{className:"text-muted-foreground",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-3 w-3 text-red-600"}),e.jsx("span",{className:"text-muted-foreground",children:"Not authenticated"}),e.jsx(Fe,{className:"h-3 w-3 text-muted-foreground ml-0.5"})]})})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("select",{className:"text-sm border rounded-md px-3 py-2 bg-background h-9",value:J,onChange:s=>Ke(s.target.value),title:"Pull strategy",children:[e.jsx("option",{value:"merge",children:"Merge"}),e.jsx("option",{value:"rebase",children:"Rebase"}),e.jsx("option",{value:"ff-only",children:"FF only"})]}),e.jsxs(o,{variant:"outline",onClick:()=>De(),size:"sm",disabled:A==="",children:[e.jsx(Ds,{className:"h-4 w-4 mr-2"+(A===""?" animate-spin":"")}),A===""?"Pulling…":"Pull"]}),e.jsxs(o,{onClick:()=>Ae(),size:"sm",disabled:P==="",children:[e.jsx($s,{className:"h-4 w-4 mr-2"+(P===""?" animate-spin":"")}),P===""?"Pushing…":"Push"]})]})]}),ue&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600 dark:border-red-900 dark:bg-red-950",children:ue}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Repository Status"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(o,{variant:"outline",size:"sm","aria-label":"Refresh status",onClick:u,disabled:m,children:[e.jsx(Ue,{className:"h-4 w-4"+(m?" animate-spin":"")}),"Refresh"]})})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Overview of your current branch, sync status with the remote, and uncommitted changes."}),m?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ue,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):r?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Branch:"}),e.jsx("span",{className:"font-mono font-semibold",children:r.branch}),Pe&&e.jsxs("span",{className:"flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-amber-500/10 text-amber-600",children:[e.jsx(ce,{className:"h-3 w-3"}),"Default branch"]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-blue-600",children:"↓"}),e.jsxs("span",{className:"text-muted-foreground",children:[r.behind," behind"]})]}),e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded"+(r.ahead>0?" bg-amber-500/10":""),children:[e.jsx("span",{className:"text-green-600",children:"↑"}),e.jsxs("span",{className:r.ahead>0?"text-amber-700 dark:text-amber-300 font-medium":"text-muted-foreground",children:[r.ahead," ",r.ahead>0?"unpushed":"ahead"]})]})]})]}),r.changes.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(o,{variant:"default",size:"sm",onClick:os,className:"h-7 text-xs",children:ls?"Deselect All":"Select All"}),e.jsxs("div",{className:"text-sm font-medium text-muted-foreground",children:["Uncommitted Changes (",r.changes.length,")"]})]}),e.jsx("div",{className:"rounded-lg border bg-muted/30 p-3 max-h-48 overflow-auto",children:e.jsx("ul",{className:"text-sm font-mono space-y-1",children:r.changes.map((s,t)=>e.jsxs("li",{className:"flex gap-2 items-center justify-between rounded px-2 py-1 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-1 min-w-0",children:[e.jsx(Ns,{checked:p.has(s.path),onCheckedChange:a=>ns(s.path,a===!0)}),e.jsx("span",{className:"inline-flex items-center justify-center w-6 h-5 rounded bg-background text-xs font-semibold",children:rs(s.status)}),e.jsx("span",{className:"text-muted-foreground truncate",children:s.path})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ds(s.path),className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive flex-shrink-0",title:"Discard changes",children:e.jsx(Cs,{className:"h-3.5 w-3.5 opacity-50"})})]},t))})})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:"Commit Changes"}),p.size>0&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.size," of ",r.changes.length," file",r.changes.length!==1?"s":""," selected"]})]}),(r.changes?.length??0)>0?e.jsxs(e.Fragment,{children:[p.size===0&&e.jsx("div",{className:"mb-3 text-xs text-amber-600 bg-amber-50 dark:bg-amber-950/20 border border-amber-200 dark:border-amber-900 rounded-lg p-2",children:"Select files above to commit specific changes"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{placeholder:"Describe your changes...",value:v,onChange:s=>K(s.target.value),className:"flex-1 bg-background border-2 border-primary focus-visible:border-primary",onKeyDown:s=>{s.key==="Enter"&&Q&&!z&&$e()}}),e.jsxs(o,{onClick:$e,disabled:!Q||z,children:[e.jsx(Fs,{className:"h-4 w-4 mr-2"}),z?"Committing…":"Commit"]})]})]}):e.jsx("div",{className:"text-center py-6 text-sm text-muted-foreground bg-muted/30 rounded-lg",children:"No uncommitted changes. Make some changes to your files to commit them."})]})]}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"No status available"})]}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Branches"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",b.length,")"]})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ss(!I),"aria-label":I?"Collapse branches":"Expand branches",children:I?e.jsx(Me,{className:"h-4 w-4"}):e.jsx(Be,{className:"h-4 w-4"})})]}),I&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground my-4",children:"Branches let you work on different features or fixes in isolation. Create a branch from any existing branch, switch between them, and merge them back when ready."}),e.jsxs("div",{className:"flex gap-2 mb-4 p-3 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"From branch"}),e.jsx("select",{className:"text-sm border rounded-md px-3 py-2 bg-background",value:me,onChange:s=>He(s.target.value),title:"Base branch for new branch",children:b.map(s=>e.jsx("option",{value:s.name,children:s.name},s.name))})]}),e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"New branch name"}),e.jsx(k,{placeholder:"feature/my-feature",value:g,onChange:s=>E(s.target.value),className:"bg-background border-2 border-primary focus-visible:border-primary"})]})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs(o,{onClick:gs,disabled:F||!g.trim(),children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),F?"Creating…":"Create Branch"]})})]}),b.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No branches found. Create your first branch above."}):e.jsx("div",{className:"space-y-2",children:b.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[s.current?e.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-green-600 animate-pulse",title:"Current branch"}):e.jsx("div",{className:"h-2.5 w-2.5 rounded-full border-2 border-muted-foreground"}),e.jsx("div",{className:"font-mono text-sm font-medium",children:s.name}),s.current&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-green-600/10 text-green-600 font-medium",children:"ACTIVE"})]}),e.jsx("div",{className:"flex gap-1.5",children:!s.current&&e.jsxs(e.Fragment,{children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>fs(s.name),disabled:be===s.name,title:"Switch to this branch",children:[e.jsx(D,{className:"h-3.5 w-3.5 mr-1.5"}),be===s.name?"Switching…":"Switch"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>bs(s.name),disabled:we===s.name,title:`Merge ${s.name} into ${r?.branch||"current branch"} (${B})`,children:[e.jsx(Ie,{className:"h-3.5 w-3.5 mr-1.5"}),we===s.name?"Merging…":"Merge"]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ps(s.name),disabled:qe===s.name,className:"text-destructive hover:text-destructive",title:"Delete this branch",children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})]})})]},s.name))}),e.jsx("div",{className:"mt-4 pt-3 border-t flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Ie,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Merge strategy:"}),e.jsxs("select",{className:"text-xs border rounded px-2 py-1 bg-background font-medium",value:B,onChange:s=>Ve(s.target.value),children:[e.jsx("option",{value:"merge",children:"Merge commit"}),e.jsx("option",{value:"squash",children:"Squash & merge"}),e.jsx("option",{value:"rebase",children:"Rebase & merge"})]})]})})]})]}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Worktrees"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",y.length,")"]})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ts(!L),"aria-label":L?"Collapse worktrees":"Expand worktrees",children:L?e.jsx(Me,{className:"h-4 w-4"}):e.jsx(Be,{className:"h-4 w-4"})})]}),L&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"Worktrees allow you to have multiple branches checked out simultaneously in different directories. Perfect for working on multiple features at once or testing changes without switching branches."}),e.jsxs("div",{className:"flex gap-2 mb-3 p-3 rounded-lg bg-muted/30",children:[e.jsx(k,{placeholder:"feature/worktree-name",value:$,onChange:s=>de(s.target.value),className:"flex-1 bg-background border-2 border-primary focus-visible:border-primary"}),e.jsxs(o,{onClick:us,disabled:he||!$.trim(),children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),he?"Creating…":"Create Worktree"]})]}),e.jsxs("p",{className:"mb-4 text-xs text-muted-foreground bg-muted/30 rounded-lg p-2",children:["💡 Worktrees are created in ",e.jsx("code",{className:"font-mono font-semibold",children:Xe})," relative to your project root.",e.jsx(ee,{to:"/settings/git",className:"underline underline-offset-2 ml-1 font-medium",children:"Configure location"})]}),y.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No worktrees yet. Create one to work on multiple branches simultaneously."}):e.jsx("div",{className:"space-y-2 mb-4",children:y.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3 bg-card hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(oe,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm font-medium",children:s.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",s.branch]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:s.path})]})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>De(s.name),disabled:A===s.name,title:"Pull latest changes",children:[e.jsx(Le,{className:"h-3.5 w-3.5 mr-1.5"}),A===s.name?"Pulling…":"Pull"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>Ae(s.name),disabled:P===s.name,title:"Push changes",children:[e.jsx(Le,{className:"h-3.5 w-3.5 mr-1.5"}),P===s.name?"Pushing…":"Push"]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>hs(s.name),disabled:Je===s.name,className:"text-destructive hover:text-destructive",title:"Remove worktree",children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})]})]},s.name))})]})]}),e.jsx(se,{open:Ze,onOpenChange:w,children:e.jsxs(te,{className:"max-w-2xl",children:[e.jsxs(ae,{children:[e.jsx(re,{children:"Authentication Required"}),e.jsx(ne,{children:"Configure git credentials to push or pull from the remote repository."})]}),e.jsxs(Ss,{defaultValue:h?.remote?.startsWith("https://")?"credentials":"instructions",className:"w-full",children:[e.jsxs(Ts,{className:"grid w-full grid-cols-2",children:[e.jsxs(We,{value:"credentials",disabled:!h?.remote?.startsWith("https://"),children:[e.jsx(ks,{className:"h-4 w-4 mr-2"}),"Enter Credentials"]}),e.jsxs(We,{value:"instructions",children:[e.jsx(Fe,{className:"h-4 w-4 mr-2"}),"Setup Instructions"]})]}),e.jsxs(ze,{value:"credentials",className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ge,{htmlFor:"auth-username",children:"Username"}),e.jsx(k,{id:"auth-username",placeholder:"your-username",value:G,onChange:s=>q(s.target.value),autoComplete:"username",className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ge,{htmlFor:"auth-password",children:"Password / Personal Access Token"}),e.jsx(k,{id:"auth-password",type:"password",placeholder:"ghp_xxxxxxxxxxxx or your password",value:W,onChange:s=>V(s.target.value),autoComplete:"current-password",className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"We recommend using a Personal Access Token instead of your password."})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(o,{variant:"outline",className:"flex-1",onClick:()=>{w(!1),q(""),V("")},children:"Cancel"}),e.jsx(o,{className:"flex-1",onClick:xs,disabled:Ce||!G||!W,children:Ce?"Saving...":"Save & Test"})]})]}),e.jsxs(ze,{value:"instructions",className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure one of the following authentication methods:"}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsxs("div",{className:"rounded bg-muted p-3",children:[e.jsx("div",{className:"font-semibold mb-1",children:"SSH Keys (Recommended)"}),e.jsx("code",{className:"text-[11px] block bg-background rounded px-2 py-1",children:'ssh-keygen -t ed25519 -C "your_email@example.com"'}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:"Then add ~/.ssh/id_ed25519.pub to your GitHub/GitLab account"})]}),e.jsxs("div",{className:"rounded bg-muted p-3",children:[e.jsx("div",{className:"font-semibold mb-1",children:"Git Credential Manager"}),e.jsx("code",{className:"text-[11px] block bg-background rounded px-2 py-1",children:"brew install git-credential-manager"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(o,{variant:"outline",onClick:()=>w(!1),className:"flex-1",children:"Close"}),e.jsx(o,{asChild:!0,className:"flex-1",children:e.jsx(ee,{to:"/settings/git",onClick:()=>w(!1),children:"Open Settings"})})]})]})]})]})}),e.jsx(se,{open:as,onOpenChange:_,children:e.jsxs(te,{className:"max-w-md",children:[e.jsxs(ae,{children:[e.jsxs(re,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5 text-destructive"}),"Discard Changes?"]}),e.jsxs(ne,{children:["Are you sure you want to discard changes to ",e.jsx("code",{className:"font-mono text-sm bg-muted px-1 py-0.5 rounded",children:C}),"? This action cannot be undone."]})]}),e.jsxs(Re,{children:[e.jsx(o,{variant:"outline",onClick:()=>{_(!1),X(null)},disabled:Y!==null,children:"Cancel"}),e.jsx(o,{variant:"destructive",onClick:ms,disabled:Y!==null,children:Y?"Discarding...":"Discard"})]})]})}),e.jsx(se,{open:es,onOpenChange:R,children:e.jsxs(te,{className:"max-w-lg",children:[e.jsxs(ae,{children:[e.jsxs(re,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5 text-amber-600"}),"Create a Branch First?"]}),e.jsxs(ne,{children:["You're about to commit directly to ",r?.branch,". It's best practice to create a feature branch first."]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"rounded-lg border border-blue-200 bg-blue-50 dark:border-blue-900 dark:bg-blue-950 p-4",children:[e.jsx("h4",{className:"text-sm font-semibold mb-2 text-blue-900 dark:text-blue-100",children:"Why create a branch?"}),e.jsxs("ul",{className:"text-sm text-blue-700 dark:text-blue-200 space-y-1 list-disc list-inside",children:[e.jsxs("li",{children:["Keeps ",r?.branch," stable and deployable"]}),e.jsx("li",{children:"Makes it easier to review and test changes"}),e.jsx("li",{children:"Allows working on multiple features simultaneously"}),e.jsx("li",{children:"Simplifies collaboration with your team"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"New branch name"}),e.jsx(k,{placeholder:"feature/my-awesome-feature",value:g,onChange:s=>E(s.target.value),onKeyDown:s=>{s.key==="Enter"&&g.trim()&&Ee()},className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will create a new branch from ",r?.branch," and switch to it"]})]})]}),e.jsxs(Re,{className:"flex-col sm:flex-row gap-2",children:[e.jsxs(o,{variant:"outline",onClick:js,disabled:z,className:"sm:flex-1",children:["Commit to ",r?.branch," Anyway"]}),e.jsxs(o,{onClick:Ee,disabled:!g.trim()||F,className:"sm:flex-1",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),F?"Creating...":"Create Branch & Switch"]})]})]})})]})}export{Ys as default};
@@ -0,0 +1,6 @@
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";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const $e=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],we=Ae("github",$e),V="../worktrees",y="../worktrees",b="coconut/github-auth-state";function _e(h){const j=h.trim();return j?/^([A-Za-z]:\\|\\\\|\/|~)/.test(j):!1}function Xe(){const[h,j]=r.useState(null),[X,v]=r.useState(y),[c,A]=r.useState("github"),[Z,Q]=r.useState(!0),[H,ee]=r.useState(!1),[a,te]=r.useState(null),[w,se]=r.useState(!1),[x,ye]=r.useState(null),[Ne,N]=r.useState(!1),[C,F]=r.useState(""),[k,D]=r.useState(""),[re,ae]=r.useState(!1),[p,S]=r.useState(!1),[ie,oe]=r.useState(!1),[Ce,R]=r.useState(!1),[E,G]=r.useState(""),[ne,ce]=r.useState(!1),[z,le]=r.useState(!1),[ke,P]=r.useState(!1),m=r.useRef(null),{toast:i}=He(),M=r.useCallback(async()=>{Q(!0);try{const s=await(await fetch(`${u}/api/v1/git/settings`)).json();if(s.success){const n=s.data||{},d={defaultWorktreePath:n.defaultWorktreePath||y,authMode:n.authMode||"github"};j(d),v(d.defaultWorktreePath),A(d.authMode)}else throw new Error(s.error?.message||"Failed to load settings")}catch(t){console.error("Failed to load git settings",t),i({title:"Error",description:"Failed to load git settings",variant:"destructive"})}finally{Q(!1)}},[i]),l=r.useCallback(async()=>{se(!0);try{const[t,s]=await Promise.all([fetch(`${u}/api/v1/git/auth-status`).then(n=>n.json()),fetch(`${u}/api/v1/git/credential-config`).then(n=>n.json())]);if(t.success)te(t.data);else throw new Error(t.error?.message||"Failed to check auth status");s.success&&ye(s.data)}catch(t){console.error("Failed to check git auth status",t),te({authenticated:!1,error:"Failed to check status"})}finally{se(!1)}},[i]),O=c==="github",Se=O&&a?.provider==="github",L=!!(O&&a?.authenticated&&a?.provider==="github"),I=!!(O&&a?.provider==="github"&&!a?.authenticated),de=r.useMemo(()=>{if(!a?.expiresAt)return null;const t=new Date(a.expiresAt);return Number.isNaN(t.getTime())?null:t.toLocaleString()},[a?.expiresAt]);r.useEffect(()=>{if(typeof window>"u")return;const t=s=>{s.origin===window.location.origin&&s.data?.type==="github-auth"&&(m.current&&!m.current.closed&&m.current.close(),m.current=null,localStorage.removeItem(b),S(!1),s.data?.success?(i({title:"GitHub connected",description:"GitHub authorization completed successfully."}),l()):i({title:"GitHub authorization failed",description:s.data?.message||"Authorization was cancelled or failed.",variant:"destructive"}))};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[l,i]),r.useEffect(()=>{if(typeof window>"u"||!p)return;const t=window.setInterval(()=>{m.current&&m.current.closed&&(window.clearInterval(t),m.current=null,S(!1),localStorage.removeItem(b))},500);return()=>window.clearInterval(t)},[p]);const Re=r.useCallback(async()=>{if(!p&&!(typeof window>"u")){S(!0);try{const t=`${window.location.origin}/auth/github/callback`,s=await fetch(`${u}/api/v1/git/providers/github/authorize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callbackUrl:t})}),n=await s.json();if(!s.ok||!n.success)throw new Error(n?.error?.message||"Failed to start GitHub authorization");const d=n?.data?.authorizeUrl,me=n?.data?.state;if(!d||!me)throw new Error("Invalid response from authorization endpoint");localStorage.removeItem(b),localStorage.setItem(b,me);const _=window.open(d,"github-authorization","width=600,height=700");if(!_)throw localStorage.removeItem(b),new Error("Popup blocked. Please allow popups and try again.");m.current=_,_.focus()}catch(t){S(!1),localStorage.removeItem(b),i({title:"GitHub authorization failed",description:t?.message||"Unable to open GitHub authorization flow.",variant:"destructive"})}}},[p,i]),Ee=r.useCallback(async()=>{oe(!0);try{const t=await fetch(`${u}/api/v1/git/providers/github/token`,{method:"DELETE"}),s=await t.json();if(!t.ok||!s.success)throw new Error(s?.error?.message||"Failed to disconnect GitHub");i({title:"GitHub disconnected",description:"Stored GitHub credentials were removed."}),await l()}catch(t){i({title:"Failed to disconnect GitHub",description:t?.message||"Please try again.",variant:"destructive"})}finally{oe(!1)}},[l,i]);r.useEffect(()=>{M(),l()},[M,l]);const Ge=async()=>{if(!E.trim()){i({title:"Error",description:"Remote URL is required",variant:"destructive"});return}ce(!0);try{const s=await(await fetch(`${u}/api/v1/git/remote`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({remoteUrl:E.trim()})})).json();if(!s.success)throw new Error(s.error?.message||"Failed to set remote URL");i({title:"Success",description:"Remote URL set successfully"}),R(!1),G(""),await l()}catch(t){console.error("Failed to set remote URL",t),i({title:"Error",description:t?.message||"Failed to set remote URL",variant:"destructive"})}finally{ce(!1)}},Pe=async()=>{le(!0);try{const s=await(await fetch(`${u}/api/v1/git/remote`,{method:"DELETE"})).json();if(!s.success)throw new Error(s.error?.message||"Failed to delete remote");i({title:"Success",description:"Remote URL removed"}),await l()}catch(t){console.error("Failed to delete remote",t),i({title:"Error",description:t?.message||"Failed to delete remote",variant:"destructive"})}finally{le(!1)}},Le=async()=>{if(!C||!k){i({title:"Error",description:"Username and password are required",variant:"destructive"});return}if(!a?.remote){i({title:"Error",description:"Set a remote URL first before saving credentials",variant:"destructive"});return}ae(!0);try{const s=await(await fetch(`${u}/api/v1/git/credentials`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:C,password:k})})).json();if(!s.success)throw new Error(s.error?.message||"Failed to save credentials");i({title:"Success",description:"Credentials saved successfully"}),N(!1),F(""),D(""),await l()}catch(t){console.error("Failed to save credentials",t),i({title:"Error",description:t?.message||"Failed to save credentials",variant:"destructive"})}finally{ae(!1)}},g=X.trim(),$=r.useMemo(()=>g?_e(g)?"Path must be relative to the project root":null:"Path is required",[g]),Ue=r.useMemo(()=>h?g!==h.defaultWorktreePath||(h.authMode||"github")!==c:!1,[h,g,c]),ue=!Z&&!H&&Ue&&!$,Te=async()=>{if(ue){ee(!0);try{const s=await(await fetch(`${u}/api/v1/git/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultWorktreePath:g,authMode:c})})).json();if(!s.success)throw new Error(s.error?.message||"Failed to update settings");const n=s.data||{},d={defaultWorktreePath:n.defaultWorktreePath||y,authMode:n.authMode||"github"};j(d),v(d.defaultWorktreePath),A(d.authMode),i({title:"Updated",description:"Git settings saved"})}catch(t){console.error("Failed to update git settings",t),i({title:"Error",description:t?.message||"Failed to update git settings",variant:"destructive"})}finally{ee(!1)}}};return Z&&!h?e.jsx("div",{children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Git Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control how Coconut creates worktrees for change proposals and manual Git operations."})]}),e.jsx(he,{}),e.jsxs(pe,{children:[e.jsxs(ge,{children:[e.jsx(fe,{children:"Remote Authentication"}),e.jsx(be,{children:"Configure authentication for remote git operations."})]}),e.jsxs(je,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{className:"text-sm font-medium",children:"Remote URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The git remote URL for your repository (origin)."}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded border bg-muted/30 px-3 py-2",children:[w&&!a?e.jsxs("span",{className:"text-sm text-muted-foreground italic flex items-center gap-2",children:[e.jsx(T,{className:"h-3.5 w-3.5 animate-spin"}),"Loading..."]}):a?.remote?e.jsxs("a",{href:a.remote.replace(/\.git$/,"").replace(/^git@([^:]+):/,"https://$1/"),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline truncate inline-flex items-center gap-1.5",children:[a.remote,e.jsx(xe,{className:"h-3.5 w-3.5 shrink-0"})]}):e.jsx("span",{className:"text-sm text-muted-foreground italic",children:"Not configured"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[a?.remote&&e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>P(!0),disabled:z,title:"Remove remote",children:e.jsx(Fe,{className:"h-4 w-4"})}),e.jsx(o,{variant:"outline",size:"sm",onClick:()=>{G(a?.remote||""),R(!0)},children:a?.remote?"Edit":"Set Remote"})]})]})]}),e.jsx(he,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{className:"text-sm font-medium",children:"Authentication Mode"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose how Coconut authenticates with your remote repository when pushing or pulling."}),e.jsxs(Me,{value:c,onValueChange:t=>A(t||"github"),className:"grid gap-2 md:grid-cols-2",children:[e.jsx("label",{htmlFor:"mode-github",className:`cursor-pointer rounded-md border p-3 transition-colors ${c==="github"?"border-primary ring-1 ring-primary/40 bg-primary/5":"border-border bg-background hover:border-primary/60"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ve,{value:"github",id:"mode-github",className:"mt-1 h-5 w-5 shrink-0 border-[1.5px]"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx("span",{className:"text-sm font-medium",children:"GitHub"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use the Coconut control plane to fetch short-lived GitHub tokens automatically."})]})]})}),e.jsx("label",{htmlFor:"mode-local",className:`cursor-pointer rounded-md border p-3 transition-colors ${c==="local"?"border-primary ring-1 ring-primary/40 bg-primary/5":"border-border bg-background hover:border-primary/60"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ve,{value:"local",id:"mode-local",className:"mt-1 h-5 w-5 shrink-0 border-[1.5px]"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx("span",{className:"text-sm font-medium",children:"Local configuration"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage credentials yourself using SSH keys, stored PATs, or OS credential helpers on this Coconut."})]})]})})]})]}),c==="github"&&!a&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-muted-foreground",children:[e.jsx(T,{className:"h-4 w-4 animate-spin"}),"Loading authentication status..."]}),c==="github"&&a&&!a.remote&&e.jsxs("div",{className:"rounded border border-amber-200 bg-amber-50 p-3 text-sm text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200",children:[e.jsx("span",{className:"font-medium",children:"Remote URL required:"})," Set a remote URL above to enable GitHub authentication."]}),c==="github"&&a?.remote&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3 rounded border p-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[w?e.jsx(T,{className:"h-5 w-5 mt-1 animate-spin text-muted-foreground"}):a?.authenticated?e.jsx(Oe,{className:"h-5 w-5 mt-1 text-green-600"}):e.jsx(Ie,{className:"h-5 w-5 mt-1 text-red-600"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx("div",{className:"font-medium",children:w?"Checking...":L?"Connected to GitHub":I?"GitHub authorization required":a?.authenticated?"Authenticated":"Not authenticated"}),Se&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(we,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:L?"GitHub App credentials active":"Authorize with GitHub to continue"})]}),L&&de&&e.jsxs("span",{className:"rounded bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",children:["Expires ",de]})]}),a?.error&&e.jsx("div",{className:"text-xs text-red-600",children:a.error})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:l,disabled:w,children:[e.jsx(T,{className:"h-4 w-4 mr-2"+(w?" animate-spin":"")}),"Check Status"]}),L?e.jsx(o,{variant:"ghost",size:"sm",onClick:Ee,disabled:ie,children:ie?"Disconnecting…":"Disconnect GitHub"}):e.jsxs(o,{size:"sm",onClick:Re,disabled:p,children:[p?e.jsx(De,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(we,{className:"h-4 w-4 mr-2"}),p?"Authorizing…":I?"Reconnect GitHub":"Connect GitHub"]})]}),e.jsx("div",{className:"text-right",children:e.jsxs("a",{href:"https://app.coconut.dev/git",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:["Manage Github authentication",e.jsx(xe,{className:"h-3 w-3"})]})})]}),I&&e.jsx("div",{className:"rounded border border-amber-200 bg-amber-50 p-3 text-xs text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200",children:"GitHub authorization has expired. Click “Reconnect GitHub” to refresh access."}),x&&(x.helper||x.origin)&&e.jsxs("div",{className:"rounded border bg-muted/50 p-3",children:[e.jsx("div",{className:"text-xs font-medium mb-1",children:"Current Configuration"}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[x.helper&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"font-mono",children:"credential.helper:"}),e.jsx("span",{className:"font-mono text-foreground",children:x.helper})]}),x.origin&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"font-mono",children:"Configured in:"}),e.jsx("span",{className:"font-mono text-foreground",children:x.origin})]})]})]})]}),c==="local"&&e.jsxs("div",{className:"rounded bg-muted p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm font-medium",children:"Setup Git Credentials"}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>N(!0),children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Enter Credentials"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-2",children:[e.jsx("p",{children:"Configure credentials directly on this Coconut. Coconut will use your existing SSH keys or credential helpers without contacting the control plane."}),e.jsxs("div",{className:"space-y-2 ml-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Option 1: SSH Keys (Recommended)"}),e.jsxs("code",{className:"text-[11px] block mt-1 bg-background rounded px-2 py-1",children:['ssh-keygen -t ed25519 -C "your_email@example.com"',e.jsx("br",{}),"# Add ~/.ssh/id_ed25519.pub to your Git provider account"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Option 2: Git Credential Manager"}),e.jsxs("code",{className:"text-[11px] block mt-1 bg-background rounded px-2 py-1",children:["# macOS (already configured with osxkeychain)",e.jsx("br",{}),"git credential-osxkeychain",e.jsx("br",{}),e.jsx("br",{}),"# Or install Git Credential Manager",e.jsx("br",{}),"brew install git-credential-manager"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Option 3: Personal Access Token"}),e.jsxs("code",{className:"text-[11px] block mt-1 bg-background rounded px-2 py-1",children:["# Store credentials after first push/pull",e.jsx("br",{}),"git config credential.helper store"]})]})]}),e.jsx("p",{className:"mt-3",children:'After configuring, click "Check Status" to verify authentication.'})]})]})]})]}),e.jsxs(pe,{children:[e.jsxs(ge,{children:[e.jsx(fe,{children:"Worktree Location"}),e.jsx(be,{children:"Choose where new worktrees should be created relative to your project root."})]}),e.jsxs(je,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"default-worktree-path",children:"Default worktree path"}),e.jsx(U,{id:"default-worktree-path",value:X,onChange:t=>v(t.target.value),placeholder:"../worktrees",spellCheck:!1}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paths are resolved from your project root. We recommend keeping worktrees outside the repository, for example ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-[11px] font-mono",children:V}),"."]}),$&&e.jsx("p",{className:"text-xs text-red-600",children:$})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(o,{type:"button",variant:"outline",size:"sm",onClick:()=>v(V),children:["Use ",V]}),e.jsxs(o,{type:"button",variant:"ghost",size:"sm",onClick:()=>v(y),children:["Reset to ",y]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(o,{type:"button",variant:"outline",disabled:H,onClick:M,children:"Reload"}),e.jsx(o,{type:"button",disabled:!ue,onClick:Te,children:H?"Saving...":"Save changes"})]}),e.jsx(W,{open:Ne,onOpenChange:N,children:e.jsxs(q,{children:[e.jsxs(B,{children:[e.jsx(J,{children:"Enter Git Credentials"}),e.jsx(K,{children:"Enter your username and personal access token for HTTPS authentication. Your credentials will be securely stored using your system's credential manager."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[!a?.remote&&e.jsx("div",{className:"rounded border border-amber-200 bg-amber-50 p-3 text-xs text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200",children:"No remote URL configured. Set a remote URL first before entering credentials."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"git-username",children:"Username"}),e.jsx(U,{id:"git-username",placeholder:"your-username",value:C,onChange:t=>F(t.target.value),autoComplete:"username"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"git-password",children:"Password / Personal Access Token"}),e.jsx(U,{id:"git-password",type:"password",placeholder:"ghp_xxxxxxxxxxxx or your password",value:k,onChange:t=>D(t.target.value),autoComplete:"current-password"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["We recommend using a Personal Access Token instead of your password.",e.jsx("br",{}),"GitHub: Settings → Developer settings → Personal access tokens",e.jsx("br",{}),"GitLab: Preferences → Access Tokens"]})]})]}),e.jsxs(Y,{children:[e.jsx(o,{variant:"outline",onClick:()=>{N(!1),F(""),D("")},children:"Cancel"}),e.jsx(o,{onClick:Le,disabled:re||!C||!k||!a?.remote,children:re?"Saving...":"Save Credentials"})]})]})}),e.jsx(W,{open:ke,onOpenChange:P,children:e.jsxs(q,{children:[e.jsxs(B,{children:[e.jsx(J,{children:"Remove Remote?"}),e.jsx(K,{children:"This will remove the origin remote from your local git configuration. The remote repository itself won't be affected."})]}),e.jsxs(Y,{children:[e.jsx(o,{variant:"outline",onClick:()=>P(!1),children:"Cancel"}),e.jsx(o,{variant:"destructive",onClick:async()=>{P(!1),await Pe()},disabled:z,children:z?"Removing...":"Remove Remote"})]})]})}),e.jsx(W,{open:Ce,onOpenChange:R,children:e.jsxs(q,{children:[e.jsxs(B,{children:[e.jsx(J,{children:a?.remote?"Edit Remote URL":"Set Remote URL"}),e.jsx(K,{children:"Configure the git remote URL for your repository. This is the origin remote used for push and pull operations."})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"remote-url",children:"Remote URL"}),e.jsx(U,{id:"remote-url",placeholder:"https://github.com/username/repo.git",value:E,onChange:t=>G(t.target.value),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter your repository URL (HTTPS or SSH format)."})]})}),e.jsxs(Y,{children:[e.jsx(o,{variant:"outline",onClick:()=>{R(!1),G("")},children:"Cancel"}),e.jsx(o,{onClick:Ge,disabled:ne||!E.trim(),children:ne?"Saving...":"Save"})]})]})})]})}export{Xe as default};
@@ -0,0 +1,11 @@
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";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Re=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Je=oe("mail",Re);/**
7
+ * @license lucide-react v0.542.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const $e=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],qe=oe("refresh-ccw",$e),Be=["a2a_v0.2","a2a_v0.1","jsonrpc2","jsonrpc","openrpc","rest"],Ke=["GET","POST","PUT","PATCH","DELETE"],He=()=>({id:"",skill:"",description:"",endpoint:"",method:"POST",enabled:!0,inputMimeType:"application/json",outputMimeType:"application/json",inputSchema:"",outputSchema:""}),w={id:"",name:"",description:"",version:"1.0.0",url:"",documentation:"",protocols:["a2a_v0.2"],authentication:{scheme:"api_key",in:"header",name:"X-API-Key",example:"",description:""},capabilities:[],supportedInputTypes:["application/json"],supportedOutputTypes:["application/json"],security:{transport:"https",encryption:"TLS 1.3",notes:""},contact:{name:"",email:""},lastUpdated:void 0},N=a=>({...a,protocols:[...a.protocols],authentication:{...a.authentication},capabilities:a.capabilities.map(n=>({...n})),supportedInputTypes:[...a.supportedInputTypes],supportedOutputTypes:[...a.supportedOutputTypes],security:{...a.security},contact:{...a.contact}}),F=()=>N(w);function Ve(a){if(!a)return F();const n=Array.isArray(a.protocols)?a.protocols.filter(r=>typeof r=="string"):[],d=Array.isArray(a.supportedContentTypes?.input)?a.supportedContentTypes.input.filter(r=>typeof r=="string"):[],A=Array.isArray(a.supportedContentTypes?.output)?a.supportedContentTypes.output.filter(r=>typeof r=="string"):[],T=Array.isArray(a.capabilities)?a.capabilities.map(r=>({id:typeof r.id=="string"?r.id:"",skill:typeof r.skill=="string"?r.skill:"",description:typeof r.description=="string"?r.description:"",endpoint:typeof r.endpoint=="string"?r.endpoint:"",method:typeof r.method=="string"?r.method:"POST",enabled:r?.enabled!==!1,inputMimeType:typeof r.input?.mimeType=="string"?r.input.mimeType:"application/json",outputMimeType:typeof r.output?.mimeType=="string"?r.output.mimeType:"application/json",inputSchema:r.input?.schema?JSON.stringify(r.input.schema,null,2):"",outputSchema:r.output?.schema?JSON.stringify(r.output.schema,null,2):""})):[],M={scheme:typeof a.authentication?.scheme=="string"?a.authentication.scheme:"api_key",in:typeof a.authentication?.in=="string"?a.authentication.in:"header",name:typeof a.authentication?.name=="string"?a.authentication.name:"X-API-Key",example:typeof a.authentication?.example=="string"?a.authentication.example:"",description:typeof a.authentication?.description=="string"?a.authentication.description:""};return{id:typeof a.id=="string"?a.id:"",name:typeof a.name=="string"?a.name:"",description:typeof a.description=="string"?a.description:"",version:typeof a.version=="string"?a.version:"1.0.0",url:typeof a.url=="string"?a.url:"",documentation:typeof a.documentation=="string"?a.documentation:"",protocols:n.length>0?n:w.protocols,authentication:M,capabilities:T,supportedInputTypes:d.length>0?d:w.supportedInputTypes,supportedOutputTypes:A.length>0?A:w.supportedOutputTypes,security:{transport:typeof a.security?.transport=="string"?a.security.transport:w.security.transport,encryption:typeof a.security?.encryption=="string"?a.security.encryption:w.security.encryption,notes:typeof a.security?.notes=="string"?a.security.notes:""},contact:{name:typeof a.contact?.name=="string"?a.contact.name:"",email:typeof a.contact?.email=="string"?a.contact.email:""},lastUpdated:typeof a.lastUpdated=="string"?a.lastUpdated:void 0}}function at(){const{toast:a}=ve(),[n,d]=u.useState(()=>F()),[A,T]=u.useState(()=>F()),[M,r]=u.useState(!0),[L,B]=u.useState(!1),[K,k]=u.useState(null),[H,D]=u.useState(""),[V,_]=u.useState(""),[z,U]=u.useState(""),[P,R]=u.useState(void 0),[le,X]=u.useState(!1),ce=u.useMemo(()=>{const t=new Set([...Be,...n.protocols]);return Array.from(t).sort()},[n.protocols]);u.useEffect(()=>{let t=!0;return(async()=>{r(!0),k(null);try{const s=await fetch(`${ie}/api/v1/identity/agent-card`);if(!s.ok)throw new Error(`Failed to load agent card (${s.status})`);const l=await s.json();if(l.success&&l.data){const p=Ve(l.data.card||void 0);if(p.id||(p.id="urn:agent:coconut"),p.url||(p.url=`${window.location.origin}/api/v1`),p.lastUpdated=l.data.updatedAt??p.lastUpdated,t){const m=N(p);d(m),T(N(m)),R(l.data.updatedAt??m.lastUpdated)}}else{if(l.error)throw new Error(l.error);if(t){const p=F();d(p),T(N(p))}}}catch(s){if(console.error("Failed to fetch agent card",s),t){k(s instanceof Error?s.message:"Failed to load agent identity");const l=F();d(l),T(N(l))}}finally{t&&r(!1)}})(),()=>{t=!1}},[]);const de=(t,i)=>{d(s=>{const l=i?[...new Set([...s.protocols,t])]:s.protocols.filter(p=>p!==t);return{...s,protocols:l}})},Z=()=>{const t=H.trim();t&&(d(i=>({...i,protocols:[...new Set([...i.protocols,t])]})),D(""))},Y=()=>{const t=V.trim();t&&(d(i=>({...i,supportedInputTypes:[...new Set([...i.supportedInputTypes,t])]})),_(""))},G=()=>{const t=z.trim();t&&(d(i=>({...i,supportedOutputTypes:[...new Set([...i.supportedOutputTypes,t])]})),U(""))},pe=t=>{d(i=>({...i,supportedInputTypes:i.supportedInputTypes.filter(s=>s!==t)}))},ue=t=>{d(i=>({...i,supportedOutputTypes:i.supportedOutputTypes.filter(s=>s!==t)}))},C=(t,i)=>{d(s=>({...s,[t]:i}))},I=(t,i)=>{d(s=>({...s,authentication:{...s.authentication,[t]:i}}))},J=(t,i)=>{d(s=>({...s,security:{...s.security,[t]:i}}))},W=(t,i)=>{d(s=>({...s,contact:{...s.contact,[t]:i}}))},he=()=>{d(t=>({...t,capabilities:[...t.capabilities,He()]}))},h=(t,i)=>{d(s=>{const l=[...s.capabilities];return l[t]={...l[t],...i},{...s,capabilities:l}})},me=t=>{d(i=>({...i,capabilities:i.capabilities.filter((s,l)=>l!==t)}))},$=()=>{const t=[["id","Agent ID"],["name","Name"],["description","Description"],["version","Version"],["url","Service URL"]];for(const[s,l]of t){const p=n[s];if(typeof p!="string"||!p.trim())throw new Error(`${l} is required`)}const i=n.capabilities.map((s,l)=>({cap:s,index:l})).filter(({cap:s})=>s.enabled&&s.id.trim()&&s.endpoint.trim()).map(({cap:s,index:l})=>{const p=s.id.trim()||`Capability ${l+1}`,m={id:s.id.trim(),skill:s.skill.trim(),description:s.description.trim(),endpoint:s.endpoint.trim(),method:s.method||"POST"},ee=(q,je)=>{if(!(!q||!q.trim()))try{return JSON.parse(q)}catch(te){throw new Error(`${p} ${je} schema must be valid JSON. ${te?.message??te}`)}};return(s.inputMimeType?.trim()||s.inputSchema?.trim())&&(m.input={mimeType:s.inputMimeType?.trim()||"application/json",schema:ee(s.inputSchema,"input")}),(s.outputMimeType?.trim()||s.outputSchema?.trim())&&(m.output={mimeType:s.outputMimeType?.trim()||"application/json",schema:ee(s.outputSchema,"output")}),m});return{id:n.id.trim(),name:n.name.trim(),description:n.description.trim(),version:n.version.trim(),url:n.url.trim(),documentation:n.documentation.trim()||void 0,protocols:n.protocols,authentication:{scheme:n.authentication.scheme.trim()||"api_key",in:n.authentication.in.trim()||"header",name:n.authentication.name.trim()||"X-API-Key",example:n.authentication.example.trim()||void 0,description:n.authentication.description.trim()||void 0},capabilities:i,supportedContentTypes:{input:n.supportedInputTypes,output:n.supportedOutputTypes},security:{transport:n.security.transport.trim()||"https",encryption:n.security.encryption.trim()||"TLS 1.3",notes:n.security.notes.trim()||void 0},contact:{name:n.contact.name.trim()||void 0,email:n.contact.email.trim()||void 0},lastUpdated:new Date().toISOString()}},xe=async()=>{B(!0),k(null);try{const t=$(),i=await fetch(`${ie}/api/v1/identity/agent-card`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({card:t})}),s=await i.json();if(!i.ok||!s?.success)throw new Error(s?.error||"Failed to save agent card");a({title:"Agent card saved",description:"The identity card has been updated successfully."});const l=s?.data?.updatedAt??new Date().toISOString();d(p=>{const m={...p,lastUpdated:l};return T(N(m)),m}),R(l)}catch(t){console.error("Failed to save agent card",t),k(t instanceof Error?t.message:"Failed to save agent card"),a({title:"Save failed",description:t instanceof Error?t.message:"Failed to save agent card, see console for details.",variant:"destructive"})}finally{B(!1)}},ye=()=>{d(N(A)),k(null),D(""),_(""),U(""),R(A.lastUpdated??P)},ge=async()=>{try{const t=JSON.stringify($(),null,2);await navigator.clipboard.writeText(t),X(!0),setTimeout(()=>X(!1),1500),a({title:"Copied!",description:"Agent card JSON copied to clipboard."})}catch(t){console.error("Failed to copy agent card preview:",t),a({title:"Copy failed",description:"Unable to copy agent card JSON to clipboard.",variant:"destructive"})}},Q=u.useMemo(()=>{if(!P)return null;try{return new Date(P).toLocaleString()}catch{return null}},[P]);return M?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(se,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading identity card..."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col justify-between gap-4 md:flex-row md:items-end",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Agent Identity"}),e.jsxs("p",{className:"text-muted-foreground",children:["Manage the"," ",e.jsx("a",{href:"/.well-known/agent-card.json",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-4 hover:text-primary",children:"/.well-known/agent-card.json"})," ","descriptor for A2A discovery."]}),Q&&e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Last updated ",Q]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(x,{variant:"outline",onClick:ye,disabled:L,children:[e.jsx(qe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Reset"})]}),e.jsx(x,{onClick:xe,disabled:L,children:L?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"h-4 w-4 animate-spin sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Saving..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Save Changes"})]})})]})]}),K&&e.jsxs(Fe,{variant:"destructive",children:[e.jsx("div",{className:"font-semibold",children:"Something went wrong"}),e.jsx(Pe,{children:K})]}),e.jsxs(Ee,{defaultValue:"overview",className:"space-y-6",children:[e.jsxs(Me,{className:"grid w-full grid-cols-6 h-auto p-1",children:[e.jsxs(b,{value:"overview",className:"gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Identity"})]}),e.jsxs(b,{value:"protocols",className:"gap-2",children:[e.jsx(Te,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Protocols"})]}),e.jsxs(b,{value:"auth",className:"gap-2",children:[e.jsx(Ce,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Security"})]}),e.jsxs(b,{value:"capabilities",className:"gap-2",children:[e.jsx(Le,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Capabilities"})]}),e.jsxs(b,{value:"contact",className:"gap-2",children:[e.jsx(Je,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(b,{value:"preview",className:"gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Preview"})]})]}),e.jsx(S,{value:"overview",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Identity Overview"}),e.jsx(v,{children:"Define core attributes used for discovery."})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-id",children:"Agent Identifier"}),e.jsx(c,{id:"agent-id",value:n.id,placeholder:"urn:agent:coconut-dev",onChange:t=>C("id",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-name",children:"Name"}),e.jsx(c,{id:"agent-name",value:n.name,placeholder:"Coconut Development Agent",onChange:t=>C("name",t.target.value)})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-version",children:"Version"}),e.jsx(c,{id:"agent-version",value:n.version,placeholder:"1.0.0",onChange:t=>C("version",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-url",children:"Primary Endpoint"}),e.jsx(c,{id:"agent-url",value:n.url,placeholder:"https://coconut.dev/api/v1",onChange:t=>C("url",t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-description",children:"Description"}),e.jsx(O,{id:"agent-description",value:n.description,placeholder:"Agent responsible for managing proposals, plans, and operations...",onChange:t=>C("description",t.target.value),rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-docs",children:"Documentation URL"}),e.jsx(c,{id:"agent-docs",value:n.documentation,placeholder:"https://docs.coconut.dev/a2a",onChange:t=>C("documentation",t.target.value)})]})]})]})}),e.jsx(S,{value:"protocols",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Protocols & Content Types"}),e.jsx(v,{children:"Select supported discovery protocols and payload formats."})]}),e.jsxs(f,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Protocols"}),e.jsx("div",{className:"grid gap-2 md:grid-cols-3",children:ce.map(t=>e.jsxs("label",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[e.jsx(ae,{checked:n.protocols.includes(t),onCheckedChange:i=>de(t,!!i)}),e.jsx("span",{className:"text-sm font-medium",children:t})]},t))}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:H,placeholder:"Add custom protocol (press Add)",onChange:t=>D(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),Z())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:Z,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]})]}),e.jsx(ne,{}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Supported Input Types"}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:V,placeholder:"application/json",onChange:t=>_(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),Y())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:Y,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.supportedInputTypes.map(t=>e.jsxs(re,{variant:"secondary",className:"flex items-center gap-1",children:[t,e.jsx("button",{type:"button",onClick:()=>pe(t),className:"ml-1 rounded-full border border-transparent bg-transparent text-muted-foreground transition hover:text-foreground",children:"×"})]},t))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Supported Output Types"}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:z,placeholder:"application/json",onChange:t=>U(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),G())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:G,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.supportedOutputTypes.map(t=>e.jsxs(re,{variant:"secondary",className:"flex items-center gap-1",children:[t,e.jsx("button",{type:"button",onClick:()=>ue(t),className:"ml-1 rounded-full border border-transparent bg-transparent text-muted-foreground transition hover:text-foreground",children:"×"})]},t))})]})]})]})]})}),e.jsx(S,{value:"auth",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Authentication & Security"}),e.jsx(v,{children:"Document how peer agents should authenticate and connect."})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-scheme",children:"Authentication Scheme"}),e.jsx(c,{id:"auth-scheme",value:n.authentication.scheme,placeholder:"api_key",onChange:t=>I("scheme",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-in",children:"Credential Location"}),e.jsx(c,{id:"auth-in",value:n.authentication.in,placeholder:"header",onChange:t=>I("in",t.target.value)})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-name",children:"Header or Field Name"}),e.jsx(c,{id:"auth-name",value:n.authentication.name,placeholder:"X-API-Key",onChange:t=>I("name",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-example",children:"Example Secret"}),e.jsx(c,{id:"auth-example",value:n.authentication.example,placeholder:"nut_***************",onChange:t=>I("example",t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-description",children:"Authentication Notes"}),e.jsx(O,{id:"auth-description",value:n.authentication.description,placeholder:"Provide API key via X-API-Key header to authenticate requests between agents.",onChange:t=>I("description",t.target.value),rows:3})]}),e.jsx(ne,{}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-transport",children:"Transport"}),e.jsx(c,{id:"security-transport",value:n.security.transport,placeholder:"https",onChange:t=>J("transport",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-encryption",children:"Encryption"}),e.jsx(c,{id:"security-encryption",value:n.security.encryption,placeholder:"TLS 1.3",onChange:t=>J("encryption",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-notes",children:"Security Notes"}),e.jsx(c,{id:"security-notes",value:n.security.notes,placeholder:"Requests must be encrypted over TLS.",onChange:t=>J("notes",t.target.value)})]})]})]})]})}),e.jsx(S,{value:"capabilities",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Capabilities"}),e.jsx(v,{children:"Describe the skills other agents can invoke."})]}),e.jsxs(f,{className:"space-y-4",children:[n.capabilities.length===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 p-6 text-center text-sm text-muted-foreground",children:"No capabilities defined yet. Add one to expose functionality for peer agents."}),n.capabilities.map((t,i)=>e.jsxs(y,{className:"border border-border/60",children:[e.jsxs(g,{className:"flex flex-col gap-2 space-y-0 md:flex-row md:items-center",children:[e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsxs(j,{className:"text-lg font-semibold",children:["Capability #",i+1]}),e.jsx(v,{children:"Toggle availability and describe request contracts."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ae,{checked:t.enabled,onCheckedChange:s=>h(i,{enabled:!!s})}),"Expose capability"]}),e.jsxs(x,{size:"icon",variant:"ghost",onClick:()=>me(i),title:"Remove capability",children:[e.jsx(be,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Remove capability"})]})]})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Capability ID"}),e.jsx(c,{value:t.id,placeholder:"create-proposal",onChange:s=>h(i,{id:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Skill"}),e.jsx(c,{value:t.skill,placeholder:"proposal_management.create",onChange:s=>h(i,{skill:s.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Description"}),e.jsx(O,{value:t.description,placeholder:"Creates a new proposal record containing intent, plan, and artifacts.",rows:3,onChange:s=>h(i,{description:s.target.value})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Endpoint"}),e.jsx(c,{value:t.endpoint,placeholder:"https://coconut.dev/api/v1/proposals",onChange:s=>h(i,{endpoint:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"HTTP Method"}),e.jsxs(Se,{value:t.method,onValueChange:s=>h(i,{method:s}),children:[e.jsx(we,{children:e.jsx(Ae,{placeholder:"Select method"})}),e.jsx(ke,{children:Ke.map(s=>e.jsx(Ie,{value:s,children:s},s))})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Input MIME Type"}),e.jsx(c,{value:t.inputMimeType??"",placeholder:"application/json",onChange:s=>h(i,{inputMimeType:s.target.value})}),e.jsx(o,{children:"Input Schema (JSON)"}),e.jsx(O,{value:t.inputSchema??"",placeholder:'{ "type": "object", "properties": { "title": { "type": "string" } } }',rows:5,onChange:s=>h(i,{inputSchema:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Output MIME Type"}),e.jsx(c,{value:t.outputMimeType??"",placeholder:"application/json",onChange:s=>h(i,{outputMimeType:s.target.value})}),e.jsx(o,{children:"Output Schema (JSON)"}),e.jsx(O,{value:t.outputSchema??"",placeholder:'{ "type": "object", "properties": { "status": { "type": "string" } } }',rows:5,onChange:s=>h(i,{outputSchema:s.target.value})})]})]})]})]},`${t.id||"capability"}-${i}`))]}),e.jsx(Oe,{children:e.jsxs(x,{type:"button",variant:"outline",onClick:he,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add Capability"]})})]})}),e.jsx(S,{value:"contact",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Contact"}),e.jsx(v,{children:"Provide a human escalation path for peer agents."})]}),e.jsxs(f,{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"contact-name",children:"Contact Name"}),e.jsx(c,{id:"contact-name",value:n.contact.name,placeholder:"Coconut DevOps Team",onChange:t=>W("name",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"contact-email",children:"Contact Email"}),e.jsx(c,{id:"contact-email",value:n.contact.email,placeholder:"support@coconut.dev",onChange:t=>W("email",t.target.value)})]})]})]})}),e.jsx(S,{value:"preview",children:e.jsxs(y,{children:[e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(j,{children:"Preview"}),e.jsx(v,{children:"Review the JSON payload served at /.well-known/agent-card.json."})]}),e.jsx(x,{variant:"outline",size:"sm",onClick:ge,children:le?e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ue,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy"})]})})]})}),e.jsx(f,{children:e.jsx("pre",{className:"max-h-96 overflow-auto rounded-md bg-muted p-4 text-sm",children:JSON.stringify((()=>{try{return $()}catch{return{id:n.id,name:n.name,description:n.description,version:n.version,url:n.url,protocols:n.protocols}}})(),null,2)})})]})})]})]})}export{at as default};
@@ -0,0 +1,6 @@
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";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const k=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],C=u("list-checks",k),I=[{value:"pending",label:"Pending"},{value:"in-progress",label:"In Progress"},{value:"completed",label:"Completed"},{value:"failed",label:"Blocked / Failed"}],N=()=>typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`step-${Date.now()}-${Math.floor(Math.random()*1e3)}`;function L({steps:l,onChange:i,disabled:n,className:o}){const d=(a,t)=>{i(l.map(s=>s.id===a?{...s,...t}:s))},h=a=>{i(l.filter(t=>t.id!==a))},m=()=>{i([...l,{id:N(),description:"",status:"pending"}])};return e.jsxs("div",{className:p("space-y-4",o),children:[l.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Break the work down into actionable steps."}),l.map((a,t)=>e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm font-semibold",children:["Step ",t+1]}),e.jsx(r,{type:"button",variant:"ghost",size:"icon",onClick:()=>h(a.id),disabled:n,"aria-label":`Remove step ${t+1}`,children:e.jsx(x,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:`${a.id}-description`,children:"Description"}),e.jsx(j,{id:`${a.id}-description`,value:a.description,onChange:s=>d(a.id,{description:s.target.value}),placeholder:"What needs to be done?",disabled:n})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:`${a.id}-status`,children:"Status"}),e.jsxs(v,{value:a.status,onValueChange:s=>d(a.id,{status:s}),disabled:n,children:[e.jsx(y,{id:`${a.id}-status`,children:e.jsx(S,{placeholder:"Select status"})}),e.jsx(f,{children:I.map(s=>e.jsx(g,{value:s.value,children:s.label},s.value))})]})]})]},a.id)),e.jsxs(r,{type:"button",variant:"outline",onClick:m,disabled:n,children:[e.jsx(b,{className:"mr-2 h-4 w-4"}),"Add Step"]})]})}export{L as I,C as L};
@@ -0,0 +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};
@@ -0,0 +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};
@@ -0,0 +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};
@@ -0,0 +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";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const 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
+
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};
@@ -0,0 +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};
@@ -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 g,a0 as M,J as ae,T as oe,g as ce,ad as le}from"./index-BSBM4i_g.js";import{C as P,b as F,c as O,d as R,a as $}from"./card-Cnz8b7Ou.js";import{L as m}from"./label-vEgNxdb2.js";import{B as J}from"./badge-DO6e5hC1.js";import{S as I}from"./switch-Bjq8cgQn.js";import{A as q,a as z}from"./alert-CNSGDe1U.js";import{R as de,a as me,L as he}from"./browser-modal-BTxVvZIA.js";import{C as L}from"./circle-alert-Dick-jNf.js";import{P as Y}from"./plus-BfBtnncn.js";import{C as xe}from"./circle-check-big-B70gdce7.js";import"./search-kcgmZUqQ.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:de,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 ge({open:r,onOpenChange:t,onImport:o}){return e.jsx(me,{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(p=>typeof p=="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(p=>e.jsx(J,{variant:"secondary",children:p},p))}),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(p=>e.jsx("li",{children:p},p))})]}),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 Ae(){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),[p,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(he,{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(g,{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(g,{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(g,{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(g,{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=p===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(g,{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(g,{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(g,{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(g,{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(g,{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(g,{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(ge,{open:V,onOpenChange:T,onImport:ee})]})}export{Ae as default};