decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
8 lines (5 loc) • 13.9 kB
JavaScript
import{c as ne,b as xe,a6 as je,d as Ne,u as Ee,a as Ce,j as s,n as fe,J as ke,q as Me,K as V,r as J,m as Se,a7 as ve,B as pe,gK as we,P as ze,e3 as re,i as Oe,h as Pe}from"./index-DoEtSiIe.js";import{A as _e,b as De}from"./alert-C5EpdwBA.js";import{T as Fe,a as qe,c as Le}from"./tooltip-DhlWzeQv.js";import{C as Ae}from"./collection-tabs-9jbbjBDw.js";import{E as Ke}from"./empty-state-C4MgLcBg.js";import{a as Re}from"./shell-layout-596_q4a1.js";import{e as $e,c as Ie,o as He,w as Qe}from"./use-org-fs-C62_MbqW.js";import"./index-BFFHlwFA.js";import"./badge-DONoxQO7.js";import"./Globe04-5yHQa01g.js";import"./UserSquare-dgrNjiXb.js";import"./use-deployment-admin-Bh76rlF7.js";import"./admin-fetch-BhTJlAsX.js";import"./agent-icon-DoabtHNW.js";import"./AlertCircle-GoAGGV0G.js";import"./UserCheck01-CA8kXGn8.js";import"./Tool01-D90Wr5xR.js";import"./ArrowUp-s5a8DQxj.js";import"./ArrowLeft-DuGHc_Gh.js";import"./ArrowRight-CMJyKdyB.js";import"./BookOpen01-DZs1-yi9.js";import"./CheckCircle-vIQcB0iT.js";import"./ChevronDown-Dm2xO7jf.js";import"./ChevronSelectorVertical-Cvgyclsz.js";import"./ChevronUp-BKdcyIOm.js";import"./LinkBroken01-CyjdgWmP.js";import"./CreditCard01-BUXydXso.js";import"./File02-Y4Nh84qP.js";import"./MessageCircle01-zc37Krdu.js";import"./SwitchHorizontal01-CHtrDs50.js";import"./Eye-DwRCQHLk.js";import"./Fingerprint04-DlIWxzRc.js";import"./Image01-BRABRo3v.js";import"./Key01-DfLmV_su.js";import"./LayoutLeft-owMYqid0.js";import"./Minus-CFYZtYi9.js";import"./Monitor01-DUhT2Mcw.js";import"./Sun-uwKn4QPm.js";import"./Play-C_9Fb_Ik.js";import"./Plus-BoPsX_T8.js";import"./SearchMd-BGRe_18c.js";import"./ShoppingBag01-CoN4FBW5.js";import"./Trash01-Ctp9Olbr.js";import"./Upload01-DgxprpI7.js";import"./Users01-BasqfwpC.js";import"./XClose-BUxhnZ3x.js";import"./Zap-CxPsn4FS.js";import"./use-org-notice-BzvGZbQ2.js";import"./thread-intent-R2KI8ie_.js";import"./use-mcp-client-86j-Nolb.js";import"./auth-IBAsOARn.js";import"./delay-CnY5UFtP.js";import"./backoff-CrEUbyZT.js";import"./watch-sse-pool-C0me6Edt.js";import"./task-board-BRF3ZwKz.js";import"./schema-CG6ylG0z.js";import"./session-runtime-CZKHty5X.js";import"./use-project-scope-AMUoXt2c.js";import"./repository-binding-BAQCDq-W.js";import"./use-panel-navigate-DHff9CS9.js";import"./thread-route-D-UE3Db_.js";import"./command-D5O7M-Cf.js";import"./index-DRuy-mDa.js";import"./integration-icon-DvT6X8cI.js";import"./project-icon-BxqBM24K.js";import"./use-navigate-to-agent-C-BC28kE.js";import"./use-debounced-value-DqHSmPMR.js";import"./new-project-dialog-CT39WKMt.js";import"./label-G4Rj_cXa.js";import"./repository-picker-BBkgoOlP.js";import"./github-icon-YYYF_UPl.js";import"./useInfiniteQuery-9vIAXgqG.js";import"./infiniteQueryObserver-BRGiYBJv.js";import"./collection-search-DL8nJQx4.js";import"./use-organization-settings-CgKOO7Ms.js";import"./new-project-store-DYc4RZIM.js";import"./legacy-admin-welcome-dialog-BYL3pyxT.js";import"./drawer-DO0sMAej.js";import"./use-mobile-BjsAkqwr.js";import"./required-auth-layout-DPL2sBE1.js";import"./use-view-draft-kind-hbAZo1QG.js";import"./use-blog-view-DJnS2ipo.js";import"./use-org-sso-CypQjzG8.js";const Be=16e3;function Ye(t){return`users/${t}`}function Ue(t,e){return t==="organization"?"MEMORY.md":`${Ye(e)}/MEMORY.md`}function Ve(t){return t==="organization"?`# Organization memory
Durable facts shared with everyone in this organization. Keep this a concise, curated index — not a log.
`:`# User memory
Facts and preferences specific to you. Keep this a concise, curated index — not a log.
`}const Je=800,he={marker:"absent",expect:{absent:!0}};function ge(t){return{marker:$e(t),expect:t.contentHash?{contentHash:t.contentHash}:null}}class Ge{constructor(e,i,o){this.write=e,this.onStatus=i,this.onSaved=o}write;onStatus;onSaved;draft=null;base=he;loaded=0;held=!1;timer;queue=Promise.resolve();change(e,i){this.draft===null&&i.generation>this.loaded&&(this.base=i.version,this.loaded=i.generation),this.draft=e,!this.held&&(this.onStatus("dirty"),clearTimeout(this.timer),this.timer=setTimeout(()=>this.flush(),Je))}flush(e=!1){clearTimeout(this.timer),this.timer=void 0,!(this.held&&!e)&&(this.held=!1,this.queue=this.queue.then(()=>this.save(e)))}discard(){clearTimeout(this.timer),this.timer=void 0,this.draft=null,this.held=!1}async save(e){const i=this.draft;if(i!==null){this.onStatus("saving");try{const o=await this.write(i,e?null:this.base.expect);if(!o.ok){this.held=!0,this.onStatus(o.reason);return}this.base=ge(o.entry),this.onSaved(o.entry,i),this.draft===i&&(this.draft=null,this.onStatus("saved"))}catch{this.onStatus("error")}}}subscribe=()=>{const e=i=>{this.draft!==null&&i.preventDefault()};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e),this.timer!==void 0&&this.flush()}}}const O="home",be=()=>0;function We(t,e,i){const o=Math.round((e-new Date(t).getTime())/1e3),m=new Intl.RelativeTimeFormat(i,{numeric:"auto"}),n=[["day",86400],["hour",3600],["minute",60]];for(const[r,b]of n)if(Math.abs(o)>=b)return m.format(-Math.round(o/b),r);return m.format(0,"second")}function Xe(t,e,i){switch(e){case"dirty":return"";case"saving":return t("settings.memory.saving");case"saved":return t("settings.memory.saved");case"conflict":return t("settings.memory.notSaved");case"forbidden":return t("settings.memory.readOnly");case"error":return t("settings.memory.saveError");case"idle":return i?t("settings.memory.updated",{time:i}):t("settings.memory.notStarted");default:return e}}function Ze(t){const e=ne.c(19),{length:i}=t,o=xe(),m=i/Be;if(m<.5)return null;const n=m>1,r=n?"text-destructive":m>.8&&"text-warning";let b;e[0]!==r?(b=Se("inline-flex items-center gap-2 rounded-sm",r),e[0]=r,e[1]=b):b=e[1];const S=`${Math.min(m,1)*100}%`;let d;e[2]!==S?(d=s.jsx("span",{className:"h-1 w-16 overflow-hidden rounded-full bg-muted",children:s.jsx("span",{className:"block h-full rounded-full bg-current transition-[width]",style:{width:S}})}),e[2]=S,e[3]=d):d=e[3];let x;e[4]!==n||e[5]!==m||e[6]!==o?(x=n?o("settings.memory.budgetOver"):o("settings.memory.budget",{percent:String(Math.round(m*100))}),e[4]=n,e[5]=m,e[6]=o,e[7]=x):x=e[7];let u;e[8]!==b||e[9]!==d||e[10]!==x?(u=s.jsx(Fe,{asChild:!0,children:s.jsxs("span",{tabIndex:0,className:b,children:[d,x]})}),e[8]=b,e[9]=d,e[10]=x,e[11]=u):u=e[11];let a;e[12]!==o?(a=o("settings.memory.budgetHint"),e[12]=o,e[13]=a):a=e[13];let f;e[14]!==a?(f=s.jsx(qe,{side:"top",className:"max-w-64",children:a}),e[14]=a,e[15]=f):f=e[15];let p;return e[16]!==u||e[17]!==f?(p=s.jsxs(Le,{children:[u,f]}),e[16]=u,e[17]=f,e[18]=p):p=e[18],p}function Te(){const t=ne.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(we,{className:"gap-3 px-6 py-5",children:s.jsxs("div",{className:"flex min-h-[320px] flex-col gap-3",children:[s.jsx(re,{className:"h-5 w-1/3"}),s.jsx(re,{className:"h-4 w-full"}),s.jsx(re,{className:"h-4 w-5/6"}),s.jsx(re,{className:"h-4 w-2/3"})]})}),t[0]=e):e=t[0],e}function et(t){const e=ne.c(101),{scope:i,userId:o,label:m}=t,n=xe(),{org:r}=je(),[b]=ke(),{language:S}=b,d=Me(),x=Re(6e4);let u;e[0]!==i||e[1]!==o?(u=Ue(i,o),e[0]=i,e[1]=o,e[2]=u):u=e[2];const a=u,f=i==="organization"?"":`users/${o}`;let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p={staleTime:0},e[3]=p):p=e[3];const l=Ie(O,a,p);let h,j,w;e[4]!==r.id||e[5]!==a||e[6]!==l.data?(h=l.data===void 0?void 0:l.data?ge(l.data):he,w=Oe,j=V.orgFsText(r.id,O,a,h?.marker??""),e[4]=r.id,e[5]=a,e[6]=l.data,e[7]=h,e[8]=j,e[9]=w):(h=e[7],j=e[8],w=e[9]);const C=l.data!=null;let k;e[10]!==r.slug||e[11]!==a?(k=()=>He(r.slug,O,a),e[10]=r.slug,e[11]=a,e[12]=k):k=e[12];let P;e[13]!==j||e[14]!==C||e[15]!==k?(P={queryKey:j,enabled:C,staleTime:1/0,queryFn:k},e[13]=j,e[14]=C,e[15]=k,e[16]=P):P=e[16];const U=w(P),ye=h===he?"":U.data,[y,oe]=J.useState("idle"),[v,ae]=J.useState(null),[le,me]=J.useState(null);let G;e[17]!==f||e[18]!==r.id||e[19]!==r.slug||e[20]!==a||e[21]!==d?(G=()=>new Ge((c,g)=>Qe(r.slug,O,a,c,g),oe,(c,g)=>{const N=ge(c);d.setQueryData(V.orgFsText(r.id,O,a,N.marker),g),d.setQueryData(V.orgFsStat(r.id,O,a),c),d.invalidateQueries({queryKey:V.orgFsList(r.id,O,f)}),d.invalidateQueries({queryKey:V.orgFsRecent(r.id)}),ae(E=>E&&{...E,version:N,body:g})}),e[17]=f,e[18]=r.id,e[19]=r.slug,e[20]=a,e[21]=d,e[22]=G):G=e[22];const[T]=J.useState(G);J.useSyncExternalStore(T.subscribe,be,be),h&&ye!==void 0&&(y==="idle"||y==="saved")&&h.marker!==v?.version.marker&&(ae({version:h,body:ye,generation:(v?.generation??0)+1}),me(null),y==="saved"&&oe("idle"));let W;e[23]!==T||e[24]!==l?(W=()=>{T.discard(),oe("idle"),me(null),ae(tt),l.refetch()},e[23]=T,e[24]=l,e[25]=W):W=e[25];const ce=W;if(!v&&(l.isError||U.isError)){let c;e[26]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(ve,{size:48,className:"text-muted-foreground"}),e[26]=c):c=e[26];let g;e[27]!==n?(g=n("settings.memory.errorTitle"),e[27]=n,e[28]=g):g=e[28];let N;e[29]!==n?(N=n("settings.memory.errorDescription"),e[29]=n,e[30]=N):N=e[30];let E;e[31]!==l||e[32]!==U?(E=()=>{l.refetch(),U.refetch()},e[31]=l,e[32]=U,e[33]=E):E=e[33];let B;e[34]!==n?(B=n("settings.memory.retry"),e[34]=n,e[35]=B):B=e[35];let Y;e[36]!==E||e[37]!==B?(Y=s.jsx(pe,{size:"sm",variant:"outline",onClick:E,children:B}),e[36]=E,e[37]=B,e[38]=Y):Y=e[38];let ie;return e[39]!==g||e[40]!==N||e[41]!==Y?(ie=s.jsx("div",{className:"flex items-center justify-center py-20",children:s.jsx(Ke,{image:c,title:g,description:N,actions:Y})}),e[39]=g,e[40]=N,e[41]=Y,e[42]=ie):ie=e[42],ie}if(!v){let c;return e[43]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(Te,{}),e[43]=c):c=e[43],c}let X;e[44]!==v.body?(X=v.body.trim(),e[44]=v.body,e[45]=X):X=e[45];let Z;e[46]!==i?(Z=Ve(i).trim(),e[46]=i,e[47]=Z):Z=e[47];const ee=X===Z,_=ee?"":v.body;let M,D,z,F,q;if(e[48]!==S||e[49]!==x||e[50]!==l.data||e[51]!==y||e[52]!==n||e[53]!==ee){const c=!ee&&l.data?We(l.data.updatedAt,x,S):null;q="flex min-h-5 items-center justify-between gap-3 text-meta";const g=y==="error"&&"text-destructive";e[59]!==g?(M=Se("inline-flex items-center gap-1.5",g),e[59]=g,e[60]=M):M=e[60],D="polite",e[61]!==y?(z=y==="saving"&&s.jsx(Pe,{className:"size-3"}),e[61]=y,e[62]=z):z=e[62],F=Xe(n,y,c),e[48]=S,e[49]=x,e[50]=l.data,e[51]=y,e[52]=n,e[53]=ee,e[54]=M,e[55]=D,e[56]=z,e[57]=F,e[58]=q}else M=e[54],D=e[55],z=e[56],F=e[57],q=e[58];let L;e[63]!==M||e[64]!==D||e[65]!==z||e[66]!==F?(L=s.jsxs("span",{className:M,"aria-live":D,children:[z,F]}),e[63]=M,e[64]=D,e[65]=z,e[66]=F,e[67]=L):L=e[67];let A;e[68]!==le||e[69]!==_?(A=le??_.trim().length,e[68]=le,e[69]=_,e[70]=A):A=e[70];let K;e[71]!==A?(K=s.jsx(Ze,{length:A}),e[71]=A,e[72]=K):K=e[72];let te;e[73]!==q||e[74]!==L||e[75]!==K?(te=s.jsxs("div",{className:q,children:[L,K]}),e[73]=q,e[74]=L,e[75]=K,e[76]=te):te=e[76];const de=te;let R;e[77]!==ce||e[78]!==T||e[79]!==y||e[80]!==n?(R=y==="conflict"&&s.jsxs(_e,{variant:"info",className:"border-warning",children:[s.jsx(ve,{className:"text-warning"}),s.jsxs(De,{className:"flex flex-1 flex-wrap items-center justify-between gap-3",children:[n("settings.memory.conflict"),s.jsxs("span",{className:"flex gap-2",children:[s.jsx(pe,{size:"sm",variant:"outline",onClick:ce,children:n("settings.memory.loadLatest")}),s.jsx(pe,{size:"sm",onClick:()=>T.flush(!0),children:n("settings.memory.keepMine")})]})]})]}),e[77]=ce,e[78]=T,e[79]=y,e[80]=n,e[81]=R):R=e[81];const ue=y==="forbidden";let $;e[82]!==i||e[83]!==n?($=n(i==="organization"?"settings.memory.orgPlaceholder":"settings.memory.userPlaceholder"),e[82]=i,e[83]=n,e[84]=$):$=e[84];let I;e[85]!==T||e[86]!==v?(I=c=>{me(c.target.value.trim().length),T.change(c.target.value,v)},e[85]=T,e[86]=v,e[87]=I):I=e[87];let H;e[88]!==m||e[89]!==v.generation||e[90]!==ue||e[91]!==$||e[92]!==I||e[93]!==_?(H=s.jsx(we,{className:"gap-0 px-6 py-5",children:s.jsx("textarea",{defaultValue:_,readOnly:ue,"aria-label":m,placeholder:$,onChange:I,className:"field-sizing-content min-h-[60vh] w-full resize-none bg-transparent font-mono text-sm leading-6 text-foreground outline-none placeholder:text-muted-foreground"},v.generation)}),e[88]=m,e[89]=v.generation,e[90]=ue,e[91]=$,e[92]=I,e[93]=_,e[94]=H):H=e[94];let Q;e[95]!==de?(Q=s.jsx(ze.Toolbar.Right.Portal,{children:de}),e[95]=de,e[96]=Q):Q=e[96];let se;return e[97]!==R||e[98]!==H||e[99]!==Q?(se=s.jsxs("div",{className:"flex flex-col gap-4",children:[R,H,Q]}),e[97]=R,e[98]=H,e[99]=Q,e[100]=se):se=e[100],se}function tt(t){return t&&{...t,version:{marker:"",expect:null}}}function Os(){const t=ne.c(29),e=xe(),{org:i}=je(),o=Ne();let m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m={strict:!1},t[0]=m):m=t[0];const r=Ee(m).scope==="user"?"user":"organization",{data:b}=Ce.useSession(),S=b?.user.id;let d;t[1]!==i||t[2]!==r||t[3]!==e?(d=r==="organization"?e("settings.memory.orgHeading",{org:i.name}):e("settings.memory.userHeading"),t[1]=i,t[2]=r,t[3]=e,t[4]=d):d=t[4];const x=d;let u;t[5]!==e?(u=e("settings.memory.tabOrg"),t[5]=e,t[6]=u):u=t[6];let a;t[7]!==u?(a={id:"organization",label:u},t[7]=u,t[8]=a):a=t[8];let f;t[9]!==e?(f=e("settings.memory.tabUser"),t[9]=e,t[10]=f):f=t[10];let p;t[11]!==f?(p={id:"user",label:f},t[11]=f,t[12]=p):p=t[12];let l;t[13]!==a||t[14]!==p?(l=[a,p],t[13]=a,t[14]=p,t[15]=l):l=t[15];let h;t[16]!==o?(h=k=>o({to:".",search:P=>({...P,scope:k==="user"?"user":void 0}),replace:!0}),t[16]=o,t[17]=h):h=t[17];let j;t[18]!==r||t[19]!==l||t[20]!==h?(j=s.jsx(Ae,{placement:"page",tabs:l,activeTab:r,onTabChange:h}),t[18]=r,t[19]=l,t[20]=h,t[21]=j):j=t[21];let w;t[22]!==x||t[23]!==r||t[24]!==S?(w=s.jsx("div",{className:"flex flex-col gap-4",children:S?s.jsx(et,{scope:r,userId:S,label:x},r):s.jsx(Te,{})}),t[22]=x,t[23]=r,t[24]=S,t[25]=w):w=t[25];let C;return t[26]!==j||t[27]!==w?(C=s.jsx(fe,{children:s.jsx(fe.Content,{children:s.jsx(fe.Container,{width:"standard",children:s.jsxs("div",{className:"flex flex-col gap-6",children:[j,w]})})})}),t[26]=j,t[27]=w,t[28]=C):C=t[28],C}export{Os as default};