@lovelybunch/api 1.0.77-alpha.2 → 1.0.77-alpha.4
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/m2m.d.ts +26 -0
- package/dist/config/m2m.js +27 -0
- package/dist/lib/auth/clerk-m2m-verifier.d.ts +34 -0
- package/dist/lib/auth/clerk-m2m-verifier.js +47 -0
- package/dist/middleware/auth.js +39 -5
- package/dist/routes/api/v1/auth/route.js +17 -0
- package/dist/server-with-static.js +19 -0
- package/dist/server.js +17 -0
- package/package.json +4 -4
- package/static/assets/{ActivityPage-BrpfoR1x.js → ActivityPage-NWY9n_Vz.js} +1 -1
- package/static/assets/{AgentsContextEditPage-DD96j1Gu.js → AgentsContextEditPage-CegcDIbc.js} +1 -1
- package/static/assets/{AgentsContextPage-DbGPK_nF.js → AgentsContextPage-tv1aSHZt.js} +1 -1
- package/static/assets/{ApiKeysSettingsPage-DCRw8BVU.js → ApiKeysSettingsPage-DBLY6U4j.js} +1 -1
- package/static/assets/{AuthSettingsPage-BZcuolzF.js → AuthSettingsPage-CrQ12eym.js} +1 -1
- package/static/assets/{CallbackPage-j_Z5gQid.js → CallbackPage-CG7uYftC.js} +1 -1
- package/static/assets/{CoconutCallbackPage-ZEdMiq56.js → CoconutCallbackPage-5SdoMUzX.js} +1 -1
- package/static/assets/{CodePage-LOMEoK8O.js → CodePage-BSpmMVCY.js} +1 -1
- package/static/assets/{CollapsibleSection-iVC3bo9u.js → CollapsibleSection-CIsOS9cT.js} +1 -1
- package/static/assets/{DashboardPage-CAxisL8l.js → DashboardPage-H6Do6mdY.js} +1 -1
- package/static/assets/{GitPage-BzVIV2mo.js → GitPage-BUjmwsaT.js} +1 -1
- package/static/assets/{GitSettingsPage-CKWWrG0f.js → GitSettingsPage-D4pHZQc1.js} +1 -1
- package/static/assets/{IdentityPage-IVZ-nvh_.js → IdentityPage-eGF1AqJq.js} +1 -1
- package/static/assets/{ImplementationStepsEditor-IzyUL2cs.js → ImplementationStepsEditor-B2rhUkN7.js} +1 -1
- package/static/assets/{IntegrationsSettingsPage-DvzES04i.js → IntegrationsSettingsPage-BtuhWJYd.js} +1 -1
- package/static/assets/{JobDetailPage-DVKKQ1j7.js → JobDetailPage-DELop2el.js} +1 -1
- package/static/assets/{KnowledgeDetailPage-jdJGqZT9.js → KnowledgeDetailPage-tar2oGxi.js} +1 -1
- package/static/assets/{KnowledgeEditPage-C60yLCQf.js → KnowledgeEditPage-B2Kar8q4.js} +1 -1
- package/static/assets/{KnowledgePage-B3G3eWhs.js → KnowledgePage-DLc2exrV.js} +1 -1
- package/static/assets/{LoginPage-DXRpkMQE.js → LoginPage-DOmSsPXw.js} +1 -1
- package/static/assets/{MailInboxPage-D4F-yUb2.js → MailInboxPage-TygzTth5.js} +1 -1
- package/static/assets/{MailProcessingModal-C5TbdlsX.js → MailProcessingModal-DNrjOWM6.js} +1 -1
- package/static/assets/{MailReadPage-Bn6Zw8xJ.js → MailReadPage-kzVyjGT2.js} +1 -1
- package/static/assets/{MailSentPage-Bk3jJOzz.js → MailSentPage-B_8poTdm.js} +1 -1
- package/static/assets/{McpSettingsPage-D2UXUhK2.js → McpSettingsPage-8OZzZoOw.js} +1 -1
- package/static/assets/{MemoryEditPage-fFwS44vf.js → MemoryEditPage-hbJZOd-h.js} +1 -1
- package/static/assets/{MemoryPage-BTOJoF-z.js → MemoryPage-mPp-CSud.js} +1 -1
- package/static/assets/{NewKnowledgePage-X86yjTVl.js → NewKnowledgePage-EFr9n04L.js} +1 -1
- package/static/assets/{NewSkillPage-e8dGvY9r.js → NewSkillPage-CMh7-arC.js} +1 -1
- package/static/assets/{NewTaskPage-DhUlLdQA.js → NewTaskPage-CQ5OgF1b.js} +1 -1
- package/static/assets/{NotFoundPage-BjIfj-6G.js → NotFoundPage-C5dV-iS-.js} +1 -1
- package/static/assets/{NotificationsSettingsPage-YWyp3_fq.js → NotificationsSettingsPage-dPjU5Q1h.js} +1 -1
- package/static/assets/{PromptsSettingsPage-DS-7Hcyy.js → PromptsSettingsPage-BvZsTJJa.js} +1 -1
- package/static/assets/{ResourceDetailPage-5lxrzduZ.js → ResourceDetailPage-BOQcC7HN.js} +1 -1
- package/static/assets/{ResourcesPage-5e8iv04j.js → ResourcesPage-D78kDCDA.js} +1 -1
- package/static/assets/{RoleEditPage-CZl5kzLm.js → RoleEditPage-B9kTm8KI.js} +1 -1
- package/static/assets/{RolePage-DH1XSfmN.js → RolePage-B2vEFgJt.js} +1 -1
- package/static/assets/{RulesSettingsPage-CfHyX5-L.js → RulesSettingsPage-DkpLo1qw.js} +1 -1
- package/static/assets/{RunDetailPage-CKvjq6lg.js → RunDetailPage-cKilo4we.js} +1 -1
- package/static/assets/{SchedulePage-DK3H_i1s.js → SchedulePage-Bs_zBMCY.js} +1 -1
- package/static/assets/{SkillDetailPage-K_CkFQv-.js → SkillDetailPage-Ltd1vGyY.js} +1 -1
- package/static/assets/{SkillEditPage-2X3bZgJ0.js → SkillEditPage-WvDnQbsn.js} +1 -1
- package/static/assets/{SkillsPage-Ba-7nPAX.js → SkillsPage-2bSn7LSx.js} +1 -1
- package/static/assets/{SkillsSettingsPage-w64_WHIP.js → SkillsSettingsPage-B9JwEAuy.js} +1 -1
- package/static/assets/{SourceInput-I-hamu6Q.js → SourceInput-BDIqXfxi.js} +1 -1
- package/static/assets/{TagInput-DEIDoXAF.js → TagInput-CL7jQrpP.js} +1 -1
- package/static/assets/{TaskDetailPage-CIzKy_lB.js → TaskDetailPage-CtG04fHi.js} +1 -1
- package/static/assets/{TaskEditPage-DE5iZOlS.js → TaskEditPage-CzqOFJag.js} +1 -1
- package/static/assets/{TasksPage-XJv3kCi4.js → TasksPage-horVpdZI.js} +1 -1
- package/static/assets/{TeamEditPage-BJYjNG9s.js → TeamEditPage-CL6ZR7WT.js} +1 -1
- package/static/assets/{TeamPage-8HQl8tJg.js → TeamPage-CZ8AhAtV.js} +1 -1
- package/static/assets/{TerminalPage-1wX_kSZq.js → TerminalPage-DdsR4df6.js} +1 -1
- package/static/assets/{TerminalSessionPage-C9DF64yx.js → TerminalSessionPage-BtNLOnes.js} +1 -1
- package/static/assets/{UserPreferencesPage-soBs08Yv.js → UserPreferencesPage-BFuA9TaZ.js} +1 -1
- package/static/assets/{UserSettingsPage-oGRL6qzb.js → UserSettingsPage-B4iBDHTu.js} +1 -1
- package/static/assets/{UtilitiesPage-CtZZsdkO.js → UtilitiesPage-lIgfa-TS.js} +1 -1
- package/static/assets/{alert-yfoaxi15.js → alert-BblaPWI4.js} +1 -1
- package/static/assets/{arrow-down-CmC8SDMn.js → arrow-down-5wVLzm2P.js} +1 -1
- package/static/assets/{arrow-left-C3PN_VXn.js → arrow-left-B2qdn6F8.js} +1 -1
- package/static/assets/{arrow-up-C2_FqbAf.js → arrow-up-BUq8ttsr.js} +1 -1
- package/static/assets/{arrow-up-down-BxszeBWu.js → arrow-up-down-Wx3HNLji.js} +1 -1
- package/static/assets/{badge-CfOS4AEh.js → badge-CnihwoO_.js} +1 -1
- package/static/assets/{browser-modal-CohGkjjX.js → browser-modal-BpmwARpG.js} +1 -1
- package/static/assets/{card-DBbETqHr.js → card-ClTppZkC.js} +1 -1
- package/static/assets/{chevron-left-CARf1vQR.js → chevron-left-B6cdF33u.js} +1 -1
- package/static/assets/{chevron-up-DPqLVVFe.js → chevron-up-DmV7RyoW.js} +1 -1
- package/static/assets/{chevrons-up-BJsTBH4G.js → chevrons-up-CaytjQin.js} +1 -1
- package/static/assets/{circle-alert-DvY6UCZI.js → circle-alert-DLogptcc.js} +1 -1
- package/static/assets/{circle-check-D4I1hq5t.js → circle-check-WnW2gKuY.js} +1 -1
- package/static/assets/{circle-check-big-DXkEigqp.js → circle-check-big-_7cw_xX7.js} +1 -1
- package/static/assets/{circle-play-Z-LH2XZF.js → circle-play-DAjst76T.js} +1 -1
- package/static/assets/{circle-x-Dh-KgkYg.js → circle-x-Cy-GEE0N.js} +1 -1
- package/static/assets/{clipboard-CME-lfxG.js → clipboard-BjRIfdtw.js} +1 -1
- package/static/assets/{clock-CzUgbpxH.js → clock-BqpT33TV.js} +1 -1
- package/static/assets/{code-Bf5KtxD0.js → code-BlCNWFR0.js} +1 -1
- package/static/assets/{download-RyS06A9x.js → download-gMGjJye8.js} +1 -1
- package/static/assets/{external-link-BUmaJn8N.js → external-link-B62Uv2FB.js} +1 -1
- package/static/assets/{eye-B6H1Wnna.js → eye-SF5oVtaC.js} +1 -1
- package/static/assets/{folder-git-2-GfrcYXqB.js → folder-git-2-DjFQ-1Nl.js} +1 -1
- package/static/assets/{globe-DGJd-BEz.js → globe-CawEz_y2.js} +1 -1
- package/static/assets/{index-7i8CPi9F.js → index-BLYnta2A.js} +1 -1
- package/static/assets/{index-BMfWq2j7.js → index-BOKRJR9W.js} +1 -1
- package/static/assets/{index-DztTpy2B.js → index-BgXpiZXS.js} +1 -1
- package/static/assets/{index-Oe08b-EX.js → index-BhC1oAgs.js} +1 -1
- package/static/assets/{index-B2zWPdyi.js → index-BsyUW5MN.js} +1 -1
- package/static/assets/{index-2KcfNqV-.js → index-C77IIPc5.js} +1 -1
- package/static/assets/{index-sRKyM1Il.js → index-CBMKhVK-.js} +1 -1
- package/static/assets/{index-DQyKDJLd.js → index-CJjOSL3x.js} +3 -3
- package/static/assets/{index-kIIlr6Bh.js → index-CVk4I1l9.js} +1 -1
- package/static/assets/{index-BMtEpMwG.js → index-CWkvL12t.js} +1 -1
- package/static/assets/{index-D7MExzMq.js → index-CmhgE-Ve.js} +1 -1
- package/static/assets/{index-D7veMECT.js → index-CutWk1Pr.js} +1 -1
- package/static/assets/{index-BMooEqjV.js → index-D6b2LruY.js} +1 -1
- package/static/assets/{index-ctTeh4My.js → index-DRejVr_E.js} +1 -1
- package/static/assets/{index--3ISLTsV.js → index-DhYqfZIE.js} +1 -1
- package/static/assets/{index--Syi3rI6.js → index-DiHN7yBx.js} +1 -1
- package/static/assets/{index-BCEWTKM2.js → index-FFag0sNb.js} +1 -1
- package/static/assets/{index-vmtCSD0U.js → index-HbxEbyW3.js} +1 -1
- package/static/assets/{index-3bHY1RZf.js → index-IG1FNNtX.js} +1 -1
- package/static/assets/{info-CHiTEVvq.js → info-On5lSg5-.js} +1 -1
- package/static/assets/{label-DZN-TTmJ.js → label-ENwgDlxz.js} +1 -1
- package/static/assets/{markdown-editor-CjtUzCZF.js → markdown-editor-ClbNJOVl.js} +3 -3
- package/static/assets/{message-square-D8KMCL9-.js → message-square-DBowh0DJ.js} +1 -1
- package/static/assets/{paperclip-CsjIUex0.js → paperclip-Fv26pkZS.js} +1 -1
- package/static/assets/{pause-DyIY-Fg6.js → pause-C35xce-o.js} +1 -1
- package/static/assets/{play-BsqG0Xxh.js → play-dMLqfItH.js} +1 -1
- package/static/assets/{radio-group-Cd6D1zWl.js → radio-group-BPgf2DjV.js} +1 -1
- package/static/assets/{refresh-cw-DvA7rcDs.js → refresh-cw-4aDPS4Ma.js} +1 -1
- package/static/assets/{search-BtvwgzIM.js → search-BKZ_bHPJ.js} +1 -1
- package/static/assets/{select-BTiepyTe.js → select-Cft45rTz.js} +1 -1
- package/static/assets/{server-DjyRLssO.js → server-RIrco6rM.js} +1 -1
- package/static/assets/{switch-QFsCjFLp.js → switch-N26zinJT.js} +1 -1
- package/static/assets/{tabs-BQcOvpJ3.js → tabs-94xo_fGd.js} +1 -1
- package/static/assets/{tag-ChBxeRYs.js → tag-D1KdHBUM.js} +1 -1
- package/static/assets/{terminal-preview-Ch9841_B.js → terminal-preview-BpviO4IZ.js} +1 -1
- package/static/assets/{triangle-alert-Dj9MnxX5.js → triangle-alert-O41QYHqC.js} +1 -1
- package/static/assets/{use-terminal-CJ3EJhYK.js → use-terminal-C8IG41zB.js} +1 -1
- package/static/assets/{video-DHNX2nx5.js → video-Dh8WwEAk.js} +1 -1
- package/static/index.html +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Le,ag as ze,r as u,j as e,B as c,v as P,P as oe,bL as me,J as B,N as ue,Q as he,R as _,U,V as q,W as V,Y,_ as G,$ as K,L as $,k as Q,bM as He,C as xe,D as We,b as Be,d as _e,f as Ue,g as qe,I as X,a8 as pe,a9 as fe,n as ge,aa as ve,ab as je,ac as Ne,ad as be,o as Ve,ae as Ye,a1 as Ge,A as N}from"./index-DQyKDJLd.js";import{C as R,a as Z,c as ee,b as ye}from"./card-DBbETqHr.js";import{B as E}from"./badge-CfOS4AEh.js";import{S as Ke,a as Qe,b as Xe,c as Ze,d as es}from"./select-BTiepyTe.js";import{L as f}from"./label-DZN-TTmJ.js";import{S as ss}from"./switch-QFsCjFLp.js";import{T as ts,a as as,b as se,c as te}from"./tabs-BQcOvpJ3.js";import{R as rs}from"./refresh-cw-DvA7rcDs.js";import{P as we}from"./play-BsqG0Xxh.js";import{P as ns}from"./pause-DyIY-Fg6.js";import{C as is}from"./clock-CzUgbpxH.js";import{S as Se}from"./server-DjyRLssO.js";import"./index-sRKyM1Il.js";import"./chevron-up-DPqLVVFe.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),[M,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(()=>{M&&(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(W=>W.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(W=>m.find(Oe=>Oe.id===W))})))}}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)}})()},[M,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)}))},Me=()=>{const s=z.serverToRemove;s&&x(t=>({...t,mcpServers:t.mcpServers.filter(r=>r!==s)})),H({open:!1,serverToRemove:null})},Fe=(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}})},F=()=>{x(re())},de=()=>{C(null),F(),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),F(),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),F()),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(B,{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(_,{children:[e.jsxs(U,{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(B,{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(_,{children:[e.jsxs(U,{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(We,{open:M,onOpenChange:s=>{w(s),s||(C(null),F())},children:e.jsxs(Be,{className:"sm:max-w-[70rem] h-[min(875px,calc(100vh-2rem))] overflow-hidden !flex flex-col",children:[e.jsxs(_e,{className:"space-y-2 pb-4 shrink-0",children:[e.jsxs(Ue,{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...
|
|
1
|
+
import{a as Le,ag as ze,r as u,j as e,B as c,v as P,P as oe,bL as me,J as B,N as ue,Q as he,R as _,U,V as q,W as V,Y,_ as G,$ as K,L as $,k as Q,bM as He,C as xe,D as We,b as Be,d as _e,f as Ue,g as qe,I as X,a8 as pe,a9 as fe,n as ge,aa as ve,ab as je,ac as Ne,ad as be,o as Ve,ae as Ye,a1 as Ge,A as N}from"./index-CJjOSL3x.js";import{C as R,a as Z,c as ee,b as ye}from"./card-ClTppZkC.js";import{B as E}from"./badge-CnihwoO_.js";import{S as Ke,a as Qe,b as Xe,c as Ze,d as es}from"./select-Cft45rTz.js";import{L as f}from"./label-ENwgDlxz.js";import{S as ss}from"./switch-N26zinJT.js";import{T as ts,a as as,b as se,c as te}from"./tabs-94xo_fGd.js";import{R as rs}from"./refresh-cw-4aDPS4Ma.js";import{P as we}from"./play-dMLqfItH.js";import{P as ns}from"./pause-C35xce-o.js";import{C as is}from"./clock-BqpT33TV.js";import{S as Se}from"./server-RIrco6rM.js";import"./index-CBMKhVK-.js";import"./chevron-up-DmV7RyoW.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),[M,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(()=>{M&&(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(W=>W.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(W=>m.find(Oe=>Oe.id===W))})))}}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)}})()},[M,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)}))},Me=()=>{const s=z.serverToRemove;s&&x(t=>({...t,mcpServers:t.mcpServers.filter(r=>r!==s)})),H({open:!1,serverToRemove:null})},Fe=(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}})},F=()=>{x(re())},de=()=>{C(null),F(),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),F(),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),F()),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(B,{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(_,{children:[e.jsxs(U,{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(B,{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(_,{children:[e.jsxs(U,{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(We,{open:M,onOpenChange:s=>{w(s),s||(C(null),F())},children:e.jsxs(Be,{className:"sm:max-w-[70rem] h-[min(875px,calc(100vh-2rem))] overflow-hidden !flex flex-col",children:[e.jsxs(_e,{className:"space-y-2 pb-4 shrink-0",children:[e.jsxs(Ue,{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
2
|
Example: Focus on performance optimizations`:`Example:
|
|
3
3
|
Run the following command and append the output to .nut/knowledge/runs.md:
|
|
4
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=>Fe(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(B,{open:z.open,onOpenChange:s=>{s||H({open:!1,serverToRemove:null})},children:e.jsxs(_,{children:[e.jsxs(U,{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:Me,children:"OK"})]})]})})]})}export{Cs as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as C,u as S,r as h,j as e,B as a,L as c,a2 as E,Q as T,k as A,A as N}from"./index-
|
|
1
|
+
import{H as C,u as S,r as h,j as e,B as a,L as c,a2 as E,Q as T,k as A,A as N}from"./index-CJjOSL3x.js";import{C as l,b as d,a as o,c as f,d as z}from"./card-ClTppZkC.js";import{B as v}from"./badge-CnihwoO_.js";import{A as p}from"./arrow-left-B2qdn6F8.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 +1 @@
|
|
|
1
|
-
import{H as Q,u as V,a as W,r as i,j as e,B as u,L as v,k as X,I as B,o as Y,ae as Z,A as y}from"./index-
|
|
1
|
+
import{H as Q,u as V,a as W,r as i,j as e,B as u,L as v,k as X,I as B,o as Y,ae as Z,A as y}from"./index-CJjOSL3x.js";import{C as N,a as C,b as O,c as ee}from"./card-ClTppZkC.js";import{L as l}from"./label-ENwgDlxz.js";import{B as se}from"./badge-CnihwoO_.js";import{c as te}from"./clipboard-B9ndUJKl.js";import{A as D}from"./arrow-left-B2qdn6F8.js";import{C as re,a as ae}from"./clipboard-BjRIfdtw.js";function me(){const{id:n}=Q(),q=V(),{toast:S}=W(),[U,k]=i.useState(!0),[o,w]=i.useState(!1),[d,c]=i.useState(null),[f,E]=i.useState(""),[x,P]=i.useState(""),[m,M]=i.useState("blue"),[h,F]=i.useState([]),[p,L]=i.useState(""),[$,g]=i.useState([]),[z,A]=i.useState(!0),[H,I]=i.useState(!1),R=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],_={blue:{bg:"#3b82f6",border:"#1e40af",text:"#ffffff"},green:{bg:"#22c55e",border:"#15803d",text:"#ffffff"},red:{bg:"#ef4444",border:"#b91c1c",text:"#ffffff"},emerald:{bg:"#10b981",border:"#047857",text:"#ffffff"},purple:{bg:"#a855f7",border:"#7e22ce",text:"#ffffff"},orange:{bg:"#f97316",border:"#c2410c",text:"#ffffff"},yellow:{bg:"#eab308",border:"#a16207",text:"#ffffff"},teal:{bg:"#14b8a6",border:"#0f766e",text:"#ffffff"},indigo:{bg:"#6366f1",border:"#4338ca",text:"#ffffff"},pink:{bg:"#ec4899",border:"#be185d",text:"#ffffff"},cyan:{bg:"#06b6d4",border:"#0e7490",text:"#ffffff"},slate:{bg:"#64748b",border:"#475569",text:"#ffffff"},gray:{bg:"#6b7280",border:"#4b5563",text:"#ffffff"}};i.useEffect(()=>{async function s(){try{k(!0);const r=await(await fetch(`${y}/api/v1/skills/${n}`)).json();if(!r.success)throw new Error(r.error||"Failed to load skill");const t=r.document;E(t.name||""),P(t.description||""),M(t.metadata?.color||"blue"),L(t.content||""),F(Array.isArray(t.metadata?.mcpServers)?t.metadata.mcpServers:[])}catch(a){const r=a instanceof Error?a.message:"Failed to load skill";c(r)}finally{k(!1)}}n&&s()},[n]),i.useEffect(()=>{let s=!0;return(async()=>{A(!0);try{const r=await fetch(`${y}/api/v1/mcp`);if(!r.ok)throw new Error("Failed to fetch MCP servers");const t=await r.json();if(!t?.success||!Array.isArray(t.servers)){s&&g([]);return}const b=t.mcpServers&&typeof t.mcpServers=="object"?t.mcpServers:{},K=t.servers.map(T=>{const j=b[T]??{};return{name:T,enabled:j?.enabled!==!1,description:typeof j?.description=="string"?j.description:void 0}});s&&g(K)}catch(r){console.error("Failed to load MCP servers",r),s&&g([])}finally{s&&A(!1)}})(),()=>{s=!1}},[]);const J=async()=>{const s=".nut/config.json";try{await te(s),I(!0),S({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>I(!1),2e3)}catch(a){console.error("Failed to copy config path:",a),S({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},G=async s=>{if(s.preventDefault(),!f.trim()||!x.trim()||!p.trim()){c("Name, description, and skill instructions are required");return}try{w(!0),c(null);const a={name:f.trim(),description:x.trim(),content:p.trim(),metadata:{color:m,mcpServers:h.length?h:void 0}},t=await(await fetch(`${y}/api/v1/skills/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();if(!t.success)throw new Error(t.error||"Failed to update skill");const b=t.document?.id||n;q(`/skills/${b}`)}catch(a){const r=a instanceof Error?a.message:"Failed to update skill";c(r)}finally{w(!1)}};return U?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:"Loading skill..."})})}):d&&!f?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:"Edit Skill"}),e.jsx("p",{className:"text-muted-foreground",children:"Unable to load skill"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/skills/${n}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})})]}),e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:e.jsx("div",{className:"text-destructive",children:d})})})]}):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:"Edit Skill"}),e.jsxs("p",{className:"text-muted-foreground",children:["Skill ID: ",n]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/skills/${n}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})})]}),e.jsxs(N,{children:[e.jsx(O,{children:e.jsxs(ee,{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-5 w-5"}),"Skill Configuration"]})}),e.jsx(C,{children:e.jsxs("form",{onSubmit:G,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"name",children:"Name *"}),e.jsx(B,{id:"name",value:f,onChange:s=>E(s.target.value),disabled:o})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:"Description *"}),e.jsx(B,{id:"description",value:x,onChange:s=>P(s.target.value),disabled:o})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:R.map(s=>{const a=_[s];return e.jsx("button",{type:"button",onClick:()=>M(s),disabled:o,className:`w-10 h-10 rounded-md border-2 transition-all ${m===s?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:a.bg,borderColor:m===s?a.border:"hsl(var(--border))",...m===s&&{"--tw-ring-color":a.border}},title:s,children:e.jsx("span",{className:"sr-only",children:s})},s)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"content",children:"Skill Instructions *"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["System prompt or instructions for this skill's behavior."," ","Insert ",e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:".nut/config.json"})," ",e.jsx("button",{type:"button",onClick:J,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:H?e.jsx(re,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(ae,{className:"h-3.5 w-3.5 ml-0.5"})})," ","if you want the skill to be able to access its name, role, or email address."]}),e.jsx(Y,{id:"content",value:p,onChange:s=>L(s.target.value),rows:8,disabled:o,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"MCP Servers (Optional)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which MCP servers this skill requires. Leave empty to inherit all available servers."}),e.jsx("div",{className:"space-y-2",children:z?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers..."}):$.length===0?e.jsx("div",{className:"text-sm text-muted-foreground border border-dashed rounded-md p-3",children:"No MCP servers configured yet. Configure servers in Settings → MCP."}):$.map(s=>e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-transparent bg-muted/30 px-3 py-2 hover:border-muted transition-colors",children:[e.jsx(Z,{checked:h.includes(s.name),onCheckedChange:a=>{F(r=>a===!0?r.includes(s.name)?r:[...r,s.name]:r.filter(t=>t!==s.name))},disabled:o||!s.enabled}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s.name,!s.enabled&&e.jsx(se,{variant:"secondary",className:"ml-2 text-xs",children:"Disabled"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.enabled?s.description||"Enabled MCP server":"Enable this server in Settings to use it"})]})]},s.name))})]}),d&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:d}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(u,{type:"button",variant:"outline",asChild:!0,disabled:o,children:e.jsx(v,{to:`/skills/${n}`,children:"Cancel"})}),e.jsx(u,{type:"submit",disabled:o,children:o?"Saving...":"Save Changes"})]})]})})]})]})}export{me as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as M,j as e,S as z,a3 as $,r as f,a as O,A as R,v as _,B as j,L as y,P as E,k as F,ah as B,ai as U}from"./index-
|
|
1
|
+
import{c as M,j as e,S as z,a3 as $,r as f,a as O,A as R,v as _,B as j,L as y,P as E,k as F,ah as B,ai as U}from"./index-CJjOSL3x.js";import{C as N,a as w,b as D,c as K}from"./card-ClTppZkC.js";import{c as V}from"./clipboard-B9ndUJKl.js";import{R as H,L}from"./browser-modal-BpmwARpG.js";import{R as P,f as Y}from"./registry-ANRa5WBi.js";import{B as v}from"./badge-CnihwoO_.js";import"./search-BKZ_bHPJ.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,bB as e,B as a,L as t}from"./index-
|
|
1
|
+
import{j as s,bB as e,B as a,L as t}from"./index-CJjOSL3x.js";import{C as i,b as l,c as r,d as n,a as d}from"./card-ClTppZkC.js";import{E as o}from"./external-link-B62Uv2FB.js";function h(){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-medium",children:"Skills Management"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure and manage AI skills that automate various development tasks."})]}),s.jsx(e,{}),s.jsxs(i,{children:[s.jsxs(l,{children:[s.jsx(r,{children:"Skills"}),s.jsx(n,{children:"Skills are managed from the Skills page. Visit the skills page to create, edit, and manage your AI skills."})]}),s.jsx(d,{children:s.jsx(a,{asChild:!0,children:s.jsxs(t,{to:"/skills",children:[s.jsx(o,{className:"h-4 w-4 mr-2"}),"Go to Skills"]})})})]})]})}export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,j as t,I as p,B as h,P as j,X as N}from"./index-
|
|
1
|
+
import{r as d,j as t,I as p,B as h,P as j,X as N}from"./index-CJjOSL3x.js";import{E as v}from"./external-link-B62Uv2FB.js";function w({sources:a,onChange:i,disabled:n}){const[l,c]=d.useState(""),[o,m]=d.useState(""),u=()=>{const e=l.trim();if(!e)return;const s=o.trim()||void 0,r={title:e,url:s};i([...a,r]),c(""),m("")},f=e=>{i(a.filter((s,r)=>r!==e))},x=e=>{e.key==="Enter"&&(e.preventDefault(),u())};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(p,{placeholder:"Source title (e.g., Design System Audit)",value:l,onChange:e=>c(e.target.value),onKeyDown:x,disabled:n,className:"flex-1"}),t.jsx(p,{placeholder:"URL (optional)",value:o,onChange:e=>m(e.target.value),onKeyDown:x,disabled:n,className:"flex-1",type:"url"}),t.jsxs(h,{type:"button",variant:"outline",onClick:u,disabled:n||!l.trim(),className:"shrink-0",children:[t.jsx(j,{className:"h-4 w-4 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Add"})]})]}),a.length>0&&t.jsx("ul",{className:"space-y-2",children:a.map((e,s)=>t.jsxs("li",{className:"flex items-start gap-2 rounded-md border bg-muted/50 p-2 text-sm",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium truncate",children:e.title}),e.url&&t.jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-primary flex items-center gap-1 truncate",children:[t.jsx(v,{className:"h-3 w-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e.url})]})]}),t.jsx(h,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(s),disabled:n,className:"h-6 w-6 p-0 shrink-0","aria-label":`Remove source ${e.title}`,children:t.jsx(N,{className:"h-3 w-3"})})]},s))})]})}export{w as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as t,I as d,B as m,X as x}from"./index-
|
|
1
|
+
import{r as p,j as t,I as d,B as m,X as x}from"./index-CJjOSL3x.js";import{B as f}from"./badge-CnihwoO_.js";function j({tags:a,onChange:r,disabled:n,placeholder:o}){const[l,s]=p.useState(""),c=()=>{const e=l.trim();if(e){if(a.includes(e)){s("");return}r([...a,e]),s("")}},i=e=>{r(a.filter(u=>u!==e))};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(d,{placeholder:o||"Add a tag",value:l,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),c())},disabled:n}),t.jsx(m,{type:"button",variant:"outline",onClick:c,disabled:n,children:"Add"})]}),a.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2",children:a.map(e=>t.jsxs(f,{variant:"secondary",className:"flex items-center gap-1",children:[e,t.jsx("button",{type:"button",onClick:()=>i(e),className:"ml-1 hover:text-destructive",disabled:n,"aria-label":`Remove tag ${e}`,children:t.jsx(x,{className:"h-3 w-3"})})]},e))})]})}export{j as T};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as T,H as xe,u as ue,r as i,a as pe,j as e,B as n,L as c,J as je,N as fe,Q as ge,R as Ne,U as ye,V as ve,W as be,Y as we,_ as Ce,$ as ke,D as H,a0 as V,b as B,d as q,f as J,g as K,a1 as G,a2 as Se,a3 as Q,a4 as De,m as Te,o as Ae,A as u}from"./index-
|
|
1
|
+
import{c as T,H as xe,u as ue,r as i,a as pe,j as e,B as n,L as c,J as je,N as fe,Q as ge,R as Ne,U as ye,V as ve,W as be,Y as we,_ as Ce,$ as ke,D as H,a0 as V,b as B,d as q,f as J,g as K,a1 as G,a2 as Se,a3 as Q,a4 as De,m as Te,o as Ae,A as u}from"./index-CJjOSL3x.js";import{c as $e}from"./clipboard-B9ndUJKl.js";import{C as m,b as k,a as h,c as W,d as Pe}from"./card-ClTppZkC.js";import{B as g}from"./badge-CnihwoO_.js";import{L as Y}from"./label-ENwgDlxz.js";import{S as X,a as Z,b as ee,c as se,d as te}from"./select-Cft45rTz.js";import{T as Ue,a as ae,g as Ee}from"./status-utils-PwF3DXLL.js";import{A as S}from"./arrow-left-B2qdn6F8.js";import{C as Ie,a as Oe}from"./clipboard-BjRIfdtw.js";import{A as Fe}from"./arrow-up-down-Wx3HNLji.js";import{I as Le}from"./info-On5lSg5-.js";import{P as Me}from"./play-dMLqfItH.js";import{C as _e}from"./clock-BqpT33TV.js";import{M as ze}from"./message-square-DBowh0DJ.js";import"./index-CBMKhVK-.js";import"./chevron-up-DmV7RyoW.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as M,u as R,a as U,r as c,A,j as e,B as h,L as p,I as O,X as V,a5 as _}from"./index-
|
|
1
|
+
import{H as M,u as R,a as U,r as c,A,j as e,B as h,L as p,I as O,X as V,a5 as _}from"./index-CJjOSL3x.js";import{L as j}from"./label-ENwgDlxz.js";import{S as D,a as L,b as F,c as I,d as r}from"./select-Cft45rTz.js";import{C as f,b as $,a as v,c as q,d as J}from"./card-ClTppZkC.js";import{M as K}from"./markdown-editor-ClbNJOVl.js";import{C as W}from"./CollapsibleSection-CIsOS9cT.js";import{I as X,L as G}from"./ImplementationStepsEditor-B2rhUkN7.js";import{T as Q}from"./TagInput-CL7jQrpP.js";import{A as N}from"./arrow-left-B2qdn6F8.js";import"./index-CBMKhVK-.js";import"./chevron-up-DmV7RyoW.js";import"./badge-CnihwoO_.js";function oe(){const{id:i}=M(),P=R(),{toast:y}=U(),[z,S]=c.useState(!0),[u,k]=c.useState(!1),[C,w]=c.useState(null),[n,o]=c.useState({title:"",description:"",priority:"medium",status:"draft",author:{id:"current-user",name:"Current User",email:"user@example.com"}}),[m,b]=c.useState([]),[T,E]=c.useState([]);c.useEffect(()=>{i&&B()},[i]);const B=async()=>{try{S(!0);const t=await fetch(`${A}/api/v1/tasks/${i}`),s=await t.json();if(s.success||s.data||t.ok){const a=s.data||s;o({title:a.title||a.intent||"",description:a.content||"",priority:a.metadata?.priority||"medium",status:a.status||"draft",author:{id:a.author?.id||"current-user",name:a.author?.name||"Current User",email:a.author?.email||"user@example.com"}});const g=Array.isArray(a.planSteps)?a.planSteps:[];b(g.map((d,x)=>({id:d.id||`step-${x+1}`,description:d.description||"",status:d.status||"pending"}))),E(a.metadata?.tags||[])}else w(s.error?.message||"Failed to fetch task")}catch(t){w(t instanceof Error?t.message:"An error occurred")}finally{S(!1)}},H=async t=>{t.preventDefault(),k(!0);try{const s=m.map(l=>({id:l.id,description:l.description.trim(),status:l.status})).filter(l=>l.description.length>0),a=T.map(l=>l.trim()).filter(l=>l.length>0),g={title:n.title,status:n.status,planSteps:s,metadata:{priority:n.priority,tags:a},content:n.description},d=await fetch(`${A}/api/v1/tasks/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),x=await d.json();if(x.success||d.ok)y({title:"Success",description:"Task updated successfully."}),P(`/tasks/${i}`);else throw new Error(x.error?.message||"Failed to update task")}catch(s){y({title:"Error",description:`Failed to update task: ${s instanceof Error?s.message:"An error occurred"}`,variant:"destructive"})}finally{k(!1)}};return z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Task"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading task data..."})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:`/tasks/${i}`,className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsxs(f,{children:[e.jsx($,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-6 bg-muted rounded w-1/2 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-3/4 animate-pulse"})]})}),e.jsx(v,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-10 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-64 bg-muted rounded animate-pulse"})]})})]})]}):C?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:"Error"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:"/tasks",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx(f,{children:e.jsx(v,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:C})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Task"}),e.jsxs("p",{className:"text-muted-foreground",children:["Editing ",i]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(p,{to:`/tasks/${i}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx("form",{onSubmit:H,children:e.jsxs(f,{children:[e.jsxs($,{children:[e.jsx(q,{children:"Task Details"}),e.jsx(J,{children:"Update the information for your task"})]}),e.jsxs(v,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"title",children:"Title *"}),e.jsx(O,{id:"title",placeholder:"Brief description of what you want to change",value:n.title,onChange:t=>o(s=>({...s,title:t.target.value})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"description",children:"Description"}),e.jsx(K,{value:n.description,onChange:t=>o(s=>({...s,description:t||""})),placeholder:"Write your task description in markdown...",height:400})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"status",children:"Status"}),e.jsxs(D,{value:n.status,onValueChange:t=>o(s=>({...s,status:t})),children:[e.jsx(L,{children:e.jsx(F,{placeholder:"Select status"})}),e.jsxs(I,{children:[e.jsx(r,{value:"draft",children:"Draft"}),e.jsx(r,{value:"proposed",children:"Proposed"}),e.jsx(r,{value:"in-review",children:"In Review"}),e.jsx(r,{value:"approved",children:"Approved"}),e.jsx(r,{value:"code-complete",children:"Code Complete"}),e.jsx(r,{value:"rejected",children:"Rejected"}),e.jsx(r,{value:"merged",children:"Merged"})]})]})]}),e.jsx(W,{defaultOpen:!0,icon:e.jsx(G,{className:"h-4 w-4"}),title:"Optional Implementation Detail",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"priority",children:"Priority"}),e.jsxs(D,{value:n.priority,onValueChange:t=>o(s=>({...s,priority:t})),children:[e.jsx(L,{children:e.jsx(F,{placeholder:"Select priority"})}),e.jsxs(I,{children:[e.jsx(r,{value:"low",children:"Low"}),e.jsx(r,{value:"medium",children:"Medium"}),e.jsx(r,{value:"high",children:"High"}),e.jsx(r,{value:"critical",children:"Critical"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Implementation Steps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Keep the implementation plan accurate as work progresses."})]}),m.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.length," step",m.length===1?"":"s"]})]}),e.jsx(X,{steps:m,onChange:b,disabled:u})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Tags"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tags power filtering and discovery across the task list."}),e.jsx(Q,{tags:T,onChange:E,disabled:u,placeholder:"Add a tag (e.g. backend, rollout)"})]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(h,{type:"button",variant:"outline",asChild:!0,children:e.jsxs(p,{to:`/tasks/${i}`,children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Cancel"]})}),e.jsx(h,{type:"submit",disabled:u||!n.title,children:u?e.jsx(e.Fragment,{children:"Saving..."}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Save Changes"]})})]})]})]})})]})}export{oe as TaskEditPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Ce,x as Ke,u as ze,s as Ve,r as A,j as t,B as P,L as te,P as ue,I as We,X,K as Ue,p as Ge,n as He,G as Qe,C as Ye,A as Xe}from"./index-
|
|
1
|
+
import{c as Ce,x as Ke,u as ze,s as Ve,r as A,j as t,B as P,L as te,P as ue,I as We,X,K as Ue,p as Ge,n as He,G as Qe,C as Ye,A as Xe}from"./index-CJjOSL3x.js";import{C as J,a as Z,c as Je}from"./card-ClTppZkC.js";import{B as se}from"./badge-CnihwoO_.js";import{S as oe,a as he,b as de,c as me,d as B}from"./select-Cft45rTz.js";import{A as Ze,a as Ee,T as qe,g as et}from"./status-utils-PwF3DXLL.js";import{S as tt}from"./search-BKZ_bHPJ.js";import{C as st}from"./chevron-up-DmV7RyoW.js";import{C as rt}from"./chevron-left-B6cdF33u.js";import"./index-CBMKhVK-.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as p,a as v,r as a,A as l,j as e,B as m,L as g,a5 as N}from"./index-
|
|
1
|
+
import{u as p,a as v,r as a,A as l,j as e,B as m,L as g,a5 as N}from"./index-CJjOSL3x.js";import{C as h,a as x,b as C,c as S}from"./card-ClTppZkC.js";import{M as w}from"./markdown-editor-ClbNJOVl.js";import{A as y}from"./arrow-left-B2qdn6F8.js";import{C as b}from"./circle-check-big-_7cw_xX7.js";import"./index-CBMKhVK-.js";function F(){const u=p(),{toast:t}=v(),[n,i]=a.useState(""),[f,r]=a.useState(!0),[o,c]=a.useState(!1);a.useEffect(()=>{fetch(`${l}/api/v1/context/team`).then(s=>s.json()).then(s=>{s.success&&i(s.document.content.trim()),r(!1)}).catch(s=>{console.error("Failed to load context:",s),t({title:"Error",description:"Failed to load team definition",variant:"destructive"}),r(!1)})},[t]);const j=async()=>{c(!0);try{const d=await(await fetch(`${l}/api/v1/context/team`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,metadata:{}})})).json();if(d.success)t({title:"Success",description:"Team definition saved successfully",action:e.jsx(b,{className:"h-4 w-4"})}),u("/context/team");else throw new Error(d.error||"Failed to save")}catch(s){console.error("Save error:",s),t({title:"Error",description:"Failed to save team definition",variant:"destructive"})}finally{c(!1)}};return f?e.jsx("div",{className:"space-y-6",children:e.jsx(h,{children:e.jsx(x,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Team Definition"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Define team structure, members, and communication"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(g,{to:"/context/team",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(y,{className:"w-4 h-4"})})}),e.jsxs(m,{onClick:j,disabled:o,size:"sm",children:[e.jsx(N,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:o?"Saving...":"Save"})]})]})]}),e.jsxs(h,{children:[e.jsx(C,{children:e.jsx(S,{children:"Team Documentation"})}),e.jsx(x,{children:e.jsx(w,{value:n,onChange:s=>i(s||""),placeholder:`Write your team definition in markdown...
|
|
2
2
|
|
|
3
3
|
## Team Members
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as N,r as t,A as v,j as e,v as C,aA as w,B as a,L as o,a2 as d,M as g,ay as y,au as b}from"./index-
|
|
1
|
+
import{a as N,r as t,A as v,j as e,v as C,aA as w,B as a,L as o,a2 as d,M as g,ay as y,au as b}from"./index-CJjOSL3x.js";import{C as i,a as r,b as E}from"./card-ClTppZkC.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 +1 @@
|
|
|
1
|
-
import{u as U,a as J,r as i,j as e,B as r,T as C,n as K,X as L,v as H,a6 as G}from"./index-
|
|
1
|
+
import{u as U,a as J,r as i,j as e,B as r,T as C,n as K,X as L,v as H,a6 as G}from"./index-CJjOSL3x.js";import{C as p,a as W}from"./card-ClTppZkC.js";import{u as X}from"./use-terminal-C8IG41zB.js";import{T as _}from"./terminal-preview-BpviO4IZ.js";/* empty css */import{R as q}from"./refresh-cw-4aDPS4Ma.js";import{C as Q,a as V}from"./chevrons-up-CaytjQin.js";import{C as Y}from"./chevron-up-DmV7RyoW.js";import{P as M}from"./play-dMLqfItH.js";import{C as Z}from"./circle-play-DAjst76T.js";import"./xterm-DTxiCjtJ.js";function he(){const m=U(),{sessions:f,loading:d,error:S,refreshSessions:h,createSession:j,destroySession:B}=X(),{toast:l}=J(),[x,u]=i.useState(""),[g,T]=i.useState(!1),[v,I]=i.useState(!1),[N,$]=i.useState([]),[,w]=i.useState(null),O=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 b=Math.floor(n/60);if(b<60)return`${b}m ago`;const k=Math.floor(b/60);return k<24?`${k}h ago`:`${Math.floor(k/24)}d ago`};i.useEffect(()=>{h()},[h]),i.useEffect(()=>{y(s=>{const t={...s};return f.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[f]),i.useEffect(()=>{try{const s=localStorage.getItem("terminal.commandHistory");s&&$(JSON.parse(s))}catch{}},[]);const D=s=>{s&&($(t=>{const a=[s,...t.filter(n=>n!==s)].slice(0,5);try{localStorage.setItem("terminal.commandHistory",JSON.stringify(a))}catch{}return a}),w(null))},c=f.filter(s=>!s.taskId?.startsWith("cp-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[o,y]=i.useState(()=>{const s={};return f.forEach(t=>{s[t.id]=!0}),s}),R=async()=>{const s=`session-${Date.now()}`;await j(s)&&(l({title:"New terminal started",description:`${s}`}),m(`/terminal/${s}`))},E=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;T(!0);try{await j(t,s)?(D(s),l({title:"Session started",description:`${t}`}),m(`/terminal/${t}`)):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{T(!1)}},A=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;I(!0);try{await j(t,s)?(D(s),setTimeout(()=>h(),150),u(""),l({title:"Started in background",description:`${t}`,action:e.jsx(G,{altText:"Open session",onClick:()=>m(`/terminal/${t}`),children:"Open"})})):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{I(!1)}},P=async s=>{await B(s)?(l({title:"Session closed",description:s}),setTimeout(()=>h(),100)):l({title:"Failed to close session",description:s,variant:"destructive"})},F=()=>{const s=c.every(a=>o[a.id]),t={};c.forEach(a=>{t[a.id]=!s}),y(t)},z=c.length>0&&c.every(s=>o[s.id]);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:"Terminal"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage terminal sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",onClick:()=>h(),disabled:d,children:[e.jsx(q,{className:`h-4 w-4 sm:mr-2 ${d?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),c.length>0&&e.jsx(r,{variant:"outline",onClick:F,children:z?e.jsxs(e.Fragment,{children:[e.jsx(Q,{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(V,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{onClick:R,disabled:d,children:[e.jsx(C,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"New Terminal"})]})]})]}),S&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:S})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),d?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(p,{className:"p-4",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))}):c.length===0?e.jsx(p,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(C,{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 a new terminal session with the"," ",e.jsx("button",{onClick:R,className:"text-primary hover:underline font-medium",children:"New Terminal"})," ","button above."]})]})]})}):e.jsx("div",{className:"space-y-2",children:c.slice(0,10).map(s=>e.jsxs(p,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(C,{className:"h-4 w-4"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",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 ",O(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",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:()=>{y(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":o[s.id]?"Hide preview":"Show preview",title:o[s.id]?"Hide preview":"Show preview",children:o[s.id]?e.jsx(Y,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"})}),e.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(`/terminal/${s.taskId}`),children:[e.jsx(M,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Open"})]}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>P(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(L,{className:"h-4 w-4"})})]})]}),o[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>m(`/terminal/${s.taskId}`),title:"Click to open full terminal session",children:e.jsx(_,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Run Custom Command"}),e.jsx(p,{children:e.jsxs(W,{className:"py-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:x,onChange:s=>u(s.target.value),onKeyDown:s=>{s.key==="Enter"?(s.preventDefault(),s.shiftKey?A():E()):s.key==="ArrowUp"?(s.preventDefault(),w(t=>{const a=t===null?0:Math.min((t??0)+1,N.length-1),n=N[a];return n&&u(n),a})):s.key==="ArrowDown"&&(s.preventDefault(),w(t=>{if(t===null)return null;const a=t-1;if(a<0)return u(""),null;const n=N[a];return n&&u(n),a}))},placeholder:"npm run dev",className:"flex-1 h-9 rounded-md border px-3 text-sm bg-white dark:bg-gray-900 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400"}),e.jsxs(r,{onClick:A,variant:"secondary",disabled:d||!x.trim()||v||g,children:[v?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-1"}):e.jsx(Z,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Background"})]}),e.jsxs(r,{onClick:E,disabled:d||!x.trim()||g||v,children:[g?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(M,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Run"})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Enter to Run • Shift+Enter to Run in background"})]})})]})]})}export{he as default};
|