UNPKG

decocms

Version:

Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools

2 lines (1 loc) • 10.7 kB
import{c as v,b as S,a6 as $,q as H,T as B,cL as z,t as A,j as t,B as T,r as M,D as q,v as U,w as Z,x as Q,aW as W,E as I,I as G,m as J}from"./index-ztdGKvBm.js";import{i as X}from"./ArrowLeft-B0PZnf1E.js";import{s as Y}from"./Plus-DWySsEmB.js";import{L as ee}from"./label-8UxgpYiA.js";import{u as te}from"./use-mcp-client-2MG3LveS.js";import{u as L}from"./use-navigate-to-agent-Cw8_3uU5.js";import{t as oe,R as re}from"./repository-picker-CSaozawA.js";import{o as se,a as K}from"./new-project-store-DID5OVrt.js";import{c as ne}from"./repository-binding-D_Xc1yRH.js";function ie(d){const e=d.path.split("/"),i=e[e.length-1]??d.path;return{owner:e.slice(0,-1).join("/"),name:i,url:d.webUrl}}function ce(d,e,i){return{title:e.name,description:i.description,pinned:!1,icon:null,metadata:{repository:{owner:e.owner,name:e.name,url:e.url,repositoryId:d.id},instructions:null,ui:{pinnedViews:null,layout:{defaultMainView:{type:"site-editor"},chatDefaultOpen:!0}}},connections:[]}}function ae(d){const e=v.c(25),{open:i,onOpenChange:r,title:s,onImportComplete:o,mode:c}=d,a=c===void 0?"agent":c,n=S(),{org:l}=$(),u=H(),h=L();let f;e[0]!==l.id||e[1]!==l.slug?(f={connectionId:B,orgId:l.id,orgSlug:l.slug},e[0]=l.id,e[1]=l.slug,e[2]=f):f=e[2];const y=te(f);let x;e[3]!==a||e[4]!==n||e[5]!==s?(x=s??n(a==="link"?"common.repositoryPicker.addRepo":"common.repositoryPicker.importFromGitHub"),e[3]=a,e[4]=n,e[5]=s,e[6]=x):x=e[6];const j=x;let P;e[7]!==y||e[8]!==n?(P=async function(C,k){const{repository:w,createdFromTemplate:b}=C,O=b?n("common.createSite.agentDescription",{template:n(oe(b))}):n("common.repositoryPicker.agentDescription",{path:w.path}),D=await y.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:ce(w,k,{description:O})}}),E=(D.structuredContent??D).item?.id;if(!E)throw new Error(n("common.repositoryPicker.createAgentFailed"));return E},e[7]=y,e[8]=n,e[9]=P):P=e[9];const p=P;let _;e[10]!==p||e[11]!==a||e[12]!==h||e[13]!==o||e[14]!==r||e[15]!==l.id||e[16]!==u||e[17]!==n?(_=async function(C){const{repository:k}=C,w=ie(k),b=a==="agent"?await p(C,w):null;z(u,l.id),r(!1),o?o({virtualMcpId:b,repository:k}):b?(A.success(C.createdFromTemplate?n("common.createSite.created",{name:w.name}):n("common.repositoryPicker.importedRepo",{name:w.name})),h(b)):A.success(n("common.repositoryPicker.addedRepo",{name:w.name}))},e[10]=p,e[11]=a,e[12]=h,e[13]=o,e[14]=r,e[15]=l.id,e[16]=u,e[17]=n,e[18]=_):_=e[18];const g=_,R=a==="agent";let N;return e[19]!==g||e[20]!==r||e[21]!==i||e[22]!==j||e[23]!==R?(N=t.jsx(re,{open:i,onOpenChange:r,title:j,onPicked:g,onError:le,allowCreateSite:R}),e[19]=g,e[20]=r,e[21]=i,e[22]=j,e[23]=R,e[24]=N):N=e[24],N}function le(d){return A.error(d)}const V={viewBox:"0 0 96 64",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0},m={stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};function pe(d){const e=v.c(9),{className:i}=d;let r,s,o,c,a,n,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("path",{d:"M22 46V22",...m,opacity:.7}),s=t.jsx("circle",{cx:"22",cy:"18",r:"4",...m,opacity:.8}),o=t.jsx("circle",{cx:"22",cy:"50",r:"4",...m,opacity:.8}),c=t.jsx("path",{d:"M22 32h14a6 6 0 0 1 6 6v4",...m,opacity:.6}),a=t.jsx("circle",{cx:"42",cy:"46",r:"4",...m,opacity:.7}),n=t.jsx("path",{d:"M56 22h9l3 4h14a3 3 0 0 1 3 3v20a3 3 0 0 1-3 3H56a3 3 0 0 1-3-3V25a3 3 0 0 1 3-3Z",...m,opacity:.75}),l=t.jsx("path",{d:"M53 34h32",...m,opacity:.5}),e[0]=r,e[1]=s,e[2]=o,e[3]=c,e[4]=a,e[5]=n,e[6]=l):(r=e[0],s=e[1],o=e[2],c=e[3],a=e[4],n=e[5],l=e[6]);let u;return e[7]!==i?(u=t.jsxs("svg",{...V,className:i,children:[r,s,o,c,a,n,l]}),e[7]=i,e[8]=u):u=e[8],u}function de(d){const e=v.c(4),{className:i}=d;let r,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("path",{d:"M16 22a4 4 0 0 1 4-4h14l6 6h20a4 4 0 0 1 4 4v20a4 4 0 0 1-4 4H20a4 4 0 0 1-4-4V22Z",...m,opacity:.8}),s=t.jsx("path",{d:"M16 28h64",...m,opacity:.5}),e[0]=r,e[1]=s):(r=e[0],s=e[1]);let o;return e[2]!==i?(o=t.jsxs("svg",{...V,className:i,children:[r,s]}),e[2]=i,e[3]=o):o=e[3],o}function Ne(d){const e=v.c(5),{className:i}=d;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsxs("g",{opacity:.55,children:[t.jsx("rect",{x:"46",y:"16",width:"128",height:"88",rx:"8",...m}),t.jsx("path",{d:"M46 34h128",...m,opacity:.6}),t.jsx("circle",{cx:"56",cy:"25",r:"2",fill:"currentColor",opacity:.6}),t.jsx("circle",{cx:"64",cy:"25",r:"2",fill:"currentColor",opacity:.45}),t.jsx("circle",{cx:"72",cy:"25",r:"2",fill:"currentColor",opacity:.3}),t.jsx("rect",{x:"58",y:"44",width:"104",height:"24",rx:"4",...m,opacity:.5}),t.jsx("rect",{x:"58",y:"76",width:"30",height:"16",rx:"3",...m,opacity:.4}),t.jsx("rect",{x:"95",y:"76",width:"30",height:"16",rx:"3",...m,opacity:.3}),t.jsx("rect",{x:"132",y:"76",width:"30",height:"16",rx:"3",...m,opacity:.22})]}),e[0]=r):r=e[0];let s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("g",{transform:"rotate(-8 44 92)",children:[t.jsx("rect",{x:"22",y:"52",width:"44",height:"76",rx:"8",...m,fill:"var(--color-background)"}),t.jsx("path",{d:"M37 60h14",...m,opacity:.5}),t.jsx("rect",{x:"29",y:"68",width:"30",height:"20",rx:"3",...m,opacity:.45}),t.jsx("path",{d:"M29 96h30M29 104h20",...m,opacity:.35}),t.jsx("rect",{x:"29",y:"112",width:"30",height:"8",rx:"4",...m,opacity:.5})]}),e[1]=s):s=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("g",{transform:"rotate(10 168 104)",children:[t.jsx("path",{d:"M150 92h30a6 6 0 0 1 6 6v26a6 6 0 0 1-6 6h-30a6 6 0 0 1-6-6V98a6 6 0 0 1 6-6Z",...m,fill:"var(--color-background)"}),t.jsx("circle",{cx:"165",cy:"104",r:"3.5",...m}),t.jsx("path",{d:"M152 116h26M152 124h16",...m,opacity:.45})]}),e[2]=o):o=e[2];let c;return e[3]!==i?(c=t.jsxs("svg",{viewBox:"0 0 220 140",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,className:i,children:[r,s,o]}),e[3]=i,e[4]=c):c=e[4],c}const ue={repository:{titleKey:"projects.new.path.repository",hintKey:"projects.new.path.repository.hint",art:pe,plate:"bg-chart-5/10 group-hover:bg-chart-5/16",art_:"text-chart-5"},folder:{titleKey:"projects.new.path.folder",hintKey:"projects.new.path.folder.hint",art:de,plate:"bg-chart-1/10 group-hover:bg-chart-1/16",art_:"text-chart-1"}},me=["repository","folder"];function he(d){const e=v.c(25),{path:i,onSelect:r}=d,s=S(),o=ue[i],c=o.art;let a;e[0]!==o.art_||e[1]!==o.plate?(a=J("flex h-28 items-center justify-center rounded-lg transition-colors",o.plate,o.art_),e[0]=o.art_,e[1]=o.plate,e[2]=a):a=e[2];let n;e[3]!==c?(n=t.jsx(c,{className:"h-20"}),e[3]=c,e[4]=n):n=e[4];let l;e[5]!==a||e[6]!==n?(l=t.jsx("span",{className:a,children:n}),e[5]=a,e[6]=n,e[7]=l):l=e[7];let u;e[8]!==o.titleKey||e[9]!==s?(u=s(o.titleKey),e[8]=o.titleKey,e[9]=s,e[10]=u):u=e[10];let h;e[11]!==u?(h=t.jsx("span",{className:"text-sm font-medium text-foreground",children:u}),e[11]=u,e[12]=h):h=e[12];let f;e[13]!==o.hintKey||e[14]!==s?(f=s(o.hintKey),e[13]=o.hintKey,e[14]=s,e[15]=f):f=e[15];let y;e[16]!==f?(y=t.jsx("span",{className:"text-xs text-muted-foreground",children:f}),e[16]=f,e[17]=y):y=e[17];let x;e[18]!==h||e[19]!==y?(x=t.jsxs("span",{className:"flex flex-col gap-0.5 px-1 pb-1",children:[h,y]}),e[18]=h,e[19]=y,e[20]=x):x=e[20];let j;return e[21]!==r||e[22]!==l||e[23]!==x?(j=t.jsxs("button",{type:"button",onClick:r,className:"group flex flex-col gap-3 surface p-3 text-left focus-ring transition-[transform,background-color] duration-200 hover:-translate-y-0.5 hover:bg-accent motion-reduce:transition-none motion-reduce:hover:translate-y-0",children:[l,x]}),e[21]=r,e[22]=l,e[23]=x,e[24]=j):j=e[24],j}function fe(d){const e=v.c(8),{label:i,children:r,hint:s}=d;let o;e[0]!==i?(o=t.jsx(ee,{children:i}),e[0]=i,e[1]=o):o=e[1];let c;e[2]!==s?(c=s&&t.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[2]=s,e[3]=c):c=e[3];let a;return e[4]!==r||e[5]!==o||e[6]!==c?(a=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[o,r,c]}),e[4]=r,e[5]=o,e[6]=c,e[7]=a):a=e[7],a}function ke({open:d,onOpenChange:e,source:i="org_home"}){const r=S(),s=ne(),o=L(),[c,a]=M.useState(null),[n,l]=M.useState(""),[u,h]=M.useState(null),f=M.useRef(null),y=()=>{a(null),l(""),h(null)},x=()=>{e(!1),y()};if(c==="repository")return t.jsx(ae,{open:!0,onOpenChange:p=>{p||x()},onImportComplete:({virtualMcpId:p})=>{p&&(K(p),o(p)),x()}});const j=async()=>{if(s.create.isPending)return;const p=n.trim();if(!p){h(r("projects.new.nameRequired"));return}try{const g=(await s.create.mutateAsync({title:p,description:null,status:"active",pinned:!1,connections:[],metadata:{instructions:null,project:{storeUrl:null},ui:{pinnedViews:null,layout:{defaultMainView:{type:"overview"},chatDefaultOpen:!0}}}}))?.id;I("project_created",{source:i,path:c}),x(),g&&(K(g),o(g)),A.success(r("projects.new.created",{title:p}))}catch{h(r("projects.new.failed"))}};return t.jsx(q,{open:d,onOpenChange:p=>{p?e(!0):x()},children:t.jsxs(U,{className:"sm:max-w-3xl",ref:f,onOpenAutoFocus:p=>{p.preventDefault(),f.current?.focus()},children:[t.jsxs(Z,{children:[t.jsx(Q,{children:r("projects.new.title")}),t.jsx(W,{children:r(c?"projects.new.step.folder.title":"projects.new.subtitle")})]}),c===null?t.jsx("div",{className:"grid grid-cols-1 gap-3 animate-in fade-in-0 duration-200 sm:grid-cols-2 motion-reduce:animate-none",children:me.map(p=>t.jsx(he,{path:p,onSelect:()=>{I("project_create_path_selected",{source:i,path:p}),a(p)}},p))}):t.jsxs("form",{className:"flex flex-col gap-4 animate-in fade-in-0 slide-in-from-right-2 duration-200 motion-reduce:animate-none",onSubmit:p=>{p.preventDefault(),h(null),j()},children:[t.jsx(fe,{label:r("projects.new.nameLabel"),children:t.jsx(G,{autoFocus:!0,value:n,onChange:p=>l(p.target.value),placeholder:r("projects.new.namePlaceholder")})}),u&&t.jsx("p",{className:"text-sm text-destructive",children:u}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsxs(T,{type:"button",variant:"ghost",onClick:()=>y(),children:[t.jsx(X,{size:14}),r("projects.new.back")]}),t.jsx(T,{type:"submit",disabled:s.create.isPending,children:s.create.isPending?r("projects.new.creating"):r("projects.new.create")})]})]})]})})}function Me(d){const e=v.c(11),{source:i,variant:r,size:s,label:o}=d,c=r===void 0?"default":r,a=s===void 0?"sm":s,n=S();let l;e[0]!==i?(l=()=>se(i),e[0]=i,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(Y,{size:14}),e[2]=u):u=e[2];let h;e[3]!==o||e[4]!==n?(h=o??n("projects.home.newProject"),e[3]=o,e[4]=n,e[5]=h):h=e[5];let f;return e[6]!==a||e[7]!==l||e[8]!==h||e[9]!==c?(f=t.jsxs(T,{size:a,variant:c,onClick:l,children:[u,h]}),e[6]=a,e[7]=l,e[8]=h,e[9]=c,e[10]=f):f=e[10],f}export{Ne as E,Me as N,ae as R,ke as a};