@lovelybunch/api 1.0.75-alpha.9 → 1.0.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/jobs/job-runner.js +10 -2
- package/dist/lib/jobs/job-scheduler.js +21 -0
- package/dist/lib/mail/mail-runner.d.ts +51 -0
- package/dist/lib/mail/mail-runner.js +342 -0
- package/dist/lib/slack/slack-service.d.ts +2 -0
- package/dist/lib/slack/slack-service.js +3 -0
- package/dist/lib/storage/file-storage.d.ts +16 -16
- package/dist/lib/storage/file-storage.js +59 -64
- package/dist/lib/terminal/terminal-manager.d.ts +3 -3
- package/dist/lib/terminal/terminal-manager.js +10 -10
- package/dist/routes/api/v1/ai/route.js +39 -19
- package/dist/routes/api/v1/git/index.js +23 -0
- package/dist/routes/api/v1/mail/index.d.ts +3 -0
- package/dist/routes/api/v1/mail/index.js +23 -0
- package/dist/routes/api/v1/mail/route.d.ts +294 -0
- package/dist/routes/api/v1/mail/route.js +344 -0
- package/dist/routes/api/v1/mcp/index.js +32 -32
- package/dist/routes/api/v1/slack/index.d.ts +3 -0
- package/dist/routes/api/v1/slack/index.js +15 -0
- package/dist/routes/api/v1/slack/route.d.ts +124 -0
- package/dist/routes/api/v1/slack/route.js +192 -0
- package/dist/routes/api/v1/tasks/[id]/route.d.ts +117 -0
- package/dist/routes/api/v1/tasks/[id]/route.js +166 -0
- package/dist/routes/api/v1/tasks/index.d.ts +3 -0
- package/dist/routes/api/v1/tasks/index.js +10 -0
- package/dist/routes/api/v1/tasks/route.d.ts +96 -0
- package/dist/routes/api/v1/tasks/route.js +136 -0
- package/dist/routes/api/v1/terminal/[taskId]/create/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/[taskId]/create/index.js +5 -0
- package/dist/routes/api/v1/terminal/[taskId]/create/route.d.ts +10 -0
- package/dist/routes/api/v1/terminal/[taskId]/create/route.js +27 -0
- package/dist/routes/api/v1/terminal/[taskId]/destroy/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/[taskId]/destroy/index.js +5 -0
- package/dist/routes/api/v1/terminal/[taskId]/destroy/route.d.ts +10 -0
- package/dist/routes/api/v1/terminal/[taskId]/destroy/route.js +21 -0
- package/dist/routes/api/v1/terminal/[taskId]/resize/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/[taskId]/resize/index.js +5 -0
- package/dist/routes/api/v1/terminal/[taskId]/resize/route.d.ts +10 -0
- package/dist/routes/api/v1/terminal/[taskId]/resize/route.js +21 -0
- package/dist/routes/api/v1/terminal/sessions/route.js +4 -4
- package/dist/server-with-static.js +12 -8
- package/dist/server.js +12 -8
- package/package.json +4 -4
- package/static/assets/{ActivityPage-OxRci_V2.js → ActivityPage-k4I7Q53O.js} +1 -1
- package/static/assets/ApiKeysSettingsPage-B1YvVdmg.js +2 -0
- package/static/assets/{ArchitectureEditPage-D7xcH6dY.js → ArchitectureEditPage-CpowsIx2.js} +4 -4
- package/static/assets/{ArchitecturePage-pvnlX-NW.js → ArchitecturePage-DYxC_aMR.js} +1 -1
- package/static/assets/{AuthSettingsPage-Bu0CZ1rY.js → AuthSettingsPage-DtSo78Y_.js} +2 -2
- package/static/assets/{CallbackPage-D0lkjxCT.js → CallbackPage-bROCGapx.js} +1 -1
- package/static/assets/CodePage-CPCj64rX.js +2 -0
- package/static/assets/{CollapsibleSection-Bt_ZLnJc.js → CollapsibleSection-M5cXbl92.js} +1 -1
- package/static/assets/DashboardPage-B9BZZfw6.js +51 -0
- package/static/assets/{GitPage-TrTxZ27J.js → GitPage-BiDtdSK1.js} +2 -2
- package/static/assets/GitSettingsPage-THm6wDjs.js +6 -0
- package/static/assets/IdentityPage-BC16skg6.js +6 -0
- package/static/assets/{ImplementationStepsEditor-Ctx0CvbU.js → ImplementationStepsEditor-HliLQav5.js} +2 -2
- package/static/assets/{IntegrationsSettingsPage-C2wJVdM7.js → IntegrationsSettingsPage-CC_VKIQa.js} +1 -1
- package/static/assets/JobDetailPage-z1QQYvmU.js +1 -0
- package/static/assets/{KnowledgeDetailPage-BdTUfWqj.js → KnowledgeDetailPage-DzHXBS7Q.js} +1 -1
- package/static/assets/{KnowledgeEditPage-D8XK4IUf.js → KnowledgeEditPage-BwGnUH_m.js} +1 -1
- package/static/assets/KnowledgePage-CGIVMS02.js +3 -0
- package/static/assets/{LoginPage-Dqxd7cTa.js → LoginPage-VQ3lcfLV.js} +1 -1
- package/static/assets/MailInboxPage-DiZKqwdU.js +1 -0
- package/static/assets/MailProcessingModal-DIeSQBoR.js +6 -0
- package/static/assets/MailReadPage-C8AACmZQ.js +1 -0
- package/static/assets/MailSentPage-C_5yFly_.js +1 -0
- package/static/assets/{McpSettingsPage-10n35zXi.js → McpSettingsPage-i9YHcu1s.js} +1 -1
- package/static/assets/{NewKnowledgePage-BlJzzuh7.js → NewKnowledgePage-BnVY7WUD.js} +1 -1
- package/static/assets/{NewSkillPage-ByqN--mH.js → NewSkillPage-DwniHD6D.js} +1 -1
- package/static/assets/NewTaskPage-F5UX2WMc.js +90 -0
- package/static/assets/NotFoundPage-BbSZX_4L.js +6 -0
- package/static/assets/NotificationsSettingsPage-C8kjcift.js +1 -0
- package/static/assets/{ProjectEditPage-DKJTY2uc.js → ProjectEditPage-DUUlIEqI.js} +1 -1
- package/static/assets/{ProjectPage-2VblKCWz.js → ProjectPage-Unz9PQpA.js} +1 -1
- package/static/assets/{PromptsSettingsPage-B4mOhXuo.js → PromptsSettingsPage-DVpIuRKI.js} +1 -1
- package/static/assets/ResourceDetailPage-DqHZ2KYD.js +1 -0
- package/static/assets/{ResourcesPage-2BbjIWfF.js → ResourcesPage-BP5tuAi-.js} +1 -1
- package/static/assets/RoleEditPage-BgKu8S0-.js +13 -0
- package/static/assets/{RolePage-qXWXZ2FZ.js → RolePage-Fed52Ov5.js} +1 -1
- package/static/assets/{RulesSettingsPage-BtM7p8F6.js → RulesSettingsPage-BQ2O0u66.js} +3 -3
- package/static/assets/SchedulePage-jkxjuzBx.js +4 -0
- package/static/assets/SkillDetailPage-k3Q2-NFd.js +1 -0
- package/static/assets/{SkillEditPage-Czlo8WWT.js → SkillEditPage-urF4snjo.js} +1 -1
- package/static/assets/SkillsPage-DlWDhEjR.js +8 -0
- package/static/assets/{SkillsSettingsPage-DKtpy7qk.js → SkillsSettingsPage-BViFgckG.js} +1 -1
- package/static/assets/{SourceInput-BITn1Y15.js → SourceInput-CAFKTHw-.js} +1 -1
- package/static/assets/{TagInput-BK91_M1N.js → TagInput-C6lI-ePr.js} +1 -1
- package/static/assets/TaskDetailPage-DpbRHnW_.js +16 -0
- package/static/assets/TaskEditPage-DssRbW0h.js +1 -0
- package/static/assets/TasksPage-CD_eo0Bj.js +17 -0
- package/static/assets/TerminalPage-BG_wlccr.js +1 -0
- package/static/assets/TerminalSessionPage-CsK-LznK.js +8 -0
- package/static/assets/{UserPreferencesPage-DrgYEcxO.js → UserPreferencesPage-CWUq3efu.js} +1 -1
- package/static/assets/UserSettingsPage-CduI_MGS.js +1 -0
- package/static/assets/{UtilitiesPage-Djr4qT5L.js → UtilitiesPage-BAxokhLh.js} +1 -1
- package/static/assets/{alert-CsMvyYoX.js → alert-BXsc6_qu.js} +1 -1
- package/static/assets/{arrow-down-BZnfbld8.js → arrow-down-DmW_3gE8.js} +1 -1
- package/static/assets/{arrow-left-WGBYWq3h.js → arrow-left-1S-835kP.js} +1 -1
- package/static/assets/{arrow-up-BByVUPE7.js → arrow-up-BYism_o1.js} +1 -1
- package/static/assets/arrow-up-down-Dw3J0a4i.js +6 -0
- package/static/assets/{badge-AwLOflf5.js → badge-BUEY53dV.js} +1 -1
- package/static/assets/{browser-modal-BzGNFfTG.js → browser-modal-DCNdI4NT.js} +2 -2
- package/static/assets/{card-SN5gKnu7.js → card-BcPlIAH5.js} +1 -1
- package/static/assets/{chevron-left-C7uNq9l_.js → chevron-left-FMmNe7yP.js} +1 -1
- package/static/assets/{chevron-up-CHdIiLxL.js → chevron-up-CqM3won3.js} +1 -1
- package/static/assets/{chevrons-up-TXwQuoUN.js → chevrons-up-DTvCkIHc.js} +1 -1
- package/static/assets/{circle-alert-37E5gU9K.js → circle-alert-dseM-Ib7.js} +1 -1
- package/static/assets/{circle-check-big-nY4PntB5.js → circle-check-big-jKg34xC-.js} +1 -1
- package/static/assets/{circle-check-D02pWDME.js → circle-check-eyo6pBP1.js} +1 -1
- package/static/assets/{circle-play-7EXFLo4F.js → circle-play-BrY_lNiH.js} +1 -1
- package/static/assets/{circle-x-By4JoTHB.js → circle-x-uqmzEce1.js} +1 -1
- package/static/assets/{clipboard-BdymjxLO.js → clipboard-tzPFoieb.js} +1 -1
- package/static/assets/{clock-HDu44KTo.js → clock-Bjc06QBM.js} +1 -1
- package/static/assets/code-DrYqPukx.js +6 -0
- package/static/assets/{download-Cv2G2Eg9.js → download-Bg__QCLT.js} +1 -1
- package/static/assets/{external-link-DwMXcCCj.js → external-link-CNDy2UUo.js} +1 -1
- package/static/assets/{eye-DYnjJzdb.js → eye-DLFBnC8t.js} +1 -1
- package/static/assets/{folder-git-2-COeWFPHS.js → folder-git-2-DUqd0WRi.js} +1 -1
- package/static/assets/index-CHdBxVyk.css +2 -0
- package/static/assets/{index-9Tv-j_Ga.js → index-DFcWlnzl.js} +118 -103
- package/static/assets/{info-BmtuPMhv.js → info-D6jxZC5X.js} +1 -1
- package/static/assets/kiro-CX1mOsRO.js +17 -0
- package/static/assets/{label-TGqbNfMO.js → label-DBuh-ke5.js} +1 -1
- package/static/assets/{markdown-editor-ls1JPK_e.js → markdown-editor-B4YNQFT2.js} +1 -1
- package/static/assets/message-square-B5RWz_ff.js +6 -0
- package/static/assets/paperclip-4A_3MaPx.js +6 -0
- package/static/assets/{pause-CAWbvTiL.js → pause-BzhKXHtR.js} +1 -1
- package/static/assets/{play-DF_Qeu0H.js → play-CHIf-Rcz.js} +1 -1
- package/static/assets/{radio-group-DYTbywtK.js → radio-group-C1ct-VsJ.js} +1 -1
- package/static/assets/{refresh-cw-BFZxHqbC.js → refresh-cw-B3OwrDUf.js} +1 -1
- package/static/assets/{search-Dr90tbch.js → search-Cq1ksEdp.js} +1 -1
- package/static/assets/{select-Cs5qtMYV.js → select-44mcS2_G.js} +1 -1
- package/static/assets/{status-utils-BDOyevaX.js → status-utils-CDkPeVfP.js} +1 -1
- package/static/assets/{switch-4TDb6YiQ.js → switch-CIwjYvCt.js} +1 -1
- package/static/assets/{tabs-BrbEvF4V.js → tabs-DTV6Su-h.js} +1 -1
- package/static/assets/{tag-DrQkepeD.js → tag-p6yeowCW.js} +1 -1
- package/static/assets/{terminal-preview-uuKF9_x4.js → terminal-preview-DN38x9Jm.js} +1 -1
- package/static/assets/use-terminal-BXJqOeJe.js +1 -0
- package/static/assets/{video-DYA2WfbA.js → video-BH5ChaoS.js} +1 -1
- package/static/index.html +2 -2
- package/static/assets/ApiKeysSettingsPage-C0evI19e.js +0 -2
- package/static/assets/CodePage-BJ4PC5nb.js +0 -2
- package/static/assets/DashboardPage-BiffPdmj.js +0 -41
- package/static/assets/GitSettingsPage-D7q5xQd_.js +0 -6
- package/static/assets/IdentityPage-CY0Ak2j0.js +0 -11
- package/static/assets/JobDetailPage-Phx_IlKX.js +0 -1
- package/static/assets/KnowledgePage-Ci9G7Br-.js +0 -8
- package/static/assets/NewProposalPage-BP7Ttoxk.js +0 -90
- package/static/assets/ProposalDetailPage-m3ysyzpj.js +0 -1
- package/static/assets/ProposalEditPage-3XVg_paW.js +0 -1
- package/static/assets/ProposalsPage-B3u0aFFz.js +0 -17
- package/static/assets/ResourceDetailPage-somBLUpC.js +0 -1
- package/static/assets/RoleEditPage-CLzX7Xhi.js +0 -13
- package/static/assets/SchedulePage-4tFcIBSs.js +0 -4
- package/static/assets/SkillDetailPage-CroSdaju.js +0 -1
- package/static/assets/SkillsPage-CgULbcI-.js +0 -8
- package/static/assets/TerminalPage-8fwvnOo2.js +0 -1
- package/static/assets/TerminalSessionPage-BhO5U48p.js +0 -13
- package/static/assets/UserSettingsPage-Dj6lKLi8.js +0 -1
- package/static/assets/droid-CPteN3f9.js +0 -17
- package/static/assets/index-GFQ5RqVh.css +0 -2
- package/static/assets/use-terminal-BG5UXuVE.js +0 -1
- package/static/assets/zap-h9QOsasv.js +0 -6
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as Ze,ag as Xe,r as m,j as e,B as u,x as O,P as pe,br as ge,J as q,N as fe,O as ve,Q as V,R as Y,U as G,V as K,W as Q,Y as Z,Z as X,L as je,k as ee,ac as Ne,bs as es,C as ss,p as se,D as be,b as ye,d as we,f as Se,g as Ce,I as te,a5 as ke,a6 as Ae,a7 as De,a8 as Ie,a9 as Te,ad as Fe,q as ts,ae as as,a1 as Pe,A as j}from"./index-9Tv-j_Ga.js";import{C as J,a as ae,c as re,b as $e}from"./card-SN5gKnu7.js";import{B as F}from"./badge-AwLOflf5.js";import{S as rs,a as ns,b as is,c as ls,d as ds}from"./select-Cs5qtMYV.js";import{L as v}from"./label-TGqbNfMO.js";import{S as cs}from"./switch-4TDb6YiQ.js";import{T as os,a as ms,b as ne,c as ie}from"./tabs-BrbEvF4V.js";import{R as us}from"./refresh-cw-BFZxHqbC.js";import{P as Me}from"./play-DF_Qeu0H.js";import{P as hs}from"./pause-CAWbvTiL.js";import{C as xs}from"./clock-HDu44KTo.js";import{C as ps}from"./chevron-up-CHdIiLxL.js";const ce=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"}],gs=[{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"}],Ee=["monday","tuesday","wednesday","thursday","friday"],Oe=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 Oe(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 T=Math.round(N/60);return T<24?`${T}h ago`:`${Math.round(T/24)}d ago`},fs=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}`},vs=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(Ee),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||[]}},js=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 Ps(){const{toast:a}=Ze(),{refresh:o}=Xe(),[x,f]=m.useState([]),[N,T]=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.useState(null),[Je,M]=m.useState(!1),[R,He]=m.useState([]),[W,Le]=m.useState([]),[ze,We]=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&&$(l)}s&&a({title:"Schedule refreshed",description:"Latest job information loaded."})}catch(t){console.error("Failed to load jobs:",t),a({title:"Failed to load schedule",description:t?.message??"Unknown error",variant:"destructive"})}finally{T(!1),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:js(h?.metadata?.tools)}));if(He(d),c){const D=(c.agentIds||(c.agentId?[c.agentId]:[])).filter(I=>!d.find(_=>_.id===I));D.length>0&&(a({title:"Some agents no longer available",description:`The following agents have been removed: ${D.join(", ")}`,variant:"destructive"}),p(I=>({...I,agentIds:I.agentIds.filter(_=>d.find(Qe=>Qe.id===_))})))}}const r=await fetch(`${j}/api/v1/mcp`);if(r.ok){const i=await r.json();if(i?.success&&Array.isArray(i.servers)&&(Le(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}))},Be=(s,t)=>{p(r=>{let i;if(t){i=[...r.agentIds,s];const l=R.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}})},Ue=(s,t)=>{if(!t&&R.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)}))},_e=()=>{const s=B.serverToRemove;s&&p(t=>({...t,mcpServers:t.mcpServers.filter(r=>r!==s)})),U({open:!1,serverToRemove:null})},qe=(s,t)=>{p(r=>{const i=new Set(r.daysOfWeek);return t?i.add(s):i.delete(s),i.size===0&&Ee.forEach(l=>i.add(l)),{...r,daysOfWeek:i}})},E=()=>{p(de())},me=s=>{We(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},ue=s=>{$(s),M(!0)},he=()=>{C(null),E(),y(!0)},Ve=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)},Ye=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 I=await D.json().catch(()=>({}));throw new Error(I?.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)}},Ge=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)}},Ke=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&&(M(!1),$(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(ge,{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($e,{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(fe,{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(ve,{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(Z,{children:"Cancel"}),e.jsx(X,{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($e,{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(je,{to:`/schedule/${s.id}`,className:"hover:underline",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:()=>Ge(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",asChild:!0,className:"h-8 px-3 text-xs",children:e.jsx(je,{to:`/schedule/${s.id}`,children:"View"})}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ve(s),disabled:w===s.id,className:"h-8 px-3 text-xs",children:"Edit"}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ke(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(fe,{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(ve,{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(Z,{children:"Cancel"}),e.jsx(X,{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:fs(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:vs(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(Ne,{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(es,{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(ss,{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=ze.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(ps,{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(be,{open:P,onOpenChange:s=>{y(s),s||(C(null),E())},children:e.jsxs(ye,{className:"max-w-4xl h-[700px] overflow-hidden flex flex-col",children:[e.jsxs(we,{className:"space-y-2 pb-4 shrink-0",children:[e.jsxs(Se,{className:"text-xl flex items-center gap-2",children:[e.jsx(ge,{className:"h-5 w-5 text-primary"}),c?"Edit Scheduled Job":"Create New Scheduled Job"]}),e.jsx(Ce,{className:"text-sm",children:c?"Update the prompt, cadence, or agent preference":"Automate recurring tasks by scheduling an agent"})]}),e.jsxs("form",{onSubmit:Ye,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(rs,{value:n.model,onValueChange:s=>A({model:s}),children:[e.jsx(ns,{id:"job-model",className:"h-11",children:e.jsx(is,{placeholder:"Select a model"})}),e.jsx(ls,{children:ce.map(s=>e.jsx(ds,{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(ke,{children:[e.jsx(Ae,{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(De,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(Ie,{children:"Available Agents"}),e.jsx(Te,{}),R.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No agents configured"}):R.map(s=>e.jsx(Fe,{checked:n.agentIds.includes(s.id),onCheckedChange:t=>Be(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(Ne,{className:"h-4 w-4"}),"MCP Servers",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(ke,{children:[e.jsx(Ae,{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(De,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(Ie,{children:"Available MCP Servers"}),e.jsx(Te,{}),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(Fe,{checked:n.mcpServers.includes(s),onCheckedChange:t=>Ue(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(ts,{id:"job-prompt",placeholder:n.agentIds.length>0?`Additional instructions to supplement the agent's predefined behavior...
|
|
2
|
-
Example: Focus on performance optimizations`:`Example:
|
|
3
|
-
Run the following command and append the output to .nut/knowledge/runs.md:
|
|
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:gs.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(as,{checked:n.daysOfWeek.has(s.value),onCheckedChange:t=>qe(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(Pe,{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(be,{open:Je,onOpenChange:s=>{M(s),s||$(null)},children:e.jsxs(ye,{className:"max-w-3xl",children:[e.jsxs(we,{children:[e.jsxs(Se,{children:["Run history — ",g?.name]}),e.jsxs(Ce,{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," • ",Oe(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(Pe,{children:e.jsx(u,{variant:"outline",onClick:()=>M(!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(Z,{children:"Cancel"}),e.jsx(X,{onClick:_e,children:"OK"})]})]})})]})}export{Ps as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as S,u as C,r as x,j as e,B as a,L as n,H as E,O as T,k as A,A as b}from"./index-9Tv-j_Ga.js";import{C as l,b as d,a as c,c as h,d as z}from"./card-SN5gKnu7.js";import{B as N}from"./badge-AwLOflf5.js";import{A as j}from"./arrow-left-WGBYWq3h.js";const i={blue:{bg:"#dbeafe",border:"#2563eb",text:"#1e40af"},green:{bg:"#dcfce7",border:"#16a34a",text:"#166534"},red:{bg:"#fee2e2",border:"#dc2626",text:"#991b1b"},emerald:{bg:"#d1fae5",border:"#10b981",text:"#047857"},purple:{bg:"#f3e8ff",border:"#9333ea",text:"#6b21a8"},orange:{bg:"#fed7aa",border:"#ea580c",text:"#9a3412"},yellow:{bg:"#fef9c3",border:"#eab308",text:"#854d0e"},teal:{bg:"#ccfbf1",border:"#14b8a6",text:"#0f766e"},indigo:{bg:"#e0e7ff",border:"#6366f1",text:"#4338ca"},pink:{bg:"#fce7f3",border:"#ec4899",text:"#9f1239"},cyan:{bg:"#cffafe",border:"#06b6d4",text:"#155e75"},slate:{bg:"#f1f5f9",border:"#475569",text:"#334155"},gray:{bg:"#f3f4f6",border:"#6b7280",text:"#374151"}};function P(){const f=S(),v=C(),[s,k]=x.useState(null),[w,p]=x.useState(!0),[g,o]=x.useState(null);x.useEffect(()=>{async function t(){try{p(!0);const u=await(await fetch(`${b}/api/v1/skills/${f.id}`)).json();u.success?k(u.document):o(u.error||"Failed to fetch skill")}catch(r){o(r instanceof Error?r.message:"Unknown error")}finally{p(!1)}}f.id&&t()},[f.id]);const y=async()=>{if(!(!s||!confirm("Are you sure you want to delete this skill?")))try{const r=await(await fetch(`${b}/api/v1/skills/${s.id}`,{method:"DELETE"})).json();r.success?v("/skills"):o(r.error?.message||"Failed to delete skill")}catch(t){o(t instanceof Error?t.message:"Unknown error")}};if(w)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-64 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 animate-pulse mt-2"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(n,{to:"/skills",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})})})]}),e.jsx(l,{children:e.jsxs(d,{children:[e.jsx("div",{className:"h-6 bg-muted rounded w-48 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-64 animate-pulse"})]})})]});if(g||!s)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Skill Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:"The requested skill could not be found"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(n,{to:"/skills",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})})})]}),e.jsx(l,{children:e.jsx(c,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-destructive",children:g||"Skill not found"})})})})]});const m=s.metadata?.color||"blue";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"space-y-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:s.name}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(n,{to:"/skills",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})}),e.jsx(a,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(n,{to:`/skills/${s.id}/edit`,children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(a,{variant:"destructive",size:"sm",onClick:y,children:[e.jsx(T,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(h,{children:"Description"})}),e.jsx(c,{children:e.jsx("p",{children:s.description})})]}),s.content&&e.jsxs(l,{children:[e.jsxs(d,{children:[e.jsx(h,{children:"Instructions"}),e.jsx(z,{children:"System prompt and behavior instructions for this skill"})]}),e.jsx(c,{children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm bg-muted p-4 rounded-md",children:s.content})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(h,{children:"Actions"})}),e.jsx(c,{className:"space-y-2",children:e.jsx(a,{variant:"default",className:"w-full justify-start",asChild:!0,children:e.jsxs(n,{to:`/terminal/sk-${s.id}`,children:[e.jsx(A,{className:"h-4 w-4 mr-2"}),"Start Skill"]})})})]}),e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(h,{children:"Information"})}),e.jsxs(c,{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Color"}),e.jsx(N,{variant:"outline",className:"capitalize border-2",style:{backgroundColor:i[m]?.bg||i.blue.bg,color:i[m]?.text||i.blue.text,borderColor:i[m]?.border||i.blue.border},children:m})]}),s.allowedTools&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Allowed Tools"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.allowedTools})]}),s.metadata?.mcpServers&&s.metadata.mcpServers.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"MCP Servers"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:s.metadata.mcpServers.map(t=>e.jsx(N,{variant:"secondary",children:t},t))})]}),!s.allowedTools&&!(s.metadata?.mcpServers&&s.metadata.mcpServers.length>0)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Tools"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No specific tools configured - inherits all tools"})]})]})]})]})]})]})}export{P as default};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{c as z,j as e,S as $,_ as O,r as h,a as _,A as E,x as B,B as v,L as y,P as F,k as L,ah as U,ai as D}from"./index-9Tv-j_Ga.js";import{C as N,a as w,b as K,c as V}from"./card-SN5gKnu7.js";import{B as b}from"./badge-AwLOflf5.js";import{c as H}from"./clipboard-B9ndUJKl.js";import{R as Y,L as P}from"./browser-modal-BzGNFfTG.js";import{R as T,f as q}from"./registry-ANRa5WBi.js";import{T as G}from"./tag-DrQkepeD.js";import"./search-Dr90tbch.js";/**
|
|
2
|
-
* @license lucide-react v0.542.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const J=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],W=z("package",J),Q=["color","tools","createdAt","updatedAt","version","focusAreas","contextPreferences","tags"];function k(t){if(t){if(Array.isArray(t)){const a=t.map(i=>{if(typeof i=="string")return i.trim();if(typeof i=="number")return`${i}`}).filter(i=>typeof i=="string"&&i.length>0);return a.length>0?a:void 0}if(typeof t=="string"){const a=t.split(",").map(i=>i.trim()).filter(i=>i.length>0);return a.length>0?a:void 0}}}function X(t,a){const i=[];if(t.content&&typeof t.content=="object")for(const d of Object.values(t.content))typeof d=="string"&&d.trim().length>0&&i.push(d.trim());const n=[];return n.push(`# ${a}`),t.description?.trim()&&n.push(t.description.trim()),[...n,...i].join(`
|
|
7
|
-
|
|
8
|
-
`).trim()}function I(t,a){const i=t.name||a.name,n=a.description||t.description||"",r={registryId:t.id,registryEndpoint:t.endpoint,registrySource:T,author:t.author};for(const o of Q){const m=a[o];if(m!==void 0)if(o==="tools"){const x=k(m);x&&(r.mcpServers=x)}else if(o==="focusAreas"||o==="contextPreferences"||o==="tags"){const x=k(m);x&&(r[o]=x)}else r[o]=m}!r.version&&t.version&&(r.version=t.version),r.color||(r.color="blue"),!r.tags&&t.tags&&(r.tags=k(t.tags));for(const[o,m]of Object.entries(r))m==null&&delete r[o];let d;return a.archive&&(d=a.archive.startsWith("http")?a.archive:`${T}${a.archive}`),{name:i,description:n,content:X(a,i),metadata:Object.keys(r).length>0?r:void 0,archiveUrl:d}}function M({open:t,onOpenChange:a,onImport:i}){return e.jsx(Y,{open:t,onOpenChange:a,categoryId:"skills",title:"Coconut Registry - Skills",confirmLabel:"Import Skill",getDetail:n=>q(n.endpoint),renderPreview:(n,r)=>{if(!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select a skill to preview"});const d=I(n,r),o=d.metadata??{},m=typeof o.version=="string"?o.version:void 0,x=Array.isArray(n.tags)?n.tags:[],j=Array.isArray(o.mcpServers)?o.mcpServers.filter(c=>typeof c=="string"):[],f=Array.isArray(o.focusAreas)?o.focusAreas.filter(c=>typeof c=="string"):[];return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx($,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.description})]}),m&&e.jsxs(b,{variant:"outline",children:["v",m]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:n.id})]}),r.archive&&e.jsxs(b,{variant:"outline",className:"gap-1 text-[10px]",children:[e.jsx(W,{className:"h-3 w-3"}),"Includes companion files"]})]}),x.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:x.map(c=>e.jsx(b,{variant:"secondary",children:c},c))}),j.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:"MCP Servers:"}),j.map(c=>e.jsx(b,{variant:"outline",children:c},c))]}),f.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"Focus Areas"}),e.jsx("ul",{className:"list-disc pl-5 text-sm text-muted-foreground",children:f.map(c=>e.jsx("li",{children:c},c))})]})]}),d.content?e.jsx(O,{className:"[&_.prose]:max-w-none",children:d.content}):r.archive?e.jsx("div",{className:"rounded-md bg-muted/50 p-4 text-sm text-muted-foreground",children:e.jsx("p",{children:"Full skill content and companion files will be downloaded during import."})}):null]})})})},onConfirm:async(n,r)=>{const d=I(n,r);await i({summary:n,detail:r,payload:d})}})}const g={blue:{bg:"#dbeafe",border:"#2563eb",text:"#1e40af"},green:{bg:"#dcfce7",border:"#16a34a",text:"#166534"},red:{bg:"#fee2e2",border:"#dc2626",text:"#991b1b"},emerald:{bg:"#d1fae5",border:"#10b981",text:"#047857"},purple:{bg:"#f3e8ff",border:"#9333ea",text:"#6b21a8"},orange:{bg:"#fed7aa",border:"#ea580c",text:"#9a3412"},yellow:{bg:"#fef9c3",border:"#eab308",text:"#854d0e"},teal:{bg:"#ccfbf1",border:"#14b8a6",text:"#0f766e"},indigo:{bg:"#e0e7ff",border:"#6366f1",text:"#4338ca"},pink:{bg:"#fce7f3",border:"#ec4899",text:"#9f1239"},cyan:{bg:"#cffafe",border:"#06b6d4",text:"#155e75"},slate:{bg:"#f1f5f9",border:"#475569",text:"#334155"},gray:{bg:"#f3f4f6",border:"#6b7280",text:"#374151"}};function le(){const[t,a]=h.useState([]),[i,n]=h.useState(!0),[r,d]=h.useState({}),[o,m]=h.useState(!1),[x,j]=h.useState(!1),{toast:f}=_(),c=h.useCallback(async()=>{n(!0);try{const s=await fetch(`${E}/api/v1/skills`);if(!s.ok)throw new Error("Failed to load skills");const p=await s.json();a(Array.isArray(p.documents)?p.documents:[])}catch(s){console.error("Failed to load skills:",s),a([])}finally{n(!1)}},[]);h.useEffect(()=>{c()},[c]);const S=async s=>{const p=`.nut/skills/${s}/SKILL.md`;try{await H(p),d(l=>({...l,[s]:!0})),setTimeout(()=>{d(l=>({...l,[s]:!1}))},2e3),f({title:"Path copied!",description:`Copied ${p} to clipboard`})}catch(l){console.error("Failed to copy path:",l),f({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},C=h.useCallback(async({payload:s})=>{let p=!1;j(!0);try{const l=await fetch(`${E}/api/v1/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s.name,description:s.description,content:s.content,metadata:s.metadata,...s.archiveUrl?{archiveUrl:s.archiveUrl}:{}})});let u=null;try{u=await l.json()}catch(A){console.error("Failed to parse registry import response:",A)}if(!(l.ok&&u?.success)){const R=(typeof u?.error=="string"?u.error:u?.error?.message)||l.statusText||"Failed to import skill from registry";throw f({title:"Failed to import skill",description:R,variant:"destructive"}),p=!0,new Error(R)}f({title:"Skill imported",description:`${s.name} is now available in Coconut`}),await c()}catch(l){if(!p){const u=l instanceof Error&&l.message?l.message:"Failed to import skill from registry";f({title:"Failed to import skill",description:u,variant:"destructive"})}throw l}finally{j(!1)}},[c,f]);return i?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(B,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading skills..."})]})})})}):t.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Skills"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage skills for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:x,children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(v,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(F,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(L,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Skills Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Specialized skills help you automate your development and business workflows."})]})})})]}),e.jsx(M,{open:o,onOpenChange:m,onImport:C})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Skills"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage skills for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:x,children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(v,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(F,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx("div",{className:"grid gap-4",children:t.map(s=>{const p=s.metadata?.color||"blue";return e.jsx(y,{to:`/skills/${s.id}`,className:"block",children:e.jsxs(N,{className:"group hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:[e.jsx(K,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"text-lg",children:s.name}),e.jsx(v,{variant:"ghost",size:"sm",onClick:l=>{l.preventDefault(),S(s.id)},className:"h-6 w-6 p-0 hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy file path to clipboard",children:r[s.id]?e.jsx(U,{className:"w-3 h-3 text-green-600"}):e.jsx(D,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono bg-muted/50 px-2 py-1 rounded inline-block cursor-pointer hover:bg-muted/70 transition-colors",onClick:l=>{l.preventDefault(),S(s.id)},title:"Click to copy file path to clipboard",children:[".nut/skills/",s.id,"/SKILL.md"]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(G,{className:"w-3 h-3"}),p]}),s.allowedTools&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(L,{className:"w-3 h-3"}),s.allowedTools]})]})]}),e.jsx(b,{variant:"outline",className:"capitalize border-2",style:{backgroundColor:g[p]?.bg||g.blue.bg,color:g[p]?.text||g.blue.text,borderColor:g[p]?.border||g.blue.border},children:p})]})}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.description})})})})]})},s.id)})})]}),e.jsx(M,{open:o,onOpenChange:m,onImport:C})]})}export{le as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as U,a as J,r as i,j as e,B as r,T as S,p as K,X as L,x as H,a4 as G}from"./index-9Tv-j_Ga.js";import{C as f,a as W}from"./card-SN5gKnu7.js";import{u as X}from"./use-terminal-BG5UXuVE.js";import{T as _}from"./terminal-preview-uuKF9_x4.js";/* empty css */import{R as q}from"./refresh-cw-BFZxHqbC.js";import{C as Q,a as V}from"./chevrons-up-TXwQuoUN.js";import{C as Y}from"./chevron-up-CHdIiLxL.js";import{P as M}from"./play-DF_Qeu0H.js";import{C as Z}from"./circle-play-7EXFLo4F.js";import"./xterm-DTxiCjtJ.js";function he(){const m=U(),{sessions:p,loading:o,error:k,refreshSessions:h,createSession:j,destroySession:B}=X(),{toast:l}=J(),[x,u]=i.useState(""),[g,T]=i.useState(!1),[v,I]=i.useState(!1),[N,$]=i.useState([]),[,w]=i.useState(null),O=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const b=Math.floor(n/60);if(b<60)return`${b}m ago`;const 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)&&(l({title:"New terminal started",description:`${s}`}),m(`/terminal/${s}`))},E=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;T(!0);try{await j(t,s)?(D(s),l({title:"Session started",description:`${t}`}),m(`/terminal/${t}`)):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{T(!1)}},A=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;I(!0);try{await j(t,s)?(D(s),setTimeout(()=>h(),150),u(""),l({title:"Started in background",description:`${t}`,action:e.jsx(G,{altText:"Open session",onClick:()=>m(`/terminal/${t}`),children:"Open"})})):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{I(!1)}},P=async s=>{await B(s)?(l({title:"Session closed",description:s}),setTimeout(()=>h(),100)):l({title:"Failed to close session",description:s,variant:"destructive"})},F=()=>{const s=c.every(a=>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(q,{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(Q,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{onClick:R,disabled: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(Y,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"})}),e.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(`/terminal/${s.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(L,{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(_,{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{he as default};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{c as Ve,j as e,B as v,a5 as Me,a6 as We,a7 as Le,a8 as Re,a9 as Be,aa as Xe,s as de,r as a,ab as Qe,E as et,v as tt,u as rt,z as st,a as at,l as ve,T as ye,X as je,P as we,k as Ne,m as nt,ac as ze,G as it,D as ct,b as ot,d as lt,f as dt,p as De,ad as Fe,ae as mt,A as me}from"./index-9Tv-j_Ga.js";import{C as ut,a as ht}from"./card-SN5gKnu7.js";import{B as Je}from"./badge-AwLOflf5.js";import{S as ke,a as Se,b as Ce,c as Ae,d as V}from"./select-Cs5qtMYV.js";import{R as xt,a as Te}from"./radio-group-DYTbywtK.js";import{C as gt}from"./CollapsibleSection-Bt_ZLnJc.js";import{L as ge}from"./label-TGqbNfMO.js";import{u as ft}from"./use-terminal-BG5UXuVE.js";import{x as pt,a as bt}from"./xterm-DTxiCjtJ.js";import{A as vt}from"./arrow-down-BZnfbld8.js";/* empty css */import{b as Ue,a as yt,c as jt,d as wt}from"./droid-CPteN3f9.js";import{R as Nt}from"./refresh-cw-BFZxHqbC.js";import{P as Ee}from"./play-DF_Qeu0H.js";import{E as kt}from"./eye-DYnjJzdb.js";import{Z as St}from"./zap-h9QOsasv.js";import"./chevron-up-CHdIiLxL.js";/**
|
|
2
|
-
* @license lucide-react v0.542.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Ct=[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],At=Ve("book-marked",Ct);/**
|
|
7
|
-
* @license lucide-react v0.542.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Tt=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Et=Ve("message-square",Tt);var Pe={exports:{}},Ge;function Pt(){return Ge||(Ge=1,(function(r,T){(function(P,C){r.exports=C()})(self,(()=>(()=>{var P={6:(d,o)=>{function f(m){try{const n=new URL(m),l=n.password&&n.username?`${n.protocol}//${n.username}:${n.password}@${n.host}`:n.username?`${n.protocol}//${n.username}@${n.host}`:`${n.protocol}//${n.host}`;return m.toLocaleLowerCase().startsWith(l.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(o,"__esModule",{value:!0}),o.LinkComputer=o.WebLinkProvider=void 0,o.WebLinkProvider=class{constructor(m,n,l,h={}){this._terminal=m,this._regex=n,this._handler=l,this._options=h}provideLinks(m,n){const l=_.computeLink(m,this._regex,this._terminal,this._handler);n(this._addCallbacks(l))}_addCallbacks(m){return m.map((n=>(n.leave=this._options.leave,n.hover=(l,h)=>{if(this._options.hover){const{range:x}=n;this._options.hover(l,h,x)}},n)))}};class _{static computeLink(n,l,h,x){const z=new RegExp(l.source,(l.flags||"")+"g"),[N,g]=_._getWindowedLineStrings(n-1,h),y=N.join("");let u;const E=[];for(;u=z.exec(y);){const p=u[0];if(!f(p))continue;const[O,j]=_._mapStrIdx(h,g,0,u.index),[Y,q]=_._mapStrIdx(h,O,j,p.length);if(O===-1||j===-1||Y===-1||q===-1)continue;const ee={start:{x:j+1,y:O+1},end:{x:q,y:Y+1}};E.push({range:ee,text:p,activate:x})}return E}static _getWindowedLineStrings(n,l){let h,x=n,z=n,N=0,g="";const y=[];if(h=l.buffer.active.getLine(n)){const u=h.translateToString(!0);if(h.isWrapped&&u[0]!==" "){for(N=0;(h=l.buffer.active.getLine(--x))&&N<2048&&(g=h.translateToString(!0),N+=g.length,y.push(g),h.isWrapped&&g.indexOf(" ")===-1););y.reverse()}for(y.push(u),N=0;(h=l.buffer.active.getLine(++z))&&h.isWrapped&&N<2048&&(g=h.translateToString(!0),N+=g.length,y.push(g),g.indexOf(" ")===-1););}return[y,x]}static _mapStrIdx(n,l,h,x){const z=n.buffer.active,N=z.getNullCell();let g=h;for(;x;){const y=z.getLine(l);if(!y)return[-1,-1];for(let u=g;u<y.length;++u){y.getCell(u,N);const E=N.getChars();if(N.getWidth()&&(x-=E.length||1,u===y.length-1&&E==="")){const p=z.getLine(l+1);p&&p.isWrapped&&(p.getCell(0,N),N.getWidth()===2&&(x+=1))}if(x<0)return[l,u]}l++,g=0}return[l,g]}}o.LinkComputer=_}},C={};function A(d){var o=C[d];if(o!==void 0)return o.exports;var f=C[d]={exports:{}};return P[d](f,f.exports,A),f.exports}var M={};return(()=>{var d=M;Object.defineProperty(d,"__esModule",{value:!0}),d.WebLinksAddon=void 0;const o=A(6),f=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function _(m,n){const l=window.open();if(l){try{l.opener=null}catch{}l.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}d.WebLinksAddon=class{constructor(m=_,n={}){this._handler=m,this._options=n}activate(m){this._terminal=m;const n=this._options,l=n.urlRegex||f;this._linkProvider=this._terminal.registerLinkProvider(new o.WebLinkProvider(this._terminal,l,this._handler,n))}dispose(){this._linkProvider?.dispose()}}})(),M})()))})(Pe)),Pe.exports}var Mt=Pt();const Wt=[{label:"Save to knowledge base",command:"Save this to the knowledge base (.nut/knowledge/) using the following schema as reference .nut/.schema/knowledge.schema.md",description:"Save content to knowledge base with schema reference"},{label:"Update project document",command:"Update the project document (.nut/context/project.md) using the following schema as reference .nut/.schema/project.schema.md",description:"Update project.md using schema reference"},{label:"Update architecture document",command:"Update the architecture document (.nut/context/architecture.md) using the following schema as reference .nut/.schema/architecture.schema.md",description:"Update architecture.md using schema reference"}];function Lt({onJumpToBottom:r,onSnippet:T,onSendKey:P}){return e.jsxs("div",{className:"w-full border-t border-gray-700/50 bg-[#252525] px-4 py-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsxs(v,{variant:"outline",size:"sm",onClick:r,className:"h-8 text-xs bg-[#2d2d2d] border-gray-600 hover:bg-[#3d3d3d] text-gray-200 hover:text-white transition-colors",title:"Jump to bottom and set focus",children:[e.jsx(vt,{className:"h-3.5 w-3.5 sm:mr-1.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Jump to Bottom"})]}),T&&e.jsxs(Me,{children:[e.jsx(We,{asChild:!0,children:e.jsxs(v,{variant:"outline",size:"sm",className:"h-8 text-xs bg-[#2d2d2d] border-gray-600 hover:bg-[#3d3d3d] text-gray-200 hover:text-white transition-colors",children:[e.jsx(At,{className:"h-3.5 w-3.5 sm:mr-1.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Snippets"})]})}),e.jsxs(Le,{align:"start",className:"w-72",children:[e.jsx(Re,{children:"Command Snippets"}),e.jsx(Be,{}),Wt.map((C,A)=>e.jsxs(Xe,{onClick:()=>T(C.command),className:"cursor-pointer flex flex-col items-start py-2",children:[e.jsx("span",{className:"font-medium",children:C.label}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono mt-0.5",children:C.command})]},A))]})]})]}),P&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>P(""),className:"h-8 px-2 flex items-center gap-1 rounded-md bg-[#2d2d2d] border border-gray-600 hover:bg-red-900/40 hover:border-red-700 text-gray-200 hover:text-red-300 transition-colors",title:"Send Ctrl+C (interrupt)",children:[e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"⌃"}),e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"C"})]}),e.jsxs("button",{onClick:()=>P(""),className:"h-8 px-2 flex items-center gap-1 rounded-md bg-[#2d2d2d] border border-gray-600 hover:bg-[#3d3d3d] hover:border-gray-500 text-gray-200 hover:text-white transition-colors",title:"Send Ctrl+Z (suspend)",children:[e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"⌃"}),e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"Z"})]}),e.jsx("button",{onClick:()=>P("\x1B"),className:"h-8 px-2 flex items-center gap-1 rounded-md bg-[#2d2d2d] border border-gray-600 hover:bg-[#3d3d3d] hover:border-gray-500 text-gray-200 hover:text-white transition-colors",title:"Send Escape key",children:e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"Esc"})})]})]})}function Rt({sessionId:r,onResize:T,onDestroy:P,pendingCommand:C,onCommandExecuted:A,showToolbar:M=!0,onSnippet:d}){const o=a.useRef(null),f=a.useRef(null),_=a.useRef(null),m=a.useRef(null),[n,l]=a.useState(!1),[h,x]=a.useState(null),[z,N]=a.useState(!0),g=a.useRef(0),y=5,u=a.useRef(null),E=a.useRef(null),p=a.useRef(C??null),O=a.useRef(!1),j=a.useRef(null),Y=a.useRef(A),q=a.useRef(P),ee=a.useRef(T);a.useEffect(()=>{Y.current=A},[A]),a.useEffect(()=>{q.current=P},[P]),a.useEffect(()=>{ee.current=T},[T]);const te=a.useCallback(k=>{!p.current||O.current||(j.current!==null&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>{if(!p.current||O.current){j.current=null;return}m.current?.readyState===WebSocket.OPEN&&(m.current.send(JSON.stringify({type:"input",data:p.current+"\r"})),O.current=!0,Y.current?.()),j.current=null},k))},[]);a.useEffect(()=>{if(p.current=C??null,O.current=!1,!p.current){j.current!==null&&(window.clearTimeout(j.current),j.current=null);return}const k=m.current?.readyState===WebSocket.OPEN;return te(k?200:800),()=>{j.current!==null&&(window.clearTimeout(j.current),j.current=null)}},[C,r,te]),a.useEffect(()=>{l(!1),N(!0),x(null)},[r]),a.useEffect(()=>{if(!o.current||!r)return;const k=S=>{const b=S.getBoundingClientRect();return b.width>0&&b.height>0},W=new pt.Terminal({cursorBlink:!0,fontSize:14,fontFamily:"'IBM Plex Mono', 'Source Code Pro', 'Fira Code', ui-monospace, Menlo, Monaco, monospace",lineHeight:1.35,letterSpacing:.5,convertEol:!0,theme:{background:"#1a1b26",foreground:"#c0caf5",cursor:"#c0caf5",cursorAccent:"#1a1b26",selectionBackground:"#33467c",selectionForeground:"#c0caf5",black:"#15161e",red:"#f7768e",green:"#9ece6a",yellow:"#e0af68",blue:"#7aa2f7",magenta:"#bb9af7",cyan:"#7dcfff",white:"#a9b1d6",brightBlack:"#414868",brightRed:"#f7768e",brightGreen:"#9ece6a",brightYellow:"#e0af68",brightBlue:"#7aa2f7",brightMagenta:"#bb9af7",brightCyan:"#7dcfff",brightWhite:"#c0caf5"}}),B=new bt.FitAddon,K=new Mt.WebLinksAddon;W.loadAddon(B),W.loadAddon(K),W.open(o.current),f.current=W,_.current=B;let L=null,X=null;const R=()=>{if(!W||!W.element||!W.element.parentElement)return;const S=W.cols??0,b=W.rows??0;if(S>0&&b>0){m.current?.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:S,rows:b}));const I=ee.current;I&&I(S,b)}},H=()=>{const S=o.current;if(S&&k(S)&&!(!W||!W.element||!W.element.parentElement))try{const b=S.getBoundingClientRect();if(b.width<10||b.height<10)return;B.fit(),R()}catch(b){console.warn("xterm fit() failed, will retry if needed:",b)}},F=()=>{L&&cancelAnimationFrame(L),L=requestAnimationFrame(()=>{H()})},ce=()=>{if(!r)return;u.current&&(window.clearTimeout(u.current),u.current=null);const S=`${Qe}/ws/terminal/${r}`,b=new WebSocket(S);return m.current=b,b.onopen=()=>{l(!0),x(null),g.current=0,console.log("Terminal WebSocket connected"),E.current&&window.clearInterval(E.current),E.current=window.setInterval(()=>{b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"keepalive"}))},120*1e3),F(),setTimeout(()=>{N(!1),F(),setTimeout(()=>F(),50),setTimeout(()=>F(),150)},400),te(1200)},b.onmessage=I=>{try{const w=JSON.parse(I.data);switch(w.type){case"snapshot":if(typeof w.data=="string"&&w.data.length&&f.current){const J=f.current;J.write(w.data,()=>{J.scrollToBottom()})}break;case"data":if(f.current){const J=f.current,ae=J.buffer.active.viewportY+J.rows>=J.buffer.active.baseY+J.buffer.active.cursorY;J.write(w.data,()=>{ae&&J.scrollToBottom()})}break;case"exit":f.current&&f.current.write(`\r
|
|
12
|
-
\x1B[31mProcess exited with code ${w.exitCode}\x1B[0m\r
|
|
13
|
-
`),q.current?.();break}}catch(w){console.error("Error parsing WebSocket message:",w)}},b.onclose=I=>{if(l(!1),console.log("Terminal WebSocket disconnected",I.code,I.reason),E.current&&(window.clearInterval(E.current),E.current=null),I.code!==1e3&&g.current<y&&r){g.current++;const w=Math.min(1e3*Math.pow(2,g.current-1),1e4);console.log(`Attempting to reconnect (${g.current}/${y}) in ${w}ms`),u.current=window.setTimeout(()=>{ce()},w)}else g.current>=y&&x("Connection lost. Please refresh the page to reconnect.")},b.onerror=I=>{console.error("Terminal WebSocket error:",I),g.current===0&&x("WebSocket connection failed")},b};ce(),W.onData(S=>{m.current?.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:S}))});const $=()=>{F()},oe=new ResizeObserver($);o.current&&oe.observe(o.current),window.addEventListener("resize",$),window.addEventListener("orientationchange",$);const se=()=>{document.visibilityState==="visible"&&(X&&clearTimeout(X),X=window.setTimeout(()=>{F()},50))};document.addEventListener("visibilitychange",se);let he=0;const Oe=20,xe=()=>{const S=o.current;if(S){if(k(S)){H();return}he+=1,he<Oe?L=requestAnimationFrame(xe):X=window.setTimeout(()=>{H()},100)}};return L=requestAnimationFrame(xe),()=>{oe.disconnect(),window.removeEventListener("resize",$),window.removeEventListener("orientationchange",$),document.removeEventListener("visibilitychange",se),L&&cancelAnimationFrame(L),X&&clearTimeout(X),u.current&&(window.clearTimeout(u.current),u.current=null),E.current&&(window.clearInterval(E.current),E.current=null),m.current?.readyState===WebSocket.OPEN&&m.current.close(),j.current!==null&&(window.clearTimeout(j.current),j.current=null),W.dispose()}},[r,te]);const re=a.useCallback(()=>{f.current&&(f.current.scrollToBottom(),f.current.focus())},[]),D=a.useCallback(k=>{m.current?.readyState===WebSocket.OPEN&&(m.current.send(JSON.stringify({type:"input",data:k})),f.current&&f.current.focus())},[]),ue=a.useCallback(k=>{m.current?.readyState===WebSocket.OPEN&&(m.current.send(JSON.stringify({type:"input",data:k})),f.current&&f.current.focus())},[]);return h?e.jsx("div",{className:"flex items-center justify-center h-full bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-red-600 font-medium",children:"Terminal Connection Error"}),e.jsx("div",{className:"text-red-500 text-sm mt-1",children:h})]})}):e.jsxs("div",{className:"relative h-full flex flex-col bg-[#1a1b26] overflow-hidden",children:[!n&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#1a1b26] bg-opacity-95 z-10 backdrop-blur-sm",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto"}),e.jsx("div",{className:"text-gray-300 mt-2",children:"Connecting to terminal..."})]})}),n&&z&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#1a1b26] bg-opacity-50 z-10 transition-opacity duration-300 backdrop-blur-sm",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-pulse rounded-full h-6 w-6 bg-blue-500 mx-auto"}),e.jsx("div",{className:"text-gray-300 text-sm mt-2",children:"Loading terminal..."})]})}),e.jsx("div",{ref:o,className:"flex-1 w-full overflow-hidden",style:{minHeight:"400px"}}),M&&e.jsx(Lt,{onJumpToBottom:re,onSnippet:d||D,onSendKey:ue})]})}const Bt=r=>r?Array.isArray(r)?r.filter(T=>typeof T=="string").map(T=>T.trim()).filter(Boolean):typeof r=="string"?r.split(",").map(T=>T.trim()).filter(Boolean):[]:[];function er(){const{proposalId:r}=et(),T=tt(),P=rt(),[C]=st(),{toast:A}=at(),M=r?.startsWith("session-"),d=a.useMemo(()=>!!r&&r.startsWith("cp-"),[r]),o=a.useMemo(()=>!!r&&r.startsWith("sk-"),[r]),f=C.get("reviewOnly")==="true",_=C.get("startOnly")==="true",m=d&&!_,n=!f,l=a.useMemo(()=>o&&r?r.replace("sk-",""):null,[o,r]),{sessions:h,loading:x,error:z,createSession:N,destroySession:g,refreshSessions:y}=ft(),[u,E]=a.useState([]),[p,O]=a.useState(null),[j,Y]=a.useState(null),[q,ee]=a.useState("claude"),[te,re]=a.useState(!1),[D,ue]=a.useState("claude"),[k,W]=a.useState([]),[B,K]=a.useState([]),[L,X]=a.useState([]),[R,H]=a.useState([]),[F,ce]=a.useState(!0),[$,oe]=a.useState(""),[se,he]=a.useState(!1),[Oe,xe]=a.useState({}),[S,b]=a.useState(null),I=a.useRef([]),[w,J]=a.useState("current"),[ae,qe]=a.useState("main"),Q=a.useMemo(()=>r?`terminal.cp.config.${r}`:null,[r]);a.useEffect(()=>{if(!(!d&&!o||!Q))try{const t=localStorage.getItem(Q);if(t){const s=JSON.parse(t);s.cliAgent&&ue(s.cliAgent),Array.isArray(s.selectedMcpServers)&&K(s.selectedMcpServers),Array.isArray(s.selectedSkillIds)&&H(s.selectedSkillIds),typeof s.automationEnabled=="boolean"&&ce(s.automationEnabled),typeof s.customInstruction=="string"&&oe(s.customInstruction),typeof s.createWorktree=="boolean"&&he(s.createWorktree),s.branchMode&&J(s.branchMode)}}catch{console.error("Failed to load config",Q)}},[d,o,Q]);const fe=a.useCallback(()=>{if(!Q)return;const t={cliAgent:D,selectedMcpServers:B,selectedSkillIds:R,automationEnabled:F,customInstruction:$,createWorktree:se,branchMode:w};try{localStorage.setItem(Q,JSON.stringify(t))}catch{console.error("Failed to persist config",Q)}},[Q,D,B,R,F,$,se,w]);a.useEffect(()=>{fe()},[$,fe]);const ne=t=>`feat/cp-${t.startsWith("cp-")?t.slice(3):t}`,He=async t=>{try{const s=ne(t),c=await(await fetch(`${me}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,from:ae})})).json();if(!c.success){const U=c.error?.message||"Unknown error";return A({title:"Branch creation failed",description:U,variant:"destructive"}),!1}return A({title:"Branch created",description:`Created branch: ${s}`}),!0}catch{return A({title:"Branch creation failed",description:"Network error or invalid response",variant:"destructive"}),!1}},$e=async t=>{try{const s=ne(t),c=await(await fetch(`${me}/api/v1/git/worktrees`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:s,from:ae})})).json();if(!c.success){const U=c.error?.message||"Unknown error";return A({title:"Worktree creation failed",description:U,variant:"destructive"}),!1}return A({title:"Worktree created",description:`Created branch: ${s}`}),!0}catch{return A({title:"Worktree creation failed",description:"Network error or invalid response",variant:"destructive"}),!1}};a.useEffect(()=>{(d||o)&&r&&(async()=>{try{const s=await fetch(`${me}/api/v1/git/status`);if(s.ok){const c=await s.json();c?.success&&c.data?.branch&&qe(c.data.branch)}const i=await fetch(`${me}/api/v1/mcp`);if(i.ok){const c=await i.json();c?.success&&Array.isArray(c.servers)&&(W(c.servers),K(U=>U.filter(G=>c.servers.includes(G))),c.mcpServers&&typeof c.mcpServers=="object"&&xe(c.mcpServers))}}catch(s){console.error("Failed to load MCP servers",s)}try{const s=await fetch(`${me}/api/v1/skills`);if(s.ok){const i=await s.json(),U=(Array.isArray(i?.documents)?i.documents:[]).map(G=>({id:G.id,name:G?.metadata?.name||G.id,mcpServers:Bt(G?.metadata?.metadata?.mcpServers)}));X(U),H(G=>{const le=G.filter(Z=>U.some(be=>be.id===Z));if(o&&l&&le.length===0){const Z=U.find(be=>be.id===l);if(Z)return[Z.id]}return le})}}catch(s){console.error("Failed to load skills",s)}})()},[d,o,r,l]),a.useEffect(()=>{const t=I.current,s=R.filter(i=>!t.includes(i));s.length>0&&K(i=>{const c=new Set(i),U=k.length>0?new Set(k):void 0;return s.forEach(G=>{const le=L.find(Z=>Z.id===G);le&&le.mcpServers.forEach(Z=>{(!U||U.has(Z))&&c.add(Z)})}),Array.from(c)}),I.current=R},[R,L,k]),a.useEffect(()=>{r&&y(r)},[r,y]),a.useEffect(()=>{if(!r)return;const s=h.filter(i=>i.proposalId===r).map(i=>i.id);E(s),!p&&s.length>0&&O(s[0]),p&&!s.includes(p)&&O(s.length>0?s[0]:null)},[h,r,p]);const ie=async t=>{if(!r)return;const s=t||void 0,i=await N(r,s);i&&(O(i),!s&&t&&Y(t),setTimeout(()=>y(r),100))},Ie=(t,s)=>{const c={proposalId:r,contextType:s??(d?"change-proposal":o?"skill":"general"),selectedMcpServers:B,selectedSkillIds:R,automationEnabled:F,customInstruction:$};switch(t){case"claude":return Ue(c);case"gemini":return wt(c);case"codex":return jt(c);case"droid":return yt(c);default:return Ue(c)}},pe=async()=>{d&&r&&(w==="new-branch"?await He(r)||console.warn("Branch creation failed, continuing with terminal creation"):w==="new-worktree"&&(await $e(r)||console.warn("Worktree creation failed, continuing with terminal creation"))),d&&se&&w==="current"&&r&&(await $e(r)||console.warn("Worktree creation failed, continuing with terminal creation"));const s=Ie(d||o?D:q);await ie(s)},Ze=async()=>{const s=Ie(D,"prepare-proposal");await ie(s)},_e=async t=>{if(await g(t)&&p===t){const i=u.filter(c=>c!==t);O(i.length>0?i[0]:null)}},Ye=t=>{_e(t)},Ke=async()=>{for(const t of u)await g(t);P("/agents")};return r?e.jsxs("div",{className:"flex flex-col h-full",children:[M&&u.length===0&&r&&e.jsx(Ot,{proposalId:r,onStart:ie,locationSearch:T.search}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-lg",children:d||o?e.jsx(ve,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(ye,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:M?"Terminal":"Agent Session"}),!M&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 font-mono",children:r}),M&&e.jsxs("span",{className:"text-sm text-gray-500 font-mono",children:["(",r,")"]})]})]})}),e.jsx("div",{className:"flex items-center gap-2 sm:gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>r&&y(r),disabled:x,className:"bg-white dark:bg-gray-800",children:[e.jsx(Nt,{className:`h-4 w-4 sm:mr-2 ${x?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),e.jsx(v,{size:"sm",variant:"destructive",onClick:Ke,title:"Close session","aria-label":"Close session",className:"h-9 w-9 p-0",children:e.jsx(je,{className:"h-4 w-4"})}),!M&&!d&&!o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ke,{value:q,onValueChange:ee,children:[e.jsx(Se,{className:"w-24",children:e.jsx(Ce,{})}),e.jsxs(Ae,{children:[e.jsx(V,{value:"claude",children:"Claude Code"}),e.jsx(V,{value:"gemini",children:"Google Gemini"}),e.jsx(V,{value:"codex",children:"OpenAI Codex"})]})]}),e.jsxs(v,{onClick:pe,disabled:x,size:"sm",variant:"default",className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Ee,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Start Agent"})]})]}),!d&&!o&&(!M||u.length===0)&&e.jsxs(v,{onClick:()=>ie(),disabled:x,size:"sm",children:[e.jsx(we,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"New Terminal"})]})]})})]}),z&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-1.5 bg-red-100 dark:bg-red-900/40 rounded-lg flex-shrink-0",children:e.jsx(je,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),e.jsx("div",{className:"text-red-800 dark:text-red-200 text-sm font-medium",children:z})]})}),u.length>0&&e.jsx("div",{className:"flex items-center gap-1 border-b dark:border-gray-700",children:u.map(t=>{const s=h.find(c=>c.id===t),i=p===t;return e.jsxs("div",{className:`flex items-center gap-2 px-4 py-3 border-b-1 cursor-pointer rounded-t-lg transition-all duration-200 ${i?"border-gray-400 bg-white dark:bg-gray-800 dark:border-gray-500 shadow-sm":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800 hover:border-gray-300"}`,onClick:()=>O(t),children:[e.jsx("div",{className:`p-1.5 rounded-md ${i?"bg-gray-200 dark:bg-gray-700":"bg-gray-100 dark:bg-gray-700"}`,children:e.jsx(ye,{className:`h-3.5 w-3.5 ${i?"text-gray-700 dark:text-gray-300":"text-gray-600 dark:text-gray-400"}`})}),e.jsxs("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["Terminal ",t.split("-").slice(-1)[0].substring(0,6)]}),e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${s?.connected?"bg-green-500":"bg-gray-400"}`}),e.jsx(v,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-red-100 dark:hover:bg-red-900/30 rounded-md opacity-60 hover:opacity-100 transition-opacity",onClick:c=>{c.stopPropagation(),_e(t)},children:e.jsx(je,{className:"h-3 w-3"})})]},t)})}),e.jsx("div",{className:"flex-1 min-h-0",children:u.length===0?e.jsx(ut,{className:"h-full",children:e.jsx(ht,{className:"flex items-center justify-center h-full p-8",children:e.jsxs("div",{className:"text-center w-full max-w-[33vw] min-w-[400px]",children:[e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-full w-fit mx-auto mb-2",children:d||o?e.jsx(Ne,{className:"h-8 w-8 text-gray-600 dark:text-gray-400"}):e.jsx(ye,{className:"h-8 w-8 text-gray-600 dark:text-gray-400"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100 mb-3",children:"Prepare Agent"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6 leading-relaxed",children:M?"Create a new terminal session":e.jsxs(e.Fragment,{children:["Configure the agent to start working on ",r,"."]})}),e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[!M&&!d&&!o&&e.jsxs("div",{className:"flex flex-col items-center gap-4 p-6 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900 w-full",children:[e.jsxs("div",{className:"w-full space-y-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Choose your AI agent"}),e.jsxs(ke,{value:q,onValueChange:ee,children:[e.jsx(Se,{className:"w-full h-11 bg-white dark:bg-gray-800",children:e.jsx(Ce,{})}),e.jsxs(Ae,{children:[e.jsx(V,{value:"claude",children:"Claude Code (default)"}),e.jsx(V,{value:"gemini",children:"Google Gemini"}),e.jsx(V,{value:"codex",children:"OpenAI Codex"})]})]})]}),e.jsxs(v,{onClick:pe,disabled:x,className:"bg-green-600 hover:bg-green-700 w-full h-11 text-base font-medium",size:"lg",children:[e.jsx(Ee,{className:"h-5 w-5 mr-2"}),"Start Agent"]}),e.jsxs("div",{className:"flex items-center gap-3 w-full",children:[e.jsx("div",{className:"flex-1 h-px bg-gray-300 dark:bg-gray-600"}),e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 font-medium",children:"or"}),e.jsx("div",{className:"flex-1 h-px bg-gray-300 dark:bg-gray-600"})]}),e.jsxs(v,{onClick:()=>ie(),disabled:x,variant:"outline",className:"w-full h-11 bg-white dark:bg-gray-800",size:"lg",children:[e.jsx(we,{className:"h-5 w-5 mr-2"}),"New Terminal"]})]}),!M&&(d||o)&&e.jsxs("div",{className:"flex flex-col items-center gap-4 p-6 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900 w-full",children:[m&&e.jsxs(v,{onClick:Ze,disabled:x,className:"w-full bg-blue-600 hover:bg-blue-700 h-11 text-base font-medium",size:"lg",children:[e.jsx(kt,{className:"h-5 w-5 mr-2"}),"Review & Prepare"]}),e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsxs(v,{variant:"outline",onClick:()=>re(!0),className:"flex-1 h-11 bg-white dark:bg-gray-800",size:"lg",children:[e.jsx(nt,{className:"h-5 w-5 mr-2"}),"Configure"]}),n&&e.jsxs(v,{onClick:pe,disabled:x,className:"flex-1 bg-green-600 hover:bg-green-700 h-11 text-base font-medium",size:"lg",children:[e.jsx(Ee,{className:"h-5 w-5 mr-2"}),"Start Agent"]})]}),e.jsxs("div",{className:"w-full space-y-3",children:[e.jsx("div",{className:"text-xs uppercase font-semibold text-gray-500 dark:text-gray-400",children:"Agent Configuration"}),e.jsxs("div",{className:"text-left text-sm text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Agent:"}),e.jsx("span",{className:"font-mono text-sm",children:D==="claude"?"Claude Code":D.charAt(0).toUpperCase()+D.slice(1)})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ve,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400 mt-0.5"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Skills:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:R.length?R.map(t=>{const s=L.find(i=>i.id===t);return e.jsx(Je,{variant:"secondary",className:"font-mono text-xs",children:s?.name||t},t)}):e.jsx("span",{className:"font-mono text-sm text-gray-500",children:"None"})})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ze,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400 mt-0.5"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"MCP Servers:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:B.length?B.map(t=>e.jsx(Je,{variant:"secondary",className:"font-mono text-xs",children:t},t)):e.jsx("span",{className:"font-mono text-sm text-gray-500",children:"None"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(St,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Full Environment Access:"}),e.jsx("span",{className:"font-mono text-sm",children:F?"Enabled":"Disabled"})]}),d&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(it,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Branch:"}),e.jsx("span",{className:"font-mono text-sm",children:w==="current"?`Current (${ae})`:w==="new-branch"?`New branch (${ne(r||"")})`:`New worktree (${ne(r||"")})`})]})]}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2 text-gray-700 dark:text-gray-300",children:[e.jsx(Et,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),"Additional Instructions"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[$.length,"/500"]})]}),e.jsx("textarea",{className:"w-full min-h-[80px] rounded-md border p-3 text-sm bg-gray-50 dark:bg-gray-900/50 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 resize-none",placeholder:"Add specific instructions to guide the agent...",value:$,onChange:t=>oe(t.target.value),rows:3}),$.length>500&&e.jsx("div",{className:"text-xs text-red-600 mt-1",children:"Custom instruction is too long (max 500 characters)"})]})]})]}),M&&u.length===0&&e.jsx("div",{className:"p-6 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900 w-full",children:e.jsxs(v,{onClick:()=>ie(),disabled:x,className:"w-full h-11 text-base font-medium",size:"lg",children:[e.jsx(we,{className:"h-5 w-5 mr-2"}),"New Terminal"]})})]})]})})}):p?e.jsx("div",{className:"h-full overflow-hidden rounded-b-lg",children:e.jsx(Rt,{sessionId:p,onDestroy:()=>Ye(p),pendingCommand:j,onCommandExecuted:()=>Y(null),showToolbar:!0})}):null}),e.jsx(ct,{open:te,onOpenChange:re,children:e.jsxs(ot,{className:"max-w-3xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(lt,{children:[e.jsx(dt,{children:"Configure Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Customize the agent's capabilities and configure it's environment."})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),"Agent"]}),e.jsxs(ke,{value:D,onValueChange:t=>ue(t),children:[e.jsx(Se,{className:"w-full",children:e.jsx(Ce,{placeholder:"Select agent"})}),e.jsxs(Ae,{children:[e.jsx(V,{value:"claude",children:"Claude Code"}),e.jsx(V,{value:"gemini",children:"Google Gemini"}),e.jsx(V,{value:"codex",children:"OpenAI Codex"}),e.jsx(V,{value:"droid",children:"Factory Droid"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4"}),"Skills"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[R.length," of ",L.length," selected"]})]}),e.jsxs(Me,{children:[e.jsx(We,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:"w-full justify-between",children:[R.length===0?"Select skills...":R.length===L.length?"All skills selected":`${R.length} skill${R.length!==1?"s":""} selected`,e.jsx(De,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Le,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Skills"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(v,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),H(L.map(s=>s.id))},children:"All"}),e.jsx(v,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),H([])},children:"None"})]})]}),e.jsx(Be,{}),L.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No skills found"}):L.map(t=>e.jsx(Fe,{checked:R.includes(t.id),onCheckedChange:s=>{H(i=>s?i.includes(t.id)?i:[...i,t.id]:i.filter(c=>c!==t.id))},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:t.name}),t.mcpServers.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP servers: ",t.mcpServers.join(", ")]}),t.mcpServers.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inherits available MCP servers"})]})},t.id))]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ze,{className:"h-4 w-4"}),"MCP Servers"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[B.length," of ",k.length," selected"]})]}),e.jsxs(Me,{children:[e.jsx(We,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:"w-full justify-between",children:[B.length===0?"Select MCP servers...":B.length===k.length?"All servers selected":`${B.length} server${B.length!==1?"s":""} selected`,e.jsx(De,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Le,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Servers"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(v,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),K(k)},children:"All"}),e.jsx(v,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),K([])},children:"None"})]})]}),e.jsx(Be,{}),k.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No MCP servers found"}):k.map(t=>e.jsx(Fe,{checked:B.includes(t),onCheckedChange:s=>{K(i=>s?i.includes(t)?i:[...i,t]:i.filter(c=>c!==t))},children:t},t))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-md bg-amber-50/50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800",children:[e.jsx(mt,{id:"automation",checked:F,onCheckedChange:t=>ce(t===!0),className:"data-[state=checked]:bg-red-600 data-[state=checked]:border-red-600 data-[state=checked]:text-white border-red-400",disabled:D==="droid"}),e.jsx("label",{htmlFor:"automation",className:"text-sm font-medium text-red-600 dark:text-red-400 cursor-pointer",children:"Full environment access (recommended in secure environments only)"})]}),D==="droid"&&e.jsxs("p",{className:"text-xs text-muted-foreground px-1",children:[e.jsx("span",{className:"font-medium",children:"Droid:"})," Automation level is set in the REPL. Press ",e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono",children:"shift+tab"})," to cycle through Off → Low → Medium → High."]})]}),d&&e.jsx(gt,{title:"Advanced Settings",description:"Configure branch and worktree options",defaultOpen:!1,children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm font-medium mb-3 block",children:"Branch Management"}),e.jsxs(xt,{value:w,onValueChange:t=>J(t),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Te,{value:"current",id:"branch-current"}),e.jsxs(ge,{htmlFor:"branch-current",className:"cursor-pointer font-normal",children:["Stay on current branch (",e.jsx("code",{className:"text-xs font-mono bg-muted px-1 py-0.5 rounded",children:ae}),")"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Te,{value:"new-branch",id:"branch-new"}),e.jsxs(ge,{htmlFor:"branch-new",className:"cursor-pointer font-normal",children:["Create new branch: ",e.jsx("code",{className:"text-xs font-mono bg-muted px-1 py-0.5 rounded",children:ne(r||"")})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Te,{value:"new-worktree",id:"branch-worktree"}),e.jsxs(ge,{htmlFor:"branch-worktree",className:"cursor-pointer font-normal",children:["Create new worktree: ",e.jsx("code",{className:"text-xs font-mono bg-muted px-1 py-0.5 rounded",children:ne(r||"")})]})]})]})]})})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(v,{variant:"outline",onClick:()=>re(!1),children:"Close"}),e.jsx(v,{onClick:()=>{if($.length>500){b("Please shorten the custom instruction to 500 characters.");return}b(null),fe(),re(!1)},children:"Save"})]}),S&&e.jsx("div",{className:"text-xs text-red-600 text-right",children:S})]})]})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-red-600 font-medium",children:"Invalid Proposal ID"}),e.jsx(v,{onClick:()=>P("/proposals"),className:"mt-4",children:"Back to Proposals"})]})})}function Ot({proposalId:r,onStart:T,locationSearch:P}){return a.useEffect(()=>{if(!r)return;const C=new URLSearchParams(P);if(!C.has("autostart"))return;const A=`terminal.autostart.${r}`;if(sessionStorage.getItem(A)==="done")return;sessionStorage.setItem(A,"done");const d=C.get("run")||void 0;T(d||void 0)},[r]),null}export{er as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as a,a as I,A as S,j as e,a2 as D,B as g,I as p,L as F}from"./index-9Tv-j_Ga.js";import{C as P,b as L,c as z,d as A,a as R}from"./card-SN5gKnu7.js";import{L as c}from"./label-TGqbNfMO.js";import{S as q,a as T,b as M,c as O,d as U}from"./select-Cs5qtMYV.js";import{C as B,a as Q}from"./clipboard-BdymjxLO.js";import"./chevron-up-CHdIiLxL.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 W(){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)window.dispatchEvent(new CustomEvent("config-updated")),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(k=>k.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]),E=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:E,children:[f?e.jsx(B,{className:"h-4 w-4"}):e.jsx(Q,{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(P,{children:[e.jsxs(L,{children:[e.jsx(z,{children:"Coconut Profile"}),e.jsx(A,{children:"Update the Coconut's identifying details and role."})]}),e.jsxs(R,{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(q,{value:n.role,onValueChange:t=>l({role:t}),children:[e.jsx(T,{children:e.jsx(M,{placeholder:"Select role"})}),e.jsx(O,{children:m.map(t=>e.jsx(U,{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(F,{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{W as default};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const m="Use .nut/context/project.md and .nut/context/architecture.md for reference.";function c(e,t,n,s=!0){const o=[];return s&&(o.push(["## Task","","- Review and begin working on the following task proposal:",` .nut/proposals/${e}.md`,"- Retrieve your firstName, lastName, and email address from: .nut/config.json and use this identity to address yourself in any task updates, comments, git commits, etc."].join(`
|
|
2
|
-
`)),o.push(["## Task Lifecycle","",`- Before beginning any work: nut task update ${e} --status active`,`- Add appropriate steps with: nut task step ${e} "Step description" --author "firstName lastName"`,"",`- If you need human clarification or input: nut task update ${e} --status blocked. The clarification can be communicated as follows: nut task comment ${e} "Comments here" --author "firstName lastName". At this point please stop work.`,"",`- When implementation is complete and ready for approval: nut task update ${e} --status review`,`- Only mark the task complete once approval criteria are satisfied: nut task update ${e} --status done`].join(`
|
|
3
|
-
`)),o.push(["## Abilities","","- The following abilities are at your disposal and should be factored into the plan where appropriate (each command has its own --help):"," - Work with knowledge documents (used for the output of any research-centric tasks):",' - nut knowledge create "Quick Note" --content "# Quick Note\\n\\nSome content here"'," - nut knowledge list"," - nut knowledge get example-filename.md",' - nut knowledge update example-filename.md --content "# Quick Note\\n\\nSome content here"'," - Creating media such as images, audio, or video or adding existing files to the resource library:"," - nut resource ls"," - nut resource add ./screenshot.png",' - nut resource image "A serene morning in Tokyo" --save',' - nut resource audio "Welcome to the future" --save'," - Using available skills (specialized, reusable, and portable modules). There is also an official registry you can pull from:"," - nut skill list"," - nut skill registry list","- Similarly, the following are available: git, gh, node, python"].join(`
|
|
4
|
-
`)),o.push(["## Operational Rules","","- DO use the nut CLI to update task status as progress changes"," (nut --help or nut task --help for details)","- DO NOT edit files outside the scope of the approved proposal (unless instructed by the Additional Instructions below)"].join(`
|
|
5
|
-
`))),t.length>0&&o.push(["## Skills","","These skills are available to you if needed:",...t.map(i=>`- ${i}`)].join(`
|
|
6
|
-
`)),n&&n.trim()&&o.push(["## Additional Instructions","","DO strictly adhere to these additional instructions:",n.trim()].join(`
|
|
7
|
-
`)),[o.join(`
|
|
8
|
-
|
|
9
|
-
`)]}function u(e,t,n){const s=[];return s.push(["## Task","",`- Review and assess the following task (include provided comments from the user and act on these accordingly) to ensure you have enough information, context, and resources (skills, MCP tools, appropriate access, etc) to successfully complete it, although DO NOT start any work at this stage: .nut/proposals/${e}.md`,"- Generate a readiness score on a scale of 1-100 (where 1 is not ready at all and 100 is complete certainty on your ability to complete this task without ANY additional user interaction) and add this as a comment (details on how to do this below).","- Be sure to suggest to the user (again via a comment) if it would make sense to decompose this into separate tasks, although DO NOT do this without user confirmation first.","- Retrieve your firstName, lastName, and email address from: .nut/config.json and use this identity to address yourself in any task updates, comments, git commits, etc."].join(`
|
|
10
|
-
`)),s.push(["## Task Lifecycle","",`- Before beginning any work: nut task update ${e} --status active`,`- Add appropriate implementation steps with: nut task step ${e} "Step description" --author "firstName lastName"`,`- If you need human clarification or input: nut task update ${e} --status blocked. The clarification can be communicated as follows: nut task comment ${e} "Comments here" --author "firstName lastName". At this point please stop work.`].join(`
|
|
11
|
-
`)),s.push(["## Abilities","","- The following abilities are at your disposal and should be factored into the plan where appropriate (each command has its own --help):"," - Work with knowledge documents (used for the output of any research-centric tasks):",' - nut knowledge create "Quick Note" --content "# Quick Note\\n\\nSome content here"'," - nut knowledge list"," - nut knowledge get example-filename.md"," - Creating media such as images, audio, or video:"," - nut resource"," - Using available skills (specialized, reusable, and portable modules). There is also an official registry you can pull from:"," - nut skill list"," - nut skill registry list","- Similarly, the following are available: git, gh, node, python"].join(`
|
|
12
|
-
`)),s.push(["## Operational Rules","","- DO NOT use 'npx' when running the nut CLI","- DO use the nut CLI to update task status as progress changes"," (nut --help or nut task --help for details)","- DO NOT edit files outside the scope of the approved proposal (unless instructed by the Additional Instructions below)"].join(`
|
|
13
|
-
`)),t.length>0&&s.push(["## Skills","","These skills are available to you if needed (if you are able to test access, etc without any writes please do so):",...t.map(o=>`- ${o}`)].join(`
|
|
14
|
-
`)),n&&n.trim()&&s.push(["## Additional Instructions","","DO strictly adhere to these additional instructions:",n.trim()].join(`
|
|
15
|
-
`)),[s.join(`
|
|
16
|
-
|
|
17
|
-
`)]}function p(e,t){const n=[];return n.push(m),e.length>0&&n.push(`Please use these skills: ${e.join(", ")}`),t&&t.trim()&&n.push(`Additional instruction: ${t.trim()}`),n}const h=e=>{const t=e.selectedSkillIds.map(d=>`.nut/skills/${d}/SKILL.md`),s=(e.contextType==="change-proposal"?c(e.proposalId,t,e.customInstruction,e.includeDefaultInstructions??!0):e.contextType==="prepare-proposal"?u(e.proposalId,t,e.customInstruction):p(t,e.customInstruction)).join(" "),o=[e.automationEnabled?"--dangerously-skip-permissions":""].filter(Boolean).join(" "),i=e.selectedMcpServers.map(d=>`'${d.replace(/'/g,"'\\''")}'`).join(","),l=[JSON.stringify(s)].concat(o?[JSON.stringify("--dangerously-skip-permissions")]:[]);return`node -e "${`const fs=require('fs'),{spawn}=require('child_process');const s=new Set([${i}]);const c=require('./.nut/mcp/config.json');const filtered=Object.entries(c.mcpServers||{}).filter(([k])=>s.has(k)).map(([k,v])=>[k,{...v,type:v.type||(v.url?'http':'stdio')}]);const o={mcpServers:Object.fromEntries(filtered)};fs.writeFileSync('.mcp.json',JSON.stringify(o,null,2));const p=spawn('claude',[${l.join(",")}],{stdio:'inherit'});p.on('exit',code=>process.exit(code));`.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`},k=e=>{const t=e.selectedSkillIds.map(r=>`.nut/skills/${r}/SKILL.md`),s=(e.contextType==="change-proposal"?c(e.proposalId,t,e.customInstruction,e.includeDefaultInstructions??!0):e.contextType==="prepare-proposal"?u(e.proposalId,t,e.customInstruction):p(t,e.customInstruction)).join(" ");return`node -e "${`const fs=require('fs'),path=require('path'),{spawn}=require('child_process');const s=new Set([${e.selectedMcpServers.map(r=>`'${r.replace(/'/g,"'\\''")}'`).join(",")}]);const c=require('./.nut/mcp/config.json');const geminiPath=path.join(require('os').homedir(),'.gemini','settings.json');let settings={};try{settings=JSON.parse(fs.readFileSync(geminiPath,'utf8'))}catch(e){}settings.mcpServers=Object.fromEntries(Object.entries(c.mcpServers||{}).filter(([k])=>s.has(k)));fs.writeFileSync(geminiPath,JSON.stringify(settings,null,2));const p=spawn('gemini',['-i',${JSON.stringify(s)}],{stdio:'inherit'});p.on('exit',code=>process.exit(code));`.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`},f=e=>{const t=e.selectedSkillIds.map(a=>`.nut/skills/${a}/SKILL.md`),s=(e.contextType==="change-proposal"?c(e.proposalId,t,e.customInstruction,e.includeDefaultInstructions??!0):e.contextType==="prepare-proposal"?u(e.proposalId,t,e.customInstruction):p(t,e.customInstruction)).join(" "),o=e.selectedMcpServers.map(a=>`'${a.replace(/'/g,"'\\''")}'`).join(","),i=[JSON.stringify(s)].concat(e.automationEnabled?[JSON.stringify("--dangerously-bypass-approvals-and-sandbox")]:[]);return`node -e "${`const fs=require('fs'),{spawn}=require('child_process');const s=new Set([${o}]);const c=require('./.nut/mcp/config.json');const filtered=Object.entries(c.mcpServers||{}).filter(([k])=>s.has(k)).map(([k,v])=>[k,{...v,type:v.type||(v.url?'http':'stdio')}]);const o={mcpServers:Object.fromEntries(filtered)};fs.writeFileSync('.mcp.json',JSON.stringify(o,null,2));const p=spawn('codex',[${i.join(",")}],{stdio:'inherit'});p.on('exit',code=>process.exit(code));`.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`},y=e=>{const t=e.selectedSkillIds.map(a=>`.nut/skills/${a}/SKILL.md`),s=(e.contextType==="change-proposal"?c(e.proposalId,t,e.customInstruction,e.includeDefaultInstructions??!0):e.contextType==="prepare-proposal"?u(e.proposalId,t,e.customInstruction):p(t,e.customInstruction)).join(" "),o=e.selectedMcpServers.map(a=>`'${a.replace(/'/g,"'\\''")}'`).join(","),i=[JSON.stringify(s)];return`node -e "${`const fs=require('fs'),{spawn}=require('child_process');const s=new Set([${o}]);const c=require('./.nut/mcp/config.json');const filtered=Object.entries(c.mcpServers||{}).filter(([k])=>s.has(k)).map(([k,v])=>[k,{...v,type:v.type||(v.url?'http':'stdio')}]);const o={mcpServers:Object.fromEntries(filtered)};fs.writeFileSync('.mcp.json',JSON.stringify(o,null,2));const p=spawn('droid',[${i.join(",")}],{stdio:'inherit'});p.on('exit',code=>process.exit(code));`.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`};export{y as a,h as b,f as c,k as d};
|