@lovelybunch/api 1.0.71-alpha.5 → 1.0.71-alpha.7
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/routes/api/v1/resources/generate/route.js +6 -0
- package/dist/routes/api/v1/resources/generate-audio/route.js +6 -0
- package/dist/routes/api/v1/resources/generate-video/index.d.ts +3 -0
- package/dist/routes/api/v1/resources/generate-video/index.js +5 -0
- package/dist/routes/api/v1/resources/generate-video/route.d.ts +19 -0
- package/dist/routes/api/v1/resources/generate-video/route.js +241 -0
- package/dist/routes/api/v1/resources/index.js +2 -0
- package/dist/routes/api/v1/resources/route.d.ts +4 -0
- package/dist/routes/api/v1/resources/route.js +8 -4
- package/package.json +4 -4
- package/static/assets/{AgentDetailPage-B3CFO9Vg.js → AgentDetailPage-Opv1vviq.js} +1 -1
- package/static/assets/{AgentEditPage-Cc8k9uYb.js → AgentEditPage-uLCBQAKt.js} +1 -1
- package/static/assets/{AgentsPage-CcRVHD2p.js → AgentsPage-CbwDfB0S.js} +1 -1
- package/static/assets/{AgentsSettingsPage-BMphtJ6C.js → AgentsSettingsPage-wqr9YnHr.js} +1 -1
- package/static/assets/{ApiKeysSettingsPage-BLlmALn1.js → ApiKeysSettingsPage-16htmPFV.js} +1 -1
- package/static/assets/{ArchitectureEditPage-B8YrHerA.js → ArchitectureEditPage-Dvfb4b-o.js} +1 -1
- package/static/assets/{ArchitecturePage-fIoEV_ow.js → ArchitecturePage-CzD1Oize.js} +1 -1
- package/static/assets/{AuthSettingsPage-CICO_5eb.js → AuthSettingsPage-BP2zlNfC.js} +1 -1
- package/static/assets/{CallbackPage-6lJyGru9.js → CallbackPage-DEnicyfd.js} +1 -1
- package/static/assets/{CodePage-gGhNXTQn.js → CodePage-wBG-_Rs8.js} +1 -1
- package/static/assets/{CollapsibleSection-CkCVMSBD.js → CollapsibleSection-DSatk0YZ.js} +1 -1
- package/static/assets/{DashboardPage-qkyq1COW.js → DashboardPage-DmXHKAfY.js} +1 -1
- package/static/assets/{GitPage-Dj9uMiQV.js → GitPage-C-ZudM8s.js} +1 -1
- package/static/assets/{GitSettingsPage--hjPt4zu.js → GitSettingsPage-DtvqZDAp.js} +1 -1
- package/static/assets/{IdentityPage-DzqrsAU2.js → IdentityPage-WwVp_vBZ.js} +1 -1
- package/static/assets/{ImplementationStepsEditor-GxhD-g8y.js → ImplementationStepsEditor-BKDdpUue.js} +1 -1
- package/static/assets/{IntegrationsSettingsPage-DR_v_Fbo.js → IntegrationsSettingsPage-Vhh08Jjd.js} +1 -1
- package/static/assets/{KnowledgeDetailPage-BEHrLcNg.js → KnowledgeDetailPage-B8jlP-NF.js} +1 -1
- package/static/assets/{KnowledgeEditPage-CETMgdZf.js → KnowledgeEditPage-BppjRoZZ.js} +1 -1
- package/static/assets/{KnowledgePage-Dz2YIqdH.js → KnowledgePage-CasWW1a1.js} +1 -1
- package/static/assets/{LoginPage-DSxl4xGK.js → LoginPage-DkguuNDQ.js} +1 -1
- package/static/assets/{McpSettingsPage-CLDzqlt3.js → McpSettingsPage-CZfBLxIj.js} +1 -1
- package/static/assets/{NewAgentPage-DlEnBUUY.js → NewAgentPage-BbANsmjr.js} +1 -1
- package/static/assets/{NewKnowledgePage-CI8D1NRB.js → NewKnowledgePage-BE18vt4E.js} +1 -1
- package/static/assets/{NewProposalPage-B1hVwad9.js → NewProposalPage-BxKHijwN.js} +1 -1
- package/static/assets/{ProjectEditPage-t_oD7x6f.js → ProjectEditPage-uwwvFm_Y.js} +1 -1
- package/static/assets/{ProjectPage-CMez4KRO.js → ProjectPage-DJvT8Jwp.js} +1 -1
- package/static/assets/{PromptsSettingsPage-DXvS4JX8.js → PromptsSettingsPage-CWdSTKxS.js} +1 -1
- package/static/assets/{ProposalDetailPage-Cbld0UYO.js → ProposalDetailPage-CDyosWFj.js} +1 -1
- package/static/assets/{ProposalEditPage-Dujm4G1-.js → ProposalEditPage-D9b0X_vT.js} +1 -1
- package/static/assets/{ProposalsPage-0L4kWC5Y.js → ProposalsPage-DdfAejqH.js} +1 -1
- package/static/assets/ResourcesPage-DCJ-ob0_.js +71 -0
- package/static/assets/{RulesSettingsPage-D6qjkKbl.js → RulesSettingsPage-CrIrk78x.js} +1 -1
- package/static/assets/{SchedulePage-CgnTsib0.js → SchedulePage-Dq53Q6fB.js} +1 -1
- package/static/assets/{TagInput-DJMwLVTn.js → TagInput-DtQl22K7.js} +1 -1
- package/static/assets/{TerminalPage-EYVbapc9.js → TerminalPage-BcclpXIS.js} +1 -1
- package/static/assets/{TerminalSessionPage-CQCLFjOR.js → TerminalSessionPage-Tecaum7f.js} +1 -1
- package/static/assets/{UserPreferencesPage-KAsCdvFQ.js → UserPreferencesPage-B4jeTbEe.js} +1 -1
- package/static/assets/{UserSettingsPage-DclI2Mhd.js → UserSettingsPage-D_fTJGEB.js} +1 -1
- package/static/assets/{UtilitiesPage-BKdyva6y.js → UtilitiesPage-BVSfnezp.js} +1 -1
- package/static/assets/{alert-p2sQnjrU.js → alert-DT5dIcQb.js} +1 -1
- package/static/assets/{arrow-down-DGeJDsho.js → arrow-down-D5JMw0I7.js} +1 -1
- package/static/assets/{arrow-left-BRSAC1N6.js → arrow-left-BbL7bi4b.js} +1 -1
- package/static/assets/{arrow-up-C5ecpR5U.js → arrow-up-D5zdohVZ.js} +1 -1
- package/static/assets/{badge-DaM4gF82.js → badge-CxMDR-vz.js} +1 -1
- package/static/assets/{browser-modal-CyeEbzDK.js → browser-modal-DZprh22G.js} +1 -1
- package/static/assets/{calendar-CV2haPQ9.js → calendar-DjIpzqju.js} +1 -1
- package/static/assets/{card-B9ym6neB.js → card-Cq3qftln.js} +1 -1
- package/static/assets/{chevron-left-D8aMFTU2.js → chevron-left-8PdSXGp8.js} +1 -1
- package/static/assets/{circle-alert-C-piOZLm.js → circle-alert-CPeWHRYV.js} +1 -1
- package/static/assets/{circle-check-4zzXsmHH.js → circle-check-BsF5HxbR.js} +1 -1
- package/static/assets/{circle-check-big-AlE11jqb.js → circle-check-big-DViAc1A0.js} +1 -1
- package/static/assets/{circle-play-cWY3nlZW.js → circle-play-C0yQlVR9.js} +1 -1
- package/static/assets/{circle-x-D58MbKgZ.js → circle-x-CT_9xyVN.js} +1 -1
- package/static/assets/{clipboard-BFF6-pdC.js → clipboard-D-CHbLVc.js} +1 -1
- package/static/assets/{clock-B-uSJOTR.js → clock-D5nAa1In.js} +1 -1
- package/static/assets/{download-DrQn0jny.js → download-Bl3cP1zr.js} +1 -1
- package/static/assets/{eye-BcjteMts.js → eye-DgdIekU1.js} +1 -1
- package/static/assets/{folder-git-2-B_ezHf_E.js → folder-git-2-BD7LL99o.js} +1 -1
- package/static/assets/{index-B0JO3x3V.js → index-CKcm92Kn.js} +3 -3
- package/static/assets/index-D9b0oysW.css +2 -0
- package/static/assets/{label-BHOOQ99D.js → label-COUiN2Pd.js} +1 -1
- package/static/assets/{markdown-editor-B0i_LOAR.js → markdown-editor-Cln2Jo2-.js} +1 -1
- package/static/assets/{pause-DqQ7Twc6.js → pause-CupPWZ26.js} +1 -1
- package/static/assets/{play-Y2N8OVBu.js → play-sWUKmZEy.js} +1 -1
- package/static/assets/{plus-D737EJ5S.js → plus-DM62ve-p.js} +1 -1
- package/static/assets/{radio-group-nRRUTZ_w.js → radio-group-B6pYL4p4.js} +1 -1
- package/static/assets/{refresh-cw-uBnPtZwp.js → refresh-cw-ClU12bdt.js} +1 -1
- package/static/assets/{search-cntvIhnF.js → search-DHLiojAp.js} +1 -1
- package/static/assets/{switch-BYf9VEgx.js → switch-DC_em8xh.js} +1 -1
- package/static/assets/{tabs-BnsC3AY5.js → tabs-KzUqSzqd.js} +1 -1
- package/static/assets/{tag-C_HL28Xd.js → tag-cF4ktw0a.js} +1 -1
- package/static/assets/{terminal-preview-Qv4UvCJz.js → terminal-preview-D-pmjUNP.js} +1 -1
- package/static/assets/{use-terminal-5sW1t6SD.js → use-terminal-C1j4Pa5C.js} +1 -1
- package/static/assets/{zap-CrLPiVyl.js → zap-DGHMgsd8.js} +1 -1
- package/static/index.html +2 -2
- package/static/assets/ResourcesPage-5sZL01s_.js +0 -66
- package/static/assets/index-C8p-lTq9.css +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{H as Qe,ag as Xe,r as m,j as e,B as u,n as O,bg as pe,M as q,N as ge,T as fe,O as V,P as Y,Q as G,R as K,U as Q,V as X,W as Z,i as ee,h as ve,bh as Ze,C as es,q as ss,s as se,D as je,a as Ne,b as be,d as ye,e as we,I as te,v as ts,w as as,x as rs,y as ns,z as is,a5 as Se,a6 as Ce,a7 as ke,a8 as Ae,a9 as De,ae as Te,a0 as ls,ac as ds,$ as Ie,A as j}from"./index-B0JO3x3V.js";import{C as J,a as ae,c as re,b as Fe}from"./card-B9ym6neB.js";import{B as F}from"./badge-DaM4gF82.js";import{L as v}from"./label-BHOOQ99D.js";import{S as cs}from"./switch-BYf9VEgx.js";import{T as os,a as ms,b as ne,c as ie}from"./tabs-BnsC3AY5.js";import{R as us}from"./refresh-cw-uBnPtZwp.js";import{P as Pe}from"./plus-D737EJ5S.js";import{P as Me}from"./play-Y2N8OVBu.js";import{P as hs}from"./pause-DqQ7Twc6.js";import{C as xs}from"./clock-B-uSJOTR.js";const ce=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"}],ps=[{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"}],$e=["monday","tuesday","wednesday","thursday","friday"],Ee=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},H=a=>{if(!a)return"—";const x=new Date(a).getTime()-Date.now(),f=Math.round(x/(1e3*60));if(Number.isNaN(f))return Ee(a);if(Math.abs(f)<1)return"now";if(f>0){if(f<60)return`in ${f}m`;const b=Math.round(f/60);return b<24?`in ${b}h`:`in ${Math.round(b/24)}d`}const N=Math.abs(f);if(N<60)return`${N}m ago`;const I=Math.round(N/60);return I<24?`${I}h ago`:`${Math.round(I/24)}d ago`},gs=a=>{if(a.type==="interval"){const o=a.daysOfWeek.map(x=>x.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${o||"All days"})`}return a.description||`Cron: ${a.expression}`},fs=a=>{const o=ce.find(x=>x.id===a);return o?o.label:a},le=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}},de=()=>({name:"",model:"claude",prompt:"",hours:6,daysOfWeek:new Set($e),status:!0,anchorHour:"",agentIds:[],mcpServers:[]}),Re=a=>{if(a.schedule.type!=="interval")return de();const o=a.agentIds||(a.agentId?[a.agentId]:[]);return{name:a.name,model:ce.some(x=>x.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||[]}},vs=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 Is(){const{toast:a}=Qe(),{refresh:o}=Xe(),[x,f]=m.useState([]),[N,I]=m.useState(!0),[L,b]=m.useState(!1),[P,y]=m.useState(!1),[n,p]=m.useState(()=>de()),[z,oe]=m.useState(!1),[w,S]=m.useState(null),[c,C]=m.useState(null),[g,M]=m.useState(null),[Oe,R]=m.useState(!1),[$,Je]=m.useState([]),[W,He]=m.useState([]),[Le,ze]=m.useState(new Set),[B,U]=m.useState({open:!1,serverToRemove:null}),k=async(s=!1)=>{try{N||b(!0);const t=await fetch(`${j}/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(f(i),c){const l=i.find(d=>d.id===c.id);l&&(C(l),l.schedule.type!=="cron"&&p(Re(l)))}if(g){const l=i.find(d=>d.id===g.id);l&&M(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{I(!1),b(!1)}};m.useEffect(()=>{k()},[]),m.useEffect(()=>{P&&(async()=>{try{const t=await fetch(`${j}/api/v1/agents`);if(t.ok){const i=await t.json(),d=(Array.isArray(i?.documents)?i.documents:[]).map(h=>({id:h.filename,name:h?.metadata?.name||h.title||h.filename,tools:vs(h?.metadata?.tools)}));if(Je(d),c){const D=(c.agentIds||(c.agentId?[c.agentId]:[])).filter(T=>!d.find(_=>_.id===T));D.length>0&&(a({title:"Some agents no longer available",description:`The following agents have been removed: ${D.join(", ")}`,variant:"destructive"}),p(T=>({...T,agentIds:T.agentIds.filter(_=>d.find(Ke=>Ke.id===_))})))}}const r=await fetch(`${j}/api/v1/mcp`);if(r.ok){const i=await r.json();if(i?.success&&Array.isArray(i.servers)&&(He(i.servers),c?.mcpServers)){const l=c.mcpServers.filter(d=>!i.servers.includes(d));l.length>0&&(a({title:"Some MCP servers are no longer available",description:`The following servers have been removed: ${l.join(", ")}`,variant:"destructive"}),p(d=>({...d,mcpServers:d.mcpServers.filter(h=>i.servers.includes(h))})))}}}catch(t){console.error("Failed to load agents or MCP servers:",t)}})()},[P,c,a]);const A=s=>{p(t=>({...t,...s}))},We=(s,t)=>{p(r=>{let i;if(t){i=[...r.agentIds,s];const l=$.find(d=>d.id===s);if(l&&l.tools.length>0){const d=new Set([...r.mcpServers,...l.tools]);return{...r,agentIds:i,mcpServers:Array.from(d).filter(h=>W.includes(h))}}}else i=r.agentIds.filter(l=>l!==s);return{...r,agentIds:i}})},Be=(s,t)=>{if(!t&&$.filter(i=>n.agentIds.includes(i.id)&&i.tools.includes(s)).length>0){U({open:!0,serverToRemove:s});return}p(r=>({...r,mcpServers:t?[...r.mcpServers,s]:r.mcpServers.filter(i=>i!==s)}))},Ue=()=>{const s=B.serverToRemove;s&&p(t=>({...t,mcpServers:t.mcpServers.filter(r=>r!==s)})),U({open:!1,serverToRemove:null})},_e=(s,t)=>{p(r=>{const i=new Set(r.daysOfWeek);return t?i.add(s):i.delete(s),i.size===0&&$e.forEach(l=>i.add(l)),{...r,daysOfWeek:i}})},E=()=>{p(de())},me=s=>{ze(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},ue=s=>{M(s),R(!0)},he=()=>{C(null),E(),y(!0)},qe=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),p(Re(s)),y(!0)},Ve=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}oe(!0);const t=!!c;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},d=t?`${j}/api/v1/jobs/${c?.id}`:`${j}/api/v1/jobs`,D=await fetch(d,{method:t?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!D.ok){const T=await D.json().catch(()=>({}));throw new Error(T?.error?.message||`Failed to ${t?"update":"create"} job (${D.status})`)}a({title:t?"Scheduled job updated":"Scheduled job created",description:l.name}),y(!1),C(null),E(),await k()}catch(r){console.error("Failed to submit job:",r),a({title:`Failed to ${c?"update":"create"} job`,description:r?.message??"Unknown error",variant:"destructive"})}finally{oe(!1)}},Ye=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}S(s.id);try{const t=await fetch(`${j}/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 k(),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{S(null)}},Ge=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}S(s.id);const t=s.status==="active"?"paused":"active";try{const r=await fetch(`${j}/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 k(),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{S(null)}},xe=async s=>{S(s.id);try{const t=await fetch(`${j}/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}),c?.id===s.id&&(y(!1),C(null),E()),g?.id===s.id&&(R(!1),M(null)),await k()}catch(t){console.error("Failed to delete job:",t),a({title:"Failed to delete job",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(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:"Schedule"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automate recurring agent runs with prompts, preferred models, and guardrails."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(u,{variant:"outline",onClick:()=>k(!0),disabled:N||L,children:[L?e.jsx(O,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(us,{className:"mr-2 h-4 w-4"}),"Refresh"]}),e.jsxs(u,{onClick:he,children:[e.jsx(Pe,{className:"mr-2 h-4 w-4"}),"New Scheduled Job"]})]})]}),N?e.jsx(J,{children:e.jsxs(ae,{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(O,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading scheduled jobs..."]})}):x.length===0?e.jsx(J,{className:"border-dashed",children:e.jsxs(ae,{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(pe,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx(re,{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 by scheduling an agent to run on your behalf. 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 agent 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(u,{onClick:he,className:"mt-8",size:"lg",children:[e.jsx(Pe,{className:"mr-2 h-5 w-5"}),"Create Your First Job"]})]})}):e.jsx("div",{className:"grid gap-4",children:x.map(s=>s._error?e.jsx(J,{className:"border-destructive/50 bg-destructive/5",children:e.jsx(Fe,{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(re,{className:"text-lg truncate text-destructive",children:["Unable to load job: ",s.id]}),e.jsx(F,{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(q,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete corrupted job?"}),e.jsxs(K,{children:["This will remove the corrupted job file ",e.jsx("strong",{children:s.id}),". This action cannot be undone."]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})})]})})},s.id):e.jsxs(J,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all hover:shadow-lg",children:[e.jsx(Fe,{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(re,{className:"text-lg truncate",children:s.name}),e.jsx(F,{variant:le(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(u,{size:"sm",variant:"default",onClick:()=>Ye(s),disabled:w===s.id,className:"h-8 px-3",children:w===s.id?e.jsx(O,{className:"h-3.5 w-3.5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"mr-1.5 h-3.5 w-3.5"}),"Run"]})}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>qe(s),disabled:w===s.id,className:"h-8 px-3 text-xs",children:"Edit"}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ge(s),disabled:w===s.id,className:"h-8 px-2",children:s.status==="active"?e.jsx(hs,{className:"h-3.5 w-3.5"}):e.jsx(Me,{className:"h-3.5 w-3.5"})}),e.jsxs(q,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete scheduled job?"}),e.jsxs(K,{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(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})}),e.jsxs(ae,{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(xs,{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:gs(s.schedule)})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(ee,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"font-semibold",children:fs(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:H(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:H(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(ee,{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(ve,{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(Ze,{className:"h-3 w-3"}),"Recent Runs"]}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ue(s),children:["View All (",s.runs.length,")",e.jsx(es,{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,1).map(t=>{const r=Le.has(t.id);return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden transition-all",children:[e.jsxs("div",{className:"p-2.5 text-xs hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>me(t.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(F,{variant:le(t.status),className:"capitalize text-[10px] h-5",children:t.status}),e.jsx("span",{className:"text-muted-foreground truncate",children:H(t.startedAt)})]}),t.trigger==="manual"&&e.jsx(F,{variant:"outline",className:"text-[10px] h-5",children:"manual"})]}),t.error&&e.jsx("p",{className:"text-destructive font-medium mt-1 line-clamp-1",children:t.error})]}),t.summary&&e.jsx("div",{className:"px-2.5 pb-2.5",children:e.jsxs("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground relative cursor-pointer hover:bg-muted/70 transition-colors",onClick:i=>{i.stopPropagation(),me(t.id)},children:[e.jsx("div",{className:r?"":"line-clamp-2",children:t.summary}),e.jsx("div",{className:"flex justify-center mt-1",children:e.jsx("div",{className:"text-muted-foreground p-0.5",children:r?e.jsx(ss,{className:"h-3 w-3"}):e.jsx(se,{className:"h-3 w-3"})})})]})})]},t.id)}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>ue(s),children:["+",s.runs.length-1," more runs"]})]})]})]})]},s.id))}),e.jsx(je,{open:P,onOpenChange:s=>{y(s),s||(C(null),E())},children:e.jsxs(Ne,{className:"max-w-4xl h-[700px] overflow-hidden flex flex-col",children:[e.jsxs(be,{className:"space-y-2 pb-4 shrink-0",children:[e.jsxs(ye,{className:"text-xl flex items-center gap-2",children:[e.jsx(pe,{className:"h-5 w-5 text-primary"}),c?"Edit Scheduled Job":"Create New Scheduled Job"]}),e.jsx(we,{className:"text-sm",children:c?"Update the prompt, cadence, or agent preference":"Automate recurring tasks by scheduling an agent"})]}),e.jsxs("form",{onSubmit:Ve,className:"flex flex-col flex-1 min-h-0",children:[e.jsxs(os,{defaultValue:"basics",className:"flex-1 flex flex-col min-h-0",children:[e.jsxs(ms,{className:"grid w-full grid-cols-3 mb-4 shrink-0",children:[e.jsx(ne,{value:"basics",children:"Basics"}),e.jsx(ne,{value:"schedule",children:"Schedule"}),e.jsx(ne,{value:"advanced",children:"Advanced"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto pr-2 -mr-2 min-h-0",children:[e.jsxs(ie,{value:"basics",className:"space-y-5 mt-0",children:[e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{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(te,{id:"job-name",placeholder:"e.g., Publish docs nightly",value:n.name,onChange:s=>A({name:s.target.value}),className:"h-11",required:!0})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-model",className:"text-sm font-medium",children:"AI Model"}),e.jsxs(ts,{value:n.model,onValueChange:s=>A({model:s}),children:[e.jsx(as,{id:"job-model",className:"h-11",children:e.jsx(rs,{placeholder:"Select a model"})}),e.jsx(ns,{children:ce.map(s=>e.jsx(is,{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(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ee,{className:"h-4 w-4"}),"Custom Agent",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(Se,{children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.agentIds.length===0?"No agents selected":`${n.agentIds.length} agent${n.agentIds.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(ke,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(Ae,{children:"Available Agents"}),e.jsx(De,{}),$.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No agents configured"}):$.map(s=>e.jsx(Te,{checked:n.agentIds.includes(s.id),onCheckedChange:t=>We(s.id,t),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:s.name}),s.tools.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP: ",s.tools.join(", ")]})]})},s.id))]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ve,{className:"h-4 w-4"}),"MCP Servers",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(Se,{children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(u,{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(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(ke,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(Ae,{children:"Available MCP Servers"}),e.jsx(De,{}),W.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No MCP servers configured"}):W.map(s=>e.jsx(Te,{checked:n.mcpServers.includes(s),onCheckedChange:t=>Be(s,t),children:s},s))]})]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{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(ls,{id:"job-prompt",placeholder:n.agentIds.length>0?`Additional instructions to supplement the agent's predefined behavior...
|
|
1
|
+
import{H as Qe,ag as Xe,r as m,j as e,B as u,n as O,bg as pe,M as q,N as ge,T as fe,O as V,P as Y,Q as G,R as K,U as Q,V as X,W as Z,i as ee,h as ve,bh as Ze,C as es,q as ss,s as se,D as je,a as Ne,b as be,d as ye,e as we,I as te,v as ts,w as as,x as rs,y as ns,z as is,a5 as Se,a6 as Ce,a7 as ke,a8 as Ae,a9 as De,ae as Te,a0 as ls,ac as ds,$ as Ie,A as j}from"./index-CKcm92Kn.js";import{C as J,a as ae,c as re,b as Fe}from"./card-Cq3qftln.js";import{B as F}from"./badge-CxMDR-vz.js";import{L as v}from"./label-COUiN2Pd.js";import{S as cs}from"./switch-DC_em8xh.js";import{T as os,a as ms,b as ne,c as ie}from"./tabs-KzUqSzqd.js";import{R as us}from"./refresh-cw-ClU12bdt.js";import{P as Pe}from"./plus-DM62ve-p.js";import{P as Me}from"./play-sWUKmZEy.js";import{P as hs}from"./pause-CupPWZ26.js";import{C as xs}from"./clock-D5nAa1In.js";const ce=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"}],ps=[{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"}],$e=["monday","tuesday","wednesday","thursday","friday"],Ee=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},H=a=>{if(!a)return"—";const x=new Date(a).getTime()-Date.now(),f=Math.round(x/(1e3*60));if(Number.isNaN(f))return Ee(a);if(Math.abs(f)<1)return"now";if(f>0){if(f<60)return`in ${f}m`;const b=Math.round(f/60);return b<24?`in ${b}h`:`in ${Math.round(b/24)}d`}const N=Math.abs(f);if(N<60)return`${N}m ago`;const I=Math.round(N/60);return I<24?`${I}h ago`:`${Math.round(I/24)}d ago`},gs=a=>{if(a.type==="interval"){const o=a.daysOfWeek.map(x=>x.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${o||"All days"})`}return a.description||`Cron: ${a.expression}`},fs=a=>{const o=ce.find(x=>x.id===a);return o?o.label:a},le=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}},de=()=>({name:"",model:"claude",prompt:"",hours:6,daysOfWeek:new Set($e),status:!0,anchorHour:"",agentIds:[],mcpServers:[]}),Re=a=>{if(a.schedule.type!=="interval")return de();const o=a.agentIds||(a.agentId?[a.agentId]:[]);return{name:a.name,model:ce.some(x=>x.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||[]}},vs=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 Is(){const{toast:a}=Qe(),{refresh:o}=Xe(),[x,f]=m.useState([]),[N,I]=m.useState(!0),[L,b]=m.useState(!1),[P,y]=m.useState(!1),[n,p]=m.useState(()=>de()),[z,oe]=m.useState(!1),[w,S]=m.useState(null),[c,C]=m.useState(null),[g,M]=m.useState(null),[Oe,R]=m.useState(!1),[$,Je]=m.useState([]),[W,He]=m.useState([]),[Le,ze]=m.useState(new Set),[B,U]=m.useState({open:!1,serverToRemove:null}),k=async(s=!1)=>{try{N||b(!0);const t=await fetch(`${j}/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(f(i),c){const l=i.find(d=>d.id===c.id);l&&(C(l),l.schedule.type!=="cron"&&p(Re(l)))}if(g){const l=i.find(d=>d.id===g.id);l&&M(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{I(!1),b(!1)}};m.useEffect(()=>{k()},[]),m.useEffect(()=>{P&&(async()=>{try{const t=await fetch(`${j}/api/v1/agents`);if(t.ok){const i=await t.json(),d=(Array.isArray(i?.documents)?i.documents:[]).map(h=>({id:h.filename,name:h?.metadata?.name||h.title||h.filename,tools:vs(h?.metadata?.tools)}));if(Je(d),c){const D=(c.agentIds||(c.agentId?[c.agentId]:[])).filter(T=>!d.find(_=>_.id===T));D.length>0&&(a({title:"Some agents no longer available",description:`The following agents have been removed: ${D.join(", ")}`,variant:"destructive"}),p(T=>({...T,agentIds:T.agentIds.filter(_=>d.find(Ke=>Ke.id===_))})))}}const r=await fetch(`${j}/api/v1/mcp`);if(r.ok){const i=await r.json();if(i?.success&&Array.isArray(i.servers)&&(He(i.servers),c?.mcpServers)){const l=c.mcpServers.filter(d=>!i.servers.includes(d));l.length>0&&(a({title:"Some MCP servers are no longer available",description:`The following servers have been removed: ${l.join(", ")}`,variant:"destructive"}),p(d=>({...d,mcpServers:d.mcpServers.filter(h=>i.servers.includes(h))})))}}}catch(t){console.error("Failed to load agents or MCP servers:",t)}})()},[P,c,a]);const A=s=>{p(t=>({...t,...s}))},We=(s,t)=>{p(r=>{let i;if(t){i=[...r.agentIds,s];const l=$.find(d=>d.id===s);if(l&&l.tools.length>0){const d=new Set([...r.mcpServers,...l.tools]);return{...r,agentIds:i,mcpServers:Array.from(d).filter(h=>W.includes(h))}}}else i=r.agentIds.filter(l=>l!==s);return{...r,agentIds:i}})},Be=(s,t)=>{if(!t&&$.filter(i=>n.agentIds.includes(i.id)&&i.tools.includes(s)).length>0){U({open:!0,serverToRemove:s});return}p(r=>({...r,mcpServers:t?[...r.mcpServers,s]:r.mcpServers.filter(i=>i!==s)}))},Ue=()=>{const s=B.serverToRemove;s&&p(t=>({...t,mcpServers:t.mcpServers.filter(r=>r!==s)})),U({open:!1,serverToRemove:null})},_e=(s,t)=>{p(r=>{const i=new Set(r.daysOfWeek);return t?i.add(s):i.delete(s),i.size===0&&$e.forEach(l=>i.add(l)),{...r,daysOfWeek:i}})},E=()=>{p(de())},me=s=>{ze(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},ue=s=>{M(s),R(!0)},he=()=>{C(null),E(),y(!0)},qe=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),p(Re(s)),y(!0)},Ve=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}oe(!0);const t=!!c;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},d=t?`${j}/api/v1/jobs/${c?.id}`:`${j}/api/v1/jobs`,D=await fetch(d,{method:t?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!D.ok){const T=await D.json().catch(()=>({}));throw new Error(T?.error?.message||`Failed to ${t?"update":"create"} job (${D.status})`)}a({title:t?"Scheduled job updated":"Scheduled job created",description:l.name}),y(!1),C(null),E(),await k()}catch(r){console.error("Failed to submit job:",r),a({title:`Failed to ${c?"update":"create"} job`,description:r?.message??"Unknown error",variant:"destructive"})}finally{oe(!1)}},Ye=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}S(s.id);try{const t=await fetch(`${j}/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 k(),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{S(null)}},Ge=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}S(s.id);const t=s.status==="active"?"paused":"active";try{const r=await fetch(`${j}/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 k(),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{S(null)}},xe=async s=>{S(s.id);try{const t=await fetch(`${j}/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}),c?.id===s.id&&(y(!1),C(null),E()),g?.id===s.id&&(R(!1),M(null)),await k()}catch(t){console.error("Failed to delete job:",t),a({title:"Failed to delete job",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(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:"Schedule"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automate recurring agent runs with prompts, preferred models, and guardrails."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(u,{variant:"outline",onClick:()=>k(!0),disabled:N||L,children:[L?e.jsx(O,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(us,{className:"mr-2 h-4 w-4"}),"Refresh"]}),e.jsxs(u,{onClick:he,children:[e.jsx(Pe,{className:"mr-2 h-4 w-4"}),"New Scheduled Job"]})]})]}),N?e.jsx(J,{children:e.jsxs(ae,{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(O,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading scheduled jobs..."]})}):x.length===0?e.jsx(J,{className:"border-dashed",children:e.jsxs(ae,{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(pe,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx(re,{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 by scheduling an agent to run on your behalf. 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 agent 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(u,{onClick:he,className:"mt-8",size:"lg",children:[e.jsx(Pe,{className:"mr-2 h-5 w-5"}),"Create Your First Job"]})]})}):e.jsx("div",{className:"grid gap-4",children:x.map(s=>s._error?e.jsx(J,{className:"border-destructive/50 bg-destructive/5",children:e.jsx(Fe,{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(re,{className:"text-lg truncate text-destructive",children:["Unable to load job: ",s.id]}),e.jsx(F,{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(q,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete corrupted job?"}),e.jsxs(K,{children:["This will remove the corrupted job file ",e.jsx("strong",{children:s.id}),". This action cannot be undone."]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})})]})})},s.id):e.jsxs(J,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all hover:shadow-lg",children:[e.jsx(Fe,{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(re,{className:"text-lg truncate",children:s.name}),e.jsx(F,{variant:le(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(u,{size:"sm",variant:"default",onClick:()=>Ye(s),disabled:w===s.id,className:"h-8 px-3",children:w===s.id?e.jsx(O,{className:"h-3.5 w-3.5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"mr-1.5 h-3.5 w-3.5"}),"Run"]})}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>qe(s),disabled:w===s.id,className:"h-8 px-3 text-xs",children:"Edit"}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ge(s),disabled:w===s.id,className:"h-8 px-2",children:s.status==="active"?e.jsx(hs,{className:"h-3.5 w-3.5"}):e.jsx(Me,{className:"h-3.5 w-3.5"})}),e.jsxs(q,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete scheduled job?"}),e.jsxs(K,{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(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})}),e.jsxs(ae,{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(xs,{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:gs(s.schedule)})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(ee,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"font-semibold",children:fs(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:H(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:H(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(ee,{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(ve,{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(Ze,{className:"h-3 w-3"}),"Recent Runs"]}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ue(s),children:["View All (",s.runs.length,")",e.jsx(es,{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,1).map(t=>{const r=Le.has(t.id);return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden transition-all",children:[e.jsxs("div",{className:"p-2.5 text-xs hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>me(t.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(F,{variant:le(t.status),className:"capitalize text-[10px] h-5",children:t.status}),e.jsx("span",{className:"text-muted-foreground truncate",children:H(t.startedAt)})]}),t.trigger==="manual"&&e.jsx(F,{variant:"outline",className:"text-[10px] h-5",children:"manual"})]}),t.error&&e.jsx("p",{className:"text-destructive font-medium mt-1 line-clamp-1",children:t.error})]}),t.summary&&e.jsx("div",{className:"px-2.5 pb-2.5",children:e.jsxs("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground relative cursor-pointer hover:bg-muted/70 transition-colors",onClick:i=>{i.stopPropagation(),me(t.id)},children:[e.jsx("div",{className:r?"":"line-clamp-2",children:t.summary}),e.jsx("div",{className:"flex justify-center mt-1",children:e.jsx("div",{className:"text-muted-foreground p-0.5",children:r?e.jsx(ss,{className:"h-3 w-3"}):e.jsx(se,{className:"h-3 w-3"})})})]})})]},t.id)}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>ue(s),children:["+",s.runs.length-1," more runs"]})]})]})]})]},s.id))}),e.jsx(je,{open:P,onOpenChange:s=>{y(s),s||(C(null),E())},children:e.jsxs(Ne,{className:"max-w-4xl h-[700px] overflow-hidden flex flex-col",children:[e.jsxs(be,{className:"space-y-2 pb-4 shrink-0",children:[e.jsxs(ye,{className:"text-xl flex items-center gap-2",children:[e.jsx(pe,{className:"h-5 w-5 text-primary"}),c?"Edit Scheduled Job":"Create New Scheduled Job"]}),e.jsx(we,{className:"text-sm",children:c?"Update the prompt, cadence, or agent preference":"Automate recurring tasks by scheduling an agent"})]}),e.jsxs("form",{onSubmit:Ve,className:"flex flex-col flex-1 min-h-0",children:[e.jsxs(os,{defaultValue:"basics",className:"flex-1 flex flex-col min-h-0",children:[e.jsxs(ms,{className:"grid w-full grid-cols-3 mb-4 shrink-0",children:[e.jsx(ne,{value:"basics",children:"Basics"}),e.jsx(ne,{value:"schedule",children:"Schedule"}),e.jsx(ne,{value:"advanced",children:"Advanced"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto pr-2 -mr-2 min-h-0",children:[e.jsxs(ie,{value:"basics",className:"space-y-5 mt-0",children:[e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{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(te,{id:"job-name",placeholder:"e.g., Publish docs nightly",value:n.name,onChange:s=>A({name:s.target.value}),className:"h-11",required:!0})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-model",className:"text-sm font-medium",children:"AI Model"}),e.jsxs(ts,{value:n.model,onValueChange:s=>A({model:s}),children:[e.jsx(as,{id:"job-model",className:"h-11",children:e.jsx(rs,{placeholder:"Select a model"})}),e.jsx(ns,{children:ce.map(s=>e.jsx(is,{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(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ee,{className:"h-4 w-4"}),"Custom Agent",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(Se,{children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.agentIds.length===0?"No agents selected":`${n.agentIds.length} agent${n.agentIds.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(ke,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(Ae,{children:"Available Agents"}),e.jsx(De,{}),$.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No agents configured"}):$.map(s=>e.jsx(Te,{checked:n.agentIds.includes(s.id),onCheckedChange:t=>We(s.id,t),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:s.name}),s.tools.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP: ",s.tools.join(", ")]})]})},s.id))]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ve,{className:"h-4 w-4"}),"MCP Servers",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(Se,{children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(u,{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(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(ke,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(Ae,{children:"Available MCP Servers"}),e.jsx(De,{}),W.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No MCP servers configured"}):W.map(s=>e.jsx(Te,{checked:n.mcpServers.includes(s),onCheckedChange:t=>Be(s,t),children:s},s))]})]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{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(ls,{id:"job-prompt",placeholder:n.agentIds.length>0?`Additional instructions to supplement the agent's predefined behavior...
|
|
2
2
|
Example: Focus on performance optimizations`:`Example:
|
|
3
3
|
Run the following command and append the output to .nut/context/knowledge/runs.md:
|
|
4
4
|
pnpm docs:publish`,rows:6,value:n.prompt,onChange:s=>A({prompt:s.target.value}),className:"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 agents' predefined instructions. Jobs run with autonomous permissions.":"Provide clear, actionable instructions. Jobs run with autonomous permissions - include safety checks where needed."})]})]})]}),e.jsx(ie,{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(v,{className:"text-sm font-medium",children:"Days of the Week"}),e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:ps.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(ds,{checked:n.daysOfWeek.has(s.value),onCheckedChange:t=>_e(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(v,{htmlFor:"job-hours",className:"text-sm font-medium",children:"Frequency (hours)"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{id:"job-hours",type:"number",min:1,value:n.hours,onChange:s=>A({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(v,{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(te,{id:"job-anchor",type:"number",min:0,max:23,placeholder:"Auto",value:n.anchorHour,onChange:s=>A({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(ie,{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(cs,{id:"job-status",checked:n.status,onCheckedChange:s=>A({status:s}),className:"mt-1"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(v,{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(Ie,{className:"gap-2 sm:gap-2 pt-4 border-t mt-4",children:[e.jsx(u,{type:"button",variant:"outline",onClick:()=>y(!1),disabled:z,className:"min-w-24",children:"Cancel"}),e.jsx(u,{type:"submit",disabled:z||!n.name.trim()||!n.prompt.trim(),className:"min-w-32",children:z?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"mr-2 h-4 w-4 animate-spin"}),c?"Saving...":"Creating..."]}):e.jsx(e.Fragment,{children:c?"Save Changes":"Create Job"})})]})]})]})}),e.jsx(je,{open:Oe,onOpenChange:s=>{R(s),s||M(null)},children:e.jsxs(Ne,{className:"max-w-3xl",children:[e.jsxs(be,{children:[e.jsxs(ye,{children:["Run history — ",g?.name]}),e.jsxs(we,{children:[g?.runs?.length??0," recorded runs. Logs stored in ",e.jsxs("code",{children:[".nut/jobs/",g?.id,".md"]})," and ",e.jsxs("code",{children:[".nut/jobs/logs/",g?.id]}),"."]})]}),e.jsxs("div",{className:"max-h-[420px] space-y-3 overflow-y-auto pr-2",children:[g?.runs.map(s=>e.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[e.jsxs("div",{className:"p-3 text-xs bg-card/50",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx(F,{variant:le(s.status),className:"capitalize text-[10px] h-5",children:s.status}),e.jsxs("span",{className:"text-muted-foreground",children:[s.trigger," • ",Ee(s.startedAt)]}),s.finishedAt&&e.jsxs("span",{className:"text-muted-foreground",children:["• completed ",H(s.finishedAt)]})]}),s.error&&e.jsx("p",{className:"text-destructive font-medium mb-2",children:s.error}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-[10px] text-muted-foreground",children:[s.outputPath&&e.jsxs("span",{children:["log: ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:s.outputPath})]}),s.cliCommand&&e.jsxs("span",{children:["cmd: ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:s.cliCommand})]})]})]}),s.summary&&e.jsx("div",{className:"px-3 pb-3",children:e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground whitespace-pre-wrap",children:s.summary})})]},s.id)),g&&g.runs.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No recorded runs yet."})]}),e.jsx(Ie,{children:e.jsx(u,{variant:"outline",onClick:()=>R(!1),children:"Close"})})]})}),e.jsx(q,{open:B.open,onOpenChange:s=>{s||U({open:!1,serverToRemove:null})},children:e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Remove MCP Server?"}),e.jsxs(K,{children:["One or more selected agents require the ",e.jsx("strong",{children:B.serverToRemove})," MCP server. Removing it may lead to unexpected consequences when the job runs."]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:Ue,children:"OK"})]})]})})]})}export{Is as default};
|
|
@@ -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-CKcm92Kn.js";import{B as f}from"./badge-CxMDR-vz.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 +1 @@
|
|
|
1
|
-
import{u as U,H as J,r as i,j as e,B as r,a3 as S,q as K,s as L,X as q,n as H,a4 as G}from"./index-
|
|
1
|
+
import{u as U,H as J,r as i,j as e,B as r,a3 as S,q as K,s as L,X as q,n as H,a4 as G}from"./index-CKcm92Kn.js";import{C as f,a as W}from"./card-Cq3qftln.js";import{u as X}from"./use-terminal-C1j4Pa5C.js";import{C as _,a as Q,T as V}from"./terminal-preview-D-pmjUNP.js";import{R as Y}from"./refresh-cw-ClU12bdt.js";import{P as M}from"./play-sWUKmZEy.js";import{C as Z}from"./circle-play-C0yQlVR9.js";import"./xterm-DTxiCjtJ.js";function oe(){const m=U(),{sessions:p,loading:o,error:k,refreshSessions:h,createSession:j,destroySession:B}=X(),{toast:l}=J(),[x,u]=i.useState(""),[g,I]=i.useState(!1),[v,T]=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 C=Math.floor(b/60);return C<24?`${C}h ago`:`${Math.floor(C/24)}d ago`};i.useEffect(()=>{h()},[h]),i.useEffect(()=>{y(s=>{const t={...s};return p.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[p]),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=p.filter(s=>!s.proposalId?.startsWith("cp-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[d,y]=i.useState(()=>{const s={};return p.forEach(t=>{s[t.id]=!0}),s}),R=async()=>{const s=`session-${Date.now()}`;await j(s,!1)&&(l({title:"New terminal started",description:`${s}`}),m(`/terminal/${s}`))},E=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;I(!0);try{await j(t,!1,s)?(D(s),l({title:"Session started",description:`${t}`}),m(`/terminal/${t}`)):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{I(!1)}},A=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;T(!0);try{await j(t,!1,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{T(!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=>d[a.id]),t={};c.forEach(a=>{t[a.id]=!s}),y(t)},z=c.length>0&&c.every(s=>d[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:o,children:[e.jsx(Y,{className:`h-4 w-4 sm:mr-2 ${o?"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(_,{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(Q,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{onClick:R,disabled:o,children:[e.jsx(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"New Terminal"})]})]})]}),k&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:k})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),o?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(f,{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(f,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(S,{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(f,{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(S,{className:"h-4 w-4"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.proposalId}),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":d[s.id]?"Hide preview":"Show preview",title:d[s.id]?"Hide preview":"Show preview",children:d[s.id]?e.jsx(K,{className:"h-4 w-4"}):e.jsx(L,{className:"h-4 w-4"})}),e.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(`/terminal/${s.proposalId}`),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(q,{className:"h-4 w-4"})})]})]}),d[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>m(`/terminal/${s.proposalId}`),title:"Click to open full terminal session",children:e.jsx(V,{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(f,{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:o||!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:o||!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{oe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Ge,j as e,B as C,a5 as Ee,a6 as Le,a7 as Pe,a8 as We,a9 as Me,aa as Ze,p as oe,r as n,ab as Ye,E as Ke,l as Xe,u as Qe,H as et,k as ue,a3 as je,ac as Be,v as ye,w as ve,x as we,y as Ne,z as H,X as Oe,ad as tt,i as _e,h as Ie,s as ke,D as rt,a as st,b as nt,d as at,ae as ze,A as ce}from"./index-
|
|
1
|
+
import{c as Ge,j as e,B as C,a5 as Ee,a6 as Le,a7 as Pe,a8 as We,a9 as Me,aa as Ze,p as oe,r as n,ab as Ye,E as Ke,l as Xe,u as Qe,H as et,k as ue,a3 as je,ac as Be,v as ye,w as ve,x as we,y as Ne,z as H,X as Oe,ad as tt,i as _e,h as Ie,s as ke,D as rt,a as st,b as nt,d as at,ae as ze,A as ce}from"./index-CKcm92Kn.js";import{C as it,a as ot}from"./card-Cq3qftln.js";import{B as De}from"./badge-CxMDR-vz.js";import{R as ct,a as Ce}from"./radio-group-B6pYL4p4.js";import{C as lt}from"./CollapsibleSection-DSatk0YZ.js";import{L as he}from"./label-COUiN2Pd.js";import{u as dt}from"./use-terminal-C1j4Pa5C.js";import{x as mt,a as ut}from"./xterm-DTxiCjtJ.js";import{A as ht}from"./arrow-down-D5JMw0I7.js";import{b as Fe,a as xt,c as gt,d as ft}from"./droid-CmYuCN_q.js";import{R as pt}from"./refresh-cw-ClU12bdt.js";import{P as Se}from"./play-sWUKmZEy.js";import{P as Ae}from"./plus-DM62ve-p.js";import{Z as bt}from"./zap-DGHMgsd8.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{r as n,H as k,b2 as N,A as g,j as e,a1 as P,v as h,w as u,x as m,y as f,z as a,I as b,B as y}from"./index-
|
|
1
|
+
import{r as n,H as k,b2 as N,A as g,j as e,a1 as P,v as h,w as u,x as m,y as f,z as a,I as b,B as y}from"./index-CKcm92Kn.js";import{C as w,b as F,c as T,d as L,a as D}from"./card-Cq3qftln.js";import{L as o}from"./label-COUiN2Pd.js";const r={theme:"coconut",defaultEditor:"cursor",terminalShell:"bash",autoSaveInterval:60,notifications:{email:!1,desktop:!1,slack:!1}};function V(s){return{theme:s?.theme??r.theme,defaultEditor:s?.defaultEditor??r.defaultEditor,terminalShell:s?.terminalShell??r.terminalShell,autoSaveInterval:s?.autoSaveInterval??r.autoSaveInterval,notifications:{email:s?.notifications?.email??r.notifications.email,desktop:s?.notifications?.desktop??r.notifications.desktop,slack:s?.notifications?.slack??r.notifications.slack}}}function B(){const[s,v]=n.useState(r),[C,E]=n.useState(!0),[c,x]=n.useState(!1),{toast:d}=k(),{theme:j,setTheme:p}=N();n.useEffect(()=>{S()},[]),n.useEffect(()=>{s.theme!==j&&p(s.theme)},[s.theme,j,p]);const S=async()=>{try{const l=await(await fetch(`${g}/api/v1/user/settings`)).json();l.success&&v(V(l.data.preferences))}catch(t){console.error("Failed to load preferences:",t),d({title:"Error",description:"Failed to load user preferences",variant:"destructive"})}finally{E(!1)}},I=async()=>{x(!0);try{const l=await(await fetch(`${g}/api/v1/user/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({preferences:s})})).json();if(l.success)d({title:"Preferences saved",description:"Your personal preferences have been updated."});else throw new Error(l.error)}catch(t){console.error("Failed to save preferences:",t),d({title:"Error",description:"Failed to save preferences",variant:"destructive"})}finally{x(!1)}},i=t=>{v(l=>({...l,...t,notifications:{...l.notifications,...t.notifications}}))};return C?e.jsx("div",{children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"User Preferences"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure defaults for editors, shells, themes, and notifications."})]}),e.jsx(P,{}),e.jsxs(w,{children:[e.jsxs(F,{children:[e.jsx(T,{children:"Workspace Defaults"}),e.jsx(L,{children:"Set the defaults Coconut uses when creating sessions and surfaces."})]}),e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"theme",children:"Theme"}),e.jsxs(h,{value:s.theme,onValueChange:t=>i({theme:t}),children:[e.jsx(u,{id:"theme",children:e.jsx(m,{placeholder:"Select theme"})}),e.jsxs(f,{children:[e.jsx(a,{value:"coconut",children:"Coconut"}),e.jsx(a,{value:"system",children:"System"}),e.jsx(a,{value:"light",children:"Light"}),e.jsx(a,{value:"dark",children:"Dark"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"System follows your OS preference. Coconut is the default branded theme."})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"defaultEditor",children:"Default Editor"}),e.jsxs(h,{value:s.defaultEditor,onValueChange:t=>i({defaultEditor:t}),children:[e.jsx(u,{id:"defaultEditor",children:e.jsx(m,{placeholder:"Select editor"})}),e.jsxs(f,{children:[e.jsx(a,{value:"cursor",children:"Cursor"}),e.jsx(a,{value:"vscode",children:"VS Code"}),e.jsx(a,{value:"vim",children:"Vim"}),e.jsx(a,{value:"emacs",children:"Emacs"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"terminalShell",children:"Preferred Shell"}),e.jsxs(h,{value:s.terminalShell,onValueChange:t=>i({terminalShell:t}),children:[e.jsx(u,{id:"terminalShell",children:e.jsx(m,{placeholder:"Select shell"})}),e.jsxs(f,{children:[e.jsx(a,{value:"bash",children:"Bash"}),e.jsx(a,{value:"zsh",children:"Zsh"}),e.jsx(a,{value:"fish",children:"Fish"}),e.jsx(a,{value:"sh",children:"sh"}),e.jsx(a,{value:"system",children:"System Default"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"autoSaveInterval",children:"Auto-save Interval (seconds)"}),e.jsx(b,{id:"autoSaveInterval",type:"number",min:10,max:600,value:s.autoSaveInterval,onChange:t=>i({autoSaveInterval:Number.parseInt(t.target.value,10)||r.autoSaveInterval})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Controls how often Coconut persists draft work to disk."})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"outline",onClick:S,disabled:c,children:"Reset"}),e.jsx(y,{onClick:I,disabled:c,children:c?"Saving...":"Save Preferences"})]})]})}export{B as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,H as I,A as S,j as e,a1 as D,B as g,I as p,v as F,w as P,x as z,y as L,z as A,L as R}from"./index-
|
|
1
|
+
import{r as a,H as I,A as S,j as e,a1 as D,B as g,I as p,v as F,w as P,x as z,y as L,z as A,L as R}from"./index-CKcm92Kn.js";import{C as q,b as T,c as M,d as O,a as U}from"./card-Cq3qftln.js";import{L as c}from"./label-COUiN2Pd.js";import{C as B,a as H}from"./clipboard-D-CHbLVc.js";const m=[{id:"software-engineer",title:"Software Engineer",description:"Builds, refactors, and reviews high-quality code across stacks. Excellent at translating specs into implementation and optimizing system performance. Strong at debugging, architecture patterns, and accelerating development velocity."},{id:"product-strategist",title:"Product Strategist",description:"Defines product direction, clarifies requirements, and aligns work with user and business goals. Skilled in roadmap planning, prioritization, and transforming ambiguous ideas into actionable plans."},{id:"researcher",title:"Researcher",description:"Investigates topics deeply, synthesizes information, and produces evidence-based insights. Strong at literature review, competitive analysis, and generating clear summaries to inform decisions."},{id:"designer",title:"Designer",description:"Creates intuitive interfaces, user flows, and visual assets. Focused on usability, accessibility, and crafting polished experiences. Strong at wireframing and turning requirements into elegant solutions."},{id:"qa-engineer",title:"QA Engineer",description:"Identifies bugs, edge cases, and reliability gaps. Produces test plans, automated tests, and reproducible reports. Strong at ensuring product quality and preventing regressions."},{id:"devops-engineer",title:"DevOps Engineer",description:"Manages infrastructure, deployments, and operational reliability. Skilled with CI/CD, observability, automation, and environment provisioning. Ensures systems are scalable and fault-tolerant."},{id:"data-analyst",title:"Data Analyst",description:"Analyzes data, defines metrics, and generates actionable insights. Strong in SQL, visualization, experimentation, and turning raw data into strategic recommendations."},{id:"marketer",title:"Marketer",description:"Creates campaigns, messaging, and positioning to reach target audiences. Skilled in content, funnels, and brand strategy. Strong at synthesizing market needs and shaping demand."},{id:"sales-partnerships-agent",title:"Sales & Partnerships Agent",description:"Identifies prospects, crafts outreach, and develops strategic relationships. Strong at value articulation, objection handling, and mapping product capabilities to customer needs."},{id:"growth-operator",title:"Growth Operator",description:"Optimizes acquisition, activation, and retention through experimentation. Skilled in funnel analysis, rapid testing, and leveraging data for compounding growth."},{id:"customer-success-specialist",title:"Customer Success Specialist",description:"Ensures users succeed by providing onboarding, guidance, and proactive support. Strong at diagnosing user challenges and improving long-term satisfaction and retention."},{id:"orchestration-engineer",title:"Orchestration Engineer",description:"Coordinates multi-agent workflows, dependencies, and handoffs. Strong at breaking large tasks into sequenced steps and ensuring agents operate cohesively and efficiently."},{id:"context-curator",title:"Context Curator",description:"Maintains clean, accurate project context by organizing files, logs, and knowledge. Strong at eliminating ambiguity, ensuring agents have the right information at the right time."},{id:"documentation-writer",title:"Documentation Writer",description:"Produces clear technical docs, guides, READMEs, and CP summaries. Strong at structuring complex information and keeping knowledge bases up to date and accessible."}];function G(){const[n,h]=a.useState({}),[r,d]=a.useState(null),[f,x]=a.useState(!1),[b,N]=a.useState(!0),[u,v]=a.useState(!1),{toast:o}=I();a.useEffect(()=>{j()},[]);const j=async()=>{try{try{const t=await fetch(`${S}/api/v1/config`),s=await t.json();if(t.ok&&s?.success){const i=s.data?.coconut||{};d(i.id??null),(i.firstName||i.lastName||i.email||i.role||i.roleDescription)&&h({firstName:i.firstName,lastName:i.lastName,email:i.email,role:i.role,roleDescription:i.roleDescription})}else d(null)}catch(t){console.error("Failed to load coconut config:",t),d(null)}}catch(t){console.error("Failed to load settings:",t),o({title:"Error",description:"Failed to load user settings",variant:"destructive"})}finally{N(!1)}},w=async()=>{v(!0);try{const s=await(await fetch(`${S}/api/v1/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({coconut:{...n,id:r||void 0}})})).json();if(s.success)o({title:"Success",description:"Settings saved successfully"});else throw new Error(s.error||"Failed to save settings")}catch(t){console.error("Failed to save settings:",t),o({title:"Error",description:"Failed to save settings",variant:"destructive"})}finally{v(!1)}},l=t=>{h(s=>{const i={...s,...t};if(t.role!==void 0){const C=m.find(E=>E.id===t.role);C?.description&&(i.roleDescription=C.description)}return i})},y=a.useMemo(()=>n.role&&m.find(s=>s.id===n.role)?.description||null,[n.role]),k=async()=>{if(r)try{await navigator.clipboard.writeText(r),x(!0),o({title:"Copied",description:"Coconut ID copied to clipboard."}),setTimeout(()=>x(!1),1500)}catch(t){console.error("Failed to copy coconut ID:",t),o({title:"Copy failed",description:"Unable to copy the Coconut ID to the clipboard.",variant:"destructive"})}};return b?e.jsx("div",{children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Coconut Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage the Coconut's profile information."})]}),e.jsx(D,{}),e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/40 p-4",children:r?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:"Coconut ID"}),e.jsx("p",{className:"mt-1 font-mono text-sm",children:r})]}),e.jsxs(g,{variant:"outline",size:"sm",onClick:k,children:[f?e.jsx(B,{className:"h-4 w-4"}):e.jsx(H,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2",children:f?"Copied":"Copy"})]})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:"Coconut ID not configured"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add an `id` under the `coconut` section in `.nut/config.json` to register this Coconut instance."})]})}),e.jsxs(q,{children:[e.jsxs(T,{children:[e.jsx(M,{children:"Coconut Profile"}),e.jsx(O,{children:"Update the Coconut's identifying details and role."})]}),e.jsxs(U,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{htmlFor:"firstName",children:"First Name"}),e.jsx(p,{id:"firstName",value:n.firstName||"",onChange:t=>l({firstName:t.target.value}),placeholder:"Enter first name"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"lastName",children:"Last Name"}),e.jsx(p,{id:"lastName",value:n.lastName||"",onChange:t=>l({lastName:t.target.value}),placeholder:"Enter last name"})]})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"email",children:"Email"}),e.jsx(p,{id:"email",type:"email",value:n.email||"",onChange:t=>l({email:t.target.value}),placeholder:"Enter email address"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"role",children:"Role"}),e.jsxs(F,{value:n.role,onValueChange:t=>l({role:t}),children:[e.jsx(P,{children:e.jsx(z,{placeholder:"Select role"})}),e.jsx(L,{children:m.map(t=>e.jsx(A,{value:t.id,children:t.title},t.id))})]}),y&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:y})]})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can also manage the Coconut's identity to other agents on the"," ",e.jsx(R,{to:"/identity",className:"underline underline-offset-4 hover:text-primary",children:"Identity page"}),"."]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(g,{variant:"outline",onClick:j,disabled:u,children:"Cancel"}),e.jsx(g,{onClick:w,disabled:u,children:u?"Saving...":"Save Changes"})]})]})}export{G as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as k,H as w,r as n,j as e,B as g,af as b,L as C,A as S,a4 as I}from"./index-
|
|
1
|
+
import{u as k,H as w,r as n,j as e,B as g,af as b,L as C,A as S,a4 as I}from"./index-CKcm92Kn.js";import{C as R,a as B}from"./card-Cq3qftln.js";import{u as Q}from"./use-terminal-C1j4Pa5C.js";import{C as $}from"./circle-play-C0yQlVR9.js";import{P as O}from"./play-sWUKmZEy.js";function L(){const o=k(),{loading:l,createSession:d,refreshSessions:j}=Q(),{toast:i}=w(),[m,u]=n.useState(!1),[x,h]=n.useState(!1),[,f]=n.useState([]),[c,y]=n.useState({});n.useEffect(()=>{try{const t=localStorage.getItem("terminal.commandHistory");t&&f(JSON.parse(t))}catch{}},[]),n.useEffect(()=>{(async()=>{try{const s=await fetch(`${S}/api/v1/context/architecture`);if(!s.ok)return;const a=await s.json();a?.success&&a?.document?.metadata?.commands&&y(a.document.metadata.commands)}catch{}})()},[]);const p=t=>{t&&f(s=>{const a=[t,...s.filter(r=>r!==t)].slice(0,5);try{localStorage.setItem("terminal.commandHistory",JSON.stringify(a))}catch{}return a})},N=async t=>{const s=(t||"").trim();if(!s)return;const a=`session-${Date.now()}`;u(!0);try{await d(a,!1,s)?(p(s),i({title:"Session started",description:`${a}`}),o(`/terminal/${a}`)):i({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{u(!1)}},v=async t=>{const s=(t||"").trim();if(!s)return;const a=`session-${Date.now()}`;h(!0);try{await d(a,!1,s)?(p(s),setTimeout(()=>j(),150),i({title:"Started in background",description:`${a}`,action:e.jsx(I,{altText:"Open session",onClick:()=>o(`/terminal/${a}`),children:"Open"})})):i({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{h(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Utilities"}),e.jsx("p",{className:"text-muted-foreground",children:"Quick commands and shortcuts"})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Quick Commands"}),e.jsx(R,{children:e.jsx(B,{className:"pt-6",children:c&&Object.keys(c).length>0?e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"rounded-md border divide-y",children:Object.entries(c).map(([t,s])=>e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 p-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-2",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:t}),e.jsx("span",{className:"text-muted-foreground hidden sm:inline",children:":"}),e.jsx("span",{className:"truncate max-w-full",children:e.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs",children:s})})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 flex-shrink-0",children:[e.jsxs(g,{onClick:()=>v(s),variant:"secondary",size:"sm",disabled:l||x||m,title:"Run in background",children:[e.jsx($,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Background"})]}),e.jsxs(g,{onClick:()=>N(s),size:"sm",disabled:l||m||x,title:"Run",children:[e.jsx(O,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Run"})]})]})]},t))})}):e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3 py-8",children:[e.jsx(b,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No quick commands configured"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md leading-relaxed",children:"Quick commands let you run common tasks with one click, like starting your development server or running build scripts."}),e.jsxs("p",{className:"text-sm text-muted-foreground max-w-md mt-2",children:["Set them up in the"," ",e.jsx(C,{to:"/context/architecture/edit",className:"text-primary hover:underline font-medium",children:"Quick Commands section"}),"."]})]})]})})})]})]})}export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as a,f as o}from"./index-
|
|
1
|
+
import{r,j as a,f as o}from"./index-CKcm92Kn.js";const v=r.forwardRef(({className:e,variant:t="default",...s},d)=>{const l="relative w-full rounded-lg border px-4 py-3 text-sm [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",i=t==="destructive"?"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive":"bg-background text-foreground";return a.jsx("div",{ref:d,role:"alert",className:o(l,i,e),...s})});v.displayName="Alert";const c=r.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:o("text-sm [&_p]:leading-relaxed",e),...t}));c.displayName="AlertDescription";export{v as A,c as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o,f as n,bd as a}from"./index-
|
|
1
|
+
import{j as o,f as n,bd as a}from"./index-CKcm92Kn.js";const s=a("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function i({className:r,variant:e,...t}){return o.jsx("div",{className:n(s({variant:e}),r),...t})}export{i as B};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as z,r,j as e,D as G,a as J,b as K,d as Q,I as V,n as M,S as W,f as X,$ as Y,B}from"./index-
|
|
1
|
+
import{c as z,r,j as e,D as G,a as J,b as K,d as Q,I as V,n as M,S as W,f as X,$ as Y,B}from"./index-CKcm92Kn.js";import{B as v}from"./badge-CxMDR-vz.js";import{a as Z}from"./registry-ANRa5WBi.js";import{S as O}from"./search-DHLiojAp.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{r,j as d,f as t}from"./index-
|
|
1
|
+
import{r,j as d,f as t}from"./index-CKcm92Kn.js";const o=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("rounded-xl border bg-card text-card-foreground shadow",a),...e}));o.displayName="Card";const c=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("flex flex-col space-y-1.5 p-6",a),...e}));c.displayName="CardHeader";const i=r.forwardRef(({className:a,...e},s)=>d.jsx("h3",{ref:s,className:t("font-semibold leading-none tracking-tight",a),...e}));i.displayName="CardTitle";const n=r.forwardRef(({className:a,...e},s)=>d.jsx("p",{ref:s,className:t("text-sm text-muted-foreground",a),...e}));n.displayName="CardDescription";const l=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("p-6 pt-0",a),...e}));l.displayName="CardContent";const f=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("flex items-center p-6 pt-0",a),...e}));f.displayName="CardFooter";export{o as C,l as a,c as b,i as c,n as d,f as e};
|