@lovelybunch/api 1.0.75-alpha.8 → 1.0.75

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 (188) hide show
  1. package/dist/lib/jobs/job-runner.js +10 -2
  2. package/dist/lib/jobs/job-scheduler.js +21 -0
  3. package/dist/lib/mail/mail-runner.d.ts +51 -0
  4. package/dist/lib/mail/mail-runner.js +342 -0
  5. package/dist/lib/slack/slack-service.d.ts +2 -0
  6. package/dist/lib/slack/slack-service.js +3 -0
  7. package/dist/lib/storage/file-storage.d.ts +16 -16
  8. package/dist/lib/storage/file-storage.js +59 -64
  9. package/dist/lib/terminal/terminal-manager.d.ts +3 -5
  10. package/dist/lib/terminal/terminal-manager.js +10 -61
  11. package/dist/routes/api/v1/ai/route.js +361 -20
  12. package/dist/routes/api/v1/chats/[id]/index.js +2 -1
  13. package/dist/routes/api/v1/chats/[id]/route.d.ts +7 -0
  14. package/dist/routes/api/v1/chats/[id]/route.js +30 -1
  15. package/dist/routes/api/v1/context/index.js +0 -2
  16. package/dist/routes/api/v1/git/index.js +23 -0
  17. package/dist/routes/api/v1/knowledge/[filename]/index.d.ts +1 -0
  18. package/dist/routes/api/v1/knowledge/[filename]/index.js +1 -0
  19. package/dist/routes/api/v1/knowledge/[filename]/route.d.ts +3 -0
  20. package/dist/routes/api/v1/knowledge/[filename]/route.js +254 -0
  21. package/dist/routes/api/v1/knowledge/index.d.ts +1 -0
  22. package/dist/routes/api/v1/knowledge/index.js +1 -0
  23. package/dist/routes/api/v1/knowledge/route.d.ts +3 -0
  24. package/dist/routes/api/v1/knowledge/route.js +176 -0
  25. package/dist/routes/api/v1/mail/index.d.ts +3 -0
  26. package/dist/routes/api/v1/mail/index.js +23 -0
  27. package/dist/routes/api/v1/mail/route.d.ts +294 -0
  28. package/dist/routes/api/v1/mail/route.js +344 -0
  29. package/dist/routes/api/v1/mcp/index.js +109 -34
  30. package/dist/routes/api/v1/slack/index.d.ts +3 -0
  31. package/dist/routes/api/v1/slack/index.js +15 -0
  32. package/dist/routes/api/v1/slack/route.d.ts +124 -0
  33. package/dist/routes/api/v1/slack/route.js +192 -0
  34. package/dist/routes/api/v1/tasks/[id]/route.d.ts +117 -0
  35. package/dist/routes/api/v1/tasks/[id]/route.js +166 -0
  36. package/dist/routes/api/v1/tasks/index.d.ts +3 -0
  37. package/dist/routes/api/v1/tasks/index.js +10 -0
  38. package/dist/routes/api/v1/tasks/route.d.ts +96 -0
  39. package/dist/routes/api/v1/tasks/route.js +136 -0
  40. package/dist/routes/api/v1/terminal/[proposalId]/create/route.js +2 -2
  41. package/dist/routes/api/v1/terminal/[taskId]/create/index.d.ts +3 -0
  42. package/dist/routes/api/v1/terminal/[taskId]/create/index.js +5 -0
  43. package/dist/routes/api/v1/terminal/[taskId]/create/route.d.ts +10 -0
  44. package/dist/routes/api/v1/terminal/[taskId]/create/route.js +27 -0
  45. package/dist/routes/api/v1/terminal/[taskId]/destroy/index.d.ts +3 -0
  46. package/dist/routes/api/v1/terminal/[taskId]/destroy/index.js +5 -0
  47. package/dist/routes/api/v1/terminal/[taskId]/destroy/route.d.ts +10 -0
  48. package/dist/routes/api/v1/terminal/[taskId]/destroy/route.js +21 -0
  49. package/dist/routes/api/v1/terminal/[taskId]/resize/index.d.ts +3 -0
  50. package/dist/routes/api/v1/terminal/[taskId]/resize/index.js +5 -0
  51. package/dist/routes/api/v1/terminal/[taskId]/resize/route.d.ts +10 -0
  52. package/dist/routes/api/v1/terminal/[taskId]/resize/route.js +21 -0
  53. package/dist/routes/api/v1/terminal/sessions/route.js +4 -4
  54. package/dist/server-with-static.js +14 -8
  55. package/dist/server.js +14 -8
  56. package/package.json +4 -4
  57. package/static/assets/{ActivityPage-DSSML9J-.js → ActivityPage-k4I7Q53O.js} +1 -1
  58. package/static/assets/ApiKeysSettingsPage-B1YvVdmg.js +2 -0
  59. package/static/assets/{ArchitectureEditPage-CIjqkpMz.js → ArchitectureEditPage-CpowsIx2.js} +1 -1
  60. package/static/assets/{ArchitecturePage-Db__w054.js → ArchitecturePage-DYxC_aMR.js} +1 -1
  61. package/static/assets/{AuthSettingsPage-Bpooi8Z0.js → AuthSettingsPage-DtSo78Y_.js} +2 -2
  62. package/static/assets/{CallbackPage-BGLKeyjv.js → CallbackPage-bROCGapx.js} +1 -1
  63. package/static/assets/CodePage-CPCj64rX.js +2 -0
  64. package/static/assets/{CollapsibleSection-B6RO5o5R.js → CollapsibleSection-M5cXbl92.js} +1 -1
  65. package/static/assets/DashboardPage-B9BZZfw6.js +51 -0
  66. package/static/assets/{GitPage-DxjLaRWe.js → GitPage-BiDtdSK1.js} +2 -2
  67. package/static/assets/GitSettingsPage-THm6wDjs.js +6 -0
  68. package/static/assets/IdentityPage-BC16skg6.js +6 -0
  69. package/static/assets/{ImplementationStepsEditor-DWjDyZzP.js → ImplementationStepsEditor-HliLQav5.js} +2 -2
  70. package/static/assets/IntegrationsSettingsPage-CC_VKIQa.js +1 -0
  71. package/static/assets/JobDetailPage-z1QQYvmU.js +1 -0
  72. package/static/assets/KnowledgeDetailPage-DzHXBS7Q.js +1 -0
  73. package/static/assets/KnowledgeEditPage-BwGnUH_m.js +1 -0
  74. package/static/assets/KnowledgePage-CGIVMS02.js +3 -0
  75. package/static/assets/{LoginPage-DptfKsWo.js → LoginPage-VQ3lcfLV.js} +1 -1
  76. package/static/assets/MailInboxPage-DiZKqwdU.js +1 -0
  77. package/static/assets/MailProcessingModal-DIeSQBoR.js +6 -0
  78. package/static/assets/MailReadPage-C8AACmZQ.js +1 -0
  79. package/static/assets/MailSentPage-C_5yFly_.js +1 -0
  80. package/static/assets/McpSettingsPage-i9YHcu1s.js +1 -0
  81. package/static/assets/NewKnowledgePage-BnVY7WUD.js +9 -0
  82. package/static/assets/{NewSkillPage-Cwy2MSr9.js → NewSkillPage-DwniHD6D.js} +1 -1
  83. package/static/assets/NewTaskPage-F5UX2WMc.js +90 -0
  84. package/static/assets/NotFoundPage-BbSZX_4L.js +6 -0
  85. package/static/assets/NotificationsSettingsPage-C8kjcift.js +1 -0
  86. package/static/assets/ProjectEditPage-DUUlIEqI.js +11 -0
  87. package/static/assets/{ProjectPage-DgUr4bVU.js → ProjectPage-Unz9PQpA.js} +1 -1
  88. package/static/assets/PromptsSettingsPage-DVpIuRKI.js +1 -0
  89. package/static/assets/ResourceDetailPage-DqHZ2KYD.js +1 -0
  90. package/static/assets/ResourcesPage-BP5tuAi-.js +41 -0
  91. package/static/assets/RoleEditPage-BgKu8S0-.js +13 -0
  92. package/static/assets/{RolePage-Sc-GFiL2.js → RolePage-Fed52Ov5.js} +1 -1
  93. package/static/assets/{RulesSettingsPage-DdMCzh9j.js → RulesSettingsPage-BQ2O0u66.js} +2 -2
  94. package/static/assets/SchedulePage-jkxjuzBx.js +4 -0
  95. package/static/assets/SkillDetailPage-k3Q2-NFd.js +1 -0
  96. package/static/assets/{SkillEditPage-BDd2CtAS.js → SkillEditPage-urF4snjo.js} +1 -1
  97. package/static/assets/SkillsPage-DlWDhEjR.js +8 -0
  98. package/static/assets/{SkillsSettingsPage-1N0JQOYc.js → SkillsSettingsPage-BViFgckG.js} +1 -1
  99. package/static/assets/SourceInput-CAFKTHw-.js +1 -0
  100. package/static/assets/{TagInput-D_SdcypZ.js → TagInput-C6lI-ePr.js} +1 -1
  101. package/static/assets/TaskDetailPage-DpbRHnW_.js +16 -0
  102. package/static/assets/TaskEditPage-DssRbW0h.js +1 -0
  103. package/static/assets/TasksPage-CD_eo0Bj.js +17 -0
  104. package/static/assets/TerminalPage-BG_wlccr.js +1 -0
  105. package/static/assets/TerminalSessionPage-CsK-LznK.js +8 -0
  106. package/static/assets/UserPreferencesPage-CWUq3efu.js +1 -0
  107. package/static/assets/UserSettingsPage-CduI_MGS.js +1 -0
  108. package/static/assets/UtilitiesPage-BAxokhLh.js +1 -0
  109. package/static/assets/{alert-BD5jo3SI.js → alert-BXsc6_qu.js} +1 -1
  110. package/static/assets/{arrow-down-BxcoVp6S.js → arrow-down-DmW_3gE8.js} +1 -1
  111. package/static/assets/{arrow-left-CdM_IPng.js → arrow-left-1S-835kP.js} +1 -1
  112. package/static/assets/{arrow-up-BOJ6ob9X.js → arrow-up-BYism_o1.js} +1 -1
  113. package/static/assets/arrow-up-down-Dw3J0a4i.js +6 -0
  114. package/static/assets/{badge-DEiQk9C9.js → badge-BUEY53dV.js} +1 -1
  115. package/static/assets/{browser-modal-Dp1eMxt6.js → browser-modal-DCNdI4NT.js} +2 -2
  116. package/static/assets/{card-BCFxXzRk.js → card-BcPlIAH5.js} +1 -1
  117. package/static/assets/{chevron-left-C25izNzZ.js → chevron-left-FMmNe7yP.js} +1 -1
  118. package/static/assets/{plus-iamYJu5V.js → chevron-up-CqM3won3.js} +2 -2
  119. package/static/assets/{chevrons-up-DqbWMOjv.js → chevrons-up-DTvCkIHc.js} +1 -1
  120. package/static/assets/{circle-alert-CMRMPnbY.js → circle-alert-dseM-Ib7.js} +1 -1
  121. package/static/assets/{circle-check-big-NI18oHuP.js → circle-check-big-jKg34xC-.js} +1 -1
  122. package/static/assets/{circle-check-D5wZZPvj.js → circle-check-eyo6pBP1.js} +1 -1
  123. package/static/assets/{circle-play-BhVU869u.js → circle-play-BrY_lNiH.js} +1 -1
  124. package/static/assets/{circle-x-BXDB-G_q.js → circle-x-uqmzEce1.js} +1 -1
  125. package/static/assets/{clipboard-DC2xmNVx.js → clipboard-tzPFoieb.js} +1 -1
  126. package/static/assets/{clock-CeCp7Pz1.js → clock-Bjc06QBM.js} +1 -1
  127. package/static/assets/code-DrYqPukx.js +6 -0
  128. package/static/assets/{download-ZF_XbTIA.js → download-Bg__QCLT.js} +1 -1
  129. package/static/assets/{external-link-CYBz87-P.js → external-link-CNDy2UUo.js} +1 -1
  130. package/static/assets/{eye-BT8MAvKY.js → eye-DLFBnC8t.js} +1 -1
  131. package/static/assets/{folder-git-2-BE9AIPnj.js → folder-git-2-DUqd0WRi.js} +1 -1
  132. package/static/assets/index-CHdBxVyk.css +2 -0
  133. package/static/assets/index-DFcWlnzl.js +487 -0
  134. package/static/assets/{info-DunFSp-x.js → info-D6jxZC5X.js} +1 -1
  135. package/static/assets/kiro-CX1mOsRO.js +17 -0
  136. package/static/assets/{label-vYhfrPMD.js → label-DBuh-ke5.js} +1 -1
  137. package/static/assets/{markdown-editor-BzZ8tCto.js → markdown-editor-B4YNQFT2.js} +1 -1
  138. package/static/assets/message-square-B5RWz_ff.js +6 -0
  139. package/static/assets/paperclip-4A_3MaPx.js +6 -0
  140. package/static/assets/{pause-BHonpdnw.js → pause-BzhKXHtR.js} +1 -1
  141. package/static/assets/{play-CCo7tau2.js → play-CHIf-Rcz.js} +1 -1
  142. package/static/assets/{radio-group-Db-pBuyW.js → radio-group-C1ct-VsJ.js} +1 -1
  143. package/static/assets/{refresh-cw-Bg7vQzOw.js → refresh-cw-B3OwrDUf.js} +1 -1
  144. package/static/assets/{search-CH2zaibZ.js → search-Cq1ksEdp.js} +1 -1
  145. package/static/assets/select-44mcS2_G.js +1 -0
  146. package/static/assets/{status-utils-BDOyevaX.js → status-utils-CDkPeVfP.js} +1 -1
  147. package/static/assets/{switch-CH-VOgPo.js → switch-CIwjYvCt.js} +1 -1
  148. package/static/assets/{tabs-XeRAjZYR.js → tabs-DTV6Su-h.js} +1 -1
  149. package/static/assets/{tag-CRP5nL5-.js → tag-p6yeowCW.js} +1 -1
  150. package/static/assets/{terminal-preview-DMJMuORo.js → terminal-preview-DN38x9Jm.js} +1 -1
  151. package/static/assets/use-terminal-BXJqOeJe.js +1 -0
  152. package/static/assets/video-BH5ChaoS.js +36 -0
  153. package/static/index.html +2 -2
  154. package/static/assets/ApiKeysSettingsPage-Chw9PNL5.js +0 -2
  155. package/static/assets/CodePage-CrokcH-S.js +0 -2
  156. package/static/assets/DashboardPage-BaSQQ8Nv.js +0 -41
  157. package/static/assets/GitSettingsPage-tKBXYAFm.js +0 -6
  158. package/static/assets/IdentityPage-D2yBjeYn.js +0 -11
  159. package/static/assets/IntegrationsSettingsPage-Bx8-0Ig4.js +0 -1
  160. package/static/assets/JobDetailPage-BQmTHled.js +0 -1
  161. package/static/assets/KnowledgeDetailPage-QMU2bC3L.js +0 -1
  162. package/static/assets/KnowledgeEditPage-DbMJVcLc.js +0 -1
  163. package/static/assets/KnowledgePage-aU1GxZSZ.js +0 -8
  164. package/static/assets/McpSettingsPage-C3WxFwRB.js +0 -1
  165. package/static/assets/NewKnowledgePage-Cbiswrw_.js +0 -9
  166. package/static/assets/NewProposalPage-B_sDMBTK.js +0 -90
  167. package/static/assets/ProjectEditPage-BznWiBBc.js +0 -11
  168. package/static/assets/PromptsSettingsPage-CY0-870a.js +0 -1
  169. package/static/assets/ProposalDetailPage-K4iMXHEg.js +0 -1
  170. package/static/assets/ProposalEditPage-jZOtCMqP.js +0 -1
  171. package/static/assets/ProposalsPage-C7n4-G05.js +0 -17
  172. package/static/assets/ResourcesPage-vB5-XkUv.js +0 -71
  173. package/static/assets/RoleEditPage-Cu7ZB3yj.js +0 -13
  174. package/static/assets/SchedulePage-Bkkf2wA0.js +0 -4
  175. package/static/assets/SkillDetailPage-5sDxf3Of.js +0 -1
  176. package/static/assets/SkillsPage-D2G7EfK8.js +0 -8
  177. package/static/assets/SourceInput-DlC0zwva.js +0 -1
  178. package/static/assets/TerminalPage--KZ7azvP.js +0 -1
  179. package/static/assets/TerminalSessionPage-ClvxK9ia.js +0 -13
  180. package/static/assets/UserPreferencesPage-CheOH7jZ.js +0 -1
  181. package/static/assets/UserSettingsPage-C8STDvfQ.js +0 -1
  182. package/static/assets/UtilitiesPage-9rTxR2md.js +0 -1
  183. package/static/assets/calendar-Cx5r9R7A.js +0 -6
  184. package/static/assets/droid-DqWsM2dp.js +0 -17
  185. package/static/assets/index-DVTgTsDa.css +0 -2
  186. package/static/assets/index-hqVgTgRB.js +0 -462
  187. package/static/assets/use-terminal-DuGZuvd2.js +0 -1
  188. package/static/assets/zap-BlzMp7dY.js +0 -6
@@ -0,0 +1 @@
1
+ import{a as A,r as i,A as N,j as e,bv as D,B as v,bw as T,t as w,k,bx as R,n as L}from"./index-DFcWlnzl.js";import{C as y,a as C}from"./card-BcPlIAH5.js";import{B as j}from"./badge-BUEY53dV.js";import{M as B}from"./MailProcessingModal-DIeSQBoR.js";import{R as U}from"./refresh-cw-B3OwrDUf.js";import{P as M}from"./paperclip-4A_3MaPx.js";import{C as $}from"./chevron-up-CqM3won3.js";import{C as F}from"./clock-Bjc06QBM.js";function O(a){if(!a)return"";try{const s=new Date(a),x=new Date().getTime()-s.getTime(),o=Math.floor(x/(1e3*60*60*24));return o===0?s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):o<7?s.toLocaleDateString("en-US",{weekday:"short",hour:"numeric",minute:"2-digit"}):s.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return a}}function z(a){const s=a.match(/^([^<]+)\s*</);return s?s[1].trim():a.split("@")[0]||a}function _(a,s=120){const c=a.replace(/\n+/g," ").trim();return c.length<=s?c:c.slice(0,s)+"..."}function J({startedAt:a}){const[s,c]=i.useState("");return i.useEffect(()=>{function x(){const f=new Date(a).getTime(),h=Date.now(),m=Math.floor((h-f)/1e3);if(m<60)c(`${m}s`);else{const p=Math.floor(m/60),d=m%60;c(`${p}m ${d}s`)}}x();const o=setInterval(x,1e3);return()=>clearInterval(o)},[a]),e.jsxs("span",{className:"flex items-center gap-1 text-blue-600 dark:text-blue-400",children:[e.jsx(F,{className:"h-3 w-3"}),s]})}function Y(){const{toast:a}=A(),[s,c]=i.useState([]),[x,o]=i.useState(!0),[f,h]=i.useState(null),[m,p]=i.useState(null),[d,g]=i.useState(null),l=i.useRef(null),u=i.useCallback(async(t=!1)=>{try{t||o(!0);const r=await(await fetch(`${N}/api/v1/mail/inbox`)).json();r.success&&c(r.data.messages||[])}catch(n){console.error("Failed to fetch inbox:",n)}finally{t||o(!1)}},[]);i.useEffect(()=>{u()},[u]),i.useEffect(()=>{const t=s.some(n=>n.processing);return t&&!l.current?l.current=setInterval(()=>u(!0),5e3):!t&&l.current&&(clearInterval(l.current),l.current=null),()=>{l.current&&(clearInterval(l.current),l.current=null)}},[s,u]);const S=async(t,n)=>{n.stopPropagation(),p(t);try{const b=await(await fetch(`${N}/api/v1/mail/${t}/status`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"read"})})).json();b.success?(c(P=>P.filter(E=>E.id!==t)),f===t&&h(null),a({title:"Marked as read",description:"Email moved to Read folder."})):a({title:"Error",description:b.error||"Failed to mark as read",variant:"destructive"})}catch{a({title:"Error",description:"Failed to mark as read",variant:"destructive"})}finally{p(null)}},I=d?s.find(t=>t.id===d):null;return x?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold",children:"Inbox"})}),[1,2,3].map(t=>e.jsx(D,{className:"h-20 w-full"},t))]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Inbox"}),s.length>0&&e.jsx(j,{variant:"secondary",children:s.length})]}),e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>u(),children:e.jsx(U,{className:"h-4 w-4"})})]}),s.length===0?e.jsx(y,{children:e.jsxs(C,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(T,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No emails in inbox"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Incoming emails will appear here when received."})]})}):e.jsx("div",{className:"space-y-2",children:s.map(t=>{const n=f===t.id;return e.jsx(y,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>h(n?null:t.id),children:e.jsxs(C,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-semibold text-sm truncate",children:z(t.from)}),t.processing&&!t.action&&e.jsxs(j,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-blue-300 text-blue-600 dark:border-blue-700 dark:text-blue-400 gap-1",children:[e.jsx(w,{className:"h-2.5 w-2.5 animate-spin"}),"Processing"]}),!t.processing&&t.action&&e.jsxs(j,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-green-300 text-green-600 dark:border-green-700 dark:text-green-400 gap-1",children:[e.jsx(k,{className:"h-2.5 w-2.5"}),"Processed"]}),t.attachments.length>0&&e.jsx(M,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:O(t.receivedAt)})]}),e.jsx("p",{className:"text-sm font-medium truncate",children:t.subject}),!n&&t.content&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:_(t.content)})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:r=>S(t.id,r),disabled:m===t.id,title:"Mark as read",children:e.jsx(R,{className:"h-4 w-4"})}),n?e.jsx($,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(L,{className:"h-4 w-4 text-muted-foreground"})]})]}),n&&e.jsxs("div",{className:"mt-4 pt-4 border-t space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"From:"})," ",t.from]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"To:"})," ",t.to.join(", ")]}),t.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"CC:"})," ",t.cc.join(", ")]})]}),t.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:t.attachments.map(r=>e.jsxs(j,{variant:"outline",className:"text-xs",children:[e.jsx(M,{className:"h-3 w-3 mr-1"}),r.filename]},r.id))}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3",children:t.content||e.jsx("span",{className:"text-muted-foreground italic",children:"No content"})}),t.processing&&!t.action&&e.jsx("button",{type:"button",className:"w-full text-left bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 rounded-lg p-3 text-sm cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-950/50 transition-colors",onClick:r=>{r.stopPropagation(),g(t.id)},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-blue-700 dark:text-blue-400 font-medium text-xs",children:[e.jsx(w,{className:"h-3.5 w-3.5 animate-spin"}),"Processing email..."]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.processingStartedAt&&e.jsx(J,{startedAt:t.processingStartedAt}),e.jsx("span",{className:"text-blue-500 dark:text-blue-400 text-[10px] font-medium",children:"View details"})]})]})}),t.action&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium text-xs mb-1",children:[e.jsx(k,{className:"h-3.5 w-3.5"}),"Agent Action"]}),e.jsx("p",{className:"text-green-900 dark:text-green-200",children:t.action})]})]})]})},t.id)})}),d&&e.jsx(B,{open:!!d,onOpenChange:t=>{t||g(null)},mailId:d,subject:I?.subject||"",onStopped:()=>u(!0)})]})}export{Y as default};
@@ -0,0 +1,6 @@
1
+ import{c as D,a as M,r as t,A as k,j as e,D as R,b as T,d as $,f as C,k as P,g as I,B as S,by as B,T as L}from"./index-DFcWlnzl.js";import{B as x}from"./badge-BUEY53dV.js";import{C as F}from"./clock-Bjc06QBM.js";import{R as _}from"./refresh-cw-B3OwrDUf.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 z=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],y=D("triangle-alert",z);function E(i){const p=new Date(i).getTime(),o=Date.now(),c=Math.floor((o-p)/1e3);if(c<60)return`${c}s`;const l=Math.floor(c/60),d=c%60;if(l<60)return`${l}m ${d}s`;const s=Math.floor(l/60),f=l%60;return`${s}h ${f}m`}function V({open:i,onOpenChange:p,mailId:o,subject:c,onStopped:l}){const{toast:d}=M(),[s,f]=t.useState(null),[h,j]=t.useState(!1),[u,v]=t.useState(!1),[b,g]=t.useState(""),N=t.useRef(null),a=t.useRef(null),m=t.useCallback(async()=>{try{const r=await(await fetch(`${k}/api/v1/mail/${o}/processing`)).json();r.success&&f(r.data)}catch(n){console.error("[mail] Failed to fetch processing status:",n)}},[o]);t.useEffect(()=>{if(!i){a.current&&(clearInterval(a.current),a.current=null);return}return j(!0),m().finally(()=>j(!1)),a.current=setInterval(m,4e3),()=>{a.current&&(clearInterval(a.current),a.current=null)}},[i,m]),t.useEffect(()=>{const n=s?.active?.startedAt||s?.processingStartedAt;if(!n||!s?.processing){g("");return}g(E(n));const r=setInterval(()=>{g(E(n))},1e3);return()=>clearInterval(r)},[s?.active?.startedAt,s?.processingStartedAt,s?.processing]),t.useEffect(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[s?.log]),t.useEffect(()=>{s&&!s.processing&&!u&&a.current&&(clearInterval(a.current),a.current=null)},[s,u]);const A=async()=>{v(!0);try{const r=await(await fetch(`${k}/api/v1/mail/${o}/processing/stop`,{method:"POST"})).json();r.success?(d({title:"Processing stopped",description:r.message}),setTimeout(()=>{m(),l?.()},1500)):d({title:"Error",description:r.error||"Failed to stop processing",variant:"destructive"})}catch{d({title:"Error",description:"Failed to stop processing",variant:"destructive"})}finally{v(!1)}},w=s?.processing&&!s?.active;return e.jsx(R,{open:i,onOpenChange:p,children:e.jsxs(T,{className:"max-w-2xl max-h-[80vh] flex flex-col",children:[e.jsxs($,{children:[e.jsxs(C,{className:"flex items-center gap-2",children:[e.jsx(P,{className:"h-5 w-5"}),"Mail Processing"]}),e.jsx(I,{className:"truncate",children:c})]}),e.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s?.processing?w?e.jsxs(x,{variant:"outline",className:"text-amber-600 border-amber-300 dark:text-amber-400 dark:border-amber-700",children:[e.jsx(y,{className:"h-3 w-3 mr-1"}),"Stuck"]}):e.jsxs(x,{variant:"outline",className:"text-blue-600 border-blue-300 dark:text-blue-400 dark:border-blue-700",children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500 animate-pulse mr-1.5"}),"Running"]}):s?e.jsx(x,{variant:"outline",className:"text-muted-foreground",children:"Completed"}):null,s?.active?.agent&&e.jsx(x,{variant:"secondary",className:"text-xs",children:s.active.agent}),b&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(F,{className:"h-3 w-3"}),b]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:()=>m(),disabled:h,title:"Refresh",children:e.jsx(_,{className:`h-3.5 w-3.5 ${h?"animate-spin":""}`})}),s?.processing&&e.jsxs(S,{variant:"destructive",size:"sm",onClick:A,disabled:u,children:[e.jsx(B,{className:"h-3.5 w-3.5 mr-1.5"}),u?"Stopping...":"Stop"]})]})]}),w&&e.jsxs("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-3 text-sm text-amber-800 dark:text-amber-300",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-xs mb-1",children:[e.jsx(y,{className:"h-3.5 w-3.5"}),"Processing appears stuck"]}),e.jsx("p",{className:"text-xs",children:"The processing flag is set but no active agent process was found on the server. This can happen if the agent crashed or the server restarted. You can stop processing to clear the flag and try again."})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-2",children:[e.jsx(L,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-medium",children:"Agent Log"}),s?.logPath&&e.jsx("span",{className:"text-[10px] opacity-60 truncate ml-1",children:s.logPath})]}),e.jsx("div",{className:"flex-1 min-h-0 max-h-[40vh] overflow-auto rounded-md border bg-muted/30 p-3 font-mono text-xs leading-relaxed",children:s?.log?e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground/80",children:s.log}),e.jsx("div",{ref:N})]}):h?e.jsx("span",{className:"text-muted-foreground italic",children:"Loading logs..."}):e.jsx("span",{className:"text-muted-foreground italic",children:"No log output available yet."})})]})]})]})})}export{V as M};
@@ -0,0 +1 @@
1
+ import{a as T,r as l,A as v,j as e,bv as A,B as w,bx as R,t as k,k as C,bw as L,E as $,n as B}from"./index-DFcWlnzl.js";import{C as E,a as M}from"./card-BcPlIAH5.js";import{B as g}from"./badge-BUEY53dV.js";import{M as F}from"./MailProcessingModal-DIeSQBoR.js";import{R as U}from"./refresh-cw-B3OwrDUf.js";import{P as S}from"./paperclip-4A_3MaPx.js";import{C as z}from"./chevron-up-CqM3won3.js";import{C as O}from"./clock-Bjc06QBM.js";function _(a){if(!a)return"";try{const s=new Date(a),m=new Date().getTime()-s.getTime(),o=Math.floor(m/(1e3*60*60*24));return o===0?s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):o<7?s.toLocaleDateString("en-US",{weekday:"short",hour:"numeric",minute:"2-digit"}):s.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return a}}function J(a){const s=a.match(/^([^<]+)\s*</);return s?s[1].trim():a.split("@")[0]||a}function V(a,s=120){const i=a.replace(/\n+/g," ").trim();return i.length<=s?i:i.slice(0,s)+"..."}function q({startedAt:a}){const[s,i]=l.useState("");return l.useEffect(()=>{function m(){const f=new Date(a).getTime(),p=Date.now(),d=Math.floor((p-f)/1e3);if(d<60)i(`${d}s`);else{const u=Math.floor(d/60),x=d%60;i(`${u}m ${x}s`)}}m();const o=setInterval(m,1e3);return()=>clearInterval(o)},[a]),e.jsxs("span",{className:"flex items-center gap-1 text-blue-600 dark:text-blue-400",children:[e.jsx(O,{className:"h-3 w-3"}),s]})}function ee(){const{toast:a}=T(),[s,i]=l.useState([]),[m,o]=l.useState(!0),[f,p]=l.useState(null),[d,u]=l.useState(null),[x,y]=l.useState(null),c=l.useRef(null),h=l.useCallback(async(t=!1)=>{try{t||o(!0);const n=await(await fetch(`${v}/api/v1/mail/read`)).json();n.success&&i(n.data.messages||[])}catch(r){console.error("Failed to fetch read mail:",r)}finally{t||o(!1)}},[]);l.useEffect(()=>{h()},[h]),l.useEffect(()=>{const t=s.some(r=>r.processing);return t&&!c.current?c.current=setInterval(()=>h(!0),5e3):!t&&c.current&&(clearInterval(c.current),c.current=null),()=>{c.current&&(clearInterval(c.current),c.current=null)}},[s,h]);const I=async(t,r)=>{r.stopPropagation(),u(t);try{const j=await(await fetch(`${v}/api/v1/mail/${t}/status`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"unread"})})).json();j.success?(i(b=>b.filter(N=>N.id!==t)),f===t&&p(null),a({title:"Moved to Inbox",description:"Email moved back to Inbox."})):a({title:"Error",description:j.error||"Failed to move email",variant:"destructive"})}catch{a({title:"Error",description:"Failed to move email",variant:"destructive"})}finally{u(null)}},P=async(t,r)=>{r.stopPropagation(),u(t);try{const j=await(await fetch(`${v}/api/v1/mail/read/${t}`,{method:"DELETE"})).json();j.success?(i(b=>b.filter(N=>N.id!==t)),f===t&&p(null),a({title:"Deleted",description:"Email has been deleted."})):a({title:"Error",description:j.error||"Failed to delete email",variant:"destructive"})}catch{a({title:"Error",description:"Failed to delete email",variant:"destructive"})}finally{u(null)}},D=x?s.find(t=>t.id===x):null;return m?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold",children:"Read"})}),[1,2,3].map(t=>e.jsx(A,{className:"h-20 w-full"},t))]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Read"}),s.length>0&&e.jsx(g,{variant:"secondary",children:s.length})]}),e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>h(),children:e.jsx(U,{className:"h-4 w-4"})})]}),s.length===0?e.jsx(E,{children:e.jsxs(M,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(R,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No read emails"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Emails marked as read will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:s.map(t=>{const r=f===t.id;return e.jsx(E,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>p(r?null:t.id),children:e.jsxs(M,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground truncate",children:J(t.from)}),t.processing&&!t.action&&e.jsxs(g,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-blue-300 text-blue-600 dark:border-blue-700 dark:text-blue-400 gap-1",children:[e.jsx(k,{className:"h-2.5 w-2.5 animate-spin"}),"Processing"]}),!t.processing&&t.action&&e.jsxs(g,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-green-300 text-green-600 dark:border-green-700 dark:text-green-400 gap-1",children:[e.jsx(C,{className:"h-2.5 w-2.5"}),"Processed"]}),t.attachments.length>0&&e.jsx(S,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:_(t.receivedAt)})]}),e.jsx("p",{className:"text-sm truncate",children:t.subject}),!r&&t.content&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:V(t.content)})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:n=>I(t.id,n),disabled:d===t.id,title:"Move to Inbox",children:e.jsx(L,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"sm",onClick:n=>P(t.id,n),disabled:d===t.id,title:"Delete",className:"text-destructive hover:text-destructive",children:e.jsx($,{className:"h-4 w-4"})}),r?e.jsx(z,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(B,{className:"h-4 w-4 text-muted-foreground"})]})]}),r&&e.jsxs("div",{className:"mt-4 pt-4 border-t space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"From:"})," ",t.from]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"To:"})," ",t.to.join(", ")]}),t.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"CC:"})," ",t.cc.join(", ")]})]}),t.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:t.attachments.map(n=>e.jsxs(g,{variant:"outline",className:"text-xs",children:[e.jsx(S,{className:"h-3 w-3 mr-1"}),n.filename]},n.id))}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3",children:t.content||e.jsx("span",{className:"text-muted-foreground italic",children:"No content"})}),t.processing&&!t.action&&e.jsx("button",{type:"button",className:"w-full text-left bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 rounded-lg p-3 text-sm cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-950/50 transition-colors",onClick:n=>{n.stopPropagation(),y(t.id)},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-blue-700 dark:text-blue-400 font-medium text-xs",children:[e.jsx(k,{className:"h-3.5 w-3.5 animate-spin"}),"Processing email..."]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.processingStartedAt&&e.jsx(q,{startedAt:t.processingStartedAt}),e.jsx("span",{className:"text-blue-500 dark:text-blue-400 text-[10px] font-medium",children:"View details"})]})]})}),t.action&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium text-xs mb-1",children:[e.jsx(C,{className:"h-3.5 w-3.5"}),"Agent Action"]}),e.jsx("p",{className:"text-green-900 dark:text-green-200",children:t.action})]})]})]})},t.id)})}),x&&e.jsx(F,{open:!!x,onOpenChange:t=>{t||y(null)},mailId:x,subject:D?.subject||"",onStopped:()=>h(!0)})]})}export{ee as default};
@@ -0,0 +1 @@
1
+ import{r as c,A as p,j as e,bv as j,B as N,bp as g,n as w}from"./index-DFcWlnzl.js";import{C as m,a as x}from"./card-BcPlIAH5.js";import{B as h}from"./badge-BUEY53dV.js";import{R as v}from"./refresh-cw-B3OwrDUf.js";import{P as u}from"./paperclip-4A_3MaPx.js";import{C as y}from"./chevron-up-CqM3won3.js";function b(t){if(!t)return"";try{const a=new Date(t),i=new Date().getTime()-a.getTime(),l=Math.floor(i/(1e3*60*60*24));return l===0?a.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):l<7?a.toLocaleDateString("en-US",{weekday:"short",hour:"numeric",minute:"2-digit"}):a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return t}}function C(t,a=120){const r=t.replace(/\n+/g," ").trim();return r.length<=a?r:r.slice(0,a)+"..."}function P(){const[t,a]=c.useState([]),[r,i]=c.useState(!0),[l,f]=c.useState(null),o=c.useCallback(async()=>{try{i(!0);const n=await(await fetch(`${p}/api/v1/mail/sent`)).json();n.success&&a(n.data.messages||[])}catch(s){console.error("Failed to fetch sent mail:",s)}finally{i(!1)}},[]);return c.useEffect(()=>{o()},[o]),r?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold",children:"Sent"})}),[1,2,3].map(s=>e.jsx(j,{className:"h-20 w-full"},s))]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sent"}),t.length>0&&e.jsx(h,{variant:"secondary",children:t.length})]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:o,children:e.jsx(v,{className:"h-4 w-4"})})]}),t.length===0?e.jsx(m,{children:e.jsxs(x,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(g,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No sent emails"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Replies and sent emails will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:t.map(s=>{const n=l===s.id;return e.jsx(m,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>f(n?null:s.id),children:e.jsxs(x,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"text-sm text-muted-foreground truncate",children:["To: ",s.to.join(", ")]}),s.attachments.length>0&&e.jsx(u,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:b(s.receivedAt)})]}),e.jsx("p",{className:"text-sm truncate",children:s.subject}),!n&&s.content&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:C(s.content)})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:n?e.jsx(y,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(w,{className:"h-4 w-4 text-muted-foreground"})})]}),n&&e.jsxs("div",{className:"mt-4 pt-4 border-t space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"From:"})," ",s.from]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"To:"})," ",s.to.join(", ")]}),s.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"CC:"})," ",s.cc.join(", ")]})]}),s.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:s.attachments.map(d=>e.jsxs(h,{variant:"outline",className:"text-xs",children:[e.jsx(u,{className:"h-3 w-3 mr-1"}),d.filename]},d.id))}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3",children:s.content||e.jsx("span",{className:"text-muted-foreground italic",children:"No content"})})]})]})},s.id)})})]})}export{P as default};
@@ -0,0 +1 @@
1
+ import{j as e,S as ne,_ as k,r as b,b0 as q,v as f,a$ as ie,aZ as ae,B as C,P as B,I as u,o as R,Y as oe,E as le,F as ce,l as de}from"./index-DFcWlnzl.js";import{C as L,b as T,c as O,d as $,a as U}from"./card-BcPlIAH5.js";import{L as h}from"./label-DBuh-ke5.js";import{B as P}from"./badge-BUEY53dV.js";import{S as I}from"./switch-CIwjYvCt.js";import{A as z,a as Y}from"./alert-BXsc6_qu.js";import{R as me,L as he}from"./browser-modal-DCNdI4NT.js";import{R as xe}from"./registry-ANRa5WBi.js";import{C as J}from"./circle-alert-dseM-Ib7.js";import{C as ve}from"./circle-check-big-jKg34xC-.js";import"./search-Cq1ksEdp.js";function K(t){if(t){if(Array.isArray(t)){const n=t.map(l=>{if(typeof l=="string")return l.trim();if(typeof l=="number")return`${l}`}).filter(l=>typeof l=="string"&&l.length>0);return n.length>0?n:void 0}if(typeof t=="string"){const n=t.split(",").map(l=>l.trim()).filter(l=>l.length>0);return n.length>0?n:void 0}}}function G(t,n){const l=t.name||n.name,x=n.description||t.description||"",a={registryId:t.id,registryEndpoint:t.endpoint,registrySource:xe,author:t.author||n.author};(n.version||t.version)&&(a.version=n.version||t.version);const d=K(n.tags)||K(t.tags);d&&(a.tags=d),n.capabilities&&Array.isArray(n.capabilities)&&(a.capabilities=n.capabilities),n.requirements&&typeof n.requirements=="object"&&(a.requirements=n.requirements),n.links&&typeof n.links=="object"&&(a.links=n.links),n.metadata&&typeof n.metadata=="object"&&(a.mcpMetadata=n.metadata);for(const[i,p]of Object.entries(a))p==null&&delete a[i];return{name:l,command:n.configuration.command,args:n.configuration.args,url:n.configuration.url,env:n.configuration.env,enabled:!0,description:x,metadata:Object.keys(a).length>0?a:void 0}}async function pe(t){const n=t.startsWith("http")?t:`https://registry.coconut.dev${t}`,l=await fetch(n,{headers:{Accept:"application/json","User-Agent":"coconut-frontend"}});if(!l.ok)throw new Error(`Failed to fetch MCP server detail: ${l.status}`);return l.json()}function ue({open:t,onOpenChange:n,onImport:l}){return e.jsx(me,{open:t,onOpenChange:n,categoryId:"mcp-servers",title:"Coconut Registry – MCP Servers",confirmLabel:"Add Server",getDetail:x=>pe(x.endpoint),renderPreview:(x,a)=>{if(!a)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select an MCP server to preview"});const d=G(x,a),i=d.metadata??{},p=typeof i.version=="string"?i.version:void 0,y=Array.isArray(x.tags)?x.tags:[],w=Array.isArray(i.capabilities)?i.capabilities.filter(j=>typeof j=="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:x.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.description})]}),p&&e.jsxs(P,{variant:"outline",children:["v",p]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:x.id})]}),y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(j=>e.jsx(P,{variant:"secondary",children:j},j))}),e.jsxs("div",{className:"space-y-2 rounded-md border p-3 bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Configuration"}),e.jsx(P,{variant:"outline",className:"text-xs",children:d.url?"HTTP":"stdio"})]}),e.jsxs("div",{className:"space-y-1 text-sm font-mono",children:[d.url?e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"URL:"})," ",e.jsx("span",{className:"text-foreground break-all",children:d.url})]}):e.jsxs(e.Fragment,{children:[d.command&&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)})]})]})]}),w.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:w.map(j=>e.jsx("li",{children:j},j))})]}),a.documentation&&e.jsxs("div",{className:"space-y-3",children:[a.documentation.overview&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Overview"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.overview})]}),a.documentation.installation&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Installation"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.installation})]}),a.documentation.usage&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Usage"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.usage})]}),a.documentation.examples&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Examples"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.examples})]})]})]})})})})},onConfirm:async(x,a)=>{const d=G(x,a);await l({summary:x,detail:a,payload:d})}})}function Ae(){const[t,n]=b.useState({}),[l,x]=b.useState(!0),[a,d]=b.useState(!1),[i,p]=b.useState({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0}),[y,w]=b.useState(!1),[j,M]=b.useState(null),[o,N]=b.useState({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0}),[V,_]=b.useState(!1);b.useEffect(()=>{D()},[]);const D=async()=>{try{x(!0);const s=await q("/api/v1/mcp/raw-config");n(s||{})}catch(s){console.error("Failed to load MCP config:",s),f({title:"Error",description:"Failed to load MCP configuration",variant:"destructive"})}finally{x(!1)}},E=async s=>{try{d(!0),await q("/api/v1/mcp/raw-config",{method:"PUT",body:JSON.stringify(s)}),n(s),f({title:"Success",description:"MCP configuration saved successfully"})}catch(r){console.error("Failed to save MCP config:",r),f({title:"Error",description:"Failed to save MCP configuration",variant:"destructive"})}finally{d(!1)}},W=()=>{if(!i.name){f({title:"Error",description:"Server name is required",variant:"destructive"});return}const s=i.command.trim().length>0,r=i.url.trim().length>0;if(!s&&!r){f({title:"Error",description:"Either Command (for stdio) or URL (for HTTP) is required",variant:"destructive"});return}if(s&&r){f({title:"Error",description:"Provide either Command or URL, not both",variant:"destructive"});return}const c={name:i.name,enabled:i.enabled,description:i.description||void 0};if(s?(c.type="stdio",c.command=i.command,i.args.trim()&&(c.args=i.args.split(" ").filter(g=>g.trim()))):(c.type="http",c.url=i.url),i.env.trim())try{c.env=JSON.parse(i.env)}catch{f({title:"Error",description:"Invalid JSON format for environment variables",variant:"destructive"});return}const v={...t,mcpServers:{...t.mcpServers,[i.name]:c}};E(v),p({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0}),w(!1)},Z=(s,r)=>{const c={...t,mcpServers:{...t.mcpServers,[s]:{...t.mcpServers[s],enabled:r}}};E(c)},Q=s=>{const{[s]:r,...c}=t.mcpServers||{},v={...t,mcpServers:c};E(v)},X=s=>{const r=t.mcpServers?.[s];r&&(N({name:r.name||s,command:r.command||"",args:r.args?.join(" ")||"",url:r.url||"",env:r.env?JSON.stringify(r.env,null,2):"",description:r.description||"",enabled:r.enabled!==!1}),M(s))},ee=s=>{const r=o.command.trim().length>0,c=o.url.trim().length>0;if(!r&&!c){f({title:"Error",description:"Either Command (for stdio) or URL (for HTTP) is required",variant:"destructive"});return}if(r&&c){f({title:"Error",description:"Provide either Command or URL, not both",variant:"destructive"});return}const v={name:o.name,enabled:o.enabled,description:o.description||void 0};if(r?(v.type="stdio",v.command=o.command,o.args.trim()&&(v.args=o.args.split(" ").filter(A=>A.trim()))):(v.type="http",v.url=o.url),o.env.trim())try{v.env=JSON.parse(o.env)}catch{f({title:"Error",description:"Invalid JSON format for environment variables",variant:"destructive"});return}const{[s]:g,...m}=t.mcpServers||{},S={...t,mcpServers:{...m,[s]:v}};E(S),M(null)},se=()=>{M(null),N({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0})},F=s=>{const r={...t,globalSettings:{...t.globalSettings,...s}};E(r)},re=async s=>{const{payload:r}=s;let c=r.name.toLowerCase().replace(/\s+/g,"-");const v=t.mcpServers||{};let g=c,m=1;for(;v[g];)g=`${c}-${m}`,m++;const S={name:g,enabled:r.enabled!==!1,description:r.description,env:r.env};r.url?(S.type="http",S.url=r.url):r.command&&(S.type="stdio",S.command=r.command,S.args=r.args);const A={...t,mcpServers:{...t.mcpServers,[g]:S}};await E(A);const te=r.url?"HTTP":"stdio";f({title:"Success",description:`MCP server "${g}" (${te}) added from registry`})};if(l)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 H=t.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(ie,{}),Object.keys(H).length===0&&!y&&e.jsxs(z,{children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(Y,{children:"No MCP servers configured yet. Add your first server to get started."})]}),e.jsxs(L,{children:[e.jsx(T,{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(ae,{className:"h-5 w-5"}),"MCP Servers"]}),e.jsx($,{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(C,{size:"sm",variant:"outline",onClick:()=>_(!0),children:[e.jsx(he,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsxs(C,{size:"sm",onClick:()=>w(!y),variant:y?"outline":"default",children:[e.jsx(B,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:y?"Cancel":"Add Server"})]})]})]})}),e.jsxs(U,{children:[y&&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",{children:[e.jsx(h,{htmlFor:"serverName",children:"Server Name"}),e.jsx(u,{id:"serverName",value:i.name,onChange:s=>p({...i,name:s.target.value}),placeholder:"e.g., filesystem-server"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverCommand",children:"Command"}),e.jsx(u,{id:"serverCommand",value:i.command,onChange:s=>p({...i,command:s.target.value}),placeholder:"e.g., npx @modelcontextprotocol/server-filesystem"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverArgs",children:"Arguments (space-separated)"}),e.jsx(u,{id:"serverArgs",value:i.args,onChange:s=>p({...i,args:s.target.value}),placeholder:"e.g., /path/to/allowed/directory"})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverUrl",children:"URL"}),e.jsx(u,{id:"serverUrl",value:i.url,onChange:s=>p({...i,url:s.target.value}),placeholder:"e.g., https://mcp.example.com/api"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Provide either Command (for stdio) or URL (for HTTP/SSE), not both."})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverDescription",children:"Description (optional)"}),e.jsx(u,{id:"serverDescription",value:i.description,onChange:s=>p({...i,description:s.target.value}),placeholder:"Brief description of what this server provides"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverEnv",children:"Environment Variables (JSON)"}),e.jsx(R,{id:"serverEnv",value:i.env,onChange:s=>p({...i,env:s.target.value}),placeholder:'{"KEY": "value", "ANOTHER_KEY": "another_value"}',rows:3})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{id:"serverEnabled",checked:i.enabled,onCheckedChange:s=>p({...i,enabled:s})}),e.jsx(h,{htmlFor:"serverEnabled",children:"Enable server"})]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs(C,{onClick:W,disabled:a,children:[e.jsx(B,{className:"h-4 w-4 mr-2"}),"Add Server"]}),e.jsx(C,{variant:"outline",onClick:()=>w(!1),children:"Cancel"})]})]}),e.jsx("div",{className:"space-y-4",children:Object.entries(H).map(([s,r])=>{const c=r.enabled!==!1,v=r.name||s,g=j===s;return e.jsx("div",{className:"border rounded-lg",children:g?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",{children:[e.jsx(h,{htmlFor:`edit-name-${s}`,children:"Server Name"}),e.jsx(u,{id:`edit-name-${s}`,value:o.name,onChange:m=>N({...o,name:m.target.value}),placeholder:"e.g., filesystem-server"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-command-${s}`,children:"Command"}),e.jsx(u,{id:`edit-command-${s}`,value:o.command,onChange:m=>N({...o,command:m.target.value}),placeholder:"e.g., npx @modelcontextprotocol/server-filesystem"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-args-${s}`,children:"Arguments (space-separated)"}),e.jsx(u,{id:`edit-args-${s}`,value:o.args,onChange:m=>N({...o,args:m.target.value}),placeholder:"e.g., /path/to/allowed/directory"})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-url-${s}`,children:"URL"}),e.jsx(u,{id:`edit-url-${s}`,value:o.url,onChange:m=>N({...o,url:m.target.value}),placeholder:"e.g., https://mcp.example.com/api"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Provide either Command (for stdio) or URL (for HTTP/SSE), not both."})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-description-${s}`,children:"Description (optional)"}),e.jsx(u,{id:`edit-description-${s}`,value:o.description,onChange:m=>N({...o,description:m.target.value}),placeholder:"Brief description of what this server provides"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-env-${s}`,children:"Environment Variables (JSON)"}),e.jsx(R,{id:`edit-env-${s}`,value:o.env,onChange:m=>N({...o,env:m.target.value}),placeholder:'{"KEY": "value", "ANOTHER_KEY": "another_value"}',rows:3})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{id:`edit-enabled-${s}`,checked:o.enabled,onCheckedChange:m=>N({...o,enabled:m})}),e.jsx(h,{htmlFor:`edit-enabled-${s}`,children:"Enable server"})]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(C,{onClick:()=>ee(s),disabled:a,children:"Save Changes"}),e.jsx(C,{variant:"outline",onClick:se,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:[c?e.jsx(ve,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"}):e.jsx(J,{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:v}),e.jsx(P,{variant:c?"default":"secondary",className:"text-xs",children:c?"Enabled":"Disabled"}),e.jsx(P,{variant:"outline",className:"text-xs",children:r.url?"HTTP":"stdio"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:r.description||r.url||r.command}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:r.url?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"URL:"})," ",r.url]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"Command:"})," ",r.command," ",r.args?.join(" ")]})})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 shrink-0",children:[e.jsx(I,{checked:c,onCheckedChange:m=>Z(s,m),disabled:a}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(s),children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Q(s),disabled:a,children:e.jsx(le,{className:"h-4 w-4"})})]})]})})},s)})})]})]}),e.jsxs(L,{children:[e.jsxs(T,{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"}),"Configuration File"]}),e.jsxs($,{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(U,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"configJson",children:"Current Configuration (JSON)"}),e.jsx(R,{id:"configJson",value:JSON.stringify(t,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(z,{children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(Y,{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(L,{children:[e.jsxs(T,{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(de,{className:"h-5 w-5"}),"Global Settings"]}),e.jsx($,{children:"Configure global MCP behavior and connection settings."})]}),e.jsx(U,{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(h,{htmlFor:"timeout",children:"Connection Timeout (ms)"}),e.jsx(u,{id:"timeout",type:"number",value:t.globalSettings?.timeout||3e4,onChange:s=>F({timeout:parseInt(s.target.value)}),placeholder:"30000"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"retryAttempts",children:"Retry Attempts"}),e.jsx(u,{id:"retryAttempts",type:"number",value:t.globalSettings?.retryAttempts||3,onChange:s=>F({retryAttempts:parseInt(s.target.value)}),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(h,{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:t.globalSettings?.logLevel||"info",onChange:s=>F({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(C,{variant:"outline",onClick:D,disabled:l,children:"Reload Configuration"})}),e.jsx(ue,{open:V,onOpenChange:_,onImport:re})]})}export{Ae as default};
@@ -0,0 +1,9 @@
1
+ import{u as S,a as y,r,j as e,B as j,t as E,a0 as T,L,I as b,A as I}from"./index-DFcWlnzl.js";import{C as i,b as c,c as l,a as d}from"./card-BcPlIAH5.js";import{L as m}from"./label-DBuh-ke5.js";import{M as A}from"./markdown-editor-B4YNQFT2.js";import{T as B}from"./TagInput-C6lI-ePr.js";import{S as P}from"./SourceInput-CAFKTHw-.js";import{A as M}from"./arrow-left-1S-835kP.js";import"./badge-BUEY53dV.js";import"./external-link-CNDy2UUo.js";function J(){const g=S(),{toast:s}=y(),[u,h]=r.useState(!1),[a,f]=r.useState(""),[n,v]=r.useState(""),[x,w]=r.useState([]),[p,C]=r.useState([]),k=async()=>{if(!a.trim()){s({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!n.trim()){s({title:"Error",description:"Please provide content for the knowledge document",variant:"destructive"});return}h(!0);try{const o=await(await fetch(`${I}/api/v1/knowledge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:a.trim(),content:n.trim(),metadata:{tags:x,sources:p}})})).json();if(o.success){s({title:"Success",description:"Knowledge document created successfully"});const N=o.document.filename.replace(".md","");g(`/knowledge/${N}`)}else s({title:"Error",description:o.error||"Failed to create knowledge document",variant:"destructive"})}catch(t){console.error("Error creating document:",t),s({title:"Error",description:"Failed to create knowledge document",variant:"destructive"})}finally{h(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h1",{className:"text-3xl font-bold",children:"Create Knowledge Document"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{onClick:k,disabled:u||!a.trim()||!n.trim(),size:"sm",children:[u?e.jsx(E,{className:"w-4 h-4 animate-spin"}):e.jsx(T,{className:"w-4 h-4"}),"Create Document"]}),e.jsx(j,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(L,{to:"/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(M,{className:"h-4 w-4"})})})]})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Basic Information"})}),e.jsx(d,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(m,{htmlFor:"title",children:"Title *"}),e.jsx(b,{id:"title",value:a,onChange:t=>f(t.target.value),placeholder:"Enter document title...",className:"text-lg"})]})})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Metadata"})}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{children:"Tags"}),e.jsx(B,{tags:x,onChange:w,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(m,{children:"Sources"}),e.jsx(P,{sources:p,onChange:C})]})]})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Content *"})}),e.jsx(d,{children:e.jsx(A,{value:n,onChange:t=>v(t||""),placeholder:`Enter your knowledge content in Markdown...
2
+
3
+ You can use:
4
+ - **Bold text**
5
+ - *Italic text*
6
+ - # Headers
7
+ - - Lists
8
+ - [Links](https://example.com)
9
+ - Code blocks and more!`})})]})]})}export{J as default};
@@ -1 +1 @@
1
- import{u as z,a as H,r as a,j as e,B as b,L as w,p as J,I as P,w as W,ag as Y,A as M}from"./index-hqVgTgRB.js";import{C as G,b as K,c as Q,a as V}from"./card-BCFxXzRk.js";import{L as l}from"./label-vYhfrPMD.js";import{B as X}from"./badge-DEiQk9C9.js";import{c as Z}from"./clipboard-B9ndUJKl.js";import{A as O}from"./arrow-left-CdM_IPng.js";import{C as ee,a as se}from"./clipboard-DC2xmNVx.js";function de(){const E=z(),{toast:g}=H(),[n,j]=a.useState(!1),[v,d]=a.useState(null),[m,A]=a.useState(""),[u,L]=a.useState(""),[c,F]=a.useState("blue"),[x,C]=a.useState([]),[h,T]=a.useState(""),[y,p]=a.useState([]),[B,N]=a.useState(!0),[I,S]=a.useState(!1),D=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],$={blue:{bg:"#3b82f6",border:"#1e40af",text:"#ffffff"},green:{bg:"#22c55e",border:"#15803d",text:"#ffffff"},red:{bg:"#ef4444",border:"#b91c1c",text:"#ffffff"},emerald:{bg:"#10b981",border:"#047857",text:"#ffffff"},purple:{bg:"#a855f7",border:"#7e22ce",text:"#ffffff"},orange:{bg:"#f97316",border:"#c2410c",text:"#ffffff"},yellow:{bg:"#eab308",border:"#a16207",text:"#ffffff"},teal:{bg:"#14b8a6",border:"#0f766e",text:"#ffffff"},indigo:{bg:"#6366f1",border:"#4338ca",text:"#ffffff"},pink:{bg:"#ec4899",border:"#be185d",text:"#ffffff"},cyan:{bg:"#06b6d4",border:"#0e7490",text:"#ffffff"},slate:{bg:"#64748b",border:"#475569",text:"#ffffff"},gray:{bg:"#6b7280",border:"#4b5563",text:"#ffffff"}};a.useEffect(()=>{let s=!0;return(async()=>{N(!0);try{const o=await fetch(`${M}/api/v1/mcp`);if(!o.ok)throw new Error("Failed to fetch MCP servers");const r=await o.json();if(!r?.success||!Array.isArray(r.servers)){s&&p([]);return}const U=r.mcpServers&&typeof r.mcpServers=="object"?r.mcpServers:{},k=r.servers.map(f=>{const i=U[f]??{};return{name:f,enabled:i?.enabled!==!1,description:typeof i?.description=="string"?i.description:void 0}});s&&(p(k),C(f=>f.filter(i=>k.some(_=>_.name===i))))}catch(o){console.error("Failed to load MCP servers",o),s&&p([])}finally{s&&N(!1)}})(),()=>{s=!1}},[]);const q=async()=>{const s=".nut/config.json";try{await Z(s),S(!0),g({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>S(!1),2e3)}catch(t){console.error("Failed to copy config path:",t),g({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},R=async s=>{if(s.preventDefault(),!m.trim()||!u.trim()||!h.trim()){d("Name, description, and skill instructions are required");return}try{j(!0),d(null);const t={name:m.trim(),description:u.trim(),content:h.trim(),metadata:{color:c,mcpServers:x.length>0?x:void 0}},r=await(await fetch(`${M}/api/v1/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json();r.success?E("/skills"):d(r.error?.message||"Failed to create skill")}catch(t){d(t instanceof Error?t.message:"Unknown error")}finally{j(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Create New Skill"}),e.jsx("p",{className:"text-muted-foreground",children:"Define an AI skill for automated development workflows"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(b,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(w,{to:"/skills",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(O,{className:"h-4 w-4"})})})})]}),e.jsxs(G,{children:[e.jsx(K,{children:e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"}),"Skill Configuration"]})}),e.jsx(V,{children:e.jsxs("form",{onSubmit:R,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"name",children:"Name *"}),e.jsx(P,{id:"name",placeholder:"e.g., design expert",value:m,onChange:s=>A(s.target.value),disabled:n})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:"Description *"}),e.jsx(P,{id:"description",placeholder:"When should this skill be used?",value:u,onChange:s=>L(s.target.value),disabled:n})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:D.map(s=>{const t=$[s];return e.jsx("button",{type:"button",onClick:()=>F(s),disabled:n,className:`w-10 h-10 rounded-md border-2 transition-all ${c===s?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:t.bg,borderColor:c===s?t.border:"hsl(var(--border))",...c===s&&{"--tw-ring-color":t.border}},title:s,children:e.jsx("span",{className:"sr-only",children:s})},s)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"content",children:"Skill Instructions *"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["System prompt or instructions for this skill."," ","Insert ",e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:".nut/config.json"})," ",e.jsx("button",{type:"button",onClick:q,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:I?e.jsx(ee,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(se,{className:"h-3.5 w-3.5 ml-0.5"})})," ","if you want the skill to be able to access its name, role, or email address."]}),e.jsx(W,{id:"content",placeholder:"You are a design expert that focuses on...",value:h,onChange:s=>T(s.target.value),rows:8,disabled:n,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"MCP Servers (Optional)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which MCP servers this skill requires."}),e.jsx("div",{className:"space-y-2",children:B?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers..."}):y.length===0?e.jsx("div",{className:"text-sm text-muted-foreground border border-dashed rounded-md p-3",children:"No MCP servers configured yet. Configure servers in Settings → MCP."}):y.map(s=>e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-transparent bg-muted/30 px-3 py-2 hover:border-muted transition-colors",children:[e.jsx(Y,{checked:x.includes(s.name),onCheckedChange:t=>{C(o=>t===!0?o.includes(s.name)?o:[...o,s.name]:o.filter(r=>r!==s.name))},disabled:n||!s.enabled}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s.name,!s.enabled&&e.jsx(X,{variant:"secondary",className:"ml-2 text-xs",children:"Disabled"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.enabled?s.description||"Enabled MCP server":"Enable this server in Settings to use it"})]})]},s.name))})]}),v&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:v}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(b,{type:"button",variant:"outline",asChild:!0,disabled:n,children:e.jsx(w,{to:"/skills",children:"Cancel"})}),e.jsx(b,{type:"submit",disabled:n,children:n?"Creating...":"Create Skill"})]})]})})]})]})}export{de as default};
1
+ import{u as z,a as H,r as a,j as e,B as b,L as w,k as J,I as P,o as W,ab as Y,A as M}from"./index-DFcWlnzl.js";import{C as G,b as K,c as Q,a as V}from"./card-BcPlIAH5.js";import{L as l}from"./label-DBuh-ke5.js";import{B as X}from"./badge-BUEY53dV.js";import{c as Z}from"./clipboard-B9ndUJKl.js";import{A as O}from"./arrow-left-1S-835kP.js";import{C as ee,a as se}from"./clipboard-tzPFoieb.js";function de(){const E=z(),{toast:g}=H(),[n,j]=a.useState(!1),[v,d]=a.useState(null),[m,A]=a.useState(""),[u,L]=a.useState(""),[c,F]=a.useState("blue"),[x,C]=a.useState([]),[h,T]=a.useState(""),[y,p]=a.useState([]),[B,N]=a.useState(!0),[I,S]=a.useState(!1),D=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],$={blue:{bg:"#3b82f6",border:"#1e40af",text:"#ffffff"},green:{bg:"#22c55e",border:"#15803d",text:"#ffffff"},red:{bg:"#ef4444",border:"#b91c1c",text:"#ffffff"},emerald:{bg:"#10b981",border:"#047857",text:"#ffffff"},purple:{bg:"#a855f7",border:"#7e22ce",text:"#ffffff"},orange:{bg:"#f97316",border:"#c2410c",text:"#ffffff"},yellow:{bg:"#eab308",border:"#a16207",text:"#ffffff"},teal:{bg:"#14b8a6",border:"#0f766e",text:"#ffffff"},indigo:{bg:"#6366f1",border:"#4338ca",text:"#ffffff"},pink:{bg:"#ec4899",border:"#be185d",text:"#ffffff"},cyan:{bg:"#06b6d4",border:"#0e7490",text:"#ffffff"},slate:{bg:"#64748b",border:"#475569",text:"#ffffff"},gray:{bg:"#6b7280",border:"#4b5563",text:"#ffffff"}};a.useEffect(()=>{let s=!0;return(async()=>{N(!0);try{const o=await fetch(`${M}/api/v1/mcp`);if(!o.ok)throw new Error("Failed to fetch MCP servers");const r=await o.json();if(!r?.success||!Array.isArray(r.servers)){s&&p([]);return}const U=r.mcpServers&&typeof r.mcpServers=="object"?r.mcpServers:{},k=r.servers.map(f=>{const i=U[f]??{};return{name:f,enabled:i?.enabled!==!1,description:typeof i?.description=="string"?i.description:void 0}});s&&(p(k),C(f=>f.filter(i=>k.some(_=>_.name===i))))}catch(o){console.error("Failed to load MCP servers",o),s&&p([])}finally{s&&N(!1)}})(),()=>{s=!1}},[]);const q=async()=>{const s=".nut/config.json";try{await Z(s),S(!0),g({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>S(!1),2e3)}catch(t){console.error("Failed to copy config path:",t),g({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},R=async s=>{if(s.preventDefault(),!m.trim()||!u.trim()||!h.trim()){d("Name, description, and skill instructions are required");return}try{j(!0),d(null);const t={name:m.trim(),description:u.trim(),content:h.trim(),metadata:{color:c,mcpServers:x.length>0?x:void 0}},r=await(await fetch(`${M}/api/v1/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json();r.success?E("/skills"):d(r.error?.message||"Failed to create skill")}catch(t){d(t instanceof Error?t.message:"Unknown error")}finally{j(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Create New Skill"}),e.jsx("p",{className:"text-muted-foreground",children:"Define an AI skill for automated development workflows"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(b,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(w,{to:"/skills",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(O,{className:"h-4 w-4"})})})})]}),e.jsxs(G,{children:[e.jsx(K,{children:e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"}),"Skill Configuration"]})}),e.jsx(V,{children:e.jsxs("form",{onSubmit:R,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"name",children:"Name *"}),e.jsx(P,{id:"name",placeholder:"e.g., design expert",value:m,onChange:s=>A(s.target.value),disabled:n})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:"Description *"}),e.jsx(P,{id:"description",placeholder:"When should this skill be used?",value:u,onChange:s=>L(s.target.value),disabled:n})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:D.map(s=>{const t=$[s];return e.jsx("button",{type:"button",onClick:()=>F(s),disabled:n,className:`w-10 h-10 rounded-md border-2 transition-all ${c===s?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:t.bg,borderColor:c===s?t.border:"hsl(var(--border))",...c===s&&{"--tw-ring-color":t.border}},title:s,children:e.jsx("span",{className:"sr-only",children:s})},s)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"content",children:"Skill Instructions *"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["System prompt or instructions for this skill."," ","Insert ",e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:".nut/config.json"})," ",e.jsx("button",{type:"button",onClick:q,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:I?e.jsx(ee,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(se,{className:"h-3.5 w-3.5 ml-0.5"})})," ","if you want the skill to be able to access its name, role, or email address."]}),e.jsx(W,{id:"content",placeholder:"You are a design expert that focuses on...",value:h,onChange:s=>T(s.target.value),rows:8,disabled:n,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"MCP Servers (Optional)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which MCP servers this skill requires."}),e.jsx("div",{className:"space-y-2",children:B?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers..."}):y.length===0?e.jsx("div",{className:"text-sm text-muted-foreground border border-dashed rounded-md p-3",children:"No MCP servers configured yet. Configure servers in Settings → MCP."}):y.map(s=>e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-transparent bg-muted/30 px-3 py-2 hover:border-muted transition-colors",children:[e.jsx(Y,{checked:x.includes(s.name),onCheckedChange:t=>{C(o=>t===!0?o.includes(s.name)?o:[...o,s.name]:o.filter(r=>r!==s.name))},disabled:n||!s.enabled}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s.name,!s.enabled&&e.jsx(X,{variant:"secondary",className:"ml-2 text-xs",children:"Disabled"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.enabled?s.description||"Enabled MCP server":"Enable this server in Settings to use it"})]})]},s.name))})]}),v&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:v}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(b,{type:"button",variant:"outline",asChild:!0,disabled:n,children:e.jsx(w,{to:"/skills",children:"Cancel"})}),e.jsx(b,{type:"submit",disabled:n,children:n?"Creating...":"Create Skill"})]})]})})]})]})}export{de as default};
@@ -0,0 +1,90 @@
1
+ import{u as X,q as Z,a as ee,s as te,r as n,A,j as e,B as j,L as E,I as y,a0 as se,y as ae,H as ie,J as ne,N as re,O as oe,Q as le,R as ce,U as de}from"./index-DFcWlnzl.js";import{C as he,b as ue,c as me,a as pe}from"./card-BcPlIAH5.js";import{L as h}from"./label-DBuh-ke5.js";import{M as ge}from"./markdown-editor-B4YNQFT2.js";import{S as F,a as L,b as P,c as I,d as r}from"./select-44mcS2_G.js";import{C as xe}from"./CollapsibleSection-M5cXbl92.js";import{I as fe,L as je}from"./ImplementationStepsEditor-HliLQav5.js";import{T as ye}from"./TagInput-C6lI-ePr.js";import{A as ve}from"./arrow-left-1S-835kP.js";import"./chevron-up-CqM3won3.js";import"./badge-BUEY53dV.js";const R={feature:{name:"New Feature",content:`## Problem Statement
2
+ Describe the problem this new feature addresses.
3
+
4
+ ## Proposed Solution
5
+ Describe the solution you're proposing.
6
+
7
+ ### Key Features
8
+ - Feature 1
9
+ - Feature 2
10
+ - Feature 3
11
+
12
+ ## Implementation Details
13
+ Describe the technical implementation approach.
14
+
15
+ ## Testing Strategy
16
+ - [ ] Unit tests
17
+ - [ ] Integration tests
18
+ - [ ] Manual testing
19
+
20
+ ## Rollout Plan
21
+ 1. Development and testing
22
+ 2. Staging deployment
23
+ 3. Production rollout
24
+
25
+ ## Success Metrics
26
+ Define how you'll measure the success of this change.`},"quick-change":{name:"Quick Change",content:`## Overview
27
+ Describe the quick change you're proposing.`},"bug-fix":{name:"Bug Fix",content:`## Bug Description
28
+ Describe the bug that needs to be fixed.
29
+
30
+ ## Steps to Reproduce
31
+ 1. Step 1
32
+ 2. Step 2
33
+ 3. Step 3
34
+
35
+ ## Expected Behavior
36
+ Describe what should happen.
37
+
38
+ ## Actual Behavior
39
+ Describe what currently happens.
40
+
41
+ ## Root Cause Analysis
42
+ Explain the underlying cause of the bug.
43
+
44
+ ## Proposed Fix
45
+ Describe the solution to fix the bug.
46
+
47
+ ## Testing Plan
48
+ - [ ] Verify fix resolves the original issue
49
+ - [ ] Test edge cases
50
+ - [ ] Regression testing
51
+
52
+ ## Risk Assessment
53
+ - Impact: Low/Medium/High
54
+ - Complexity: Low/Medium/High
55
+ - Risk of introducing new bugs: Low/Medium/High`},refactor:{name:"Refactor",content:`## Current State
56
+ Describe what needs to be refactored and why.
57
+
58
+ ## Refactoring Goals
59
+ - Improve code readability
60
+ - Reduce complexity
61
+ - Enhance maintainability
62
+
63
+ ## Proposed Changes
64
+ Describe the refactoring approach.
65
+
66
+ ## Risk Assessment
67
+ - Breaking changes: None/Low/Medium/High
68
+ - Testing strategy for regression prevention`},documentation:{name:"Documentation",content:`## Documentation Gap
69
+ What documentation is missing or outdated?
70
+
71
+ ## Proposed Updates
72
+ - [ ] API documentation
73
+ - [ ] User guides
74
+ - [ ] Code comments
75
+ - [ ] README updates
76
+
77
+ ## Target Audience
78
+ Who will benefit from these documentation changes?`},"security-fix":{name:"Security Fix",content:`## Security Issue
79
+ Brief description (avoid sensitive details).
80
+
81
+ ## Impact Assessment
82
+ - Severity: Low/Medium/High/Critical
83
+ - Affected components
84
+ - User impact
85
+
86
+ ## Proposed Fix
87
+ High-level approach to resolution.
88
+
89
+ ## Verification Plan
90
+ How to confirm the fix works without exposing the vulnerability.`}},M="feature";function Pe(){const B=X(),H=Z(),{toast:v}=ee(),{user:u,authEnabled:S}=te(),[c,w]=n.useState(!1),[U,q]=n.useState(M),[O,p]=n.useState(!1),[C,g]=n.useState(null),b=H.state,N=b?.description||R[M].content,$=b?.title||"",[a,l]=n.useState({title:$,description:N,priority:"medium",author:{id:"current-user",name:"",email:""}}),[m,V]=n.useState([]),[D,z]=n.useState([]),[K,_]=n.useState(N),x=n.useCallback(t=>{if((t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),!c&&a.title)){const s=document.querySelector("form");s&&s.requestSubmit()}},[c,a.title]),Q=a.description!==K,W=t=>{Q?(g(t),p(!0)):k(t)},k=t=>{const s=R[t];q(t),l(i=>({...i,description:s.content})),_(s.content)},G=()=>{C&&(k(C),g(null)),p(!1)},J=()=>{g(null),p(!1)};n.useEffect(()=>(document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}),[x]);const T=n.useCallback(async()=>{try{const s=await(await fetch(`${A}/api/v1/user/settings`)).json();if(s.success&&s.data){const{profile:i}=s.data;l(d=>({...d,author:{...d.author,name:i?.firstName&&i?.lastName?`${i.firstName} ${i.lastName}`.trim():i?.firstName||i?.lastName||d.author.name,email:i?.email||d.author.email}}))}}catch(t){console.error("Failed to load user settings:",t)}},[]);n.useEffect(()=>{S?u&&l(t=>({...t,author:{...t.author,id:u.id||t.author.id,name:u.name||t.author.name,email:u.email||t.author.email}})):T()},[S,u,T]);const Y=async t=>{t.preventDefault(),w(!0);try{const s=m.map(o=>({id:o.id,description:o.description.trim(),status:o.status})).filter(o=>o.description.length>0),i=D.map(o=>o.trim()).filter(o=>o.length>0),d={title:a.title,author:{...a.author,type:"human"},planSteps:s,metadata:{priority:a.priority,tags:i},content:a.description},f=await(await fetch(`${A}/api/v1/tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)})).json();if(f.success)v({title:"Success",description:"Task created successfully."}),B(`/tasks/${f.data.id}`);else throw new Error(f.error?.message||"Failed to create task")}catch(s){const i=s instanceof Error?s.message:"Unknown error occurred";v({title:"Error",description:`Error creating task: ${i}`,variant:"destructive"})}finally{w(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"New Task"}),e.jsx("p",{className:"text-muted-foreground",children:"Create a new task"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(j,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(E,{to:"/tasks",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(ve,{className:"h-4 w-4"})})})})]}),e.jsx("form",{onSubmit:Y,children:e.jsxs(he,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(me,{children:"Task Details"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{htmlFor:"template-select",className:"text-sm text-muted-foreground",children:"Template:"}),e.jsxs(F,{value:U,onValueChange:W,children:[e.jsx(L,{className:"w-36",children:e.jsx(P,{})}),e.jsxs(I,{children:[e.jsx(r,{value:"feature",children:"New Feature"}),e.jsx(r,{value:"quick-change",children:"Quick Change"}),e.jsx(r,{value:"bug-fix",children:"Bug Fix"}),e.jsx(r,{value:"refactor",children:"Refactor"}),e.jsx(r,{value:"documentation",children:"Documentation"}),e.jsx(r,{value:"security-fix",children:"Security Fix"})]})]})]})]})}),e.jsxs(pe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"title",children:"Title *"}),e.jsx(y,{id:"title",placeholder:"Brief overview of the task",value:a.title,onChange:t=>l(s=>({...s,title:t.target.value})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"description",children:"Description"}),e.jsx(ge,{value:a.description,onChange:t=>l(s=>({...s,description:t||""})),placeholder:"Write your task description in markdown...",height:300})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"author-name",children:"Author Name"}),e.jsx(y,{id:"author-name",value:a.author.name,onChange:t=>l(s=>({...s,author:{...s.author,name:t.target.value}})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"author-email",children:"Author Email"}),e.jsx(y,{id:"author-email",type:"email",value:a.author.email,onChange:t=>l(s=>({...s,author:{...s.author,email:t.target.value}}))})]})]}),e.jsx(xe,{icon:e.jsx(je,{className:"h-4 w-4"}),title:"Optional Implementation Detail",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"priority",children:"Priority"}),e.jsxs(F,{value:a.priority,onValueChange:t=>l(s=>({...s,priority:t})),children:[e.jsx(L,{children:e.jsx(P,{placeholder:"Select priority"})}),e.jsxs(I,{children:[e.jsx(r,{value:"low",children:"Low"}),e.jsx(r,{value:"medium",children:"Medium"}),e.jsx(r,{value:"high",children:"High"}),e.jsx(r,{value:"critical",children:"Critical"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Implementation Steps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Break the change into actionable steps."})]}),m.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.length," step",m.length===1?"":"s"]})]}),e.jsx(fe,{steps:m,onChange:V,disabled:c})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Tags"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Use tags to categorize this task by area, team, or priority."}),e.jsx(ye,{tags:D,onChange:z,disabled:c,placeholder:"Add a tag (e.g. frontend, infra)"})]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{type:"button",variant:"outline",asChild:!0,children:e.jsx(E,{to:"/tasks",children:"Cancel"})}),e.jsx(j,{type:"submit",disabled:c||!a.title,className:"relative",children:c?e.jsx(e.Fragment,{children:"Creating..."}):e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"mr-2 h-4 w-4"}),"Create Task",e.jsx("span",{className:"ml-2 text-xs opacity-60 font-mono",children:"⌘↵"})]})})]})]})]})}),e.jsx(ae,{open:O,onOpenChange:p,children:e.jsxs(ie,{children:[e.jsxs(ne,{children:[e.jsx(re,{children:"Switch Template?"}),e.jsx(oe,{children:"You have unsaved changes to your task description. Switching templates will replace your current content with the new template. This action cannot be undone."})]}),e.jsxs(le,{children:[e.jsx(ce,{onClick:J,children:"Cancel"}),e.jsx(de,{onClick:G,children:"Switch Template"})]})]})})]})}export{Pe as NewTaskPage};
@@ -0,0 +1,6 @@
1
+ import{c as s,q as a,j as e,B as c,L as o}from"./index-DFcWlnzl.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 n=[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],r=s("compass",n);function i(){const t=a();return e.jsxs("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 p-4 text-center",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(r,{className:"h-12 w-12 text-muted-foreground",strokeWidth:1.5}),e.jsx("h1",{className:"text-4xl font-bold tracking-tight",children:"404"}),e.jsxs("p",{className:"text-lg text-muted-foreground",children:["Nothing here at ",e.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-sm",children:t.pathname})]})]}),e.jsx(c,{asChild:!0,children:e.jsx(o,{to:"/",children:"Back to Dashboard"})})]})}export{i as default};
@@ -0,0 +1 @@
1
+ import{r as i,a as W,A as m,j as e,a$ as T,B as v,I as F,a0 as Y,bp as Z,bq as ee}from"./index-DFcWlnzl.js";import{C as E,b as B,c as U,d as I,a as O}from"./card-BcPlIAH5.js";import{L as c}from"./label-DBuh-ke5.js";import{S as h}from"./switch-CIwjYvCt.js";import{S as se,a as te,b as ae,c as ne,d as ie}from"./select-44mcS2_G.js";import{M as re}from"./message-square-B5RWz_ff.js";import{C as oe}from"./circle-check-eyo6pBP1.js";import{C as D}from"./circle-x-uqmzEce1.js";import{R as V}from"./refresh-cw-B3OwrDUf.js";import"./chevron-up-CqM3won3.js";const y={enabled:!1,channelId:"",channelName:"",siteUrl:"",notifications:{proposals:{created:!0,statusChange:!0},jobs:{completed:!0,failed:!0},git:{push:!1,merge:!0}},hasBotToken:!1,hasSigningSecret:!1};function je(){const[t,k]=i.useState(y),[x,$]=i.useState(""),[p,P]=i.useState(""),[S]=i.useState(()=>typeof window<"u"?window.location.origin:""),[l,j]=i.useState({data:[],error:null,loading:!1}),[H,L]=i.useState(!0),[A,g]=i.useState(!1),[J,R]=i.useState(!1),[M,_]=i.useState(!1),[o,z]=i.useState(null),[b,N]=i.useState(null),{toast:r}=W(),G=i.useCallback(async()=>{L(!0);try{const a=await(await fetch(`${m}/api/v1/slack/config`)).json();if(a.success)k({...y,...a.data});else throw new Error(a.error||"Failed to load Slack configuration")}catch(s){console.error("Failed to load Slack config:",s),r({title:"Error",description:"Failed to load Slack configuration",variant:"destructive"})}finally{L(!1)}},[r]),q=i.useCallback(async()=>{R(!0),N(null);try{const a=await(await fetch(`${m}/api/v1/slack/test`,{method:"POST"})).json();a.success?(N({success:!0,teamName:a.teamName}),r({title:"Connected",description:`Connected to workspace: ${a.teamName}`})):(N({success:!1,error:a.error}),r({title:"Connection failed",description:a.error||"Failed to connect",variant:"destructive"}))}catch(s){N({success:!1,error:s.message}),r({title:"Error",description:s.message||"Connection test failed",variant:"destructive"})}finally{R(!1)}},[r]),C=i.useCallback(async()=>{j(s=>({...s,loading:!0,error:null}));try{const a=await(await fetch(`${m}/api/v1/slack/channels`)).json();if(a.success)j({data:a.data||[],error:null,loading:!1});else{const n=a.error||"Failed to load channels";j({data:[],error:n,loading:!1})}}catch(s){console.error("Failed to load Slack channels:",s),j({data:[],error:s.message||"Failed to load channels",loading:!1})}},[]),X=async()=>{g(!0);try{const s={};if(x&&x!=="***"&&(s.botToken=x),p&&p!=="***"&&(s.signingSecret=p),s.siteUrl=S,Object.keys(s).length===1&&s.siteUrl&&!x&&!p){r({title:"No changes",description:"Enter new tokens to save"}),g(!1);return}const n=await(await fetch(`${m}/api/v1/slack/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).json();if(n.success)k({...y,...n.data}),$(""),P(""),r({title:"Saved",description:"Slack tokens saved successfully"}),await q();else throw new Error(n.error||"Failed to save tokens")}catch(s){r({title:"Error",description:s.message||"Failed to save tokens",variant:"destructive"})}finally{g(!1)}},w=async s=>{g(!0);try{const n=await(await fetch(`${m}/api/v1/slack/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).json();if(n.success)k({...y,...n.data}),r({title:"Saved",description:"Configuration updated"});else throw new Error(n.error||"Failed to save configuration")}catch(a){r({title:"Error",description:a.message||"Failed to save",variant:"destructive"})}finally{g(!1)}},K=async()=>{_(!0);try{const a=await(await fetch(`${m}/api/v1/slack/notify`,{method:"POST"})).json();if(a.success)r({title:"Sent",description:"Test notification sent to Slack"});else throw new Error(a.error||"Failed to send notification")}catch(s){r({title:"Error",description:s.message||"Failed to send test notification",variant:"destructive"})}finally{_(!1)}},u=(s,a,n)=>{const Q={...t.notifications,[s]:{...t.notifications[s],[a]:n}};w({notifications:Q})},f=async s=>{z(s);try{const n=await(await fetch(`${m}/api/v1/slack/notify/example`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:s})})).json();if(n.success)r({title:"Sent",description:`Example notification sent to ${t.channelName}`});else throw new Error(n.error||"Failed to send example notification")}catch(a){r({title:"Error",description:a.message||"Failed to send example notification",variant:"destructive"})}finally{z(null)}};if(i.useEffect(()=>{G()},[G]),i.useEffect(()=>{t.hasBotToken&&C()},[t.hasBotToken,C]),H)return e.jsx("div",{children:"Loading..."});const d=!!t.channelId;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Slack notifications for Coconut events."})]}),e.jsx(T,{}),e.jsxs(E,{children:[e.jsxs(B,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-5 w-5"}),e.jsx(U,{children:"Slack Connection"})]}),e.jsx(I,{children:"Connect your Slack workspace to receive notifications from Coconut."})]}),e.jsxs(O,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded border bg-muted/30 px-3 py-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:t.hasBotToken?b?.success?e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"h-4 w-4 text-green-600"}),e.jsxs("span",{className:"text-sm font-medium text-green-600",children:["Connected to ",b.teamName]})]}):b?.error?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 text-red-600"}),e.jsx("span",{className:"text-sm text-red-600",children:b.error})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-4 rounded-full bg-yellow-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Token configured - click Test to verify"})]}):e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Not connected"})]})}),e.jsxs(v,{variant:"outline",size:"sm",onClick:q,disabled:J||!t.hasBotToken,children:[e.jsx(V,{className:`h-4 w-4 mr-2 ${J?"animate-spin":""}`}),"Test"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"botToken",children:"Bot User OAuth Token"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(F,{id:"botToken",type:"password",placeholder:t.hasBotToken?"••••••••••••••••":"xoxb-...",value:x,onChange:s=>$(s.target.value),className:"flex-1"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Find this in your Slack app settings under OAuth & Permissions. The token should start with ",e.jsx("code",{className:"text-xs bg-muted px-1 rounded",children:"xoxb-"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"signingSecret",children:"Signing Secret"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(F,{id:"signingSecret",type:"password",placeholder:t.hasSigningSecret?"••••••••••••••••":"Enter signing secret",value:p,onChange:s=>P(s.target.value),className:"flex-1"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Find this in your Slack app settings under Basic Information → App Credentials."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"siteUrl",children:"Site URL"}),e.jsx(F,{id:"siteUrl",type:"text",value:S,disabled:!0,className:"bg-muted"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This URL will be used for links in Slack notifications.",t.siteUrl&&t.siteUrl!==S&&e.jsxs("span",{className:"block mt-1 text-amber-600",children:["Currently saved: ",t.siteUrl]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(v,{onClick:X,disabled:A||!x&&!p,children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),A?"Saving...":"Save Tokens"]})}),e.jsxs("div",{className:"rounded border bg-muted/50 p-4 space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Setup Instructions"}),e.jsxs("ol",{className:"text-xs text-muted-foreground space-y-1 list-decimal list-inside",children:[e.jsxs("li",{children:["Go to ",e.jsx("a",{href:"https://api.slack.com/apps",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"api.slack.com/apps"})," and select your app"]}),e.jsxs("li",{children:['Under "OAuth & Permissions", add these Bot Token Scopes:',e.jsxs("ul",{className:"ml-4 mt-1 space-y-0.5",children:[e.jsxs("li",{children:[e.jsx("code",{className:"text-xs bg-background px-1 rounded",children:"chat:write"})," - Send messages"]}),e.jsxs("li",{children:[e.jsx("code",{className:"text-xs bg-background px-1 rounded",children:"channels:read"})," - List public channels"]}),e.jsxs("li",{children:[e.jsx("code",{className:"text-xs bg-background px-1 rounded",children:"groups:read"})," - List private channels (optional)"]})]})]}),e.jsx("li",{children:"Install the app to your workspace and copy the Bot User OAuth Token"}),e.jsx("li",{children:'Under "Basic Information", copy the Signing Secret'})]})]})]})]}),e.jsxs(E,{children:[e.jsxs(B,{children:[e.jsx(U,{children:"Notification Channel"}),e.jsx(I,{children:"Select the Slack channel where notifications will be posted."})]}),e.jsxs(O,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:"Channel"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(se,{value:t.channelId,onValueChange:s=>{const a=l.data.find(n=>n.id===s);w({channelId:s,channelName:a?`#${a.name}`:""})},disabled:!t.hasBotToken||l.loading||!!l.error,children:[e.jsx(te,{className:"flex-1",children:e.jsx(ae,{placeholder:l.loading?"Loading channels...":l.error?"Unable to load channels":"Select a channel"})}),e.jsx(ne,{children:l.data.map(s=>e.jsxs(ie,{value:s.id,children:[s.isPrivate?"🔒":"#"," ",s.name,!s.isMember&&" (bot not member)"]},s.id))})]}),e.jsx(v,{variant:"outline",size:"icon",onClick:C,disabled:l.loading||!t.hasBotToken,children:e.jsx(V,{className:`h-4 w-4 ${l.loading?"animate-spin":""}`})})]}),l.error&&e.jsxs("div",{className:"rounded border border-red-200 bg-red-50 p-3 text-xs text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:[e.jsx("span",{className:"font-medium",children:"Error loading channels:"})," ",l.error]}),t.channelName&&!l.error&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Currently set to: ",e.jsx("span",{className:"font-medium",children:t.channelName})]}),!t.hasBotToken&&e.jsx("p",{className:"text-xs text-amber-600",children:"Configure your Bot Token above to select a channel."})]}),d&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Send a test notification to verify the setup"}),e.jsxs(v,{variant:"outline",size:"sm",onClick:K,disabled:M||!t.enabled,children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),M?"Sending...":"Send Test"]})]})]})]}),e.jsxs(E,{children:[e.jsxs(B,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"h-5 w-5"}),e.jsx(U,{children:"Notification Types"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c,{htmlFor:"notifications-enabled",className:"text-sm font-normal",children:"Enable notifications"}),e.jsx(h,{id:"notifications-enabled",checked:t.enabled,onCheckedChange:s=>w({enabled:s}),disabled:!t.hasBotToken||!d})]})]}),e.jsx(I,{children:"Choose which events trigger Slack notifications."})]}),e.jsxs(O,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Proposals"}),e.jsxs("div",{className:"space-y-3 ml-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"proposals-created",className:"text-sm font-normal",children:"New proposal created"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("proposal.created"),disabled:!d||o==="proposal.created",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="proposal.created"?"Sending...":"Send Example"}),e.jsx(h,{id:"proposals-created",checked:t.notifications.proposals.created,onCheckedChange:s=>u("proposals","created",s),disabled:!t.enabled})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"proposals-status",className:"text-sm font-normal",children:"Proposal status changed"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("proposal.statusChange"),disabled:!d||o==="proposal.statusChange",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="proposal.statusChange"?"Sending...":"Send Example"}),e.jsx(h,{id:"proposals-status",checked:t.notifications.proposals.statusChange,onCheckedChange:s=>u("proposals","statusChange",s),disabled:!t.enabled})]})]})]})]}),e.jsx(T,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Scheduled Jobs"}),e.jsxs("div",{className:"space-y-3 ml-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"jobs-completed",className:"text-sm font-normal",children:"Job completed successfully"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("job.completed"),disabled:!d||o==="job.completed",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="job.completed"?"Sending...":"Send Example"}),e.jsx(h,{id:"jobs-completed",checked:t.notifications.jobs.completed,onCheckedChange:s=>u("jobs","completed",s),disabled:!t.enabled})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"jobs-failed",className:"text-sm font-normal",children:"Job failed"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("job.failed"),disabled:!d||o==="job.failed",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="job.failed"?"Sending...":"Send Example"}),e.jsx(h,{id:"jobs-failed",checked:t.notifications.jobs.failed,onCheckedChange:s=>u("jobs","failed",s),disabled:!t.enabled})]})]})]})]}),e.jsx(T,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Git Operations"}),e.jsxs("div",{className:"space-y-3 ml-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"git-push",className:"text-sm font-normal",children:"Code pushed"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("git.push"),disabled:!d||o==="git.push",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="git.push"?"Sending...":"Send Example"}),e.jsx(h,{id:"git-push",checked:t.notifications.git.push,onCheckedChange:s=>u("git","push",s),disabled:!t.enabled})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"git-merge",className:"text-sm font-normal",children:"Branch merged"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("git.merge"),disabled:!d||o==="git.merge",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="git.merge"?"Sending...":"Send Example"}),e.jsx(h,{id:"git-merge",checked:t.notifications.git.merge,onCheckedChange:s=>u("git","merge",s),disabled:!t.enabled})]})]})]})]}),!t.enabled&&t.hasBotToken&&d&&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:"Enable notifications above to start receiving Slack messages for these events."})]})]})]})}export{je as default};
@@ -0,0 +1,11 @@
1
+ import{u as L,a as I,r as i,A as S,j as e,B as C,L as M,a0 as A,I as p}from"./index-DFcWlnzl.js";import{C as m,a as x,b,c as P}from"./card-BcPlIAH5.js";import{L as l}from"./label-DBuh-ke5.js";import{S as B,a as D,b as T,c as O,d as j}from"./select-44mcS2_G.js";import{M as V}from"./markdown-editor-B4YNQFT2.js";import{A as W}from"./arrow-left-1S-835kP.js";import{C as z}from"./circle-check-big-jKg34xC-.js";import"./chevron-up-CqM3won3.js";function G(){const E=L(),{toast:d}=I(),[a,v]=i.useState({project:{name:"",description:"",website:"",version:"1.0.0",stage:"development"}}),[u,g]=i.useState(""),[F,f]=i.useState(!0),[y,w]=i.useState(!1);i.useEffect(()=>{fetch(`${S}/api/v1/context/project`).then(t=>t.json()).then(t=>{if(t.success){const s=t.document;v({project:{name:s.metadata.project?.name||"",description:s.metadata.project?.description||"",website:s.metadata.project?.website||s.metadata.project?.repository||"",version:s.metadata.project?.version||"1.0.0",stage:s.metadata.project?.stage||"development"}}),g(s.content.trim())}f(!1)}).catch(t=>{console.error("Failed to load context:",t),d({title:"Error",description:"Failed to load project context",variant:"destructive"}),f(!1)})},[d]);const k=async()=>{w(!0);try{const s={project:Object.fromEntries(Object.entries(a.project).map(([o,r])=>[o,typeof r=="string"?r.trim():r]))},n=await(await fetch(`${S}/api/v1/context/project`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:u,metadata:s})})).json();if(n.success)d({title:"Success",description:"Project context saved successfully",action:e.jsx(z,{className:"h-4 w-4"})}),E("/context/project");else throw new Error(n.error||"Failed to save context")}catch(t){console.error("Save error:",t),d({title:"Error",description:"Failed to save project context",variant:"destructive"})}finally{w(!1)}},c=(t,s)=>{v(N=>{const n={...N},o=t.split(".");let r=n;for(let h=0;h<o.length-1;h++)r=r[o[h]];return r[o[o.length-1]]=s,n})};return F?e.jsx("div",{className:"space-y-6",children:e.jsx(m,{children:e.jsx(x,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Project Overview"}),e.jsx("p",{className:"text-muted-foreground",children:"Edit project information and documentation"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(M,{to:"/context/project",children:[e.jsx(W,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Back"})]})}),e.jsxs(C,{size:"sm",onClick:k,disabled:y,children:[e.jsx(A,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:y?"Saving...":"Save"})]})]})]}),e.jsxs(m,{children:[e.jsx(b,{children:e.jsx(P,{children:"Project Information"})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-name",children:"Project Name"}),e.jsx(p,{id:"project-name",value:a.project.name,onChange:t=>c("project.name",t.target.value),placeholder:"My Awesome Project"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-version",children:"Version"}),e.jsx(p,{id:"project-version",value:a.project.version,onChange:t=>c("project.version",t.target.value),placeholder:"1.0.0"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-description",children:"Description"}),e.jsx(p,{id:"project-description",value:a.project.description,onChange:t=>c("project.description",t.target.value),placeholder:"Brief description of what this project does"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-website",children:"Website"}),e.jsx(p,{id:"project-website",value:a.project.website,onChange:t=>c("project.website",t.target.value),placeholder:"https://yourproject.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-stage",children:"Development Stage"}),e.jsxs(B,{value:a.project.stage,onValueChange:t=>c("project.stage",t),children:[e.jsx(D,{children:e.jsx(T,{placeholder:"Select stage"})}),e.jsxs(O,{children:[e.jsx(j,{value:"prototype",children:"Prototype"}),e.jsx(j,{value:"development",children:"Development"}),e.jsx(j,{value:"mvp",children:"MVP"}),e.jsx(j,{value:"production",children:"Production"})]})]})]})]})]})]}),e.jsxs(m,{children:[e.jsx(b,{children:e.jsx(P,{children:"Documentation"})}),e.jsx(x,{children:e.jsx(V,{value:u,onChange:t=>g(t||""),placeholder:`Write your project documentation in markdown...
2
+
3
+ ## What is this project?
4
+
5
+ Describe what your project does, who it's for, and why it exists.
6
+
7
+ ## Current State
8
+
9
+ - Development stage
10
+ - Key features that are working
11
+ - What's planned for next releases`,height:800})})]})]})}export{G as default};
@@ -1 +1 @@
1
- import{a as w,r,A as y,j as e,H as C,F as b,B as n,M as P,aB as E,L as k,Q as L,ay as z}from"./index-hqVgTgRB.js";import{C as c,a as i,b as p,c as B}from"./card-BCFxXzRk.js";import{B as x}from"./badge-DEiQk9C9.js";import{c as F}from"./clipboard-B9ndUJKl.js";import{E as D}from"./external-link-CYBz87-P.js";function I(){const{toast:d}=w(),[o,h]=r.useState(null),[j,u]=r.useState(!0),[f,l]=r.useState(!1);r.useEffect(()=>{fetch(`${y}/api/v1/context/project`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(h(s.document),l(!0)):l(!1)}).catch(()=>{l(!1)}).finally(()=>{u(!1)})},[]);const v=async()=>{const s=".nut/context/project.md";try{await F(s),d({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(m){console.error("Failed to copy path:",m),d({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},N=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"project-md",filename:"project.md",name:"project.md",path:".nut/context/project.md"}});window.dispatchEvent(s)};if(j)return e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading Project Overview..."})]})})})});if(!f||!o)return e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(b,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Project Overview Found"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Run ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded",children:"coconut init"})," to create the project overview."]})]})})})});const t=o.metadata,a=t.project?.website||t.project?.repository,g=a?(s=>{try{return new URL(s.startsWith("http")?s:`https://${s}`).host.replace(/^www\./,"")}catch{return s.replace(/^https?:\/\//,"")}})(a):null;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:"Project Overview"}),e.jsx("p",{className:"text-muted-foreground",children:"Core project information and configuration"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:"outline",size:"sm",onClick:N,children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(n,{variant:"outline",size:"sm",onClick:v,children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(n,{size:"sm",asChild:!0,children:e.jsxs(k,{to:"/context/project/edit",children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),t&&e.jsx("div",{className:"grid grid-cols-1 gap-4",children:e.jsxs(c,{children:[e.jsx(p,{className:"pb-3",children:e.jsx(B,{className:"text-lg font-semibold",children:"Project Info"})}),e.jsxs(i,{className:"space-y-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.project?.name||"Unnamed Project"}),t.project?.description&&e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t.project.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&e.jsx(n,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(D,{className:"w-3 h-3 mr-2"}),g||"Website"]})}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[t.project?.version&&e.jsxs(x,{variant:"secondary",children:["v",t.project.version]}),t.project?.stage&&e.jsx(x,{variant:t.project.stage==="mvp"?"default":"secondary",children:t.project.stage})]})]})]})]})}),e.jsxs(c,{children:[e.jsx(p,{}),e.jsx(i,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(z,{children:o.content||"No content available"})})})]})]})}export{I as default};
1
+ import{a as w,r,A as y,j as e,t as C,F as b,B as n,M as P,au as E,L as k,Y as L,ar as z}from"./index-DFcWlnzl.js";import{C as c,a as i,b as p,c as F}from"./card-BcPlIAH5.js";import{B as x}from"./badge-BUEY53dV.js";import{c as B}from"./clipboard-B9ndUJKl.js";import{E as D}from"./external-link-CNDy2UUo.js";function I(){const{toast:d}=w(),[o,h]=r.useState(null),[j,u]=r.useState(!0),[f,l]=r.useState(!1);r.useEffect(()=>{fetch(`${y}/api/v1/context/project`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(h(s.document),l(!0)):l(!1)}).catch(()=>{l(!1)}).finally(()=>{u(!1)})},[]);const v=async()=>{const s=".nut/context/project.md";try{await B(s),d({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(m){console.error("Failed to copy path:",m),d({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},N=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"project-md",filename:"project.md",name:"project.md",path:".nut/context/project.md"}});window.dispatchEvent(s)};if(j)return e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading Project Overview..."})]})})})});if(!f||!o)return e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(b,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Project Overview Found"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Run ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded",children:"coconut init"})," to create the project overview."]})]})})})});const t=o.metadata,a=t.project?.website||t.project?.repository,g=a?(s=>{try{return new URL(s.startsWith("http")?s:`https://${s}`).host.replace(/^www\./,"")}catch{return s.replace(/^https?:\/\//,"")}})(a):null;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:"Project Overview"}),e.jsx("p",{className:"text-muted-foreground",children:"Core project information and configuration"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:"outline",size:"sm",onClick:N,children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(n,{variant:"outline",size:"sm",onClick:v,children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(n,{size:"sm",asChild:!0,children:e.jsxs(k,{to:"/context/project/edit",children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),t&&e.jsx("div",{className:"grid grid-cols-1 gap-4",children:e.jsxs(c,{children:[e.jsx(p,{className:"pb-3",children:e.jsx(F,{className:"text-lg font-semibold",children:"Project Info"})}),e.jsxs(i,{className:"space-y-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.project?.name||"Unnamed Project"}),t.project?.description&&e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t.project.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&e.jsx(n,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(D,{className:"w-3 h-3 mr-2"}),g||"Website"]})}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[t.project?.version&&e.jsxs(x,{variant:"secondary",children:["v",t.project.version]}),t.project?.stage&&e.jsx(x,{variant:t.project.stage==="mvp"?"default":"secondary",children:t.project.stage})]})]})]})]})}),e.jsxs(c,{children:[e.jsx(p,{}),e.jsx(i,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(z,{children:o.content||"No content available"})})})]})]})}export{I as default};
@@ -0,0 +1 @@
1
+ import{j as e,a$ as p,B as r,P as h,Y as j,af as u,E as g,I as l}from"./index-DFcWlnzl.js";import{C as t,b as i,c as n,d as c,a as d}from"./card-BcPlIAH5.js";import{L as a}from"./label-DBuh-ke5.js";import{S as f,a as v,b as N,c as y,d as b}from"./select-44mcS2_G.js";import{B as o}from"./badge-BUEY53dV.js";import{E as w}from"./eye-DLFBnC8t.js";import{D as C}from"./download-Bg__QCLT.js";import"./chevron-up-CqM3won3.js";function U(){const m=[{id:"1",name:"Code Review Assistant",description:"Prompt for AI agents to perform thorough code reviews",category:"Code Review",usage:"cursor-cli, claude-code",lastUpdated:"2 days ago",active:!0},{id:"2",name:"Architecture Advisor",description:"System prompt for architectural decision guidance",category:"Architecture",usage:"gemini-cli, claude-code",lastUpdated:"1 week ago",active:!0},{id:"3",name:"Bug Analysis Expert",description:"Specialized prompt for debugging and error analysis",category:"Debugging",usage:"cursor-cli",lastUpdated:"3 days ago",active:!1},{id:"4",name:"Documentation Generator",description:"Prompt for generating comprehensive code documentation",category:"Documentation",usage:"github-copilot, claude-code",lastUpdated:"5 days ago",active:!0}],x=["Code Review","Architecture","Debugging","Documentation","Testing","Refactoring","Security","Performance"];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"System Prompts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage system prompts used by AI agents and integrations for consistent behavior."})]}),e.jsx(p,{}),e.jsxs(t,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(n,{children:"Prompt Library"}),e.jsx(c,{children:"Pre-configured prompts for different AI agents and use cases."})]}),e.jsxs(r,{size:"sm",children:[e.jsx(h,{className:"h-4 w-4 mr-2"}),"New Prompt"]})]})}),e.jsx(d,{children:e.jsx("div",{className:"space-y-4",children:m.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h4",{className:"font-medium",children:s.name}),e.jsx(o,{variant:s.active?"default":"secondary",children:s.active?"Active":"Inactive"}),e.jsx(o,{variant:"outline",children:s.category})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.description}),e.jsxs("div",{className:"flex items-center space-x-4 mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used by: ",s.usage]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Updated: ",s.lastUpdated]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(w,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(j,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(u,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(g,{className:"h-4 w-4"})})]})]},s.id))})})]}),e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(n,{children:"Create New Prompt"}),e.jsx(c,{children:"Design a new system prompt for your AI agents and integrations."})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptName",children:"Prompt Name"}),e.jsx(l,{id:"promptName",placeholder:"Enter prompt name"})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptCategory",children:"Category"}),e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(N,{placeholder:"Select category"})}),e.jsx(y,{children:x.map(s=>e.jsx(b,{value:s.toLowerCase(),children:s},s))})]})]})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptDescription",children:"Description"}),e.jsx(l,{id:"promptDescription",placeholder:"Brief description of the prompt's purpose"})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"targetIntegrations",children:"Target Integrations"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:["cursor-cli","claude-code","gemini-cli","github-copilot"].map(s=>e.jsxs("label",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",className:"rounded"}),e.jsx("span",{className:"text-sm",children:s})]},s))})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptContent",children:"Prompt Content"}),e.jsx("textarea",{id:"promptContent",className:"w-full min-h-[200px] p-3 border rounded-md font-mono text-sm",placeholder:"You are an expert code reviewer. Your task is to..."})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptVariables",children:"Variables (JSON format)"}),e.jsx("textarea",{id:"promptVariables",className:"w-full min-h-[100px] p-3 border rounded-md font-mono text-sm",placeholder:'{"language": "typescript", "framework": "react", "style": "functional"}'})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(r,{variant:"outline",children:"Preview"}),e.jsx(r,{variant:"outline",children:"Save as Draft"}),e.jsx(r,{children:"Save & Activate"})]})]})]}),e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(n,{children:"Prompt Templates"}),e.jsx(c,{children:"Import and export prompt templates for sharing across teams."})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(r,{variant:"outline",size:"sm",children:[e.jsx(C,{className:"h-4 w-4 mr-2"}),"Import Template"]}),e.jsx(r,{variant:"outline",size:"sm",children:"Export All Prompts"}),e.jsx(r,{variant:"outline",size:"sm",children:"Export Selected"})]}),e.jsx("div",{className:"p-4 border-2 border-dashed rounded-lg text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag and drop prompt template files here, or click to browse"})})]})]})]})}export{U as default};
@@ -0,0 +1 @@
1
+ import{x as Z,u as ee,a as se,r as a,A as u,j as e,B as i,ae as te,af as A,m as ae,F as M,X as ie,aq as re,ar as le,as as ne,at as oe}from"./index-DFcWlnzl.js";import{B as ce}from"./badge-BUEY53dV.js";import{c as W}from"./clipboard-B9ndUJKl.js";import{A as B}from"./arrow-left-1S-835kP.js";import{L as de,H as me,I as ue,V as xe,M as R,F as he,a as I}from"./video-BH5ChaoS.js";import{D as U}from"./download-Bg__QCLT.js";import{T as fe}from"./tag-p6yeowCW.js";function ke(){const{id:x}=Z(),b=ee(),{toast:o}=se(),[s,p]=a.useState(null),[G,C]=a.useState(!0),[L,h]=a.useState(null),[r,j]=a.useState(null),[f,F]=a.useState(!1),[g,c]=a.useState(!1),[V,E]=a.useState(!1),[S,T]=a.useState(!1);a.useEffect(()=>{x&&(C(!0),h(null),fetch(`${u}/api/v1/resources/${x}`).then(t=>{if(!t.ok)throw new Error(`Resource not found (${t.status})`);if(t.headers.get("content-type")?.includes("application/json"))return t.json();throw new Error("NEED_METADATA")}).then(t=>{if(t.success&&t.data)p(t.data);else if(t.id)p(t);else throw new Error("Invalid response")}).catch(async t=>{if(t.message==="NEED_METADATA")try{const d=await(await fetch(`${u}/api/v1/resources`)).json();if(d.success&&d.data){const m=d.data.find(Q=>Q.id===x);if(m){p(m);return}}h("Resource not found")}catch{h("Failed to load resource")}else h(t.message||"Failed to load resource")}).finally(()=>C(!1)))},[x]),a.useEffect(()=>{T(!1)},[s?.id]);const l=s?`${u}/api/v1/resources/${s.id}`:"",w=s?.thumbnailPath?`${u}/api/v1/resources/${s.id}/thumbnail`:"",D=s?.type.startsWith("image/")??!1,P=s?s.type==="image/svg+xml"||s.name.toLowerCase().endsWith(".svg"):!1,_=s?s.type==="application/pdf"||s.name.toLowerCase().endsWith(".pdf"):!1,H=s?.type.startsWith("video/")??!1,J=s?.type.startsWith("audio/")??!1,v=s?s.type.startsWith("text/")||s.type==="application/json"||s.type.includes("javascript")||s.type.includes("typescript")||s.type.includes("xml")||s.name.toLowerCase().match(/\.(txt|md|json|js|ts|jsx|tsx|css|html|xml|yaml|yml|log|sh|bash|zsh|fish)$/)!==null:!1,N=s?s.name.toLowerCase().endsWith(".md")||s.name.toLowerCase().endsWith(".markdown"):!1,y=s?s.type==="application/json"||s.name.toLowerCase().endsWith(".json"):!1,k=s?s.type==="text/html"||s.name.toLowerCase().endsWith(".html"):!1;a.useEffect(()=>{s&&(v||N||y||k)?(F(!0),fetch(l).then(t=>{if(t.ok)return t.text();throw new Error("Failed to load file")}).then(t=>j(t)).catch(t=>{console.error("Failed to load text content:",t),j(null)}).finally(()=>F(!1))):j(null)},[s?.id,v,N,y,k,l]),a.useEffect(()=>{const t=n=>{n.key==="Escape"&&g&&c(!1)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[g]);const O=t=>{if(t===0)return"0 B";const n=1024,d=["B","KB","MB","GB"],m=Math.floor(Math.log(t)/Math.log(n));return parseFloat((t/Math.pow(n,m)).toFixed(2))+" "+d[m]},K=t=>new Date(t).toLocaleString(),z=t=>t.startsWith("image/")?e.jsx(ue,{className:"h-6 w-6"}):t.startsWith("video/")?e.jsx(xe,{className:"h-6 w-6"}):t.startsWith("audio/")?e.jsx(R,{className:"h-6 w-6"}):t.includes("text")||t.includes("document")||t.includes("code")?e.jsx(M,{className:"h-6 w-6"}):t.includes("json")||t.includes("javascript")||t.includes("typescript")?e.jsx(he,{className:"h-6 w-6"}):e.jsx(re,{className:"h-6 w-6"}),$=()=>{s&&window.open(`${u}/api/v1/resources/${s.id}?download=true`)},Y=async()=>{if(s)try{const t=`.nut/resources/files/${s.path}`;await W(t),o({title:"Path copied!",description:`Copied ${t} to clipboard`})}catch{o({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},q=async()=>{if(s)try{const t=`${window.location.origin}/resources/${s.id}`;await W(t),E(!0),o({title:"Link copied!",description:"Share link copied to clipboard"}),setTimeout(()=>E(!1),2e3)}catch{o({title:"Failed to copy",description:"Unable to copy link to clipboard",variant:"destructive"})}},X=()=>{if(!s)return null;if(P)return e.jsxs(e.Fragment,{children:[e.jsx("img",{src:l,alt:s.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(i,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>c(!0),children:e.jsx(I,{className:"h-4 w-4"})})]});if(_)return e.jsx("iframe",{src:l,className:"w-full h-full min-h-[600px] rounded-lg border",title:s.name});if(H)return e.jsx("video",{src:l,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg",children:"Your browser does not support the video tag."});if(J)return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(R,{className:"h-24 w-24 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-6 bg-muted/30 flex justify-center",children:e.jsx("audio",{src:l,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]});if(N&&r!==null)return f?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6 prose prose-sm dark:prose-invert max-w-none",children:e.jsx(le,{remarkPlugins:[oe],rehypePlugins:[ne],children:r})});if(k&&r!==null)return f?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("iframe",{srcDoc:r,className:"w-full h-full min-h-[600px] rounded-lg border",title:s.name,sandbox:"allow-same-origin"});if(y&&r!==null){if(f)return e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})});let t=r;try{const n=JSON.parse(r);t=JSON.stringify(n,null,2)}catch{}return e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto",children:e.jsx("code",{children:t})})})}return v&&r!==null?f?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto whitespace-pre-wrap",children:e.jsx("code",{children:r})})}):D?e.jsxs(e.Fragment,{children:[w&&!S&&e.jsx("img",{src:w,alt:s.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg blur-[2px] scale-[1.01]"}),e.jsx("img",{src:l,alt:s.name,className:`max-w-full max-h-full object-contain rounded-lg shadow-lg ${w&&!S?"absolute inset-0 m-auto opacity-0":""}`,onLoad:()=>T(!0)}),e.jsx(i,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>c(!0),children:e.jsx(I,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[z(s.type),e.jsx("p",{className:"text-sm",children:"Preview not available for this file type"}),e.jsxs(i,{variant:"outline",onClick:$,children:[e.jsx(U,{className:"mr-2 h-4 w-4"}),"Download to view"]})]})};return G?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading resource..."})}):L||!s?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:L||"Resource not found"}),e.jsxs(i,{variant:"outline",onClick:()=>b("/resources"),children:[e.jsx(B,{className:"mr-2 h-4 w-4"}),"Back to Resources"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"px-6 py-4 flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(i,{variant:"ghost",size:"icon",onClick:()=>b("/resources"),title:"Back to Resources",children:e.jsx(B,{className:"h-4 w-4"})}),z(s.type),e.jsxs("div",{className:"min-w-0 flex items-baseline gap-3",children:[e.jsx("h1",{className:"text-xl font-semibold truncate",children:s.name}),e.jsx("p",{className:"text-sm text-muted-foreground flex-shrink-0",children:s.type})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:q,title:"Copy share link",children:V?e.jsx(te,{className:"h-4 w-4"}):e.jsx(de,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:Y,title:"Copy path to clipboard",children:e.jsx(A,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:$,title:"Download",children:e.jsx(U,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 relative flex items-center justify-center bg-muted/30 p-6 overflow-hidden border rounded-lg",children:X()}),e.jsx("div",{className:"p-6 flex-shrink-0 bg-background",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-x-6 gap-y-2 md:grid-cols-2 text-sm",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Size:"}),e.jsx("span",{children:O(s.size)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Uploaded:"}),e.jsx("span",{children:K(s.uploadedAt)})]})]}),e.jsx("div",{className:"space-y-2",children:s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map(t=>e.jsx(ce,{variant:"secondary",className:"text-xs",children:t},t))})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.metadata.description?e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Description:"}),e.jsx("span",{className:"truncate flex-1",title:s.metadata.description,children:s.metadata.description})]}):e.jsx("div",{className:"flex-1"}),s.metadata.generationPrompt&&e.jsxs(i,{size:"sm",className:"h-6 text-xs px-2 flex-shrink-0",onClick:()=>{navigator.clipboard.writeText(s.metadata.generationPrompt||""),o({title:"Prompt copied!",description:"Generation prompt copied to clipboard"})},children:[e.jsx(A,{className:"h-2.5 w-2.5 mr-1"}),"Copy Prompt"]})]})]})})]}),g&&(D||P)&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black/95 flex items-center justify-center",onClick:()=>c(!1),children:[e.jsx(i,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 h-10 w-10 text-white hover:bg-white/20",onClick:()=>c(!1),children:e.jsx(ie,{className:"h-6 w-6"})}),e.jsx("img",{src:l,alt:s.name,className:"max-w-[95vw] max-h-[95vh] object-contain",onClick:t=>t.stopPropagation()})]})]})}export{ke as default};