UNPKG

decocms

Version:

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

2 lines (1 loc) • 5.92 kB
import{c as p,a6 as h,an as _,K as g,i as O,V as D,ao as A}from"./index-DoEtSiIe.js";const C=["deco","anthropic","openrouter","llmapi","google","openai-compatible"],L=new Set(C);function T(o){return L.has(o)}const v=new Set(["anthropic","openrouter","deco"]);function W(o){return v.has(o)}function I(o,e,t){return{anthropic:`claude-${o}-${e}-${t}`,openrouter:`anthropic/claude-${o}-${e}.${t}`,copilot:`claude-${o}-${e}.${t}`}}const E=I("opus",5,5),S=I("sonnet",5,5);function P(o){return o.capabilities?.includes("decisions")===!0}function Y(o){const e=o.capabilities?.includes("image")===!0&&!o.capabilities.includes("text");return!P(o)&&o.asyncResearch!==!0&&!e}const w={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"]},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 M(o){return o.toLowerCase().replace(/[^a-z0-9]/g,"")}function F(o){return M(o).includes("deepresearch")}const N=["sonar","searchpreview","online"];function y(o){const e=M(o);return e.includes("deepresearch")?!1:N.some(t=>e.includes(t))}function H(o){return o.asyncResearch!==!0&&y(o.modelId)}function V(o){return o.asyncResearch===!0||F(o.modelId)||y(o.modelId)}function u(o,e,t,n){for(const i of t){const s=o.find(a=>a.modelId===i);if(s)return{keyId:e,modelId:s.modelId,title:s.title}}for(const i of t){const s=o.find(a=>a.modelId.includes(i));if(s)return{keyId:e,modelId:s.modelId,title:s.title}}if(n){const i=o.find(n);if(i)return{keyId:e,modelId:i.modelId,title:i.title}}return null}function Q(o,e){const t={chat:{fast:null,smart:null,thinking:null},image:null,webSearch:null,deepResearch:null};for(const n of o){const i=(e[n.id]??[]).filter(a=>!P(a)),s=n.providerId;t.chat.fast||(t.chat.fast=u(i,n.id,w[s]??[])),t.chat.smart||(t.chat.smart=u(i,n.id,x[s]??[])),t.chat.thinking||(t.chat.thinking=u(i,n.id,K[s]??[])),t.image||(t.image=u(i,n.id,$[s]??[],a=>a.capabilities?.includes("image")===!0&&!a.modelId.startsWith("openrouter/auto"))),t.webSearch||(t.webSearch=u(i,n.id,b[s]??[],H)),t.deepResearch||(t.deepResearch=u(i,n.id,q[s]??[],V))}return t}function U(o,e){return{queryKey:g.aiProviderKeys(e),staleTime:6e4,queryFn:async()=>await A(o,"AI_PROVIDER_KEY_LIST",{})}}function k(){const o=p.c(7),{org:e}=h(),t=_();let n;o[0]!==e.id?(n=g.aiProviders(e.id),o[0]=e.id,o[1]=n):n=o[1];let i;o[2]!==t?(i=async()=>await t.call("AI_PROVIDERS_LIST",{}),o[2]=t,o[3]=i):i=o[3];let s;o[4]!==n||o[5]!==i?(s={queryKey:n,staleTime:1/0,queryFn:i},o[4]=n,o[5]=i,o[6]=s):s=o[6];const{data:a}=D(s);return a}function z(){const o=p.c(5),{org:e}=h();let t;o[0]!==e.id||o[1]!==e.slug?(t=U(e.slug,e.id),o[0]=e.id,o[1]=e.slug,o[2]=t):t=o[2];const{data:n}=D(t);let i;return o[3]!==n?.keys?(i=n?.keys??[],o[3]=n?.keys,o[4]=i):i=o[4],i}function J(){const o=p.c(2),e=z();let t;return o[0]!==e?(t=e.filter(B),o[0]=e,o[1]=t):t=o[1],t}function B(o){return T(o.providerId)}function R(o){const e=p.c(15),{org:t}=h(),n=_();let i;e[0]!==o||e[1]!==t.id?(i=g.aiProviderModels(t.id,o??""),e[0]=o,e[1]=t.id,e[2]=i):i=e[2];const s=!!o;let a;e[3]!==o||e[4]!==n?(a=async()=>await n.call("AI_PROVIDERS_LIST_MODELS",{keyId:o??""}),e[3]=o,e[4]=n,e[5]=a):a=e[5];let l;e[6]!==i||e[7]!==s||e[8]!==a?(l={queryKey:i,enabled:s,staleTime:6e4,queryFn:a},e[6]=i,e[7]=s,e[8]=a,e[9]=l):l=e[9];const{data:r,isLoading:c}=O(l);let d;e[10]!==r?.models?(d=r?.models??[],e[10]=r?.models,e[11]=d):d=e[11];const m=!!o&&c;let f;return e[12]!==d||e[13]!==m?(f={models:d,isLoading:m},e[12]=d,e[13]=m,e[14]=f):f=e[14],f}function X(o){const e=p.c(8),t=o[0],n=o[1],i=o[2],{models:s}=R(t?.id),{models:a}=R(n?.id),{models:l}=R(i?.id);let r;if(e[0]!==t||e[1]!==n||e[2]!==i||e[3]!==o||e[4]!==s||e[5]!==a||e[6]!==l){const c={};t?.id&&(c[t.id]=s),n?.id&&(c[n.id]=a),i?.id&&(c[i.id]=l),r=Q(o,c),e[0]=t,e[1]=n,e[2]=i,e[3]=o,e[4]=s,e[5]=a,e[6]=l,e[7]=r}else r=e[7];return r}function Z(o){const e=p.c(11),{org:t}=h(),n=_();let i;e[0]!==o||e[1]!==t.id?(i=g.aiProviderModels(t.id,o),e[0]=o,e[1]=t.id,e[2]=i):i=e[2];let s;e[3]!==o||e[4]!==n?(s=async()=>await n.call("AI_PROVIDERS_LIST_MODELS",{keyId:o}),e[3]=o,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:l}=D(a);let r;return e[9]!==l?.models?(r=l?.models??[],e[9]=l?.models,e[10]=r):r=e[10],r}export{R as a,V as b,Y as c,X as d,k as e,T as f,z as g,Z as h,H as i,Q as p,W as s,J as u};