@lovelybunch/api 1.0.77-alpha.0 → 1.0.77-alpha.1
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/config/oauth.d.ts +33 -0
- package/dist/config/oauth.js +43 -0
- package/dist/lib/auth/auth-manager.d.ts +21 -1
- package/dist/lib/auth/auth-manager.js +57 -3
- package/dist/lib/auth/clerk-verifier.d.ts +22 -0
- package/dist/lib/auth/clerk-verifier.js +30 -0
- package/dist/middleware/auth.js +40 -3
- package/dist/routes/api/v1/auth/route.js +90 -0
- package/dist/routes/api/v1/auth-settings/route.js +83 -2
- package/dist/routes/api/v1/jobs/[id]/route.d.ts +20 -20
- package/dist/routes/api/v1/jobs/route.d.ts +20 -20
- package/dist/routes/api/v1/slack/route.d.ts +6 -6
- package/dist/server-with-static.js +13 -0
- package/dist/server.js +11 -0
- package/package.json +5 -4
- package/static/assets/{ActivityPage-rASRHKYj.js → ActivityPage-DqSj7XDx.js} +1 -1
- package/static/assets/{AgentsContextEditPage-CMWD-7mS.js → AgentsContextEditPage-C5afMo09.js} +1 -1
- package/static/assets/AgentsContextPage-IrZGdiYt.js +1 -0
- package/static/assets/{ApiKeysSettingsPage-DxtuyXwn.js → ApiKeysSettingsPage-CFBTIYNp.js} +2 -2
- package/static/assets/AuthSettingsPage-LU7DFMG6.js +11 -0
- package/static/assets/{CallbackPage-CjlTVuif.js → CallbackPage-Beg0ZLv4.js} +1 -1
- package/static/assets/CoconutCallbackPage-BuBYbeY-.js +1 -0
- package/static/assets/CodePage-C9auBWu3.js +2 -0
- package/static/assets/{CollapsibleSection-LrQJlSxD.js → CollapsibleSection-C3uaXDrK.js} +1 -1
- package/static/assets/{DashboardPage-DnyFyDO0.js → DashboardPage-DK2uEtcQ.js} +1 -1
- package/static/assets/{GitPage-o37iQMYQ.js → GitPage-BgfZ5rXn.js} +2 -2
- package/static/assets/{GitSettingsPage-O0fe5kxm.js → GitSettingsPage-DIhaZgDD.js} +2 -2
- package/static/assets/{IdentityPage-KWjruliO.js → IdentityPage-6_IEyGmH.js} +2 -2
- package/static/assets/{ImplementationStepsEditor-h_Mxu1tF.js → ImplementationStepsEditor-BXjs77nI.js} +1 -1
- package/static/assets/IntegrationsSettingsPage-Cu-C86-i.js +1 -0
- package/static/assets/JobDetailPage-BWd0sz7w.js +1 -0
- package/static/assets/KnowledgeDetailPage-Cx0NiVN5.js +1 -0
- package/static/assets/{KnowledgeEditPage-DrdvEGuR.js → KnowledgeEditPage-Dtp9Ceyp.js} +1 -1
- package/static/assets/{KnowledgePage-CK5rtZcv.js → KnowledgePage-DRavibOT.js} +2 -2
- package/static/assets/LoginPage-Bn-55dqi.js +1 -0
- package/static/assets/{MailInboxPage-CewILL7o.js → MailInboxPage-B-mzoocZ.js} +1 -1
- package/static/assets/MailProcessingModal-B5HFIwxh.js +1 -0
- package/static/assets/{MailReadPage--LnQ743i.js → MailReadPage-DVVICNmn.js} +1 -1
- package/static/assets/{MailSentPage-BqO4iBq6.js → MailSentPage-BmqXLEIF.js} +1 -1
- package/static/assets/McpSettingsPage-D6hW-2uy.js +1 -0
- package/static/assets/{MemoryEditPage-BLfdKEDu.js → MemoryEditPage-Cw2oWAW2.js} +1 -1
- package/static/assets/MemoryPage-BKNQlp0x.js +1 -0
- package/static/assets/{NewKnowledgePage-SrBhXpH6.js → NewKnowledgePage-zWnjfGF1.js} +1 -1
- package/static/assets/{NewSkillPage-vt-0rIkv.js → NewSkillPage-eqK5nwnk.js} +1 -1
- package/static/assets/{NewTaskPage-CBUpwIFP.js → NewTaskPage-BcOmFrza.js} +2 -2
- package/static/assets/{NotFoundPage-CWF5qOC0.js → NotFoundPage-CKcBMXOQ.js} +1 -1
- package/static/assets/{NotificationsSettingsPage-3ZvMrqiq.js → NotificationsSettingsPage-DETz35D7.js} +1 -1
- package/static/assets/PromptsSettingsPage-8--L7lw4.js +1 -0
- package/static/assets/{ResourceDetailPage-CE4iDbv7.js → ResourceDetailPage-BH-A0yn7.js} +1 -1
- package/static/assets/{ResourcesPage-4_5NA4RF.js → ResourcesPage-CfdKptfd.js} +1 -1
- package/static/assets/{RoleEditPage-4sSELIRX.js → RoleEditPage-DfqF4tLW.js} +1 -1
- package/static/assets/RolePage-CCwufp_f.js +1 -0
- package/static/assets/{RulesSettingsPage-DnyGaden.js → RulesSettingsPage-dzUPGors.js} +4 -4
- package/static/assets/{RunDetailPage-D2ajvKfh.js → RunDetailPage-B9I5nrOb.js} +1 -1
- package/static/assets/SchedulePage-7Ufvzd34.js +4 -0
- package/static/assets/SkillDetailPage-DCjWVhUE.js +1 -0
- package/static/assets/{SkillEditPage-DeI8uu3S.js → SkillEditPage-BA-ebFGI.js} +1 -1
- package/static/assets/{SkillsPage-Bb_dEdun.js → SkillsPage-QqNzKzhn.js} +2 -2
- package/static/assets/{SkillsSettingsPage-CMWf2O9y.js → SkillsSettingsPage-DPXiPnWO.js} +1 -1
- package/static/assets/{SourceInput-CtyUOXOG.js → SourceInput-0S84iX2C.js} +1 -1
- package/static/assets/{TagInput-C0NyMxlY.js → TagInput-C_2MLj_1.js} +1 -1
- package/static/assets/{TaskDetailPage-6DDI0juh.js → TaskDetailPage-6E7isObV.js} +2 -2
- package/static/assets/{TaskEditPage-Btc1NXtR.js → TaskEditPage-Bd1DFoK3.js} +1 -1
- package/static/assets/{TasksPage-C9TYvqRz.js → TasksPage-CeWPVVwj.js} +1 -1
- package/static/assets/{TeamEditPage-CLvNy6Ss.js → TeamEditPage-CgYsqeq9.js} +1 -1
- package/static/assets/TeamPage-CEojyLvc.js +1 -0
- package/static/assets/{TerminalPage-DNDHEYJZ.js → TerminalPage-D-LJMND7.js} +1 -1
- package/static/assets/{TerminalSessionPage-nNCw_oDE.js → TerminalSessionPage-BGHgOQhV.js} +2 -2
- package/static/assets/{UserPreferencesPage-jc1SA79x.js → UserPreferencesPage-D5nGgztl.js} +1 -1
- package/static/assets/{UserSettingsPage-pr6n15Pz.js → UserSettingsPage-Dv6fSWWx.js} +1 -1
- package/static/assets/UtilitiesPage-hCM0KDs8.js +1 -0
- package/static/assets/{alert-BtkLXQ3p.js → alert-DxBTp_In.js} +1 -1
- package/static/assets/{arrow-down-DnNLmXEs.js → arrow-down-Be4lZFzF.js} +1 -1
- package/static/assets/{arrow-left-B9NBHEkS.js → arrow-left-DzGSl0dC.js} +1 -1
- package/static/assets/{arrow-up-eMUJY7J9.js → arrow-up-6HVzdiIw.js} +1 -1
- package/static/assets/{arrow-up-down-DIuMvAne.js → arrow-up-down-C9lUuyDO.js} +1 -1
- package/static/assets/{badge-BbfU_aPt.js → badge-DyF_7_dv.js} +1 -1
- package/static/assets/{browser-modal-J9l3o5os.js → browser-modal-DKHn0FAC.js} +2 -2
- package/static/assets/{card-CL5bB4cs.js → card-DW9yx9FC.js} +1 -1
- package/static/assets/{chevron-left-B-7K6MNx.js → chevron-left-CJjrbO2y.js} +1 -1
- package/static/assets/{chevron-up-BwTmMEW2.js → chevron-up-BrSqNhfU.js} +1 -1
- package/static/assets/{chevrons-up-jI6nxhrz.js → chevrons-up-wQrNHZqU.js} +1 -1
- package/static/assets/{circle-alert-vJFSz39V.js → circle-alert-ByPjREVD.js} +1 -1
- package/static/assets/{circle-check-D2LVHMl-.js → circle-check-D7peX4CI.js} +1 -1
- package/static/assets/{circle-check-big-BwQ_q1N7.js → circle-check-big--yqXPZzU.js} +1 -1
- package/static/assets/{circle-play-CLKDBkrK.js → circle-play-C2th8mzN.js} +1 -1
- package/static/assets/{circle-x-CuUVLiI-.js → circle-x-Oj6Gai3s.js} +1 -1
- package/static/assets/{clipboard-BHOFelnW.js → clipboard-qigxJPlJ.js} +1 -1
- package/static/assets/{clock-D-X3KCw6.js → clock-JhtahL2B.js} +1 -1
- package/static/assets/{code-DqYaanki.js → code-DcBDG3ah.js} +1 -1
- package/static/assets/{download-DeEju9jg.js → download-BBjLPrfj.js} +1 -1
- package/static/assets/{external-link-CrRz0sU-.js → external-link-DDneC3kx.js} +1 -1
- package/static/assets/{eye-Cx9ZGkg5.js → eye-Bl23BbY6.js} +1 -1
- package/static/assets/{folder-git-2-Cizv1NA6.js → folder-git-2-BBe22u2y.js} +1 -1
- package/static/assets/{globe-lpD9Jv31.js → globe-C3j3aWiD.js} +1 -1
- package/static/assets/{index-ByTA2ZiD.js → index-0zkOcODK.js} +105 -105
- package/static/assets/{index-CMaK0hpv.js → index-B-9XKFgb.js} +1 -1
- package/static/assets/{index-ihWq-CVE.js → index-CWt3zgDI.js} +1 -1
- package/static/assets/{index-CkT4WgqR.js → index-Cbo5QxHl.js} +1 -1
- package/static/assets/{index-BknCCMZK.js → index-D2rSjJPF.js} +1 -1
- package/static/assets/{index-Dc9Njo8L.js → index-DFfxOZw8.js} +1 -1
- package/static/assets/{index-BVrOTqTm.js → index-DUwRskPW.js} +1 -1
- package/static/assets/{index-BvZJRqTz.js → index-DaAZbWZV.js} +1 -1
- package/static/assets/{index-DgAcL75U.js → index-DdDCTC_d.js} +1 -1
- package/static/assets/{index-BCYTbJRb.js → index-DdSybLsG.js} +1 -1
- package/static/assets/{index-BPdWQ0rI.js → index-DgFdrtDt.js} +1 -1
- package/static/assets/{index-BL-5Bhtg.js → index-DkobSVA-.js} +1 -1
- package/static/assets/{index-D12O6wM3.js → index-DuWsaYa4.js} +1 -1
- package/static/assets/{index-DK1gGyTZ.js → index-DukcrMyC.js} +1 -1
- package/static/assets/{index-Dnj5cWsp.js → index-I6ZfnFaA.js} +1 -1
- package/static/assets/{index-Hy3cH93B.js → index-QZn_aaqg.js} +1 -1
- package/static/assets/{index-Djzp98Vj.js → index-UM1qitEs.js} +1 -1
- package/static/assets/{index-DIt703WU.js → index-r07pPAcM.js} +1 -1
- package/static/assets/{index-CuLP7P_G.js → index-xBQb0rMo.js} +1 -1
- package/static/assets/{info-DxhTCbw1.js → info-DWORrO-s.js} +1 -1
- package/static/assets/{label-Dp0-28_O.js → label-DyhnItJm.js} +1 -1
- package/static/assets/{markdown-editor-DUmrf1eN.js → markdown-editor-C8LFQE7K.js} +38 -38
- package/static/assets/{message-square-BPOApeM3.js → message-square-CiISW36v.js} +1 -1
- package/static/assets/{paperclip-Bfjc1WLZ.js → paperclip-DRufaOtA.js} +1 -1
- package/static/assets/{pause-Bfz-QQZp.js → pause-GqIUdKFa.js} +1 -1
- package/static/assets/{play-fOwEoIcu.js → play-CkuTY54l.js} +1 -1
- package/static/assets/{radio-group-B8RB7N01.js → radio-group-ClpV676y.js} +1 -1
- package/static/assets/{refresh-cw-Cj_5MZiJ.js → refresh-cw-CYBx0C_n.js} +1 -1
- package/static/assets/{search-BgbqRUnf.js → search-DxiQuWo1.js} +1 -1
- package/static/assets/{select-CfwLZl55.js → select-D_L7OXwN.js} +1 -1
- package/static/assets/{server-u9FLHclt.js → server-CgjJESGe.js} +1 -1
- package/static/assets/{switch-CX_Inx_p.js → switch-DXojpqQ8.js} +1 -1
- package/static/assets/{tabs-Bj0YyeRI.js → tabs-zdz4RlY5.js} +1 -1
- package/static/assets/{tag-rYG4CdRx.js → tag-CeaYtqPJ.js} +1 -1
- package/static/assets/{terminal-preview-BNm5-Umi.js → terminal-preview-CspSfoko.js} +1 -1
- package/static/assets/{triangle-alert-C0ovMJwZ.js → triangle-alert-DTdlIh6V.js} +1 -1
- package/static/assets/{use-terminal-D1UnvAVs.js → use-terminal-DkVoTttR.js} +1 -1
- package/static/assets/{video-CuyRES-H.js → video-5zJ0jcFw.js} +1 -1
- package/static/index.html +1 -1
- package/dist/routes/api/v1/context/architecture/route.d.ts +0 -3
- package/dist/routes/api/v1/context/architecture/route.js +0 -245
- package/dist/routes/api/v1/context/project/route.d.ts +0 -3
- package/dist/routes/api/v1/context/project/route.js +0 -200
- package/static/assets/AgentsContextPage-VfMmxxr6.js +0 -1
- package/static/assets/AuthSettingsPage-CWTpS6BA.js +0 -11
- package/static/assets/CodePage-DwjtGxQi.js +0 -2
- package/static/assets/IntegrationsSettingsPage-DeFQd6af.js +0 -1
- package/static/assets/JobDetailPage-HOLpF7Sx.js +0 -1
- package/static/assets/KnowledgeDetailPage-C5egPQ54.js +0 -1
- package/static/assets/LoginPage-DajEouCN.js +0 -1
- package/static/assets/MailProcessingModal-B1ZLXyYl.js +0 -1
- package/static/assets/McpSettingsPage-BZ6GJOtk.js +0 -1
- package/static/assets/MemoryPage-BV0RlvUS.js +0 -1
- package/static/assets/PromptsSettingsPage-pHKoiUPI.js +0 -1
- package/static/assets/RolePage-Ds17xn4X.js +0 -1
- package/static/assets/SchedulePage-oEGct1B1.js +0 -4
- package/static/assets/SkillDetailPage-mSypV_JK.js +0 -1
- package/static/assets/TeamPage-DSWax4fa.js +0 -1
- package/static/assets/UtilitiesPage-CjLb989o.js +0 -1
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{c as Y,t as le,r as n,bD as l,j as e,bx as O,i as ce,D as I,W as M,B as c,b as V,d as $,f as H,g as J,I as j,Y as z,z as oe,E as de,H as he,J as ue,N as xe,O as me,Q as ge,R as je,U as pe,V as ve,w as r}from"./index-ByTA2ZiD.js";import{C as p,b as v,c as w,d as f,a as y}from"./card-CL5bB4cs.js";import{L as o}from"./label-Dp0-28_O.js";import{S as _,a as W,b as q,c as B,d as a}from"./select-CfwLZl55.js";import{S as E}from"./switch-CX_Inx_p.js";import{B as U}from"./badge-BbfU_aPt.js";import{C as we}from"./circle-alert-vJFSz39V.js";import"./index-CuLP7P_G.js";import"./chevron-up-BwTmMEW2.js";/**
|
|
2
|
-
* @license lucide-react v0.542.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const fe=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],ye=Y("key-round",fe);/**
|
|
7
|
-
* @license lucide-react v0.542.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Ne=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Se=Y("user-plus",Ne);function Re(){const{user:N,authEnabled:K,checkAuthStatus:Q}=le(),[i,d]=n.useState(null),[G,k]=n.useState(!0),[F,D]=n.useState(!1),[X,S]=n.useState(!1),[C,P]=n.useState(""),[b,R]=n.useState(""),[T,L]=n.useState("viewer"),[A,h]=n.useState(null),[u,x]=n.useState(""),Z=!K||N?.role==="admin";n.useEffect(()=>{m()},[]);const m=async()=>{try{k(!0);const s=await l("/api/v1/auth-settings");s.success?d(s.data):d(null)}catch(s){console.error("Failed to load auth settings:",s),d(null)}finally{k(!1)}},ee=async()=>{if(!i)return;const s=!i.enabled;try{const t=await l("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({enabled:s})});if(t.success)d({...i,enabled:s}),await Q(),r({title:"Success",description:`Authentication ${s?"enabled":"disabled"}`});else throw new Error(t.error||"Failed to toggle auth")}catch(t){r({title:"Error",description:t.message||"Failed to toggle authentication",variant:"destructive"})}},se=async()=>{if(!i)return;const s=!i.allowRegistration;try{const t=await l("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({allowRegistration:s})});if(t.success)d({...i,allowRegistration:s}),r({title:"Success",description:`Self-registration ${s?"enabled":"disabled"}`});else throw new Error(t.error||"Failed to update setting")}catch(t){r({title:"Error",description:t.message||"Failed to update setting",variant:"destructive"})}},te=async()=>{if(!C||!b){r({title:"Error",description:"Please provide email and name",variant:"destructive"});return}try{const s=await l("/api/v1/auth-settings/users",{method:"POST",body:JSON.stringify({email:C,name:b,role:T})});if(s.success)await m(),S(!1),P(""),R(""),L("viewer"),r({title:"Success",description:"User added to whitelist"});else throw new Error(s.error||"Failed to add user")}catch(s){r({title:"Error",description:s.message||"Failed to add user",variant:"destructive"})}},ie=async s=>{try{const t=await l(`/api/v1/auth-settings/users/${s}`,{method:"DELETE"});if(t.success)await m(),r({title:"Success",description:"User removed from whitelist"});else throw new Error(t.error||"Failed to remove user")}catch(t){r({title:"Error",description:t.message||"Failed to remove user",variant:"destructive"})}},re=async(s,t)=>{try{const g=await l(`/api/v1/auth-settings/users/${s}`,{method:"PUT",body:JSON.stringify({role:t})});if(g.success)await m(),r({title:"Success",description:"User role updated"});else throw new Error(g.error||"Failed to update role")}catch(g){r({title:"Error",description:g.message||"Failed to update role",variant:"destructive"})}},ae=async()=>{if(!(!A||!u)){if(u.length<8){r({title:"Error",description:"Password must be at least 8 characters",variant:"destructive"});return}try{const s=await l(`/api/v1/auth-settings/users/${A}/reset-password`,{method:"POST",body:JSON.stringify({newPassword:u})});if(s.success)h(null),x(""),r({title:"Success",description:"Password reset successfully"});else throw new Error(s.error||"Failed to reset password")}catch(s){r({title:"Error",description:s.message||"Failed to reset password",variant:"destructive"})}}},ne=async()=>{if(i)try{D(!0);const s=await l("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({session:i.session})});if(s.success)r({title:"Success",description:"Session settings updated"});else throw new Error(s.error||"Failed to update settings")}catch(s){r({title:"Error",description:s.message||"Failed to update settings",variant:"destructive"})}finally{D(!1)}};return G?e.jsx("div",{children:"Loading..."}):i?Z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage authentication settings and user access."})]}),e.jsx(O,{}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"}),e.jsx(w,{children:"Authentication Status"})]}),e.jsx(f,{children:"Control whether authentication is required to access Coconut."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"auth-enabled",children:"Require Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"When enabled, users must log in to access Coconut"})]}),e.jsx(E,{id:"auth-enabled",checked:i.enabled,onCheckedChange:ee})]}),i.enabled&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"allow-registration",children:"Allow Self-Registration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Whitelisted users can create their own accounts"})]}),e.jsx(E,{id:"allow-registration",checked:i.allowRegistration,onCheckedChange:se})]})]})]}),e.jsxs(p,{children:[e.jsx(v,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(w,{children:"Whitelisted Users"}),e.jsx(f,{children:"Manage users who can access this Coconut instance."})]}),e.jsxs(I,{open:X,onOpenChange:S,children:[e.jsx(M,{asChild:!0,children:e.jsxs(c,{size:"sm",children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Add User"]})}),e.jsxs(V,{children:[e.jsxs($,{children:[e.jsx(H,{children:"Add User to Whitelist"}),e.jsx(J,{children:"Add a user's email to allow them to register and access Coconut."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-email",children:"Email"}),e.jsx(j,{id:"new-email",type:"email",value:C,onChange:s=>P(s.target.value),placeholder:"user@example.com"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-name",children:"Name"}),e.jsx(j,{id:"new-name",value:b,onChange:s=>R(s.target.value),placeholder:"User Name"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-role",children:"Role"}),e.jsxs(_,{value:T,onValueChange:s=>L(s),children:[e.jsx(W,{children:e.jsx(q,{})}),e.jsxs(B,{children:[e.jsx(a,{value:"viewer",children:"Viewer"}),e.jsx(a,{value:"engineer",children:"Engineer"}),e.jsx(a,{value:"designer",children:"Designer"}),e.jsx(a,{value:"product_manager",children:"Product Manager"}),e.jsx(a,{value:"manager",children:"Manager"}),e.jsx(a,{value:"admin",children:"Admin"})]})]})]})]}),e.jsxs(z,{children:[e.jsx(c,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(c,{onClick:te,children:"Add User"})]})]})]})]})}),e.jsx(y,{children:e.jsx("div",{className:"space-y-4",children:i.providers.local.users.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:s.name}),s.registered?e.jsx(U,{variant:"default",className:"text-xs",children:"Registered"}):e.jsx(U,{variant:"secondary",className:"text-xs",children:"Pending"}),s.id===N?.id&&e.jsx(U,{variant:"outline",className:"text-xs",children:"You"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.email}),s.lastLoginAt&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last login: ",new Date(s.lastLoginAt).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_,{value:s.role,onValueChange:t=>re(s.id,t),children:[e.jsx(W,{className:"w-40",children:e.jsx(q,{})}),e.jsxs(B,{children:[e.jsx(a,{value:"viewer",children:"Viewer"}),e.jsx(a,{value:"engineer",children:"Engineer"}),e.jsx(a,{value:"designer",children:"Designer"}),e.jsx(a,{value:"product_manager",children:"Product Manager"}),e.jsx(a,{value:"manager",children:"Manager"}),e.jsx(a,{value:"admin",children:"Admin"})]})]}),e.jsxs(I,{open:A===s.id,onOpenChange:t=>{t||(h(null),x(""))},children:[e.jsx(M,{asChild:!0,children:e.jsx(c,{size:"sm",variant:"outline",onClick:()=>h(s.id),children:e.jsx(ye,{className:"h-4 w-4"})})}),e.jsxs(V,{children:[e.jsxs($,{children:[e.jsx(H,{children:"Reset Password"}),e.jsxs(J,{children:["Set a new password for ",s.name]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{children:[e.jsx(o,{htmlFor:"reset-password",children:"New Password"}),e.jsx(j,{id:"reset-password",type:"password",value:u,onChange:t=>x(t.target.value),placeholder:"At least 8 characters",minLength:8})]})}),e.jsxs(z,{children:[e.jsx(c,{variant:"outline",onClick:()=>{h(null),x("")},children:"Cancel"}),e.jsx(c,{onClick:ae,children:"Reset Password"})]})]})]}),s.id!==N?.id&&e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsx(c,{size:"sm",variant:"destructive",children:e.jsx(he,{className:"h-4 w-4"})})}),e.jsxs(ue,{children:[e.jsxs(xe,{children:[e.jsx(me,{children:"Remove User"}),e.jsxs(ge,{children:["Are you sure you want to remove ",s.name," from the whitelist? They will no longer be able to access Coconut."]})]}),e.jsxs(je,{children:[e.jsx(pe,{children:"Cancel"}),e.jsx(ve,{onClick:()=>ie(s.id),children:"Remove"})]})]})]})]})]},s.id))})})]}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsx(w,{children:"Session Settings"}),e.jsx(f,{children:"Configure session behavior and security."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"session-expiry",children:"Session Expiry"}),e.jsx(j,{id:"session-expiry",value:i.session.expiresIn,onChange:s=>d({...i,session:{...i.session,expiresIn:s.target.value}}),placeholder:"7d"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Format: 30s, 15m, 24h, 7d"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"secure-cookies",children:"Secure Cookies (HTTPS only)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enable in production with HTTPS"})]}),e.jsx(E,{id:"secure-cookies",checked:i.session.secure||!1,onCheckedChange:s=>d({...i,session:{...i.session,secure:s}})})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(c,{onClick:ne,disabled:F,children:F?"Saving...":"Save Session Settings"})})]}):e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have permission to manage authentication settings."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Secure your Coconut instance with authentication."})]}),e.jsx(O,{}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-5 w-5 text-muted-foreground"}),e.jsx(w,{children:"Authentication Not Configured"})]}),e.jsx(f,{children:"Authentication has not been initialized. Use the CLI to set up authentication."})]}),e.jsxs(y,{children:[e.jsx("div",{className:"bg-muted p-4 rounded-md",children:e.jsxs("code",{className:"text-sm",children:["$ nut auth init",e.jsx("br",{}),"$ nut auth toggle"]})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"This will create an admin user and enable authentication for your Coconut instance."})]})]})]})}export{Re as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{u as ce,a as de,r as i,j as e,B as r,T as oe,n as M,X as me,F as xe,_ as he,D as ue,b as fe,d as pe,f as je,k as ge,a4 as B,a5 as R,a6 as H,a7 as L,a8 as O,a9 as _,o as ve,A as T}from"./index-ByTA2ZiD.js";import{C as g,b as Ne,a as G,c as ye}from"./card-CL5bB4cs.js";import{B as U}from"./badge-BbfU_aPt.js";import{u as we}from"./use-terminal-D1UnvAVs.js";import{T as Se}from"./terminal-preview-BNm5-Umi.js";import{S as Ce,a as be,b as ke,c as Ae,d as w}from"./select-CfwLZl55.js";import{b as De,e as Me,d as Te,c as Ie,a as $e}from"./pipeline-builders-DrEjlsbH.js";import{R as Ee}from"./refresh-cw-Cj_5MZiJ.js";import{C as Pe,a as ze}from"./chevrons-up-jI6nxhrz.js";import{P as Fe}from"./play-fOwEoIcu.js";import{C as Be}from"./code-DqYaanki.js";import{C as Re}from"./chevron-up-BwTmMEW2.js";import{S as He}from"./server-u9FLHclt.js";import"./xterm-DTxiCjtJ.js";import"./index-CuLP7P_G.js";const Le=c=>c?Array.isArray(c)?c.filter(x=>typeof x=="string").map(x=>x.trim()).filter(Boolean):typeof c=="string"?c.split(",").map(x=>x.trim()).filter(Boolean):[]:[];function ts(){const c=ce(),{sessions:x,loading:b,error:I,refreshSessions:S,createSession:V,destroySession:K}=we(),{toast:v}=de(),[$,W]=i.useState([]),[q,X]=i.useState(!0),[j,k]=i.useState(()=>({})),[A,N]=i.useState(!1),[f,J]=i.useState("claude"),[E,Q]=i.useState(""),[D,P]=i.useState(!1),[h,Y]=i.useState([]),[p,y]=i.useState([]),[Z,ee]=i.useState({}),[u,se]=i.useState([]),[o,C]=i.useState([]),te=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const d=Math.floor(n/60);if(d<60)return`${d}m ago`;const l=Math.floor(d/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`};i.useEffect(()=>{(async()=>{try{const t=await fetch(`${T}/api/v1/tasks`);if(t.ok){const a=await t.json(),n=a.data||a;W(Array.isArray(n)?n:[])}}catch(t){console.error("Error loading tasks:",t)}finally{X(!1)}})()},[]),i.useEffect(()=>{S()},[S]),i.useEffect(()=>{if(!A)return;(async()=>{try{const t=await fetch(`${T}/api/v1/mcp`);if(t.ok){const a=await t.json();a?.success&&Array.isArray(a.servers)&&(Y(a.servers),y(n=>n.filter(d=>a.servers.includes(d))),a.mcpServers&&typeof a.mcpServers=="object"&&ee(a.mcpServers))}}catch(t){console.error("Failed to load MCP servers",t)}try{const t=await fetch(`${T}/api/v1/skills`);if(t.ok){const a=await t.json(),d=(Array.isArray(a?.documents)?a.documents:[]).map(l=>({id:l.id,name:l?.metadata?.name||l.id,mcpServers:Le(l?.metadata?.metadata?.mcpServers)}));se(d),C(l=>l.filter(F=>d.some(le=>le.id===F)))}}catch(t){console.error("Failed to load skills",t)}})()},[A]),i.useEffect(()=>{o.length!==0&&y(s=>{const t=new Set(s),a=h.length>0?new Set(h):void 0;return o.forEach(n=>{const d=u.find(l=>l.id===n);d&&d.mcpServers.forEach(l=>{(!a||a.has(l))&&t.add(l)})}),Array.from(t)})},[o,u,h]);const m=i.useMemo(()=>x.filter(s=>s.taskId?.startsWith("cp-")||s.taskId?.startsWith("ag-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[x]);i.useEffect(()=>{k(s=>{const t={...s};return m.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[m]);const z=i.useMemo(()=>$.filter(s=>s.status==="draft"||s.status==="ready").sort((s,t)=>new Date(t.metadata.createdAt).getTime()-new Date(s.metadata.createdAt).getTime()).slice(0,3),[$]),ae=()=>{const s=m.every(a=>j[a.id]),t={};m.forEach(a=>{t[a.id]=!s}),k(t)},ie=m.length>0&&m.every(s=>j[s.id]),ne=async s=>{await K(s)?(v({title:"Session closed",description:s}),setTimeout(()=>S(),100)):v({title:"Failed to close session",description:s,variant:"destructive"})},re=async()=>{P(!0);try{const s=`session-${Date.now()}`,t={taskId:s,contextType:"change-task",cliAgent:f,mcpServersMap:Z,selectedMcpServers:p,skills:u,selectedSkillIds:o,automationEnabled:!1,customInstruction:E.trim(),includeDefaultInstructions:!1};let a="";f==="claude"?a=De(t):f==="gemini"?a=Me(t):f==="codex"?a=Te(t):f==="droid"?a=Ie(t):f==="kiro"&&(a=$e(t)),await V(s,a)?(v({title:"Coding session started",description:`Session ${s} created`}),N(!1),c(`/terminal/${s}`)):v({title:"Failed to start session",description:"Could not create terminal session",variant:"destructive"})}catch(s){console.error("Error starting coding session:",s),v({title:"Error",description:"Failed to start coding session",variant:"destructive"})}finally{P(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Agents"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage agents and their active sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>S(),disabled:b,children:[e.jsx(Ee,{className:`h-4 w-4 sm:mr-2 ${b?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),m.length>0&&e.jsx(r,{variant:"outline",size:"sm",onClick:ae,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ze,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{size:"sm",onClick:()=>N(!0),children:[e.jsx(Fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Interactive Session"})]})]})]}),I&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:I})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),b?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(g,{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):m.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(Be,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching an"," ",e.jsx("button",{onClick:()=>N(!0),className:"text-primary hover:underline font-medium",children:"Interactive Session"})," ","or working on a"," ",e.jsx("button",{onClick:()=>c("/tasks"),className:"text-primary hover:underline font-medium",children:"New Task"})]})]})]})}):e.jsx("div",{className:"space-y-2",children:m.slice(0,10).map(s=>e.jsxs(g,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(oe,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:s.taskId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",te(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{k(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":j[s.id]?"Hide preview":"Show preview",title:j[s.id]?"Hide preview":"Show preview",children:j[s.id]?e.jsx(Re,{className:"h-4 w-4"}):e.jsx(M,{className:"h-4 w-4"})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>c(`/terminal/${s.taskId}`),children:"Open"}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>ne(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(me,{className:"h-4 w-4"})})]})]}),j[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>c(`/terminal/${s.taskId}`),title:"Click to open full terminal session",children:e.jsx(Se,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"New Tasks"}),q?e.jsx("div",{className:"space-y-3",children:[...Array(3)].map((s,t)=>e.jsx(g,{children:e.jsx(Ne,{className:"py-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 animate-pulse"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/3 animate-pulse"})]}),e.jsx("div",{className:"h-5 bg-muted rounded w-16 animate-pulse"})]})})},t))}):z.length===0?e.jsx(g,{children:e.jsx(G,{className:"flex items-center justify-center py-6",children:e.jsx("div",{className:"text-center text-sm text-gray-500",children:"No draft or approved tasks found"})})}):e.jsx("div",{className:"space-y-2",children:z.map(s=>e.jsx(g,{className:"hover:shadow-md transition-all cursor-pointer hover:border-primary/50",onClick:()=>c(`/terminal/${s.id}`),children:e.jsx(G,{className:"py-4",children:e.jsx("div",{className:"flex justify-between items-start gap-4",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(ye,{className:"text-base leading-tight",children:s.title||s.intent}),e.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[s.priority&&e.jsx(U,{variant:s.priority==="high"||s.priority==="critical"?"destructive":s.priority==="medium"?"secondary":"outline",className:"text-xs",children:s.priority}),e.jsx(U,{variant:"default",className:"text-xs",children:s.status})]})]}),s.content&&e.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[s.content.split(`
|
|
2
|
-
`).slice(0,2).join(" ").substring(0,150),s.content.length>150?"...":""]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.id," • by ",s.author.name," • ",new Date(s.metadata.createdAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex gap-2",onClick:t=>t.stopPropagation(),children:[e.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>c(`/tasks/${s.id}`),className:"h-7 px-2 text-xs",children:[e.jsx(xe,{className:"h-3 w-3 mr-1"})," View"]}),e.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>c(`/tasks/${s.id}/edit`),className:"h-7 px-2 text-xs",children:[e.jsx(he,{className:"h-3 w-3 mr-1"})," Edit"]})]})]})]})})})},s.id))})]}),e.jsx(ue,{open:A,onOpenChange:N,children:e.jsxs(fe,{className:"max-w-lg",children:[e.jsxs(pe,{children:[e.jsx(je,{children:"Start Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Start an interactive session"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Agent"}),e.jsxs(Ce,{value:f,onValueChange:s=>J(s),children:[e.jsx(be,{className:"w-full",children:e.jsx(ke,{placeholder:"Select coding agent"})}),e.jsxs(Ae,{children:[e.jsx(w,{value:"claude",children:"Claude Code"}),e.jsx(w,{value:"gemini",children:"Google Gemini"}),e.jsx(w,{value:"codex",children:"OpenAI Codex"}),e.jsx(w,{value:"droid",children:"Factory Droid"}),e.jsx(w,{value:"kiro",children:"Kiro"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4"}),"Skills"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[o.length," of ",u.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(r,{variant:"outline",className:"w-full justify-between",children:[o.length===0?"Select skills...":o.length===u.length?"All skills selected":`${o.length} skill${o.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(H,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(L,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Skills"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),C(u.map(t=>t.id))},children:"All"}),e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),C([])},children:"None"})]})]}),e.jsx(O,{}),u.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No skills found"}):u.map(s=>e.jsx(_,{checked:o.includes(s.id),onCheckedChange:t=>{C(a=>t?a.includes(s.id)?a:[...a,s.id]:a.filter(n=>n!==s.id))},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:s.name}),s.mcpServers.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP servers: ",s.mcpServers.join(", ")]}),s.mcpServers.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inherits available MCP servers"})]})},s.id))]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(He,{className:"h-4 w-4"}),"MCP Servers"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[p.length," of ",h.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(r,{variant:"outline",className:"w-full justify-between",children:[p.length===0?"Select MCP servers...":p.length===h.length?"All servers selected":`${p.length} server${p.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(H,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(L,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Servers"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y(h)},children:"All"}),e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y([])},children:"None"})]})]}),e.jsx(O,{}),h.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No MCP servers found"}):h.map(s=>e.jsx(_,{checked:p.includes(s),onCheckedChange:t=>{y(a=>t?a.includes(s)?a:[...a,s]:a.filter(n=>n!==s))},children:s},s))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Additional Instructions (optional)"}),e.jsx(ve,{value:E,onChange:s=>Q(s.target.value),placeholder:"Add any custom instructions for the coding agent...",rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(r,{variant:"outline",onClick:()=>N(!1),disabled:D,children:"Cancel"}),e.jsx(r,{onClick:re,disabled:D,children:D?"Starting...":"Start Session"})]})]})]})})]})}export{ts as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as d,bD as A,w as i,j as e,bx as K,e as f,n as j,C as y,ad as v,I as N,B as r,H as b,a1 as k,h as $}from"./index-ByTA2ZiD.js";import{C as _,b as F,c as E,d as M,a as G}from"./card-CL5bB4cs.js";import{L as m}from"./label-Dp0-28_O.js";import{S as Q,a as W,b as X,c as Z,d as ee}from"./select-CfwLZl55.js";import{G as se}from"./globe-lpD9Jv31.js";import"./index-CuLP7P_G.js";import"./chevron-up-BwTmMEW2.js";const te=[{id:"openai/gpt-4o",label:"GPT-4o",provider:"openai",supportsMCP:!0,strengths:["balanced","reasoning","code","tools"],notes:"Great general model with tool/function calling support."},{id:"openai/gpt-4o-mini",label:"GPT-4o Mini",provider:"openai",supportsMCP:!0,strengths:["cost-effective","fast","tools"],notes:"Good for quick, inexpensive tasks with function calling."},{id:"openai/gpt-4.1",label:"GPT-4.1",provider:"openai",supportsMCP:!0,strengths:["coding","instruction following","long context"],notes:"Latest GPT-4 series with enhanced capabilities."},{id:"openai/o3-mini",label:"o3-mini",provider:"openai",supportsMCP:!0,strengths:["reasoning","math","coding"],notes:"Reasoning model optimized for efficiency."},{id:"anthropic/claude-sonnet-4.5",label:"Claude Sonnet 4.5",provider:"anthropic",supportsMCP:!0,strengths:["agents","coding","tools","fast","long context"],notes:"Most advanced Sonnet - 1.5-2x faster, optimized for agents and tool orchestration."},{id:"anthropic/claude-sonnet-4",label:"Claude Sonnet 4",provider:"anthropic",supportsMCP:!0,strengths:["reasoning","analysis","tools","coding"],notes:"Excellent tool use and reasoning capabilities."},{id:"anthropic/claude-3.5-sonnet",label:"Claude 3.5 Sonnet",provider:"anthropic",supportsMCP:!0,strengths:["reasoning","analysis","tools"],notes:"Reliable Claude model with strong tool support."},{id:"google/gemini-2.0-flash-001",label:"Gemini 2.0 Flash",provider:"google",supportsMCP:!0,strengths:["speed","multimodal","tools"],notes:"Fast Google model with function calling."},{id:"meta-llama/llama-3.1-405b-instruct",label:"Llama 3.1 405B",provider:"meta-llama",supportsMCP:!0,strengths:["reasoning","open weights","code"],notes:"High-capacity open model; function calling often available."},{id:"qwen/qwen-2.5-72b-instruct",label:"Qwen 2.5 72B",provider:"qwen",supportsMCP:!0,strengths:["cost-effective","code","tools"],notes:"Strong value open model with tool support."}],ae={models:te},re=ae;function z(){return re.models}function xe(){const[t,O]=d.useState({}),[n,R]=d.useState(!0),[D,L]=d.useState(!1),[x,U]=d.useState({}),[I,q]=d.useState({}),[H,Y]=d.useState(z()[0]?.id||"openai/gpt-4o"),[l,J]=d.useState({openrouter:!1,replicate:!1,anthropic:!1,openai:!1,gemini:!1,factorydroid:!1,callbackToken:!1});d.useEffect(()=>{P()},[]);const P=async()=>{try{R(!0);const s=await A("/api/v1/config?type=global");if(s.success&&s.data){const a=s.data.apiKeys||{},o={},c={};for(const C of["openrouter","replicate","anthropic","openai","gemini","factorydroid","callbackToken"]){const S=a[C];S&&typeof S=="string"&&S.trim()!==""?(o[C]=!0,c[C]="***"):(o[C]=!1,c[C]="")}O(c);const T=s.data.defaults&&s.data.defaults.model?String(s.data.defaults.model):void 0;Y(T||z()[0]?.id||"openai/gpt-4o")}}catch(s){console.error("Failed to load API keys:",s),i({title:"Error",description:"Failed to load API keys",variant:"destructive"})}finally{R(!1)}},p=(s,a)=>{O(o=>({...o,[s]:a}))},B=async s=>{try{q(T=>({...T,[s]:!0}));const a=t[s],o={provider:s};a&&a!=="***"&&(o.key=a);const c=await A("/api/v1/config/test",{method:"POST",body:JSON.stringify(o)});c.success&&c.message?i({title:"Test Result",description:c.message}):c.success?i({title:"Test Result",description:"Success"}):i({title:"Test Failed",description:c.message||"Unknown error",variant:"destructive"})}catch(a){i({title:"Test Failed",description:a instanceof Error?a.message:"Unknown error",variant:"destructive"})}finally{q(a=>({...a,[s]:!1}))}},h=s=>{J(a=>({...a,[s]:!a[s]}))},u=async s=>{try{const a={[s]:""};await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),i({title:"Success",description:`${s} API key cleared`}),await P()}catch(a){console.error("Failed to clear API key:",a),i({title:"Error",description:"Failed to clear API key",variant:"destructive"})}},g=async s=>{try{U(o=>({...o,[s]:!0}));const a={[s]:t[s]};await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),i({title:"Success",description:`${s} API key saved`}),await P()}catch(a){console.error("Failed to save API key:",a),i({title:"Error",description:"Failed to save API key",variant:"destructive"})}finally{U(a=>({...a,[s]:!1}))}},V=async()=>{try{L(!0),await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({defaults:{model:H}})}),i({title:"Success",description:"Default model saved successfully"})}catch(s){console.error("Failed to save default model:",s),i({title:"Error",description:"Failed to save default model",variant:"destructive"})}finally{L(!1)}},w={openrouter:"OPENROUTER_API_KEY",replicate:"REPLICATE_API_TOKEN",anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GEMINI_API_KEY",factorydroid:"FACTORY_API_KEY"};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"AI & LLM"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Coconut's connections to LLM providers."})]}),e.jsx(K,{}),e.jsxs(_,{children:[e.jsxs(F,{children:[e.jsx(E,{children:"API Keys & Authentication"}),e.jsx(M,{children:"Manage API keys and authentication tokens for integrated services."})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"AI Assistant API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used by the AI Assistant sidebar for chat and code suggestions."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("openrouter"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.openrouter&&t.openrouter!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.openrouter?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenRouter"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.openrouter})]})]}),t.openrouter&&t.openrouter!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.openrouter&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openrouterKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"openrouterKey",type:"password",placeholder:"sk-or-v1-...",className:"flex-1",value:t.openrouter||"",onChange:s=>p("openrouter",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openrouter"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>B("openrouter"),disabled:!!I.openrouter,title:"Test API key",children:I.openrouter?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openrouter"),disabled:x.openrouter||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenRouter"})]})]})]}),e.jsx(K,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Resource Creation API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used for generating images and other resources."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("replicate"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.replicate&&t.replicate!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.replicate?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Replicate"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.replicate})]})]}),t.replicate&&t.replicate!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.replicate&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"replicateKey",children:"API Token"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"replicateKey",type:"password",placeholder:"r8_...",className:"flex-1",value:t.replicate||"",onChange:s=>p("replicate",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("replicate"),title:"Clear API token",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>B("replicate"),disabled:!!I.replicate,title:"Test API token",children:I.replicate?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("replicate"),disabled:x.replicate||n,title:"Save API token",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token from"," ",e.jsx("a",{href:"https://replicate.com/account/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Replicate"})]})]})]}),e.jsx(K,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Coding Agent API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These keys are automatically provided to coding agents when they start running."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("anthropic"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.anthropic&&t.anthropic!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.anthropic?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Anthropic Claude"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.anthropic})]})]}),t.anthropic&&t.anthropic!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.anthropic&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"anthropicKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"anthropicKey",type:"password",placeholder:"sk-ant-...",className:"flex-1",value:t.anthropic||"",onChange:s=>p("anthropic",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("anthropic"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("anthropic"),disabled:x.anthropic||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://console.anthropic.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Anthropic Console"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("openai"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.openai&&t.openai!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.openai?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenAI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.openai})]})]}),t.openai&&t.openai!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.openai&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openaiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"openaiKey",type:"password",placeholder:"sk-...",className:"flex-1",value:t.openai||"",onChange:s=>p("openai",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openai"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openai"),disabled:x.openai||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenAI Platform"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("gemini"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.gemini&&t.gemini!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.gemini?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Google Gemini"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.gemini})]})]}),t.gemini&&t.gemini!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.gemini&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"geminiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"geminiKey",type:"password",placeholder:"AIza...",className:"flex-1",value:t.gemini||"",onChange:s=>p("gemini",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("gemini"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("gemini"),disabled:x.gemini||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://makersuite.google.com/app/apikey",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Google AI Studio"})]})]})]}),e.jsxs("div",{className:"border rounded-lg mt-4",children:[e.jsxs("button",{onClick:()=>h("factorydroid"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.factorydroid&&t.factorydroid!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.factorydroid?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Factory Droid"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w.factorydroid})]})]}),t.factorydroid&&t.factorydroid!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.factorydroid&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"factorydroidKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"factorydroidKey",type:"password",placeholder:"fd-...",className:"flex-1",value:t.factorydroid||"",onChange:s=>p("factorydroid",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("factorydroid"),title:"Clear API key",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("factorydroid"),disabled:x.factorydroid||n,title:"Save API key",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://factorydroid.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Factory Droid"})]})]})]})]})]}),e.jsxs(_,{children:[e.jsxs(F,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-5 w-5"}),e.jsx(E,{children:"Coconut Control Plane"})]}),e.jsxs(M,{children:["Connect to the"," ",e.jsx("a",{href:"https://app.coconut.dev",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Coconut Dashboard"})," ","to access third-party connectors (Google Drive, Slack, HubSpot, Stripe, and more)."]})]}),e.jsx(G,{className:"space-y-4",children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("callbackToken"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex items-center justify-center w-8 h-8 rounded-md",t.callbackToken&&t.callbackToken!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:l.callbackToken?e.jsx(j,{className:"h-4 w-4"}):e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Callback Token"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"COCONUT_CALLBACK_TOKEN"})]})]}),t.callbackToken&&t.callbackToken!==""&&e.jsx(v,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),l.callbackToken&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"callbackTokenKey",children:"Callback Token"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(N,{id:"callbackTokenKey",type:"password",placeholder:"cpt_...",className:"flex-1",value:t.callbackToken||"",onChange:s=>p("callbackToken",s.target.value),disabled:n}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("callbackToken"),title:"Clear callback token",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("callbackToken"),disabled:x.callbackToken||n,title:"Save callback token",children:e.jsx(k,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Find your callback token in the"," ",e.jsx("a",{href:"https://app.coconut.dev",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Coconut Dashboard"}),". This token enables the ",e.jsx("code",{className:"text-xs",children:"list_connectors"})," and ",e.jsx("code",{className:"text-xs",children:"connector_request"})," tools."]})]})]})})]}),e.jsxs(_,{children:[e.jsxs(F,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),e.jsx(E,{children:"AI Assistant Settings"})]}),e.jsx(M,{children:"Configure default AI model and behavior for the AI assistant sidebar."})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"defaultModel",children:"Default AI Model"}),e.jsxs(Q,{value:H,onValueChange:Y,children:[e.jsx(W,{children:e.jsx(X,{placeholder:"Select default AI model"})}),e.jsx(Z,{children:z().map(s=>e.jsx(ee,{value:s.id,children:s.label},s.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This model will be selected by default when opening the AI assistant."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(r,{onClick:V,disabled:D||n,children:D?"Saving...":"Save"})})]})]})]})}export{xe as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as Y,u as Z,a as ee,ac as se,r as l,j as e,B as d,L as p,v as D,z as te,E as ae,H as re,J as ne,N as ie,O as de,Q as le,R as ce,U as oe,V as me,k as z,C as ue,_ as xe,bx as B,m as he,A as C}from"./index-ByTA2ZiD.js";import{c as je}from"./clipboard-B9ndUJKl.js";import{C as c,b as f,a as o,c as g,d as H}from"./card-CL5bB4cs.js";import{B as N}from"./badge-BbfU_aPt.js";import{A as $}from"./arrow-left-B9NBHEkS.js";import{P as k}from"./play-fOwEoIcu.js";import{C as pe,a as fe}from"./clipboard-BHOFelnW.js";import{S as ge}from"./server-u9FLHclt.js";import{R as Ne}from"./refresh-cw-Cj_5MZiJ.js";import{P as be}from"./pause-Bfz-QQZp.js";import{C as O}from"./clock-D-X3KCw6.js";const ve=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"},{id:"kiro",label:"Kiro"}],b=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},T=a=>{if(!a)return"—";const n=new Date(a).getTime()-Date.now(),i=Math.round(n/(1e3*60));if(Number.isNaN(i))return b(a);if(Math.abs(i)<1)return"now";if(i>0){if(i<60)return`in ${i}m`;const x=Math.round(i/60);return x<24?`in ${x}h`:`in ${Math.round(x/24)}d`}const s=Math.abs(i);if(s<60)return`${s}m ago`;const u=Math.round(s/60);return u<24?`${u}h ago`:`${Math.round(u/24)}d ago`},we=a=>{if(a.type==="interval"){const m=a.daysOfWeek.map(n=>n.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${m||"All days"})`}return a.description||`Cron: ${a.expression}`},ye=a=>{const m=ve.find(n=>n.id===a);return m?m.label:a},R=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}};function Pe(){const{id:a}=Y(),m=Z(),{toast:n}=ee(),{refresh:i}=se(),[s,u]=l.useState(null),[E,x]=l.useState(!0),[v,I]=l.useState(null),[J,P]=l.useState(!1),[A,M]=l.useState(!1),[h,F]=l.useState(!1),[G,U]=l.useState(!1),S=async()=>{if(a)try{x(!0);const r=await(await fetch(`${C}/api/v1/jobs/${a}`)).json();r.success?u(r.data):I(r.error?.message||"Failed to fetch job")}catch(t){I(t instanceof Error?t.message:"Unknown error")}finally{x(!1)}};l.useEffect(()=>{S()},[a]);const V=async()=>{if(a){P(!0);try{const r=await(await fetch(`${C}/api/v1/jobs/${a}`,{method:"DELETE"})).json();r.success?(n({title:"Job deleted",description:s?.name||"Scheduled job has been deleted"}),m("/schedule")):n({title:"Failed to delete job",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(t){n({title:"Failed to delete job",description:t instanceof Error?t.message:"Unknown error",variant:"destructive"})}finally{P(!1)}}},q=async()=>{if(!s||!a)return;M(!0);const t=s.status==="active"?"paused":"active";try{const j=await(await fetch(`${C}/api/v1/jobs/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})})).json();j.success?(u(j.data),await i(),n({title:t==="active"?"Job resumed":"Job paused",description:s.name})):n({title:"Failed to update job",description:j.error?.message||"Unknown error",variant:"destructive"})}catch(r){n({title:"Failed to update job",description:r instanceof Error?r.message:"Unknown error",variant:"destructive"})}finally{M(!1)}},L=async()=>{if(!(!s||!a)){F(!0);try{const t=await fetch(`${C}/api/v1/jobs/${a}/run`,{method:"POST"}),r=await t.json();r.success||t.ok?(n({title:"Run started",description:`${s.name} is executing.`}),await S(),await i()):n({title:"Failed to start run",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(t){n({title:"Failed to start run",description:t instanceof Error?t.message:"Unknown error",variant:"destructive"})}finally{F(!1)}}},K=(t,r)=>{if(!r)return"—";const j=new Date(r).getTime()-new Date(t).getTime();if(j<1e3)return"<1s";const w=Math.floor(j/1e3);if(w<60)return`${w}s`;const y=Math.floor(w/60),Q=w%60;if(y<60)return`${y}m ${Q}s`;const W=Math.floor(y/60),X=y%60;return`${W}h ${X}m`};if(E)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx(d,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx($,{className:"h-4 w-4"})})})]}),e.jsxs(c,{children:[e.jsx(f,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]})}),e.jsx(o,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-5/6 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-4/6 animate-pulse"})]})})]})]});if(v||!s)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:v||"Job not found"})}),e.jsx(d,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx($,{className:"h-4 w-4"})})})]}),e.jsx(c,{children:e.jsx(o,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:v||"Job not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The job with ID "',a,'" could not be found.']}),e.jsx(d,{asChild:!0,className:"mt-4",children:e.jsx(p,{to:"/schedule",children:"Back to Schedule"})})]})})})]});const _=s.agentIds||(s.agentId?[s.agentId]:[]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.name}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(d,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(p,{to:"/schedule",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx($,{className:"h-4 w-4"})})}),e.jsxs(d,{variant:"default",size:"sm",onClick:L,disabled:h||!!s._error,children:[h?e.jsx(D,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(k,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:h?"Running...":"Run Now"})]}),e.jsxs(te,{children:[e.jsx(ae,{asChild:!0,children:e.jsxs(d,{variant:"destructive",size:"sm",disabled:J,children:[e.jsx(re,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:J?"Deleting...":"Delete"})]})}),e.jsxs(ne,{children:[e.jsxs(ie,{children:[e.jsx(de,{children:"Are you absolutely sure?"}),e.jsxs(le,{children:["This action cannot be undone. This will permanently delete the scheduled job",e.jsxs("span",{className:"font-semibold",children:[' "',s.name,'"']}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(ce,{children:[e.jsx(oe,{children:"Cancel"}),e.jsx(me,{onClick:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Job"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const t=`.nut/jobs/job-${s.id}.md`;try{await je(t),U(!0),n({title:"Copied!",description:`${t} copied to clipboard`}),setTimeout(()=>U(!1),2e3)}catch(r){console.error("Failed to copy path:",r),n({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono",children:[e.jsx("span",{children:`.nut/jobs/job-${s.id}.md`}),G?e.jsx(pe,{className:"h-3.5 w-3.5"}):e.jsx(fe,{className:"h-3.5 w-3.5"})]})]}),s._error&&e.jsx(c,{className:"border-destructive/50 bg-destructive/5",children:e.jsxs(o,{className:"pt-6",children:[e.jsx("p",{className:"text-sm text-destructive font-medium",children:s._error}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Please review the job file at ",e.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:[".nut/jobs/job-",s.id,".md"]})]})]})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(c,{children:[e.jsxs(f,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(g,{children:"Job Configuration"}),e.jsx(N,{variant:R(s.status),className:"capitalize",children:s.status})]}),s.description&&e.jsx(H,{children:s.description})]}),e.jsxs(o,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Instructions"}),e.jsx("div",{className:"rounded-md bg-muted/50 p-3 font-mono text-sm whitespace-pre-wrap",children:s.prompt})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"AI Model"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:ye(s.model)})]})]}),_.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Custom Skills"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:_.map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800 text-xs",children:[e.jsx(z,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-100",children:t.replace(".md","")})]},t))})]}),s.mcpServers&&s.mcpServers.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"MCP Servers"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.mcpServers.map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-purple-50 dark:bg-purple-950/20 border border-purple-200 dark:border-purple-800 text-xs",children:[e.jsx(ge,{className:"h-3 w-3 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"font-medium text-purple-900 dark:text-purple-100",children:t})]},t))})]})]})]})]}),e.jsxs(c,{children:[e.jsx(f,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(g,{children:"Run History"}),e.jsxs(H,{children:[s.runs.length," recorded run",s.runs.length!==1?"s":""]})]}),e.jsxs(d,{variant:"outline",size:"sm",onClick:S,children:[e.jsx(Ne,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})}),e.jsx(o,{children:s.runs.length===0?e.jsx("div",{className:"rounded-md border border-dashed bg-muted/20 p-6 text-center text-sm text-muted-foreground",children:'No runs yet. Click "Run Now" to execute this job.'}):e.jsx("div",{className:"space-y-1.5",children:s.runs.map(t=>e.jsxs(p,{to:`/schedule/${a}/run/${t.id}`,className:"flex items-center gap-3 p-3 rounded-md border bg-card/50 hover:bg-accent/50 transition-colors group",children:[e.jsx(N,{variant:R(t.status),className:"capitalize text-xs shrink-0",children:t.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:b(t.startedAt)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",T(t.startedAt),")"]}),t.finishedAt&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["• ",K(t.startedAt,t.finishedAt)]})]}),t.error&&e.jsx("p",{className:"text-xs text-destructive font-medium mt-0.5 line-clamp-1",children:t.error})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.trigger==="manual"&&e.jsx(N,{variant:"outline",className:"text-xs",children:"manual"}),e.jsx(ue,{className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})]},t.id))})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(c,{children:[e.jsx(f,{children:e.jsx(g,{children:"Actions"})}),e.jsxs(o,{className:"space-y-2",children:[e.jsxs(d,{variant:"default",className:"w-full justify-start",onClick:L,disabled:h||!!s._error,children:[h?e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(k,{className:"h-4 w-4 mr-2"}),h?"Running...":"Run Now"]}),e.jsxs(d,{variant:"outline",className:"w-full justify-start",onClick:q,disabled:A||!!s._error,children:[A?e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}):s.status==="active"?e.jsx(be,{className:"h-4 w-4 mr-2"}):e.jsx(k,{className:"h-4 w-4 mr-2"}),A?"Updating...":s.status==="active"?"Pause Job":"Resume Job"]}),e.jsx(d,{variant:"outline",className:"w-full justify-start",asChild:!0,disabled:!!s._error,children:e.jsxs(p,{to:"/schedule",state:{editJobId:s.id},children:[e.jsx(xe,{className:"h-4 w-4 mr-2"}),"Edit Job"]})})]})]}),e.jsxs(c,{children:[e.jsx(f,{children:e.jsx(g,{children:"Schedule"})}),e.jsxs(o,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(O,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:we(s.schedule)})]}),s.schedule.type==="interval"&&s.schedule.anchorHour!==void 0&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Start hour:"})," ",e.jsxs("span",{children:[s.schedule.anchorHour,":00"]})]}),e.jsx(B,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Next run:"}),e.jsx("span",{className:"font-medium",children:T(s.metadata.nextRunAt)})]}),s.metadata.nextRunAt&&e.jsx("div",{className:"text-xs text-muted-foreground",children:b(s.metadata.nextRunAt)})]})]})]}),e.jsxs(c,{children:[e.jsx(f,{children:e.jsx(g,{children:"Information"})}),e.jsxs(o,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(he,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Created:"}),e.jsx("span",{children:b(s.metadata.createdAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(O,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Updated:"}),e.jsx("span",{children:b(s.metadata.updatedAt)})]}),s.metadata.lastRunAt&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(k,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Last run:"}),e.jsx("span",{children:T(s.metadata.lastRunAt)})]}),e.jsx(B,{}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Status:"}),e.jsx("div",{className:"mt-1",children:e.jsx(N,{variant:R(s.status),className:"capitalize",children:s.status})})]}),s.tags&&s.tags.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:s.tags.map(t=>e.jsx(N,{variant:"outline",className:"text-xs",children:t},t))})]})]})]})]})]})]})}export{Pe as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as A,u as T,a as $,r as i,A as p,j as e,v as g,B as o,L as x,M as F,_ as L,z as S,E as z,H as P,J as B,N as K,O as U,Q as _,R as H,U as M,V as R,ad as q,ae as I,m as V,$ as W}from"./index-ByTA2ZiD.js";import{C as d,a as m,b as J,c as O}from"./card-CL5bB4cs.js";import{B as Q}from"./badge-BbfU_aPt.js";import{c as G}from"./clipboard-B9ndUJKl.js";import{A as j}from"./arrow-left-B9NBHEkS.js";import{T as X}from"./tag-rYG4CdRx.js";import{E as Y}from"./external-link-CrRz0sU-.js";function Z(n){return typeof n=="string"?n.startsWith("http://")||n.startsWith("https://")?{title:n,url:n}:{title:n}:n}function ie(){const n=A(),v=T(),{toast:r}=$(),l=n.filename,[s,N]=i.useState(null),[w,k]=i.useState(!0),[h,u]=i.useState(!1),[y,f]=i.useState(!1);i.useEffect(()=>{l&&C()},[l]);const C=async()=>{try{const a=await(await fetch(`${p}/api/v1/knowledge/${l}`)).json();a.success?N(a.document):r({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}catch(t){console.error("Error fetching document:",t),r({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}finally{k(!1)}},D=async()=>{if(!s)return;const t=`.nut/knowledge/${s.filename}`;try{await G(t),f(!0),setTimeout(()=>f(!1),2e3),r({title:"Copied!",description:`Path copied to clipboard: ${t}`})}catch(a){console.error("Failed to copy path:",a),r({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},b=()=>{if(!s)return;const t=new CustomEvent("discuss-in-chat",{detail:{type:"knowledge",id:`knowledge-${s.filename.replace(".md","")}`,filename:s.filename,name:s.filename,path:`.nut/knowledge/${s.filename}`}});window.dispatchEvent(t)},E=async()=>{if(s){u(!0);try{const a=await(await fetch(`${p}/api/v1/knowledge/${l}`,{method:"DELETE"})).json();a.success?(r({title:"Success",description:"Knowledge document deleted successfully"}),v("/knowledge")):r({title:"Error",description:a.error||"Failed to delete knowledge document",variant:"destructive"})}catch(t){console.error("Error deleting document:",t),r({title:"Error",description:"Failed to delete knowledge document",variant:"destructive"})}finally{u(!1)}}};return w?e.jsx("div",{className:"space-y-6",children:e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(g,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):s?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.title}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(o,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(x,{to:"/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})}),e.jsxs(o,{variant:"outline",size:"sm",onClick:b,children:[e.jsx(F,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsx(o,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(x,{to:`/knowledge/${l}/edit`,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(S,{children:[e.jsx(z,{asChild:!0,children:e.jsxs(o,{variant:"destructive",size:"sm",children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})}),e.jsxs(B,{children:[e.jsxs(K,{children:[e.jsx(U,{children:"Delete Knowledge Document"}),e.jsxs(_,{children:["Are you sure you want to delete “",s.title,"”? This action cannot be undone."]})]}),e.jsxs(H,{children:[e.jsx(M,{children:"Cancel"}),e.jsx(R,{onClick:E,disabled:h,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:h?e.jsx(g,{className:"w-4 h-4 animate-spin"}):"Delete"})]})]})]})]})]}),e.jsx("div",{className:"text-left",children:e.jsxs("button",{type:"button",onClick:D,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono text-left",children:[e.jsxs("span",{className:"break-all",children:[".nut/knowledge/",s.filename]}),y?e.jsx(q,{className:"h-3.5 w-3.5 flex-shrink-0 text-green-600"}):e.jsx(I,{className:"h-3.5 w-3.5 flex-shrink-0"})]})})]}),e.jsxs("div",{className:"flex flex-col gap-2 text-sm text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(V,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Updated ",s.metadata.updated]})]}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-start gap-1.5 sm:items-center",children:[e.jsx(X,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5 sm:mt-0"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map((t,a)=>e.jsx(Q,{variant:"outline",className:"text-xs",children:t},a))})]})]}),s.metadata.sources&&s.metadata.sources.length>0&&e.jsxs(d,{children:[e.jsx(J,{children:e.jsx(O,{children:"Sources"})}),e.jsx(m,{children:e.jsx("ul",{className:"space-y-2",children:s.metadata.sources.map((t,a)=>{const c=Z(t);return e.jsx("li",{children:c.url?e.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-foreground hover:text-primary transition-colors group",children:[e.jsx("span",{className:"group-hover:underline",children:c.title}),e.jsx(Y,{className:"w-3.5 h-3.5 text-muted-foreground group-hover:text-primary flex-shrink-0"})]}):e.jsx("span",{className:"text-muted-foreground",children:c.title})},a)})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsx(W,{children:s.content})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(o,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(x,{to:"/knowledge",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"The requested knowledge document could not be found."})]})})})]})}export{ie as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as I,s as z,t as B,r as t,j as e,v as g,I as l,B as y,w as n}from"./index-ByTA2ZiD.js";import{L as c}from"./label-Dp0-28_O.js";import{C as D,b as k,c as H,d as M,a as O}from"./card-CL5bB4cs.js";import{T as V,a as W,b as w,c as N}from"./tabs-Bj0YyeRI.js";function Q(){const i=I(),o=z(),{login:b,register:C,isAuthenticated:h,authEnabled:x,isLoading:m}=B(),[a,d]=t.useState(!1),[L,S]=t.useState("login"),[p,E]=t.useState(""),[f,T]=t.useState(""),[j,F]=t.useState(""),[u,P]=t.useState(""),[v,R]=t.useState("");t.useEffect(()=>{if(!m){if(!x)i("/");else if(h){const s=o.state?.from?.pathname||"/";i(s,{replace:!0})}}},[x,h,m,i,o]);const A=async s=>{s.preventDefault(),d(!0);try{await b(p,f),n({title:"Success",description:"Logged in successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Login failed",description:r.message||"Invalid email or password",variant:"destructive"})}finally{d(!1)}},q=async s=>{if(s.preventDefault(),u.length<8){n({title:"Invalid password",description:"Password must be at least 8 characters",variant:"destructive"});return}d(!0);try{await C(j,u,v),n({title:"Success",description:"Account created successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Registration failed",description:r.message||"Failed to create account",variant:"destructive"})}finally{d(!1)}};return m?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(g,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-background to-muted p-4",children:e.jsxs(D,{className:"w-full max-w-md",children:[e.jsxs(k,{className:"space-y-1 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("svg",{className:"h-12 w-12 text-green-600",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z"})})}),e.jsx(H,{className:"text-2xl font-bold",children:"Welcome to Coconut"}),e.jsx(M,{children:"Sign in to your account or create a new one"})]}),e.jsx(O,{children:e.jsxs(V,{value:L,onValueChange:s=>S(s),children:[e.jsxs(W,{className:"grid w-full grid-cols-2",children:[e.jsx(w,{value:"login",children:"Login"}),e.jsx(w,{value:"register",children:"Register"})]}),e.jsx(N,{value:"login",className:"space-y-4",children:e.jsxs("form",{onSubmit:A,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-email",children:"Email"}),e.jsx(l,{id:"login-email",type:"email",placeholder:"you@example.com",value:p,onChange:s=>E(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-password",children:"Password"}),e.jsx(l,{id:"login-password",type:"password",value:f,onChange:s=>T(s.target.value),required:!0,disabled:a})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Logging in..."]}):"Login"})]})}),e.jsx(N,{value:"register",className:"space-y-4",children:e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-email",children:"Email"}),e.jsx(l,{id:"register-email",type:"email",placeholder:"you@example.com",value:j,onChange:s=>F(s.target.value),required:!0,disabled:a}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only whitelisted emails can register"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-name",children:"Name"}),e.jsx(l,{id:"register-name",type:"text",placeholder:"Your name",value:v,onChange:s=>R(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-password",children:"Password"}),e.jsx(l,{id:"register-password",type:"password",value:u,onChange:s=>P(s.target.value),required:!0,disabled:a,minLength:8}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"At least 8 characters"})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating account..."]}):"Create Account"})]})})]})})]})})}export{Q as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as A,r as t,A as S,j as e,D,b as R,d as $,f as C,k as M,g as P,B as k,bO as B,T as I}from"./index-ByTA2ZiD.js";import{B as x}from"./badge-BbfU_aPt.js";import{T as y}from"./triangle-alert-C0ovMJwZ.js";import{C as F}from"./clock-D-X3KCw6.js";import{R as L}from"./refresh-cw-Cj_5MZiJ.js";function E(i){const f=new Date(i).getTime(),o=Date.now(),l=Math.floor((o-f)/1e3);if(l<60)return`${l}s`;const c=Math.floor(l/60),d=l%60;if(c<60)return`${c}m ${d}s`;const s=Math.floor(c/60),p=c%60;return`${s}h ${p}m`}function U({open:i,onOpenChange:f,mailId:o,subject:l,onStopped:c}){const{toast:d}=A(),[s,p]=t.useState(null),[g,j]=t.useState(!1),[u,v]=t.useState(!1),[b,h]=t.useState(""),N=t.useRef(null),a=t.useRef(null),m=t.useCallback(async()=>{try{const r=await(await fetch(`${S}/api/v1/mail/${o}/processing`)).json();r.success&&p(r.data)}catch(n){console.error("[mail] Failed to fetch processing status:",n)}},[o]);t.useEffect(()=>{if(!i){a.current&&(clearInterval(a.current),a.current=null);return}return j(!0),m().finally(()=>j(!1)),a.current=setInterval(m,4e3),()=>{a.current&&(clearInterval(a.current),a.current=null)}},[i,m]),t.useEffect(()=>{const n=s?.active?.startedAt||s?.processingStartedAt;if(!n||!s?.processing){h("");return}h(E(n));const r=setInterval(()=>{h(E(n))},1e3);return()=>clearInterval(r)},[s?.active?.startedAt,s?.processingStartedAt,s?.processing]),t.useEffect(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[s?.log]),t.useEffect(()=>{s&&!s.processing&&!u&&a.current&&(clearInterval(a.current),a.current=null)},[s,u]);const T=async()=>{v(!0);try{const r=await(await fetch(`${S}/api/v1/mail/${o}/processing/stop`,{method:"POST"})).json();r.success?(d({title:"Processing stopped",description:r.message}),setTimeout(()=>{m(),c?.()},1500)):d({title:"Error",description:r.error||"Failed to stop processing",variant:"destructive"})}catch{d({title:"Error",description:"Failed to stop processing",variant:"destructive"})}finally{v(!1)}},w=s?.processing&&!s?.active;return e.jsx(D,{open:i,onOpenChange:f,children:e.jsxs(R,{className:"max-w-2xl max-h-[80vh] flex flex-col",children:[e.jsxs($,{children:[e.jsxs(C,{className:"flex items-center gap-2",children:[e.jsx(M,{className:"h-5 w-5"}),"Mail Processing"]}),e.jsx(P,{className:"truncate",children:l})]}),e.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s?.processing?w?e.jsxs(x,{variant:"outline",className:"text-amber-600 border-amber-300 dark:text-amber-400 dark:border-amber-700",children:[e.jsx(y,{className:"h-3 w-3 mr-1"}),"Stuck"]}):e.jsxs(x,{variant:"outline",className:"text-blue-600 border-blue-300 dark:text-blue-400 dark:border-blue-700",children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500 animate-pulse mr-1.5"}),"Running"]}):s?e.jsx(x,{variant:"outline",className:"text-muted-foreground",children:"Completed"}):null,s?.active?.agent&&e.jsx(x,{variant:"secondary",className:"text-xs",children:s.active.agent}),b&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(F,{className:"h-3 w-3"}),b]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>m(),disabled:g,title:"Refresh",children:e.jsx(L,{className:`h-3.5 w-3.5 ${g?"animate-spin":""}`})}),s?.processing&&e.jsxs(k,{variant:"destructive",size:"sm",onClick:T,disabled:u,children:[e.jsx(B,{className:"h-3.5 w-3.5 mr-1.5"}),u?"Stopping...":"Stop"]})]})]}),w&&e.jsxs("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-3 text-sm text-amber-800 dark:text-amber-300",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-xs mb-1",children:[e.jsx(y,{className:"h-3.5 w-3.5"}),"Processing appears stuck"]}),e.jsx("p",{className:"text-xs",children:"The processing flag is set but no active agent process was found on the server. This can happen if the agent crashed or the server restarted. You can stop processing to clear the flag and try again."})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-2",children:[e.jsx(I,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-medium",children:"Agent Log"}),s?.logPath&&e.jsx("span",{className:"text-[10px] opacity-60 truncate ml-1",children:s.logPath})]}),e.jsx("div",{className:"flex-1 min-h-0 max-h-[40vh] overflow-auto rounded-md border bg-muted/30 p-3 font-mono text-xs leading-relaxed",children:s?.log?e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground/80",children:s.log}),e.jsx("div",{ref:N})]}):g?e.jsx("span",{className:"text-muted-foreground italic",children:"Loading logs..."}):e.jsx("span",{className:"text-muted-foreground italic",children:"No log output available yet."})})]})]})]})})}export{U as M};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,S as ne,$ as k,r as b,bD as q,w as f,bx as ie,bv as ae,B as C,P as B,I as u,o as R,_ as oe,H as le,F as ce,l as de}from"./index-ByTA2ZiD.js";import{C as L,b as T,c as O,d as $,a as U}from"./card-CL5bB4cs.js";import{L as h}from"./label-Dp0-28_O.js";import{B as P}from"./badge-BbfU_aPt.js";import{S as I}from"./switch-CX_Inx_p.js";import{A as z,a as Y}from"./alert-BtkLXQ3p.js";import{R as me,L as he}from"./browser-modal-J9l3o5os.js";import{R as xe}from"./registry-ANRa5WBi.js";import{C as J}from"./circle-alert-vJFSz39V.js";import{C as ve}from"./circle-check-big-BwQ_q1N7.js";import"./search-BgbqRUnf.js";function K(t){if(t){if(Array.isArray(t)){const n=t.map(l=>{if(typeof l=="string")return l.trim();if(typeof l=="number")return`${l}`}).filter(l=>typeof l=="string"&&l.length>0);return n.length>0?n:void 0}if(typeof t=="string"){const n=t.split(",").map(l=>l.trim()).filter(l=>l.length>0);return n.length>0?n:void 0}}}function G(t,n){const l=t.name||n.name,x=n.description||t.description||"",a={registryId:t.id,registryEndpoint:t.endpoint,registrySource:xe,author:t.author||n.author};(n.version||t.version)&&(a.version=n.version||t.version);const d=K(n.tags)||K(t.tags);d&&(a.tags=d),n.capabilities&&Array.isArray(n.capabilities)&&(a.capabilities=n.capabilities),n.requirements&&typeof n.requirements=="object"&&(a.requirements=n.requirements),n.links&&typeof n.links=="object"&&(a.links=n.links),n.metadata&&typeof n.metadata=="object"&&(a.mcpMetadata=n.metadata);for(const[i,p]of Object.entries(a))p==null&&delete a[i];return{name:l,command:n.configuration.command,args:n.configuration.args,url:n.configuration.url,env:n.configuration.env,enabled:!0,description:x,metadata:Object.keys(a).length>0?a:void 0}}async function pe(t){const n=t.startsWith("http")?t:`https://registry.coconut.dev${t}`,l=await fetch(n,{headers:{Accept:"application/json","User-Agent":"coconut-frontend"}});if(!l.ok)throw new Error(`Failed to fetch MCP server detail: ${l.status}`);return l.json()}function ue({open:t,onOpenChange:n,onImport:l}){return e.jsx(me,{open:t,onOpenChange:n,categoryId:"mcp-servers",title:"Coconut Registry – MCP Servers",confirmLabel:"Add Server",getDetail:x=>pe(x.endpoint),renderPreview:(x,a)=>{if(!a)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select an MCP server to preview"});const d=G(x,a),i=d.metadata??{},p=typeof i.version=="string"?i.version:void 0,y=Array.isArray(x.tags)?x.tags:[],w=Array.isArray(i.capabilities)?i.capabilities.filter(j=>typeof j=="string"):[];return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(ne,{className:"h-full",children:e.jsx("div",{className:"space-y-6 p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:x.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.description})]}),p&&e.jsxs(P,{variant:"outline",children:["v",p]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:x.id})]}),y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(j=>e.jsx(P,{variant:"secondary",children:j},j))}),e.jsxs("div",{className:"space-y-2 rounded-md border p-3 bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Configuration"}),e.jsx(P,{variant:"outline",className:"text-xs",children:d.url?"HTTP":"stdio"})]}),e.jsxs("div",{className:"space-y-1 text-sm font-mono",children:[d.url?e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"URL:"})," ",e.jsx("span",{className:"text-foreground break-all",children:d.url})]}):e.jsxs(e.Fragment,{children:[d.command&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Command:"})," ",e.jsx("span",{className:"text-foreground",children:d.command})]}),d.args&&d.args.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Args:"})," ",e.jsx("span",{className:"text-foreground",children:d.args.join(" ")})]})]}),d.env&&Object.keys(d.env).length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Env:"})," ",e.jsx("span",{className:"text-foreground",children:JSON.stringify(d.env)})]})]})]}),w.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Capabilities"}),e.jsx("ul",{className:"list-disc pl-5 text-sm text-muted-foreground space-y-1",children:w.map(j=>e.jsx("li",{children:j},j))})]}),a.documentation&&e.jsxs("div",{className:"space-y-3",children:[a.documentation.overview&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Overview"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.overview})]}),a.documentation.installation&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Installation"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.installation})]}),a.documentation.usage&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Usage"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.usage})]}),a.documentation.examples&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Examples"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.examples})]})]})]})})})})},onConfirm:async(x,a)=>{const d=G(x,a);await l({summary:x,detail:a,payload:d})}})}function Ae(){const[t,n]=b.useState({}),[l,x]=b.useState(!0),[a,d]=b.useState(!1),[i,p]=b.useState({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0}),[y,w]=b.useState(!1),[j,M]=b.useState(null),[o,N]=b.useState({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0}),[V,_]=b.useState(!1);b.useEffect(()=>{D()},[]);const D=async()=>{try{x(!0);const s=await q("/api/v1/mcp/raw-config");n(s||{})}catch(s){console.error("Failed to load MCP config:",s),f({title:"Error",description:"Failed to load MCP configuration",variant:"destructive"})}finally{x(!1)}},E=async s=>{try{d(!0),await q("/api/v1/mcp/raw-config",{method:"PUT",body:JSON.stringify(s)}),n(s),f({title:"Success",description:"MCP configuration saved successfully"})}catch(r){console.error("Failed to save MCP config:",r),f({title:"Error",description:"Failed to save MCP configuration",variant:"destructive"})}finally{d(!1)}},W=()=>{if(!i.name){f({title:"Error",description:"Server name is required",variant:"destructive"});return}const s=i.command.trim().length>0,r=i.url.trim().length>0;if(!s&&!r){f({title:"Error",description:"Either Command (for stdio) or URL (for HTTP) is required",variant:"destructive"});return}if(s&&r){f({title:"Error",description:"Provide either Command or URL, not both",variant:"destructive"});return}const c={name:i.name,enabled:i.enabled,description:i.description||void 0};if(s?(c.type="stdio",c.command=i.command,i.args.trim()&&(c.args=i.args.split(" ").filter(g=>g.trim()))):(c.type="http",c.url=i.url),i.env.trim())try{c.env=JSON.parse(i.env)}catch{f({title:"Error",description:"Invalid JSON format for environment variables",variant:"destructive"});return}const v={...t,mcpServers:{...t.mcpServers,[i.name]:c}};E(v),p({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0}),w(!1)},Q=(s,r)=>{const c={...t,mcpServers:{...t.mcpServers,[s]:{...t.mcpServers[s],enabled:r}}};E(c)},X=s=>{const{[s]:r,...c}=t.mcpServers||{},v={...t,mcpServers:c};E(v)},Z=s=>{const r=t.mcpServers?.[s];r&&(N({name:r.name||s,command:r.command||"",args:r.args?.join(" ")||"",url:r.url||"",env:r.env?JSON.stringify(r.env,null,2):"",description:r.description||"",enabled:r.enabled!==!1}),M(s))},ee=s=>{const r=o.command.trim().length>0,c=o.url.trim().length>0;if(!r&&!c){f({title:"Error",description:"Either Command (for stdio) or URL (for HTTP) is required",variant:"destructive"});return}if(r&&c){f({title:"Error",description:"Provide either Command or URL, not both",variant:"destructive"});return}const v={name:o.name,enabled:o.enabled,description:o.description||void 0};if(r?(v.type="stdio",v.command=o.command,o.args.trim()&&(v.args=o.args.split(" ").filter(A=>A.trim()))):(v.type="http",v.url=o.url),o.env.trim())try{v.env=JSON.parse(o.env)}catch{f({title:"Error",description:"Invalid JSON format for environment variables",variant:"destructive"});return}const{[s]:g,...m}=t.mcpServers||{},S={...t,mcpServers:{...m,[s]:v}};E(S),M(null)},se=()=>{M(null),N({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0})},F=s=>{const r={...t,globalSettings:{...t.globalSettings,...s}};E(r)},re=async s=>{const{payload:r}=s;let c=r.name.toLowerCase().replace(/\s+/g,"-");const v=t.mcpServers||{};let g=c,m=1;for(;v[g];)g=`${c}-${m}`,m++;const S={name:g,enabled:r.enabled!==!1,description:r.description,env:r.env};r.url?(S.type="http",S.url=r.url):r.command&&(S.type="stdio",S.command=r.command,S.args=r.args);const A={...t,mcpServers:{...t.mcpServers,[g]:S}};await E(A);const te=r.url?"HTTP":"stdio";f({title:"Success",description:`MCP server "${g}" (${te}) added from registry`})};if(l)return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"MCP Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading configuration..."})]})});const H=t.mcpServers||{};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"MCP Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Model Context Protocol servers and settings."})]}),e.jsx(ie,{}),Object.keys(H).length===0&&!y&&e.jsxs(z,{children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(Y,{children:"No MCP servers configured yet. Add your first server to get started."})]}),e.jsxs(L,{children:[e.jsx(T,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-5 w-5"}),"MCP Servers"]}),e.jsx($,{className:"hidden sm:block",children:"Configure and manage Model Context Protocol servers for enhanced AI capabilities."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>_(!0),children:[e.jsx(he,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsxs(C,{size:"sm",onClick:()=>w(!y),variant:y?"outline":"default",children:[e.jsx(B,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:y?"Cancel":"Add Server"})]})]})]})}),e.jsxs(U,{children:[y&&e.jsxs("div",{className:"space-y-4 p-3 sm:p-4 border rounded-lg mb-4",children:[e.jsx("h4",{className:"font-medium",children:"Add MCP Server"}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverName",children:"Server Name"}),e.jsx(u,{id:"serverName",value:i.name,onChange:s=>p({...i,name:s.target.value}),placeholder:"e.g., filesystem-server"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverCommand",children:"Command"}),e.jsx(u,{id:"serverCommand",value:i.command,onChange:s=>p({...i,command:s.target.value}),placeholder:"e.g., npx @modelcontextprotocol/server-filesystem"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverArgs",children:"Arguments (space-separated)"}),e.jsx(u,{id:"serverArgs",value:i.args,onChange:s=>p({...i,args:s.target.value}),placeholder:"e.g., /path/to/allowed/directory"})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverUrl",children:"URL"}),e.jsx(u,{id:"serverUrl",value:i.url,onChange:s=>p({...i,url:s.target.value}),placeholder:"e.g., https://mcp.example.com/api"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Provide either Command (for stdio) or URL (for HTTP/SSE), not both."})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverDescription",children:"Description (optional)"}),e.jsx(u,{id:"serverDescription",value:i.description,onChange:s=>p({...i,description:s.target.value}),placeholder:"Brief description of what this server provides"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverEnv",children:"Environment Variables (JSON)"}),e.jsx(R,{id:"serverEnv",value:i.env,onChange:s=>p({...i,env:s.target.value}),placeholder:'{"KEY": "value", "ANOTHER_KEY": "another_value"}',rows:3})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{id:"serverEnabled",checked:i.enabled,onCheckedChange:s=>p({...i,enabled:s})}),e.jsx(h,{htmlFor:"serverEnabled",children:"Enable server"})]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs(C,{onClick:W,disabled:a,children:[e.jsx(B,{className:"h-4 w-4 mr-2"}),"Add Server"]}),e.jsx(C,{variant:"outline",onClick:()=>w(!1),children:"Cancel"})]})]}),e.jsx("div",{className:"space-y-4",children:Object.entries(H).map(([s,r])=>{const c=r.enabled!==!1,v=r.name||s,g=j===s;return e.jsx("div",{className:"border rounded-lg",children:g?e.jsxs("div",{className:"space-y-4 p-3 sm:p-4",children:[e.jsx("h4",{className:"font-medium",children:"Edit MCP Server"}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-name-${s}`,children:"Server Name"}),e.jsx(u,{id:`edit-name-${s}`,value:o.name,onChange:m=>N({...o,name:m.target.value}),placeholder:"e.g., filesystem-server"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-command-${s}`,children:"Command"}),e.jsx(u,{id:`edit-command-${s}`,value:o.command,onChange:m=>N({...o,command:m.target.value}),placeholder:"e.g., npx @modelcontextprotocol/server-filesystem"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-args-${s}`,children:"Arguments (space-separated)"}),e.jsx(u,{id:`edit-args-${s}`,value:o.args,onChange:m=>N({...o,args:m.target.value}),placeholder:"e.g., /path/to/allowed/directory"})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-url-${s}`,children:"URL"}),e.jsx(u,{id:`edit-url-${s}`,value:o.url,onChange:m=>N({...o,url:m.target.value}),placeholder:"e.g., https://mcp.example.com/api"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Provide either Command (for stdio) or URL (for HTTP/SSE), not both."})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-description-${s}`,children:"Description (optional)"}),e.jsx(u,{id:`edit-description-${s}`,value:o.description,onChange:m=>N({...o,description:m.target.value}),placeholder:"Brief description of what this server provides"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-env-${s}`,children:"Environment Variables (JSON)"}),e.jsx(R,{id:`edit-env-${s}`,value:o.env,onChange:m=>N({...o,env:m.target.value}),placeholder:'{"KEY": "value", "ANOTHER_KEY": "another_value"}',rows:3})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{id:`edit-enabled-${s}`,checked:o.enabled,onCheckedChange:m=>N({...o,enabled:m})}),e.jsx(h,{htmlFor:`edit-enabled-${s}`,children:"Enable server"})]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(C,{onClick:()=>ee(s),disabled:a,children:"Save Changes"}),e.jsx(C,{variant:"outline",onClick:se,children:"Cancel"})]})]}):e.jsx("div",{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0 flex-1",children:[c?e.jsx(ve,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"}):e.jsx(J,{className:"h-4 w-4 text-gray-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h4",{className:"font-medium text-sm sm:text-base",children:v}),e.jsx(P,{variant:c?"default":"secondary",className:"text-xs",children:c?"Enabled":"Disabled"}),e.jsx(P,{variant:"outline",className:"text-xs",children:r.url?"HTTP":"stdio"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:r.description||r.url||r.command}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:r.url?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"URL:"})," ",r.url]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"Command:"})," ",r.command," ",r.args?.join(" ")]})})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 shrink-0",children:[e.jsx(I,{checked:c,onCheckedChange:m=>Q(s,m),disabled:a}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(s),children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(s),disabled:a,children:e.jsx(le,{className:"h-4 w-4"})})]})]})})},s)})})]})]}),e.jsxs(L,{children:[e.jsxs(T,{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"}),"Configuration File"]}),e.jsxs($,{children:["The MCP configuration is stored in ",e.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:".nut/mcp/config.json"})]})]}),e.jsxs(U,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"configJson",children:"Current Configuration (JSON)"}),e.jsx(R,{id:"configJson",value:JSON.stringify(t,null,2),readOnly:!0,rows:12,className:"font-mono text-sm",placeholder:"Loading configuration..."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This is a read-only view of the current configuration. Use the forms above to make changes."})]}),e.jsxs(z,{children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(Y,{children:"Configuration changes are automatically saved to the MCP config file. This file can also be edited manually if you prefer working with JSON directly."})]})]})]}),e.jsxs(L,{children:[e.jsxs(T,{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(de,{className:"h-5 w-5"}),"Global Settings"]}),e.jsx($,{children:"Configure global MCP behavior and connection settings."})]}),e.jsx(U,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"timeout",children:"Connection Timeout (ms)"}),e.jsx(u,{id:"timeout",type:"number",value:t.globalSettings?.timeout||3e4,onChange:s=>F({timeout:parseInt(s.target.value)}),placeholder:"30000"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"retryAttempts",children:"Retry Attempts"}),e.jsx(u,{id:"retryAttempts",type:"number",value:t.globalSettings?.retryAttempts||3,onChange:s=>F({retryAttempts:parseInt(s.target.value)}),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"logLevel",children:"Log Level"}),e.jsxs("select",{id:"logLevel",className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",value:t.globalSettings?.logLevel||"info",onChange:s=>F({logLevel:s.target.value}),children:[e.jsx("option",{value:"debug",children:"Debug"}),e.jsx("option",{value:"info",children:"Info"}),e.jsx("option",{value:"warn",children:"Warning"}),e.jsx("option",{value:"error",children:"Error"})]})]})]})})]}),e.jsx("div",{className:"flex justify-end space-x-2",children:e.jsx(C,{variant:"outline",onClick:D,disabled:l,children:"Reload Configuration"})}),e.jsx(ue,{open:V,onOpenChange:_,onImport:re})]})}export{Ae as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as y,r as t,A as N,j as e,v,q as C,B as a,L as l,_ as d,M as w,au as g,aq as E}from"./index-ByTA2ZiD.js";import{C as r,a as i,b}from"./card-CL5bB4cs.js";import{c as M}from"./clipboard-B9ndUJKl.js";function S(){const{toast:c}=y(),[o,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${N}/api/v1/context/memory`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/memory.md";try{await M(s),c({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),c({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"memory-md",filename:"memory.md",name:"memory.md",path:".nut/context/memory.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(r,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(v,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading memory..."})]})})})}):!u||!o?e.jsx("div",{className:"space-y-6",children:e.jsx(r,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Memory Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Memory will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(l,{to:"/context/memory/edit",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),"Create Memory"]})})]})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Memory"}),e.jsx("p",{className:"text-muted-foreground",children:"Persistent memory and learned context"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(g,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(l,{to:"/context/memory/edit",children:[e.jsx(d,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(r,{children:[e.jsx(b,{className:"pb-0"}),e.jsx(i,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(E,{children:o.content||"No content available"})})})]})]})}export{S as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,bx as p,B as r,P as h,_ as j,ae as u,H as g,I as o}from"./index-ByTA2ZiD.js";import{C as a,b as i,c as n,d as c,a as d}from"./card-CL5bB4cs.js";import{L as t}from"./label-Dp0-28_O.js";import{S as f,a as v,b as N,c as y,d as b}from"./select-CfwLZl55.js";import{B as l}from"./badge-BbfU_aPt.js";import{E as w}from"./eye-Cx9ZGkg5.js";import{D as C}from"./download-DeEju9jg.js";import"./index-CuLP7P_G.js";import"./chevron-up-BwTmMEW2.js";function B(){const m=[{id:"1",name:"Code Review Assistant",description:"Prompt for AI agents to perform thorough code reviews",category:"Code Review",usage:"cursor-cli, claude-code",lastUpdated:"2 days ago",active:!0},{id:"2",name:"Architecture Advisor",description:"System prompt for architectural decision guidance",category:"Architecture",usage:"gemini-cli, claude-code",lastUpdated:"1 week ago",active:!0},{id:"3",name:"Bug Analysis Expert",description:"Specialized prompt for debugging and error analysis",category:"Debugging",usage:"cursor-cli",lastUpdated:"3 days ago",active:!1},{id:"4",name:"Documentation Generator",description:"Prompt for generating comprehensive code documentation",category:"Documentation",usage:"github-copilot, claude-code",lastUpdated:"5 days ago",active:!0}],x=["Code Review","Architecture","Debugging","Documentation","Testing","Refactoring","Security","Performance"];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"System Prompts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage system prompts used by AI agents and integrations for consistent behavior."})]}),e.jsx(p,{}),e.jsxs(a,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(n,{children:"Prompt Library"}),e.jsx(c,{children:"Pre-configured prompts for different AI agents and use cases."})]}),e.jsxs(r,{size:"sm",children:[e.jsx(h,{className:"h-4 w-4 mr-2"}),"New Prompt"]})]})}),e.jsx(d,{children:e.jsx("div",{className:"space-y-4",children:m.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h4",{className:"font-medium",children:s.name}),e.jsx(l,{variant:s.active?"default":"secondary",children:s.active?"Active":"Inactive"}),e.jsx(l,{variant:"outline",children:s.category})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.description}),e.jsxs("div",{className:"flex items-center space-x-4 mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used by: ",s.usage]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Updated: ",s.lastUpdated]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(w,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(j,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(u,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(g,{className:"h-4 w-4"})})]})]},s.id))})})]}),e.jsxs(a,{children:[e.jsxs(i,{children:[e.jsx(n,{children:"Create New Prompt"}),e.jsx(c,{children:"Design a new system prompt for your AI agents and integrations."})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(t,{htmlFor:"promptName",children:"Prompt Name"}),e.jsx(o,{id:"promptName",placeholder:"Enter prompt name"})]}),e.jsxs("div",{children:[e.jsx(t,{htmlFor:"promptCategory",children:"Category"}),e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(N,{placeholder:"Select category"})}),e.jsx(y,{children:x.map(s=>e.jsx(b,{value:s.toLowerCase(),children:s},s))})]})]})]}),e.jsxs("div",{children:[e.jsx(t,{htmlFor:"promptDescription",children:"Description"}),e.jsx(o,{id:"promptDescription",placeholder:"Brief description of the prompt's purpose"})]}),e.jsxs("div",{children:[e.jsx(t,{htmlFor:"targetIntegrations",children:"Target Integrations"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:["cursor-cli","claude-code","gemini-cli","github-copilot"].map(s=>e.jsxs("label",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",className:"rounded"}),e.jsx("span",{className:"text-sm",children:s})]},s))})]}),e.jsxs("div",{children:[e.jsx(t,{htmlFor:"promptContent",children:"Prompt Content"}),e.jsx("textarea",{id:"promptContent",className:"w-full min-h-[200px] p-3 border rounded-md font-mono text-sm",placeholder:"You are an expert code reviewer. Your task is to..."})]}),e.jsxs("div",{children:[e.jsx(t,{htmlFor:"promptVariables",children:"Variables (JSON format)"}),e.jsx("textarea",{id:"promptVariables",className:"w-full min-h-[100px] p-3 border rounded-md font-mono text-sm",placeholder:'{"language": "typescript", "framework": "react", "style": "functional"}'})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(r,{variant:"outline",children:"Preview"}),e.jsx(r,{variant:"outline",children:"Save as Draft"}),e.jsx(r,{children:"Save & Activate"})]})]})]}),e.jsxs(a,{children:[e.jsxs(i,{children:[e.jsx(n,{children:"Prompt Templates"}),e.jsx(c,{children:"Import and export prompt templates for sharing across teams."})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(r,{variant:"outline",size:"sm",children:[e.jsx(C,{className:"h-4 w-4 mr-2"}),"Import Template"]}),e.jsx(r,{variant:"outline",size:"sm",children:"Export All Prompts"}),e.jsx(r,{variant:"outline",size:"sm",children:"Export Selected"})]}),e.jsx("div",{className:"p-4 border-2 border-dashed rounded-lg text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag and drop prompt template files here, or click to browse"})})]})]})]})}export{B as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as N,r as t,A as v,j as e,v as C,F as g,B as a,L as c,_ as d,M as w,au as y,aq as b}from"./index-ByTA2ZiD.js";import{C as i,a as r,b as E}from"./card-CL5bB4cs.js";import{c as k}from"./clipboard-B9ndUJKl.js";function L(){const{toast:l}=N(),[o,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${v}/api/v1/context/role`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/role.md";try{await k(s),l({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),l({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"role-md",filename:"role.md",name:"role.md",path:".nut/context/role.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading role definition..."})]})})})}):!u||!o?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(g,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Role Definition Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Role definition will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(c,{to:"/context/role/edit",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),"Create Role Definition"]})})]})})})}):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:"Role"}),e.jsx("p",{className:"text-muted-foreground",children:"This Coconut's responsibilities and guidelines"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(c,{to:"/context/role/edit",children:[e.jsx(d,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(i,{children:[e.jsx(E,{className:"pb-0"}),e.jsx(r,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(b,{children:o.content||"No content available"})})})]})]})}export{L as default};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as Le,ac as ze,r as u,j as e,B as c,v as P,P as oe,bI as me,z as W,E as ue,H as he,J as U,N as _,O as q,Q as V,R as Y,U as G,V as K,L as $,k as Q,bJ as He,C as xe,D as Be,b as We,d as Ue,f as _e,g as qe,I as X,a4 as pe,a5 as fe,n as ge,a6 as ve,a7 as je,a8 as Ne,a9 as be,o as Ve,aa as Ye,Y as Ge,A as N}from"./index-ByTA2ZiD.js";import{C as R,a as Z,c as ee,b as ye}from"./card-CL5bB4cs.js";import{B as E}from"./badge-BbfU_aPt.js";import{S as Ke,a as Qe,b as Xe,c as Ze,d as es}from"./select-CfwLZl55.js";import{L as f}from"./label-Dp0-28_O.js";import{S as ss}from"./switch-CX_Inx_p.js";import{T as ts,a as as,b as se,c as te}from"./tabs-Bj0YyeRI.js";import{R as rs}from"./refresh-cw-Cj_5MZiJ.js";import{P as we}from"./play-fOwEoIcu.js";import{P as ns}from"./pause-Bfz-QQZp.js";import{C as is}from"./clock-D-X3KCw6.js";import{S as Se}from"./server-u9FLHclt.js";import"./index-CuLP7P_G.js";import"./chevron-up-BwTmMEW2.js";const ne=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"},{id:"kiro",label:"Kiro"}],ls=[{label:"Monday",value:"monday"},{label:"Tuesday",value:"tuesday"},{label:"Wednesday",value:"wednesday"},{label:"Thursday",value:"thursday"},{label:"Friday",value:"friday"},{label:"Saturday",value:"saturday"},{label:"Sunday",value:"sunday"}],Ie=["monday","tuesday","wednesday","thursday","friday"],ds=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},ae=a=>{if(!a)return"—";const h=new Date(a).getTime()-Date.now(),p=Math.round(h/(1e3*60));if(Number.isNaN(p))return ds(a);if(Math.abs(p)<1)return"now";if(p>0){if(p<60)return`in ${p}m`;const y=Math.round(p/60);return y<24?`in ${y}h`:`in ${Math.round(y/24)}d`}const b=Math.abs(p);if(b<60)return`${b}m ago`;const T=Math.round(b/60);return T<24?`${T}h ago`:`${Math.round(T/24)}d ago`},cs=a=>{if(a.type==="interval"){const o=a.daysOfWeek.map(h=>h.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${o||"All days"})`}return a.description||`Cron: ${a.expression}`},os=a=>{const o=ne.find(h=>h.id===a);return o?o.label:a},ke=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}},re=()=>({name:"",model:"claude",prompt:"",hours:6,daysOfWeek:new Set(Ie),status:!0,anchorHour:"",agentIds:[],mcpServers:[]}),Ce=a=>{if(a.schedule.type!=="interval")return re();const o=a.agentIds||(a.agentId?[a.agentId]:[]);return{name:a.name,model:ne.some(h=>h.id===a.model)?a.model:"claude",prompt:a.prompt,hours:a.schedule.hours,daysOfWeek:new Set(a.schedule.daysOfWeek),status:a.status==="active",anchorHour:a.schedule.anchorHour===void 0?"":String(a.schedule.anchorHour),agentIds:o,mcpServers:a.mcpServers||[]}},ms=a=>a?Array.isArray(a)?a.filter(o=>typeof o=="string").map(o=>o.trim()).filter(Boolean):typeof a=="string"?a.split(",").map(o=>o.trim()).filter(Boolean):[]:[];function Cs(){const{toast:a}=Le(),{refresh:o}=ze(),[h,p]=u.useState([]),[b,T]=u.useState(!0),[J,y]=u.useState(!1),[F,w]=u.useState(!1),[n,x]=u.useState(()=>re()),[O,ie]=u.useState(!1),[S,k]=u.useState(null),[d,C]=u.useState(null),[g,Ae]=u.useState([]),[L,De]=u.useState([]),[z,H]=u.useState({open:!1,serverToRemove:null}),I=async(s=!1)=>{try{b||y(!0);const t=await fetch(`${N}/api/v1/jobs`);if(!t.ok)throw new Error(`Failed to fetch jobs (${t.status})`);const r=await t.json();if(!r?.success)throw new Error(r?.error?.message||"Unknown error loading jobs");const i=r.data??[];if(p(i),d){const l=i.find(m=>m.id===d.id);l&&(C(l),l.schedule.type!=="cron"&&x(Ce(l)))}s&&a({title:"Schedule refreshed",description:"Latest job information loaded."})}catch(t){console.error("Failed to load jobs:",t),a({title:"Failed to load schedule",description:t?.message??"Unknown error",variant:"destructive"})}finally{T(!1),y(!1)}};u.useEffect(()=>{I()},[]),u.useEffect(()=>{F&&(async()=>{try{const t=await fetch(`${N}/api/v1/skills`);if(t.ok){const i=await t.json(),m=(Array.isArray(i?.documents)?i.documents:[]).map(j=>({id:j.id,name:j?.metadata?.name||j.id,mcpServers:ms(j?.metadata?.metadata?.mcpServers)}));if(Ae(m),d){const A=(d.agentIds||(d.agentId?[d.agentId]:[])).filter(D=>!m.find(B=>B.id===D));A.length>0&&(a({title:"Some skills are no longer available",description:`The following skills have been removed: ${A.join(", ")}`,variant:"destructive"}),x(D=>({...D,agentIds:D.agentIds.filter(B=>m.find(Oe=>Oe.id===B))})))}}const r=await fetch(`${N}/api/v1/mcp`);if(r.ok){const i=await r.json();if(i?.success&&Array.isArray(i.servers)&&(De(i.servers),d?.mcpServers)){const l=d.mcpServers.filter(m=>!i.servers.includes(m));l.length>0&&(a({title:"Some MCP servers are no longer available",description:`The following servers have been removed: ${l.join(", ")}`,variant:"destructive"}),x(m=>({...m,mcpServers:m.mcpServers.filter(j=>i.servers.includes(j))})))}}}catch(t){console.error("Failed to load skills or MCP servers:",t)}})()},[F,d,a]);const v=s=>{x(t=>({...t,...s}))},le=(s,t)=>{const r=new Set(t);return g.filter(i=>s.includes(i.id)).forEach(i=>{i.mcpServers.forEach(l=>{L.includes(l)&&r.add(l)})}),Array.from(r)},Te=(s,t)=>{x(r=>{let i;if(t){i=[...r.agentIds,s];const l=g.find(m=>m.id===s);if(l&&l.mcpServers.length>0)return{...r,agentIds:i,mcpServers:le(i,r.mcpServers)}}else i=r.agentIds.filter(l=>l!==s);return{...r,agentIds:i}})},$e=(s,t)=>{if(!t&&g.filter(i=>n.agentIds.includes(i.id)&&i.mcpServers.includes(s)).length>0){H({open:!0,serverToRemove:s});return}x(r=>({...r,mcpServers:t?[...r.mcpServers,s]:r.mcpServers.filter(i=>i!==s)}))},Fe=()=>{const s=z.serverToRemove;s&&x(t=>({...t,mcpServers:t.mcpServers.filter(r=>r!==s)})),H({open:!1,serverToRemove:null})},Me=(s,t)=>{x(r=>{const i=new Set(r.daysOfWeek);return t?i.add(s):i.delete(s),i.size===0&&Ie.forEach(l=>i.add(l)),{...r,daysOfWeek:i}})},M=()=>{x(re())},de=()=>{C(null),M(),w(!0)},Pe=s=>{if(s._error){a({title:"Cannot edit corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}if(s.schedule.type==="cron"){a({title:"Manual edit required",description:"Cron-based jobs can be edited directly in .nut/jobs/<id>.md for now.",variant:"destructive"});return}C(s),x(Ce(s)),w(!0)},Re=async s=>{if(s.preventDefault(),!n.name.trim()){a({title:"Job name required",description:"Please provide a name for the scheduled job.",variant:"destructive"});return}if(!n.prompt.trim()){a({title:"Prompt required",description:"Please provide instructions for the scheduled job.",variant:"destructive"});return}ie(!0);const t=!!d;try{const r=Number(n.anchorHour.trim()),i=n.anchorHour.trim()===""||Number.isNaN(r)?void 0:Math.min(23,Math.max(0,r)),l={name:n.name.trim(),prompt:n.prompt.trim(),model:n.model,status:n.status?"active":"paused",schedule:{type:"interval",hours:Math.max(1,Number(n.hours)||6),daysOfWeek:Array.from(n.daysOfWeek),anchorHour:i},agentIds:n.agentIds.length>0?n.agentIds:void 0,mcpServers:n.mcpServers.length>0?n.mcpServers:void 0},m=t?`${N}/api/v1/jobs/${d?.id}`:`${N}/api/v1/jobs`,A=await fetch(m,{method:t?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!A.ok){const D=await A.json().catch(()=>({}));throw new Error(D?.error?.message||`Failed to ${t?"update":"create"} job (${A.status})`)}a({title:t?"Scheduled job updated":"Scheduled job created",description:l.name}),w(!1),C(null),M(),await I()}catch(r){console.error("Failed to submit job:",r),a({title:`Failed to ${d?"update":"create"} job`,description:r?.message??"Unknown error",variant:"destructive"})}finally{ie(!1)}},Ee=async s=>{if(s._error){a({title:"Cannot run corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}k(s.id);try{const t=await fetch(`${N}/api/v1/jobs/${s.id}/run`,{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to run job (${t.status})`)}a({title:"Run started",description:`${s.name} is executing.`}),await I(),await o()}catch(t){console.error("Failed to run job:",t),a({title:"Run failed to start",description:t?.message??"Unknown error",variant:"destructive"})}finally{k(null)}},Je=async s=>{if(s._error){a({title:"Cannot update corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}k(s.id);const t=s.status==="active"?"paused":"active";try{const r=await fetch(`${N}/api/v1/jobs/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i?.error?.message||`Failed to update job (${r.status})`)}a({title:t==="active"?"Job resumed":"Job paused",description:s.name}),await I(),await o()}catch(r){console.error("Failed to update job status:",r),a({title:"Failed to update job",description:r?.message??"Unknown error",variant:"destructive"})}finally{k(null)}},ce=async s=>{k(s.id);try{const t=await fetch(`${N}/api/v1/jobs/${s.id}`,{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to delete job (${t.status})`)}a({title:"Scheduled job deleted",description:s.name}),d?.id===s.id&&(w(!1),C(null),M()),await I()}catch(t){console.error("Failed to delete job:",t),a({title:"Failed to delete job",description:t?.message??"Unknown error",variant:"destructive"})}finally{k(null)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Jobs"}),e.jsx("p",{className:"text-md text-muted-foreground",children:"Automate recurring AI runs"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(c,{variant:"outline",onClick:()=>I(!0),disabled:b||J,children:[J?e.jsx(P,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(rs,{className:"mr-2 h-4 w-4"}),"Refresh"]}),e.jsxs(c,{onClick:de,children:[e.jsx(oe,{className:"mr-2 h-4 w-4"}),"New Scheduled Job"]})]})]}),b?e.jsx(R,{children:e.jsxs(Z,{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading scheduled jobs..."]})}):h.length===0?e.jsx(R,{className:"border-dashed",children:e.jsxs(Z,{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-6 mb-6",children:e.jsx(me,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx(ee,{className:"text-2xl mb-3",children:"No scheduled jobs yet"}),e.jsx("p",{className:"text-muted-foreground max-w-md mb-6",children:"Automate recurring tasks with optional skills and MCP servers. Set up your first job to get started."}),e.jsxs("div",{className:"bg-accent/50 rounded-lg p-6 max-w-lg space-y-3 text-sm text-left",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"1"})}),e.jsx("p",{className:"text-muted-foreground",children:"Choose the days of the week and cadence that fit your workflow"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"2"})}),e.jsx("p",{className:"text-muted-foreground",children:"Provide detailed instructions so the job can execute safely"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"3"})}),e.jsx("p",{className:"text-muted-foreground",children:"All runs are logged under for review"})]})]}),e.jsxs(c,{onClick:de,className:"mt-8",size:"lg",children:[e.jsx(oe,{className:"mr-2 h-5 w-5"}),"Create Your First Job"]})]})}):e.jsx("div",{className:"grid gap-4",children:h.map(s=>s._error?e.jsx(R,{className:"border-destructive/50 bg-destructive/5",children:e.jsx(ye,{className:"pb-3",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.5",children:[e.jsxs(ee,{className:"text-lg truncate text-destructive",children:["Unable to load job: ",s.id]}),e.jsx(E,{variant:"destructive",className:"text-xs shrink-0",children:"Error"})]}),e.jsx("p",{className:"text-sm text-destructive/80 mt-1",children:s._error}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Please review the job file at ",e.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:[".nut/jobs/",s.id,".md"]})]})]}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs(W,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(c,{size:"sm",variant:"ghost",disabled:S===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(he,{className:"h-3.5 w-3.5"})})}),e.jsxs(U,{children:[e.jsxs(_,{children:[e.jsx(q,{children:"Delete corrupted job?"}),e.jsxs(V,{children:["This will remove the corrupted job file ",e.jsx("strong",{children:s.id}),". This action cannot be undone."]})]}),e.jsxs(Y,{children:[e.jsx(G,{children:"Cancel"}),e.jsx(K,{onClick:()=>ce(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})})]})})},s.id):e.jsxs(R,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all hover:shadow-lg",children:[e.jsx(ye,{className:"pb-3",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.5",children:[e.jsx($,{to:`/schedule/${s.id}`,className:"hover:underline",children:e.jsx(ee,{className:"text-lg truncate",children:s.name})}),e.jsx(E,{variant:ke(s.status),className:"capitalize text-xs shrink-0",children:s.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:s.description||s.prompt||"No description provided"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(c,{size:"sm",variant:"default",onClick:()=>Ee(s),disabled:S===s.id,className:"h-8 px-3",children:S===s.id?e.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"mr-1.5 h-3.5 w-3.5"}),"Run"]})}),e.jsx(c,{size:"sm",variant:"outline",asChild:!0,className:"h-8 px-3 text-xs",children:e.jsx($,{to:`/schedule/${s.id}`,children:"View"})}),e.jsx(c,{size:"sm",variant:"outline",onClick:()=>Pe(s),disabled:S===s.id,className:"h-8 px-3 text-xs",children:"Edit"}),e.jsx(c,{size:"sm",variant:"outline",onClick:()=>Je(s),disabled:S===s.id,className:"h-8 px-2",children:s.status==="active"?e.jsx(ns,{className:"h-3.5 w-3.5"}):e.jsx(we,{className:"h-3.5 w-3.5"})}),e.jsxs(W,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(c,{size:"sm",variant:"ghost",disabled:S===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(he,{className:"h-3.5 w-3.5"})})}),e.jsxs(U,{children:[e.jsxs(_,{children:[e.jsx(q,{children:"Delete scheduled job?"}),e.jsxs(V,{children:["This will remove ",e.jsx("strong",{children:s.name}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(Y,{children:[e.jsx(G,{children:"Cancel"}),e.jsx(K,{onClick:()=>ce(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})}),e.jsxs(Z,{className:"space-y-3 pt-0",children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(is,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"font-semibold truncate",children:cs(s.schedule)})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(Q,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"font-semibold",children:os(s.model)})]}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Next"}),e.jsx("div",{className:"font-semibold truncate",children:ae(s.metadata.nextRunAt)})]})}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Last"}),e.jsx("div",{className:"font-semibold truncate",children:ae(s.metadata.lastRunAt)})]})})]}),(s.agentIds&&s.agentIds.length>0||s.agentId||s.mcpServers&&s.mcpServers.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[(s.agentIds||(s.agentId?[s.agentId]:[])).map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(Q,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-100",children:t.replace(".md","")})]},t)),s.mcpServers&&s.mcpServers.length>0&&s.mcpServers.map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-purple-50 dark:bg-purple-950/20 border border-purple-200 dark:border-purple-800",children:[e.jsx(Se,{className:"h-3 w-3 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"font-medium text-purple-900 dark:text-purple-100",children:t})]},t))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[e.jsx(He,{className:"h-3 w-3"}),"Recent Runs"]}),s.runs.length>1&&e.jsx(c,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",asChild:!0,children:e.jsxs($,{to:`/schedule/${s.id}`,children:["View All (",s.runs.length,")",e.jsx(xe,{className:"ml-1 h-3 w-3"})]})})]}),s.runs.length===0?e.jsx("div",{className:"rounded-md border border-dashed bg-muted/20 p-4 text-center text-xs text-muted-foreground",children:'No runs yet • Click "Run" to execute'}):e.jsxs("div",{className:"space-y-1.5",children:[s.runs.slice(0,3).map(t=>e.jsxs($,{to:`/schedule/${s.id}/run/${t.id}`,className:"flex items-center gap-2 p-2.5 rounded-md border bg-card/50 hover:bg-accent/50 transition-colors text-xs group",children:[e.jsx(E,{variant:ke(t.status),className:"capitalize text-[10px] h-5 shrink-0",children:t.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-muted-foreground truncate",children:ae(t.startedAt)}),t.error&&e.jsx("p",{className:"text-destructive font-medium mt-0.5 line-clamp-1",children:t.error})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.trigger==="manual"&&e.jsx(E,{variant:"outline",className:"text-[10px] h-5",children:"manual"}),e.jsx(xe,{className:"h-3 w-3 text-muted-foreground group-hover:text-foreground transition-colors"})]})]},t.id)),s.runs.length>3&&e.jsx(c,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",asChild:!0,children:e.jsxs($,{to:`/schedule/${s.id}`,children:["+",s.runs.length-3," more runs"]})})]})]})]})]},s.id))}),e.jsx(Be,{open:F,onOpenChange:s=>{w(s),s||(C(null),M())},children:e.jsxs(We,{className:"sm:max-w-[70rem] h-[min(875px,calc(100vh-2rem))] overflow-hidden !flex flex-col",children:[e.jsxs(Ue,{className:"space-y-2 pb-4 shrink-0",children:[e.jsxs(_e,{className:"text-xl flex items-center gap-2",children:[e.jsx(me,{className:"h-5 w-5 text-primary"}),d?"Edit Scheduled Job":"Create New Scheduled Job"]}),e.jsx(qe,{className:"text-sm",children:d?"Update the prompt, cadence, or skill selection":"Automate recurring tasks with optional skills and MCP access"})]}),e.jsxs("form",{onSubmit:Re,className:"flex flex-col flex-1 min-h-0",children:[e.jsxs(ts,{defaultValue:"basics",className:"flex-1 flex flex-col min-h-0",children:[e.jsxs(as,{className:"grid w-full grid-cols-3 mb-4 shrink-0",children:[e.jsx(se,{value:"basics",children:"Basics"}),e.jsx(se,{value:"schedule",children:"Schedule"}),e.jsx(se,{value:"advanced",children:"Advanced"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto pr-2 -mr-2 min-h-0",children:[e.jsxs(te,{value:"basics",className:"mt-0 space-y-5",children:[e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(f,{htmlFor:"job-name",className:"text-sm font-medium flex items-center gap-1.5",children:["Job Name",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(X,{id:"job-name",placeholder:"e.g., Publish docs nightly",value:n.name,onChange:s=>v({name:s.target.value}),className:"h-11",required:!0})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(f,{htmlFor:"job-model",className:"text-sm font-medium",children:"Agent"}),e.jsxs(Ke,{value:n.model,onValueChange:s=>v({model:s}),children:[e.jsx(Qe,{id:"job-model",className:"h-11",children:e.jsx(Xe,{placeholder:"Select a model"})}),e.jsx(Ze,{children:ne.map(s=>e.jsx(es,{value:s.id,children:s.label},s.id))})]})]})]}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(f,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(Q,{className:"h-4 w-4"}),"Skills",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(pe,{children:[e.jsx(fe,{asChild:!0,children:e.jsxs(c,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.agentIds.length===0?"Select skills...":n.agentIds.length===g.length&&g.length>0?"All skills selected":`${n.agentIds.length} skill${n.agentIds.length!==1?"s":""} selected`,e.jsx(ge,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(ve,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(je,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Skills"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(c,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault();const t=g.map(r=>r.id);v({agentIds:t,mcpServers:le(t,n.mcpServers)})},children:"All"}),e.jsx(c,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),v({agentIds:[]})},children:"None"})]})]}),e.jsx(Ne,{}),g.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No skills found"}):g.map(s=>e.jsx(be,{checked:n.agentIds.includes(s.id),onCheckedChange:t=>Te(s.id,t),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:s.name}),s.mcpServers.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP servers: ",s.mcpServers.join(", ")]}),s.mcpServers.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inherits available MCP servers"})]})},s.id))]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(f,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(Se,{className:"h-4 w-4"}),"MCP Servers",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(pe,{children:[e.jsx(fe,{asChild:!0,children:e.jsxs(c,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.mcpServers.length===0?"No MCP servers selected":`${n.mcpServers.length} server${n.mcpServers.length!==1?"s":""} selected`,e.jsx(ge,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(ve,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(je,{children:"Available MCP Servers"}),e.jsx(Ne,{}),L.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No MCP servers configured"}):L.map(s=>e.jsx(be,{checked:n.mcpServers.includes(s),onCheckedChange:t=>$e(s,t),children:s},s))]})]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(f,{htmlFor:"job-prompt",className:"text-sm font-medium flex items-center gap-1.5",children:[n.agentIds.length>0?"Custom Instructions":"Instructions",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(Ve,{id:"job-prompt",placeholder:n.agentIds.length>0?`Additional instructions to supplement the selected skills...
|
|
2
|
-
Example: Focus on performance optimizations`:`Example:
|
|
3
|
-
Run the following command and append the output to .nut/knowledge/runs.md:
|
|
4
|
-
pnpm test`,value:n.prompt,onChange:s=>v({prompt:s.target.value}),className:"h-[min(42vh,22rem)] resize-none font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-start gap-1.5",children:[e.jsx("span",{className:"text-amber-600 dark:text-amber-500",children:"⚠"}),e.jsx("span",{children:n.agentIds.length>0?"These custom instructions will be combined with the selected skills. Jobs run with autonomous permissions.":"Provide clear, actionable instructions. Jobs run with autonomous permissions - include safety checks where needed."})]})]})]}),e.jsx(te,{value:"schedule",className:"space-y-5 mt-0",children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-[1.2fr_1fr]",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"text-sm font-medium",children:"Days of the Week"}),e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:ls.map(s=>e.jsxs("label",{className:"flex items-center gap-2.5 text-sm rounded-md border border-input px-3.5 py-2.5 cursor-pointer hover:bg-accent/50 transition-colors",children:[e.jsx(Ye,{checked:n.daysOfWeek.has(s.value),onCheckedChange:t=>Me(s.value,t)}),e.jsx("span",{className:"font-medium",children:s.label})]},s.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which days the job should run"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(f,{htmlFor:"job-hours",className:"text-sm font-medium",children:"Frequency (hours)"}),e.jsxs("div",{className:"relative",children:[e.jsx(X,{id:"job-hours",type:"number",min:1,value:n.hours,onChange:s=>v({hours:Number(s.target.value)||1}),className:"h-11 pr-16"}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"hours"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How often the job runs on selected days"})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(f,{htmlFor:"job-anchor",className:"text-sm font-medium flex items-center gap-1.5",children:["Start Hour",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(X,{id:"job-anchor",type:"number",min:0,max:23,placeholder:"Auto",value:n.anchorHour,onChange:s=>v({anchorHour:s.target.value}),className:"h-11"}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"0-23"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Preferred starting hour in 24h format"})]})]})]})}),e.jsx(te,{value:"advanced",className:"space-y-5 mt-0",children:e.jsxs("div",{className:"flex items-start gap-4 rounded-lg border border-border bg-accent/20 p-4",children:[e.jsx(ss,{id:"job-status",checked:n.status,onCheckedChange:s=>v({status:s}),className:"mt-1"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(f,{htmlFor:"job-status",className:"text-base font-semibold cursor-pointer",children:n.status?"Start Active":"Start Paused"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.status?"Job will begin running on the configured schedule immediately after creation.":"Job will be created in a paused state. You can activate it later from the schedule page."})]})]})})]})]}),e.jsxs(Ge,{className:"gap-2 sm:gap-2 pt-4 border-t mt-4",children:[e.jsx(c,{type:"button",variant:"outline",onClick:()=>w(!1),disabled:O,className:"min-w-24",children:"Cancel"}),e.jsx(c,{type:"submit",disabled:O||!n.name.trim()||!n.prompt.trim(),className:"min-w-32",children:O?e.jsxs(e.Fragment,{children:[e.jsx(P,{className:"mr-2 h-4 w-4 animate-spin"}),d?"Saving...":"Creating..."]}):e.jsx(e.Fragment,{children:d?"Save Changes":"Create Job"})})]})]})]})}),e.jsx(W,{open:z.open,onOpenChange:s=>{s||H({open:!1,serverToRemove:null})},children:e.jsxs(U,{children:[e.jsxs(_,{children:[e.jsx(q,{children:"Remove MCP Server?"}),e.jsxs(V,{children:["One or more selected skills require the ",e.jsx("strong",{children:z.serverToRemove})," MCP server. Removing it may lead to unexpected consequences when the job runs."]})]}),e.jsxs(Y,{children:[e.jsx(G,{children:"Cancel"}),e.jsx(K,{onClick:Fe,children:"OK"})]})]})})]})}export{Cs as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as C,u as S,r as h,j as e,B as a,L as c,_ as E,H as T,k as A,A as N}from"./index-ByTA2ZiD.js";import{C as l,b as d,a as o,c as f,d as z}from"./card-CL5bB4cs.js";import{B as v}from"./badge-BbfU_aPt.js";import{A as p}from"./arrow-left-B9NBHEkS.js";function B(n){return n.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())}const i={blue:{bg:"#dbeafe",border:"#2563eb",text:"#1e40af"},green:{bg:"#dcfce7",border:"#16a34a",text:"#166534"},red:{bg:"#fee2e2",border:"#dc2626",text:"#991b1b"},emerald:{bg:"#d1fae5",border:"#10b981",text:"#047857"},purple:{bg:"#f3e8ff",border:"#9333ea",text:"#6b21a8"},orange:{bg:"#fed7aa",border:"#ea580c",text:"#9a3412"},yellow:{bg:"#fef9c3",border:"#eab308",text:"#854d0e"},teal:{bg:"#ccfbf1",border:"#14b8a6",text:"#0f766e"},indigo:{bg:"#e0e7ff",border:"#6366f1",text:"#4338ca"},pink:{bg:"#fce7f3",border:"#ec4899",text:"#9f1239"},cyan:{bg:"#cffafe",border:"#06b6d4",text:"#155e75"},slate:{bg:"#f1f5f9",border:"#475569",text:"#334155"},gray:{bg:"#f3f4f6",border:"#6b7280",text:"#374151"}};function U(){const n=C(),u=S(),[s,w]=h.useState(null),[k,g]=h.useState(!0),[b,m]=h.useState(null);h.useEffect(()=>{async function r(){try{g(!0);const j=await(await fetch(`${N}/api/v1/skills/${n.id}`)).json();j.success?w(j.document):m(j.error||"Failed to fetch skill")}catch(t){m(t instanceof Error?t.message:"Unknown error")}finally{g(!1)}}n.id&&r()},[n.id]);const y=async()=>{if(!(!s||!confirm("Are you sure you want to delete this skill?")))try{const t=await(await fetch(`${N}/api/v1/skills/${s.id}`,{method:"DELETE"})).json();t.success?u("/skills"):m(t.error?.message||"Failed to delete skill")}catch(r){m(r instanceof Error?r.message:"Unknown error")}};if(k)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-64 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 animate-pulse mt-2"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(c,{to:"/skills",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})})})]}),e.jsx(l,{children:e.jsxs(d,{children:[e.jsx("div",{className:"h-6 bg-muted rounded w-48 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-64 animate-pulse"})]})})]});if(b||!s)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Skill Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:"The requested skill could not be found"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(c,{to:"/skills",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})})})]}),e.jsx(l,{children:e.jsx(o,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-destructive",children:b||"Skill not found"})})})})]});const x=s.metadata?.color||"blue";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("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",children:B(s.name)}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(c,{to:"/skills",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})}),e.jsx(a,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(c,{to:`/skills/${s.id}/edit`,children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(a,{variant:"destructive",size:"sm",onClick:y,children:[e.jsx(T,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(f,{children:"Description"})}),e.jsx(o,{children:e.jsx("p",{children:s.description})})]}),s.content&&e.jsxs(l,{children:[e.jsxs(d,{children:[e.jsx(f,{children:"Instructions"}),e.jsx(z,{children:"System prompt and behavior instructions for this skill"})]}),e.jsx(o,{children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm bg-muted p-4 rounded-md",children:s.content})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(f,{children:"Actions"})}),e.jsx(o,{className:"space-y-2",children:e.jsx(a,{variant:"default",className:"w-full justify-start",asChild:!0,children:e.jsxs(c,{to:`/terminal/sk-${s.id}`,children:[e.jsx(A,{className:"h-4 w-4 mr-2"}),"Use Skill"]})})})]}),e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(f,{children:"Information"})}),e.jsxs(o,{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Color"}),e.jsx(v,{variant:"outline",className:"capitalize border-2",style:{backgroundColor:i[x]?.bg||i.blue.bg,color:i[x]?.text||i.blue.text,borderColor:i[x]?.border||i.blue.border},children:x})]}),s.allowedTools&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Allowed Tools"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.allowedTools})]}),s.metadata?.mcpServers&&s.metadata.mcpServers.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"MCP Servers"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:s.metadata.mcpServers.map(r=>e.jsx(v,{variant:"secondary",children:r},r))})]}),!s.allowedTools&&!(s.metadata?.mcpServers&&s.metadata.mcpServers.length>0)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Tools"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No specific tools configured - inherits all tools"})]})]})]})]})]})]})}export{U as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as N,r as t,A as v,j as e,v as C,aw as w,B as a,L as o,_ as d,M as g,au as y,aq as b}from"./index-ByTA2ZiD.js";import{C as i,a as r,b as E}from"./card-CL5bB4cs.js";import{c as T}from"./clipboard-B9ndUJKl.js";function D(){const{toast:c}=N(),[l,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${v}/api/v1/context/team`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/team.md";try{await T(s),c({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),c({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"team-md",filename:"team.md",name:"team.md",path:".nut/context/team.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading team definition..."})]})})})}):!u||!l?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(w,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Team Definition Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Team definition will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(o,{to:"/context/team/edit",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),"Create Team Definition"]})})]})})})}):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:"Team"}),e.jsx("p",{className:"text-muted-foreground",children:"Team structure and member information"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(g,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(o,{to:"/context/team/edit",children:[e.jsx(d,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(i,{children:[e.jsx(E,{className:"pb-0"}),e.jsx(r,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(b,{children:l.content||"No content available"})})})]})]})}export{D as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as L,a as F,r as n,A as C,j as s,B as m,v as b,a1 as M,I,H as Q,P as R,ab as W,a2 as q}from"./index-ByTA2ZiD.js";import{C as G,a as K}from"./card-CL5bB4cs.js";import{u as V}from"./use-terminal-D1UnvAVs.js";import{C as X}from"./circle-play-CLKDBkrK.js";import{P as Y}from"./play-fOwEoIcu.js";function A(){return`script-${Date.now()}-${Math.floor(Math.random()*1e3)}`}function T(o){return Object.entries(o).map(([l,r])=>({id:A(),name:l,command:r}))}function $(o){const l={};for(const r of o){const x=r.name.trim();x&&(l[x]=r.command)}return l}function ns(){const o=L(),{loading:l,createSession:r,refreshSessions:x}=V(),{toast:c}=F(),[O,h]=n.useState(!1),[P,p]=n.useState(!1),[g,j]=n.useState(!1),[B,D]=n.useState(!0),[d,u]=n.useState([]),[E,v]=n.useState({}),[,N]=n.useState([]),_=JSON.stringify($(d))!==JSON.stringify(E);n.useEffect(()=>{try{const e=localStorage.getItem("terminal.commandHistory");e&&N(JSON.parse(e))}catch{}},[]),n.useEffect(()=>{(async()=>{try{const t=await fetch(`${C}/api/v1/config`);if(!t.ok)return;const i=(await t.json())?.data?.scripts||{};v(i),u(T(i))}catch{}finally{D(!1)}})()},[]);const y=e=>{e&&N(t=>{const a=[e,...t.filter(i=>i!==e)].slice(0,5);try{localStorage.setItem("terminal.commandHistory",JSON.stringify(a))}catch{}return a})},z=n.useCallback(async()=>{const e=$(d),t=d.filter(a=>!a.name.trim()&&!a.command.trim()).length;j(!0);try{if(!(await fetch(`${C}/api/v1/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({scripts:e})})).ok)throw new Error("Save failed");v(e),u(T(e)),c({title:"Scripts saved",description:t>0?`${t} blank row${t>1?"s":""} removed`:void 0})}catch{c({title:"Failed to save scripts",variant:"destructive"})}finally{j(!1)}},[d,c]),S=()=>{u(e=>[...e,{id:A(),name:"",command:""}])},k=(e,t,a)=>{u(i=>i.map(f=>f.id===e?{...f,[t]:a}:f))},H=e=>{u(t=>t.filter(a=>a.id!==e))},J=async e=>{const t=(e||"").trim();if(!t)return;const a=`session-${Date.now()}`;h(!0);try{await r(a,t)?(y(t),c({title:"Session started",description:a}),o(`/terminal/${a}`)):c({title:"Failed to start",variant:"destructive"})}finally{h(!1)}},U=async e=>{const t=(e||"").trim();if(!t)return;const a=`session-${Date.now()}`;p(!0);try{await r(a,t)?(y(t),setTimeout(()=>x(),150),c({title:"Started in background",description:a,action:s.jsx(q,{altText:"Open session",onClick:()=>o(`/terminal/${a}`),children:"Open"})})):c({title:"Failed to start",variant:"destructive"})}finally{p(!1)}},w=l||O||P;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Utilities"}),s.jsx("p",{className:"text-muted-foreground",children:"Quick commands and shortcuts"})]}),s.jsx("div",{className:"flex items-center gap-2",children:_&&s.jsxs(m,{onClick:z,disabled:g,size:"sm",children:[g?s.jsx(b,{className:"h-4 w-4 mr-1 animate-spin"}):s.jsx(M,{className:"h-4 w-4 mr-1"}),"Save"]})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Scripts"}),s.jsx(G,{children:s.jsx(K,{className:"pt-6",children:B?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(b,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):d.length>0?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"hidden sm:grid sm:grid-cols-[1fr_2fr_auto] gap-2 px-2 pb-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Name"}),s.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Command"}),s.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide w-[200px]",children:"Actions"})]}),s.jsx("div",{className:"rounded-md border divide-y",children:d.map(e=>s.jsxs("div",{className:"flex flex-col sm:grid sm:grid-cols-[1fr_2fr_auto] gap-2 p-2 items-start sm:items-center",children:[s.jsx(I,{value:e.name,onChange:t=>k(e.id,"name",t.target.value),placeholder:"script name",className:"h-8 text-sm font-medium"}),s.jsx(I,{value:e.command,onChange:t=>k(e.id,"command",t.target.value),placeholder:"command to run",className:"h-8 text-sm font-mono"}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsxs(m,{onClick:()=>U(e.command),variant:"secondary",size:"sm",disabled:w||!e.command.trim(),title:"Run in background",children:[s.jsx(X,{className:"h-4 w-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:"Background"})]}),s.jsxs(m,{onClick:()=>J(e.command),size:"sm",disabled:w||!e.command.trim(),title:"Run",children:[s.jsx(Y,{className:"h-4 w-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:"Run"})]}),s.jsx(m,{onClick:()=>H(e.id),variant:"ghost",size:"sm",title:"Remove script",children:s.jsx(Q,{className:"h-4 w-4"})})]})]},e.id))}),s.jsxs(m,{variant:"outline",size:"sm",onClick:S,className:"mt-2",children:[s.jsx(R,{className:"h-4 w-4 mr-1"}),"Add Script"]})]}):s.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3 py-8",children:[s.jsx(W,{className:"h-12 w-12 text-muted-foreground"}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No scripts configured"}),s.jsx("p",{className:"text-sm text-muted-foreground max-w-md leading-relaxed",children:"Scripts let you run common tasks with one click, like starting your development server or running build commands."})]}),s.jsxs(m,{variant:"outline",onClick:S,children:[s.jsx(R,{className:"h-4 w-4 mr-1"}),"Add Script"]})]})})})]})]})}export{ns as default};
|