decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
2 lines (1 loc) • 6.22 kB
JavaScript
import{c as p,a6 as f,an as _,K as g,i as A,V as D,ao as C}from"./index-ztdGKvBm.js";const L=["deco","anthropic","openrouter","llmapi","google","openai-compatible"],w=new Set(L);function T(t){return w.has(t)}const v=new Set(["anthropic","openrouter","deco"]);function G(t){return v.has(t)}function I(t,e,o){return{anthropic:`claude-${t}-${e}-${o}`,openrouter:`anthropic/claude-${t}-${e}.${o}`,copilot:`claude-${t}-${e}.${o}`}}const E=I("opus",5,5),S=I("sonnet",5,5);function M(t){return t.capabilities?.includes("decisions")===!0}function W(t){const e=t.capabilities?.includes("image")===!0&&!t.capabilities.includes("text");return!M(t)&&t.asyncResearch!==!0&&!e}const P={anthropic:["claude-haiku-4-5","claude-haiku"],openrouter:["qwen/qwen3.5-flash","anthropic/claude-haiku-4.5","anthropic/claude-haiku","google/gemini-3-flash"],deco:["qwen/qwen3.5-flash","anthropic/claude-haiku"],llmapi:["claude-haiku-4-5","claude-haiku","gpt-4o-mini"],google:["gemini-2.5-flash","gemini-3-flash"]};function Y(t){return P[t]?.[0]??null}const x={anthropic:[S.anthropic,"claude-sonnet-5","claude-sonnet"],openrouter:[S.openrouter,"anthropic/claude-sonnet-5","anthropic/claude-sonnet","anthropic/claude-opus-4.8","google/gemini-3-pro"],deco:[S.openrouter,"anthropic/claude-sonnet-5","anthropic/claude-sonnet","anthropic/claude"],llmapi:["claude-sonnet-4-6","claude-sonnet"],google:["gemini-3-pro","gemini-3-flash"]},K={anthropic:[E.anthropic,"claude-opus-4-8","claude-sonnet-5","claude-sonnet","claude-fable-5"],openrouter:[E.openrouter,"anthropic/claude-opus-4.8:extended","anthropic/claude-opus-4.8","anthropic/claude-sonnet-5:extended","anthropic/claude-sonnet-5","google/gemini-3-pro","anthropic/claude-fable-5"],deco:[E.openrouter,"anthropic/claude-opus","anthropic/claude-sonnet-4.6","anthropic/claude-sonnet","anthropic/claude-fable"],llmapi:["claude-opus-4-8","claude-opus","claude-sonnet-4-6"],google:["gemini-3-pro"]},$={openrouter:["google/gemini-3-pro-image","openai/gpt-5-image","google/gemini-2.5-flash-image"],deco:["google/gemini-3-pro-image","openai/gpt-5-image","google/gemini-2.5-flash-image"],llmapi:["gemini-2.5-flash-image","gpt-image-1"],google:["gemini-2.0-flash-image"]},b={openrouter:["perplexity/sonar","perplexity/sonar-pro"],deco:["perplexity/sonar","perplexity/sonar-pro"]},q={openrouter:["perplexity/deep-research","perplexity/sonar-pro"],deco:["perplexity/deep-research","perplexity/sonar-pro"]};function y(t){return t.toLowerCase().replace(/[^a-z0-9]/g,"")}function F(t){return y(t).includes("deepresearch")}const N=["sonar","searchpreview","online"];function O(t){const e=y(t);return e.includes("deepresearch")?!1:N.some(o=>e.includes(o))}function H(t){return t.asyncResearch!==!0&&O(t.modelId)}function V(t){return t.asyncResearch===!0||F(t.modelId)||O(t.modelId)}function d(t,e,o,n){for(const i of o){const s=t.find(a=>a.modelId===i);if(s)return{keyId:e,modelId:s.modelId,title:s.title}}for(const i of o){const s=t.find(a=>a.modelId.includes(i));if(s)return{keyId:e,modelId:s.modelId,title:s.title}}if(n){const i=t.find(n);if(i)return{keyId:e,modelId:i.modelId,title:i.title}}return null}function Q(t,e){const o={chat:{fast:null,smart:null,thinking:null},image:null,webSearch:null,deepResearch:null};for(const n of t){const i=(e[n.id]??[]).filter(a=>!M(a)),s=n.providerId;o.chat.fast||(o.chat.fast=d(i,n.id,P[s]??[])),o.chat.smart||(o.chat.smart=d(i,n.id,x[s]??[])),o.chat.thinking||(o.chat.thinking=d(i,n.id,K[s]??[])),o.image||(o.image=d(i,n.id,$[s]??[],a=>a.capabilities?.includes("image")===!0&&!a.modelId.startsWith("openrouter/auto"))),o.webSearch||(o.webSearch=d(i,n.id,b[s]??[],H)),o.deepResearch||(o.deepResearch=d(i,n.id,q[s]??[],V))}return o}function j(t,e){switch(e){case"fast":return t.chat.fast;case"smart":return t.chat.smart;case"thinking":return t.chat.thinking;case"image":return t.image;case"web_search":return t.webSearch;case"deep_research":return t.deepResearch}}function U(t,e){return{queryKey:g.aiProviderKeys(e),staleTime:6e4,queryFn:async()=>await C(t,"AI_PROVIDER_KEY_LIST",{})}}function J(){const t=p.c(7),{org:e}=f(),o=_();let n;t[0]!==e.id?(n=g.aiProviders(e.id),t[0]=e.id,t[1]=n):n=t[1];let i;t[2]!==o?(i=async()=>await o.call("AI_PROVIDERS_LIST",{}),t[2]=o,t[3]=i):i=t[3];let s;t[4]!==n||t[5]!==i?(s={queryKey:n,staleTime:1/0,queryFn:i},t[4]=n,t[5]=i,t[6]=s):s=t[6];const{data:a}=D(s);return a}function k(){const t=p.c(5),{org:e}=f();let o;t[0]!==e.id||t[1]!==e.slug?(o=U(e.slug,e.id),t[0]=e.id,t[1]=e.slug,t[2]=o):o=t[2];const{data:n}=D(o);let i;return t[3]!==n?.keys?(i=n?.keys??[],t[3]=n?.keys,t[4]=i):i=t[4],i}function X(){const t=p.c(2),e=k();let o;return t[0]!==e?(o=e.filter(z),t[0]=e,t[1]=o):o=t[1],o}function z(t){return T(t.providerId)}function R(t){const e=p.c(15),{org:o}=f(),n=_();let i;e[0]!==t||e[1]!==o.id?(i=g.aiProviderModels(o.id,t??""),e[0]=t,e[1]=o.id,e[2]=i):i=e[2];const s=!!t;let a;e[3]!==t||e[4]!==n?(a=async()=>await n.call("AI_PROVIDERS_LIST_MODELS",{keyId:t??""}),e[3]=t,e[4]=n,e[5]=a):a=e[5];let c;e[6]!==i||e[7]!==s||e[8]!==a?(c={queryKey:i,enabled:s,staleTime:6e4,queryFn:a},e[6]=i,e[7]=s,e[8]=a,e[9]=c):c=e[9];const{data:r,isLoading:l}=A(c);let u;e[10]!==r?.models?(u=r?.models??[],e[10]=r?.models,e[11]=u):u=e[11];const m=!!t&&l;let h;return e[12]!==u||e[13]!==m?(h={models:u,isLoading:m},e[12]=u,e[13]=m,e[14]=h):h=e[14],h}function Z(t){const e=p.c(8),o=t[0],n=t[1],i=t[2],{models:s}=R(o?.id),{models:a}=R(n?.id),{models:c}=R(i?.id);let r;if(e[0]!==o||e[1]!==n||e[2]!==i||e[3]!==t||e[4]!==s||e[5]!==a||e[6]!==c){const l={};o?.id&&(l[o.id]=s),n?.id&&(l[n.id]=a),i?.id&&(l[i.id]=c),r=Q(t,l),e[0]=o,e[1]=n,e[2]=i,e[3]=t,e[4]=s,e[5]=a,e[6]=c,e[7]=r}else r=e[7];return r}function ee(t){const e=p.c(11),{org:o}=f(),n=_();let i;e[0]!==t||e[1]!==o.id?(i=g.aiProviderModels(o.id,t),e[0]=t,e[1]=o.id,e[2]=i):i=e[2];let s;e[3]!==t||e[4]!==n?(s=async()=>await n.call("AI_PROVIDERS_LIST_MODELS",{keyId:t}),e[3]=t,e[4]=n,e[5]=s):s=e[5];let a;e[6]!==i||e[7]!==s?(a={queryKey:i,staleTime:6e4,queryFn:s},e[6]=i,e[7]=s,e[8]=a):a=e[8];const{data:c}=D(a);let r;return e[9]!==c?.models?(r=c?.models??[],e[9]=c?.models,e[10]=r):r=e[10],r}export{E as C,j as a,Z as b,R as c,V as d,W as e,J as f,Y as g,S as h,H as i,T as j,k,ee as l,Q as p,G as s,X as u};