1import{V as c,W as m,Y as x,x as v,Z as Y,_ as J,j as e,L as S,J as _,$ as V,a0 as H,g as X,H as Z,t as d,r as A,a1 as z,a2 as ee,C as se,X as te,a3 as ae}from"./index-CWHMBte_.js";import{u as w}from"./useMutation-Zidc56FI.js";import{P as l}from"./Panel-Csk_gV5u.js";import{P as G}from"./PageHeader-BRWhOMTt.js";import{C as re}from"./compass-Cdd5N5vC.js";import{G as ne}from"./gauge-Zgtfc1ZN.js";import{M as W}from"./message-square-B-ZwEE_z.js";import{C as $}from"./circle-check-B2Wz_37W.js";import{T as ie}from"./triangle-alert-CySzMDU-.js";import{P as oe}from"./pencil-BS3Fg6SG.js";import{L as Q}from"./lock-open-ClOx9gBE.js";import{T as de}from"./trash-2-DYulR_6P.js";import{P as le}from"./plus-D2-wuwri.js";const ce=c({method:"GET"}).middleware([m]).handler(x("b3a770bce1ed40ab58d10ff498d09b507124b5e1a56da3f3d2e23287e333c769"));c({method:"POST"}).middleware([m]).handler(x("2f6ebe41a5f31608984d2937866d41d1881c6ee98bab736627099359237b1609"));c({method:"POST"}).middleware([m]).handler(x("5545bbf9d7cfe7e84f99eab0e2b86d5640dbd44387cbb09932b2d3cb7532d645"));const me=c({method:"POST"}).middleware([m]).handler(x("c0e4bcd040311f9bb4e8eeadf1c50c6abe72e2dd70b4c20c7ec2f9c92ede6130")),xe=c({method:"POST"}).middleware([m]).handler(x("b73cadb9579aa38305c1c4b5bf41ab5cab7cef3271cdd4f276715dd35d555e99")),pe=c({method:"POST"}).middleware([m]).handler(x("1ea3fe530a2bdabb67c36f0b04fe0d38367d93cf7919c2ae22b054d6001d5419")),he=c({method:"POST"}).middleware([m]).handler(x("3acb57f42cef4923b918bf9b8732bda5e2eef6f8f33bc71f0b40c426728800a6")),ue=c({method:"POST"}).middleware([m]).handler(x("c3c5445d4acc2578fed1c1a41702ef8b18dcb021e2a97282cb25c14e3044988a")),ge=c({method:"POST"}).middleware([m]).handler(x("3770468a91f8519447a10f72ab6ed4b4439396a96642ebbf2e89d6ecaba0ff58"));c({method:"POST"}).middleware([m]).handler(x("6465c821ab64bedd55259affc9a8cfd07a063d461255a9e6fd9f35c435bc3a83"));const be=["idea","planning","build","launch","growth"];function _e(){const n=v(ce),k=v(me),C=v(ge),P=v(xe),b=v(pe),f=v(he),j=v(ue),M=Y(),{data:T,isLoading:g}=J({queryKey:["mission-brain"],queryFn:()=>n()}),o=()=>M.invalidateQueries({queryKey:["mission-brain"]}),p=w({mutationFn:()=>k(),onSuccess:()=>{d.success("Roadmap locked in."),o()},onError:s=>d.error(s.message)}),h=w({mutationFn:()=>C(),onSuccess:()=>{d.success("Roadmap unlocked â you can edit it now."),o()},onError:s=>d.error(s.message)}),y=w({mutationFn:s=>j({data:{roadmap:s}}),onSuccess:()=>{d.success("Roadmap updated."),o()},onError:s=>d.error(s.message)}),E=w({mutationFn:s=>P({data:{phase:s}}),onSuccess:()=>{d.success("Phase updated."),o()},onError:s=>d.error(s.message)}),O=w({mutationFn:s=>b({data:{north_star:s}}),onSuccess:()=>{d.success("North star saved."),o()},onError:s=>d.error(s.message)}),F=w({mutationFn:s=>f({data:s}),onSuccess:()=>o(),onError:s=>d.error(s.message)});if(g)return e.jsx("div",{className:"p-10 text-center text-muted-foreground",children:"Loading mission brainâ¦"});if(!T?.mission)return e.jsxs("div",{className:"p-6 md:p-10 max-w-3xl mx-auto",children:[e.jsx(G,{eyebrow:"Mission Operations",title:"Mission Brain",subtitle:"The shared playbook every agent reads from."}),e.jsxs(l,{className:"mt-6 text-center",children:[e.jsx(re,{className:"h-10 w-10 text-primary mx-auto mb-4"}),e.jsx("h2",{className:"font-display text-xl glow-text mb-2",children:"No mission yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"Create a mission first, then talk to Atlas â he'll draft your roadmap so every other agent knows the plan."}),e.jsxs(S,{to:"/missions",className:"inline-flex items-center gap-2 px-4 py-2 rounded-md glass border border-primary/40 text-xs tracking-[0.18em] uppercase text-primary hover:glow-edge transition",children:["Create a mission ",e.jsx(_,{className:"h-3.5 w-3.5"})]})]})]});const{mission:t,memory:r,journal:a}=T,i=r?.roadmap??[],L=!!r?.roadmap_locked_at,I=r?.current_phase??"idea",B=i.filter(s=>s.status==="done").length,K=i.length?Math.round(B/i.length*100):0,u=i.find(s=>s.status!=="done")??null,R=u?.owner_agent?V(u.owner_agent):null,D=u?/north\s*star|offering|positioning|mission statement/i.test(u.title):!1,q=!!r?.north_star,U=()=>{const s=document.getElementById("north-star");s&&(s.scrollIntoView({behavior:"smooth",block:"start"}),s.classList.add("ring-2","ring-primary/60"),setTimeout(()=>s.classList.remove("ring-2","ring-primary/60"),1800))};
1return e.jsxs("div",{className:"p-6 md:p-10 max-w-6xl mx-auto space-y-6",children:[e.jsx(G,{eyebrow:"Mission Operations",title:"Mission Brain",subtitle:`The shared playbook every agent reads from â ${t.title}.`}),e.jsx(l,{children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[e.jsx("div",{className:"rounded-md p-2 bg-primary/15 border border-primary/40 text-primary shrink-0",children:e.jsx(ne,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[10px] tracking-[0.22em] uppercase text-primary/80",children:"Paired view · Mission Progress"}),e.jsxs("p",{className:"text-sm text-foreground/90 leading-relaxed mt-1",children:[e.jsx("span",{className:"font-medium",children:"Mission Brain"})," is the ",e.jsx("em",{children:"how"})," â the roadmap, north star and journal your agents work from."," ",e.jsx("span",{className:"font-medium",children:"Mission Progress"})," is the ",e.jsx("em",{children:"what"})," â the stages and activities scoreboard for the same mission."]})]})]}),e.jsxs(S,{to:"/missions",className:"inline-flex items-center gap-2 px-4 py-2 rounded-md bg-primary text-primary-foreground text-xs tracking-[0.18em] uppercase hover:opacity-90 transition shrink-0",children:["View Mission Progress ",e.jsx(_,{className:"h-3.5 w-3.5"})]})]})}),e.jsx(l,{children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] tracking-[0.24em] uppercase text-muted-foreground",children:"Current mission"}),e.jsx("div",{className:"font-display text-2xl glow-text",children:t.title})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(fe,{phase:I}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[B,"/",i.length," steps · ",e.jsxs("span",{className:"text-primary font-medium",children:[K,"%"]})]}),e.jsxs(S,{to:"/room/$agentId",params:{agentId:"atlas"},className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-md glass border border-primary/40 text-xs tracking-[0.18em] uppercase text-primary hover:glow-edge transition",children:[e.jsx(W,{className:"h-3.5 w-3.5"})," Talk to Atlas"]})]})]})}),L&&u&&e.jsx(l,{children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"text-[11px] tracking-[0.24em] uppercase text-primary/80 mb-1",children:["Next up · step ",i.indexOf(u)+1," of ",i.length]}),e.jsx("div",{className:"font-display text-xl glow-text",children:u.title}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2 leading-relaxed",children:D&&!q?e.jsx(e.Fragment,{children:"Write your North Star sentence below â one line on what winning this mission looks like. Save it, then come back here and check this step off."}):R?e.jsxs(e.Fragment,{children:["Open ",e.jsx("span",{className:"text-primary",children:R.name}
1)," and work this step together. When it's complete, come back here and click the circle to check it off."]}):e.jsx(e.Fragment,{children:"No owner assigned. Edit the roadmap to assign an agent, or talk to Atlas and he'll route it. When done, check it off here."})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[D&&!q?e.jsxs("button",{onClick:U,className:"inline-flex items-center gap-2 px-4 py-2 rounded-md bg-primary text-primary-foreground text-xs tracking-[0.18em] uppercase hover:opacity-90 transition",children:[e.jsx(H,{className:"h-3.5 w-3.5"})," Set North Star"]}):e.jsxs(S,{to:"/room/$agentId",params:{agentId:R?.id??"atlas"},className:"inline-flex items-center gap-2 px-4 py-2 rounded-md bg-primary text-primary-foreground text-xs tracking-[0.18em] uppercase hover:opacity-90 transition",children:[e.jsx(W,{className:"h-3.5 w-3.5"}),"Open ",R?.name??"Atlas"," ",e.jsx(_,{className:"h-3.5 w-3.5"})]}),e.jsxs("button",{onClick:()=>F.mutate({step_id:u.id,status:"done"}),className:"inline-flex items-center gap-2 px-4 py-2 rounded-md glass border border-primary/40 text-xs tracking-[0.18em] uppercase text-primary hover:glow-edge transition",children:[e.jsx($,{className:"h-3.5 w-3.5"})," Mark done"]})]})]})}),L&&!u&&i.length>0&&e.jsx(l,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($,{className:"h-6 w-6 text-emerald-400"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-display text-lg glow-text",children:"Every step is checked off."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Move your mission to the next phase on the right, or talk to Atlas about what comes after this."})]})]})}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx("div",{id:"north-star",className:"rounded-md transition-shadow",children:e.jsx(Ne,{value:r?.north_star??"",onSave:s=>O.mutate(s),saving:O.isPending})}),e.jsx(ye,{roadmap:i,locked:L,lockedAt:r?.roadmap_locked_at??null,onToggle:(s,N)=>F.mutate({step_id:s,status:N}),onLock:()=>p.mutate(),onUnlock:()=>h.mutate(),onSave:s=>y.mutate(s),saving:y.isPending,locking:p.isPending||h.isPending}),(r?.blockers?.length??0)>0&&e.jsx(l,{title:"Open blockers",children:e.jsx("ul",{className:"space-y-2",children:r.blockers.map((s,N)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ie,{className:"h-4 w-4 text-amber-400 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:s})]},N))})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(l,{title:"Phase",children:[e.jsxs("div",{className:"text-xs text-muted-foreground mb-3",children:["Your mission is currently in ",e.jsx("span",{className:"text-primary font-medium",children:I}),". Move it when you and Atlas agree the criteria are met."]}),e.jsx("div",{className:"grid grid-cols-1 gap-1.5",children:X.map(s=>{const N=s.id===I;return e.jsxs("button",{onClick:()=>!N&&E.mutate(s.id),disabled:N||E.isPending,className:`text-left rounded-md px-3 py-2 text-sm transition border ${N?"border-primary/60 bg-primary/10 text-primary":"border-border/40 hover:border-primary/40 hover:bg-primary/5"}`,children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:s.description})]},s.id)})})]}),e.jsx(l,{title:"Recent activity",children:a.length===0?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Nothing logged yet. As you chat with agents, key decisions and milestones will appear here."}):e.jsx("ul",{className:"space-y-3 max-h-[420px] overflow-y-auto pr-1",children:a.slice(0,25).map(s=>e.jsxs("li",{className:"text-sm border-l-2 border-primary/40 pl-3",children:[e.jsxs("div",{className:"text-[10px] tracking-[0.18em] uppercase text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{children:new Date(s.created_at).toLocaleDateString()}),e.jsx("span",{children:"·"}),e.jsx("span",{className:"text-primary/80",children:s.kind}),e.jsx("span",{children:"·"}),e.jsx("span",{children:s.agent_id})]}),e.jsx("div",{className:"text-foreground/90",children:s.summary})]},s.id))})})]})]})]})}function fe({phase:n}){return e.jsxs("span",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full glass border border-primary/40 text-[10px] tracking-[0.22em] uppercase text-primary",children:[e.jsx(Z,{className:"h-3 w-3"})," Phase: ",n]})}function je(){return`s-${Math.random().toString(36).slice(2,8)}-${Date.now().toString(36).slice(-4)}`}function ye({roadmap:n,locked:k,lockedAt:C,onToggle:P,onLock:b,onUnlock:f,onSave:j,saving:M,locking:T}){const[g,o]=A.useState(!1),[p,h]=A.useState(n);if(A.useEffect(()=>{g||h(n)},[n,g]),n.length===0&&!g)return e.jsx(l,{title:"Roadmap",children:e.jsxs("div",{className:"text-sm text-muted-foreground py-4",children:["Atlas hasn't drafted a roadmap yet."," ",e.jsx(S,{to:"/room/$agentId",params:{agentId:"atlas"},className:"text-primary underline",children:"Open Atlas"})," ","and ask him to draft one â or"," ",e.jsx("button",{onClick:()=>{h([]),o(!0)},className:"text-primary underline",children:"start one yourself"}),"."]})});const y=(t,r)=>{h(a=>a.map(i=>i.id===t?{...i,...r}:i))},E=t=>h(r=>r.filter(a=>a.id!==t)),O=()=>h(t=>[...t,{id:je(),title:"",stage:"idea",status:"todo"}]),F=p.length>0&&p.every(t=>t.title.trim().length>0)&&p.length<=40;return e.jsxs(l,{title:"Roadmap",children:[!k&&!g&&e.jsxs("div",{className:"mb-4 rounded-md border border-amber-400/40 bg-amber-500/10 p-3 flex items-start gap-3",children:[e.jsx(H,{className:"h-4 w-4 text-amber-300 mt-0.5"}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("div",{className:"text-amber-200",children:"Draft roadmap â not locked yet."}),e.jsx("div",{className:"text-muted-foreground text-xs",children:"Edit or add steps below, then lock it in so every agent treats it as canonical."})]}),e.jsxs("button",{onClick:()=>o(!0),className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-md glass border border-primary/40 text-xs tracking-[0.18em] uppercase text-primary hover:glow-edge transition",children:[e.jsx(oe,{className:"h-3.5 w-3.5"})," Edit"]}),e.jsxs("button",{onClick:b,disabled:T,className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-md bg-primary text-primary-foreground text-xs tracking-[0.18em] uppercase hover:opacity-90 transition disabled:opacity-50",children:[e.jsx(Q,{className:"h-3.5 w-3.5"})," Lock this in"]})]}),k&&!g&&e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3 text-xs",children:[e.jsxs("span",{className:"text-emerald-300/90 flex items-center gap-2",children:[e.jsx(z,{className:"h-3.5 w-3.5"})," Locked on ",new Date(C).toLocaleDateString()]}),e.jsxs("button",{onClick:f,disabled:T,className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-md glass border border-border/40 tracking-[0.18em] uppercase hover:border-primary/40 transition disabled:opacity-50",children:[e.jsx(Q,{className:"h-3.5 w-3.5"})," Unlock to edit"]})]}),g?e.jsxs("div",{className:"space-y-3",children:[e.jsx("ul",{className:"space-y-2",children:p.map((t,r)=>e.jsxs("li",{className:"rounded-md glass p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[10px] tracking-[0.18em] uppercase text-muted-foreground w-6",children:[r+1,"."]}),e.jsx("input",{value:t.title,onChange:a=>y(t.id,{title:a.target.value}),placeholder:"Step title",maxLength:200,className:"flex-1 bg-background/40 rounded-md px-2 py-1.5 text-sm border border-border/40 focus:border-primary/60 outline-none"}),e.jsx("button",{onClick:()=>
1E(t.id),"aria-label":"Remove step",className:"p-1.5 rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition",children:e.jsx(de,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pl-8",children:[e.jsx("select",{value:t.stage,onChange:a=>y(t.id,{stage:a.target.value}),className:"bg-background/40 rounded-md px-2 py-1 text-xs border border-border/40 focus:border-primary/60 outline-none",children:be.map(a=>e.jsx("option",{value:a,children:a},a))}),e.jsxs("select",{value:t.owner_agent??"",onChange:a=>y(t.id,{owner_agent:a.target.value||void 0}),className:"bg-background/40 rounded-md px-2 py-1 text-xs border border-border/40 focus:border-primary/60 outline-none",children:[e.jsx("option",{value:"",children:"â no owner â"}),ee.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]}),e.jsxs("select",{value:t.status,onChange:a=>y(t.id,{status:a.target.value}),className:"bg-background/40 rounded-md px-2 py-1 text-xs border border-border/40 focus:border-primary/60 outline-none",children:[e.jsx("option",{value:"todo",children:"todo"}),e.jsx("option",{value:"doing",children:"doing"}),e.jsx("option",{value:"done",children:"done"})]})]})]},t.id))}),e.jsxs("button",{onClick:O,disabled:p.length>=40,className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-md glass border border-border/40 text-xs tracking-[0.18em] uppercase hover:border-primary/40 transition disabled:opacity-50",children:[e.jsx(le,{className:"h-3.5 w-3.5"})," Add step"]}),e.jsxs("div",{className:"flex gap-2 pt-2 border-t border-border/30",children:[e.jsxs("button",{onClick:()=>{j(p),o(!1)},disabled:!F||M,className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-md bg-primary text-primary-foreground text-xs tracking-[0.18em] uppercase disabled:opacity-50",children:[e.jsx(se,{className:"h-3.5 w-3.5"})," Save changes"]}),e.jsxs("button",{onClick:()=>{h(n),o(!1)},className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-md glass border border-border/40 text-xs tracking-[0.18em] uppercase",children:[e.jsx(te,{className:"h-3.5 w-3.5"})," Cancel"]})]})]}):e.jsx("ul",{className:"space-y-2",children:n.map(t=>{const r=t.owner_agent?V(t.owner_agent):null,a=r?.id??"atlas";return e.jsxs("li",{className:"flex items-start gap-3 rounded-md glass p-3",children:[e.jsx("button",{onClick:()=>P(t.id,t.status==="done"?"todo":"done"),className:"mt-0.5","aria-label":"Toggle step",children:t.status==="done"?e.jsx($,{className:"h-5 w-5 text-emerald-400"}):e.jsx(ae,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-sm ${t.status==="done"?"line-through text-muted-foreground":"text-foreground"}`,children:t.title}),e.jsxs("div",{className:"text-[10px] tracking-[0.18em] uppercase text-muted-foreground mt-0.5",children:[t.stage,r?` · owner: ${r.name}`:""]})]}),e.jsxs(S,{to:"/room/$agentId",params:{agentId:a},className:"opacity-70 hover:opacity-100 inline-flex items-center gap-1 px-2 py-1 rounded-md glass border border-border/40 text-[10px] tracking-[0.18em] uppercase hover:border-primary/40 hover:text-primary transition",title:r?`Work this step with ${r.name}`:"Ask Atlas to route this step",children:["Work it ",e.jsx(_,{className:"h-3 w-3"})]})]},t.id)})})]})}function Ne({value:n,onSave:k,saving:C}){const[P,b]=A.useState(!1),[f,j]=A.useState(n);return e.jsx(l,{title:"North star",children:P?e.jsxs("div",{className:"space-y-3",children:[e.jsx("textarea",{value:f,onChange:M=>j(M.target.value),placeholder:"In one sentence: what does success look like?",className:"w-full bg-background/40 rounded-md p-3 text-sm border border-border/40 focus:border-primary/60 outline-none",rows:3,maxLength:280}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{k(f),b(!1)},disabled:C||f.trim().length<2,className:"px-3 py-1.5 rounded-md bg-primary text-primary-foreground text-xs tracking-[0.18em] uppercase disabled:opacity-50",children:"Save"}),e.jsx("button",{onClick:()=>{j(n),b(!1)},className:"px-3 py-1.5 rounded-md glass border border-border/40 text-xs tracking-[0.18em] uppercase",children:"Cancel"})]})]}):e.jsxs("div",{children:[n?e.jsx("p",{className:"text-foreground
1/90 text-sm leading-relaxed",children:n}):e.jsx("p",{className:"text-muted-foreground text-sm italic",children:"No north star set. One sentence â what does winning this mission look like?"}),e.jsx("button",{onClick:()=>{j(n),b(!0)},className:"mt-3 text-xs tracking-[0.18em] uppercase text-primary hover:underline",children:n?"Edit":"Add a north star"})]})})}export{_e as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.