@lovelybunch/api 1.0.76-alpha.10 → 1.0.76-alpha.12

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 (142) hide show
  1. package/dist/lib/git.d.ts +3 -0
  2. package/dist/lib/git.js +35 -0
  3. package/dist/routes/api/v1/ai/route.js +56 -149
  4. package/dist/routes/api/v1/git/index.js +27 -1
  5. package/dist/routes/api/v1/jobs/[id]/route.d.ts +12 -18
  6. package/dist/routes/api/v1/jobs/[id]/route.js +3 -3
  7. package/dist/routes/api/v1/jobs/route.d.ts +19 -19
  8. package/dist/routes/api/v1/jobs/route.js +17 -2
  9. package/dist/routes/api/v1/mcp/index.js +27 -19
  10. package/dist/routes/api/v1/resources/generate/route.js +10 -3
  11. package/dist/routes/api/v1/slack/route.d.ts +6 -6
  12. package/package.json +4 -4
  13. package/static/assets/{ActivityPage-B3rsYt_4.js → ActivityPage-BJJTUKh9.js} +1 -1
  14. package/static/assets/{AgentsContextEditPage-4D7qO4S-.js → AgentsContextEditPage-DdBAbiaZ.js} +1 -1
  15. package/static/assets/{AgentsContextPage-NmvLRo0k.js → AgentsContextPage-C49ImhHO.js} +1 -1
  16. package/static/assets/{ApiKeysSettingsPage-BGj5p9zw.js → ApiKeysSettingsPage-CYl8BKyY.js} +1 -1
  17. package/static/assets/{ArchitectureEditPage-DI2jNmc9.js → ArchitectureEditPage-Bj3Bg_pV.js} +1 -1
  18. package/static/assets/{ArchitecturePage-DiIuThUM.js → ArchitecturePage-B4REANhO.js} +1 -1
  19. package/static/assets/{AuthSettingsPage-DWuwxAS0.js → AuthSettingsPage-CvobAtkW.js} +1 -1
  20. package/static/assets/{CallbackPage-BCmkYhEr.js → CallbackPage-Cg68HItO.js} +1 -1
  21. package/static/assets/{CodePage-BZhIkymg.js → CodePage-BgIQAm3x.js} +1 -1
  22. package/static/assets/{CollapsibleSection-BJzLVd-x.js → CollapsibleSection-B80EDHZL.js} +1 -1
  23. package/static/assets/{DashboardPage-DtwE553F.js → DashboardPage-KtwwIk4u.js} +1 -1
  24. package/static/assets/{GitPage-qG7VYL9b.js → GitPage-U50MBUc2.js} +1 -1
  25. package/static/assets/{GitSettingsPage-C8Bgpj-X.js → GitSettingsPage-CVJFc5Cz.js} +1 -1
  26. package/static/assets/{IdentityPage-Cf8Ruu-g.js → IdentityPage-B_prxEfP.js} +1 -1
  27. package/static/assets/{ImplementationStepsEditor-BXIRT7o1.js → ImplementationStepsEditor-7737WSoi.js} +1 -1
  28. package/static/assets/{IntegrationsSettingsPage-th56kUgi.js → IntegrationsSettingsPage-CzmVKesF.js} +1 -1
  29. package/static/assets/JobDetailPage-61LKyh2y.js +1 -0
  30. package/static/assets/{KnowledgeDetailPage-BklEOfs0.js → KnowledgeDetailPage-DF8VINWX.js} +1 -1
  31. package/static/assets/{KnowledgeEditPage-BGqzVqHi.js → KnowledgeEditPage-BPqv8dm5.js} +1 -1
  32. package/static/assets/{KnowledgePage-Dmm7vzAj.js → KnowledgePage-DK2ZmTOW.js} +1 -1
  33. package/static/assets/{LoginPage-PDafaEnq.js → LoginPage-BJoMiSzz.js} +1 -1
  34. package/static/assets/MailInboxPage-D7kppimo.js +1 -0
  35. package/static/assets/MailProcessingModal-CiU2tPrl.js +1 -0
  36. package/static/assets/MailReadPage-C6Uk8fuE.js +1 -0
  37. package/static/assets/{MailSentPage-CjBrbezf.js → MailSentPage-BC08nLUD.js} +1 -1
  38. package/static/assets/{McpSettingsPage-DxE-4YPc.js → McpSettingsPage-CdNU_m5E.js} +1 -1
  39. package/static/assets/{MemoryEditPage-BlQ5EN1w.js → MemoryEditPage-CrMnRGDo.js} +1 -1
  40. package/static/assets/{MemoryPage-B8fsgW7z.js → MemoryPage-BXzS3NzY.js} +1 -1
  41. package/static/assets/{NewKnowledgePage-CuH201xQ.js → NewKnowledgePage-Ia0GhoF_.js} +1 -1
  42. package/static/assets/{NewSkillPage-BdX7eNoi.js → NewSkillPage-B-lKmYIT.js} +1 -1
  43. package/static/assets/{NewTaskPage-D9W2Yi0r.js → NewTaskPage-B9sYSebW.js} +1 -1
  44. package/static/assets/{NotFoundPage-D9tmTVho.js → NotFoundPage-CFh8ZpUq.js} +1 -1
  45. package/static/assets/{NotificationsSettingsPage-B4lBxS8D.js → NotificationsSettingsPage-CkW0hhZp.js} +1 -1
  46. package/static/assets/{ProjectEditPage-DdqUI91K.js → ProjectEditPage-CERVEYfa.js} +1 -1
  47. package/static/assets/{ProjectPage-DB7ugw8l.js → ProjectPage-smlgt2WA.js} +1 -1
  48. package/static/assets/{PromptsSettingsPage-DFXoKUjj.js → PromptsSettingsPage-rmH7tCbI.js} +1 -1
  49. package/static/assets/{ResourceDetailPage-CWc4YIMc.js → ResourceDetailPage-JYYH_eYN.js} +1 -1
  50. package/static/assets/ResourcesPage-Bxo0L-YJ.js +41 -0
  51. package/static/assets/{RoleEditPage-B20UAC2r.js → RoleEditPage-DUxyu-Pf.js} +1 -1
  52. package/static/assets/{RolePage-C5Jf7wxY.js → RolePage-Bxtbnhzq.js} +1 -1
  53. package/static/assets/{RulesSettingsPage-91WP1FQf.js → RulesSettingsPage-Bq85g3dZ.js} +1 -1
  54. package/static/assets/RunDetailPage-Bmr-OpEH.js +1 -0
  55. package/static/assets/SchedulePage-DVFrtK_u.js +4 -0
  56. package/static/assets/{SkillDetailPage-Cpxz_wmk.js → SkillDetailPage-DLVeAMHh.js} +1 -1
  57. package/static/assets/{SkillEditPage-Cz7VRg0r.js → SkillEditPage-L8qO7aXB.js} +1 -1
  58. package/static/assets/{SkillsPage-Bxmsi6Xd.js → SkillsPage-Dbk0ZdCj.js} +1 -1
  59. package/static/assets/{SkillsSettingsPage-Cysx53Au.js → SkillsSettingsPage-D1LF96aM.js} +1 -1
  60. package/static/assets/{SourceInput-D59F7hff.js → SourceInput-s6cvxCld.js} +1 -1
  61. package/static/assets/{TagInput-BH6wDXWJ.js → TagInput-B6t8mWa1.js} +1 -1
  62. package/static/assets/{TaskDetailPage-5ktdWaTr.js → TaskDetailPage-CFKiBp4N.js} +1 -1
  63. package/static/assets/{TaskEditPage-CIZWp_s4.js → TaskEditPage-CU1Nh5Wt.js} +1 -1
  64. package/static/assets/{TasksPage-BNXDm-Er.js → TasksPage-ChyoBFb1.js} +1 -1
  65. package/static/assets/{TeamEditPage-C10siqme.js → TeamEditPage-BiH1cvW_.js} +1 -1
  66. package/static/assets/{TeamPage-CXpZVAfy.js → TeamPage-CZgCevCv.js} +1 -1
  67. package/static/assets/{TerminalPage-DJ-Tu_hG.js → TerminalPage-CnMHrceg.js} +1 -1
  68. package/static/assets/{TerminalSessionPage-BLryJlkL.js → TerminalSessionPage-CWRmxO5F.js} +1 -1
  69. package/static/assets/{UserPreferencesPage-BvAcv5tt.js → UserPreferencesPage-DBAMcnVw.js} +1 -1
  70. package/static/assets/{UserSettingsPage-NQfoOvHf.js → UserSettingsPage-DaJ5ULZ6.js} +1 -1
  71. package/static/assets/{UtilitiesPage-NnBCWVn8.js → UtilitiesPage-DK2tA2dg.js} +1 -1
  72. package/static/assets/{alert-CMfexl-V.js → alert-BLA1YxSF.js} +1 -1
  73. package/static/assets/{arrow-down-7VoAlw8h.js → arrow-down-BS_gkmFX.js} +1 -1
  74. package/static/assets/{arrow-left-CkQCXG-O.js → arrow-left-BMmwy6t5.js} +1 -1
  75. package/static/assets/{arrow-up-Bozm6eto.js → arrow-up-DEdQz7h4.js} +1 -1
  76. package/static/assets/{arrow-up-down-BgZelEPF.js → arrow-up-down-BfLyyRID.js} +1 -1
  77. package/static/assets/{badge-CKqDVhJv.js → badge-DXtacKLi.js} +1 -1
  78. package/static/assets/{browser-modal-CIOZi1Jw.js → browser-modal-C-EJH5-l.js} +1 -1
  79. package/static/assets/{card-jBf8qQSy.js → card-T1Zl_t-O.js} +1 -1
  80. package/static/assets/{chevron-left-D1qHCYRd.js → chevron-left-CHIuYPig.js} +1 -1
  81. package/static/assets/{chevron-up-CcwaoTsZ.js → chevron-up-C1j8XcMS.js} +1 -1
  82. package/static/assets/{chevrons-up-BtlNQbrw.js → chevrons-up-CJo8Mkrm.js} +1 -1
  83. package/static/assets/{circle-alert-DqK0nUqF.js → circle-alert-C-TQDAZH.js} +1 -1
  84. package/static/assets/{circle-check-qo4cPVA1.js → circle-check-D4Eo7NeP.js} +1 -1
  85. package/static/assets/{circle-check-big-DDQIqE0G.js → circle-check-big-Dw0wgLkY.js} +1 -1
  86. package/static/assets/{circle-play-CQ-UItmT.js → circle-play-XYouMl6A.js} +1 -1
  87. package/static/assets/{circle-x-Bd57ohC5.js → circle-x-i-p09ZTc.js} +1 -1
  88. package/static/assets/{clipboard-JQLlAwqS.js → clipboard-CAJMRUqv.js} +1 -1
  89. package/static/assets/{clock-DTp411N-.js → clock-t6EXtqFH.js} +1 -1
  90. package/static/assets/{code-Bi-U-NxE.js → code-CQveJCBf.js} +1 -1
  91. package/static/assets/{download-DNaE6rtO.js → download-gURwTJ4j.js} +1 -1
  92. package/static/assets/{external-link-DRsIhdWR.js → external-link-B6lRGdDG.js} +1 -1
  93. package/static/assets/{eye-jqpFU8Rl.js → eye-BmQvWYqM.js} +1 -1
  94. package/static/assets/{folder-git-2-ixHmuqNj.js → folder-git-2-Y7dQhpIc.js} +1 -1
  95. package/static/assets/{globe-BZEWER4V.js → globe-DZ1sD-ad.js} +1 -1
  96. package/static/assets/index-6zt5f3rT.js +502 -0
  97. package/static/assets/{index-BGKQ2Csq.js → index-B-EQGkgp.js} +1 -1
  98. package/static/assets/{index-CtWTFIFI.js → index-BDAqiMeO.js} +1 -1
  99. package/static/assets/{index-2_Tb936f.js → index-BKsuLLw3.js} +1 -1
  100. package/static/assets/{index-BD47WGC6.js → index-BQ6h7obM.js} +1 -1
  101. package/static/assets/index-BcCuKdbf.css +1 -0
  102. package/static/assets/{index-htJaaOEZ.js → index-C7-vaKc0.js} +1 -1
  103. package/static/assets/{index-M-XcYp88.js → index-CEVCklYW.js} +1 -1
  104. package/static/assets/{index-B8B_4B2l.js → index-CdbMr7EO.js} +1 -1
  105. package/static/assets/{index-DHAvHhw0.js → index-Cop1vyXt.js} +1 -1
  106. package/static/assets/{index-CK5AHHmM.js → index-Ct1TqN9g.js} +1 -1
  107. package/static/assets/{index-D-5sddKG.js → index-CvaJ85WT.js} +1 -1
  108. package/static/assets/{index-BLjvGp1F.js → index-DHyZkKDt.js} +1 -1
  109. package/static/assets/{index-C3ao8yMv.js → index-DeFIoxHB.js} +1 -1
  110. package/static/assets/{index-CoeRBZRl.js → index-DiWum-Qk.js} +1 -1
  111. package/static/assets/{index-DffngCzC.js → index-DkcxAJRd.js} +1 -1
  112. package/static/assets/{index-UDlexUv4.js → index-JMlWoOlR.js} +1 -1
  113. package/static/assets/{index-Bft1WzL9.js → index-d2atEU4g.js} +1 -1
  114. package/static/assets/{index-CdmUQF6-.js → index-p7Qpxih7.js} +1 -1
  115. package/static/assets/{index-CiS46Fde.js → index-q465oP8l.js} +1 -1
  116. package/static/assets/{info-Na9GqbtC.js → info-gGFJAYNn.js} +1 -1
  117. package/static/assets/{label-CHVVHrlr.js → label-CSt-eWXG.js} +1 -1
  118. package/static/assets/{markdown-editor-CT9CPLw5.js → markdown-editor-C6ZusrL3.js} +3 -3
  119. package/static/assets/{message-square-B5NR6hzj.js → message-square-B-XWYk3x.js} +1 -1
  120. package/static/assets/{paperclip-SI0kWfGf.js → paperclip-Drtxq0HD.js} +1 -1
  121. package/static/assets/{pause-DKI9nsrI.js → pause-fdtoI1yQ.js} +1 -1
  122. package/static/assets/{play-BTA0gBuh.js → play-BjJrEDlO.js} +1 -1
  123. package/static/assets/{radio-group-BO2__pxZ.js → radio-group-CLFgSQkD.js} +1 -1
  124. package/static/assets/{refresh-cw-DLJpfa8_.js → refresh-cw-DF2wDnWT.js} +1 -1
  125. package/static/assets/{search-SRuczbr5.js → search-CYS9xEgy.js} +1 -1
  126. package/static/assets/{select-D8HyxWyg.js → select-C7W_IjpH.js} +1 -1
  127. package/static/assets/{switch-Ck0OeSLk.js → switch-CeUexKh7.js} +1 -1
  128. package/static/assets/{tabs-CmFe8eVW.js → tabs-CqVmSyiJ.js} +1 -1
  129. package/static/assets/{tag-BTjGQC_2.js → tag-Mob815Ck.js} +1 -1
  130. package/static/assets/{terminal-preview-BkQIuk__.js → terminal-preview-Byv2z2nW.js} +1 -1
  131. package/static/assets/triangle-alert-DW7a6_v9.js +6 -0
  132. package/static/assets/{use-terminal-CrqBojgD.js → use-terminal-CQe1dgj2.js} +1 -1
  133. package/static/assets/{video-BlwRNgSo.js → video-Ovebr1Iq.js} +1 -1
  134. package/static/index.html +2 -2
  135. package/static/assets/JobDetailPage-ZyEcbPAe.js +0 -1
  136. package/static/assets/MailInboxPage-M5_2gGkB.js +0 -1
  137. package/static/assets/MailProcessingModal-C4PotIFc.js +0 -6
  138. package/static/assets/MailReadPage-D32FUx5o.js +0 -1
  139. package/static/assets/ResourcesPage-BK-EXoIA.js +0 -41
  140. package/static/assets/SchedulePage-BijprHGn.js +0 -4
  141. package/static/assets/index-BWhM9fZn.js +0 -502
  142. package/static/assets/index-oRAlpULD.css +0 -1
@@ -1 +1 @@
1
- import{r as d,bE as A,w as i,j as e,bD as K,e as f,n as j,C as y,ae as v,I as N,B as r,H as b,a1 as k,h as $}from"./index-BWhM9fZn.js";import{C as _,b as E,c as F,d as M,a as G}from"./card-jBf8qQSy.js";import{L as m}from"./label-CHVVHrlr.js";import{S as Q,a as W,b as X,c as Z,d as ee}from"./select-D8HyxWyg.js";import{G as se}from"./globe-BZEWER4V.js";import"./index-CdmUQF6-.js";import"./chevron-up-CcwaoTsZ.js";const te=[{id:"openai/gpt-4o",label:"GPT-4o",provider:"openai",supportsMCP:!0,strengths:["balanced","reasoning","code","tools"],notes:"Great general model with tool/function calling support."},{id:"openai/gpt-4o-mini",label:"GPT-4o Mini",provider:"openai",supportsMCP:!0,strengths:["cost-effective","fast","tools"],notes:"Good for quick, inexpensive tasks with function calling."},{id:"openai/gpt-4.1",label:"GPT-4.1",provider:"openai",supportsMCP:!0,strengths:["coding","instruction following","long context"],notes:"Latest GPT-4 series with enhanced capabilities."},{id:"openai/o3-mini",label:"o3-mini",provider:"openai",supportsMCP:!0,strengths:["reasoning","math","coding"],notes:"Reasoning model optimized for efficiency."},{id:"anthropic/claude-sonnet-4.5",label:"Claude Sonnet 4.5",provider:"anthropic",supportsMCP:!0,strengths:["agents","coding","tools","fast","long context"],notes:"Most advanced Sonnet - 1.5-2x faster, optimized for agents and tool orchestration."},{id:"anthropic/claude-sonnet-4",label:"Claude Sonnet 4",provider:"anthropic",supportsMCP:!0,strengths:["reasoning","analysis","tools","coding"],notes:"Excellent tool use and reasoning capabilities."},{id:"anthropic/claude-3.5-sonnet",label:"Claude 3.5 Sonnet",provider:"anthropic",supportsMCP:!0,strengths:["reasoning","analysis","tools"],notes:"Reliable Claude model with strong tool support."},{id:"google/gemini-2.0-flash-001",label:"Gemini 2.0 Flash",provider:"google",supportsMCP:!0,strengths:["speed","multimodal","tools"],notes:"Fast Google model with function calling."},{id:"meta-llama/llama-3.1-405b-instruct",label:"Llama 3.1 405B",provider:"meta-llama",supportsMCP:!0,strengths:["reasoning","open weights","code"],notes:"High-capacity open model; function calling often available."},{id:"qwen/qwen-2.5-72b-instruct",label:"Qwen 2.5 72B",provider:"qwen",supportsMCP:!0,strengths:["cost-effective","code","tools"],notes:"Strong value open model with tool support."}],ae={models:te},re=ae;function z(){return re.models}function xe(){const[t,O]=d.useState({}),[n,R]=d.useState(!0),[D,L]=d.useState(!1),[x,U]=d.useState({}),[I,q]=d.useState({}),[H,Y]=d.useState(z()[0]?.id||"openai/gpt-4o"),[l,J]=d.useState({openrouter:!1,replicate:!1,anthropic:!1,openai:!1,gemini:!1,factorydroid:!1,callbackToken:!1});d.useEffect(()=>{P()},[]);const P=async()=>{try{R(!0);const s=await A("/api/v1/config?type=global");if(s.success&&s.data){const a=s.data.apiKeys||{},o={},c={};for(const C of["openrouter","replicate","anthropic","openai","gemini","factorydroid","callbackToken"]){const S=a[C];S&&typeof S=="string"&&S.trim()!==""?(o[C]=!0,c[C]="***"):(o[C]=!1,c[C]="")}O(c);const T=s.data.defaults&&s.data.defaults.model?String(s.data.defaults.model):void 0;Y(T||z()[0]?.id||"openai/gpt-4o")}}catch(s){console.error("Failed to load API keys:",s),i({title:"Error",description:"Failed to load API keys",variant:"destructive"})}finally{R(!1)}},p=(s,a)=>{O(o=>({...o,[s]:a}))},B=async s=>{try{q(T=>({...T,[s]:!0}));const a=t[s],o={provider:s};a&&a!=="***"&&(o.key=a);const c=await A("/api/v1/config/test",{method:"POST",body:JSON.stringify(o)});c.success&&c.message?i({title:"Test Result",description:c.message}):c.success?i({title:"Test Result",description:"Success"}):i({title:"Test Failed",description:c.message||"Unknown error",variant:"destructive"})}catch(a){i({title:"Test Failed",description:a instanceof Error?a.message:"Unknown error",variant:"destructive"})}finally{q(a=>({...a,[s]:!1}))}},h=s=>{J(a=>({...a,[s]:!a[s]}))},u=async s=>{try{const a={[s]:""};await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),i({title:"Success",description:`${s} API key cleared`}),await P()}catch(a){console.error("Failed to clear API key:",a),i({title:"Error",description:"Failed to clear API key",variant:"destructive"})}},g=async s=>{try{U(o=>({...o,[s]:!0}));const a={[s]:t[s]};await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),i({title:"Success",description:`${s} API key saved`}),await P()}catch(a){console.error("Failed to save API key:",a),i({title:"Error",description:"Failed to save API key",variant:"destructive"})}finally{U(a=>({...a,[s]:!1}))}},V=async()=>{try{L(!0),await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({defaults:{model:H}})}),i({title:"Success",description:"Default model saved successfully"})}catch(s){console.error("Failed to save default model:",s),i({title:"Error",description:"Failed to save default model",variant:"destructive"})}finally{L(!1)}},w={openrouter:"OPENROUTER_API_KEY",replicate:"REPLICATE_API_TOKEN",anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GEMINI_API_KEY",factorydroid:"FACTORY_API_KEY"};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"AI & LLM"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Coconut's connections to LLM providers."})]}),e.jsx(K,{}),e.jsxs(_,{children:[e.jsxs(E,{children:[e.jsx(F,{children:"API Keys & Authentication"}),e.jsx(M,{children:"Manage API keys and authentication tokens for integrated services."})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"AI Assistant API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used by the AI Assistant sidebar for chat and code suggestions."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("openrouter"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.openrouter&&t.openrouter!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.openrouter?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenRouter"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.openrouter})]})]}),t.openrouter&&t.openrouter!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.openrouter&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openrouterKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"openrouterKey",type:"password",placeholder:"sk-or-v1-...",className:"flex-1",value:t.openrouter||"",onChange:s=>p("openrouter",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openrouter"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>B("openrouter"),disabled:!!I.openrouter,title:"Test API key",children:I.openrouter?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openrouter"),disabled:x.openrouter||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenRouter"})]})]})]}),e.jsx(K,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Resource Creation API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used for generating images and other resources."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("replicate"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.replicate&&t.replicate!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.replicate?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Replicate"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.replicate})]})]}),t.replicate&&t.replicate!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.replicate&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"replicateKey",children:"API Token"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"replicateKey",type:"password",placeholder:"r8_...",className:"flex-1",value:t.replicate||"",onChange:s=>p("replicate",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("replicate"),title:"Clear API token",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>B("replicate"),disabled:!!I.replicate,title:"Test API token",children:I.replicate?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("replicate"),disabled:x.replicate||n,title:"Save API token",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token from"," ",e.jsx("a",{href:"https://replicate.com/account/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Replicate"})]})]})]}),e.jsx(K,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Coding Agent API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These keys are automatically provided to coding agents when they start running."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("anthropic"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.anthropic&&t.anthropic!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.anthropic?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Anthropic Claude"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.anthropic})]})]}),t.anthropic&&t.anthropic!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.anthropic&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"anthropicKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"anthropicKey",type:"password",placeholder:"sk-ant-...",className:"flex-1",value:t.anthropic||"",onChange:s=>p("anthropic",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("anthropic"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("anthropic"),disabled:x.anthropic||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://console.anthropic.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Anthropic Console"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("openai"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.openai&&t.openai!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.openai?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenAI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.openai})]})]}),t.openai&&t.openai!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.openai&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openaiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"openaiKey",type:"password",placeholder:"sk-...",className:"flex-1",value:t.openai||"",onChange:s=>p("openai",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openai"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openai"),disabled:x.openai||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenAI Platform"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("gemini"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.gemini&&t.gemini!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.gemini?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Google Gemini"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.gemini})]})]}),t.gemini&&t.gemini!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.gemini&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"geminiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"geminiKey",type:"password",placeholder:"AIza...",className:"flex-1",value:t.gemini||"",onChange:s=>p("gemini",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("gemini"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("gemini"),disabled:x.gemini||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://makersuite.google.com/app/apikey",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Google AI Studio"})]})]})]}),e.jsxs("div",{className:"border rounded-lg mt-4",children:[e.jsxs("button",{onClick:()=>h("factorydroid"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.factorydroid&&t.factorydroid!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.factorydroid?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Factory Droid"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.factorydroid})]})]}),t.factorydroid&&t.factorydroid!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.factorydroid&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"factorydroidKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"factorydroidKey",type:"password",placeholder:"fd-...",className:"flex-1",value:t.factorydroid||"",onChange:s=>p("factorydroid",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("factorydroid"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("factorydroid"),disabled:x.factorydroid||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://factorydroid.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Factory Droid"})]})]})]})]})]}),e.jsxs(_,{children:[e.jsxs(E,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-5 w-5"}),e.jsx(F,{children:"Coconut Control Plane"})]}),e.jsxs(M,{children:["Connect to the"," ",e.jsx("a",{href:"https://app.coconut.dev",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Coconut Dashboard"})," ","to access third-party connectors (Google Drive, Slack, HubSpot, Stripe, and more)."]})]}),e.jsx(G,{className:"space-y-4",children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("callbackToken"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.callbackToken&&t.callbackToken!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.callbackToken?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Callback Token"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"COCONUT_CALLBACK_TOKEN"})]})]}),t.callbackToken&&t.callbackToken!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.callbackToken&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"callbackTokenKey",children:"Callback Token"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"callbackTokenKey",type:"password",placeholder:"cpt_...",className:"flex-1",value:t.callbackToken||"",onChange:s=>p("callbackToken",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("callbackToken"),title:"Clear callback token",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("callbackToken"),disabled:x.callbackToken||n,title:"Save callback token",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Find your callback token in the"," ",e.jsx("a",{href:"https://app.coconut.dev",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Coconut Dashboard"}),". This token enables the ",e.jsx("code",{className:"text-xs",children:"list_connectors"})," and ",e.jsx("code",{className:"text-xs",children:"connector_request"})," tools."]})]})]})})]}),e.jsxs(_,{children:[e.jsxs(E,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),e.jsx(F,{children:"AI Assistant Settings"})]}),e.jsx(M,{children:"Configure default AI model and behavior for the AI assistant sidebar."})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"defaultModel",children:"Default AI Model"}),e.jsxs(Q,{value:H,onValueChange:Y,children:[e.jsx(W,{children:e.jsx(X,{placeholder:"Select default AI model"})}),e.jsx(Z,{children:z().map(s=>e.jsx(ee,{value:s.id,children:s.label},s.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This model will be selected by default when opening the AI assistant."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(r,{onClick:V,disabled:D||n,children:D?"Saving...":"Save"})})]})]})]})}export{xe as default};
1
+ import{r as d,bE as A,w as i,j as e,bD as K,e as f,n as j,C as y,ae as v,I as N,B as r,H as b,a1 as k,h as $}from"./index-6zt5f3rT.js";import{C as _,b as E,c as F,d as M,a as G}from"./card-T1Zl_t-O.js";import{L as m}from"./label-CSt-eWXG.js";import{S as Q,a as W,b as X,c as Z,d as ee}from"./select-C7W_IjpH.js";import{G as se}from"./globe-DZ1sD-ad.js";import"./index-p7Qpxih7.js";import"./chevron-up-C1j8XcMS.js";const te=[{id:"openai/gpt-4o",label:"GPT-4o",provider:"openai",supportsMCP:!0,strengths:["balanced","reasoning","code","tools"],notes:"Great general model with tool/function calling support."},{id:"openai/gpt-4o-mini",label:"GPT-4o Mini",provider:"openai",supportsMCP:!0,strengths:["cost-effective","fast","tools"],notes:"Good for quick, inexpensive tasks with function calling."},{id:"openai/gpt-4.1",label:"GPT-4.1",provider:"openai",supportsMCP:!0,strengths:["coding","instruction following","long context"],notes:"Latest GPT-4 series with enhanced capabilities."},{id:"openai/o3-mini",label:"o3-mini",provider:"openai",supportsMCP:!0,strengths:["reasoning","math","coding"],notes:"Reasoning model optimized for efficiency."},{id:"anthropic/claude-sonnet-4.5",label:"Claude Sonnet 4.5",provider:"anthropic",supportsMCP:!0,strengths:["agents","coding","tools","fast","long context"],notes:"Most advanced Sonnet - 1.5-2x faster, optimized for agents and tool orchestration."},{id:"anthropic/claude-sonnet-4",label:"Claude Sonnet 4",provider:"anthropic",supportsMCP:!0,strengths:["reasoning","analysis","tools","coding"],notes:"Excellent tool use and reasoning capabilities."},{id:"anthropic/claude-3.5-sonnet",label:"Claude 3.5 Sonnet",provider:"anthropic",supportsMCP:!0,strengths:["reasoning","analysis","tools"],notes:"Reliable Claude model with strong tool support."},{id:"google/gemini-2.0-flash-001",label:"Gemini 2.0 Flash",provider:"google",supportsMCP:!0,strengths:["speed","multimodal","tools"],notes:"Fast Google model with function calling."},{id:"meta-llama/llama-3.1-405b-instruct",label:"Llama 3.1 405B",provider:"meta-llama",supportsMCP:!0,strengths:["reasoning","open weights","code"],notes:"High-capacity open model; function calling often available."},{id:"qwen/qwen-2.5-72b-instruct",label:"Qwen 2.5 72B",provider:"qwen",supportsMCP:!0,strengths:["cost-effective","code","tools"],notes:"Strong value open model with tool support."}],ae={models:te},re=ae;function z(){return re.models}function xe(){const[t,O]=d.useState({}),[n,R]=d.useState(!0),[D,L]=d.useState(!1),[x,U]=d.useState({}),[I,q]=d.useState({}),[H,Y]=d.useState(z()[0]?.id||"openai/gpt-4o"),[l,J]=d.useState({openrouter:!1,replicate:!1,anthropic:!1,openai:!1,gemini:!1,factorydroid:!1,callbackToken:!1});d.useEffect(()=>{P()},[]);const P=async()=>{try{R(!0);const s=await A("/api/v1/config?type=global");if(s.success&&s.data){const a=s.data.apiKeys||{},o={},c={};for(const C of["openrouter","replicate","anthropic","openai","gemini","factorydroid","callbackToken"]){const S=a[C];S&&typeof S=="string"&&S.trim()!==""?(o[C]=!0,c[C]="***"):(o[C]=!1,c[C]="")}O(c);const T=s.data.defaults&&s.data.defaults.model?String(s.data.defaults.model):void 0;Y(T||z()[0]?.id||"openai/gpt-4o")}}catch(s){console.error("Failed to load API keys:",s),i({title:"Error",description:"Failed to load API keys",variant:"destructive"})}finally{R(!1)}},p=(s,a)=>{O(o=>({...o,[s]:a}))},B=async s=>{try{q(T=>({...T,[s]:!0}));const a=t[s],o={provider:s};a&&a!=="***"&&(o.key=a);const c=await A("/api/v1/config/test",{method:"POST",body:JSON.stringify(o)});c.success&&c.message?i({title:"Test Result",description:c.message}):c.success?i({title:"Test Result",description:"Success"}):i({title:"Test Failed",description:c.message||"Unknown error",variant:"destructive"})}catch(a){i({title:"Test Failed",description:a instanceof Error?a.message:"Unknown error",variant:"destructive"})}finally{q(a=>({...a,[s]:!1}))}},h=s=>{J(a=>({...a,[s]:!a[s]}))},u=async s=>{try{const a={[s]:""};await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),i({title:"Success",description:`${s} API key cleared`}),await P()}catch(a){console.error("Failed to clear API key:",a),i({title:"Error",description:"Failed to clear API key",variant:"destructive"})}},g=async s=>{try{U(o=>({...o,[s]:!0}));const a={[s]:t[s]};await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),i({title:"Success",description:`${s} API key saved`}),await P()}catch(a){console.error("Failed to save API key:",a),i({title:"Error",description:"Failed to save API key",variant:"destructive"})}finally{U(a=>({...a,[s]:!1}))}},V=async()=>{try{L(!0),await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({defaults:{model:H}})}),i({title:"Success",description:"Default model saved successfully"})}catch(s){console.error("Failed to save default model:",s),i({title:"Error",description:"Failed to save default model",variant:"destructive"})}finally{L(!1)}},w={openrouter:"OPENROUTER_API_KEY",replicate:"REPLICATE_API_TOKEN",anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GEMINI_API_KEY",factorydroid:"FACTORY_API_KEY"};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"AI & LLM"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Coconut's connections to LLM providers."})]}),e.jsx(K,{}),e.jsxs(_,{children:[e.jsxs(E,{children:[e.jsx(F,{children:"API Keys & Authentication"}),e.jsx(M,{children:"Manage API keys and authentication tokens for integrated services."})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"AI Assistant API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used by the AI Assistant sidebar for chat and code suggestions."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("openrouter"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.openrouter&&t.openrouter!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.openrouter?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenRouter"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.openrouter})]})]}),t.openrouter&&t.openrouter!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.openrouter&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openrouterKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"openrouterKey",type:"password",placeholder:"sk-or-v1-...",className:"flex-1",value:t.openrouter||"",onChange:s=>p("openrouter",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openrouter"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>B("openrouter"),disabled:!!I.openrouter,title:"Test API key",children:I.openrouter?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openrouter"),disabled:x.openrouter||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenRouter"})]})]})]}),e.jsx(K,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Resource Creation API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used for generating images and other resources."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("replicate"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.replicate&&t.replicate!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.replicate?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Replicate"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.replicate})]})]}),t.replicate&&t.replicate!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.replicate&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"replicateKey",children:"API Token"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"replicateKey",type:"password",placeholder:"r8_...",className:"flex-1",value:t.replicate||"",onChange:s=>p("replicate",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("replicate"),title:"Clear API token",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>B("replicate"),disabled:!!I.replicate,title:"Test API token",children:I.replicate?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("replicate"),disabled:x.replicate||n,title:"Save API token",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token from"," ",e.jsx("a",{href:"https://replicate.com/account/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Replicate"})]})]})]}),e.jsx(K,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Coding Agent API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These keys are automatically provided to coding agents when they start running."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("anthropic"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.anthropic&&t.anthropic!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.anthropic?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Anthropic Claude"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.anthropic})]})]}),t.anthropic&&t.anthropic!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.anthropic&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"anthropicKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"anthropicKey",type:"password",placeholder:"sk-ant-...",className:"flex-1",value:t.anthropic||"",onChange:s=>p("anthropic",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("anthropic"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("anthropic"),disabled:x.anthropic||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://console.anthropic.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Anthropic Console"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("openai"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.openai&&t.openai!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.openai?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenAI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.openai})]})]}),t.openai&&t.openai!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.openai&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openaiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"openaiKey",type:"password",placeholder:"sk-...",className:"flex-1",value:t.openai||"",onChange:s=>p("openai",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openai"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openai"),disabled:x.openai||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenAI Platform"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("gemini"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.gemini&&t.gemini!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.gemini?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Google Gemini"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.gemini})]})]}),t.gemini&&t.gemini!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.gemini&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"geminiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"geminiKey",type:"password",placeholder:"AIza...",className:"flex-1",value:t.gemini||"",onChange:s=>p("gemini",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("gemini"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("gemini"),disabled:x.gemini||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://makersuite.google.com/app/apikey",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Google AI Studio"})]})]})]}),e.jsxs("div",{className:"border rounded-lg mt-4",children:[e.jsxs("button",{onClick:()=>h("factorydroid"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.factorydroid&&t.factorydroid!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.factorydroid?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Factory Droid"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.factorydroid})]})]}),t.factorydroid&&t.factorydroid!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.factorydroid&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"factorydroidKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"factorydroidKey",type:"password",placeholder:"fd-...",className:"flex-1",value:t.factorydroid||"",onChange:s=>p("factorydroid",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("factorydroid"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("factorydroid"),disabled:x.factorydroid||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://factorydroid.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Factory Droid"})]})]})]})]})]}),e.jsxs(_,{children:[e.jsxs(E,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-5 w-5"}),e.jsx(F,{children:"Coconut Control Plane"})]}),e.jsxs(M,{children:["Connect to the"," ",e.jsx("a",{href:"https://app.coconut.dev",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Coconut Dashboard"})," ","to access third-party connectors (Google Drive, Slack, HubSpot, Stripe, and more)."]})]}),e.jsx(G,{className:"space-y-4",children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("callbackToken"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.callbackToken&&t.callbackToken!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.callbackToken?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Callback Token"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"COCONUT_CALLBACK_TOKEN"})]})]}),t.callbackToken&&t.callbackToken!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.callbackToken&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"callbackTokenKey",children:"Callback Token"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"callbackTokenKey",type:"password",placeholder:"cpt_...",className:"flex-1",value:t.callbackToken||"",onChange:s=>p("callbackToken",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("callbackToken"),title:"Clear callback token",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("callbackToken"),disabled:x.callbackToken||n,title:"Save callback token",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Find your callback token in the"," ",e.jsx("a",{href:"https://app.coconut.dev",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Coconut Dashboard"}),". This token enables the ",e.jsx("code",{className:"text-xs",children:"list_connectors"})," and ",e.jsx("code",{className:"text-xs",children:"connector_request"})," tools."]})]})]})})]}),e.jsxs(_,{children:[e.jsxs(E,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),e.jsx(F,{children:"AI Assistant Settings"})]}),e.jsx(M,{children:"Configure default AI model and behavior for the AI assistant sidebar."})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"defaultModel",children:"Default AI Model"}),e.jsxs(Q,{value:H,onValueChange:Y,children:[e.jsx(W,{children:e.jsx(X,{placeholder:"Select default AI model"})}),e.jsx(Z,{children:z().map(s=>e.jsx(ee,{value:s.id,children:s.label},s.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This model will be selected by default when opening the AI assistant."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(r,{onClick:V,disabled:D||n,children:D?"Saving...":"Save"})})]})]})]})}export{xe as default};
@@ -0,0 +1 @@
1
+ import{y as Y,u as Z,a as ee,ad as se,r as l,j as e,B as d,L as p,v as D,z as te,E as ae,H as re,J as ne,N as ie,O as de,Q as le,R as ce,U as oe,V as me,k as z,a4 as ue,C as xe,_ as he,bD as B,m as je,A as C}from"./index-6zt5f3rT.js";import{c as pe}from"./clipboard-B9ndUJKl.js";import{C as c,b as f,a as o,c as g,d as H}from"./card-T1Zl_t-O.js";import{B as N}from"./badge-DXtacKLi.js";import{A as $}from"./arrow-left-BMmwy6t5.js";import{P as A}from"./play-BjJrEDlO.js";import{C as fe,a as ge}from"./clipboard-CAJMRUqv.js";import{R as Ne}from"./refresh-cw-DF2wDnWT.js";import{P as be}from"./pause-fdtoI1yQ.js";import{C as O}from"./clock-t6EXtqFH.js";const ve=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"},{id:"kiro",label:"Kiro"}],b=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},T=a=>{if(!a)return"—";const n=new Date(a).getTime()-Date.now(),i=Math.round(n/(1e3*60));if(Number.isNaN(i))return b(a);if(Math.abs(i)<1)return"now";if(i>0){if(i<60)return`in ${i}m`;const x=Math.round(i/60);return x<24?`in ${x}h`:`in ${Math.round(x/24)}d`}const s=Math.abs(i);if(s<60)return`${s}m ago`;const u=Math.round(s/60);return u<24?`${u}h ago`:`${Math.round(u/24)}d ago`},we=a=>{if(a.type==="interval"){const m=a.daysOfWeek.map(n=>n.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${m||"All days"})`}return a.description||`Cron: ${a.expression}`},ye=a=>{const m=ve.find(n=>n.id===a);return m?m.label:a},R=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}};function Je(){const{id:a}=Y(),m=Z(),{toast:n}=ee(),{refresh:i}=se(),[s,u]=l.useState(null),[E,x]=l.useState(!0),[v,I]=l.useState(null),[J,P]=l.useState(!1),[k,M]=l.useState(!1),[h,F]=l.useState(!1),[G,U]=l.useState(!1),S=async()=>{if(a)try{x(!0);const r=await(await fetch(`${C}/api/v1/jobs/${a}`)).json();r.success?u(r.data):I(r.error?.message||"Failed to fetch job")}catch(t){I(t instanceof Error?t.message:"Unknown error")}finally{x(!1)}};l.useEffect(()=>{S()},[a]);const V=async()=>{if(a){P(!0);try{const r=await(await fetch(`${C}/api/v1/jobs/${a}`,{method:"DELETE"})).json();r.success?(n({title:"Job deleted",description:s?.name||"Scheduled job has been deleted"}),m("/schedule")):n({title:"Failed to delete job",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(t){n({title:"Failed to delete job",description:t instanceof Error?t.message:"Unknown error",variant:"destructive"})}finally{P(!1)}}},q=async()=>{if(!s||!a)return;M(!0);const t=s.status==="active"?"paused":"active";try{const j=await(await fetch(`${C}/api/v1/jobs/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})})).json();j.success?(u(j.data),await i(),n({title:t==="active"?"Job resumed":"Job paused",description:s.name})):n({title:"Failed to update job",description:j.error?.message||"Unknown error",variant:"destructive"})}catch(r){n({title:"Failed to update job",description:r instanceof Error?r.message:"Unknown error",variant:"destructive"})}finally{M(!1)}},L=async()=>{if(!(!s||!a)){F(!0);try{const t=await fetch(`${C}/api/v1/jobs/${a}/run`,{method:"POST"}),r=await t.json();r.success||t.ok?(n({title:"Run started",description:`${s.name} is executing.`}),await S(),await i()):n({title:"Failed to start run",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(t){n({title:"Failed to start run",description:t instanceof Error?t.message:"Unknown error",variant:"destructive"})}finally{F(!1)}}},K=(t,r)=>{if(!r)return"—";const j=new Date(r).getTime()-new Date(t).getTime();if(j<1e3)return"<1s";const w=Math.floor(j/1e3);if(w<60)return`${w}s`;const y=Math.floor(w/60),Q=w%60;if(y<60)return`${y}m ${Q}s`;const W=Math.floor(y/60),X=y%60;return`${W}h ${X}m`};if(E)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx(d,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx($,{className:"h-4 w-4"})})})]}),e.jsxs(c,{children:[e.jsx(f,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]})}),e.jsx(o,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-5/6 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-4/6 animate-pulse"})]})})]})]});if(v||!s)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("h3",{className:"text-lg font-semibold text-destructive",children:v||"Job not found"})}),e.jsx(d,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx($,{className:"h-4 w-4"})})})]}),e.jsx(c,{children:e.jsx(o,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:v||"Job not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The job with ID "',a,'" could not be found.']}),e.jsx(d,{asChild:!0,className:"mt-4",children:e.jsx(p,{to:"/schedule",children:"Back to Schedule"})})]})})})]});const _=s.agentIds||(s.agentId?[s.agentId]:[]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.name}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(d,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(p,{to:"/schedule",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx($,{className:"h-4 w-4"})})}),e.jsxs(d,{variant:"default",size:"sm",onClick:L,disabled:h||!!s._error,children:[h?e.jsx(D,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(A,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:h?"Running...":"Run Now"})]}),e.jsxs(te,{children:[e.jsx(ae,{asChild:!0,children:e.jsxs(d,{variant:"destructive",size:"sm",disabled:J,children:[e.jsx(re,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:J?"Deleting...":"Delete"})]})}),e.jsxs(ne,{children:[e.jsxs(ie,{children:[e.jsx(de,{children:"Are you absolutely sure?"}),e.jsxs(le,{children:["This action cannot be undone. This will permanently delete the scheduled job",e.jsxs("span",{className:"font-semibold",children:[' "',s.name,'"']}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(ce,{children:[e.jsx(oe,{children:"Cancel"}),e.jsx(me,{onClick:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Job"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const t=`.nut/jobs/job-${s.id}.md`;try{await pe(t),U(!0),n({title:"Copied!",description:`${t} copied to clipboard`}),setTimeout(()=>U(!1),2e3)}catch(r){console.error("Failed to copy path:",r),n({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono",children:[e.jsx("span",{children:`.nut/jobs/job-${s.id}.md`}),G?e.jsx(fe,{className:"h-3.5 w-3.5"}):e.jsx(ge,{className:"h-3.5 w-3.5"})]})]}),s._error&&e.jsx(c,{className:"border-destructive/50 bg-destructive/5",children:e.jsxs(o,{className:"pt-6",children:[e.jsx("p",{className:"text-sm text-destructive font-medium",children:s._error}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Please review the job file at ",e.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:[".nut/jobs/job-",s.id,".md"]})]})]})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(c,{children:[e.jsxs(f,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(g,{children:"Job Configuration"}),e.jsx(N,{variant:R(s.status),className:"capitalize",children:s.status})]}),s.description&&e.jsx(H,{children:s.description})]}),e.jsxs(o,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Instructions"}),e.jsx("div",{className:"rounded-md bg-muted/50 p-3 font-mono text-sm whitespace-pre-wrap",children:s.prompt})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"AI Model"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:ye(s.model)})]})]}),_.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Custom Agents"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:_.map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800 text-xs",children:[e.jsx(z,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-100",children:t.replace(".md","")})]},t))})]}),s.mcpServers&&s.mcpServers.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"MCP Servers"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.mcpServers.map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-purple-50 dark:bg-purple-950/20 border border-purple-200 dark:border-purple-800 text-xs",children:[e.jsx(ue,{className:"h-3 w-3 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"font-medium text-purple-900 dark:text-purple-100",children:t})]},t))})]})]})]})]}),e.jsxs(c,{children:[e.jsx(f,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(g,{children:"Run History"}),e.jsxs(H,{children:[s.runs.length," recorded run",s.runs.length!==1?"s":""]})]}),e.jsxs(d,{variant:"outline",size:"sm",onClick:S,children:[e.jsx(Ne,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})}),e.jsx(o,{children:s.runs.length===0?e.jsx("div",{className:"rounded-md border border-dashed bg-muted/20 p-6 text-center text-sm text-muted-foreground",children:'No runs yet. Click "Run Now" to execute this job.'}):e.jsx("div",{className:"space-y-1.5",children:s.runs.map(t=>e.jsxs(p,{to:`/schedule/${a}/run/${t.id}`,className:"flex items-center gap-3 p-3 rounded-md border bg-card/50 hover:bg-accent/50 transition-colors group",children:[e.jsx(N,{variant:R(t.status),className:"capitalize text-xs shrink-0",children:t.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:b(t.startedAt)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",T(t.startedAt),")"]}),t.finishedAt&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["• ",K(t.startedAt,t.finishedAt)]})]}),t.error&&e.jsx("p",{className:"text-xs text-destructive font-medium mt-0.5 line-clamp-1",children:t.error})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.trigger==="manual"&&e.jsx(N,{variant:"outline",className:"text-xs",children:"manual"}),e.jsx(xe,{className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})]},t.id))})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(c,{children:[e.jsx(f,{children:e.jsx(g,{children:"Actions"})}),e.jsxs(o,{className:"space-y-2",children:[e.jsxs(d,{variant:"default",className:"w-full justify-start",onClick:L,disabled:h||!!s._error,children:[h?e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(A,{className:"h-4 w-4 mr-2"}),h?"Running...":"Run Now"]}),e.jsxs(d,{variant:"outline",className:"w-full justify-start",onClick:q,disabled:k||!!s._error,children:[k?e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}):s.status==="active"?e.jsx(be,{className:"h-4 w-4 mr-2"}):e.jsx(A,{className:"h-4 w-4 mr-2"}),k?"Updating...":s.status==="active"?"Pause Job":"Resume Job"]}),e.jsx(d,{variant:"outline",className:"w-full justify-start",asChild:!0,disabled:!!s._error,children:e.jsxs(p,{to:"/schedule",state:{editJobId:s.id},children:[e.jsx(he,{className:"h-4 w-4 mr-2"}),"Edit Job"]})})]})]}),e.jsxs(c,{children:[e.jsx(f,{children:e.jsx(g,{children:"Schedule"})}),e.jsxs(o,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(O,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:we(s.schedule)})]}),s.schedule.type==="interval"&&s.schedule.anchorHour!==void 0&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Start hour:"})," ",e.jsxs("span",{children:[s.schedule.anchorHour,":00"]})]}),e.jsx(B,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Next run:"}),e.jsx("span",{className:"font-medium",children:T(s.metadata.nextRunAt)})]}),s.metadata.nextRunAt&&e.jsx("div",{className:"text-xs text-muted-foreground",children:b(s.metadata.nextRunAt)})]})]})]}),e.jsxs(c,{children:[e.jsx(f,{children:e.jsx(g,{children:"Information"})}),e.jsxs(o,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(je,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Created:"}),e.jsx("span",{children:b(s.metadata.createdAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(O,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Updated:"}),e.jsx("span",{children:b(s.metadata.updatedAt)})]}),s.metadata.lastRunAt&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(A,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Last run:"}),e.jsx("span",{children:T(s.metadata.lastRunAt)})]}),e.jsx(B,{}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Status:"}),e.jsx("div",{className:"mt-1",children:e.jsx(N,{variant:R(s.status),className:"capitalize",children:s.status})})]}),s.tags&&s.tags.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:s.tags.map(t=>e.jsx(N,{variant:"outline",className:"text-xs",children:t},t))})]})]})]})]})]})]})}export{Je as default};
@@ -1 +1 @@
1
- import{y as A,u as T,a as $,r as i,A as p,j as e,v as g,B as o,L as x,M as F,_ as L,z as S,E as z,H as P,J as B,N as K,O as U,Q as _,R as H,U as M,V as R,ae as q,af as I,m as V,$ as W}from"./index-BWhM9fZn.js";import{C as d,a as m,b as J,c as O}from"./card-jBf8qQSy.js";import{B as Q}from"./badge-CKqDVhJv.js";import{c as G}from"./clipboard-B9ndUJKl.js";import{A as j}from"./arrow-left-CkQCXG-O.js";import{T as X}from"./tag-BTjGQC_2.js";import{E as Y}from"./external-link-DRsIhdWR.js";function Z(n){return typeof n=="string"?n.startsWith("http://")||n.startsWith("https://")?{title:n,url:n}:{title:n}:n}function ie(){const n=A(),v=T(),{toast:r}=$(),l=n.filename,[s,N]=i.useState(null),[w,k]=i.useState(!0),[h,u]=i.useState(!1),[y,f]=i.useState(!1);i.useEffect(()=>{l&&C()},[l]);const C=async()=>{try{const a=await(await fetch(`${p}/api/v1/knowledge/${l}`)).json();a.success?N(a.document):r({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}catch(t){console.error("Error fetching document:",t),r({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}finally{k(!1)}},D=async()=>{if(!s)return;const t=`.nut/knowledge/${s.filename}`;try{await G(t),f(!0),setTimeout(()=>f(!1),2e3),r({title:"Copied!",description:`Path copied to clipboard: ${t}`})}catch(a){console.error("Failed to copy path:",a),r({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},b=()=>{if(!s)return;const t=new CustomEvent("discuss-in-chat",{detail:{type:"knowledge",id:`knowledge-${s.filename.replace(".md","")}`,filename:s.filename,name:s.filename,path:`.nut/knowledge/${s.filename}`}});window.dispatchEvent(t)},E=async()=>{if(s){u(!0);try{const a=await(await fetch(`${p}/api/v1/knowledge/${l}`,{method:"DELETE"})).json();a.success?(r({title:"Success",description:"Knowledge document deleted successfully"}),v("/knowledge")):r({title:"Error",description:a.error||"Failed to delete knowledge document",variant:"destructive"})}catch(t){console.error("Error deleting document:",t),r({title:"Error",description:"Failed to delete knowledge document",variant:"destructive"})}finally{u(!1)}}};return w?e.jsx("div",{className:"space-y-6",children:e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(g,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):s?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.title}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(o,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(x,{to:"/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})}),e.jsxs(o,{variant:"outline",size:"sm",onClick:b,children:[e.jsx(F,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsx(o,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(x,{to:`/knowledge/${l}/edit`,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(S,{children:[e.jsx(z,{asChild:!0,children:e.jsxs(o,{variant:"destructive",size:"sm",children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})}),e.jsxs(B,{children:[e.jsxs(K,{children:[e.jsx(U,{children:"Delete Knowledge Document"}),e.jsxs(_,{children:["Are you sure you want to delete “",s.title,"”? This action cannot be undone."]})]}),e.jsxs(H,{children:[e.jsx(M,{children:"Cancel"}),e.jsx(R,{onClick:E,disabled:h,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:h?e.jsx(g,{className:"w-4 h-4 animate-spin"}):"Delete"})]})]})]})]})]}),e.jsx("div",{className:"text-left",children:e.jsxs("button",{type:"button",onClick:D,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono text-left",children:[e.jsxs("span",{className:"break-all",children:[".nut/knowledge/",s.filename]}),y?e.jsx(q,{className:"h-3.5 w-3.5 flex-shrink-0 text-green-600"}):e.jsx(I,{className:"h-3.5 w-3.5 flex-shrink-0"})]})})]}),e.jsxs("div",{className:"flex flex-col gap-2 text-sm text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(V,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Updated ",s.metadata.updated]})]}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-start gap-1.5 sm:items-center",children:[e.jsx(X,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5 sm:mt-0"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map((t,a)=>e.jsx(Q,{variant:"outline",className:"text-xs",children:t},a))})]})]}),s.metadata.sources&&s.metadata.sources.length>0&&e.jsxs(d,{children:[e.jsx(J,{children:e.jsx(O,{children:"Sources"})}),e.jsx(m,{children:e.jsx("ul",{className:"space-y-2",children:s.metadata.sources.map((t,a)=>{const c=Z(t);return e.jsx("li",{children:c.url?e.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-foreground hover:text-primary transition-colors group",children:[e.jsx("span",{className:"group-hover:underline",children:c.title}),e.jsx(Y,{className:"w-3.5 h-3.5 text-muted-foreground group-hover:text-primary flex-shrink-0"})]}):e.jsx("span",{className:"text-muted-foreground",children:c.title})},a)})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsx(W,{children:s.content})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(o,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(x,{to:"/knowledge",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"The requested knowledge document could not be found."})]})})})]})}export{ie as default};
1
+ import{y as A,u as T,a as $,r as i,A as p,j as e,v as g,B as o,L as x,M as F,_ as L,z as S,E as z,H as P,J as B,N as K,O as U,Q as _,R as H,U as M,V as R,ae as q,af as I,m as V,$ as W}from"./index-6zt5f3rT.js";import{C as d,a as m,b as J,c as O}from"./card-T1Zl_t-O.js";import{B as Q}from"./badge-DXtacKLi.js";import{c as G}from"./clipboard-B9ndUJKl.js";import{A as j}from"./arrow-left-BMmwy6t5.js";import{T as X}from"./tag-Mob815Ck.js";import{E as Y}from"./external-link-B6lRGdDG.js";function Z(n){return typeof n=="string"?n.startsWith("http://")||n.startsWith("https://")?{title:n,url:n}:{title:n}:n}function ie(){const n=A(),v=T(),{toast:r}=$(),l=n.filename,[s,N]=i.useState(null),[w,k]=i.useState(!0),[h,u]=i.useState(!1),[y,f]=i.useState(!1);i.useEffect(()=>{l&&C()},[l]);const C=async()=>{try{const a=await(await fetch(`${p}/api/v1/knowledge/${l}`)).json();a.success?N(a.document):r({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}catch(t){console.error("Error fetching document:",t),r({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}finally{k(!1)}},D=async()=>{if(!s)return;const t=`.nut/knowledge/${s.filename}`;try{await G(t),f(!0),setTimeout(()=>f(!1),2e3),r({title:"Copied!",description:`Path copied to clipboard: ${t}`})}catch(a){console.error("Failed to copy path:",a),r({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},b=()=>{if(!s)return;const t=new CustomEvent("discuss-in-chat",{detail:{type:"knowledge",id:`knowledge-${s.filename.replace(".md","")}`,filename:s.filename,name:s.filename,path:`.nut/knowledge/${s.filename}`}});window.dispatchEvent(t)},E=async()=>{if(s){u(!0);try{const a=await(await fetch(`${p}/api/v1/knowledge/${l}`,{method:"DELETE"})).json();a.success?(r({title:"Success",description:"Knowledge document deleted successfully"}),v("/knowledge")):r({title:"Error",description:a.error||"Failed to delete knowledge document",variant:"destructive"})}catch(t){console.error("Error deleting document:",t),r({title:"Error",description:"Failed to delete knowledge document",variant:"destructive"})}finally{u(!1)}}};return w?e.jsx("div",{className:"space-y-6",children:e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(g,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):s?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.title}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(o,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(x,{to:"/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})}),e.jsxs(o,{variant:"outline",size:"sm",onClick:b,children:[e.jsx(F,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsx(o,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(x,{to:`/knowledge/${l}/edit`,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(S,{children:[e.jsx(z,{asChild:!0,children:e.jsxs(o,{variant:"destructive",size:"sm",children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})}),e.jsxs(B,{children:[e.jsxs(K,{children:[e.jsx(U,{children:"Delete Knowledge Document"}),e.jsxs(_,{children:["Are you sure you want to delete “",s.title,"”? This action cannot be undone."]})]}),e.jsxs(H,{children:[e.jsx(M,{children:"Cancel"}),e.jsx(R,{onClick:E,disabled:h,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:h?e.jsx(g,{className:"w-4 h-4 animate-spin"}):"Delete"})]})]})]})]})]}),e.jsx("div",{className:"text-left",children:e.jsxs("button",{type:"button",onClick:D,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono text-left",children:[e.jsxs("span",{className:"break-all",children:[".nut/knowledge/",s.filename]}),y?e.jsx(q,{className:"h-3.5 w-3.5 flex-shrink-0 text-green-600"}):e.jsx(I,{className:"h-3.5 w-3.5 flex-shrink-0"})]})})]}),e.jsxs("div",{className:"flex flex-col gap-2 text-sm text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(V,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Updated ",s.metadata.updated]})]}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-start gap-1.5 sm:items-center",children:[e.jsx(X,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5 sm:mt-0"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map((t,a)=>e.jsx(Q,{variant:"outline",className:"text-xs",children:t},a))})]})]}),s.metadata.sources&&s.metadata.sources.length>0&&e.jsxs(d,{children:[e.jsx(J,{children:e.jsx(O,{children:"Sources"})}),e.jsx(m,{children:e.jsx("ul",{className:"space-y-2",children:s.metadata.sources.map((t,a)=>{const c=Z(t);return e.jsx("li",{children:c.url?e.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-foreground hover:text-primary transition-colors group",children:[e.jsx("span",{className:"group-hover:underline",children:c.title}),e.jsx(Y,{className:"w-3.5 h-3.5 text-muted-foreground group-hover:text-primary flex-shrink-0"})]}):e.jsx("span",{className:"text-muted-foreground",children:c.title})},a)})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsx(W,{children:s.content})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(o,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(x,{to:"/knowledge",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"The requested knowledge document could not be found."})]})})})]})}export{ie as default};
@@ -1 +1 @@
1
- import{y as $,u as z,a as B,r as a,A as E,j as e,v as S,B as h,L as M,a1 as D,X as K,I as R}from"./index-BWhM9fZn.js";import{C as d,a as l,b as x,c as p}from"./card-jBf8qQSy.js";import{L as g}from"./label-CHVVHrlr.js";import{M as U}from"./markdown-editor-CT9CPLw5.js";import{T as _}from"./TagInput-BH6wDXWJ.js";import{n as H,S as J}from"./SourceInput-D59F7hff.js";import{A as O}from"./arrow-left-CkQCXG-O.js";import"./index-CdmUQF6-.js";import"./badge-CKqDVhJv.js";import"./external-link-DRsIhdWR.js";function se(){const y=$(),i=z(),{toast:n}=B(),r=y.filename,[m,T]=a.useState(null),[L,b]=a.useState(!0),[u,f]=a.useState(!1),[o,j]=a.useState(""),[c,v]=a.useState(""),[w,N]=a.useState([]),[k,C]=a.useState([]);a.useEffect(()=>{r&&A()},[r]);const A=async()=>{try{const t=await(await fetch(`${E}/api/v1/knowledge/${r}`)).json();t.success?(T(t.document),j(t.document.title),v(t.document.content),N(t.document.metadata.tags||[]),C(H(t.document.metadata.sources))):(n({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/knowledge"))}catch(s){console.error("Error fetching document:",s),n({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/knowledge")}finally{b(!1)}},F=async()=>{if(m){if(!o.trim()){n({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!c.trim()){n({title:"Error",description:"Please provide content for the knowledge document",variant:"destructive"});return}f(!0);try{const t=await(await fetch(`${E}/api/v1/knowledge/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:o.trim(),content:c.trim(),metadata:{tags:w,sources:k}})})).json();if(t.success){n({title:"Success",description:"Knowledge document updated successfully"});const P=t.document.filename.replace(".md","");i(`/knowledge/${P}`,{replace:!0})}else n({title:"Error",description:t.error||"Failed to update knowledge document",variant:"destructive"})}catch(s){console.error("Error updating document:",s),n({title:"Error",description:"Failed to update knowledge document",variant:"destructive"})}finally{f(!1)}}},I=()=>{i(`/knowledge/${r}`)};return L?e.jsx("div",{className:"space-y-6",children:e.jsx(d,{children:e.jsx(l,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(S,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):m?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Document"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:m.filename})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(M,{to:"/knowledge",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(h,{onClick:F,disabled:u||!o.trim()||!c.trim(),size:"sm",children:[u?e.jsx(S,{className:"w-4 h-4 animate-spin sm:mr-2"}):e.jsx(D,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:u?"Saving...":"Save"})]}),e.jsxs(h,{onClick:I,variant:"outline",size:"sm",children:[e.jsx(K,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Cancel"})]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(p,{children:"Basic Information"})}),e.jsx(l,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(g,{htmlFor:"title",children:"Title *"}),e.jsx(R,{id:"title",value:o,onChange:s=>j(s.target.value),placeholder:"Enter document title...",className:"text-lg"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Changing the title will rename the file"})]})})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(p,{children:"Metadata"})}),e.jsxs(l,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(g,{children:"Tags"}),e.jsx(_,{tags:w,onChange:N,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(g,{children:"Sources"}),e.jsx(J,{sources:k,onChange:C})]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(p,{children:"Content *"})}),e.jsx(l,{children:e.jsx(U,{value:c,onChange:s=>v(s||""),placeholder:"Enter your knowledge content in Markdown..."})})]})]}):null}export{se as default};
1
+ import{y as $,u as z,a as B,r as a,A as E,j as e,v as S,B as h,L as M,a1 as D,X as K,I as R}from"./index-6zt5f3rT.js";import{C as d,a as l,b as x,c as p}from"./card-T1Zl_t-O.js";import{L as g}from"./label-CSt-eWXG.js";import{M as U}from"./markdown-editor-C6ZusrL3.js";import{T as _}from"./TagInput-B6t8mWa1.js";import{n as H,S as J}from"./SourceInput-s6cvxCld.js";import{A as O}from"./arrow-left-BMmwy6t5.js";import"./index-p7Qpxih7.js";import"./badge-DXtacKLi.js";import"./external-link-B6lRGdDG.js";function se(){const y=$(),i=z(),{toast:n}=B(),r=y.filename,[m,T]=a.useState(null),[L,b]=a.useState(!0),[u,f]=a.useState(!1),[o,j]=a.useState(""),[c,v]=a.useState(""),[w,N]=a.useState([]),[k,C]=a.useState([]);a.useEffect(()=>{r&&A()},[r]);const A=async()=>{try{const t=await(await fetch(`${E}/api/v1/knowledge/${r}`)).json();t.success?(T(t.document),j(t.document.title),v(t.document.content),N(t.document.metadata.tags||[]),C(H(t.document.metadata.sources))):(n({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/knowledge"))}catch(s){console.error("Error fetching document:",s),n({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/knowledge")}finally{b(!1)}},F=async()=>{if(m){if(!o.trim()){n({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!c.trim()){n({title:"Error",description:"Please provide content for the knowledge document",variant:"destructive"});return}f(!0);try{const t=await(await fetch(`${E}/api/v1/knowledge/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:o.trim(),content:c.trim(),metadata:{tags:w,sources:k}})})).json();if(t.success){n({title:"Success",description:"Knowledge document updated successfully"});const P=t.document.filename.replace(".md","");i(`/knowledge/${P}`,{replace:!0})}else n({title:"Error",description:t.error||"Failed to update knowledge document",variant:"destructive"})}catch(s){console.error("Error updating document:",s),n({title:"Error",description:"Failed to update knowledge document",variant:"destructive"})}finally{f(!1)}}},I=()=>{i(`/knowledge/${r}`)};return L?e.jsx("div",{className:"space-y-6",children:e.jsx(d,{children:e.jsx(l,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(S,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):m?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Document"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:m.filename})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(M,{to:"/knowledge",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(h,{onClick:F,disabled:u||!o.trim()||!c.trim(),size:"sm",children:[u?e.jsx(S,{className:"w-4 h-4 animate-spin sm:mr-2"}):e.jsx(D,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:u?"Saving...":"Save"})]}),e.jsxs(h,{onClick:I,variant:"outline",size:"sm",children:[e.jsx(K,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Cancel"})]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(p,{children:"Basic Information"})}),e.jsx(l,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(g,{htmlFor:"title",children:"Title *"}),e.jsx(R,{id:"title",value:o,onChange:s=>j(s.target.value),placeholder:"Enter document title...",className:"text-lg"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Changing the title will rename the file"})]})})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(p,{children:"Metadata"})}),e.jsxs(l,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(g,{children:"Tags"}),e.jsx(_,{tags:w,onChange:N,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(g,{children:"Sources"}),e.jsx(J,{sources:k,onChange:C})]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(p,{children:"Content *"})}),e.jsx(l,{children:e.jsx(U,{value:c,onChange:s=>v(s||""),placeholder:"Enter your knowledge content in Markdown..."})})]})]}):null}export{se as default};
@@ -1,3 +1,3 @@
1
- import{j as e,S as V,$ as q,u as Q,r as p,a as W,A as R,v as X,B as x,L as P,P as z,F as C,M as K,ae as I,af as M}from"./index-BWhM9fZn.js";import{C as L,a as B}from"./card-jBf8qQSy.js";import{B as j}from"./badge-CKqDVhJv.js";import{c as Z}from"./clipboard-B9ndUJKl.js";import{R as ee,L as O}from"./browser-modal-CIOZi1Jw.js";import{R as te,f as se}from"./registry-ANRa5WBi.js";import{A as ae}from"./arrow-up-down-BgZelEPF.js";import{A as ne}from"./arrow-up-Bozm6eto.js";import{A as re}from"./arrow-down-7VoAlw8h.js";import"./search-SRuczbr5.js";const ie=["createdAt","updatedAt","version","tags"];function U(a){if(a){if(Array.isArray(a)){const l=a.map(i=>{if(typeof i=="string")return i.trim();if(typeof i=="number")return`${i}`}).filter(i=>typeof i=="string"&&i.length>0);return l.length>0?l:void 0}if(typeof a=="string"){const l=a.split(",").map(i=>i.trim()).filter(i=>i.length>0);return l.length>0?l:void 0}}}function oe(a,l){const i=[];if(a.content&&typeof a.content=="object")for(const r of Object.values(a.content))typeof r=="string"&&r.trim().length>0&&i.push(r.trim());const s=[];return s.push(`# ${l}`),a.description?.trim()&&s.push(a.description.trim()),[...s,...i].join(`
1
+ import{j as e,S as V,$ as q,u as Q,r as p,a as W,A as R,v as X,B as x,L as P,P as z,F as C,M as K,ae as I,af as M}from"./index-6zt5f3rT.js";import{C as L,a as B}from"./card-T1Zl_t-O.js";import{B as j}from"./badge-DXtacKLi.js";import{c as Z}from"./clipboard-B9ndUJKl.js";import{R as ee,L as O}from"./browser-modal-C-EJH5-l.js";import{R as te,f as se}from"./registry-ANRa5WBi.js";import{A as ae}from"./arrow-up-down-BfLyyRID.js";import{A as ne}from"./arrow-up-DEdQz7h4.js";import{A as re}from"./arrow-down-BS_gkmFX.js";import"./search-CYS9xEgy.js";const ie=["createdAt","updatedAt","version","tags"];function U(a){if(a){if(Array.isArray(a)){const l=a.map(i=>{if(typeof i=="string")return i.trim();if(typeof i=="number")return`${i}`}).filter(i=>typeof i=="string"&&i.length>0);return l.length>0?l:void 0}if(typeof a=="string"){const l=a.split(",").map(i=>i.trim()).filter(i=>i.length>0);return l.length>0?l:void 0}}}function oe(a,l){const i=[];if(a.content&&typeof a.content=="object")for(const r of Object.values(a.content))typeof r=="string"&&r.trim().length>0&&i.push(r.trim());const s=[];return s.push(`# ${l}`),a.description?.trim()&&s.push(a.description.trim()),[...s,...i].join(`
2
2
 
3
3
  `).trim()}function _(a,l){const i=a.name||l.name,s={registryId:a.id,registryEndpoint:a.endpoint,registrySource:te,author:a.author,category:"general"};for(const r of ie){const o=l[r];if(o!==void 0)if(r==="tags"){const m=U(o);m&&(s[r]=m)}else s[r]=o}!s.version&&a.version&&(s.version=a.version),!s.tags&&a.tags&&(s.tags=U(a.tags));const d=s.tags;if(d){const r=["knowledge","architecture","rules"],o=d.find(m=>r.includes(m.toLowerCase()));o&&(s.type=o.toLowerCase())}for(const[r,o]of Object.entries(s))o==null&&delete s[r];return{title:i,content:oe(l,i),metadata:Object.keys(s).length>0?s:void 0}}function H({open:a,onOpenChange:l,onImport:i}){return e.jsx(ee,{open:a,onOpenChange:l,categoryId:"knowledge",title:"Coconut Registry – Knowledge",confirmLabel:"Import Knowledge",getDetail:s=>se(s.endpoint),renderPreview:(s,d)=>{if(!d)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select a knowledge item to preview"});const r=_(s,d),o=r.metadata??{},m=typeof o.version=="string"?o.version:void 0,h=Array.isArray(s.tags)?s.tags:[],y=typeof o.category=="string"?o.category:"general",w=typeof o.type=="string"?o.type:void 0;return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(V,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:s.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]}),m&&e.jsxs(j,{variant:"outline",children:["v",m]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:s.id})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(j,{variant:"secondary",className:"capitalize",children:y}),w&&e.jsx(j,{variant:"outline",className:"capitalize",children:w})]}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(g=>e.jsx(j,{variant:"secondary",children:g},g))})]}),e.jsx(q,{className:"[&_.prose]:max-w-none",children:r.content})]})})})},onConfirm:async(s,d)=>{const r=_(s,d);await i({summary:s,detail:d,payload:r})}})}const J=a=>{if(!a)return"Unknown";const l=new Date(a);if(Number.isNaN(l.getTime()))return a;const s=new Date().getTime()-l.getTime(),d=Math.floor(s/6e4),r=Math.floor(s/36e5),o=Math.floor(s/864e5);return d<1?"Just now":d<60?`${d} minute${d===1?"":"s"} ago`:r<24?`${r} hour${r===1?"":"s"} ago`:o<7?`${o} day${o===1?"":"s"} ago`:new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(l)};function je(){const a=Q(),[l,i]=p.useState([]),[s,d]=p.useState(!0),[r,o]=p.useState({}),[m,h]=p.useState(!1),[y,w]=p.useState(!1),[g,Y]=p.useState("updated"),[A,S]=p.useState("desc"),{toast:u}=W(),v=p.useCallback(async()=>{d(!0);try{const t=await fetch(`${R}/api/v1/knowledge`);if(!t.ok)throw new Error("Failed to load knowledge");const n=await t.json();i(n.documents||[])}catch(t){console.error("Failed to load knowledge:",t),i([])}finally{d(!1)}},[]);p.useEffect(()=>{v()},[v]);const N=t=>{g===t?S(n=>n==="asc"?"desc":"asc"):(Y(t),S(t==="updated"?"desc":"asc"))},G=[...l].sort((t,n)=>{let c=0;switch(g){case"file":c=(t.title||t.filename).localeCompare(n.title||n.filename);break;case"category":c=(t.metadata.category||"general").localeCompare(n.metadata.category||"general");break;case"updated":{const f=new Date(t.metadata.updated||0).getTime(),$=new Date(n.metadata.updated||0).getTime();c=f-$;break}}return A==="asc"?c:-c}),b=({column:t})=>g!==t?e.jsx(ae,{className:"h-3 w-3 ml-1 opacity-50"}):A==="asc"?e.jsx(ne,{className:"h-3 w-3 ml-1"}):e.jsx(re,{className:"h-3 w-3 ml-1"}),k=async t=>{const n=`.nut/knowledge/${t}`;try{await Z(n),o(c=>({...c,[t]:!0})),setTimeout(()=>{o(c=>({...c,[t]:!1}))},2e3),u({title:"Path copied!",description:`Copied ${n} to clipboard`})}catch(c){console.error("Failed to copy path:",c),u({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},D=t=>{const n=new CustomEvent("discuss-in-chat",{detail:{type:"knowledge",id:`knowledge-${t.filename.replace(".md","")}`,filename:t.filename,name:t.filename,path:`.nut/knowledge/${t.filename}`}});window.dispatchEvent(n)},T=p.useCallback(async({payload:t})=>{let n=!1;w(!0);try{const c=await fetch(`${R}/api/v1/knowledge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t.title,content:t.content,metadata:t.metadata})});let f=null;try{f=await c.json()}catch(E){console.error("Failed to parse registry import response:",E)}if(!(c.ok&&f?.success)){const F=(typeof f?.error=="string"?f.error:f?.error?.message)||c.statusText||"Failed to import knowledge from registry";throw u({title:"Failed to import knowledge",description:F,variant:"destructive"}),n=!0,new Error(F)}u({title:"Knowledge imported",description:`${t.title} is now available in Coconut`}),await v()}catch(c){if(!n){const f=c instanceof Error&&c.message?c.message:"Failed to import knowledge from registry";u({title:"Failed to import knowledge",description:f,variant:"destructive"})}throw c}finally{w(!1)}},[v,u]);return s?e.jsx("div",{className:"space-y-6",children:e.jsx(L,{children:e.jsx(B,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(X,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge base..."})]})})})}):l.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Knowledge Base"}),e.jsx("p",{className:"text-muted-foreground",children:"Accumulated project knowledge, patterns, and best practices"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>h(!0),disabled:y,children:[e.jsx(O,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(x,{size:"sm",asChild:!0,children:e.jsxs(P,{to:"/knowledge/new",children:[e.jsx(z,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx(L,{children:e.jsx(B,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Knowledge Documents Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Knowledge documents will appear here as they are created."})]})})})]}),e.jsx(H,{open:m,onOpenChange:h,onImport:T})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Knowledge Base"}),e.jsxs("p",{className:"text-muted-foreground",children:["Accumulated project knowledge, patterns, and best practices (",l.length," documents)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>h(!0),disabled:y,children:[e.jsx(O,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(x,{size:"sm",asChild:!0,children:e.jsxs(P,{to:"/knowledge/new",children:[e.jsx(z,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsxs("div",{className:"rounded-lg border overflow-hidden",children:[e.jsxs("div",{className:"hidden bg-muted/50 px-4 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground md:grid md:grid-cols-[minmax(0,2.5fr),minmax(0,1fr),minmax(0,1fr),auto] md:items-center md:gap-4",children:[e.jsxs("button",{type:"button",onClick:()=>N("file"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["File",e.jsx(b,{column:"file"})]}),e.jsxs("button",{type:"button",onClick:()=>N("category"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["Category",e.jsx(b,{column:"category"})]}),e.jsxs("button",{type:"button",onClick:()=>N("updated"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["Updated",e.jsx(b,{column:"updated"})]}),e.jsx("span",{className:"justify-self-end",children:"Actions"})]}),e.jsx("div",{className:"divide-y",children:G.map(t=>e.jsxs("div",{onClick:()=>a(`/knowledge/${t.filename.replace(".md","")}`),className:"px-3 py-3 transition-colors hover:bg-muted/60 cursor-pointer md:px-4 md:py-4 md:grid md:grid-cols-[minmax(0,2.5fr),minmax(0,1fr),minmax(0,1fr),auto] md:items-center md:gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 md:hidden",children:[e.jsx("div",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:e.jsx(C,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium text-foreground text-sm",children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(j,{variant:"secondary",className:"capitalize text-[10px] px-1.5 py-0",children:t.metadata.category||"general"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:J(t.metadata.updated)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(x,{variant:"ghost",size:"icon",onClick:n=>{n.stopPropagation(),D(t)},className:"h-7 w-7",title:"Discuss in chat",children:e.jsx(K,{className:"h-3 w-3"})}),e.jsx(x,{variant:"ghost",size:"icon",onClick:n=>{n.stopPropagation(),k(t.filename)},className:"h-7 w-7",title:"Copy file path to clipboard",children:r[t.filename]?e.jsx(I,{className:"h-3 w-3 text-green-600"}):e.jsx(M,{className:"h-3 w-3"})})]})]})})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:e.jsx(C,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("div",{className:"block truncate font-medium text-foreground",children:t.title}),e.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),k(t.filename)},className:`inline-flex max-w-full items-center overflow-hidden rounded bg-muted px-2 py-1 font-mono text-xs text-muted-foreground transition-colors hover:bg-muted/80${r[t.filename]?" ring-1 ring-primary/50 text-foreground":""}`,title:"Copy file path to clipboard",children:e.jsxs("span",{className:"truncate",children:[".nut/knowledge/",t.filename]})})]})]}),e.jsx("div",{className:"hidden md:block",children:e.jsx(j,{variant:"secondary",className:"capitalize",children:t.metadata.category||"general"})}),e.jsx("div",{className:"hidden text-sm text-muted-foreground md:block",children:J(t.metadata.updated)}),e.jsxs("div",{className:"hidden md:flex items-center gap-1 justify-end",children:[e.jsx(x,{variant:"ghost",size:"icon",onClick:n=>{n.stopPropagation(),D(t)},className:"h-8 w-8",title:"Discuss in chat",children:e.jsx(K,{className:"h-3.5 w-3.5"})}),e.jsx(x,{variant:"ghost",size:"icon",onClick:n=>{n.stopPropagation(),k(t.filename)},className:"h-8 w-8",title:"Copy file path to clipboard",children:r[t.filename]?e.jsx(I,{className:"h-3 w-3 text-green-600"}):e.jsx(M,{className:"h-3 w-3"})})]})]},t.filename))})]})]}),e.jsx(H,{open:m,onOpenChange:h,onImport:T})]})}export{je as default};
@@ -1 +1 @@
1
- import{u as I,s as z,t as B,r as t,j as e,v as g,I as l,B as y,w as n}from"./index-BWhM9fZn.js";import{L as c}from"./label-CHVVHrlr.js";import{C as D,b as k,c as H,d as M,a as O}from"./card-jBf8qQSy.js";import{T as V,a as W,b as w,c as N}from"./tabs-CmFe8eVW.js";function Q(){const i=I(),o=z(),{login:b,register:C,isAuthenticated:h,authEnabled:x,isLoading:m}=B(),[a,d]=t.useState(!1),[L,S]=t.useState("login"),[p,E]=t.useState(""),[f,T]=t.useState(""),[j,F]=t.useState(""),[u,P]=t.useState(""),[v,R]=t.useState("");t.useEffect(()=>{if(!m){if(!x)i("/");else if(h){const s=o.state?.from?.pathname||"/";i(s,{replace:!0})}}},[x,h,m,i,o]);const A=async s=>{s.preventDefault(),d(!0);try{await b(p,f),n({title:"Success",description:"Logged in successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Login failed",description:r.message||"Invalid email or password",variant:"destructive"})}finally{d(!1)}},q=async s=>{if(s.preventDefault(),u.length<8){n({title:"Invalid password",description:"Password must be at least 8 characters",variant:"destructive"});return}d(!0);try{await C(j,u,v),n({title:"Success",description:"Account created successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Registration failed",description:r.message||"Failed to create account",variant:"destructive"})}finally{d(!1)}};return m?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(g,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-background to-muted p-4",children:e.jsxs(D,{className:"w-full max-w-md",children:[e.jsxs(k,{className:"space-y-1 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("svg",{className:"h-12 w-12 text-green-600",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z"})})}),e.jsx(H,{className:"text-2xl font-bold",children:"Welcome to Coconut"}),e.jsx(M,{children:"Sign in to your account or create a new one"})]}),e.jsx(O,{children:e.jsxs(V,{value:L,onValueChange:s=>S(s),children:[e.jsxs(W,{className:"grid w-full grid-cols-2",children:[e.jsx(w,{value:"login",children:"Login"}),e.jsx(w,{value:"register",children:"Register"})]}),e.jsx(N,{value:"login",className:"space-y-4",children:e.jsxs("form",{onSubmit:A,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-email",children:"Email"}),e.jsx(l,{id:"login-email",type:"email",placeholder:"you@example.com",value:p,onChange:s=>E(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-password",children:"Password"}),e.jsx(l,{id:"login-password",type:"password",value:f,onChange:s=>T(s.target.value),required:!0,disabled:a})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Logging in..."]}):"Login"})]})}),e.jsx(N,{value:"register",className:"space-y-4",children:e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-email",children:"Email"}),e.jsx(l,{id:"register-email",type:"email",placeholder:"you@example.com",value:j,onChange:s=>F(s.target.value),required:!0,disabled:a}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only whitelisted emails can register"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-name",children:"Name"}),e.jsx(l,{id:"register-name",type:"text",placeholder:"Your name",value:v,onChange:s=>R(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-password",children:"Password"}),e.jsx(l,{id:"register-password",type:"password",value:u,onChange:s=>P(s.target.value),required:!0,disabled:a,minLength:8}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"At least 8 characters"})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating account..."]}):"Create Account"})]})})]})})]})})}export{Q as default};
1
+ import{u as I,s as z,t as B,r as t,j as e,v as g,I as l,B as y,w as n}from"./index-6zt5f3rT.js";import{L as c}from"./label-CSt-eWXG.js";import{C as D,b as k,c as H,d as M,a as O}from"./card-T1Zl_t-O.js";import{T as V,a as W,b as w,c as N}from"./tabs-CqVmSyiJ.js";function Q(){const i=I(),o=z(),{login:b,register:C,isAuthenticated:h,authEnabled:x,isLoading:m}=B(),[a,d]=t.useState(!1),[L,S]=t.useState("login"),[p,E]=t.useState(""),[f,T]=t.useState(""),[j,F]=t.useState(""),[u,P]=t.useState(""),[v,R]=t.useState("");t.useEffect(()=>{if(!m){if(!x)i("/");else if(h){const s=o.state?.from?.pathname||"/";i(s,{replace:!0})}}},[x,h,m,i,o]);const A=async s=>{s.preventDefault(),d(!0);try{await b(p,f),n({title:"Success",description:"Logged in successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Login failed",description:r.message||"Invalid email or password",variant:"destructive"})}finally{d(!1)}},q=async s=>{if(s.preventDefault(),u.length<8){n({title:"Invalid password",description:"Password must be at least 8 characters",variant:"destructive"});return}d(!0);try{await C(j,u,v),n({title:"Success",description:"Account created successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Registration failed",description:r.message||"Failed to create account",variant:"destructive"})}finally{d(!1)}};return m?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(g,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-background to-muted p-4",children:e.jsxs(D,{className:"w-full max-w-md",children:[e.jsxs(k,{className:"space-y-1 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("svg",{className:"h-12 w-12 text-green-600",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z"})})}),e.jsx(H,{className:"text-2xl font-bold",children:"Welcome to Coconut"}),e.jsx(M,{children:"Sign in to your account or create a new one"})]}),e.jsx(O,{children:e.jsxs(V,{value:L,onValueChange:s=>S(s),children:[e.jsxs(W,{className:"grid w-full grid-cols-2",children:[e.jsx(w,{value:"login",children:"Login"}),e.jsx(w,{value:"register",children:"Register"})]}),e.jsx(N,{value:"login",className:"space-y-4",children:e.jsxs("form",{onSubmit:A,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-email",children:"Email"}),e.jsx(l,{id:"login-email",type:"email",placeholder:"you@example.com",value:p,onChange:s=>E(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-password",children:"Password"}),e.jsx(l,{id:"login-password",type:"password",value:f,onChange:s=>T(s.target.value),required:!0,disabled:a})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Logging in..."]}):"Login"})]})}),e.jsx(N,{value:"register",className:"space-y-4",children:e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-email",children:"Email"}),e.jsx(l,{id:"register-email",type:"email",placeholder:"you@example.com",value:j,onChange:s=>F(s.target.value),required:!0,disabled:a}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only whitelisted emails can register"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-name",children:"Name"}),e.jsx(l,{id:"register-name",type:"text",placeholder:"Your name",value:v,onChange:s=>R(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-password",children:"Password"}),e.jsx(l,{id:"register-password",type:"password",value:u,onChange:s=>P(s.target.value),required:!0,disabled:a,minLength:8}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"At least 8 characters"})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating account..."]}):"Create Account"})]})})]})})]})})}export{Q as default};
@@ -0,0 +1 @@
1
+ import{a as A,r as i,A as N,j as e,bM as D,B as v,bN as T,v as w,k,bO as R,n as L}from"./index-6zt5f3rT.js";import{C as y,a as C}from"./card-T1Zl_t-O.js";import{B as j}from"./badge-DXtacKLi.js";import{M as B}from"./MailProcessingModal-CiU2tPrl.js";import{R as U}from"./refresh-cw-DF2wDnWT.js";import{P as M}from"./paperclip-Drtxq0HD.js";import{C as $}from"./chevron-up-C1j8XcMS.js";import{C as F}from"./clock-t6EXtqFH.js";import"./triangle-alert-DW7a6_v9.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 Z(){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{Z as default};
@@ -0,0 +1 @@
1
+ import{a as A,r as t,A as S,j as e,D,b as R,d as $,f as P,k as C,g as M,B as k,bP as B,T as I}from"./index-6zt5f3rT.js";import{B as x}from"./badge-DXtacKLi.js";import{T as y}from"./triangle-alert-DW7a6_v9.js";import{C as F}from"./clock-t6EXtqFH.js";import{R as L}from"./refresh-cw-DF2wDnWT.js";function E(i){const f=new Date(i).getTime(),o=Date.now(),l=Math.floor((o-f)/1e3);if(l<60)return`${l}s`;const c=Math.floor(l/60),d=l%60;if(c<60)return`${c}m ${d}s`;const s=Math.floor(c/60),p=c%60;return`${s}h ${p}m`}function U({open:i,onOpenChange:f,mailId:o,subject:l,onStopped:c}){const{toast:d}=A(),[s,p]=t.useState(null),[g,j]=t.useState(!1),[u,v]=t.useState(!1),[b,h]=t.useState(""),N=t.useRef(null),a=t.useRef(null),m=t.useCallback(async()=>{try{const r=await(await fetch(`${S}/api/v1/mail/${o}/processing`)).json();r.success&&p(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){h("");return}h(E(n));const r=setInterval(()=>{h(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 T=async()=>{v(!0);try{const r=await(await fetch(`${S}/api/v1/mail/${o}/processing/stop`,{method:"POST"})).json();r.success?(d({title:"Processing stopped",description:r.message}),setTimeout(()=>{m(),c?.()},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(D,{open:i,onOpenChange:f,children:e.jsxs(R,{className:"max-w-2xl max-h-[80vh] flex flex-col",children:[e.jsxs($,{children:[e.jsxs(P,{className:"flex items-center gap-2",children:[e.jsx(C,{className:"h-5 w-5"}),"Mail Processing"]}),e.jsx(M,{className:"truncate",children:l})]}),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(k,{variant:"ghost",size:"sm",onClick:()=>m(),disabled:g,title:"Refresh",children:e.jsx(L,{className:`h-3.5 w-3.5 ${g?"animate-spin":""}`})}),s?.processing&&e.jsxs(k,{variant:"destructive",size:"sm",onClick:T,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(I,{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})]}):g?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{U as M};
@@ -0,0 +1 @@
1
+ import{a as T,r as l,A as v,j as e,bM as A,B as w,bO as R,v as k,k as C,bN as L,H as $,n as B}from"./index-6zt5f3rT.js";import{C as E,a as M}from"./card-T1Zl_t-O.js";import{B as g}from"./badge-DXtacKLi.js";import{M as F}from"./MailProcessingModal-CiU2tPrl.js";import{R as U}from"./refresh-cw-DF2wDnWT.js";import{P as S}from"./paperclip-Drtxq0HD.js";import{C as O}from"./chevron-up-C1j8XcMS.js";import{C as z}from"./clock-t6EXtqFH.js";import"./triangle-alert-DW7a6_v9.js";function _(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 H(a){const s=a.match(/^([^<]+)\s*</);return s?s[1].trim():a.split("@")[0]||a}function J(a,s=120){const i=a.replace(/\n+/g," ").trim();return i.length<=s?i:i.slice(0,s)+"..."}function V({startedAt:a}){const[s,i]=l.useState("");return l.useEffect(()=>{function x(){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),m=d%60;i(`${u}m ${m}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(z,{className:"h-3 w-3"}),s]})}function te(){const{toast:a}=T(),[s,i]=l.useState([]),[x,o]=l.useState(!0),[f,p]=l.useState(null),[d,u]=l.useState(null),[m,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=m?s.find(t=>t.id===m):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:"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:H(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:J(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(O,{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(V,{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)})}),m&&e.jsx(F,{open:!!m,onOpenChange:t=>{t||y(null)},mailId:m,subject:D?.subject||"",onStopped:()=>h(!0)})]})}export{te as default};
@@ -1 +1 @@
1
- import{r as c,A as j,j as e,bM as p,B as N,bG as g,n as w}from"./index-BWhM9fZn.js";import{C as m,a as x}from"./card-jBf8qQSy.js";import{B as h}from"./badge-CKqDVhJv.js";import{R as v}from"./refresh-cw-DLJpfa8_.js";import{P as u}from"./paperclip-SI0kWfGf.js";import{C as y}from"./chevron-up-CcwaoTsZ.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(`${j}/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(p,{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};
1
+ import{r as c,A as j,j as e,bM as p,B as N,bG as g,n as w}from"./index-6zt5f3rT.js";import{C as m,a as x}from"./card-T1Zl_t-O.js";import{B as h}from"./badge-DXtacKLi.js";import{R as v}from"./refresh-cw-DF2wDnWT.js";import{P as u}from"./paperclip-Drtxq0HD.js";import{C as y}from"./chevron-up-C1j8XcMS.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(`${j}/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(p,{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};
@@ -1 +1 @@
1
- import{j as e,S as ne,$ as k,r as b,bE as B,w as f,bD as ie,bB as ae,B as C,P as q,I as u,o as R,_ as oe,H as le,F as ce,l as de}from"./index-BWhM9fZn.js";import{C as L,b as T,c as O,d as $,a as U}from"./card-jBf8qQSy.js";import{L as h}from"./label-CHVVHrlr.js";import{B as P}from"./badge-CKqDVhJv.js";import{S as I}from"./switch-Ck0OeSLk.js";import{A as z,a as Y}from"./alert-CMfexl-V.js";import{R as me,L as he}from"./browser-modal-CIOZi1Jw.js";import{R as xe}from"./registry-ANRa5WBi.js";import{C as J}from"./circle-alert-DqK0nUqF.js";import{C as ve}from"./circle-check-big-DDQIqE0G.js";import"./search-SRuczbr5.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 B("/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 B("/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)},Q=(s,r)=>{const c={...t,mcpServers:{...t.mcpServers,[s]:{...t.mcpServers[s],enabled:r}}};E(c)},X=s=>{const{[s]:r,...c}=t.mcpServers||{},v={...t,mcpServers:c};E(v)},Z=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(q,{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(q,{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=>Q(s,m),disabled:a}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(s),children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(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};
1
+ import{j as e,S as ne,$ as k,r as b,bE as B,w as f,bD as ie,bB as ae,B as C,P as q,I as u,o as R,_ as oe,H as le,F as ce,l as de}from"./index-6zt5f3rT.js";import{C as L,b as T,c as O,d as $,a as U}from"./card-T1Zl_t-O.js";import{L as h}from"./label-CSt-eWXG.js";import{B as P}from"./badge-DXtacKLi.js";import{S as I}from"./switch-CeUexKh7.js";import{A as z,a as Y}from"./alert-BLA1YxSF.js";import{R as me,L as he}from"./browser-modal-C-EJH5-l.js";import{R as xe}from"./registry-ANRa5WBi.js";import{C as J}from"./circle-alert-C-TQDAZH.js";import{C as ve}from"./circle-check-big-Dw0wgLkY.js";import"./search-CYS9xEgy.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 B("/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 B("/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)},Q=(s,r)=>{const c={...t,mcpServers:{...t.mcpServers,[s]:{...t.mcpServers[s],enabled:r}}};E(c)},X=s=>{const{[s]:r,...c}=t.mcpServers||{},v={...t,mcpServers:c};E(v)},Z=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(q,{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(q,{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=>Q(s,m),disabled:a}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(s),children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(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};
@@ -1,4 +1,4 @@
1
- import{u as j,a as v,r as a,A as l,j as e,B as m,L as g,a1 as y}from"./index-BWhM9fZn.js";import{C as h,a as x,b as N,c as C}from"./card-jBf8qQSy.js";import{M as S}from"./markdown-editor-CT9CPLw5.js";import{A as w}from"./arrow-left-CkQCXG-O.js";import{C as E}from"./circle-check-big-DDQIqE0G.js";import"./index-CdmUQF6-.js";function B(){const u=j(),{toast:t}=v(),[n,r]=a.useState(""),[p,o]=a.useState(!0),[i,c]=a.useState(!1);a.useEffect(()=>{fetch(`${l}/api/v1/context/memory`).then(s=>s.json()).then(s=>{s.success&&r(s.document.content.trim()),o(!1)}).catch(s=>{console.error("Failed to load context:",s),t({title:"Error",description:"Failed to load memory",variant:"destructive"}),o(!1)})},[t]);const f=async()=>{c(!0);try{const d=await(await fetch(`${l}/api/v1/context/memory`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,metadata:{}})})).json();if(d.success)t({title:"Success",description:"Memory saved successfully",action:e.jsx(E,{className:"h-4 w-4"})}),u("/context/memory");else throw new Error(d.error||"Failed to save")}catch(s){console.error("Save error:",s),t({title:"Error",description:"Failed to save memory",variant:"destructive"})}finally{c(!1)}};return p?e.jsx("div",{className:"space-y-6",children:e.jsx(h,{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-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Memory"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Manage persistent memory, decisions, and learned context"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(g,{to:"/context/memory",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(w,{className:"w-4 h-4"})})}),e.jsxs(m,{onClick:f,disabled:i,size:"sm",children:[e.jsx(y,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:i?"Saving...":"Save"})]})]})]}),e.jsxs(h,{children:[e.jsx(N,{children:e.jsx(C,{children:"Memory Documentation"})}),e.jsx(x,{children:e.jsx(S,{value:n,onChange:s=>r(s||""),placeholder:`Write your memory in markdown...
1
+ import{u as j,a as v,r as a,A as l,j as e,B as m,L as g,a1 as y}from"./index-6zt5f3rT.js";import{C as h,a as x,b as N,c as C}from"./card-T1Zl_t-O.js";import{M as S}from"./markdown-editor-C6ZusrL3.js";import{A as w}from"./arrow-left-BMmwy6t5.js";import{C as E}from"./circle-check-big-Dw0wgLkY.js";import"./index-p7Qpxih7.js";function B(){const u=j(),{toast:t}=v(),[n,r]=a.useState(""),[p,o]=a.useState(!0),[i,c]=a.useState(!1);a.useEffect(()=>{fetch(`${l}/api/v1/context/memory`).then(s=>s.json()).then(s=>{s.success&&r(s.document.content.trim()),o(!1)}).catch(s=>{console.error("Failed to load context:",s),t({title:"Error",description:"Failed to load memory",variant:"destructive"}),o(!1)})},[t]);const f=async()=>{c(!0);try{const d=await(await fetch(`${l}/api/v1/context/memory`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,metadata:{}})})).json();if(d.success)t({title:"Success",description:"Memory saved successfully",action:e.jsx(E,{className:"h-4 w-4"})}),u("/context/memory");else throw new Error(d.error||"Failed to save")}catch(s){console.error("Save error:",s),t({title:"Error",description:"Failed to save memory",variant:"destructive"})}finally{c(!1)}};return p?e.jsx("div",{className:"space-y-6",children:e.jsx(h,{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-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Memory"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Manage persistent memory, decisions, and learned context"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(g,{to:"/context/memory",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(w,{className:"w-4 h-4"})})}),e.jsxs(m,{onClick:f,disabled:i,size:"sm",children:[e.jsx(y,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:i?"Saving...":"Save"})]})]})]}),e.jsxs(h,{children:[e.jsx(N,{children:e.jsx(C,{children:"Memory Documentation"})}),e.jsx(x,{children:e.jsx(S,{value:n,onChange:s=>r(s||""),placeholder:`Write your memory in markdown...
2
2
 
3
3
  ## Key Decisions
4
4
 
@@ -1 +1 @@
1
- import{a as y,r as t,A as N,j as e,v,q as C,B as a,L as l,_ as d,M as w,av as g,ar as E}from"./index-BWhM9fZn.js";import{C as r,a as i,b}from"./card-jBf8qQSy.js";import{c as M}from"./clipboard-B9ndUJKl.js";function S(){const{toast:c}=y(),[o,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${N}/api/v1/context/memory`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/memory.md";try{await M(s),c({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),c({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"memory-md",filename:"memory.md",name:"memory.md",path:".nut/context/memory.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(r,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(v,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading memory..."})]})})})}):!u||!o?e.jsx("div",{className:"space-y-6",children:e.jsx(r,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Memory Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Memory will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(l,{to:"/context/memory/edit",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),"Create Memory"]})})]})})})}):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:"Memory"}),e.jsx("p",{className:"text-muted-foreground",children:"Persistent memory and learned context"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(g,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(l,{to:"/context/memory/edit",children:[e.jsx(d,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(r,{children:[e.jsx(b,{className:"pb-0"}),e.jsx(i,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(E,{children:o.content||"No content available"})})})]})]})}export{S as default};
1
+ import{a as y,r as t,A as N,j as e,v,q as C,B as a,L as l,_ as d,M as w,av as g,ar as E}from"./index-6zt5f3rT.js";import{C as r,a as i,b}from"./card-T1Zl_t-O.js";import{c as M}from"./clipboard-B9ndUJKl.js";function S(){const{toast:c}=y(),[o,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${N}/api/v1/context/memory`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/memory.md";try{await M(s),c({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),c({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"memory-md",filename:"memory.md",name:"memory.md",path:".nut/context/memory.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(r,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(v,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading memory..."})]})})})}):!u||!o?e.jsx("div",{className:"space-y-6",children:e.jsx(r,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Memory Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Memory will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(l,{to:"/context/memory/edit",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),"Create Memory"]})})]})})})}):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:"Memory"}),e.jsx("p",{className:"text-muted-foreground",children:"Persistent memory and learned context"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(g,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(l,{to:"/context/memory/edit",children:[e.jsx(d,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(r,{children:[e.jsx(b,{className:"pb-0"}),e.jsx(i,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(E,{children:o.content||"No content available"})})})]})]})}export{S as default};