@lovelybunch/api 1.0.75 → 1.0.76-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/storage/file-storage.d.ts +1 -0
- package/dist/lib/storage/file-storage.js +9 -1
- package/dist/routes/api/v1/mail/route.d.ts +3 -3
- package/dist/routes/api/v1/slack/route.d.ts +6 -6
- package/dist/routes/api/v1/tasks/[id]/route.d.ts +2 -2
- package/dist/routes/api/v1/tasks/[id]/steps/[stepId]/route.d.ts +60 -0
- package/dist/routes/api/v1/tasks/[id]/steps/[stepId]/route.js +81 -0
- package/dist/routes/api/v1/tasks/index.js +2 -0
- package/dist/routes/api/v1/tasks/route.d.ts +2 -2
- package/package.json +4 -4
- package/static/assets/{ActivityPage-k4I7Q53O.js → ActivityPage-DxajSxG1.js} +1 -1
- package/static/assets/{ApiKeysSettingsPage-B1YvVdmg.js → ApiKeysSettingsPage-DiBqSUMz.js} +1 -1
- package/static/assets/{ArchitectureEditPage-CpowsIx2.js → ArchitectureEditPage-iflIJaCh.js} +1 -1
- package/static/assets/{ArchitecturePage-DYxC_aMR.js → ArchitecturePage-oB3FtdZ7.js} +1 -1
- package/static/assets/{AuthSettingsPage-DtSo78Y_.js → AuthSettingsPage-BY7x-6wd.js} +1 -1
- package/static/assets/{CallbackPage-bROCGapx.js → CallbackPage-CYcV3OHa.js} +1 -1
- package/static/assets/{CodePage-CPCj64rX.js → CodePage-DxJYFhiT.js} +1 -1
- package/static/assets/{CollapsibleSection-M5cXbl92.js → CollapsibleSection-BLZv27JC.js} +1 -1
- package/static/assets/{DashboardPage-B9BZZfw6.js → DashboardPage-BdsK2Vor.js} +1 -1
- package/static/assets/{GitPage-BiDtdSK1.js → GitPage-CKIIMGjF.js} +1 -1
- package/static/assets/{GitSettingsPage-THm6wDjs.js → GitSettingsPage-sI4uzGzt.js} +1 -1
- package/static/assets/{IdentityPage-BC16skg6.js → IdentityPage-vzzaKU2-.js} +1 -1
- package/static/assets/ImplementationStepsEditor-BMHTxNEX.js +6 -0
- package/static/assets/{IntegrationsSettingsPage-CC_VKIQa.js → IntegrationsSettingsPage-BzuUrHO1.js} +1 -1
- package/static/assets/{JobDetailPage-z1QQYvmU.js → JobDetailPage-C-IKmhAF.js} +1 -1
- package/static/assets/{KnowledgeDetailPage-DzHXBS7Q.js → KnowledgeDetailPage-C1RHtPzz.js} +1 -1
- package/static/assets/{KnowledgeEditPage-BwGnUH_m.js → KnowledgeEditPage-D3gIqqKn.js} +1 -1
- package/static/assets/{KnowledgePage-CGIVMS02.js → KnowledgePage-DJphs1Kg.js} +1 -1
- package/static/assets/{LoginPage-VQ3lcfLV.js → LoginPage-DVaToPHL.js} +1 -1
- package/static/assets/{MailInboxPage-DiZKqwdU.js → MailInboxPage-I-MbS647.js} +1 -1
- package/static/assets/{MailProcessingModal-DIeSQBoR.js → MailProcessingModal-DXtDHWM_.js} +1 -1
- package/static/assets/{MailReadPage-C8AACmZQ.js → MailReadPage-DUN8EQjl.js} +1 -1
- package/static/assets/{MailSentPage-C_5yFly_.js → MailSentPage-DsGgBGBQ.js} +1 -1
- package/static/assets/{McpSettingsPage-i9YHcu1s.js → McpSettingsPage-d66ZIwm7.js} +1 -1
- package/static/assets/{NewKnowledgePage-BnVY7WUD.js → NewKnowledgePage-WbN6BikQ.js} +1 -1
- package/static/assets/{NewSkillPage-DwniHD6D.js → NewSkillPage-DesCsYgS.js} +1 -1
- package/static/assets/NewTaskPage-CrmiPuuw.js +91 -0
- package/static/assets/{NotFoundPage-BbSZX_4L.js → NotFoundPage-BcTtqwNP.js} +1 -1
- package/static/assets/{NotificationsSettingsPage-C8kjcift.js → NotificationsSettingsPage-BeJw7gY7.js} +1 -1
- package/static/assets/{ProjectEditPage-DUUlIEqI.js → ProjectEditPage-DiHz-pYk.js} +1 -1
- package/static/assets/{ProjectPage-Unz9PQpA.js → ProjectPage-CKaHBZlw.js} +1 -1
- package/static/assets/{PromptsSettingsPage-DVpIuRKI.js → PromptsSettingsPage-B_Opt_KA.js} +1 -1
- package/static/assets/{ResourceDetailPage-DqHZ2KYD.js → ResourceDetailPage-BSeDQxri.js} +1 -1
- package/static/assets/{ResourcesPage-BP5tuAi-.js → ResourcesPage-YmerqN0J.js} +1 -1
- package/static/assets/{RoleEditPage-BgKu8S0-.js → RoleEditPage-Bm7HG4sg.js} +1 -1
- package/static/assets/{RolePage-Fed52Ov5.js → RolePage-DoN5_uka.js} +1 -1
- package/static/assets/{RulesSettingsPage-BQ2O0u66.js → RulesSettingsPage-yQELBKgb.js} +1 -1
- package/static/assets/{SchedulePage-jkxjuzBx.js → SchedulePage-nmchdGUK.js} +1 -1
- package/static/assets/{SkillDetailPage-k3Q2-NFd.js → SkillDetailPage-BFjBVPS8.js} +1 -1
- package/static/assets/{SkillEditPage-urF4snjo.js → SkillEditPage-CjpscD5K.js} +1 -1
- package/static/assets/{SkillsPage-DlWDhEjR.js → SkillsPage-Dr_uyKVB.js} +1 -1
- package/static/assets/{SkillsSettingsPage-BViFgckG.js → SkillsSettingsPage-BknrbJBC.js} +1 -1
- package/static/assets/{SourceInput-CAFKTHw-.js → SourceInput-LclyzQLW.js} +1 -1
- package/static/assets/{TagInput-C6lI-ePr.js → TagInput-BZ6JyIo1.js} +1 -1
- package/static/assets/{TaskDetailPage-DpbRHnW_.js → TaskDetailPage-D97oWW98.js} +1 -1
- package/static/assets/{TaskEditPage-DssRbW0h.js → TaskEditPage-BTfzRYwM.js} +1 -1
- package/static/assets/{TasksPage-CD_eo0Bj.js → TasksPage-COvedmQz.js} +1 -1
- package/static/assets/{TerminalPage-BG_wlccr.js → TerminalPage-DhbOmISZ.js} +1 -1
- package/static/assets/{TerminalSessionPage-CsK-LznK.js → TerminalSessionPage-D2rZb8Ej.js} +1 -1
- package/static/assets/{UserPreferencesPage-CWUq3efu.js → UserPreferencesPage-CgtsVqvs.js} +1 -1
- package/static/assets/{UserSettingsPage-CduI_MGS.js → UserSettingsPage-AXLWqe0G.js} +1 -1
- package/static/assets/{UtilitiesPage-BAxokhLh.js → UtilitiesPage-CxQkYrza.js} +1 -1
- package/static/assets/{alert-BXsc6_qu.js → alert-BUrHsk9_.js} +1 -1
- package/static/assets/{arrow-down-DmW_3gE8.js → arrow-down-J9YP8VW9.js} +1 -1
- package/static/assets/{arrow-left-1S-835kP.js → arrow-left-RAzvFXpe.js} +1 -1
- package/static/assets/{arrow-up-BYism_o1.js → arrow-up-CjXXRPYC.js} +1 -1
- package/static/assets/{arrow-up-down-Dw3J0a4i.js → arrow-up-down-BRoDh-fK.js} +1 -1
- package/static/assets/{badge-BUEY53dV.js → badge-CA-A_JCd.js} +1 -1
- package/static/assets/{browser-modal-DCNdI4NT.js → browser-modal-DVtwh2h7.js} +1 -1
- package/static/assets/{card-BcPlIAH5.js → card-DdrUHBUG.js} +1 -1
- package/static/assets/{chevron-left-FMmNe7yP.js → chevron-left-C4bGr2Al.js} +1 -1
- package/static/assets/{chevron-up-CqM3won3.js → chevron-up-CPpQ_jgb.js} +1 -1
- package/static/assets/{chevrons-up-DTvCkIHc.js → chevrons-up-C8oR0iOR.js} +1 -1
- package/static/assets/{circle-alert-dseM-Ib7.js → circle-alert-B3zeVGHG.js} +1 -1
- package/static/assets/{circle-check-eyo6pBP1.js → circle-check-OfRBf8tJ.js} +1 -1
- package/static/assets/{circle-check-big-jKg34xC-.js → circle-check-big-CeVxJ4hA.js} +1 -1
- package/static/assets/{circle-play-BrY_lNiH.js → circle-play-C_Chmziu.js} +1 -1
- package/static/assets/{circle-x-uqmzEce1.js → circle-x-CtfEmATn.js} +1 -1
- package/static/assets/{clipboard-tzPFoieb.js → clipboard-Z_0Z5-r1.js} +1 -1
- package/static/assets/{clock-Bjc06QBM.js → clock-B43LjbrK.js} +1 -1
- package/static/assets/{code-DrYqPukx.js → code-D77i0toJ.js} +1 -1
- package/static/assets/{download-Bg__QCLT.js → download-C8rLaNF6.js} +1 -1
- package/static/assets/{external-link-CNDy2UUo.js → external-link-D6UvIQYD.js} +1 -1
- package/static/assets/{eye-DLFBnC8t.js → eye-C3fWwYx-.js} +1 -1
- package/static/assets/{folder-git-2-DUqd0WRi.js → folder-git-2-Crtn4eyJ.js} +1 -1
- package/static/assets/{index-DFcWlnzl.js → index-SWBrq2bx.js} +3 -3
- package/static/assets/{info-D6jxZC5X.js → info-BZi8bEGv.js} +1 -1
- package/static/assets/{label-DBuh-ke5.js → label-C8Wxd6GE.js} +1 -1
- package/static/assets/{markdown-editor-B4YNQFT2.js → markdown-editor-DAk7M9Ju.js} +1 -1
- package/static/assets/{message-square-B5RWz_ff.js → message-square-BpqFAvyq.js} +1 -1
- package/static/assets/{paperclip-4A_3MaPx.js → paperclip-Dk7jEYtI.js} +1 -1
- package/static/assets/{pause-BzhKXHtR.js → pause-CX3StCWt.js} +1 -1
- package/static/assets/{play-CHIf-Rcz.js → play-CRPN1vUy.js} +1 -1
- package/static/assets/{radio-group-C1ct-VsJ.js → radio-group-DFIfCEpZ.js} +1 -1
- package/static/assets/{refresh-cw-B3OwrDUf.js → refresh-cw-DGBXSYy5.js} +1 -1
- package/static/assets/{search-Cq1ksEdp.js → search-C9jI6Lg7.js} +1 -1
- package/static/assets/{select-44mcS2_G.js → select-DgNHsbaX.js} +1 -1
- package/static/assets/status-utils-PwF3DXLL.js +1 -0
- package/static/assets/{switch-CIwjYvCt.js → switch-C2zPfM3G.js} +1 -1
- package/static/assets/{tabs-DTV6Su-h.js → tabs-B7fjkp5h.js} +1 -1
- package/static/assets/{tag-p6yeowCW.js → tag-BOwlwHfi.js} +1 -1
- package/static/assets/{terminal-preview-DN38x9Jm.js → terminal-preview-BvBQu5Sd.js} +1 -1
- package/static/assets/{use-terminal-BXJqOeJe.js → use-terminal-xv9qDaX1.js} +1 -1
- package/static/assets/{video-BH5ChaoS.js → video-CW0zFsfp.js} +1 -1
- package/static/index.html +1 -1
- package/static/assets/ImplementationStepsEditor-HliLQav5.js +0 -6
- package/static/assets/NewTaskPage-F5UX2WMc.js +0 -90
- package/static/assets/status-utils-CDkPeVfP.js +0 -1
package/static/assets/{IntegrationsSettingsPage-CC_VKIQa.js → IntegrationsSettingsPage-BzuUrHO1.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,b0 as A,v as l,j as e,a$ as T,e as j,n as y,C as v,ae as N,I as b,B as r,E as k,a0 as w,h as $}from"./index-DFcWlnzl.js";import{C as U,b as Y,c as q,d as B,a as H}from"./card-BcPlIAH5.js";import{L as m}from"./label-DBuh-ke5.js";import{S as Q,a as W,b as X,c as Z,d as ee}from"./select-44mcS2_G.js";import"./chevron-up-CqM3won3.js";const se=[{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."}],te={models:se},ae=te;function E(){return ae.models}function ce(){const[t,F]=d.useState({}),[i,M]=d.useState(!0),[_,G]=d.useState(!1),[p,z]=d.useState({}),[I,R]=d.useState({}),[O,L]=d.useState(E()[0]?.id||"openai/gpt-4o"),[n,J]=d.useState({openrouter:!1,replicate:!1,anthropic:!1,openai:!1,gemini:!1,factorydroid:!1});d.useEffect(()=>{P()},[]);const P=async()=>{try{M(!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"]){const K=a[C];K&&typeof K=="string"&&K.trim()!==""?(o[C]=!0,c[C]="***"):(o[C]=!1,c[C]="")}F(c);const S=s.data.defaults&&s.data.defaults.model?String(s.data.defaults.model):void 0;L(S||E()[0]?.id||"openai/gpt-4o")}}catch(s){console.error("Failed to load API keys:",s),l({title:"Error",description:"Failed to load API keys",variant:"destructive"})}finally{M(!1)}},x=(s,a)=>{F(o=>({...o,[s]:a}))},D=async s=>{try{R(S=>({...S,[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?l({title:"Test Result",description:c.message}):c.success?l({title:"Test Result",description:"Success"}):l({title:"Test Failed",description:c.message||"Unknown error",variant:"destructive"})}catch(a){l({title:"Test Failed",description:a instanceof Error?a.message:"Unknown error",variant:"destructive"})}finally{R(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})}),l({title:"Success",description:`${s} API key cleared`}),await P()}catch(a){console.error("Failed to clear API key:",a),l({title:"Error",description:"Failed to clear API key",variant:"destructive"})}},g=async s=>{try{z(o=>({...o,[s]:!0}));const a={[s]:t[s]};await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),l({title:"Success",description:`${s} API key saved`}),await P()}catch(a){console.error("Failed to save API key:",a),l({title:"Error",description:"Failed to save API key",variant:"destructive"})}finally{z(a=>({...a,[s]:!1}))}},V=async()=>{try{G(!0),await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({defaults:{model:O}})}),l({title:"Success",description:"Default model saved successfully"})}catch(s){console.error("Failed to save default model:",s),l({title:"Error",description:"Failed to save default model",variant:"destructive"})}finally{G(!1)}},f={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(T,{}),e.jsxs(U,{children:[e.jsxs(Y,{children:[e.jsx(q,{children:"API Keys & Authentication"}),e.jsx(B,{children:"Manage API keys and authentication tokens for integrated services."})]}),e.jsxs(H,{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:j("flex items-center justify-center w-8 h-8 rounded-md",t.openrouter&&t.openrouter!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.openrouter?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{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:f.openrouter})]})]}),t.openrouter&&t.openrouter!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.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(b,{id:"openrouterKey",type:"password",placeholder:"sk-or-v1-...",className:"flex-1",value:t.openrouter||"",onChange:s=>x("openrouter",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openrouter"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>D("openrouter"),disabled:!!I.openrouter,title:"Test API key",children:I.openrouter?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openrouter"),disabled:p.openrouter||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenRouter"})]})]})]}),e.jsx(T,{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:j("flex items-center justify-center w-8 h-8 rounded-md",t.replicate&&t.replicate!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.replicate?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{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:f.replicate})]})]}),t.replicate&&t.replicate!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.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(b,{id:"replicateKey",type:"password",placeholder:"r8_...",className:"flex-1",value:t.replicate||"",onChange:s=>x("replicate",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("replicate"),title:"Clear API token",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>D("replicate"),disabled:!!I.replicate,title:"Test API token",children:I.replicate?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("replicate"),disabled:p.replicate||i,title:"Save API token",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token from"," ",e.jsx("a",{href:"https://replicate.com/account/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Replicate"})]})]})]}),e.jsx(T,{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:j("flex items-center justify-center w-8 h-8 rounded-md",t.anthropic&&t.anthropic!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.anthropic?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{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:f.anthropic})]})]}),t.anthropic&&t.anthropic!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.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(b,{id:"anthropicKey",type:"password",placeholder:"sk-ant-...",className:"flex-1",value:t.anthropic||"",onChange:s=>x("anthropic",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("anthropic"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("anthropic"),disabled:p.anthropic||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://console.anthropic.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Anthropic Console"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>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:j("flex items-center justify-center w-8 h-8 rounded-md",t.openai&&t.openai!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.openai?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{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:f.openai})]})]}),t.openai&&t.openai!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.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(b,{id:"openaiKey",type:"password",placeholder:"sk-...",className:"flex-1",value:t.openai||"",onChange:s=>x("openai",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openai"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openai"),disabled:p.openai||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenAI Platform"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>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:j("flex items-center justify-center w-8 h-8 rounded-md",t.gemini&&t.gemini!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.gemini?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{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:f.gemini})]})]}),t.gemini&&t.gemini!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.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(b,{id:"geminiKey",type:"password",placeholder:"AIza...",className:"flex-1",value:t.gemini||"",onChange:s=>x("gemini",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("gemini"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("gemini"),disabled:p.gemini||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://makersuite.google.com/app/apikey",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Google AI Studio"})]})]})]}),e.jsxs("div",{className:"border rounded-lg mt-4",children:[e.jsxs("button",{onClick:()=>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:j("flex items-center justify-center w-8 h-8 rounded-md",t.factorydroid&&t.factorydroid!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.factorydroid?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{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:f.factorydroid})]})]}),t.factorydroid&&t.factorydroid!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.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(b,{id:"factorydroidKey",type:"password",placeholder:"fd-...",className:"flex-1",value:t.factorydroid||"",onChange:s=>x("factorydroid",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("factorydroid"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("factorydroid"),disabled:p.factorydroid||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://factorydroid.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Factory Droid"})]})]})]})]})]}),e.jsxs(U,{children:[e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),e.jsx(q,{children:"AI Assistant Settings"})]}),e.jsx(B,{children:"Configure default AI model and behavior for the AI assistant sidebar."})]}),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"defaultModel",children:"Default AI Model"}),e.jsxs(Q,{value:O,onValueChange:L,children:[e.jsx(W,{children:e.jsx(X,{placeholder:"Select default AI model"})}),e.jsx(Z,{children:E().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:_||i,children:_?"Saving...":"Save"})})]})]})]})}export{ce as default};
|
|
1
|
+
import{r as d,b0 as A,v as l,j as e,a$ as T,e as j,n as y,C as v,ae as N,I as b,B as r,E as k,a0 as w,h as $}from"./index-SWBrq2bx.js";import{C as U,b as Y,c as q,d as B,a as H}from"./card-DdrUHBUG.js";import{L as m}from"./label-C8Wxd6GE.js";import{S as Q,a as W,b as X,c as Z,d as ee}from"./select-DgNHsbaX.js";import"./chevron-up-CPpQ_jgb.js";const se=[{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."}],te={models:se},ae=te;function E(){return ae.models}function ce(){const[t,F]=d.useState({}),[i,M]=d.useState(!0),[_,G]=d.useState(!1),[p,z]=d.useState({}),[I,R]=d.useState({}),[O,L]=d.useState(E()[0]?.id||"openai/gpt-4o"),[n,J]=d.useState({openrouter:!1,replicate:!1,anthropic:!1,openai:!1,gemini:!1,factorydroid:!1});d.useEffect(()=>{P()},[]);const P=async()=>{try{M(!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"]){const K=a[C];K&&typeof K=="string"&&K.trim()!==""?(o[C]=!0,c[C]="***"):(o[C]=!1,c[C]="")}F(c);const S=s.data.defaults&&s.data.defaults.model?String(s.data.defaults.model):void 0;L(S||E()[0]?.id||"openai/gpt-4o")}}catch(s){console.error("Failed to load API keys:",s),l({title:"Error",description:"Failed to load API keys",variant:"destructive"})}finally{M(!1)}},x=(s,a)=>{F(o=>({...o,[s]:a}))},D=async s=>{try{R(S=>({...S,[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?l({title:"Test Result",description:c.message}):c.success?l({title:"Test Result",description:"Success"}):l({title:"Test Failed",description:c.message||"Unknown error",variant:"destructive"})}catch(a){l({title:"Test Failed",description:a instanceof Error?a.message:"Unknown error",variant:"destructive"})}finally{R(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})}),l({title:"Success",description:`${s} API key cleared`}),await P()}catch(a){console.error("Failed to clear API key:",a),l({title:"Error",description:"Failed to clear API key",variant:"destructive"})}},g=async s=>{try{z(o=>({...o,[s]:!0}));const a={[s]:t[s]};await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),l({title:"Success",description:`${s} API key saved`}),await P()}catch(a){console.error("Failed to save API key:",a),l({title:"Error",description:"Failed to save API key",variant:"destructive"})}finally{z(a=>({...a,[s]:!1}))}},V=async()=>{try{G(!0),await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({defaults:{model:O}})}),l({title:"Success",description:"Default model saved successfully"})}catch(s){console.error("Failed to save default model:",s),l({title:"Error",description:"Failed to save default model",variant:"destructive"})}finally{G(!1)}},f={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(T,{}),e.jsxs(U,{children:[e.jsxs(Y,{children:[e.jsx(q,{children:"API Keys & Authentication"}),e.jsx(B,{children:"Manage API keys and authentication tokens for integrated services."})]}),e.jsxs(H,{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:j("flex items-center justify-center w-8 h-8 rounded-md",t.openrouter&&t.openrouter!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.openrouter?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{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:f.openrouter})]})]}),t.openrouter&&t.openrouter!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.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(b,{id:"openrouterKey",type:"password",placeholder:"sk-or-v1-...",className:"flex-1",value:t.openrouter||"",onChange:s=>x("openrouter",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openrouter"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>D("openrouter"),disabled:!!I.openrouter,title:"Test API key",children:I.openrouter?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openrouter"),disabled:p.openrouter||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenRouter"})]})]})]}),e.jsx(T,{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:j("flex items-center justify-center w-8 h-8 rounded-md",t.replicate&&t.replicate!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.replicate?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{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:f.replicate})]})]}),t.replicate&&t.replicate!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.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(b,{id:"replicateKey",type:"password",placeholder:"r8_...",className:"flex-1",value:t.replicate||"",onChange:s=>x("replicate",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("replicate"),title:"Clear API token",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>D("replicate"),disabled:!!I.replicate,title:"Test API token",children:I.replicate?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("replicate"),disabled:p.replicate||i,title:"Save API token",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token from"," ",e.jsx("a",{href:"https://replicate.com/account/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Replicate"})]})]})]}),e.jsx(T,{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:j("flex items-center justify-center w-8 h-8 rounded-md",t.anthropic&&t.anthropic!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.anthropic?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{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:f.anthropic})]})]}),t.anthropic&&t.anthropic!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.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(b,{id:"anthropicKey",type:"password",placeholder:"sk-ant-...",className:"flex-1",value:t.anthropic||"",onChange:s=>x("anthropic",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("anthropic"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("anthropic"),disabled:p.anthropic||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://console.anthropic.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Anthropic Console"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>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:j("flex items-center justify-center w-8 h-8 rounded-md",t.openai&&t.openai!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.openai?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{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:f.openai})]})]}),t.openai&&t.openai!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.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(b,{id:"openaiKey",type:"password",placeholder:"sk-...",className:"flex-1",value:t.openai||"",onChange:s=>x("openai",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openai"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openai"),disabled:p.openai||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenAI Platform"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>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:j("flex items-center justify-center w-8 h-8 rounded-md",t.gemini&&t.gemini!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.gemini?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{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:f.gemini})]})]}),t.gemini&&t.gemini!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.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(b,{id:"geminiKey",type:"password",placeholder:"AIza...",className:"flex-1",value:t.gemini||"",onChange:s=>x("gemini",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("gemini"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("gemini"),disabled:p.gemini||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://makersuite.google.com/app/apikey",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Google AI Studio"})]})]})]}),e.jsxs("div",{className:"border rounded-lg mt-4",children:[e.jsxs("button",{onClick:()=>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:j("flex items-center justify-center w-8 h-8 rounded-md",t.factorydroid&&t.factorydroid!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.factorydroid?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{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:f.factorydroid})]})]}),t.factorydroid&&t.factorydroid!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.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(b,{id:"factorydroidKey",type:"password",placeholder:"fd-...",className:"flex-1",value:t.factorydroid||"",onChange:s=>x("factorydroid",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("factorydroid"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("factorydroid"),disabled:p.factorydroid||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://factorydroid.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Factory Droid"})]})]})]})]})]}),e.jsxs(U,{children:[e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),e.jsx(q,{children:"AI Assistant Settings"})]}),e.jsx(B,{children:"Configure default AI model and behavior for the AI assistant sidebar."})]}),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"defaultModel",children:"Default AI Model"}),e.jsxs(Q,{value:O,onValueChange:L,children:[e.jsx(W,{children:e.jsx(X,{placeholder:"Select default AI model"})}),e.jsx(Z,{children:E().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:_||i,children:_?"Saving...":"Save"})})]})]})]})}export{ce as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as se,u as te,a as ae,ad as re,r as d,j as e,B as c,L as N,t as C,y as ne,z as ie,E as de,H as le,J as ce,N as oe,O as me,Q as xe,R as ue,U as he,k as H,a9 as pe,n as je,F as ge,Y as fe,a$ as O,m as Ne,A as v}from"./index-DFcWlnzl.js";import{c as ve}from"./clipboard-B9ndUJKl.js";import{C as o,b as g,a as m,c as b,d as G}from"./card-BcPlIAH5.js";import{B as w}from"./badge-BUEY53dV.js";import{A as D}from"./arrow-left-1S-835kP.js";import{P as S}from"./play-CHIf-Rcz.js";import{C as be,a as we}from"./clipboard-tzPFoieb.js";import{R as ye}from"./refresh-cw-B3OwrDUf.js";import{C as Ce}from"./chevron-up-CqM3won3.js";import{P as Se}from"./pause-BzhKXHtR.js";import{C as q}from"./clock-Bjc06QBM.js";const ke=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"},{id:"kiro",label:"Kiro"}],f=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},$=a=>{if(!a)return"—";const i=new Date(a).getTime()-Date.now(),l=Math.round(i/(1e3*60));if(Number.isNaN(l))return f(a);if(Math.abs(l)<1)return"now";if(l>0){if(l<60)return`in ${l}m`;const h=Math.round(l/60);return h<24?`in ${h}h`:`in ${Math.round(h/24)}d`}const t=Math.abs(l);if(t<60)return`${t}m ago`;const u=Math.round(t/60);return u<24?`${u}h ago`:`${Math.round(u/24)}d ago`},Ae=a=>{if(a.type==="interval"){const x=a.daysOfWeek.map(i=>i.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${x||"All days"})`}return a.description||`Cron: ${a.expression}`},Re=a=>{const x=ke.find(i=>i.id===a);return x?x.label:a},L=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}};function Me(){const{id:a}=se(),x=te(),{toast:i}=ae(),{refresh:l}=re(),[t,u]=d.useState(null),[T,h]=d.useState(!0),[y,E]=d.useState(null),[P,F]=d.useState(!1),[k,J]=d.useState(!1),[p,U]=d.useState(!1),[K,z]=d.useState(!1),[Q,V]=d.useState(new Set),[B,A]=d.useState({}),[W,M]=d.useState(new Set),R=async()=>{if(a)try{h(!0);const r=await(await fetch(`${v}/api/v1/jobs/${a}`)).json();r.success?u(r.data):E(r.error?.message||"Failed to fetch job")}catch(s){E(s instanceof Error?s.message:"Unknown error")}finally{h(!1)}};d.useEffect(()=>{R()},[a]);const Y=async()=>{if(a){F(!0);try{const r=await(await fetch(`${v}/api/v1/jobs/${a}`,{method:"DELETE"})).json();r.success?(i({title:"Job deleted",description:t?.name||"Scheduled job has been deleted"}),x("/schedule")):i({title:"Failed to delete job",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(s){i({title:"Failed to delete job",description:s instanceof Error?s.message:"Unknown error",variant:"destructive"})}finally{F(!1)}}},X=async()=>{if(!t||!a)return;J(!0);const s=t.status==="active"?"paused":"active";try{const n=await(await fetch(`${v}/api/v1/jobs/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:s})})).json();n.success?(u(n.data),await l(),i({title:s==="active"?"Job resumed":"Job paused",description:t.name})):i({title:"Failed to update job",description:n.error?.message||"Unknown error",variant:"destructive"})}catch(r){i({title:"Failed to update job",description:r instanceof Error?r.message:"Unknown error",variant:"destructive"})}finally{J(!1)}},_=async()=>{if(!(!t||!a)){U(!0);try{const s=await fetch(`${v}/api/v1/jobs/${a}/run`,{method:"POST"}),r=await s.json();r.success||s.ok?(i({title:"Run started",description:`${t.name} is executing.`}),await R(),await l()):i({title:"Failed to start run",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(s){i({title:"Failed to start run",description:s instanceof Error?s.message:"Unknown error",variant:"destructive"})}finally{U(!1)}}},Z=async s=>{V(r=>{const n=new Set(r);return n.has(s)?n.delete(s):(n.add(s),!B[s]&&a&&ee(s)),n})},ee=async s=>{if(a){M(r=>new Set(r).add(s));try{const r=await fetch(`${v}/api/v1/jobs/${a}/runs/${s}/log`);if(r.ok){const n=await r.text();A(j=>({...j,[s]:n}))}else{const n=await r.json().catch(()=>({}));A(j=>({...j,[s]:n.error?.message||"Log not available"}))}}catch(r){A(n=>({...n,[s]:r instanceof Error?r.message:"Failed to load log"}))}finally{M(r=>{const n=new Set(r);return n.delete(s),n})}}};if(T)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(c,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(N,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})]}),e.jsxs(o,{children:[e.jsx(g,{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(m,{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(y||!t)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:y||"Job not found"})}),e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(N,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})]}),e.jsx(o,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:y||"Job not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The job with ID "',a,'" could not be found.']}),e.jsx(c,{asChild:!0,className:"mt-4",children:e.jsx(N,{to:"/schedule",children:"Back to Schedule"})})]})})})]});const I=t.agentIds||(t.agentId?[t.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:t.name}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(N,{to:"/schedule",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})}),e.jsxs(c,{variant:"default",size:"sm",onClick:_,disabled:p||!!t._error,children:[p?e.jsx(C,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Running...":"Run Now"})]}),e.jsxs(ne,{children:[e.jsx(ie,{asChild:!0,children:e.jsxs(c,{variant:"destructive",size:"sm",disabled:P,children:[e.jsx(de,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:P?"Deleting...":"Delete"})]})}),e.jsxs(le,{children:[e.jsxs(ce,{children:[e.jsx(oe,{children:"Are you absolutely sure?"}),e.jsxs(me,{children:["This action cannot be undone. This will permanently delete the scheduled job",e.jsxs("span",{className:"font-semibold",children:[' "',t.name,'"']}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(xe,{children:[e.jsx(ue,{children:"Cancel"}),e.jsx(he,{onClick:Y,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Job"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const s=`.nut/jobs/job-${t.id}.md`;try{await ve(s),z(!0),i({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>z(!1),2e3)}catch(r){console.error("Failed to copy path:",r),i({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-${t.id}.md`}),K?e.jsx(be,{className:"h-3.5 w-3.5"}):e.jsx(we,{className:"h-3.5 w-3.5"})]})]}),t._error&&e.jsx(o,{className:"border-destructive/50 bg-destructive/5",children:e.jsxs(m,{className:"pt-6",children:[e.jsx("p",{className:"text-sm text-destructive font-medium",children:t._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-",t.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(o,{children:[e.jsxs(g,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"Job Configuration"}),e.jsx(w,{variant:L(t.status),className:"capitalize",children:t.status})]}),t.description&&e.jsx(G,{children:t.description})]}),e.jsxs(m,{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:t.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(H,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:Re(t.model)})]})]}),I.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:I.map(s=>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(H,{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:s.replace(".md","")})]},s))})]}),t.mcpServers&&t.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:t.mcpServers.map(s=>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(pe,{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:s})]},s))})]})]})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{children:"Run History"}),e.jsxs(G,{children:[t.runs.length," recorded run",t.runs.length!==1?"s":""]})]}),e.jsxs(c,{variant:"outline",size:"sm",onClick:R,children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})}),e.jsx(m,{children:t.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-3",children:t.runs.map(s=>{const r=Q.has(s.id),n=W.has(s.id),j=B[s.id];return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden",children:[e.jsxs("div",{className:"p-3 cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>Z(s.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(w,{variant:L(s.status),className:"capitalize text-xs",children:s.status}),e.jsx("span",{className:"text-sm text-muted-foreground",children:f(s.startedAt)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",$(s.startedAt),")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.trigger==="manual"&&e.jsx(w,{variant:"outline",className:"text-xs",children:"manual"}),r?e.jsx(Ce,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(je,{className:"h-4 w-4 text-muted-foreground"})]})]}),s.error&&e.jsx("p",{className:"text-sm text-destructive font-medium mb-2",children:s.error}),s.summary&&!r&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.summary})]}),r&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t bg-muted/20",children:[e.jsxs("div",{className:"pt-3 grid gap-2 text-xs",children:[s.finishedAt&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Finished:"}),e.jsx("span",{children:f(s.finishedAt)})]}),s.cliCommand&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Command:"}),e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs break-all",children:s.cliCommand})]}),s.outputPath&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Log path:"}),e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs",children:s.outputPath})]})]}),s.summary&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Summary"}),e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-xs leading-relaxed whitespace-pre-wrap",children:s.summary})]}),e.jsxs("div",{children:[e.jsxs("h5",{className:"text-xs font-medium text-muted-foreground mb-1 flex items-center gap-1.5",children:[e.jsx(ge,{className:"h-3 w-3"}),"Full Log"]}),n?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground p-2",children:[e.jsx(C,{className:"h-3 w-3 animate-spin"}),"Loading log..."]}):j?e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-xs leading-relaxed max-h-96 overflow-auto whitespace-pre-wrap",children:j}):e.jsx("div",{className:"text-xs text-muted-foreground p-2",children:"Log not available"})]})]})]},s.id)})})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Actions"})}),e.jsxs(m,{className:"space-y-2",children:[e.jsxs(c,{variant:"default",className:"w-full justify-start",onClick:_,disabled:p||!!t._error,children:[p?e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(S,{className:"h-4 w-4 mr-2"}),p?"Running...":"Run Now"]}),e.jsxs(c,{variant:"outline",className:"w-full justify-start",onClick:X,disabled:k||!!t._error,children:[k?e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}):t.status==="active"?e.jsx(Se,{className:"h-4 w-4 mr-2"}):e.jsx(S,{className:"h-4 w-4 mr-2"}),k?"Updating...":t.status==="active"?"Pause Job":"Resume Job"]}),e.jsx(c,{variant:"outline",className:"w-full justify-start",asChild:!0,disabled:!!t._error,children:e.jsxs(N,{to:"/schedule",state:{editJobId:t.id},children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Edit Job"]})})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Schedule"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(q,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:Ae(t.schedule)})]}),t.schedule.type==="interval"&&t.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:[t.schedule.anchorHour,":00"]})]}),e.jsx(O,{}),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.metadata.nextRunAt)})]}),t.metadata.nextRunAt&&e.jsx("div",{className:"text-xs text-muted-foreground",children:f(t.metadata.nextRunAt)})]})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Information"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ne,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Created:"}),e.jsx("span",{children:f(t.metadata.createdAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(q,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Updated:"}),e.jsx("span",{children:f(t.metadata.updatedAt)})]}),t.metadata.lastRunAt&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(S,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Last run:"}),e.jsx("span",{children:$(t.metadata.lastRunAt)})]}),e.jsx(O,{}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Status:"}),e.jsx("div",{className:"mt-1",children:e.jsx(w,{variant:L(t.status),className:"capitalize",children:t.status})})]}),t.tags&&t.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:t.tags.map(s=>e.jsx(w,{variant:"outline",className:"text-xs",children:s},s))})]})]})]})]})]})]})}export{Me as default};
|
|
1
|
+
import{x as se,u as te,a as ae,ad as re,r as d,j as e,B as c,L as N,t as C,y as ne,z as ie,E as de,H as le,J as ce,N as oe,O as me,Q as xe,R as ue,U as he,k as H,a9 as pe,n as je,F as ge,Y as fe,a$ as O,m as Ne,A as v}from"./index-SWBrq2bx.js";import{c as ve}from"./clipboard-B9ndUJKl.js";import{C as o,b as g,a as m,c as b,d as G}from"./card-DdrUHBUG.js";import{B as w}from"./badge-CA-A_JCd.js";import{A as D}from"./arrow-left-RAzvFXpe.js";import{P as S}from"./play-CRPN1vUy.js";import{C as be,a as we}from"./clipboard-Z_0Z5-r1.js";import{R as ye}from"./refresh-cw-DGBXSYy5.js";import{C as Ce}from"./chevron-up-CPpQ_jgb.js";import{P as Se}from"./pause-CX3StCWt.js";import{C as q}from"./clock-B43LjbrK.js";const ke=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"},{id:"kiro",label:"Kiro"}],f=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},$=a=>{if(!a)return"—";const i=new Date(a).getTime()-Date.now(),l=Math.round(i/(1e3*60));if(Number.isNaN(l))return f(a);if(Math.abs(l)<1)return"now";if(l>0){if(l<60)return`in ${l}m`;const h=Math.round(l/60);return h<24?`in ${h}h`:`in ${Math.round(h/24)}d`}const t=Math.abs(l);if(t<60)return`${t}m ago`;const u=Math.round(t/60);return u<24?`${u}h ago`:`${Math.round(u/24)}d ago`},Ae=a=>{if(a.type==="interval"){const x=a.daysOfWeek.map(i=>i.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${x||"All days"})`}return a.description||`Cron: ${a.expression}`},Re=a=>{const x=ke.find(i=>i.id===a);return x?x.label:a},L=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}};function Me(){const{id:a}=se(),x=te(),{toast:i}=ae(),{refresh:l}=re(),[t,u]=d.useState(null),[T,h]=d.useState(!0),[y,E]=d.useState(null),[P,F]=d.useState(!1),[k,J]=d.useState(!1),[p,U]=d.useState(!1),[K,z]=d.useState(!1),[Q,V]=d.useState(new Set),[B,A]=d.useState({}),[W,M]=d.useState(new Set),R=async()=>{if(a)try{h(!0);const r=await(await fetch(`${v}/api/v1/jobs/${a}`)).json();r.success?u(r.data):E(r.error?.message||"Failed to fetch job")}catch(s){E(s instanceof Error?s.message:"Unknown error")}finally{h(!1)}};d.useEffect(()=>{R()},[a]);const Y=async()=>{if(a){F(!0);try{const r=await(await fetch(`${v}/api/v1/jobs/${a}`,{method:"DELETE"})).json();r.success?(i({title:"Job deleted",description:t?.name||"Scheduled job has been deleted"}),x("/schedule")):i({title:"Failed to delete job",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(s){i({title:"Failed to delete job",description:s instanceof Error?s.message:"Unknown error",variant:"destructive"})}finally{F(!1)}}},X=async()=>{if(!t||!a)return;J(!0);const s=t.status==="active"?"paused":"active";try{const n=await(await fetch(`${v}/api/v1/jobs/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:s})})).json();n.success?(u(n.data),await l(),i({title:s==="active"?"Job resumed":"Job paused",description:t.name})):i({title:"Failed to update job",description:n.error?.message||"Unknown error",variant:"destructive"})}catch(r){i({title:"Failed to update job",description:r instanceof Error?r.message:"Unknown error",variant:"destructive"})}finally{J(!1)}},_=async()=>{if(!(!t||!a)){U(!0);try{const s=await fetch(`${v}/api/v1/jobs/${a}/run`,{method:"POST"}),r=await s.json();r.success||s.ok?(i({title:"Run started",description:`${t.name} is executing.`}),await R(),await l()):i({title:"Failed to start run",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(s){i({title:"Failed to start run",description:s instanceof Error?s.message:"Unknown error",variant:"destructive"})}finally{U(!1)}}},Z=async s=>{V(r=>{const n=new Set(r);return n.has(s)?n.delete(s):(n.add(s),!B[s]&&a&&ee(s)),n})},ee=async s=>{if(a){M(r=>new Set(r).add(s));try{const r=await fetch(`${v}/api/v1/jobs/${a}/runs/${s}/log`);if(r.ok){const n=await r.text();A(j=>({...j,[s]:n}))}else{const n=await r.json().catch(()=>({}));A(j=>({...j,[s]:n.error?.message||"Log not available"}))}}catch(r){A(n=>({...n,[s]:r instanceof Error?r.message:"Failed to load log"}))}finally{M(r=>{const n=new Set(r);return n.delete(s),n})}}};if(T)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(c,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(N,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})]}),e.jsxs(o,{children:[e.jsx(g,{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(m,{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(y||!t)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:y||"Job not found"})}),e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(N,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})]}),e.jsx(o,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:y||"Job not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The job with ID "',a,'" could not be found.']}),e.jsx(c,{asChild:!0,className:"mt-4",children:e.jsx(N,{to:"/schedule",children:"Back to Schedule"})})]})})})]});const I=t.agentIds||(t.agentId?[t.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:t.name}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(N,{to:"/schedule",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})}),e.jsxs(c,{variant:"default",size:"sm",onClick:_,disabled:p||!!t._error,children:[p?e.jsx(C,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Running...":"Run Now"})]}),e.jsxs(ne,{children:[e.jsx(ie,{asChild:!0,children:e.jsxs(c,{variant:"destructive",size:"sm",disabled:P,children:[e.jsx(de,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:P?"Deleting...":"Delete"})]})}),e.jsxs(le,{children:[e.jsxs(ce,{children:[e.jsx(oe,{children:"Are you absolutely sure?"}),e.jsxs(me,{children:["This action cannot be undone. This will permanently delete the scheduled job",e.jsxs("span",{className:"font-semibold",children:[' "',t.name,'"']}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(xe,{children:[e.jsx(ue,{children:"Cancel"}),e.jsx(he,{onClick:Y,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Job"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const s=`.nut/jobs/job-${t.id}.md`;try{await ve(s),z(!0),i({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>z(!1),2e3)}catch(r){console.error("Failed to copy path:",r),i({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-${t.id}.md`}),K?e.jsx(be,{className:"h-3.5 w-3.5"}):e.jsx(we,{className:"h-3.5 w-3.5"})]})]}),t._error&&e.jsx(o,{className:"border-destructive/50 bg-destructive/5",children:e.jsxs(m,{className:"pt-6",children:[e.jsx("p",{className:"text-sm text-destructive font-medium",children:t._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-",t.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(o,{children:[e.jsxs(g,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"Job Configuration"}),e.jsx(w,{variant:L(t.status),className:"capitalize",children:t.status})]}),t.description&&e.jsx(G,{children:t.description})]}),e.jsxs(m,{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:t.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(H,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:Re(t.model)})]})]}),I.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:I.map(s=>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(H,{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:s.replace(".md","")})]},s))})]}),t.mcpServers&&t.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:t.mcpServers.map(s=>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(pe,{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:s})]},s))})]})]})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{children:"Run History"}),e.jsxs(G,{children:[t.runs.length," recorded run",t.runs.length!==1?"s":""]})]}),e.jsxs(c,{variant:"outline",size:"sm",onClick:R,children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})}),e.jsx(m,{children:t.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-3",children:t.runs.map(s=>{const r=Q.has(s.id),n=W.has(s.id),j=B[s.id];return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden",children:[e.jsxs("div",{className:"p-3 cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>Z(s.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(w,{variant:L(s.status),className:"capitalize text-xs",children:s.status}),e.jsx("span",{className:"text-sm text-muted-foreground",children:f(s.startedAt)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",$(s.startedAt),")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.trigger==="manual"&&e.jsx(w,{variant:"outline",className:"text-xs",children:"manual"}),r?e.jsx(Ce,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(je,{className:"h-4 w-4 text-muted-foreground"})]})]}),s.error&&e.jsx("p",{className:"text-sm text-destructive font-medium mb-2",children:s.error}),s.summary&&!r&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.summary})]}),r&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t bg-muted/20",children:[e.jsxs("div",{className:"pt-3 grid gap-2 text-xs",children:[s.finishedAt&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Finished:"}),e.jsx("span",{children:f(s.finishedAt)})]}),s.cliCommand&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Command:"}),e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs break-all",children:s.cliCommand})]}),s.outputPath&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Log path:"}),e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs",children:s.outputPath})]})]}),s.summary&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Summary"}),e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-xs leading-relaxed whitespace-pre-wrap",children:s.summary})]}),e.jsxs("div",{children:[e.jsxs("h5",{className:"text-xs font-medium text-muted-foreground mb-1 flex items-center gap-1.5",children:[e.jsx(ge,{className:"h-3 w-3"}),"Full Log"]}),n?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground p-2",children:[e.jsx(C,{className:"h-3 w-3 animate-spin"}),"Loading log..."]}):j?e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-xs leading-relaxed max-h-96 overflow-auto whitespace-pre-wrap",children:j}):e.jsx("div",{className:"text-xs text-muted-foreground p-2",children:"Log not available"})]})]})]},s.id)})})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Actions"})}),e.jsxs(m,{className:"space-y-2",children:[e.jsxs(c,{variant:"default",className:"w-full justify-start",onClick:_,disabled:p||!!t._error,children:[p?e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(S,{className:"h-4 w-4 mr-2"}),p?"Running...":"Run Now"]}),e.jsxs(c,{variant:"outline",className:"w-full justify-start",onClick:X,disabled:k||!!t._error,children:[k?e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}):t.status==="active"?e.jsx(Se,{className:"h-4 w-4 mr-2"}):e.jsx(S,{className:"h-4 w-4 mr-2"}),k?"Updating...":t.status==="active"?"Pause Job":"Resume Job"]}),e.jsx(c,{variant:"outline",className:"w-full justify-start",asChild:!0,disabled:!!t._error,children:e.jsxs(N,{to:"/schedule",state:{editJobId:t.id},children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Edit Job"]})})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Schedule"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(q,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:Ae(t.schedule)})]}),t.schedule.type==="interval"&&t.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:[t.schedule.anchorHour,":00"]})]}),e.jsx(O,{}),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.metadata.nextRunAt)})]}),t.metadata.nextRunAt&&e.jsx("div",{className:"text-xs text-muted-foreground",children:f(t.metadata.nextRunAt)})]})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Information"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ne,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Created:"}),e.jsx("span",{children:f(t.metadata.createdAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(q,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Updated:"}),e.jsx("span",{children:f(t.metadata.updatedAt)})]}),t.metadata.lastRunAt&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(S,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Last run:"}),e.jsx("span",{children:$(t.metadata.lastRunAt)})]}),e.jsx(O,{}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Status:"}),e.jsx("div",{className:"mt-1",children:e.jsx(w,{variant:L(t.status),className:"capitalize",children:t.status})})]}),t.tags&&t.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:t.tags.map(s=>e.jsx(w,{variant:"outline",className:"text-xs",children:s},s))})]})]})]})]})]})]})}export{Me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as A,u as T,a as F,r as i,A as p,j as e,t as g,B as o,L as x,M as L,Y as S,y as $,z,E as P,H as B,J as K,N as U,O as _,Q as H,R as M,U as R,ae as q,af as I,m as W,_ as J}from"./index-
|
|
1
|
+
import{x as A,u as T,a as F,r as i,A as p,j as e,t as g,B as o,L as x,M as L,Y as S,y as $,z,E as P,H as B,J as K,N as U,O as _,Q as H,R as M,U as R,ae as q,af as I,m as W,_ as J}from"./index-SWBrq2bx.js";import{C as d,a as m,b as O,c as Q}from"./card-DdrUHBUG.js";import{B as V}from"./badge-CA-A_JCd.js";import{c as Y}from"./clipboard-B9ndUJKl.js";import{A as j}from"./arrow-left-RAzvFXpe.js";import{T as G}from"./tag-BOwlwHfi.js";import{E as X}from"./external-link-D6UvIQYD.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(),N=T(),{toast:r}=F(),l=n.filename,[s,v]=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?v(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 Y(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"}),N("/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(L,{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(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs($,{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(W,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Updated ",s.metadata.updated]})]}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-start gap-1.5 sm:items-center",children:[e.jsx(G,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5 sm:mt-0"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map((t,a)=>e.jsx(V,{variant:"outline",className:"text-xs",children:t},a))})]})]}),s.metadata.sources&&s.metadata.sources.length>0&&e.jsxs(d,{children:[e.jsx(O,{children:e.jsx(Q,{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(X,{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(J,{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{x as $,u as z,a as B,r as n,A as E,j as e,t as S,B as h,L as M,a0 as D,X as K,I as R}from"./index-
|
|
1
|
+
import{x as $,u as z,a as B,r as n,A as E,j as e,t as S,B as h,L as M,a0 as D,X as K,I as R}from"./index-SWBrq2bx.js";import{C as d,a as l,b as x,c as g}from"./card-DdrUHBUG.js";import{L as p}from"./label-C8Wxd6GE.js";import{M as U}from"./markdown-editor-DAk7M9Ju.js";import{T as _}from"./TagInput-BZ6JyIo1.js";import{n as H,S as J}from"./SourceInput-LclyzQLW.js";import{A as O}from"./arrow-left-RAzvFXpe.js";import"./badge-CA-A_JCd.js";import"./external-link-D6UvIQYD.js";function te(){const y=$(),i=z(),{toast:a}=B(),r=y.filename,[m,T]=n.useState(null),[L,b]=n.useState(!0),[u,f]=n.useState(!1),[o,j]=n.useState(""),[c,v]=n.useState(""),[w,N]=n.useState([]),[k,C]=n.useState([]);n.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))):(a({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/knowledge"))}catch(s){console.error("Error fetching document:",s),a({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/knowledge")}finally{b(!1)}},F=async()=>{if(m){if(!o.trim()){a({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!c.trim()){a({title:"Error",description:"Please provide content for the knowledge document",variant:"destructive"});return}f(!0);try{const t=await(await fetch(`${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){a({title:"Success",description:"Knowledge document updated successfully"});const P=t.document.filename.replace(".md","");i(`/knowledge/${P}`,{replace:!0})}else a({title:"Error",description:t.error||"Failed to update knowledge document",variant:"destructive"})}catch(s){console.error("Error updating document:",s),a({title:"Error",description:"Failed to update knowledge document",variant:"destructive"})}finally{f(!1)}}},I=()=>{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 Knowledge Document"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:m.filename})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(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(g,{children:"Basic Information"})}),e.jsx(l,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(p,{htmlFor:"title",children:"Title *"}),e.jsx(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(g,{children:"Metadata"})}),e.jsxs(l,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{children:"Tags"}),e.jsx(_,{tags:w,onChange:N,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(p,{children:"Sources"}),e.jsx(J,{sources:k,onChange:C})]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(g,{children:"Content *"})}),e.jsx(l,{children:e.jsx(U,{value:c,onChange:s=>v(s||""),placeholder:"Enter your knowledge content in Markdown..."})})]})]}):null}export{te 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 $,t 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-
|
|
1
|
+
import{j as e,S as V,_ as q,u as Q,r as p,a as W,A as $,t 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-SWBrq2bx.js";import{C as L,a as B}from"./card-DdrUHBUG.js";import{B as j}from"./badge-CA-A_JCd.js";import{c as Z}from"./clipboard-B9ndUJKl.js";import{R as ee,L as O}from"./browser-modal-DVtwh2h7.js";import{R as te,f as se}from"./registry-ANRa5WBi.js";import{A as ae}from"./arrow-up-down-BRoDh-fK.js";import{A as ne}from"./arrow-up-CjXXRPYC.js";import{A as re}from"./arrow-down-J9YP8VW9.js";import"./search-C9jI6Lg7.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(`${$}/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(),E=new Date(n.metadata.updated||0).getTime();c=f-E;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(`${$}/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(F){console.error("Failed to parse registry import response:",F)}if(!(c.ok&&f?.success)){const R=(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:R,variant:"destructive"}),n=!0,new Error(R)}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,q as z,s as B,r as t,j as e,t as g,I as l,B as y,v as n}from"./index-
|
|
1
|
+
import{u as I,q as z,s as B,r as t,j as e,t as g,I as l,B as y,v as n}from"./index-SWBrq2bx.js";import{L as c}from"./label-C8Wxd6GE.js";import{C as D,b as k,c as H,d as M,a as O}from"./card-DdrUHBUG.js";import{T as V,a as W,b as w,c as N}from"./tabs-B7fjkp5h.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 q=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)}},A=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:q,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:A,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 +1 @@
|
|
|
1
|
-
import{a as A,r as i,A as N,j as e,bv as D,B as v,bw as T,t as w,k,bx as R,n as L}from"./index-
|
|
1
|
+
import{a as A,r as i,A as N,j as e,bv as D,B as v,bw as T,t as w,k,bx as R,n as L}from"./index-SWBrq2bx.js";import{C as y,a as C}from"./card-DdrUHBUG.js";import{B as j}from"./badge-CA-A_JCd.js";import{M as B}from"./MailProcessingModal-DXtDHWM_.js";import{R as U}from"./refresh-cw-DGBXSYy5.js";import{P as M}from"./paperclip-Dk7jEYtI.js";import{C as $}from"./chevron-up-CPpQ_jgb.js";import{C as F}from"./clock-B43LjbrK.js";function O(a){if(!a)return"";try{const s=new Date(a),x=new Date().getTime()-s.getTime(),o=Math.floor(x/(1e3*60*60*24));return o===0?s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):o<7?s.toLocaleDateString("en-US",{weekday:"short",hour:"numeric",minute:"2-digit"}):s.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return a}}function z(a){const s=a.match(/^([^<]+)\s*</);return s?s[1].trim():a.split("@")[0]||a}function _(a,s=120){const c=a.replace(/\n+/g," ").trim();return c.length<=s?c:c.slice(0,s)+"..."}function J({startedAt:a}){const[s,c]=i.useState("");return i.useEffect(()=>{function x(){const f=new Date(a).getTime(),h=Date.now(),m=Math.floor((h-f)/1e3);if(m<60)c(`${m}s`);else{const p=Math.floor(m/60),d=m%60;c(`${p}m ${d}s`)}}x();const o=setInterval(x,1e3);return()=>clearInterval(o)},[a]),e.jsxs("span",{className:"flex items-center gap-1 text-blue-600 dark:text-blue-400",children:[e.jsx(F,{className:"h-3 w-3"}),s]})}function Y(){const{toast:a}=A(),[s,c]=i.useState([]),[x,o]=i.useState(!0),[f,h]=i.useState(null),[m,p]=i.useState(null),[d,g]=i.useState(null),l=i.useRef(null),u=i.useCallback(async(t=!1)=>{try{t||o(!0);const r=await(await fetch(`${N}/api/v1/mail/inbox`)).json();r.success&&c(r.data.messages||[])}catch(n){console.error("Failed to fetch inbox:",n)}finally{t||o(!1)}},[]);i.useEffect(()=>{u()},[u]),i.useEffect(()=>{const t=s.some(n=>n.processing);return t&&!l.current?l.current=setInterval(()=>u(!0),5e3):!t&&l.current&&(clearInterval(l.current),l.current=null),()=>{l.current&&(clearInterval(l.current),l.current=null)}},[s,u]);const S=async(t,n)=>{n.stopPropagation(),p(t);try{const b=await(await fetch(`${N}/api/v1/mail/${t}/status`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"read"})})).json();b.success?(c(P=>P.filter(E=>E.id!==t)),f===t&&h(null),a({title:"Marked as read",description:"Email moved to Read folder."})):a({title:"Error",description:b.error||"Failed to mark as read",variant:"destructive"})}catch{a({title:"Error",description:"Failed to mark as read",variant:"destructive"})}finally{p(null)}},I=d?s.find(t=>t.id===d):null;return x?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold",children:"Inbox"})}),[1,2,3].map(t=>e.jsx(D,{className:"h-20 w-full"},t))]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Inbox"}),s.length>0&&e.jsx(j,{variant:"secondary",children:s.length})]}),e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>u(),children:e.jsx(U,{className:"h-4 w-4"})})]}),s.length===0?e.jsx(y,{children:e.jsxs(C,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(T,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No emails in inbox"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Incoming emails will appear here when received."})]})}):e.jsx("div",{className:"space-y-2",children:s.map(t=>{const n=f===t.id;return e.jsx(y,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>h(n?null:t.id),children:e.jsxs(C,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-semibold text-sm truncate",children:z(t.from)}),t.processing&&!t.action&&e.jsxs(j,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-blue-300 text-blue-600 dark:border-blue-700 dark:text-blue-400 gap-1",children:[e.jsx(w,{className:"h-2.5 w-2.5 animate-spin"}),"Processing"]}),!t.processing&&t.action&&e.jsxs(j,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-green-300 text-green-600 dark:border-green-700 dark:text-green-400 gap-1",children:[e.jsx(k,{className:"h-2.5 w-2.5"}),"Processed"]}),t.attachments.length>0&&e.jsx(M,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:O(t.receivedAt)})]}),e.jsx("p",{className:"text-sm font-medium truncate",children:t.subject}),!n&&t.content&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:_(t.content)})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:r=>S(t.id,r),disabled:m===t.id,title:"Mark as read",children:e.jsx(R,{className:"h-4 w-4"})}),n?e.jsx($,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(L,{className:"h-4 w-4 text-muted-foreground"})]})]}),n&&e.jsxs("div",{className:"mt-4 pt-4 border-t space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"From:"})," ",t.from]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"To:"})," ",t.to.join(", ")]}),t.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"CC:"})," ",t.cc.join(", ")]})]}),t.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:t.attachments.map(r=>e.jsxs(j,{variant:"outline",className:"text-xs",children:[e.jsx(M,{className:"h-3 w-3 mr-1"}),r.filename]},r.id))}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3",children:t.content||e.jsx("span",{className:"text-muted-foreground italic",children:"No content"})}),t.processing&&!t.action&&e.jsx("button",{type:"button",className:"w-full text-left bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 rounded-lg p-3 text-sm cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-950/50 transition-colors",onClick:r=>{r.stopPropagation(),g(t.id)},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-blue-700 dark:text-blue-400 font-medium text-xs",children:[e.jsx(w,{className:"h-3.5 w-3.5 animate-spin"}),"Processing email..."]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.processingStartedAt&&e.jsx(J,{startedAt:t.processingStartedAt}),e.jsx("span",{className:"text-blue-500 dark:text-blue-400 text-[10px] font-medium",children:"View details"})]})]})}),t.action&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium text-xs mb-1",children:[e.jsx(k,{className:"h-3.5 w-3.5"}),"Agent Action"]}),e.jsx("p",{className:"text-green-900 dark:text-green-200",children:t.action})]})]})]})},t.id)})}),d&&e.jsx(B,{open:!!d,onOpenChange:t=>{t||g(null)},mailId:d,subject:I?.subject||"",onStopped:()=>u(!0)})]})}export{Y as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as D,a as M,r as t,A as k,j as e,D as R,b as T,d as $,f as C,k as P,g as I,B as S,by as B,T as L}from"./index-
|
|
1
|
+
import{c as D,a as M,r as t,A as k,j as e,D as R,b as T,d as $,f as C,k as P,g as I,B as S,by as B,T as L}from"./index-SWBrq2bx.js";import{B as x}from"./badge-CA-A_JCd.js";import{C as F}from"./clock-B43LjbrK.js";import{R as _}from"./refresh-cw-DGBXSYy5.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as T,r as l,A as v,j as e,bv as A,B as w,bx as R,t as k,k as C,bw as L,E as $,n as B}from"./index-
|
|
1
|
+
import{a as T,r as l,A as v,j as e,bv as A,B as w,bx as R,t as k,k as C,bw as L,E as $,n as B}from"./index-SWBrq2bx.js";import{C as E,a as M}from"./card-DdrUHBUG.js";import{B as g}from"./badge-CA-A_JCd.js";import{M as F}from"./MailProcessingModal-DXtDHWM_.js";import{R as U}from"./refresh-cw-DGBXSYy5.js";import{P as S}from"./paperclip-Dk7jEYtI.js";import{C as z}from"./chevron-up-CPpQ_jgb.js";import{C as O}from"./clock-B43LjbrK.js";function _(a){if(!a)return"";try{const s=new Date(a),m=new Date().getTime()-s.getTime(),o=Math.floor(m/(1e3*60*60*24));return o===0?s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):o<7?s.toLocaleDateString("en-US",{weekday:"short",hour:"numeric",minute:"2-digit"}):s.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return a}}function J(a){const s=a.match(/^([^<]+)\s*</);return s?s[1].trim():a.split("@")[0]||a}function V(a,s=120){const i=a.replace(/\n+/g," ").trim();return i.length<=s?i:i.slice(0,s)+"..."}function q({startedAt:a}){const[s,i]=l.useState("");return l.useEffect(()=>{function m(){const f=new Date(a).getTime(),p=Date.now(),d=Math.floor((p-f)/1e3);if(d<60)i(`${d}s`);else{const u=Math.floor(d/60),x=d%60;i(`${u}m ${x}s`)}}m();const o=setInterval(m,1e3);return()=>clearInterval(o)},[a]),e.jsxs("span",{className:"flex items-center gap-1 text-blue-600 dark:text-blue-400",children:[e.jsx(O,{className:"h-3 w-3"}),s]})}function ee(){const{toast:a}=T(),[s,i]=l.useState([]),[m,o]=l.useState(!0),[f,p]=l.useState(null),[d,u]=l.useState(null),[x,y]=l.useState(null),c=l.useRef(null),h=l.useCallback(async(t=!1)=>{try{t||o(!0);const n=await(await fetch(`${v}/api/v1/mail/read`)).json();n.success&&i(n.data.messages||[])}catch(r){console.error("Failed to fetch read mail:",r)}finally{t||o(!1)}},[]);l.useEffect(()=>{h()},[h]),l.useEffect(()=>{const t=s.some(r=>r.processing);return t&&!c.current?c.current=setInterval(()=>h(!0),5e3):!t&&c.current&&(clearInterval(c.current),c.current=null),()=>{c.current&&(clearInterval(c.current),c.current=null)}},[s,h]);const I=async(t,r)=>{r.stopPropagation(),u(t);try{const j=await(await fetch(`${v}/api/v1/mail/${t}/status`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"unread"})})).json();j.success?(i(b=>b.filter(N=>N.id!==t)),f===t&&p(null),a({title:"Moved to Inbox",description:"Email moved back to Inbox."})):a({title:"Error",description:j.error||"Failed to move email",variant:"destructive"})}catch{a({title:"Error",description:"Failed to move email",variant:"destructive"})}finally{u(null)}},P=async(t,r)=>{r.stopPropagation(),u(t);try{const j=await(await fetch(`${v}/api/v1/mail/read/${t}`,{method:"DELETE"})).json();j.success?(i(b=>b.filter(N=>N.id!==t)),f===t&&p(null),a({title:"Deleted",description:"Email has been deleted."})):a({title:"Error",description:j.error||"Failed to delete email",variant:"destructive"})}catch{a({title:"Error",description:"Failed to delete email",variant:"destructive"})}finally{u(null)}},D=x?s.find(t=>t.id===x):null;return m?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold",children:"Read"})}),[1,2,3].map(t=>e.jsx(A,{className:"h-20 w-full"},t))]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Read"}),s.length>0&&e.jsx(g,{variant:"secondary",children:s.length})]}),e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>h(),children:e.jsx(U,{className:"h-4 w-4"})})]}),s.length===0?e.jsx(E,{children:e.jsxs(M,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(R,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No read emails"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Emails marked as read will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:s.map(t=>{const r=f===t.id;return e.jsx(E,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>p(r?null:t.id),children:e.jsxs(M,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground truncate",children:J(t.from)}),t.processing&&!t.action&&e.jsxs(g,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-blue-300 text-blue-600 dark:border-blue-700 dark:text-blue-400 gap-1",children:[e.jsx(k,{className:"h-2.5 w-2.5 animate-spin"}),"Processing"]}),!t.processing&&t.action&&e.jsxs(g,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-green-300 text-green-600 dark:border-green-700 dark:text-green-400 gap-1",children:[e.jsx(C,{className:"h-2.5 w-2.5"}),"Processed"]}),t.attachments.length>0&&e.jsx(S,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:_(t.receivedAt)})]}),e.jsx("p",{className:"text-sm truncate",children:t.subject}),!r&&t.content&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:V(t.content)})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:n=>I(t.id,n),disabled:d===t.id,title:"Move to Inbox",children:e.jsx(L,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"sm",onClick:n=>P(t.id,n),disabled:d===t.id,title:"Delete",className:"text-destructive hover:text-destructive",children:e.jsx($,{className:"h-4 w-4"})}),r?e.jsx(z,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(B,{className:"h-4 w-4 text-muted-foreground"})]})]}),r&&e.jsxs("div",{className:"mt-4 pt-4 border-t space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"From:"})," ",t.from]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"To:"})," ",t.to.join(", ")]}),t.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"CC:"})," ",t.cc.join(", ")]})]}),t.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:t.attachments.map(n=>e.jsxs(g,{variant:"outline",className:"text-xs",children:[e.jsx(S,{className:"h-3 w-3 mr-1"}),n.filename]},n.id))}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3",children:t.content||e.jsx("span",{className:"text-muted-foreground italic",children:"No content"})}),t.processing&&!t.action&&e.jsx("button",{type:"button",className:"w-full text-left bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 rounded-lg p-3 text-sm cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-950/50 transition-colors",onClick:n=>{n.stopPropagation(),y(t.id)},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-blue-700 dark:text-blue-400 font-medium text-xs",children:[e.jsx(k,{className:"h-3.5 w-3.5 animate-spin"}),"Processing email..."]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.processingStartedAt&&e.jsx(q,{startedAt:t.processingStartedAt}),e.jsx("span",{className:"text-blue-500 dark:text-blue-400 text-[10px] font-medium",children:"View details"})]})]})}),t.action&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium text-xs mb-1",children:[e.jsx(C,{className:"h-3.5 w-3.5"}),"Agent Action"]}),e.jsx("p",{className:"text-green-900 dark:text-green-200",children:t.action})]})]})]})},t.id)})}),x&&e.jsx(F,{open:!!x,onOpenChange:t=>{t||y(null)},mailId:x,subject:D?.subject||"",onStopped:()=>h(!0)})]})}export{ee as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,A as p,j as e,bv as j,B as N,bp as g,n as w}from"./index-
|
|
1
|
+
import{r as c,A as p,j as e,bv as j,B as N,bp as g,n as w}from"./index-SWBrq2bx.js";import{C as m,a as x}from"./card-DdrUHBUG.js";import{B as h}from"./badge-CA-A_JCd.js";import{R as v}from"./refresh-cw-DGBXSYy5.js";import{P as u}from"./paperclip-Dk7jEYtI.js";import{C as y}from"./chevron-up-CPpQ_jgb.js";function b(t){if(!t)return"";try{const a=new Date(t),i=new Date().getTime()-a.getTime(),l=Math.floor(i/(1e3*60*60*24));return l===0?a.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):l<7?a.toLocaleDateString("en-US",{weekday:"short",hour:"numeric",minute:"2-digit"}):a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return t}}function C(t,a=120){const r=t.replace(/\n+/g," ").trim();return r.length<=a?r:r.slice(0,a)+"..."}function P(){const[t,a]=c.useState([]),[r,i]=c.useState(!0),[l,f]=c.useState(null),o=c.useCallback(async()=>{try{i(!0);const n=await(await fetch(`${p}/api/v1/mail/sent`)).json();n.success&&a(n.data.messages||[])}catch(s){console.error("Failed to fetch sent mail:",s)}finally{i(!1)}},[]);return c.useEffect(()=>{o()},[o]),r?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold",children:"Sent"})}),[1,2,3].map(s=>e.jsx(j,{className:"h-20 w-full"},s))]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sent"}),t.length>0&&e.jsx(h,{variant:"secondary",children:t.length})]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:o,children:e.jsx(v,{className:"h-4 w-4"})})]}),t.length===0?e.jsx(m,{children:e.jsxs(x,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(g,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No sent emails"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Replies and sent emails will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:t.map(s=>{const n=l===s.id;return e.jsx(m,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>f(n?null:s.id),children:e.jsxs(x,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"text-sm text-muted-foreground truncate",children:["To: ",s.to.join(", ")]}),s.attachments.length>0&&e.jsx(u,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:b(s.receivedAt)})]}),e.jsx("p",{className:"text-sm truncate",children:s.subject}),!n&&s.content&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:C(s.content)})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:n?e.jsx(y,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(w,{className:"h-4 w-4 text-muted-foreground"})})]}),n&&e.jsxs("div",{className:"mt-4 pt-4 border-t space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"From:"})," ",s.from]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"To:"})," ",s.to.join(", ")]}),s.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"CC:"})," ",s.cc.join(", ")]})]}),s.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:s.attachments.map(d=>e.jsxs(h,{variant:"outline",className:"text-xs",children:[e.jsx(u,{className:"h-3 w-3 mr-1"}),d.filename]},d.id))}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3",children:s.content||e.jsx("span",{className:"text-muted-foreground italic",children:"No content"})})]})]})},s.id)})})]})}export{P as default};
|