@zuplo/cli 7.14.8 → 7.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwe/general/decrypt.js +3 -2
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jws/general/verify.js +2 -8
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +11 -8
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/key_management.js +0 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/package.json +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/general/decrypt.js +3 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/general/verify.js +2 -8
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +11 -8
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_management.js +0 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/core/zeno.js +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-DB6LKZ36.js → chunk-F4G3YEN2.js} +3 -3
- package/node_modules/@zuplo/runtime/out/esm/{chunk-PY52EHDX.js → chunk-GWGCD6Z7.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/{chunk-SNTU476S.js → chunk-HTXNM72E.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/chunk-M4IZPJP6.js +37 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-2HVCLUM4.js.map → chunk-M4IZPJP6.js.map} +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-6R2COTV6.js → chunk-SX6JF7A6.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp/messages/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js +1 -1
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/ansi-regex/index.js +22 -17
- package/node_modules/ansi-regex/package.json +1 -1
- package/node_modules/ansi-regex/readme.md +8 -0
- package/package.json +11 -11
- package/node_modules/@zuplo/runtime/out/esm/chunk-2HVCLUM4.js +0 -37
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-DB6LKZ36.js.LEGAL.txt → chunk-F4G3YEN2.js.LEGAL.txt} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-DB6LKZ36.js.map → chunk-F4G3YEN2.js.map} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-PY52EHDX.js.map → chunk-GWGCD6Z7.js.map} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-SNTU476S.js.map → chunk-HTXNM72E.js.map} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-2HVCLUM4.js.LEGAL.txt → chunk-M4IZPJP6.js.LEGAL.txt} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-6R2COTV6.js.map → chunk-SX6JF7A6.js.map} +0 -0
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*--------------------------------------------------------------------------------------------*/
|
|
24
24
|
|
|
25
|
-
import{a as wA,b as CA,c as kA,d as di,e as Fe,f as LA,g as rf,h as NA,i as UA,j as qA,k as rR,m as iR,o as $A,q as sR,r as aR}from"./chunk-VP5Q3DEN.js";import{a as Be,b as nf,c as pi,d as OA,h as MA,i as of,j as Lu,n as DA,r as Fo,s as oR}from"./chunk-PY52EHDX.js";import{A as m,B as rs,C as Xe,D as wa,F as tt,G as $t,H as ef,I as _A,J as tf,K as xA,L as jA,M as Nu,N as zA,O as HA,a as vA,b as nR,c as TA,d as w,e as IA,f as Xm,g as se,h as ve,i as ts,j as EA,k as qe,l as $,m as O,n as De,o as Te,p as Sa,q as li,r as Se,s as Je,t as z,u as Le,v as Mu,w as ns,x as PA,y as os,z as AA}from"./chunk-6R2COTV6.js";import{a as be}from"./chunk-UKQQD2JN.js";import{$ as _,A as Zm,B as nA,C as oA,D as rA,E as iA,F as sA,G as aA,H as cA,I as uA,J as lA,K as Vm,L as dA,M as pA,N as Jm,O as Km,P as mA,Q as Wm,R as Ym,S as fA,T as hA,U as gA,V as yA,W as bA,X as RA,Y as Ra,Z as SA,_ as Qm,a as je,aa as K,b as tR,c as B,d as T,e as ct,f as zP,g as es,h as HP,i as ba,j as FP,k as BP,l as GP,m as ZP,n as VP,o as JP,p as KP,q as WP,r as YP,s as QP,t as XP,u as eA,v as tA,w as Hm,x as Fm,y as Bm,z as Gm}from"./chunk-2HVCLUM4.js";import{a as i,b as xB,d as OB}from"./chunk-TYV53J3B.js";var v_=xB(Uf=>{"use strict";Object.defineProperty(Uf,"__esModule",{value:!0});Uf.parse=t2;Uf.serialize=n2;var KZ=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,WZ=/^[\u0021-\u003A\u003C-\u007E]*$/,YZ=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,QZ=/^[\u0020-\u003A\u003D-\u007E]*$/,XZ=Object.prototype.toString,e2=(()=>{let e=i(function(){},"C");return e.prototype=Object.create(null),e})();function t2(e,t){let n=new e2,o=e.length;if(o<2)return n;let r=t?.decode||o2,s=0;do{let a=e.indexOf("=",s);if(a===-1)break;let c=e.indexOf(";",s),u=c===-1?o:c;if(a>u){s=e.lastIndexOf(";",a-1)+1;continue}let l=w_(e,s,a),d=C_(e,a,l),p=e.slice(l,d);if(n[p]===void 0){let f=w_(e,a+1,u),h=C_(e,u,f),g=r(e.slice(f,h));n[p]=g}s=u+1}while(s<o);return n}i(t2,"parse");function w_(e,t,n){do{let o=e.charCodeAt(t);if(o!==32&&o!==9)return t}while(++t<n);return n}i(w_,"startIndex");function C_(e,t,n){for(;t>n;){let o=e.charCodeAt(--t);if(o!==32&&o!==9)return t+1}return n}i(C_,"endIndex");function n2(e,t,n){let o=n?.encode||encodeURIComponent;if(!KZ.test(e))throw new TypeError(`argument name is invalid: ${e}`);let r=o(t);if(!WZ.test(r))throw new TypeError(`argument val is invalid: ${t}`);let s=e+"="+r;if(!n)return s;if(n.maxAge!==void 0){if(!Number.isInteger(n.maxAge))throw new TypeError(`option maxAge is invalid: ${n.maxAge}`);s+="; Max-Age="+n.maxAge}if(n.domain){if(!YZ.test(n.domain))throw new TypeError(`option domain is invalid: ${n.domain}`);s+="; Domain="+n.domain}if(n.path){if(!QZ.test(n.path))throw new TypeError(`option path is invalid: ${n.path}`);s+="; Path="+n.path}if(n.expires){if(!r2(n.expires)||!Number.isFinite(n.expires.valueOf()))throw new TypeError(`option expires is invalid: ${n.expires}`);s+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(s+="; HttpOnly"),n.secure&&(s+="; Secure"),n.partitioned&&(s+="; Partitioned"),n.priority)switch(typeof n.priority=="string"?n.priority.toLowerCase():void 0){case"low":s+="; Priority=Low";break;case"medium":s+="; Priority=Medium";break;case"high":s+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${n.priority}`)}if(n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite){case!0:case"strict":s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"none":s+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${n.sameSite}`)}return s}i(n2,"serialize");function o2(e){if(e.indexOf("%")===-1)return e;try{return decodeURIComponent(e)}catch{return e}}i(o2,"decode");function r2(e){return XZ.call(e)==="[object Date]"}i(r2,"isDate")});var et=new Proxy({},{get(e,t){let n=String(t);switch(n){case"ZUPLO_ENVIRONMENT_TYPE":return _.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return _.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return _.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return _.instance.accountName;case"ZUPLO_PROJECT_NAME":return _.instance.projectName;case"ZUPLO_BUILD_ID":return _.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return _.instance.build.COMPATIBILITY_DATE}if(!(wA(n)&&!CA(n)))return _.instance.runtime[n]}});var FA=new Map([["input","input"],["cache-read-input","cache_read_input"],["cache-write-input","cache_write_input"],["output","output"]]),MB=new Set(["5m","1h"]);function BA(e){return typeof e!="object"||e===null||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).filter(([,t])=>t!==null))}i(BA,"withoutNullFields");var GA=m.number().int().min(0).max(Number.MAX_SAFE_INTEGER),LB=m.object({category:m.enum(["input","cache_read_input","cache_write_input","output"]),costPerToken:m.number().nonnegative(),minInputTokens:GA.optional(),maxInputTokens:GA.optional(),cacheTtl:m.enum(["5m","1h"]).optional()}).superRefine((e,t)=>{e.minInputTokens!==void 0&&e.maxInputTokens!==void 0&&e.minInputTokens>e.maxInputTokens&&t.addIssue({code:"custom",path:["minInputTokens"],message:"must not exceed maxInputTokens"}),e.cacheTtl!==void 0&&e.category!=="cache_write_input"&&t.addIssue({code:"custom",path:["cacheTtl"],message:"is only valid for cache_write_input rates"})}),NB=m.object({revision:m.string().min(1),currency:m.literal("USD"),rates:m.array(LB)}).superRefine((e,t)=>{for(let n=0;n<e.rates.length;n++){let o=e.rates[n];for(let r=n+1;r<e.rates.length;r++){let s=e.rates[r];if(o.category!==s.category||o.cacheTtl!==s.cacheTtl)continue;let a=o.minInputTokens??0,c=o.maxInputTokens??Number.POSITIVE_INFINITY,u=s.minInputTokens??0,l=s.maxInputTokens??Number.POSITIVE_INFINITY;a<=l&&u<=c&&t.addIssue({code:"custom",path:["rates",r],message:`overlaps rates.${n} for the same category and qualifiers`})}}});function UB(e){let t=BA(e);if(typeof t!="object"||t===null||Array.isArray(t))return{card:t,ignoredRates:[]};let n=t.rates;if(!Array.isArray(n))return{card:t,ignoredRates:[]};let o=[],r=[];for(let s of n){let a=BA(s);if(typeof a!="object"||a===null||Array.isArray(a)){r.push(a);continue}let{category:c,cacheTtl:u}=a;if(typeof c=="string"&&!FA.has(c)){o.push(`category ${JSON.stringify(c)}`);continue}if(typeof u=="string"&&!MB.has(u)){o.push(`cacheTtl ${JSON.stringify(u)}`);continue}r.push(typeof c=="string"?{...a,category:FA.get(c)}:a)}return{card:{...t,rates:r},ignoredRates:o}}i(UB,"fromWireCard");function JA(e){let t=NB.safeParse(e);if(t.success){let{revision:n,currency:o,rates:r}=t.data;return{tokenRateCard:{revision:n,currency:o,rates:r}}}return{error:t.error.issues.map(n=>`${n.path.length>0?n.path.join("."):"<root>"}: ${n.message}`).join("; ")}}i(JA,"parseTokenRateCard");function ZA(e){if(e==null)return{};let{card:t,ignoredRates:n}=UB(e),o=JA(t);return o.tokenRateCard===void 0||n.length===0?o:{...o,ignoredRates:n}}i(ZA,"validateTokenRateCard");function sf(e){return[e.category,e.cacheTtl??"",e.minInputTokens??"",e.maxInputTokens??""].join("\0")}i(sf,"rateSelector");function qB(e,t){let n=new Map(t.rates.map(r=>[sf(r),r])),o=new Set(e.rates.map(sf));return{revision:t.revision,currency:t.currency,rates:[...e.rates.map(r=>n.get(sf(r))??r),...t.rates.filter(r=>!o.has(sf(r)))]}}i(qB,"mergeTokenRateCards");function KA(e,t){let n=ZA(e);if(n.tokenRateCard===void 0)return n.error===void 0?{}:{error:n.error};let o=ZA(t),r=[VA("list",n),VA("override",o,t)].filter(c=>c!==void 0),s=r.length===0?{}:{ignoredRates:r};if(o.error!==void 0)return{tokenRateCard:n.tokenRateCard,overrideError:o.error,...s};if(o.tokenRateCard===void 0)return{tokenRateCard:n.tokenRateCard,...s};let a=JA(qB(n.tokenRateCard,o.tokenRateCard));return a.tokenRateCard===void 0?{tokenRateCard:n.tokenRateCard,overrideError:`merged card: ${a.error}`,...s}:{tokenRateCard:a.tokenRateCard,...s}}i(KA,"resolveModelTokenRateCard");function VA(e,t,n){if(t.ignoredRates===void 0)return;let o=typeof n=="object"&&n!==null?n.revision:void 0,r=t.tokenRateCard?.revision??(typeof o=="string"?o:void 0);return{card:e,...r===void 0?{}:{revision:r},values:t.ignoredRates}}i(VA,"ignoredRatesOf");var pe=class e{static{i(this,"SystemLogMap")}static#e=new WeakMap;static getLogger(t){let n=e.#e.get(t);if(!n){let o=`No system logger found for context with requestId '${t.requestId}'`;throw K.console.error(o),new je(o)}return n}static addLogger(t,n){e.#e.set(t,n)}};function pt(e,t){e.has("Authorization")||e.set("Authorization",`Bearer ${_.instance.authApiJWT}`),e.set("zp-rid",t??`global-${crypto.randomUUID()}`),e.set("zp-dn",_.instance.deploymentName??"unknown"),e.set("User-Agent",_.instance.systemUserAgent),e.set("zp-compat-date",_.instance.build.COMPATIBILITY_DATE??"none")}i(pt,"setZuploHeaders");var YA=["openai","anthropic","google","mistral","xai","bedrock-mantle","vertex-ai","openrouter","jev"];function WA(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}i(WA,"defineOwn");function DB(e,t,n){for(let[o,r]of Object.entries(t)){let s=r.deploymentModels;if(!s)continue;let a=e[o];if(!a){n.warn("AI provider assignment maps deployments but has no catalog models; deployment usage will not resolve a cost",{label:o,deployments:Object.keys(s)});continue}let c={...a};for(let[u,l]of Object.entries(s)){let d=Object.hasOwn(c,l)?c[l]:void 0;if(!d){n.warn("AI provider deployment maps to a model that is not in the catalog; usage against this deployment would be costed at zero",{label:o,deployment:u,model:l,available:Object.keys(c)});continue}let p={...d,model:u,aliasOf:d.model};WA(a,u,p);let f=u.toLowerCase();f!==u&&!Object.hasOwn(a,f)&&WA(a,f,{...p,model:f})}}}i(DB,"applyDeploymentModelAliases");var $B="openrouter",jB=[":nitro",":floor",":online",":exacto"],zB="bedrock-runtime",HB=/^arn:aws(?:-[a-z]+)*:bedrock:[a-z0-9-]+:\d*:(?:foundation-model|inference-profile)\/([^/]+)$/;function FB(e){return HB.exec(e)?.[1]}i(FB,"bedrockArnModelId");function vr(e,t,n){if(!e)return;let o=i(u=>Object.hasOwn(e,u)?e[u]:void 0,"own"),r=i(u=>{let l=o(u.toLowerCase());return o(u)??(l?.aliasOf?l:void 0)},"resolve"),s=r(t);if(s)return s;let a=n?.toLowerCase();if(a===zB){let u=FB(t);return u===void 0?void 0:r(u)}if(a!==$B)return;let c=jB.find(u=>t.endsWith(u));if(c!==void 0)return r(t.slice(0,-c.length))}i(vr,"resolveModelRow");var BB=60,QA="connections-v1";async function XA(e){let t=await Xe("supported-models",{});return new tt(t,e)}i(XA,"createSupportedModelsCache");async function Uu(e){return(await XA(e)).get(QA)}i(Uu,"getCachedSupportedModels");function cR(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(cR,"isRecord");function GB(e){return cR(e)&&Array.isArray(e.data)&&e.data.every(t=>cR(t)&&typeof t.label=="string"&&typeof t.providerType=="string"&&typeof t.isCustom=="boolean"&&Array.isArray(t.models)&&t.models.every(n=>cR(n)&&typeof n.model=="string"&&typeof n.kind=="string"&&typeof n.status=="string"))}i(GB,"isProviderAssignmentsResponse");function ZB(e){let t={},n={};for(let o of e.data)t[o.label]=o.models.map(r=>({info:{...o.isCustom?{id:r.id}:{},model:r.model,kind:r.kind,status:r.status,...r.dialect==null?{}:{dialect:r.dialect},...r.basePath==null?{}:{basePath:r.basePath}},tokenRateCard:r.tokenRateCard,overriddenTokenRateCard:r.overriddenTokenRateCard})),n[o.label]={...o.isCustom?{id:o.providerId}:{},baseUrl:o.baseUrl??"",isCustom:o.isCustom,...o.envVarName==null?{}:{envVarName:o.envVarName},providerType:o.providerType,...o.deploymentModels==null?{}:{deploymentModels:o.deploymentModels},...o.gcpProjectId==null?{}:{gcpProjectId:o.gcpProjectId}};return{models:t,providers:n}}i(ZB,"fromProviderAssignments");function VB(e){let t=typeof e=="object"&&e!==null?e.revision:void 0;return typeof t=="string"?t:void 0}i(VB,"overrideRevision");function JB(e,t){let n={};for(let[r,s]of Object.entries(e.models)){let a=r.toLowerCase();n[a]={};for(let c of s){let u=KA(c.tokenRateCard,c.overriddenTokenRateCard);u.error!==void 0&&t.warn("Ignoring invalid AI model token rate card",{provider:r,model:c.info.model,error:u.error});for(let l of u.ignoredRates??[])t.warn("Ignoring AI model token rates with an unknown category or cache TTL",{provider:r,model:c.info.model,card:l.card,revision:l.revision,unknown:l.values});u.overrideError!==void 0&&t.error("Ignoring invalid AI model override token rate card; pricing at the list card",{provider:r,model:c.info.model,overrideRevision:VB(c.overriddenTokenRateCard),error:u.overrideError}),n[a][c.info.model]={...c.info,...u.tokenRateCard===void 0?{}:{tokenRateCard:u.tokenRateCard}}}}let o={};for(let[r,s]of Object.entries(e.providers))o[r.toLowerCase()]=s;return DB(n,o,t),{modelsByProvider:n,providerMetadata:o}}i(JB,"buildSupportedModels");async function so(e,t){let n=pe.getLogger(e),o=await Uu(e);if(o)return n.info("Using cached supported models data",{providersCount:Object.keys(o.modelsByProvider).length,providers:Object.keys(o.modelsByProvider)}),{modelsByProvider:o.modelsByProvider,providerMetadata:o.providerMetadata};let r=new Headers({"content-type":"application/json"});pt(r,e.requestId);let s=et.ZUPLO_SERVICE_BUCKET_ID,a=new URL(`/v1/buckets/${s}/provider-assignments?includeDeprecated=true`,_.instance.zuploEdgeApiUrl).toString(),c=await $t({retryDelayMs:100,retries:t?.retries??5,retryOn404:!0,logger:n},a,{method:"GET",headers:r,signal:t?.signal});if(c.status!==200){let f="Failed to fetch supported models from Gateway service";try{let h=await c.text(),g=JSON.parse(h);n.error(f,g),f=`${f}: ${g.message||c.statusText}`}catch{n.error(f,{status:c.status}),f=`${f}: ${c.status}`}throw new Error(f)}let u=await c.json();if(!GB(u)){let f="Gateway service returned an unexpected provider assignments body";throw n.error(f,{bucketId:s}),new Error(f)}let l=ZB(u);n.info("Gateway service response received",{providersCount:Object.keys(l.models).length,providers:Object.keys(l.models),totalModels:Object.values(l.models).reduce((f,h)=>f+h.length,0)});let d=JB(l,n),p=await XA(e);return t?.signal.throwIfAborted(),p.put(QA,d,BB),d}i(so,"getSupportedModels");async function ek(e){let t=new AbortController,n;try{return await Promise.race([so(e,{signal:t.signal,retries:0}),new Promise((o,r)=>{n=setTimeout(()=>{t.abort(),r(new Error("Model discovery catalog deadline exceeded"))},2e3)})])}finally{clearTimeout(n)}}i(ek,"getDiscoverySupportedModels");function uR(e,t){let n=e.provider.toLowerCase();if(!e.environmentVariable)return n;for(let[o,r]of Object.entries(t))if(r.envVarName===e.environmentVariable)return o;return n}i(uR,"resolveProviderLabel");function tk(e){let t=Object.entries(e).map(([n,o])=>o.envVarName?`'${n}' (envVarName: ${o.envVarName})`:`'${n}'`);return t.length>0?t.join(", "):"none"}i(tk,"describeProviderAssignments");function nk(e,t,n,o){let r=t.toLowerCase(),s=o[r];if(!s)return!1;let a=s[e];return a?a.kind===n&&a.status==="active":!1}i(nk,"isModelSupported");function ok(e,t,n){let o=e.toLowerCase(),r=n[o];return r?Object.values(r).filter(s=>s.kind===t&&s.status==="active").map(s=>s.model):[]}i(ok,"getModelsByProviderAndKind");var rk=new be(Symbol("ai-gateway-provider-credential-passthrough"));function ik(e,t){rk.set(e,t)}i(ik,"setProviderCredentialPassthrough");function lR(e){return rk.get(e)}i(lR,"getProviderCredentialPassthrough");function af(e){return lR(e)!==void 0}i(af,"hasProviderCredentialPassthrough");function KB(e){return{revision:e.revision,currency:e.currency,rates:e.rates.map(t=>({category:t.category.replaceAll("_","-"),costPerToken:t.costPerToken,...t.cacheTtl===void 0?{}:{cacheTtl:t.cacheTtl},...t.minInputTokens===void 0?{}:{minInputTokens:t.minInputTokens},...t.maxInputTokens===void 0?{}:{maxInputTokens:t.maxInputTokens}}))}}i(KB,"publicTokenRateCard");var lk=Symbol("ai-gateway-model-selection"),WB="zuplodemo",YB="azure-ai",qu="https://demo.zuplo.ai";function QB(e){return e?.providerType?.toLowerCase()===WB&&e.isCustom!==!0}i(QB,"isZuploDemoAssignment");var sk=Symbol("ai-gateway-model-routing"),is='Use "providerName/model", for example "openai/gpt-5".',dR=["completions","embeddings"],ak=["main","backup","fallbackTimeoutSeconds","quotaFallback"];function Bo(e,t,n){throw new T(`Invalid AI Gateway model routing field '${e}': ${t}. ${n}`)}i(Bo,"invalid");function an(e,t,n,o){return o?o(e,t,n):Bo(e,t,n)}i(an,"reject");function pR(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(pR,"isRecord");function ln(e,t,n){if(typeof e!="string")return an(t,"must be a string",is,n);if(e.length===0)return an(t,"must not be empty",is,n);if(e.trim()!==e||/\s/.test(e))return an(t,`contains whitespace in '${e}'`,is,n);let o=e.indexOf("/");if(o===-1)return an(t,`'${e}' has no provider name separator`,is,n);let r=e.slice(0,o),s=e.slice(o+1);return r.length===0?an(t,`'${e}' has an empty provider name`,is,n):/^[A-Za-z0-9._-]+$/.test(r)?s.length===0?an(t,`'${e}' has an empty model`,is,n):s.startsWith("/")?an(t,`'${e}' starts the model with an extra "/"`,is,n):{provider:r,model:s,raw:e}:an(t,`provider name '${r}' contains unsupported characters`,'Use only letters, numbers, ".", "_", or "-" in the provider name',n)}i(ln,"parseModelRef");function XB(e,t,n){let o=typeof e=="string"?{main:e}:pR(e)?e:{};if(typeof e!="string"&&!pR(e))return an(t,"must be a model reference string or an object",'Set it to "providerName/model" or { main: "openai/gpt-5" }',n);let r=Object.keys(o).filter(l=>!ak.includes(l));if(r.length>0)return an(`${t}.${r[0]}`,`unknown property '${r[0]}'`,`Remove it; supported properties are ${ak.join(", ")}`,n);if(Object.keys(o).length===0)return an(t,"must not be an empty object",`Set 'main' to a "providerName/model" reference`,n);let s=ln(o.main,`${t}.main`,n);if(o.backup===null)return an(`${t}.backup`,"is null",'Set it to a "providerName/model" reference, or omit the field instead',n);if(o.quotaFallback===null)return an(`${t}.quotaFallback`,"is null",'Set it to a "providerName/model" reference, or omit the field instead',n);let a=o.backup===void 0?void 0:ln(o.backup,`${t}.backup`,n),c=o.quotaFallback===void 0?void 0:ln(o.quotaFallback,`${t}.quotaFallback`,n);if(a?.raw.toLowerCase()===s.raw.toLowerCase())return an(`${t}.backup`,`must differ from '${t}.main'`,"Choose a different backup model or omit 'backup'",n);if(c?.raw.toLowerCase()===s.raw.toLowerCase())return an(`${t}.quotaFallback`,`must differ from '${t}.main'`,"Choose a different quota fallback model or omit 'quotaFallback'",n);let u=o.fallbackTimeoutSeconds;if(u!==void 0){if(a===void 0)return an(`${t}.fallbackTimeoutSeconds`,"requires a backup model","Set 'backup' or omit 'fallbackTimeoutSeconds'",n);if(typeof u=="string")return an(`${t}.fallbackTimeoutSeconds`,`is a string '${u}', not a number`,"Remove the quotes and set it to a number from 1 through 300",n);if(typeof u!="number"||!Number.isFinite(u)||u<1)return an(`${t}.fallbackTimeoutSeconds`,"must be a finite number greater than or equal to 1","Set it to a number from 1 through 300",n);if(u>300)return an(`${t}.fallbackTimeoutSeconds`,"must not exceed the platform request duration of 300 seconds","Set it to 300 or less so the backup can run before the request ends",n)}return{main:s.raw,...a===void 0?{}:{backup:a.raw},...u===void 0?{}:{fallbackTimeoutSeconds:u},...c===void 0?{}:{quotaFallback:c.raw}}}i(XB,"normalizeAIGatewayRouteTarget");async function ss(e){let{modelsByProvider:t,providerMetadata:n}=await so(e),r=[...new Set([...Object.keys(t),...Object.keys(n)])].map(a=>{let c=n[a],u=Object.values(t[a]??{}).map(l=>({model:l.model,capability:l.kind,status:l.status,...l.tokenRateCard===void 0?{}:{tokenRateCard:KB(l.tokenRateCard)}}));return{providerName:a,...c?.baseUrl===void 0?{}:{baseUrl:c.baseUrl},...c?.isCustom===void 0?{}:{isCustom:c.isCustom},...c?.providerType===void 0?{}:{providerType:c.providerType.toLowerCase()},models:u}}),s=new Map;for(let[a,c]of Object.entries(n))c.envVarName!==void 0&&s.set(a.toLowerCase(),c.envVarName);return{providers:r,providerEnvironmentVariables:s,modelsByProvider:t,providerMetadata:n}}i(ss,"loadProviders");function eG(e){return`${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_API_KEY`}i(eG,"conventionEnvironmentVariable");function ck(e){return e&&et[e]?.trim()||void 0}i(ck,"nonEmptyEnvironmentValue");function mR(e){let{provider:t,providerEnvironmentVariables:n,metadata:o,path:r,allowMissingApiKey:s,log:a}=e;if(QB(o)){let p;try{p=new URL(o.baseUrl).origin}catch{}return p!==qu?Bo(r,`ZuploDemo provider URL '${o.baseUrl}' is not the trusted demo provider origin '${qu}'`,`Set the ZuploDemo catalog base URL to '${qu}', or choose a keyed provider`):_.instance.authApiJWT?.trim()?{apiKeySource:"zuplodemo"}:Bo(r,"ZuploDemo requires a Zuplo deployment JWT, but this gateway does not have one","Deploy the gateway through Zuplo so it receives a deployment JWT, or choose a keyed provider")}let c=n.get(t.toLowerCase()),u=eG(t),l,d;if(c!==void 0){let p=ck(c);p!==void 0&&(l=p,d=c)}if(l===void 0){let p=ck(u);p!==void 0&&(l=p,d=u)}if(l===void 0){if(s===!0)return{};if(c!==void 0)throw a?.setLogProperties?.({aiProvider:t,aiProviderEnvironmentVariable:c,aiProviderConventionalEnvironmentVariable:u,aiRoutingField:r}),a?.error("AI provider key not present in this deployment. Provider changes redeploy the gateway automatically; if this persists, redeploy from AI Settings \u2192 General in the Zuplo Portal."),new T(`Provider '${t}' is not ready on this gateway yet. If a provider was recently added or changed, the gateway may still be updating; retry in a minute or two. If this persists, contact the gateway administrator.`);return Bo(r,`could not resolve an API key for provider name '${t}'. No key binding found in your account's AI providers and conventional environment variable '${u}' is not set`,`Add an AI provider named '${t}' with an API key in the Zuplo Portal, or set '${u}'`)}return{apiKey:l,environmentVariable:d}}i(mR,"resolveApiKey");function tG(e){let{provider:t,providers:n,path:o}=e,r=n.find(({providerName:a})=>a.toLowerCase()===t.toLowerCase());if(r!==void 0)return r.providerName;let s=n.map(({providerName:a})=>a).sort().join(", ");Bo(o,`references unknown provider name '${t}'`,`Use 'providerName/model' to select a configured provider; configured provider names: ${s||"none"}`)}i(tG,"resolveCatalogEntryLabel");function nG(e){let{provider:t,model:n,capability:o,modelsByProvider:r,providerMetadata:s,path:a}=e,c=t.toLowerCase(),u=s[c],l=u?.providerType?.toLowerCase();if(l===void 0||u?.isCustom!==!1||l===YB)return;let d=vr(r[c],n,l);d?.kind===o&&d.status==="active"||(d?.kind===o&&Bo(a,`model '${n}' is not active for provider name '${t}'`,`Update provider '${t}' model selections to use an active model, or use another provider name that offers it`),Bo(a,`model '${n}' is not included in model selections for provider name '${t}'`,`Update provider '${t}' model selections to include '${n}', or use another provider name that offers it`))}i(nG,"assertAssignmentOffersModel");function uk(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}i(uk,"cloneRouting");function oG(e,t){be.set(e,lk,t)}i(oG,"setModelSelection");function qn(e){return be.get(e,lk)}i(qn,"getModelSelection");var fR={async load(e){let{providers:t}=await ss(e);return t}},En={async set(e,t){if(!pR(t))return Bo("routing","must be an object","Set at least one of 'completions' or 'embeddings'");let n=Object.keys(t).filter(d=>!dR.includes(d));if(n.length>0)return Bo(`routing.${n[0]}`,`unknown capability '${n[0]}'`,"Use 'completions' or 'embeddings', or remove this property");let o=dR.filter(d=>t[d]!==void 0);if(o.length===0)return Bo("routing","must not be empty","Set at least one of 'completions' or 'embeddings'");let r={};for(let d of o)r[d]=XB(t[d],`routing.${d}`);let{providers:s,providerEnvironmentVariables:a,modelsByProvider:c,providerMetadata:u}=await ss(e),l={};for(let d of dR){let p=r[d];if(typeof p!="object")continue;let f=ln(p.main,`routing.${d}.main`),h=p.backup?ln(p.backup,`routing.${d}.backup`):void 0,g=p.quotaFallback?ln(p.quotaFallback,`routing.${d}.quotaFallback`):void 0,S=new Map;for(let[C,v]of[["main",f],["backup",h],["quotaFallback",g]])if(v){let I=tG({provider:v.provider,providers:s,path:`routing.${d}.${C}`});nG({provider:I,model:v.model,capability:d,modelsByProvider:c,providerMetadata:u,path:`routing.${d}.${C}`});let P={...v,provider:I};S.set(C,P)}let b=i(C=>{let v=S.get(C);if(v===void 0)throw new Error(`Missing resolved AI Gateway routing field '${C}'`);let I=u[v.provider.toLowerCase()];return{provider:v.provider,model:v.model,...mR({provider:v.provider,providerEnvironmentVariables:a,metadata:I,path:`routing.${d}.${C}`,allowMissingApiKey:C==="main"&&af(e),log:e.log})}},"toCandidate");l[d]={candidates:[b("main"),...h?[b("backup")]:[]],...h?{fallbackTimeoutSeconds:p.fallbackTimeoutSeconds??60}:{},...g?{quotaFallback:b("quotaFallback")}:{}}}oG(e,{byCapability:l}),be.set(e,sk,uk(r))},get(e){let t=be.get(e,sk);return t===void 0?void 0:uk(t)}};var rG=new Set(["converse","converse-stream","invoke","invoke-with-response-stream"]),iG=new Set(["count-tokens","invoke-with-bidirectional-stream"]),sG=/\/model\/(.+)\/([a-z-]+)$/;function as(e){let t=e.replace(/\/{2,}/g,"/"),n=t.split("/"),o=n[1]==="a"||n[1]==="u"?3:2;if(n.length<o+3||n[o]!=="model")return null;let r=sG.exec(t);if(!r)return null;let[,s,a]=r;return!s||!a?null:rG.has(a)?{operation:a,requested:a,encodedModelId:s}:iG.has(a)?{operation:"unsupported",requested:a,encodedModelId:s}:null}i(as,"matchBedrockRuntimeRoute");function Zt(e){return as(e)!==null}i(Zt,"isBedrockRuntimeRoute");function dk(e){try{return decodeURIComponent(e)}catch{return e}}i(dk,"decodeBedrockModelId");function ao(e,t,n,o){if(Zt(e))return cn(t,aG(t),n,o)}i(ao,"bedrockPolicyErrorResponse");function aG(e){return e===401||e===403?"AccessDeniedException":e===404?"ResourceNotFoundException":e===429?"ThrottlingException":e>=500?e===503?"ServiceUnavailableException":"InternalServerException":"ValidationException"}i(aG,"bedrockExceptionForStatus");function cn(e,t,n,o){let r={"content-type":"application/json","x-amzn-errortype":t};return o&&(r["x-amzn-requestid"]=o),new Response(JSON.stringify({message:n}),{status:e,headers:r})}i(cn,"createBedrockErrorResponse");function hR(e,t,n){if(Zt(e))return cn(400,"ServiceQuotaExceededException",t,n)}i(hR,"bedrockQuotaExceededResponse");function Du(e){if(Zt(e))return null;let t=/\/v1\/models(?:\/|$)/.exec(e);return t?.index===void 0?null:e.slice(t.index)}i(Du,"resolveModelsBasePath");function Tt(e){return Du(new URL(e.url).pathname)!==null}i(Tt,"isModelsDiscoveryRoute");function Ca(e,t){return e.provider.toLowerCase()===t.provider.toLowerCase()&&e.model.toLowerCase()===t.model.toLowerCase()}i(Ca,"refsEqual");function Go(e){let t=new URL(e.url).pathname;return Zt(t)?{capability:"completions",nativeProvider:"bedrock-runtime"}:t.endsWith("/v1/embeddings")?{capability:"embeddings"}:t.endsWith("/v1/messages/count_tokens")?{capability:"completions",nativeProvider:"anthropic"}:t.endsWith("/v1/messages")?{capability:"completions",nativeProvider:"anthropic"}:t.endsWith("/v1/systemone")?{capability:"completions",nativeProvider:"jev"}:/\/v1\/responses(?:\/|$)/.test(t)?{capability:"completions",nativeProvider:"openai"}:{capability:"completions"}}i(Go,"resolveAIGatewayRequestRoute");function pk(e){let t;try{t=new URL(e.url).pathname}catch{return}let n=i(o=>t===o||t.endsWith(o),"matchesBase");if(!Zt(t)&&!n("/v1/systemone")){if(n("/v1/chat/completions")||n("/v1/responses")||n("/v1/messages")||n("/v1/messages/count_tokens"))return"completions";if(n("/v1/embeddings"))return"embeddings"}}i(pk,"resolveMeteredCapability");function va(e,t,n,o){return vr(n?.[e.toLowerCase()],t,o)?.dialect?.toLowerCase()}i(va,"catalogModelDialect");var cG={openai:new Set(["xai"])};function Ta(e){let t=e.nativeProvider.toLowerCase(),n=e.providerType?.toLowerCase();return n===t||n!==void 0&&cG[t]?.has(n)===!0||e.dialect?.toLowerCase()===t}i(Ta,"selectionSatisfiesNativeProvider");function uG(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(uG,"isRecord");async function lG(e){try{let t=await e.clone().json();if(uG(t)&&Object.hasOwn(t,"model"))return{present:!0,value:t.model}}catch{}return{present:!1,value:void 0}}i(lG,"readAIGatewayRequestModel");async function mi(e){let t=as(new URL(e.url).pathname);return t!==null?{present:!0,value:dk(t.encodedModelId)}:lG(e)}i(mi,"readAIGatewayRequestedModel");function cf(e){if(Zt(new URL(e.url).pathname)){let t='"bedrock/anthropic.claude-sonnet-4-5-20250929-v1:0" (the AWS SDKs percent-encode it into one path segment for you)';return{source:"modelId",missing:`Send a qualified "providerName/model" as the modelId, for example ${t}.`,malformed:`The modelId must use "providerName/model", for example ${t}.`}}return{source:"request.body.model",missing:'Send "providerName/model", for example "openai/gpt-5".',malformed:'The request body model must use "providerName/model", for example "openai/gpt-5".'}}i(cf,"describeRequestModelSource");function Ia(e,t="request.body.model"){let n=ln(e,t);return{ref:n,raw:n.raw}}i(Ia,"parseAIGatewayRequestModel");var dG=new Set(["response.completed","response.failed","response.incomplete","response.cancelled","response.expired"]),pG=[["/v1/responses","openai-responses"],["/v1/messages","anthropic-messages"],["/v1/chat/completions","openai-chat"]];function Qt(e){if(Tt(e))return null;let t=new URL(e.url).pathname;if(Zt(t))return null;for(let[n,o]of pG)if(t===n||t.endsWith(n)||t.includes(`${n}/`))return o;return null}i(Qt,"getFormat");async function $u(e){let t=Qt(e);if(!t)return null;let n;try{n=await e.clone().json()}catch{return null}return{format:t,body:n}}i($u,"getRequestBody");async function mG(e,t){let n=Qt(e);if(!n)return null;let o;try{o=await t.clone().json()}catch{return null}return{format:n,body:o}}i(mG,"getResponseBody");function gR(e){let t=e?.usage;if(!t||typeof t!="object")return;let n=i(c=>typeof c=="number"?c:void 0,"num"),o=n(t.input_tokens)??n(t.prompt_tokens),r=n(t.output_tokens)??n(t.completion_tokens);if(o===void 0&&r===void 0)return;let s=o??0,a=r??0;return{promptTokens:s,completionTokens:a,totalTokens:n(t.total_tokens)??s+a}}i(gR,"getUsage");function lt(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>lt(t)).filter(Boolean).join(" ");if(e&&typeof e=="object"){let t=e;if(typeof t.text=="string")return t.text;if(t.type==="thinking"&&typeof t.thinking=="string")return t.thinking;if(typeof t.input_text=="string")return t.input_text;if(t.content!==void 0)return lt(t.content);let n=t.source;if(n&&n.type==="text"&&typeof n.data=="string")return n.data}return""}i(lt,"flattenMessageContent");function Ea(e){if(!e||typeof e!="object")return"";let t=e,n=[];if(Array.isArray(t.messages))for(let o of t.messages)n.push(lt(o.content));if(typeof t.system=="string"?n.push(t.system):Array.isArray(t.system)&&n.push(lt(t.system)),typeof t.instructions=="string"&&n.push(t.instructions),typeof t.input=="string")n.push(t.input);else if(Array.isArray(t.input))for(let o of t.input)n.push(lt(o.content));if(Array.isArray(t.choices))for(let o of t.choices)n.push(lt(o.message?.content));if(Array.isArray(t.output))for(let o of t.output)n.push(lt(o.content));return Array.isArray(t.content)&&n.push(lt(t.content)),n.filter(Boolean).join(`
|
|
25
|
+
import{a as wA,b as CA,c as kA,d as di,e as Fe,f as LA,g as rf,h as NA,i as UA,j as qA,k as rR,m as iR,o as $A,q as sR,r as aR}from"./chunk-VP5Q3DEN.js";import{a as Be,b as nf,c as pi,d as OA,h as MA,i as of,j as Lu,n as DA,r as Fo,s as oR}from"./chunk-GWGCD6Z7.js";import{A as m,B as rs,C as Xe,D as wa,F as tt,G as $t,H as ef,I as _A,J as tf,K as xA,L as jA,M as Nu,N as zA,O as HA,a as vA,b as nR,c as TA,d as w,e as IA,f as Xm,g as se,h as ve,i as ts,j as EA,k as qe,l as $,m as O,n as De,o as Te,p as Sa,q as li,r as Se,s as Je,t as z,u as Le,v as Mu,w as ns,x as PA,y as os,z as AA}from"./chunk-SX6JF7A6.js";import{a as be}from"./chunk-UKQQD2JN.js";import{$ as _,A as Zm,B as nA,C as oA,D as rA,E as iA,F as sA,G as aA,H as cA,I as uA,J as lA,K as Vm,L as dA,M as pA,N as Jm,O as Km,P as mA,Q as Wm,R as Ym,S as fA,T as hA,U as gA,V as yA,W as bA,X as RA,Y as Ra,Z as SA,_ as Qm,a as je,aa as K,b as tR,c as B,d as T,e as ct,f as zP,g as es,h as HP,i as ba,j as FP,k as BP,l as GP,m as ZP,n as VP,o as JP,p as KP,q as WP,r as YP,s as QP,t as XP,u as eA,v as tA,w as Hm,x as Fm,y as Bm,z as Gm}from"./chunk-M4IZPJP6.js";import{a as i,b as xB,d as OB}from"./chunk-TYV53J3B.js";var v_=xB(Uf=>{"use strict";Object.defineProperty(Uf,"__esModule",{value:!0});Uf.parse=t2;Uf.serialize=n2;var KZ=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,WZ=/^[\u0021-\u003A\u003C-\u007E]*$/,YZ=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,QZ=/^[\u0020-\u003A\u003D-\u007E]*$/,XZ=Object.prototype.toString,e2=(()=>{let e=i(function(){},"C");return e.prototype=Object.create(null),e})();function t2(e,t){let n=new e2,o=e.length;if(o<2)return n;let r=t?.decode||o2,s=0;do{let a=e.indexOf("=",s);if(a===-1)break;let c=e.indexOf(";",s),u=c===-1?o:c;if(a>u){s=e.lastIndexOf(";",a-1)+1;continue}let l=w_(e,s,a),d=C_(e,a,l),p=e.slice(l,d);if(n[p]===void 0){let f=w_(e,a+1,u),h=C_(e,u,f),g=r(e.slice(f,h));n[p]=g}s=u+1}while(s<o);return n}i(t2,"parse");function w_(e,t,n){do{let o=e.charCodeAt(t);if(o!==32&&o!==9)return t}while(++t<n);return n}i(w_,"startIndex");function C_(e,t,n){for(;t>n;){let o=e.charCodeAt(--t);if(o!==32&&o!==9)return t+1}return n}i(C_,"endIndex");function n2(e,t,n){let o=n?.encode||encodeURIComponent;if(!KZ.test(e))throw new TypeError(`argument name is invalid: ${e}`);let r=o(t);if(!WZ.test(r))throw new TypeError(`argument val is invalid: ${t}`);let s=e+"="+r;if(!n)return s;if(n.maxAge!==void 0){if(!Number.isInteger(n.maxAge))throw new TypeError(`option maxAge is invalid: ${n.maxAge}`);s+="; Max-Age="+n.maxAge}if(n.domain){if(!YZ.test(n.domain))throw new TypeError(`option domain is invalid: ${n.domain}`);s+="; Domain="+n.domain}if(n.path){if(!QZ.test(n.path))throw new TypeError(`option path is invalid: ${n.path}`);s+="; Path="+n.path}if(n.expires){if(!r2(n.expires)||!Number.isFinite(n.expires.valueOf()))throw new TypeError(`option expires is invalid: ${n.expires}`);s+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(s+="; HttpOnly"),n.secure&&(s+="; Secure"),n.partitioned&&(s+="; Partitioned"),n.priority)switch(typeof n.priority=="string"?n.priority.toLowerCase():void 0){case"low":s+="; Priority=Low";break;case"medium":s+="; Priority=Medium";break;case"high":s+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${n.priority}`)}if(n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite){case!0:case"strict":s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"none":s+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${n.sameSite}`)}return s}i(n2,"serialize");function o2(e){if(e.indexOf("%")===-1)return e;try{return decodeURIComponent(e)}catch{return e}}i(o2,"decode");function r2(e){return XZ.call(e)==="[object Date]"}i(r2,"isDate")});var et=new Proxy({},{get(e,t){let n=String(t);switch(n){case"ZUPLO_ENVIRONMENT_TYPE":return _.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return _.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return _.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return _.instance.accountName;case"ZUPLO_PROJECT_NAME":return _.instance.projectName;case"ZUPLO_BUILD_ID":return _.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return _.instance.build.COMPATIBILITY_DATE}if(!(wA(n)&&!CA(n)))return _.instance.runtime[n]}});var FA=new Map([["input","input"],["cache-read-input","cache_read_input"],["cache-write-input","cache_write_input"],["output","output"]]),MB=new Set(["5m","1h"]);function BA(e){return typeof e!="object"||e===null||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).filter(([,t])=>t!==null))}i(BA,"withoutNullFields");var GA=m.number().int().min(0).max(Number.MAX_SAFE_INTEGER),LB=m.object({category:m.enum(["input","cache_read_input","cache_write_input","output"]),costPerToken:m.number().nonnegative(),minInputTokens:GA.optional(),maxInputTokens:GA.optional(),cacheTtl:m.enum(["5m","1h"]).optional()}).superRefine((e,t)=>{e.minInputTokens!==void 0&&e.maxInputTokens!==void 0&&e.minInputTokens>e.maxInputTokens&&t.addIssue({code:"custom",path:["minInputTokens"],message:"must not exceed maxInputTokens"}),e.cacheTtl!==void 0&&e.category!=="cache_write_input"&&t.addIssue({code:"custom",path:["cacheTtl"],message:"is only valid for cache_write_input rates"})}),NB=m.object({revision:m.string().min(1),currency:m.literal("USD"),rates:m.array(LB)}).superRefine((e,t)=>{for(let n=0;n<e.rates.length;n++){let o=e.rates[n];for(let r=n+1;r<e.rates.length;r++){let s=e.rates[r];if(o.category!==s.category||o.cacheTtl!==s.cacheTtl)continue;let a=o.minInputTokens??0,c=o.maxInputTokens??Number.POSITIVE_INFINITY,u=s.minInputTokens??0,l=s.maxInputTokens??Number.POSITIVE_INFINITY;a<=l&&u<=c&&t.addIssue({code:"custom",path:["rates",r],message:`overlaps rates.${n} for the same category and qualifiers`})}}});function UB(e){let t=BA(e);if(typeof t!="object"||t===null||Array.isArray(t))return{card:t,ignoredRates:[]};let n=t.rates;if(!Array.isArray(n))return{card:t,ignoredRates:[]};let o=[],r=[];for(let s of n){let a=BA(s);if(typeof a!="object"||a===null||Array.isArray(a)){r.push(a);continue}let{category:c,cacheTtl:u}=a;if(typeof c=="string"&&!FA.has(c)){o.push(`category ${JSON.stringify(c)}`);continue}if(typeof u=="string"&&!MB.has(u)){o.push(`cacheTtl ${JSON.stringify(u)}`);continue}r.push(typeof c=="string"?{...a,category:FA.get(c)}:a)}return{card:{...t,rates:r},ignoredRates:o}}i(UB,"fromWireCard");function JA(e){let t=NB.safeParse(e);if(t.success){let{revision:n,currency:o,rates:r}=t.data;return{tokenRateCard:{revision:n,currency:o,rates:r}}}return{error:t.error.issues.map(n=>`${n.path.length>0?n.path.join("."):"<root>"}: ${n.message}`).join("; ")}}i(JA,"parseTokenRateCard");function ZA(e){if(e==null)return{};let{card:t,ignoredRates:n}=UB(e),o=JA(t);return o.tokenRateCard===void 0||n.length===0?o:{...o,ignoredRates:n}}i(ZA,"validateTokenRateCard");function sf(e){return[e.category,e.cacheTtl??"",e.minInputTokens??"",e.maxInputTokens??""].join("\0")}i(sf,"rateSelector");function qB(e,t){let n=new Map(t.rates.map(r=>[sf(r),r])),o=new Set(e.rates.map(sf));return{revision:t.revision,currency:t.currency,rates:[...e.rates.map(r=>n.get(sf(r))??r),...t.rates.filter(r=>!o.has(sf(r)))]}}i(qB,"mergeTokenRateCards");function KA(e,t){let n=ZA(e);if(n.tokenRateCard===void 0)return n.error===void 0?{}:{error:n.error};let o=ZA(t),r=[VA("list",n),VA("override",o,t)].filter(c=>c!==void 0),s=r.length===0?{}:{ignoredRates:r};if(o.error!==void 0)return{tokenRateCard:n.tokenRateCard,overrideError:o.error,...s};if(o.tokenRateCard===void 0)return{tokenRateCard:n.tokenRateCard,...s};let a=JA(qB(n.tokenRateCard,o.tokenRateCard));return a.tokenRateCard===void 0?{tokenRateCard:n.tokenRateCard,overrideError:`merged card: ${a.error}`,...s}:{tokenRateCard:a.tokenRateCard,...s}}i(KA,"resolveModelTokenRateCard");function VA(e,t,n){if(t.ignoredRates===void 0)return;let o=typeof n=="object"&&n!==null?n.revision:void 0,r=t.tokenRateCard?.revision??(typeof o=="string"?o:void 0);return{card:e,...r===void 0?{}:{revision:r},values:t.ignoredRates}}i(VA,"ignoredRatesOf");var pe=class e{static{i(this,"SystemLogMap")}static#e=new WeakMap;static getLogger(t){let n=e.#e.get(t);if(!n){let o=`No system logger found for context with requestId '${t.requestId}'`;throw K.console.error(o),new je(o)}return n}static addLogger(t,n){e.#e.set(t,n)}};function pt(e,t){e.has("Authorization")||e.set("Authorization",`Bearer ${_.instance.authApiJWT}`),e.set("zp-rid",t??`global-${crypto.randomUUID()}`),e.set("zp-dn",_.instance.deploymentName??"unknown"),e.set("User-Agent",_.instance.systemUserAgent),e.set("zp-compat-date",_.instance.build.COMPATIBILITY_DATE??"none")}i(pt,"setZuploHeaders");var YA=["openai","anthropic","google","mistral","xai","bedrock-mantle","vertex-ai","openrouter","jev"];function WA(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}i(WA,"defineOwn");function DB(e,t,n){for(let[o,r]of Object.entries(t)){let s=r.deploymentModels;if(!s)continue;let a=e[o];if(!a){n.warn("AI provider assignment maps deployments but has no catalog models; deployment usage will not resolve a cost",{label:o,deployments:Object.keys(s)});continue}let c={...a};for(let[u,l]of Object.entries(s)){let d=Object.hasOwn(c,l)?c[l]:void 0;if(!d){n.warn("AI provider deployment maps to a model that is not in the catalog; usage against this deployment would be costed at zero",{label:o,deployment:u,model:l,available:Object.keys(c)});continue}let p={...d,model:u,aliasOf:d.model};WA(a,u,p);let f=u.toLowerCase();f!==u&&!Object.hasOwn(a,f)&&WA(a,f,{...p,model:f})}}}i(DB,"applyDeploymentModelAliases");var $B="openrouter",jB=[":nitro",":floor",":online",":exacto"],zB="bedrock-runtime",HB=/^arn:aws(?:-[a-z]+)*:bedrock:[a-z0-9-]+:\d*:(?:foundation-model|inference-profile)\/([^/]+)$/;function FB(e){return HB.exec(e)?.[1]}i(FB,"bedrockArnModelId");function vr(e,t,n){if(!e)return;let o=i(u=>Object.hasOwn(e,u)?e[u]:void 0,"own"),r=i(u=>{let l=o(u.toLowerCase());return o(u)??(l?.aliasOf?l:void 0)},"resolve"),s=r(t);if(s)return s;let a=n?.toLowerCase();if(a===zB){let u=FB(t);return u===void 0?void 0:r(u)}if(a!==$B)return;let c=jB.find(u=>t.endsWith(u));if(c!==void 0)return r(t.slice(0,-c.length))}i(vr,"resolveModelRow");var BB=60,QA="connections-v1";async function XA(e){let t=await Xe("supported-models",{});return new tt(t,e)}i(XA,"createSupportedModelsCache");async function Uu(e){return(await XA(e)).get(QA)}i(Uu,"getCachedSupportedModels");function cR(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(cR,"isRecord");function GB(e){return cR(e)&&Array.isArray(e.data)&&e.data.every(t=>cR(t)&&typeof t.label=="string"&&typeof t.providerType=="string"&&typeof t.isCustom=="boolean"&&Array.isArray(t.models)&&t.models.every(n=>cR(n)&&typeof n.model=="string"&&typeof n.kind=="string"&&typeof n.status=="string"))}i(GB,"isProviderAssignmentsResponse");function ZB(e){let t={},n={};for(let o of e.data)t[o.label]=o.models.map(r=>({info:{...o.isCustom?{id:r.id}:{},model:r.model,kind:r.kind,status:r.status,...r.dialect==null?{}:{dialect:r.dialect},...r.basePath==null?{}:{basePath:r.basePath}},tokenRateCard:r.tokenRateCard,overriddenTokenRateCard:r.overriddenTokenRateCard})),n[o.label]={...o.isCustom?{id:o.providerId}:{},baseUrl:o.baseUrl??"",isCustom:o.isCustom,...o.envVarName==null?{}:{envVarName:o.envVarName},providerType:o.providerType,...o.deploymentModels==null?{}:{deploymentModels:o.deploymentModels},...o.gcpProjectId==null?{}:{gcpProjectId:o.gcpProjectId}};return{models:t,providers:n}}i(ZB,"fromProviderAssignments");function VB(e){let t=typeof e=="object"&&e!==null?e.revision:void 0;return typeof t=="string"?t:void 0}i(VB,"overrideRevision");function JB(e,t){let n={};for(let[r,s]of Object.entries(e.models)){let a=r.toLowerCase();n[a]={};for(let c of s){let u=KA(c.tokenRateCard,c.overriddenTokenRateCard);u.error!==void 0&&t.warn("Ignoring invalid AI model token rate card",{provider:r,model:c.info.model,error:u.error});for(let l of u.ignoredRates??[])t.warn("Ignoring AI model token rates with an unknown category or cache TTL",{provider:r,model:c.info.model,card:l.card,revision:l.revision,unknown:l.values});u.overrideError!==void 0&&t.error("Ignoring invalid AI model override token rate card; pricing at the list card",{provider:r,model:c.info.model,overrideRevision:VB(c.overriddenTokenRateCard),error:u.overrideError}),n[a][c.info.model]={...c.info,...u.tokenRateCard===void 0?{}:{tokenRateCard:u.tokenRateCard}}}}let o={};for(let[r,s]of Object.entries(e.providers))o[r.toLowerCase()]=s;return DB(n,o,t),{modelsByProvider:n,providerMetadata:o}}i(JB,"buildSupportedModels");async function so(e,t){let n=pe.getLogger(e),o=await Uu(e);if(o)return n.info("Using cached supported models data",{providersCount:Object.keys(o.modelsByProvider).length,providers:Object.keys(o.modelsByProvider)}),{modelsByProvider:o.modelsByProvider,providerMetadata:o.providerMetadata};let r=new Headers({"content-type":"application/json"});pt(r,e.requestId);let s=et.ZUPLO_SERVICE_BUCKET_ID,a=new URL(`/v1/buckets/${s}/provider-assignments?includeDeprecated=true`,_.instance.zuploEdgeApiUrl).toString(),c=await $t({retryDelayMs:100,retries:t?.retries??5,retryOn404:!0,logger:n},a,{method:"GET",headers:r,signal:t?.signal});if(c.status!==200){let f="Failed to fetch supported models from Gateway service";try{let h=await c.text(),g=JSON.parse(h);n.error(f,g),f=`${f}: ${g.message||c.statusText}`}catch{n.error(f,{status:c.status}),f=`${f}: ${c.status}`}throw new Error(f)}let u=await c.json();if(!GB(u)){let f="Gateway service returned an unexpected provider assignments body";throw n.error(f,{bucketId:s}),new Error(f)}let l=ZB(u);n.info("Gateway service response received",{providersCount:Object.keys(l.models).length,providers:Object.keys(l.models),totalModels:Object.values(l.models).reduce((f,h)=>f+h.length,0)});let d=JB(l,n),p=await XA(e);return t?.signal.throwIfAborted(),p.put(QA,d,BB),d}i(so,"getSupportedModels");async function ek(e){let t=new AbortController,n;try{return await Promise.race([so(e,{signal:t.signal,retries:0}),new Promise((o,r)=>{n=setTimeout(()=>{t.abort(),r(new Error("Model discovery catalog deadline exceeded"))},2e3)})])}finally{clearTimeout(n)}}i(ek,"getDiscoverySupportedModels");function uR(e,t){let n=e.provider.toLowerCase();if(!e.environmentVariable)return n;for(let[o,r]of Object.entries(t))if(r.envVarName===e.environmentVariable)return o;return n}i(uR,"resolveProviderLabel");function tk(e){let t=Object.entries(e).map(([n,o])=>o.envVarName?`'${n}' (envVarName: ${o.envVarName})`:`'${n}'`);return t.length>0?t.join(", "):"none"}i(tk,"describeProviderAssignments");function nk(e,t,n,o){let r=t.toLowerCase(),s=o[r];if(!s)return!1;let a=s[e];return a?a.kind===n&&a.status==="active":!1}i(nk,"isModelSupported");function ok(e,t,n){let o=e.toLowerCase(),r=n[o];return r?Object.values(r).filter(s=>s.kind===t&&s.status==="active").map(s=>s.model):[]}i(ok,"getModelsByProviderAndKind");var rk=new be(Symbol("ai-gateway-provider-credential-passthrough"));function ik(e,t){rk.set(e,t)}i(ik,"setProviderCredentialPassthrough");function lR(e){return rk.get(e)}i(lR,"getProviderCredentialPassthrough");function af(e){return lR(e)!==void 0}i(af,"hasProviderCredentialPassthrough");function KB(e){return{revision:e.revision,currency:e.currency,rates:e.rates.map(t=>({category:t.category.replaceAll("_","-"),costPerToken:t.costPerToken,...t.cacheTtl===void 0?{}:{cacheTtl:t.cacheTtl},...t.minInputTokens===void 0?{}:{minInputTokens:t.minInputTokens},...t.maxInputTokens===void 0?{}:{maxInputTokens:t.maxInputTokens}}))}}i(KB,"publicTokenRateCard");var lk=Symbol("ai-gateway-model-selection"),WB="zuplodemo",YB="azure-ai",qu="https://demo.zuplo.ai";function QB(e){return e?.providerType?.toLowerCase()===WB&&e.isCustom!==!0}i(QB,"isZuploDemoAssignment");var sk=Symbol("ai-gateway-model-routing"),is='Use "providerName/model", for example "openai/gpt-5".',dR=["completions","embeddings"],ak=["main","backup","fallbackTimeoutSeconds","quotaFallback"];function Bo(e,t,n){throw new T(`Invalid AI Gateway model routing field '${e}': ${t}. ${n}`)}i(Bo,"invalid");function an(e,t,n,o){return o?o(e,t,n):Bo(e,t,n)}i(an,"reject");function pR(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(pR,"isRecord");function ln(e,t,n){if(typeof e!="string")return an(t,"must be a string",is,n);if(e.length===0)return an(t,"must not be empty",is,n);if(e.trim()!==e||/\s/.test(e))return an(t,`contains whitespace in '${e}'`,is,n);let o=e.indexOf("/");if(o===-1)return an(t,`'${e}' has no provider name separator`,is,n);let r=e.slice(0,o),s=e.slice(o+1);return r.length===0?an(t,`'${e}' has an empty provider name`,is,n):/^[A-Za-z0-9._-]+$/.test(r)?s.length===0?an(t,`'${e}' has an empty model`,is,n):s.startsWith("/")?an(t,`'${e}' starts the model with an extra "/"`,is,n):{provider:r,model:s,raw:e}:an(t,`provider name '${r}' contains unsupported characters`,'Use only letters, numbers, ".", "_", or "-" in the provider name',n)}i(ln,"parseModelRef");function XB(e,t,n){let o=typeof e=="string"?{main:e}:pR(e)?e:{};if(typeof e!="string"&&!pR(e))return an(t,"must be a model reference string or an object",'Set it to "providerName/model" or { main: "openai/gpt-5" }',n);let r=Object.keys(o).filter(l=>!ak.includes(l));if(r.length>0)return an(`${t}.${r[0]}`,`unknown property '${r[0]}'`,`Remove it; supported properties are ${ak.join(", ")}`,n);if(Object.keys(o).length===0)return an(t,"must not be an empty object",`Set 'main' to a "providerName/model" reference`,n);let s=ln(o.main,`${t}.main`,n);if(o.backup===null)return an(`${t}.backup`,"is null",'Set it to a "providerName/model" reference, or omit the field instead',n);if(o.quotaFallback===null)return an(`${t}.quotaFallback`,"is null",'Set it to a "providerName/model" reference, or omit the field instead',n);let a=o.backup===void 0?void 0:ln(o.backup,`${t}.backup`,n),c=o.quotaFallback===void 0?void 0:ln(o.quotaFallback,`${t}.quotaFallback`,n);if(a?.raw.toLowerCase()===s.raw.toLowerCase())return an(`${t}.backup`,`must differ from '${t}.main'`,"Choose a different backup model or omit 'backup'",n);if(c?.raw.toLowerCase()===s.raw.toLowerCase())return an(`${t}.quotaFallback`,`must differ from '${t}.main'`,"Choose a different quota fallback model or omit 'quotaFallback'",n);let u=o.fallbackTimeoutSeconds;if(u!==void 0){if(a===void 0)return an(`${t}.fallbackTimeoutSeconds`,"requires a backup model","Set 'backup' or omit 'fallbackTimeoutSeconds'",n);if(typeof u=="string")return an(`${t}.fallbackTimeoutSeconds`,`is a string '${u}', not a number`,"Remove the quotes and set it to a number from 1 through 300",n);if(typeof u!="number"||!Number.isFinite(u)||u<1)return an(`${t}.fallbackTimeoutSeconds`,"must be a finite number greater than or equal to 1","Set it to a number from 1 through 300",n);if(u>300)return an(`${t}.fallbackTimeoutSeconds`,"must not exceed the platform request duration of 300 seconds","Set it to 300 or less so the backup can run before the request ends",n)}return{main:s.raw,...a===void 0?{}:{backup:a.raw},...u===void 0?{}:{fallbackTimeoutSeconds:u},...c===void 0?{}:{quotaFallback:c.raw}}}i(XB,"normalizeAIGatewayRouteTarget");async function ss(e){let{modelsByProvider:t,providerMetadata:n}=await so(e),r=[...new Set([...Object.keys(t),...Object.keys(n)])].map(a=>{let c=n[a],u=Object.values(t[a]??{}).map(l=>({model:l.model,capability:l.kind,status:l.status,...l.tokenRateCard===void 0?{}:{tokenRateCard:KB(l.tokenRateCard)}}));return{providerName:a,...c?.baseUrl===void 0?{}:{baseUrl:c.baseUrl},...c?.isCustom===void 0?{}:{isCustom:c.isCustom},...c?.providerType===void 0?{}:{providerType:c.providerType.toLowerCase()},models:u}}),s=new Map;for(let[a,c]of Object.entries(n))c.envVarName!==void 0&&s.set(a.toLowerCase(),c.envVarName);return{providers:r,providerEnvironmentVariables:s,modelsByProvider:t,providerMetadata:n}}i(ss,"loadProviders");function eG(e){return`${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_API_KEY`}i(eG,"conventionEnvironmentVariable");function ck(e){return e&&et[e]?.trim()||void 0}i(ck,"nonEmptyEnvironmentValue");function mR(e){let{provider:t,providerEnvironmentVariables:n,metadata:o,path:r,allowMissingApiKey:s,log:a}=e;if(QB(o)){let p;try{p=new URL(o.baseUrl).origin}catch{}return p!==qu?Bo(r,`ZuploDemo provider URL '${o.baseUrl}' is not the trusted demo provider origin '${qu}'`,`Set the ZuploDemo catalog base URL to '${qu}', or choose a keyed provider`):_.instance.authApiJWT?.trim()?{apiKeySource:"zuplodemo"}:Bo(r,"ZuploDemo requires a Zuplo deployment JWT, but this gateway does not have one","Deploy the gateway through Zuplo so it receives a deployment JWT, or choose a keyed provider")}let c=n.get(t.toLowerCase()),u=eG(t),l,d;if(c!==void 0){let p=ck(c);p!==void 0&&(l=p,d=c)}if(l===void 0){let p=ck(u);p!==void 0&&(l=p,d=u)}if(l===void 0){if(s===!0)return{};if(c!==void 0)throw a?.setLogProperties?.({aiProvider:t,aiProviderEnvironmentVariable:c,aiProviderConventionalEnvironmentVariable:u,aiRoutingField:r}),a?.error("AI provider key not present in this deployment. Provider changes redeploy the gateway automatically; if this persists, redeploy from AI Settings \u2192 General in the Zuplo Portal."),new T(`Provider '${t}' is not ready on this gateway yet. If a provider was recently added or changed, the gateway may still be updating; retry in a minute or two. If this persists, contact the gateway administrator.`);return Bo(r,`could not resolve an API key for provider name '${t}'. No key binding found in your account's AI providers and conventional environment variable '${u}' is not set`,`Add an AI provider named '${t}' with an API key in the Zuplo Portal, or set '${u}'`)}return{apiKey:l,environmentVariable:d}}i(mR,"resolveApiKey");function tG(e){let{provider:t,providers:n,path:o}=e,r=n.find(({providerName:a})=>a.toLowerCase()===t.toLowerCase());if(r!==void 0)return r.providerName;let s=n.map(({providerName:a})=>a).sort().join(", ");Bo(o,`references unknown provider name '${t}'`,`Use 'providerName/model' to select a configured provider; configured provider names: ${s||"none"}`)}i(tG,"resolveCatalogEntryLabel");function nG(e){let{provider:t,model:n,capability:o,modelsByProvider:r,providerMetadata:s,path:a}=e,c=t.toLowerCase(),u=s[c],l=u?.providerType?.toLowerCase();if(l===void 0||u?.isCustom!==!1||l===YB)return;let d=vr(r[c],n,l);d?.kind===o&&d.status==="active"||(d?.kind===o&&Bo(a,`model '${n}' is not active for provider name '${t}'`,`Update provider '${t}' model selections to use an active model, or use another provider name that offers it`),Bo(a,`model '${n}' is not included in model selections for provider name '${t}'`,`Update provider '${t}' model selections to include '${n}', or use another provider name that offers it`))}i(nG,"assertAssignmentOffersModel");function uk(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}i(uk,"cloneRouting");function oG(e,t){be.set(e,lk,t)}i(oG,"setModelSelection");function qn(e){return be.get(e,lk)}i(qn,"getModelSelection");var fR={async load(e){let{providers:t}=await ss(e);return t}},En={async set(e,t){if(!pR(t))return Bo("routing","must be an object","Set at least one of 'completions' or 'embeddings'");let n=Object.keys(t).filter(d=>!dR.includes(d));if(n.length>0)return Bo(`routing.${n[0]}`,`unknown capability '${n[0]}'`,"Use 'completions' or 'embeddings', or remove this property");let o=dR.filter(d=>t[d]!==void 0);if(o.length===0)return Bo("routing","must not be empty","Set at least one of 'completions' or 'embeddings'");let r={};for(let d of o)r[d]=XB(t[d],`routing.${d}`);let{providers:s,providerEnvironmentVariables:a,modelsByProvider:c,providerMetadata:u}=await ss(e),l={};for(let d of dR){let p=r[d];if(typeof p!="object")continue;let f=ln(p.main,`routing.${d}.main`),h=p.backup?ln(p.backup,`routing.${d}.backup`):void 0,g=p.quotaFallback?ln(p.quotaFallback,`routing.${d}.quotaFallback`):void 0,S=new Map;for(let[C,v]of[["main",f],["backup",h],["quotaFallback",g]])if(v){let I=tG({provider:v.provider,providers:s,path:`routing.${d}.${C}`});nG({provider:I,model:v.model,capability:d,modelsByProvider:c,providerMetadata:u,path:`routing.${d}.${C}`});let P={...v,provider:I};S.set(C,P)}let b=i(C=>{let v=S.get(C);if(v===void 0)throw new Error(`Missing resolved AI Gateway routing field '${C}'`);let I=u[v.provider.toLowerCase()];return{provider:v.provider,model:v.model,...mR({provider:v.provider,providerEnvironmentVariables:a,metadata:I,path:`routing.${d}.${C}`,allowMissingApiKey:C==="main"&&af(e),log:e.log})}},"toCandidate");l[d]={candidates:[b("main"),...h?[b("backup")]:[]],...h?{fallbackTimeoutSeconds:p.fallbackTimeoutSeconds??60}:{},...g?{quotaFallback:b("quotaFallback")}:{}}}oG(e,{byCapability:l}),be.set(e,sk,uk(r))},get(e){let t=be.get(e,sk);return t===void 0?void 0:uk(t)}};var rG=new Set(["converse","converse-stream","invoke","invoke-with-response-stream"]),iG=new Set(["count-tokens","invoke-with-bidirectional-stream"]),sG=/\/model\/(.+)\/([a-z-]+)$/;function as(e){let t=e.replace(/\/{2,}/g,"/"),n=t.split("/"),o=n[1]==="a"||n[1]==="u"?3:2;if(n.length<o+3||n[o]!=="model")return null;let r=sG.exec(t);if(!r)return null;let[,s,a]=r;return!s||!a?null:rG.has(a)?{operation:a,requested:a,encodedModelId:s}:iG.has(a)?{operation:"unsupported",requested:a,encodedModelId:s}:null}i(as,"matchBedrockRuntimeRoute");function Zt(e){return as(e)!==null}i(Zt,"isBedrockRuntimeRoute");function dk(e){try{return decodeURIComponent(e)}catch{return e}}i(dk,"decodeBedrockModelId");function ao(e,t,n,o){if(Zt(e))return cn(t,aG(t),n,o)}i(ao,"bedrockPolicyErrorResponse");function aG(e){return e===401||e===403?"AccessDeniedException":e===404?"ResourceNotFoundException":e===429?"ThrottlingException":e>=500?e===503?"ServiceUnavailableException":"InternalServerException":"ValidationException"}i(aG,"bedrockExceptionForStatus");function cn(e,t,n,o){let r={"content-type":"application/json","x-amzn-errortype":t};return o&&(r["x-amzn-requestid"]=o),new Response(JSON.stringify({message:n}),{status:e,headers:r})}i(cn,"createBedrockErrorResponse");function hR(e,t,n){if(Zt(e))return cn(400,"ServiceQuotaExceededException",t,n)}i(hR,"bedrockQuotaExceededResponse");function Du(e){if(Zt(e))return null;let t=/\/v1\/models(?:\/|$)/.exec(e);return t?.index===void 0?null:e.slice(t.index)}i(Du,"resolveModelsBasePath");function Tt(e){return Du(new URL(e.url).pathname)!==null}i(Tt,"isModelsDiscoveryRoute");function Ca(e,t){return e.provider.toLowerCase()===t.provider.toLowerCase()&&e.model.toLowerCase()===t.model.toLowerCase()}i(Ca,"refsEqual");function Go(e){let t=new URL(e.url).pathname;return Zt(t)?{capability:"completions",nativeProvider:"bedrock-runtime"}:t.endsWith("/v1/embeddings")?{capability:"embeddings"}:t.endsWith("/v1/messages/count_tokens")?{capability:"completions",nativeProvider:"anthropic"}:t.endsWith("/v1/messages")?{capability:"completions",nativeProvider:"anthropic"}:t.endsWith("/v1/systemone")?{capability:"completions",nativeProvider:"jev"}:/\/v1\/responses(?:\/|$)/.test(t)?{capability:"completions",nativeProvider:"openai"}:{capability:"completions"}}i(Go,"resolveAIGatewayRequestRoute");function pk(e){let t;try{t=new URL(e.url).pathname}catch{return}let n=i(o=>t===o||t.endsWith(o),"matchesBase");if(!Zt(t)&&!n("/v1/systemone")){if(n("/v1/chat/completions")||n("/v1/responses")||n("/v1/messages")||n("/v1/messages/count_tokens"))return"completions";if(n("/v1/embeddings"))return"embeddings"}}i(pk,"resolveMeteredCapability");function va(e,t,n,o){return vr(n?.[e.toLowerCase()],t,o)?.dialect?.toLowerCase()}i(va,"catalogModelDialect");var cG={openai:new Set(["xai"])};function Ta(e){let t=e.nativeProvider.toLowerCase(),n=e.providerType?.toLowerCase();return n===t||n!==void 0&&cG[t]?.has(n)===!0||e.dialect?.toLowerCase()===t}i(Ta,"selectionSatisfiesNativeProvider");function uG(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(uG,"isRecord");async function lG(e){try{let t=await e.clone().json();if(uG(t)&&Object.hasOwn(t,"model"))return{present:!0,value:t.model}}catch{}return{present:!1,value:void 0}}i(lG,"readAIGatewayRequestModel");async function mi(e){let t=as(new URL(e.url).pathname);return t!==null?{present:!0,value:dk(t.encodedModelId)}:lG(e)}i(mi,"readAIGatewayRequestedModel");function cf(e){if(Zt(new URL(e.url).pathname)){let t='"bedrock/anthropic.claude-sonnet-4-5-20250929-v1:0" (the AWS SDKs percent-encode it into one path segment for you)';return{source:"modelId",missing:`Send a qualified "providerName/model" as the modelId, for example ${t}.`,malformed:`The modelId must use "providerName/model", for example ${t}.`}}return{source:"request.body.model",missing:'Send "providerName/model", for example "openai/gpt-5".',malformed:'The request body model must use "providerName/model", for example "openai/gpt-5".'}}i(cf,"describeRequestModelSource");function Ia(e,t="request.body.model"){let n=ln(e,t);return{ref:n,raw:n.raw}}i(Ia,"parseAIGatewayRequestModel");var dG=new Set(["response.completed","response.failed","response.incomplete","response.cancelled","response.expired"]),pG=[["/v1/responses","openai-responses"],["/v1/messages","anthropic-messages"],["/v1/chat/completions","openai-chat"]];function Qt(e){if(Tt(e))return null;let t=new URL(e.url).pathname;if(Zt(t))return null;for(let[n,o]of pG)if(t===n||t.endsWith(n)||t.includes(`${n}/`))return o;return null}i(Qt,"getFormat");async function $u(e){let t=Qt(e);if(!t)return null;let n;try{n=await e.clone().json()}catch{return null}return{format:t,body:n}}i($u,"getRequestBody");async function mG(e,t){let n=Qt(e);if(!n)return null;let o;try{o=await t.clone().json()}catch{return null}return{format:n,body:o}}i(mG,"getResponseBody");function gR(e){let t=e?.usage;if(!t||typeof t!="object")return;let n=i(c=>typeof c=="number"?c:void 0,"num"),o=n(t.input_tokens)??n(t.prompt_tokens),r=n(t.output_tokens)??n(t.completion_tokens);if(o===void 0&&r===void 0)return;let s=o??0,a=r??0;return{promptTokens:s,completionTokens:a,totalTokens:n(t.total_tokens)??s+a}}i(gR,"getUsage");function lt(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>lt(t)).filter(Boolean).join(" ");if(e&&typeof e=="object"){let t=e;if(typeof t.text=="string")return t.text;if(t.type==="thinking"&&typeof t.thinking=="string")return t.thinking;if(typeof t.input_text=="string")return t.input_text;if(t.content!==void 0)return lt(t.content);let n=t.source;if(n&&n.type==="text"&&typeof n.data=="string")return n.data}return""}i(lt,"flattenMessageContent");function Ea(e){if(!e||typeof e!="object")return"";let t=e,n=[];if(Array.isArray(t.messages))for(let o of t.messages)n.push(lt(o.content));if(typeof t.system=="string"?n.push(t.system):Array.isArray(t.system)&&n.push(lt(t.system)),typeof t.instructions=="string"&&n.push(t.instructions),typeof t.input=="string")n.push(t.input);else if(Array.isArray(t.input))for(let o of t.input)n.push(lt(o.content));if(Array.isArray(t.choices))for(let o of t.choices)n.push(lt(o.message?.content));if(Array.isArray(t.output))for(let o of t.output)n.push(lt(o.content));return Array.isArray(t.content)&&n.push(lt(t.content)),n.filter(Boolean).join(`
|
|
26
26
|
`)}i(Ea,"extractAllText");async function*fG(e,t){let n=Qt(e),o=t.clone().body;if(!o||!n)return;let r=o.getReader(),s=new TextDecoder,a="";try{for(;;){let{done:c,value:u}=await r.read();if(c)break;a+=s.decode(u,{stream:!0});let l;for(;(l=a.indexOf(`
|
|
27
27
|
|
|
28
28
|
`))!==-1;){let d=a.slice(0,l);a=a.slice(l+2);let p=hG(d,n);p&&(yield p)}}}finally{r.releaseLock()}}i(fG,"getStreamEvents");function hG(e,t){let n=e.split(`
|
|
@@ -425,5 +425,5 @@ Signature verification is impossible without access to the original signed mater
|
|
|
425
425
|
`);let R=new v("!xml"),E=R,x="";this.matcher.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;let U=new I(this.options.processEntities);for(let k=0;k<y.length;k++)if(y[k]==="<")if(y[k+1]==="/"){let Y=Cn(y,">",k,"Closing Tag is not closed."),H=y.substring(k+2,Y).trim();if(this.options.removeNSPrefix){let Pe=H.indexOf(":");Pe!==-1&&(H=H.substr(Pe+1))}H=Jn(this.options.transformTagName,H,"",this.options).tagName,E&&(x=this.saveTextToParentTag(x,E,this.matcher));let Ce=this.matcher.getCurrentTag();if(H&&this.options.unpairedTags.indexOf(H)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${H}>`);Ce&&this.options.unpairedTags.indexOf(Ce)!==-1&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,E=this.tagsNodeStack.pop(),x="",k=Y}else if(y[k+1]==="?"){let Y=Mn(y,k,!1,"?>");if(!Y)throw new Error("Pi Tag is not closed.");if(x=this.saveTextToParentTag(x,E,this.matcher),!(this.options.ignoreDeclaration&&Y.tagName==="?xml"||this.options.ignorePiTags)){let H=new v(Y.tagName);H.add(this.options.textNodeName,""),Y.tagName!==Y.tagExp&&Y.attrExpPresent&&(H[":@"]=this.buildAttributesMap(Y.tagExp,this.matcher,Y.tagName)),this.addChild(E,H,this.matcher,k)}k=Y.closeIndex+1}else if(y.substr(k+1,3)==="!--"){let Y=Cn(y,"-->",k+4,"Comment is not closed.");if(this.options.commentPropName){let H=y.substring(k+4,Y-2);x=this.saveTextToParentTag(x,E,this.matcher),E.add(this.options.commentPropName,[{[this.options.textNodeName]:H}])}k=Y}else if(y.substr(k+1,2)==="!D"){let Y=U.readDocType(y,k);this.docTypeEntities=Y.entities,k=Y.i}else if(y.substr(k+1,2)==="!["){let Y=Cn(y,"]]>",k,"CDATA is not closed.")-2,H=y.substring(k+9,Y);x=this.saveTextToParentTag(x,E,this.matcher);let Ce=this.parseTextData(H,E.tagname,this.matcher,!0,!1,!0,!0);Ce==null&&(Ce=""),this.options.cdataPropName?E.add(this.options.cdataPropName,[{[this.options.textNodeName]:H}]):E.add(this.options.textNodeName,Ce),k=Y+2}else{let Y=Mn(y,k,this.options.removeNSPrefix);if(!Y){let sn=y.substring(Math.max(0,k-50),Math.min(y.length,k+50));throw new Error(`readTagExp returned undefined at position ${k}. Context: "${sn}"`)}let H=Y.tagName,Ce=Y.rawTagName,Pe=Y.tagExp,He=Y.attrExpPresent,Rt=Y.closeIndex;if({tagName:H,tagExp:Pe}=Jn(this.options.transformTagName,H,Pe,this.options),this.options.strictReservedNames&&(H===this.options.commentPropName||H===this.options.cdataPropName||H===this.options.textNodeName||H===this.options.attributesGroupName))throw new Error(`Invalid tag name: ${H}`);E&&x&&E.tagname!=="!xml"&&(x=this.saveTextToParentTag(x,E,this.matcher,!1));let gn=E;gn&&this.options.unpairedTags.indexOf(gn.tagname)!==-1&&(E=this.tagsNodeStack.pop(),this.matcher.pop());let ii=!1;Pe.length>0&&Pe.lastIndexOf("/")===Pe.length-1&&(ii=!0,H[H.length-1]==="/"?(H=H.substr(0,H.length-1),Pe=H):Pe=Pe.substr(0,Pe.length-1),He=H!==Pe);let St=null,Nn={},si;si=ie(Ce),H!==R.tagname&&this.matcher.push(H,{},si),H!==Pe&&He&&(St=this.buildAttributesMap(Pe,this.matcher,H),St&&(Nn=ce(St,this.options))),H!==R.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode(this.stopNodeExpressions,this.matcher));let Tn=k;if(this.isCurrentNodeStopNode){let sn="";if(ii)k=Y.closeIndex;else if(this.options.unpairedTags.indexOf(H)!==-1)k=Y.closeIndex;else{let ci=this.readStopNodeData(y,Ce,Rt+1);if(!ci)throw new Error(`Unexpected end of ${Ce}`);k=ci.i,sn=ci.tagContent}let ai=new v(H);St&&(ai[":@"]=St),ai.add(this.options.textNodeName,sn),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(E,ai,this.matcher,Tn)}else{if(ii){({tagName:H,tagExp:Pe}=Jn(this.options.transformTagName,H,Pe,this.options));let sn=new v(H);St&&(sn[":@"]=St),this.addChild(E,sn,this.matcher,Tn),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(this.options.unpairedTags.indexOf(H)!==-1){let sn=new v(H);St&&(sn[":@"]=St),this.addChild(E,sn,this.matcher,Tn),this.matcher.pop(),this.isCurrentNodeStopNode=!1,k=Y.closeIndex;continue}else{let sn=new v(H);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(E),St&&(sn[":@"]=St),this.addChild(E,sn,this.matcher,Tn),E=sn}x="",k=Rt}}else x+=y[k];return R.child},"parseXml");function le(y,R,E,x){this.options.captureMetaData||(x=void 0);let U=this.options.jPath?E.toString():E,k=this.options.updateTag(R.tagname,U,R[":@"]);k===!1||(typeof k=="string"&&(R.tagname=k),y.addChild(R,x))}i(le,"addChild"),n(le,"addChild");function de(y,R,E){let x=this.options.processEntities;if(!x||!x.enabled)return y;if(x.allowedTags){let U=this.options.jPath?E.toString():E;if(!(Array.isArray(x.allowedTags)?x.allowedTags.includes(R):x.allowedTags(R,U)))return y}if(x.tagFilter){let U=this.options.jPath?E.toString():E;if(!x.tagFilter(R,U))return y}for(let U of Object.keys(this.docTypeEntities)){let k=this.docTypeEntities[U],oe=y.match(k.regx);if(oe){if(this.entityExpansionCount+=oe.length,x.maxTotalExpansions&&this.entityExpansionCount>x.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${x.maxTotalExpansions}`);let Y=y.length;if(y=y.replace(k.regx,k.val),x.maxExpandedLength&&(this.currentExpandedLength+=y.length-Y,this.currentExpandedLength>x.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${x.maxExpandedLength}`)}}for(let U of Object.keys(this.lastEntities)){let k=this.lastEntities[U],oe=y.match(k.regex);if(oe&&(this.entityExpansionCount+=oe.length,x.maxTotalExpansions&&this.entityExpansionCount>x.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${x.maxTotalExpansions}`);y=y.replace(k.regex,k.val)}if(y.indexOf("&")===-1)return y;if(this.options.htmlEntities)for(let U of Object.keys(this.htmlEntities)){let k=this.htmlEntities[U],oe=y.match(k.regex);if(oe&&(this.entityExpansionCount+=oe.length,x.maxTotalExpansions&&this.entityExpansionCount>x.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${x.maxTotalExpansions}`);y=y.replace(k.regex,k.val)}return y=y.replace(this.ampEntity.regex,this.ampEntity.val),y}i(de,"replaceEntitiesValue"),n(de,"replaceEntitiesValue");function ke(y,R,E,x){return y&&(x===void 0&&(x=R.child.length===0),y=this.parseTextData(y,R.tagname,E,!1,R[":@"]?Object.keys(R[":@"]).length!==0:!1,x),y!==void 0&&y!==""&&R.add(this.options.textNodeName,y),y=""),y}i(ke,"saveTextToParentTag"),n(ke,"saveTextToParentTag");function xe(y,R){if(!y||y.length===0)return!1;for(let E=0;E<y.length;E++)if(R.matches(y[E]))return!0;return!1}i(xe,"isItStopNode"),n(xe,"isItStopNode");function j(y,R,E=">"){let x,U="";for(let k=R;k<y.length;k++){let oe=y[k];if(x)oe===x&&(x="");else if(oe==='"'||oe==="'")x=oe;else if(oe===E[0])if(E[1]){if(y[k+1]===E[1])return{data:U,index:k}}else return{data:U,index:k};else oe===" "&&(oe=" ");U+=oe}}i(j,"tagExpWithClosingIndex"),n(j,"tagExpWithClosingIndex");function Cn(y,R,E,x){let U=y.indexOf(R,E);if(U===-1)throw new Error(x);return U+R.length-1}i(Cn,"findClosingIndex"),n(Cn,"findClosingIndex");function Mn(y,R,E,x=">"){let U=j(y,R+1,x);if(!U)return;let k=U.data,oe=U.index,Y=k.search(/\s/),H=k,Ce=!0;Y!==-1&&(H=k.substring(0,Y),k=k.substring(Y+1).trimStart());let Pe=H;if(E){let He=H.indexOf(":");He!==-1&&(H=H.substr(He+1),Ce=H!==U.data.substr(He+1))}return{tagName:H,tagExp:k,closeIndex:oe,attrExpPresent:Ce,rawTagName:Pe}}i(Mn,"readTagExp"),n(Mn,"readTagExp");function jo(y,R,E){let x=E,U=1;for(;E<y.length;E++)if(y[E]==="<")if(y[E+1]==="/"){let k=Cn(y,">",E,`${R} is not closed`);if(y.substring(E+2,k).trim()===R&&(U--,U===0))return{tagContent:y.substring(x,E),i:k};E=k}else if(y[E+1]==="?")E=Cn(y,"?>",E+1,"StopNode is not closed.");else if(y.substr(E+1,3)==="!--")E=Cn(y,"-->",E+3,"StopNode is not closed.");else if(y.substr(E+1,2)==="![")E=Cn(y,"]]>",E,"StopNode is not closed.")-2;else{let k=Mn(y,E,">");k&&((k&&k.tagName)===R&&k.tagExp[k.tagExp.length-1]!=="/"&&U++,E=k.closeIndex)}}i(jo,"readStopNodeData"),n(jo,"readStopNodeData");function io(y,R,E){if(R&&typeof y=="string"){let x=y.trim();return x==="true"?!0:x==="false"?!1:vt(y,E)}else return l(y)?y:""}i(io,"parseValue"),n(io,"parseValue");function hr(y,R,E){let x=Number.parseInt(y,R);return x>=0&&x<=1114111?String.fromCodePoint(x):E+y+";"}i(hr,"fromCodePoint"),n(hr,"fromCodePoint");function Jn(y,R,E,x){if(y){let U=y(R);E===R&&(E=U),R=U}return R=gr(R,x),{tagName:R,tagExp:E}}i(Jn,"transformTagName"),n(Jn,"transformTagName");function gr(y,R){if(p.includes(y))throw new Error(`[SECURITY] Invalid name: "${y}" is a reserved JavaScript keyword that could cause prototype pollution`);return d.includes(y)?R.onDangerousProperty(y):y}i(gr,"sanitizeName"),n(gr,"sanitizeName");var vn=v.getMetaDataSymbol();function yr(y,R){if(!y||typeof y!="object")return{};if(!R)return y;let E={};for(let x in y)if(x.startsWith(R)){let U=x.substring(R.length);E[U]=y[x]}else E[x]=y[x];return E}i(yr,"stripAttributePrefix"),n(yr,"stripAttributePrefix");function br(y,R,E){return Co(y,R,E)}i(br,"prettify"),n(br,"prettify");function Co(y,R,E){let x,U={};for(let k=0;k<y.length;k++){let oe=y[k],Y=Qr(oe);if(Y!==void 0&&Y!==R.textNodeName){let H=yr(oe[":@"]||{},R.attributeNamePrefix);E.push(Y,H)}if(Y===R.textNodeName)x===void 0?x=oe[Y]:x+=""+oe[Y];else{if(Y===void 0)continue;if(oe[Y]){let H=Co(oe[Y],R,E),Ce=zo(H,R);if(oe[":@"]?Rr(H,oe[":@"],E,R):Object.keys(H).length===1&&H[R.textNodeName]!==void 0&&!R.alwaysCreateTextNode?H=H[R.textNodeName]:Object.keys(H).length===0&&(R.alwaysCreateTextNode?H[R.textNodeName]="":H=""),oe[vn]!==void 0&&typeof H=="object"&&H!==null&&(H[vn]=oe[vn]),U[Y]!==void 0&&Object.prototype.hasOwnProperty.call(U,Y))Array.isArray(U[Y])||(U[Y]=[U[Y]]),U[Y].push(H);else{let Pe=R.jPath?E.toString():E;R.isArray(Y,Pe,Ce)?U[Y]=[H]:U[Y]=H}Y!==void 0&&Y!==R.textNodeName&&E.pop()}}}return typeof x=="string"?x.length>0&&(U[R.textNodeName]=x):x!==void 0&&(U[R.textNodeName]=x),U}i(Co,"compress"),n(Co,"compress");function Qr(y){let R=Object.keys(y);for(let E=0;E<R.length;E++){let x=R[E];if(x!==":@")return x}}i(Qr,"propName"),n(Qr,"propName");function Rr(y,R,E,x){if(R){let U=Object.keys(R),k=U.length;for(let oe=0;oe<k;oe++){let Y=U[oe],H=Y.startsWith(x.attributeNamePrefix)?Y.substring(x.attributeNamePrefix.length):Y,Ce=x.jPath?E.toString()+"."+H:E;x.isArray(Y,Ce,!0,!0)?y[Y]=[R[Y]]:y[Y]=R[Y]}}}i(Rr,"assignAttributes"),n(Rr,"assignAttributes");function zo(y,R){let{textNodeName:E}=R,x=Object.keys(y).length;return!!(x===0||x===1&&(y[E]||typeof y[E]=="boolean"||y[E]===0))}i(zo,"isLeafTag"),n(zo,"isLeafTag");var Xr={allowBooleanAttributes:!1,unpairedTags:[]};function Sr(y,R){R=Object.assign({},Xr,R);let E=[],x=!1,U=!1;y[0]==="\uFEFF"&&(y=y.substr(1));for(let k=0;k<y.length;k++)if(y[k]==="<"&&y[k+1]==="?"){if(k+=2,k=Yt(y,k),k.err)return k}else if(y[k]==="<"){let oe=k;if(k++,y[k]==="!"){k=wr(y,k);continue}else{let Y=!1;y[k]==="/"&&(Y=!0,k++);let H="";for(;k<y.length&&y[k]!==">"&&y[k]!==" "&&y[k]!==" "&&y[k]!==`
|
|
426
426
|
`&&y[k]!=="\r";k++)H+=y[k];if(H=H.trim(),H[H.length-1]==="/"&&(H=H.substring(0,H.length-1),k--),!Wi(H)){let He;return H.trim().length===0?He="Invalid space after '<'.":He="Tag '"+H+"' is an invalid name.",ut("InvalidTag",He,Dt(y,k))}let Ce=ti(y,k);if(Ce===!1)return ut("InvalidAttr","Attributes for '"+H+"' have open quote.",Dt(y,k));let Pe=Ce.value;if(k=Ce.index,Pe[Pe.length-1]==="/"){let He=k-Pe.length;Pe=Pe.substring(0,Pe.length-1);let Rt=Cr(Pe,R);if(Rt===!0)x=!0;else return ut(Rt.err.code,Rt.err.msg,Dt(y,He+Rt.err.line))}else if(Y)if(Ce.tagClosed){if(Pe.trim().length>0)return ut("InvalidTag","Closing tag '"+H+"' can't have attributes or invalid starting.",Dt(y,oe));if(E.length===0)return ut("InvalidTag","Closing tag '"+H+"' has not been opened.",Dt(y,oe));{let He=E.pop();if(H!==He.tagName){let Rt=Dt(y,He.tagStartPos);return ut("InvalidTag","Expected closing tag '"+He.tagName+"' (opened in line "+Rt.line+", col "+Rt.col+") instead of closing tag '"+H+"'.",Dt(y,oe))}E.length==0&&(U=!0)}}else return ut("InvalidTag","Closing tag '"+H+"' doesn't have proper closing.",Dt(y,k));else{let He=Cr(Pe,R);if(He!==!0)return ut(He.err.code,He.err.msg,Dt(y,k-Pe.length+He.err.line));if(U===!0)return ut("InvalidXml","Multiple possible root nodes found.",Dt(y,k));R.unpairedTags.indexOf(H)!==-1||E.push({tagName:H,tagStartPos:oe}),x=!0}for(k++;k<y.length;k++)if(y[k]==="<")if(y[k+1]==="!"){k++,k=wr(y,k);continue}else if(y[k+1]==="?"){if(k=Yt(y,++k),k.err)return k}else break;else if(y[k]==="&"){let He=oi(y,k);if(He==-1)return ut("InvalidChar","char '&' is not expected.",Dt(y,k));k=He}else if(U===!0&&!Ho(y[k]))return ut("InvalidXml","Extra text at the end",Dt(y,k));y[k]==="<"&&k--}}else{if(Ho(y[k]))continue;return ut("InvalidChar","char '"+y[k]+"' is not expected.",Dt(y,k))}if(x){if(E.length==1)return ut("InvalidTag","Unclosed tag '"+E[0].tagName+"'.",Dt(y,E[0].tagStartPos));if(E.length>0)return ut("InvalidXml","Invalid '"+JSON.stringify(E.map(k=>k.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return ut("InvalidXml","Start tag expected.",1);return!0}i(Sr,"validate"),n(Sr,"validate");function Ho(y){return y===" "||y===" "||y===`
|
|
427
427
|
`||y==="\r"}i(Ho,"isWhiteSpace"),n(Ho,"isWhiteSpace");function Yt(y,R){let E=R;for(;R<y.length;R++)if(y[R]=="?"||y[R]==" "){let x=y.substr(E,R-E);if(R>5&&x==="xml")return ut("InvalidXml","XML declaration allowed only at the start of the document.",Dt(y,R));if(y[R]=="?"&&y[R+1]==">"){R++;break}else continue}return R}i(Yt,"readPI"),n(Yt,"readPI");function wr(y,R){if(y.length>R+5&&y[R+1]==="-"&&y[R+2]==="-"){for(R+=3;R<y.length;R++)if(y[R]==="-"&&y[R+1]==="-"&&y[R+2]===">"){R+=2;break}}else if(y.length>R+8&&y[R+1]==="D"&&y[R+2]==="O"&&y[R+3]==="C"&&y[R+4]==="T"&&y[R+5]==="Y"&&y[R+6]==="P"&&y[R+7]==="E"){let E=1;for(R+=8;R<y.length;R++)if(y[R]==="<")E++;else if(y[R]===">"&&(E--,E===0))break}else if(y.length>R+9&&y[R+1]==="["&&y[R+2]==="C"&&y[R+3]==="D"&&y[R+4]==="A"&&y[R+5]==="T"&&y[R+6]==="A"&&y[R+7]==="["){for(R+=8;R<y.length;R++)if(y[R]==="]"&&y[R+1]==="]"&&y[R+2]===">"){R+=2;break}}return R}i(wr,"readCommentAndCDATA"),n(wr,"readCommentAndCDATA");var ma='"',ei="'";function ti(y,R){let E="",x="",U=!1;for(;R<y.length;R++){if(y[R]===ma||y[R]===ei)x===""?x=y[R]:x!==y[R]||(x="");else if(y[R]===">"&&x===""){U=!0;break}E+=y[R]}return x!==""?!1:{value:E,index:R,tagClosed:U}}i(ti,"readAttributeStr"),n(ti,"readAttributeStr");var Ki=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Cr(y,R){let E=c(y,Ki),x={};for(let U=0;U<E.length;U++){if(E[U][1].length===0)return ut("InvalidAttr","Attribute '"+E[U][2]+"' has no space in starting.",Ln(E[U]));if(E[U][3]!==void 0&&E[U][4]===void 0)return ut("InvalidAttr","Attribute '"+E[U][2]+"' is without value.",Ln(E[U]));if(E[U][3]===void 0&&!R.allowBooleanAttributes)return ut("InvalidAttr","boolean attribute '"+E[U][2]+"' is not allowed.",Ln(E[U]));let k=E[U][2];if(!ri(k))return ut("InvalidAttr","Attribute '"+k+"' is an invalid name.",Ln(E[U]));if(!Object.prototype.hasOwnProperty.call(x,k))x[k]=1;else return ut("InvalidAttr","Attribute '"+k+"' is repeated.",Ln(E[U]))}return!0}i(Cr,"validateAttributeString"),n(Cr,"validateAttributeString");function ni(y,R){let E=/\d/;for(y[R]==="x"&&(R++,E=/[\da-fA-F]/);R<y.length;R++){if(y[R]===";")return R;if(!y[R].match(E))break}return-1}i(ni,"validateNumberAmpersand"),n(ni,"validateNumberAmpersand");function oi(y,R){if(R++,y[R]===";")return-1;if(y[R]==="#")return R++,ni(y,R);let E=0;for(;R<y.length;R++,E++)if(!(y[R].match(/\w/)&&E<20)){if(y[R]===";")break;return-1}return R}i(oi,"validateAmpersand"),n(oi,"validateAmpersand");function ut(y,R,E){return{err:{code:y,msg:R,line:E.line||E,col:E.col}}}i(ut,"getErrorObject"),n(ut,"getErrorObject");function ri(y){return u(y)}i(ri,"validateAttrName"),n(ri,"validateAttrName");function Wi(y){return u(y)}i(Wi,"validateTagName"),n(Wi,"validateTagName");function Dt(y,R){let E=y.substring(0,R).split(/\r?\n/);return{line:E.length,col:E[E.length-1].length+1}}i(Dt,"getLineNumberForPosition"),n(Dt,"getLineNumberForPosition");function Ln(y){return y.startIndex+y[1].length}i(Ln,"getPositionFromMatch"),n(Ln,"getPositionFromMatch");var Yi=class{static{i(this,"XMLParser")}static{n(this,"XMLParser")}constructor(y){this.externalEntities={},this.options=b(y)}parse(y,R){if(typeof y!="string"&&y.toString)y=y.toString();else if(typeof y!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(R){R===!0&&(R={});let U=Sr(y,R);if(U!==!0)throw Error(`${U.err.msg}:${U.err.line}:${U.err.col}`)}let E=new we(this.options);E.addExternalEntities(this.externalEntities);let x=E.parseXml(y);return this.options.preserveOrder||x===void 0?x:br(x,this.options,E.matcher)}addEntity(y,R){if(R.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(y.indexOf("&")!==-1||y.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(R==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[y]=R}static getMetaDataSymbol(){return v.getMetaDataSymbol()}};return new Yi(e)},"getXmlParser");var qP=class extends vo{static{i(this,"XmlToJsonOutboundPolicy")}static policyType="xml-to-json";parser;parseOnStatusCodes;constructor(t,n){let o=Ro(t,["textNodeName"]);super(o,n),We(this.options,this.policyName).optional("removeNSPrefix","boolean").optional("ignoreProcessingInstructions","boolean").optional("ignoreDeclarations","boolean").optional("ignoreAttributes","boolean").optional("stopNodes","array").optional("attributeNamePrefix","string").optional("textNodeName","string").optional("trimValues","boolean"),this.parseOnStatusCodes=o.parseOnStatusCodes?Wo(o.parseOnStatusCodes):void 0,this.parser=SB({removeNSPrefix:o?.removeNSPrefix??!0,ignorePiTags:o?.ignoreProcessingInstructions??!0,ignoreDeclaration:o?.ignoreDeclarations??!0,ignoreAttributes:o?.ignoreAttributes??!0,stopNodes:o?.stopNodes??[],attributeNamePrefix:o?.attributeNamePrefix??"@_",textNodeName:o?.textNodeName??"#text",trimValues:o?.trimValues??!0,processEntities:{enabled:!0,maxTotalExpansions:1/0,maxEntityCount:1e3}})}async handler(t,n,o){if(this.parseOnStatusCodes&&!this.parseOnStatusCodes.includes(t.status))return t;let r;try{let c=await t.text();r=this.parser.parse(c)}catch(c){let u=`XmlToJsonOutboundPolicy - Error parsing XML contents in policy '${this.policyName}'.`;throw o.log.error(u,c),new B(u)}let s=new Headers(t.headers);return s.set("content-type","application/json"),new Response(JSON.stringify(r),{status:t.status,statusText:t.statusText,headers:s})}};var DP=class{static{i(this,"ServiceProviderImpl")}services=new Map;addService(t,n){if(this.services.get(t))throw new je(`A service with the name ${t} already exists -- you cannot have duplicate services`);this.services.set(t,n)}getService(t){return this.services.get(t)}};var $P=class{static{i(this,"ApiKeyConsumerClient")}bucketId;cacheDurationSeconds;cacheNamePromise;constructor(t){this.bucketId=t?.bucketId,this.cacheDurationSeconds=t?.cacheDurationSeconds??60}getCacheName(t){return this.cacheNamePromise||(this.cacheNamePromise=Xe("zuplo-get-consumer",{bucketId:t})),this.cacheNamePromise}async get(t){me("utility.get-consumer");let n=bs(),o=this.bucketId??et.ZUPLO_SERVICE_BUCKET_ID;if(!o)throw new T("ApiKeyConsumerClient - no bucketId provided and no default bucket is configured for this environment. Pass `bucketId` explicitly (find it in the Zuplo portal under Settings > API Key Buckets).");if(!o.startsWith("bckt_"))throw new T(`ApiKeyConsumerClient - bucketId "${o}" is not a valid bucket id. Bucket ids start with "bckt_" (e.g. "bckt_2HaK3odRyJle6NJSu8mzNKBC30BYxllxL"); a bucket name (e.g. "zprj-...-working-copy") is not accepted here. Find the bucket id in the Zuplo portal under Settings > API Key Buckets.`);if(!t||t.trim()==="")throw new T("ApiKeyConsumerClient.get - consumerId is required and cannot be empty");let r=await this.getCacheName(o),s=new tt(r,n);if(this.cacheDurationSeconds>0){let l=await s.get(t);if(l)return l}let a=`/v2/key-auth/${encodeURIComponent(o)}/consumers/${encodeURIComponent(t)}`,c=await RR(a),u={id:c.id,name:c.name,createdOn:c.createdOn,updatedOn:c.updatedOn};return c.description!==void 0&&(u.description=c.description),c.metadata!==void 0&&(u.metadata=c.metadata),this.cacheDurationSeconds>0&&s.put(t,u,this.cacheDurationSeconds),u}};var wB=10,CB=3e4,Kp=class{static{i(this,"BackgroundLoader")}#e=new Map;#t;#o;#n;#i;#r;#s={};constructor(t,n){if(typeof n=="number"){let o=n;this.#o=o*1e3,this.#i=CB,this.#n=wB,this.#r=Number.POSITIVE_INFINITY}else{let o=n;this.#o=o.ttlSeconds*1e3,this.#i=o.loaderTimeoutSeconds?o.loaderTimeoutSeconds*1e3:CB,this.#n=wB,this.#r=o.staleIfErrorSeconds===void 0?Number.POSITIVE_INFINITY:o.staleIfErrorSeconds*1e3}this.#t=t}#a(t){return t.expiry<=new Date}#c(t){let n=this.#s[t];return!(n===void 0||n===0)}#l(t){let n=this.#e.get(t);if(n&&!this.#a(n))return n.data}async get(t){let n=this.#l(t);if(n)return this.#d(t),n;if(this.#c(t))try{await qie(()=>this.#l(t)!==void 0||!this.#c(t),this.#i+this.#n+1,this.#n);let o=this.#l(t);if(o)return o}catch{}try{return await this.#u(t)}catch(o){let r=this.#e.get(t);if(r&&!this.#p(r))return r.data;throw o}}#p(t){return this.#r===Number.POSITIVE_INFINITY?!1:this.#r<=0?!0:Date.now()>t.expiry.getTime()+this.#r}#d(t){if(!this.#c(t)){let n=this.#u(t);di().waitUntil(n)}}async#u(t){try{this.#s[t]===void 0&&(this.#s[t]=0),this.#s[t]++;let n=await Promise.race([this.#t(t),scheduler.wait(this.#i)]);if(n===void 0)throw new T(`BackgroundLoader: Loader timed out after ${this.#i} ms.`);return this.#e.set(t,{data:n,expiry:new Date(Date.now()+this.#o)}),n}finally{this.#s[t]--}}};async function qie(e,t,n){let o=Date.now();for(;!e();){let r=Date.now()-o;if(r>t)throw new T(`BackgroundLoader: Timeout waiting for an on-going loader after ${r} ms.`);await scheduler.wait(n)}}i(qie,"waitUntilTrue");import{trace as Die}from"@opentelemetry/api";var vB,TB=i(()=>(vB??=Die.getTracer("pipeline"),vB),"tracer"),IB=i(async(e,t,n)=>{let o=ot.instance.routeData.policies,r=Ua([e],o);if(r.length===0)throw new B(`Invalid 'invokeInboundPolicy call' - no policy '${e}' found.`);let s=r[0],a;try{a=rt.getContextExtensions(n)}catch{a=void 0}let c=a?.currentPolicyName;a&&(a.currentPolicyName=s.policyName);try{return await TB().startActiveSpan(`policy:${s.policyName}`,async l=>{try{Na(l,s);let d=await s.handler(t,n);if(d instanceof Request||d instanceof Be||d instanceof Response)return d instanceof Response||d instanceof Be?d:new Be(d);throw new T(`Invalid state - invalid handler on policy '${s.policyName}' invoked via 'invokeInboundPolicy' on route '${n.route.path}'. The result of an inbound policy must be a Response or Request.`)}catch(d){throw Jo(l,d),d}finally{l.end()}})}finally{a&&a.currentPolicyName===s.policyName&&(a.currentPolicyName=c)}},"invokeInboundPolicy"),EB=i(async(e,t,n,o)=>{let r=ot.instance.routeData.policies,s=nl([e],r);if(s.length===0)throw new B(`Invalid 'invokeOutboundPolicy call' - no policy '${e}' found.`);let a=s[0];return await TB().startActiveSpan(`policy:${a.policyName}`,async u=>{try{Na(u,a);let l=await a.handler(t,n,o);if(l instanceof Response)return l;throw new T(`Invalid state - invalid handler on policy '${a.policyName}' invoked via 'invokeOutboundPolicy' on route '${o.route.path}. The result of an outbound policy must be a Response.`)}catch(l){throw Jo(u,l),l}finally{u.end()}})},"invokeOutboundPolicy");var _t=class{static{i(this,"BaseAnalyticsEvent")}eventId;requestId;timestamp;accountName;projectName;deploymentName;unit;value;constructor(t){this.eventId=t.eventId,this.requestId=t.requestId,this.timestamp=t.timestamp??new Date,this.accountName=t.accountName,this.projectName=t.projectName,this.deploymentName=t.deploymentName,this.unit=t.unit,this.value=t.value}};var Hb=class extends _t{static{i(this,"AiGatewayBlockedCountEvent")}eventType=q.AI_GATEWAY_BLOCKED_COUNT;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.type||!this.metadata.type.trim())&&(this.metadata.type="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var Fb=class extends _t{static{i(this,"AiGatewayCostSumEvent")}eventType=q.AI_GATEWAY_COST_SUM;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.model||!this.metadata.model.trim())&&(this.metadata.model="unknown"),(!this.metadata.provider||!this.metadata.provider.trim())&&(this.metadata.provider="unknown"),(!this.metadata.label||!this.metadata.label.trim())&&(this.metadata.label="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown"),(!this.metadata.costSource||!this.metadata.costSource.trim())&&(this.metadata.costSource="unknown"),(!this.metadata.costAccuracy||!this.metadata.costAccuracy.trim())&&(this.metadata.costAccuracy="unknown")}};var Bb=class extends _t{static{i(this,"AiGatewayFallbackCountEvent")}eventType=q.AI_GATEWAY_FALLBACK_COUNT;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.type||!this.metadata.type.trim())&&(this.metadata.type="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var Gb=class extends _t{static{i(this,"AiGatewayLatencyHistogramEvent")}eventType=q.AI_GATEWAY_LATENCY_HISTOGRAM;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.model||!this.metadata.model.trim())&&(this.metadata.model="unknown"),(!this.metadata.provider||!this.metadata.provider.trim())&&(this.metadata.provider="unknown"),(!this.metadata.label||!this.metadata.label.trim())&&(this.metadata.label="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var Zb=class extends _t{static{i(this,"AiGatewayRequestCountEvent")}eventType=q.AI_GATEWAY_REQUEST_COUNT;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.model||!this.metadata.model.trim())&&(this.metadata.model="unknown"),(!this.metadata.provider||!this.metadata.provider.trim())&&(this.metadata.provider="unknown"),(!this.metadata.label||!this.metadata.label.trim())&&(this.metadata.label="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var Vb=class extends _t{static{i(this,"AiGatewayTokenSumEvent")}eventType=q.AI_GATEWAY_TOKEN_SUM;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.model||!this.metadata.model.trim())&&(this.metadata.model="unknown"),(!this.metadata.provider||!this.metadata.provider.trim())&&(this.metadata.provider="unknown"),(!this.metadata.label||!this.metadata.label.trim())&&(this.metadata.label="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var Jb=class extends _t{static{i(this,"AiGatewayWarningCountEvent")}eventType=q.AI_GATEWAY_WARNING_COUNT;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.type||!this.metadata.type.trim())&&(this.metadata.type="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var Kb=class extends _t{static{i(this,"CacheOperationEvent")}eventType=q.CACHE_OPERATION;metadata;constructor(t){super(t),this.metadata=t.metadata}};var Wb=class extends _t{static{i(this,"GraphqlOperationEvent")}eventType=q.GRAPHQL_OPERATION;metadata;constructor(t){super(t),this.metadata=t.metadata}};var Yb=class extends _t{static{i(this,"HandlerExecutionEvent")}eventType=q.HANDLER_EXECUTION;metadata;constructor(t){super(t),this.metadata=t.metadata}};var Qb=class extends _t{static{i(this,"McpEvent")}eventType;metadata;constructor(t){super(t),this.eventType=t.eventType,this.metadata=t.metadata}};var yt=i(e=>t=>new Qb({...t,eventType:e}),"buildMcpEvent"),$ie={[q.AI_GATEWAY_COST_SUM]:e=>new Fb(e),[q.AI_GATEWAY_REQUEST_COUNT]:e=>new Zb(e),[q.AI_GATEWAY_TOKEN_SUM]:e=>new Vb(e),[q.AI_GATEWAY_LATENCY_HISTOGRAM]:e=>new Gb(e),[q.AI_GATEWAY_WARNING_COUNT]:e=>new Jb(e),[q.AI_GATEWAY_BLOCKED_COUNT]:e=>new Hb(e),[q.AI_GATEWAY_FALLBACK_COUNT]:e=>new Bb(e),[q.MCP_REQUEST_RECEIVED]:yt(q.MCP_REQUEST_RECEIVED),[q.MCP_REQUEST_COMPLETED]:yt(q.MCP_REQUEST_COMPLETED),[q.MCP_REQUEST_REJECTED]:yt(q.MCP_REQUEST_REJECTED),[q.MCP_INITIALIZE_NEGOTIATED]:yt(q.MCP_INITIALIZE_NEGOTIATED),[q.MCP_CLIENT_UNSUPPORTED_BEHAVIOR]:yt(q.MCP_CLIENT_UNSUPPORTED_BEHAVIOR),[q.MCP_CAPABILITY_LISTED]:yt(q.MCP_CAPABILITY_LISTED),[q.MCP_CAPABILITY_INVOKED]:yt(q.MCP_CAPABILITY_INVOKED),[q.MCP_CAPABILITY_COMPLETED]:yt(q.MCP_CAPABILITY_COMPLETED),[q.MCP_CAPABILITY_FAILED]:yt(q.MCP_CAPABILITY_FAILED),[q.MCP_CAPABILITY_CONNECT_REQUIRED]:yt(q.MCP_CAPABILITY_CONNECT_REQUIRED),[q.MCP_AUTH_DOWNSTREAM_TOKEN_VALIDATED]:yt(q.MCP_AUTH_DOWNSTREAM_TOKEN_VALIDATED),[q.MCP_AUTH_DOWNSTREAM_TOKEN_REJECTED]:yt(q.MCP_AUTH_DOWNSTREAM_TOKEN_REJECTED),[q.MCP_OAUTH_CLIENT_REGISTERED]:yt(q.MCP_OAUTH_CLIENT_REGISTERED),[q.MCP_OAUTH_AUTHORIZE_STARTED]:yt(q.MCP_OAUTH_AUTHORIZE_STARTED),[q.MCP_OAUTH_AUTHORIZE_AWAITING_SETUP]:yt(q.MCP_OAUTH_AUTHORIZE_AWAITING_SETUP),[q.MCP_OAUTH_TOKEN_ISSUED]:yt(q.MCP_OAUTH_TOKEN_ISSUED),[q.MCP_OAUTH_TOKEN_REFRESH_ROTATED]:yt(q.MCP_OAUTH_TOKEN_REFRESH_ROTATED),[q.MCP_OAUTH_TOKEN_REVOKED]:yt(q.MCP_OAUTH_TOKEN_REVOKED),[q.MCP_AUTH_UPSTREAM_CONNECT_REQUIRED]:yt(q.MCP_AUTH_UPSTREAM_CONNECT_REQUIRED),[q.MCP_AUTH_UPSTREAM_CONNECT_STARTED]:yt(q.MCP_AUTH_UPSTREAM_CONNECT_STARTED),[q.MCP_AUTH_UPSTREAM_CALLBACK_RECEIVED]:yt(q.MCP_AUTH_UPSTREAM_CALLBACK_RECEIVED),[q.MCP_AUTH_UPSTREAM_TOKEN_EXCHANGE_SUCCEEDED]:yt(q.MCP_AUTH_UPSTREAM_TOKEN_EXCHANGE_SUCCEEDED),[q.MCP_AUTH_UPSTREAM_TOKEN_EXCHANGE_FAILED]:yt(q.MCP_AUTH_UPSTREAM_TOKEN_EXCHANGE_FAILED),[q.MCP_AUTH_UPSTREAM_CREDENTIAL_RESOLVED]:yt(q.MCP_AUTH_UPSTREAM_CREDENTIAL_RESOLVED),[q.MCP_AUTH_UPSTREAM_CREDENTIAL_MISSING]:yt(q.MCP_AUTH_UPSTREAM_CREDENTIAL_MISSING),[q.MCP_AUTH_UPSTREAM_RECONSENT_REQUIRED]:yt(q.MCP_AUTH_UPSTREAM_RECONSENT_REQUIRED),[q.GRAPHQL_OPERATION]:e=>new Wb(e),[q.CACHE_OPERATION]:e=>new Kb(e),[q.HANDLER_EXECUTION]:e=>new Yb(e)};function PB(e,t){let n=$ie[e];return n(t)}i(PB,"createAnalyticsEvent");var Xb=class{static{i(this,"ZuploGatewayAnalyticsContext")}#e;#t;constructor(t){this.#e=[],this.#t=t}addAnalyticsEvent(t,n,o,r,s){let a=this.createAnalyticsEvent(t,n,o,r,s);this.#e.push(a)}flushAnalyticsEvents(){let t=[...this.#e];return this.#e.length=0,t}getAnalyticsEvents(){return[...this.#e]}createAnalyticsEvent(t,n,o,r,s){return PB(n,{eventId:s??crypto.randomUUID(),requestId:this.#t,accountName:_.instance.accountName??"unknown",projectName:_.instance.projectName??"unknown",deploymentName:_.instance.deploymentName??"unknown",metadata:o,unit:r,value:t})}};var jie="127.0.0.1";function AB(e){let t=_.instance,n=e.get(t.trustedIpHeader)?.trim();return n||(t.isLocalDevelopment?jie:void 0)}i(AB,"resolveClientIp");function zie(e){let t={};if(!e)return t;try{let n=e.split(","),o={};return n.forEach(r=>{let[s,a]=r.split("=");s&&a&&(o[s.trim()]=a.trim())}),o.asnum&&(t[Vm]=o.asnum),o.zip&&(t[Jm]=o.zip.split("+")[0]),o.dma&&(t[Km]=o.dma),o.region_code&&(t[Wm]=o.region_code),o.timezone&&(t[Ym]=o.timezone),o.city&&(t[Hm]=o.city),o.continent&&(t[Fm]=o.continent),o.country_code&&(t[Bm]=o.country_code),o.long&&(t[Gm]=o.long),o.lat&&(t[Zm]=o.lat),t}catch{return{}}}i(zie,"parseEdgeScapeHeader");function kB(e,t){let n=zie(t);for(let[o,r]of Object.entries(n))e.has(o)||e.set(o,r)}i(kB,"setZpHeadersFromAkamaiEdgeScapeHeader");var Ba=class{static{i(this,"HeaderIncomingRequestProperties")}#e;constructor(t){this.#e=t;let n=t.get(yA);if(n){let o=new Headers(t);kB(o,n),this.#e=o}}detachFromRequest(){this.#e=Si(this.#e)}get ip(){return AB(this.#e)}get asn(){try{let t=this.#e.get(Vm);if(typeof t=="string")return parseInt(t,10)}catch{}}get asOrganization(){return this.#e.get(dA)??void 0}get city(){return this.#e.get(ZP)??this.#e.get(Hm)??void 0}get continent(){return this.#e.get(VP)??this.#e.get(Fm)??void 0}get country(){return this.#e.get(JP)??this.#e.get(Bm)??void 0}get latitude(){return this.#e.get(WP)??this.#e.get(Zm)??void 0}get longitude(){return this.#e.get(KP)??this.#e.get(Gm)??void 0}get colo(){return this.#e.get(pA)??void 0}get postalCode(){return this.#e.get(eA)??this.#e.get(Jm)??void 0}get metroCode(){return this.#e.get(XP)??this.#e.get(Km)??void 0}get region(){return this.#e.get(YP)??this.#e.get(mA)??void 0}get regionCode(){return this.#e.get(QP)??this.#e.get(Wm)??void 0}get timezone(){return this.#e.get(tA)??this.#e.get(Ym)??void 0}get httpProtocol(){return this.#e.get(fA)??void 0}get clientCert(){return this.#e.get(oA)??void 0}get clientMtlsVerificationStatus(){return this.#e.get(rA)??void 0}get clientMtlsVerificationReason(){return this.#e.get(iA)??void 0}get clientCertFingerprintSha256(){return this.#e.get(sA)??void 0}get clientCertNotBefore(){return this.#e.get(aA)??void 0}get clientCertNotAfter(){return this.#e.get(cA)??void 0}get clientCertIssuerDn(){return this.#e.get(uA)??void 0}get clientCertSubjectDn(){return this.#e.get(lA)??void 0}toJSON(){return{ip:this.ip,asn:this.asn,asOrganization:this.asOrganization,city:this.city,continent:this.continent,country:this.country,latitude:this.latitude,longitude:this.longitude,colo:this.colo,postalCode:this.postalCode,metroCode:this.metroCode,region:this.region,regionCode:this.regionCode,timezone:this.timezone,httpProtocol:this.httpProtocol,clientCert:this.clientCert,clientMtlsVerificationStatus:this.clientMtlsVerificationStatus,clientMtlsVerificationReason:this.clientMtlsVerificationReason,clientCertFingerprintSha256:this.clientCertFingerprintSha256,clientCertNotBefore:this.clientCertNotBefore,clientCertNotAfter:this.clientCertNotAfter,clientCertIssuerDn:this.clientCertIssuerDn,clientCertSubjectDn:this.clientCertSubjectDn}}};function nu(e){return{contextId:e.contextId,incomingRequestProperties:e.incomingRequestProperties,requestId:e.requestId,route:e.route,custom:e.custom,parentContext:e.parentContext,analyticsContext:e.analyticsContext}}i(nu,"createRewriteContext");var Zu=class extends Event{static{i(this,"ResponseSendingEvent")}constructor(t,n){super("responseSending"),this.request=t,this.mutableResponse=n}request;mutableResponse},Vu=class extends Event{static{i(this,"ResponseSentEvent")}constructor(t,n){super("responseSent"),this.request=t,this.response=n}request;response},Hie=Object.freeze([]),rt=class e{static{i(this,"ZuploContextExtensions")}static#e=new WeakMap;static initialize(t,n,o=n.url){if(!e.#e.has(t)){let r=new e(n,o);return e.#e.set(t,r),r}throw new Error(`ZuploContextExtensions already initialized for context with requestId '${t.requestId}'`)}static findContextExtensions(t){return e.#e.get(t)}static getContextExtensions(t){let n=e.#e.get(t);if(!n)throw new B(`Invalid state, could not get ZuploContext extensions for context with requestId '${t.requestId}'`);return n}latestRequest;originalRequest;receivedUrl;requestLogProperties=new Map;systemRequestLogProperties=new Map;#t;startDeferringMetrics(){return this.#t?!1:(this.#t=[],!0)}deferMetrics(t){return this.#t?(this.#t.push(t),!0):!1}flushDeferredMetrics(){let t=this.#t??[];this.#t=void 0;let n=[];for(let o of t)try{o()}catch(r){n.push(r)}return n}#o;#n=!1;addPipelineExitHook(t){if(this.#n){try{t(void 0)}catch(n){K.console.error("Error running a late pipeline exit hook",n)}return}this.#o??=[],this.#o.push(t)}runPipelineExitHooks(t){this.#n=!0;let n=this.#o;if(!n)return Hie;this.#o=void 0;let o=[];for(let r of n)try{r(t)}catch(s){o.push(s)}return o}auditLogEventId="";preRequestState;currentPolicyName;preRequestPhase;#i;#r;#s;constructor(t,n){this.latestRequest=t,this.originalRequest=t.originalRequest,this.receivedUrl=n,this.preRequestState=void 0,this.currentPolicyName=void 0,this.preRequestPhase=void 0,this.#i=[],this.#r=[],this.#s=[]}addResponseSendingHook(t){this.#r.push(t)}addResponseSendingFinalHook(t){this.#i.push(t)}addHandlerResponseHook(t){this.#s.push(t)}onResponseSendingFinal=i(async(t,n,o)=>{for(let r of this.#i)await r(t,n,o)},"onResponseSendingFinal");onResponseSending=i(async(t,n,o)=>{let r=t,s=_.instance.build.COMPATIBILITY_FLAGS.chainResponseSendingHooks;for(let a of this.#r)r=await a(s?r:t,n,o);return r},"onResponseSending");onHandlerResponse=i(async(t,n,o)=>{for(let r of this.#s)await r(t,n,o)},"onHandlerResponse")},oh=class extends EventTarget{static{i(this,"SystemZuploContext")}constructor({logger:t,route:n,requestId:o,event:r,custom:s,incomingRequestProperties:a,parentContext:c}){super(),this.log=Object.freeze(t),this.route=n,this.requestId=o,this.custom=s,this.incomingRequestProperties=a,this.parentContext=c,this.#e=r,this.invokeInboundPolicy=(u,l)=>IB(u,l,this),this.contextId=crypto.randomUUID(),this.invokeOutboundPolicy=(u,l,d)=>EB(u,l,d,this),this.invokeRoute=async(u,l)=>{let d=u;typeof u=="string"&&u.startsWith("/")&&(d=new URL(u,"http://localhost"));let p=new Be(d,l);return ot.instance.handleRequest(p,this,{parentContext:this,routeBinding:hx(l)})},this.waitUntil=u=>{this.#e.waitUntil(u)},this.addResponseSendingHook=u=>{rt.getContextExtensions(this).addResponseSendingHook(u)},this.addResponseSendingFinalHook=u=>{rt.getContextExtensions(this).addResponseSendingFinalHook(u)},this.addPreRequestHandler=(u,l)=>{f_(this,rt.getContextExtensions(this),u,l)},this.analyticsContext=new Xb(o),Object.freeze(this)}#e;#t=new EventTarget;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;invokeInboundPolicy;invokeOutboundPolicy;invokeRoute;waitUntil;addResponseSendingHook;addResponseSendingFinalHook;addPreRequestHandler;addEventListener(t,n,o){me("context.addEventListener");let r=i(s=>{try{typeof n=="function"?n(s):n.handleEvent(s)}catch(a){throw this.log.error(`Error invoking event ${t}. See following logs for details.`),a}},"wrapped");this.#t.addEventListener(t,r,o)}removeEventListener(t,n,o){me("context.removeEventListener"),this.#t.removeEventListener(t,n,o)}dispatchEvent(t){return this.#t.dispatchEvent(t)}};export{et as a,pe as b,fR as c,En as d,Qt as e,$u as f,mG as g,gR as h,lt as i,Ea as j,fG as k,cs as l,yR as m,me as n,RR as o,wR as p,Dn as q,Tr as r,Aa as s,us as t,Z as u,jt as v,ls as w,q as x,CR as y,vR as z,mf as A,Ve as B,Bn as C,hi as D,ge as E,vo as F,f_ as G,__ as H,_R as I,NR as J,jG as K,yi as L,Xb as M,nu as N,Zu as O,Vu as P,rt as Q,xS as R,Wn as S,NO as T,SM as U,IM as V,v4 as W,xM as X,bw as Y,O4 as Z,ks as _,Gn as $,mo as aa,_s as ba,tr as ca,nr as da,Mi as ea,Os as fa,_r as ga,Mt as ha,sg as ia,dc as ja,pc as ka,Ul as la,ql as ma,mc as na,fn as oa,Li as pa,Lt as qa,An as ra,bn as sa,fc as ta,Nt as ua,xr as va,hc as wa,gc as xa,Ms as ya,Ls as za,Ni as Aa,ag as Ba,yc as Ca,Dl as Da,bc as Ea,$l as Fa,Or as Ga,er as Ha,Ao as Ia,cg as Ja,ug as Ka,jl as La,zl as Ma,Rc as Na,Sc as Oa,Hl as Pa,Fl as Qa,Bl as Ra,Gl as Sa,wc as Ta,Zl as Ua,Vl as Va,Cc as Wa,Jl as Xa,Mr as Ya,Lr as Za,vc as _a,Tc as $a,Ic as ab,Nr as bb,fo as cb,Ec as db,Kl as eb,Wl as fb,Yl as gb,Ql as hb,Xl as ib,Ns as jb,ed as kb,td as lb,nd as mb,od as nb,rd as ob,id as pb,sd as qb,ad as rb,Pc as sb,cd as tb,ud as ub,ld as vb,dd as wb,pd as xb,md as yb,fd as zb,hd as Ab,gd as Bb,yd as Cb,bd as Db,Rd as Eb,Sd as Fb,wd as Gb,ko as Hb,_o as Ib,xo as Jb,Cd as Kb,Ur as Lb,qr as Mb,Us as Nb,vd as Ob,Td as Pb,Id as Qb,Ed as Rb,Pd as Sb,Ac as Tb,Ad as Ub,kd as Vb,kc as Wb,lg as Xb,_d as Yb,xd as Zb,Od as _b,ww as $b,Dr as ac,Md as bc,Ld as cc,Nd as dc,Ud as ec,qd as fc,Dd as gc,$d as hc,jd as ic,zd as jc,Oi as kc,Hd as lc,Fd as mc,Bd as nc,Gd as oc,Zd as pc,_c as qc,qs as rc,Ds as sc,xc as tc,Oc as uc,Mc as vc,Vd as wc,Lc as xc,Nc as yc,Jd as zc,Kd as Ac,Uc as Bc,$s as Cc,Wd as Dc,Yd as Ec,Qd as Fc,Xd as Gc,ep as Hc,tp as Ic,np as Jc,op as Kc,rp as Lc,ip as Mc,sp as Nc,ap as Oc,cp as Pc,up as Qc,lp as Rc,dg as Sc,dp as Tc,$r as Uc,pg as Vc,pp as Wc,mg as Xc,fg as Yc,hg as Zc,gg as _c,yg as $c,bg as ad,Rg as bd,Sg as cd,wg as dd,Cg as ed,vg as fd,Tg as gd,Ig as hd,Eg as id,Pg as jd,Ag as kd,mp as ld,fp as md,kg as nd,_g as od,xg as pd,Og as qd,hp as rd,gp as sd,Mg as td,Lg as ud,Ng as vd,Bg as wd,Ap as xd,Jg as yd,Di as zd,CL as Ad,uC as Bd,Fc as Cd,Bc as Dd,ji as Ed,oy as Fd,Br as Gd,ry as Hd,kL as Id,qp as Jd,cY as Kd,RN as Ld,yY as Md,SY as Nd,PC as Od,gPe as Pd,py as Qd,yPe as Rd,LC as Sd,UY as Td,NC as Ud,DC as Vd,UPe as Wd,qPe as Xd,oU as Yd,$U as Zd,jU as _d,zU as $d,HU as ae,FU as be,BU as ce,z5 as de,iv as ee,Y5 as fe,sv as ge,cv as he,lv as ie,mv as je,hv as ke,yv as le,Rv as me,wv as ne,Tv as oe,Pv as pe,_v as qe,Mv as re,Qs as se,Et as te,sr as ue,Nv as ve,Uv as we,Gp as xe,Zp as ye,Vp as ze,Hv as Ae,Wp as Be,Gv as Ce,Zv as De,N9 as Ee,Vv as Fe,Jv as Ge,aT as He,lT as Ie,qy as Je,Dy as Ke,xD as Le,Zy as Me,tI as Ne,iI as Oe,Xy as Pe,lI as Qe,mI as Re,h$ as Se,wI as Te,j$ as Ue,G$ as Ve,Z$ as We,PI as Xe,K$ as Ye,rb as Ze,n7 as _e,AI as $e,_n as af,rj as bf,MI as cf,LI as df,sj as ef,qI as ff,cj as gf,yj as hf,bj as if,Rj as jf,Sj as kf,wj as lf,Cj as mf,BI as nf,Ij as of,Ej as pf,Pj as qf,Aj as rf,kj as sf,_j as tf,xj as uf,Oj as vf,Mj as wf,hb as xf,aee as yf,qj as zf,$j as Af,YI as Bf,wee as Cf,eE as Df,Kj as Ef,Vi as Ff,yu as Gf,at as Hf,kt as If,qZe as Jf,lr as Kf,VZe as Lf,bm as Mf,YZe as Nf,QZe as Of,no as Pf,t2e as Qf,n2e as Rf,o2e as Sf,r2e as Tf,i2e as Uf,s2e as Vf,a2e as Wf,c2e as Xf,Rm as Yf,u2e as Zf,sa as _f,f2e as $f,Sb as ag,aa as bg,Ru as cg,rE as dg,E2e as eg,iE as fg,sE as gg,aE as hg,cE as ig,uE as jg,lE as kg,dE as lg,pE as mg,mE as ng,fE as og,Dz as pg,wo as qg,oo as rg,Ht as sg,Hz as tg,Mte as ug,Lte as vg,hE as wg,HJe as xg,FJe as yg,BJe as zg,rH as Ag,iH as Bg,fKe as Cg,hKe as Dg,gE as Eg,wm as Fg,Pb as Gg,gKe as Hg,cH as Ig,SKe as Jg,Cm as Kg,uH as Lg,lH as Mg,EKe as Ng,PKe as Og,AKe as Pg,kKe as Qg,dH as Rg,pH as Sg,fH as Tg,dr as Ug,Yr as Vg,cne as Wg,une as Xg,qKe as Yg,DKe as Zg,$Ke as _g,jKe as $g,pr as ah,RE as bh,mne as ch,XKe as dh,yH as eh,u4e as fh,SE as gh,hne as hh,vne as ih,Ine as jh,SH as kh,C4e as lh,v4e as mh,T4e as nh,TH as oh,A4e as ph,k4e as qh,_4e as rh,EE as sh,xb as th,PE as uh,PH as vh,$4e as wh,j4e as xh,z4e as yh,H4e as zh,v1 as Ah,ro as Bh,gWe as Ch,FE as Dh,TWe as Eh,T1 as Fh,IWe as Gh,Koe as Hh,Woe as Ih,BWe as Jh,GWe as Kh,Yoe as Lh,WWe as Mh,D1 as Nh,XWe as Oh,WE as Ph,YE as Qh,G1 as Rh,Sre as Sh,K1 as Th,oP as Uh,iF as Vh,iP as Wh,fF as Xh,sP as Yh,cP as Zh,gF as _h,yF as $h,bF as ai,dP as bi,mP as ci,IF as di,EF as ei,PF as fi,AF as gi,kF as hi,xF as ii,gP as ji,Bre as ki,UF as li,SP as mi,HF as ni,FF as oi,BF as pi,oie as qi,GF as ri,ZF as si,VF as ti,JF as ui,KF as vi,TP as wi,YF as xi,QF as yi,IP as zi,EP as Ai,tB as Bi,oB as Ci,rB as Di,kP as Ei,sB as Fi,pB as Gi,LP as Hi,NP as Ii,mB as Ji,RB as Ki,qP as Li,DP as Mi,$P as Ni,Kp as Oi};
|
|
428
|
-
/*! For license information please see chunk-
|
|
429
|
-
//# sourceMappingURL=chunk-
|
|
428
|
+
/*! For license information please see chunk-F4G3YEN2.js.LEGAL.txt */
|
|
429
|
+
//# sourceMappingURL=chunk-F4G3YEN2.js.map
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
* DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*--------------------------------------------------------------------------------------------*/
|
|
24
24
|
|
|
25
|
-
import{a as g}from"./chunk-A3QGJZO7.js";import{$ as T}from"./chunk-
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
import{a as g}from"./chunk-A3QGJZO7.js";import{$ as T}from"./chunk-M4IZPJP6.js";import{a as r}from"./chunk-TYV53J3B.js";var P=class e extends Request{static{r(this,"ZuploRequest")}#t=void 0;#e;#n;constructor(t,n,s){super(t,n);let o=n?.params;this.#n=s,o?this.#e=o:t instanceof e?this.#e=t.#e:this.#e={};let a=n?.user;a?this.user=a:t instanceof e&&(this.user=t.user)}get originalRequest(){return this.#n??null}get query(){if(this.#t===void 0){let t={},n=new URL(this.url).searchParams;for(let[s,o]of n.entries())t[s]=o;this.#t=t}return g(this.#t)}get params(){return g(this.#e)}user};function h(){return T.instance.build.COMPATIBILITY_FLAGS.mcpProtocolVersion20260728===!0}r(h,"isMcp20260728Enabled");var S="2026-07-28",A="io.modelcontextprotocol/protocolVersion",U="io.modelcontextprotocol/clientCapabilities",B="io.modelcontextprotocol/clientInfo",W="io.modelcontextprotocol/serverInfo",Z=-32022,Q=/^\d{4}-\d{2}-\d{2}$/;function I(e){return typeof e=="string"&&Q.test(e)&&e>=S}r(I,"isModernProtocolVersion");function f(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}r(f,"isRecord");function k(e){if(!f(e)||!f(e.params))return;let t=e.params._meta;return f(t)?t:void 0}r(k,"readRequestMeta");function L(e){let t=k(e)?.[A];return typeof t=="string"?t:void 0}r(L,"readEnvelopeProtocolVersion");function X(e){let t=k(e)?.[U];return f(t)?t:void 0}r(X,"readEnvelopeClientCapabilities");function x(e,t){if(Array.isArray(t))return!1;let n=e.get("mcp-protocol-version"),s=L(t);return n!==null&&I(n)||s!==void 0&&I(s)}r(x,"isModernMcpRequest");var ee="zuplo_upstream_connect";var M="2.0",R=-32600,N=-32602,re=-32603,oe=-32001,b=10*1024*1024;function c(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}r(c,"isRecord");function y(e){return typeof e=="string"||typeof e=="number"}r(y,"isRequestId");function p(e){return e===null?"null":Array.isArray(e)?"an array":typeof e=="object"?"an object":typeof e=="string"?JSON.stringify(e.length>40?`${e.slice(0,40)}\u2026`:e):String(e)}r(p,"describeValue");function i(e){if(!(e===void 0||c(e)))return`params must be an object when present (got ${p(e)}).`}r(i,"optionalObjectParams");function u(e,t){return n=>{if(!c(n))return`params must be an object with a string \`${e}\` (got ${p(n)}). Example: ${t}`;if(typeof n[e]!="string")return`params.${e} must be a string (got ${p(n[e])}). Example: ${t}`}}r(u,"requireStringField");var v={initialize:i,ping:i,"tools/list":i,"tools/call":u("name",'{"name":"my_tool","arguments":{}}'),"prompts/list":i,"prompts/get":u("name",'{"name":"my_prompt"}'),"resources/list":i,"resources/templates/list":i,"resources/read":u("uri",'{"uri":"file:///a.txt"}'),"resources/subscribe":u("uri",'{"uri":"file:///a.txt"}'),"resources/unsubscribe":u("uri",'{"uri":"file:///a.txt"}'),"completion/complete":i,"logging/setLevel":u("level",'{"level":"info"}'),"server/discover":i,"subscriptions/listen":i,"tasks/get":u("taskId",'{"taskId":"task-123"}'),"tasks/update":u("taskId",'{"taskId":"task-123"}'),"tasks/cancel":u("taskId",'{"taskId":"task-123"}')},C={"notifications/initialized":i,"notifications/cancelled":i,"notifications/progress":i,"notifications/roots/list_changed":i,"notifications/subscriptions/acknowledged":i},j=new Set(["server/discover","subscriptions/listen","tasks/get","tasks/update","tasks/cancel"]),$=new Set(["notifications/subscriptions/acknowledged"]);function V(e,t){return Object.hasOwn(v,e)&&(t||!j.has(e))}r(V,"isKnownRequestMethod");function w(e,t){return Object.hasOwn(C,e)&&(t||!$.has(e))}r(w,"isKnownNotificationMethod");function l(e){return{type:"invalid",...e.method===void 0?{}:{method:e.method},id:e.id,error:{code:e.code,message:e.message},raw:e.raw}}r(l,"invalidMessage");function m(e){return y(e)?e:null}r(m,"usableId");function K(e,t,n,s){if(V(t,s)){let o=v[t](e.params);if(o!==void 0)return l({raw:e,method:t,id:n,code:N,message:`Invalid params for \`${t}\`: ${o}`});let a=e.params===void 0?{}:e.params;return{type:"request",method:t,id:n,params:a,raw:e}}return{type:"request",method:t,id:n,params:e.params,raw:e}}r(K,"classifyRequest");function Y(e,t,n){if(w(t,n)){let s=C[t](e.params);if(s!==void 0)return l({raw:e,method:t,id:null,code:N,message:`Invalid params for \`${t}\`: ${s}`});let o=e.params===void 0?{}:e.params;return{type:"notification",method:t,params:o,raw:e}}return{type:"notification",method:t,params:e.params,raw:e}}r(Y,"classifyNotification");function _(e,t=!1){if(!c(e)||e.jsonrpc!==M)return l({raw:e,id:m(c(e)?e.id:void 0),code:R,message:`Invalid Request: batch member is not a JSON-RPC 2.0 message (got ${p(e)}). Every member must include \`"jsonrpc":"2.0"\`.`});let n=e.method;if(typeof n=="string"){if(!("id"in e))return Y(e,n,t);let s=e.id;return y(s)?K(e,n,s,t):l({raw:e,method:n,id:null,code:R,message:`Invalid Request: request id must be a string or number (got ${p(s)}). The gateway cannot correlate a reply to this id \u2014 omit \`id\` to send a notification instead.`})}if(n!==void 0)return l({raw:e,id:m(e.id),code:R,message:`Invalid Request: method must be a string (got ${p(n)}).`});if("result"in e&&y(e.id)&&c(e.result))return{type:"result",id:e.id,result:e.result,raw:e};if("error"in e){let s=e.error;if(c(s)&&typeof s.code=="number"&&typeof s.message=="string"){let o={code:s.code,message:s.message,...s.data===void 0?{}:{data:s.data}};return{type:"error",id:m(e.id),error:o,raw:e}}}return l({raw:e,id:m(e.id),code:R,message:"Invalid Request: message has no `method` and is not a valid JSON-RPC result or error."})}r(_,"classifyMember");var D=new WeakMap,q=new WeakMap;function ie(e){return q.get(e)}r(ie,"getEnvelopeText");async function G(e){let t=e.headers.get("content-type");if(t===null||!t.toLowerCase().includes("json"))return null;let n=e.headers.get("content-length");if(n!==null&&Number(n)>b)return null;let s;try{s=await e.clone().text()}catch{return null}if(s.length>b)return null;let o;try{o=JSON.parse(s)}catch{return null}let a=e.headers.get("mcp-protocol-version");if(Array.isArray(o)){if(o.length>0&&!o.some(d=>c(d)&&d.jsonrpc===M))return null;let O={transport:"json",shape:"batch",messages:o.map(d=>_(d)),...a===null?{}:{protocolVersion:a}};return q.set(O,s),O}if(!c(o)||o.jsonrpc!==M)return null;let E={transport:"json",shape:"single",messages:[_(o,h()&&x(e.headers,o))],...a===null?{}:{protocolVersion:a}};return q.set(E,s),E}r(G,"parseEnvelope");function ae(e){let t=D.get(e);return t===void 0&&(t=G(e),D.set(e,t)),t}r(ae,"getRequest");export{P as a,h as b,S as c,A as d,U as e,B as f,W as g,Z as h,I as i,L as j,X as k,x as l,ee as m,M as n,R as o,re as p,oe as q,c as r,y as s,ie as t,ae as u};
|
|
26
|
+
//# sourceMappingURL=chunk-GWGCD6Z7.js.map
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
* DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*--------------------------------------------------------------------------------------------*/
|
|
24
24
|
|
|
25
|
-
import{a as x,n as O,o as H,p as I,q as N,r as h,s as C,u as b}from"./chunk-
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
import{a as x,n as O,o as H,p as I,q as N,r as h,s as C,u as b}from"./chunk-GWGCD6Z7.js";import{a as l}from"./chunk-TYV53J3B.js";function f(n,e){return{jsonrpc:O,id:n,error:{code:e.code,message:e.message,...e.data===void 0?{}:{data:e.data}}}}l(f,"errorReply");function v(n,e){return{jsonrpc:O,id:n,result:e}}l(v,"resultReply");function q(n,e){return e.length===0?new Response(null,{status:202}):Response.json(n==="single"?e[0]:e)}l(q,"replyResponse");function A(n){return n.type==="request"}l(A,"isRequestType");function $(n,e,o){let a=o===void 0?void 0:e,i=o===void 0?e:o;if(a!==void 0&&!n.messages.includes(a))throw new Error("createErrorResponse: the message must be one of envelope.messages from the same getRequest() parse.");let t=[];for(let c of n.messages)if(c.type==="request"){let r=a===void 0||c===a?i:{code:N,message:"Not processed"};t.push(f(c.id,r))}else c.type==="invalid"&&t.push(f(c.id,c.error));return q(n.shape,t)}l($,"createErrorResponse");function S(n,e,o){let a=n.messages.filter(A);if(a.length!==1||a[0]!==e)throw new Error("createResultResponse: the message must be the envelope's only request. For batches with multiple requests use processMessages, which forwards the rest and stitches replies by id.");let i=[];for(let t of n.messages)t===e?i.push(v(e.id,o)):t.type==="invalid"&&i.push(f(t.id,t.error));return q(n.shape,i)}l(S,"createResultResponse");function j(n,e){if(n===void 0)return;let o=n,a=Object.hasOwn(n,e)?o[e]:void 0;return a!==void 0?a:Object.hasOwn(n,"*")?o["*"]:void 0}l(j,"pickHandler");function T(n){return typeof n=="string"?`s:${n}`:`n:${n}`}l(T,"idKey");function D(n){let e=new Set;for(let o of n.messages){if(o.type!=="request")continue;let a=T(o.id);if(e.has(a))return o.id;e.add(a)}}l(D,"findDuplicateRequestId");async function K(n){let{response:e,plan:o,context:a,policyName:i}=n,t=(e.headers.get("content-type")??"").toLowerCase(),c=[];if(t.includes("json"))try{let p=await e.clone().text();if(p.trim().length>0){let u=JSON.parse(p);c=Array.isArray(u)?u:[u]}}catch{return a.log.warn(`MCP policy "${i}": upstream JSON response could not be parsed; locally generated replies were not merged.`),e}else if(e.body!==null)return a.log.warn(`MCP policy "${i}": upstream response is "${t||"unknown"}"; locally generated replies were not merged.`),e;if(c.length>0&&!c.every(p=>h(p)&&p.jsonrpc==="2.0"))return a.log.warn(`MCP policy "${i}": upstream response body is not JSON-RPC; locally generated replies were not merged.`),e;let r=new Map,y=[];for(let p of c){let u=h(p)?p.id:void 0,s=C(u)?T(u):void 0;s===void 0||r.has(s)?y.push(p):r.set(s,p)}let d=[];for(let p of o)if(p.action==="local")d.push(p.reply);else if(p.action==="forward"&&p.replyId!==void 0){let u=T(p.replyId),s=r.get(u);s===void 0?a.log.warn(`MCP policy "${i}": upstream returned no reply for request id ${JSON.stringify(p.replyId)}; the gateway does not synthesize results, so the gap is passed through.`):(r.delete(u),d.push(s))}let R=[...r.values(),...y];R.length>0&&(a.log.warn(`MCP policy "${i}": upstream returned ${R.length} repl${R.length===1?"y":"ies"} with unexpected or duplicate ids; appended after the correlated replies.`),d.push(...R));let m=new Headers(e.headers);m.delete("content-length"),m.set("content-type","application/json");let P=e.status===202||e.status===204?200:e.status;return new Response(JSON.stringify(d),{status:P,headers:m})}l(K,"stitchResponse");function J(n){return async(e,o,a,i)=>{let t=await b(e);if(t===null)return e;if(t.shape==="batch"&&t.messages.length===0)return Response.json(f(null,{code:H,message:"Invalid Request: batch must not be empty."}));let c=D(t);if(c!==void 0){let s=t.messages.filter(g=>g.type==="request").map(g=>f(g.id??null,{code:H,message:`Invalid Request: duplicate request id ${JSON.stringify(c)} in batch. Ids must be unique so replies can be correlated.`}));return q(t.shape,s)}let r=[],y=0,d=!1;for(let s of t.messages)switch(s.type){case"invalid":{r.push({action:"local",reply:f(s.id,s.error)}),y+=1,d=!0;break}case"result":case"error":{r.push({action:"forward",wire:s.raw,replyId:void 0});break}case"request":case"notification":{let g=j(n.requests,s.method),w=s.type==="request",k=w?s.id:void 0;if(g===void 0){r.push({action:"forward",wire:s.raw,replyId:k});break}let M;try{M=await g({message:s,request:e,context:o,envelope:t,options:a,policyName:i})}catch(E){if(o.log.error(`MCP message handler for "${s.method}" threw in policy "${i}"; failing only this message.`,E),M=w?{error:{code:I,message:"Internal error"}}:void 0,!w){r.push({action:"drop"}),d=!0;break}}if(M===void 0)r.push({action:"forward",wire:s.raw,replyId:k});else if("params"in M){if(!h(M.params)){o.log.error(`MCP message handler for "${s.method}" in policy "${i}" returned a non-object params verdict; failing only this message.`),w?(r.push({action:"local",reply:f(s.id,{code:I,message:"Internal error"})}),y+=1):r.push({action:"drop"}),d=!0;break}let E=h(s.raw)?s.raw:{};r.push({action:"forward",wire:{...E,params:M.params},replyId:k}),d=!0}else"error"in M?(w?(r.push({action:"local",reply:f(s.id,M.error)}),y+=1):r.push({action:"drop"}),d=!0):"result"in M?(w?(r.push({action:"local",reply:v(s.id,M.result)}),y+=1):(o.log.warn(`MCP message handler for "${s.method}" in policy "${i}" returned a result for a notification; notifications have no replies, dropping the message.`),r.push({action:"drop"})),d=!0):r.push({action:"forward",wire:s.raw,replyId:k});break}}let R=r.filter(s=>s.action==="forward");if(R.length===0){let s=[];for(let g of r)g.action==="local"&&s.push(g.reply);return q(t.shape,s)}if(!d)return e;let m=R.map(s=>s.wire),P=JSON.stringify(t.shape==="single"?m[0]:m),p=new Headers(e.headers);p.delete("content-length");let u=new x(e,{body:P,headers:p});return y>0&&o.addResponseSendingHook(s=>K({response:s,plan:r,context:o,policyName:i})),u}}l(J,"processMessages");export{$ as a,S as b,J as c};
|
|
26
|
+
//# sourceMappingURL=chunk-HTXNM72E.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Zuplo, Inc. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This software and associated documentation files (the "Software") is intended to be used
|
|
6
|
+
* only by Zuplo customers solely to develop and test applications that will be deployed
|
|
7
|
+
* to Zuplo hosted services. You and others in your organization may use these files on your
|
|
8
|
+
* Development Devices solely for the above stated purpose.
|
|
9
|
+
*
|
|
10
|
+
* Outside of uses stated above, no license is granted for any other purpose including
|
|
11
|
+
* without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
12
|
+
* sublicense, host, and/or sell copies of the Software.
|
|
13
|
+
*
|
|
14
|
+
* The software may include third party components with separate legal notices or governed by
|
|
15
|
+
* other agreements, as described in licenses either embedded in or accompanying the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
18
|
+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
19
|
+
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
20
|
+
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
21
|
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
22
|
+
* DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*--------------------------------------------------------------------------------------------*/
|
|
24
|
+
|
|
25
|
+
import{a as r}from"./chunk-TYV53J3B.js";var U=class extends Error{static{r(this,"SystemError")}constructor(t,n){super(t,n),this.name="InternalError"}},N=class extends TypeError{static{r(this,"NetworkError")}cause;constructor(t){super("The upstream request failed due to a network error.",{cause:t}),this.name="TypeError",this.cause=t}},A=class extends Error{static{r(this,"RuntimeError")}extensionMembers;constructor(t,n){typeof t=="string"?super(t,n):(super(t.message,n),this.extensionMembers=t.extensionMembers),this.name="RuntimeError"}},J=class extends A{static{r(this,"ConfigurationError")}constructor(t,n){super(t,n),this.name="ConfigurationError"}};var ht="zuplo-request-id",Ee="zp-rid",he="zp-body-removed",Re="cf-ray",Rt="x-forwarded-scheme",Ot="x-forwarded-proto",yt="x-scheme",Oe="cf-ipcity",ye="cf-ipcontinent",Ae="cf-ipcountry",Se="cf-iplongitude",Te="cf-iplatitude",At="cf-region",St="cf-region-code",Tt="cf-metro-code",bt="cf-postal-code",Pt="cf-timezone",Ct="zp-ipcity",Lt="zp-ipcontinent",xt="zp-ipcountry",It="zp-iplongitude",wt="zp-iplatitude",K="x-real-ip",v="true-client-ip";var be="zp-client-cert",Pe="zp-mtls-status",Ce="zp-mtls-failure-reason",Le="zp-mtls-cert-fingerprint-sha256",xe="zp-mtls-cert-not-before",Ie="zp-mtls-cert-not-after",we="zp-mtls-cert-issuer-dn",Ue="zp-mtls-cert-subject-dn",Ne="zp-asn",Me="zp-asorg",De="zp-colo",ve="zp-postalcode",He="zp-metrocode",ze="zp-region",Fe="zp-regioncode",Ze="zp-timezone",Ut="zp-http-protocol",H="zp-local-service",Ve="zp-gateway-api-key",ke="x-akamai-edgescape",Nt=[be,Pe,Ce,Le,xe,Ie,we,Ue,ke,H],Mt=[Oe,ye,Ae,Se,Te,Ne,Me,De,ve,He,ze,Fe,Ze],Dt=["zp-","cf-"],vt=[Ee,Re,he,Ve];var Ht="system-logger";var Be=!1;function P(e,t){return{open:`\x1B[${e.join(";")}m`,close:`\x1B[${t}m`,regexp:new RegExp(`\\x1b\\[${t}m`,"g")}}r(P,"code");function C(e,t){return Be?`${t.open}${e.replace(t.regexp,t.open)}${t.close}`:e}r(C,"run");function Ge(e){return C(e,P([31],39))}r(Ge,"red");function $e(e){return C(e,P([32],39))}r($e,"green");function je(e){return C(e,P([33],39))}r(je,"yellow");function Ye(e){return C(e,P([34],39))}r(Ye,"blue");function qe(e){return C(e,P([35],39))}r(qe,"magenta");function We(e){return C(e,P([36],39))}r(We,"cyan");var Ft=new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|"),"g");var X=[Ge,$e,je,Ye,qe,We];function Je(e){let t=0,n=e.length,i=0;if(n>0)for(;i<n;)t=(t<<5)-t+e.charCodeAt(i++)|0;return t}r(Je,"hashCode");function Q(e){let t=Math.abs(Je(e));return X[t%X.length]}r(Q,"generateColor");function ee(e,t,...n){let i=0,o=n.length,c=String(t).replace(/%[sdjoO%]/g,s=>{if(s==="%%")return"%";if(i>=o)return s;switch(s){case"%s":return String(n[i++]);case"%d":return Number(n[i++]).toString();case"%o":return e(n[i++]).split(`
|
|
26
|
+
`).map(l=>l.trim()).join(" ");case"%O":return e(n[i++]);case"%j":try{return JSON.stringify(n[i++])}catch{return"[Circular]"}default:return s}});for(let s of n.splice(i))s===null||!(typeof s=="object"&&s!==null)?c+=" "+s:c+=" "+e(s);return c}r(ee,"format");function T(e,t,n,i){let o={seen:[],stylize:Ke,showHidden:t??!1,depth:n??2,colors:i??!1,customInspect:!0};return o.colors&&(o.stylize=Qe),M(o,e,o.depth)}r(T,"inspect");T.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};T.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function Ke(e,t){return e}r(Ke,"stylizeNoColor");function Xe(e){return typeof e=="boolean"}r(Xe,"isBoolean");function ne(e){return e===void 0}r(ne,"isUndefined");function Qe(e,t){let n=T.styles[t];return n?"\x1B["+T.colors[n][0]+"m"+e+"\x1B["+T.colors[n][1]+"m":e}r(Qe,"stylizeWithColor");function z(e){return typeof e=="function"}r(z,"isFunction");function re(e){return typeof e=="string"}r(re,"isString");function et(e){return typeof e=="number"}r(et,"isNumber");function oe(e){return e===null}r(oe,"isNull");function ie(e,t){return Object.hasOwn(e,t)}r(ie,"hasOwn");function F(e){return B(e)&&G(e)==="[object RegExp]"}r(F,"isRegExp");function B(e){return typeof e=="object"&&e!==null}r(B,"isObject");function Z(e){return B(e)&&(G(e)==="[object Error]"||e instanceof Error)}r(Z,"isError");function te(e){return B(e)&&G(e)==="[object Date]"}r(te,"isDate");function G(e){return Object.prototype.toString.call(e)}r(G,"objectToString");function tt(e){let t={};return e.forEach(function(n,i){t[n]=!0}),t}r(tt,"arrayToHash");function nt(e,t,n,i,o){let c=[];for(let s=0,l=t.length;s<l;++s)ie(t,String(s))?c.push(k(e,t,n,i,String(s),!0)):c.push("");return o.forEach(function(s){s.match(/^\d+$/)||c.push(k(e,t,n,i,s,!0))}),c}r(nt,"formatArray");function V(e){return"["+Error.prototype.toString.call(e)+"]"}r(V,"formatError");function M(e,t,n){if(e.customInspect&&t&&z(t.inspect)&&t.inspect!==T&&!(t.constructor&&t.constructor.prototype===t)){let u=t.inspect(n,e);return re(u)||(u=M(e,u,n)),u}let i=rt(e,t);if(i)return i;let o=Object.keys(t),c=tt(o);try{e.showHidden&&Object.getOwnPropertyNames&&(o=Object.getOwnPropertyNames(t))}catch{}if(Z(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return V(t);if(o.length===0){if(z(t)){let u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(F(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(te(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Z(t))return V(t)}let s="",l=!1,p=["{","}"];if(Array.isArray(t)&&(l=!0,p=["[","]"]),z(t)&&(s=" [Function"+(t.name?": "+t.name:"")+"]"),F(t)&&(s=" "+RegExp.prototype.toString.call(t)),te(t)&&(s=" "+Date.prototype.toUTCString.call(t)),Z(t)&&(s=" "+V(t)),o.length===0&&(!l||t.length==0))return p[0]+s+p[1];if(n<0)return F(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);let a;return l?a=nt(e,t,n,c,o):a=o.map(function(u){return k(e,t,n,c,u,l)}),e.seen.pop(),ot(a,s,p)}r(M,"formatValue");function k(e,t,n,i,o,c){let s,l,p;p={value:void 0};try{p.value=t[o]}catch{}try{Object.getOwnPropertyDescriptor&&(p=Object.getOwnPropertyDescriptor(t,o)||p)}catch{}if(p.get?p.set?l=e.stylize("[Getter/Setter]","special"):l=e.stylize("[Getter]","special"):p.set&&(l=e.stylize("[Setter]","special")),ie(i,o)||(s="["+o+"]"),l||(e.seen.indexOf(p.value)<0?(oe(n)?l=M(e,p.value,null):l=M(e,p.value,n-1),l.indexOf(`
|
|
27
|
+
`)>-1&&(c?l=l.split(`
|
|
28
|
+
`).map(function(a){return" "+a}).join(`
|
|
29
|
+
`).substr(2):l=`
|
|
30
|
+
`+l.split(`
|
|
31
|
+
`).map(function(a){return" "+a}).join(`
|
|
32
|
+
`))):l=e.stylize("[Circular]","special")),ne(s)){if(c&&o.match(/^\d+$/))return l;s=JSON.stringify(""+o),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+l}r(k,"formatProperty");function rt(e,t){if(ne(t))return e.stylize("undefined","undefined");if(re(t)){let n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(et(t))return e.stylize(""+t,"number");if(Xe(t))return e.stylize(""+t,"boolean");if(oe(t))return e.stylize("null","null")}r(rt,"formatPrimitive");function ot(e,t,n){let i=0;return e.reduce(function(c,s){return i++,s.indexOf(`
|
|
33
|
+
`)>=0&&i++,c+s.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?n[0]+(t===""?"":t+`
|
|
34
|
+
`)+" "+e.join(`,
|
|
35
|
+
`)+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}r(ot,"reduceToSingleString");var se=r((e,...t)=>ee(T,e,t),"format");var $=class{static{r(this,"Debugger")}manager;ns;color;last;enabled;constructor(t,n){this.manager=t,this.ns=n,this.color=Q(n),this.last=0,this.enabled=t.enabled.some(i=>i.test(n))}log(...t){if(!this.enabled)return;let n,i=t[0];typeof i=="function"?n=i():n=String(i);let o=Date.now()-(this.last||Date.now());n=se(n,...t);let c=`${this.color(this.ns)} ${n} ${this.color(`+${o}ms`)}`;console.log(c),this.last=Date.now()}},j=class{static{r(this,"DebugManager")}debuggers;enabled;constructor(t){this.debuggers=new Map,this.enabled=t??[]}};function it(e){return!e||e.length===0?[]:(e=e.replace(/\s/g,"").replace(/\*/g,".+"),e.split(",").map(t=>new RegExp(`^${t}$`)))}r(it,"extract");var D;function ae(e){let t=globalThis.DEBUG;D||(D=new j(it(t)));let n=new $(D,e);return D.debuggers.set(e,n),Object.assign(n.log.bind(n),{self:n})}r(ae,"debug");function st(e){if(e.length>=255)throw new TypeError("Alphabet too long");let t=new Uint8Array(256);for(let a=0;a<t.length;a++)t[a]=255;for(let a=0;a<e.length;a++){let u=e.charAt(a),E=u.charCodeAt(0);if(t[E]!==255)throw new TypeError(u+" is ambiguous");t[E]=a}let n=e.length,i=e.charAt(0),o=Math.log(n)/Math.log(256),c=Math.log(256)/Math.log(n);function s(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";let u=0,E=0,g=0,d=a.length;for(;g!==d&&a[g]===0;)g++,u++;let R=(d-g)*c+1>>>0,m=new Uint8Array(R);for(;g!==d;){let O=a[g],h=0;for(let S=R-1;(O!==0||h<E)&&S!==-1;S--,h++)O+=256*m[S]>>>0,m[S]=O%n>>>0,O=O/n>>>0;if(O!==0)throw new Error("Non-zero carry");E=h,g++}let f=R-E;for(;f!==R&&m[f]===0;)f++;let y=i.repeat(u);for(;f<R;++f)y+=e.charAt(m[f]);return y}r(s,"encode");function l(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;let u=0,E=0,g=0;for(;a[u]===i;)E++,u++;let d=(a.length-u)*o+1>>>0,R=new Uint8Array(d);for(;u<a.length;){let O=a.charCodeAt(u);if(O>255)return;let h=t[O];if(h===255)return;let S=0;for(let w=d-1;(h!==0||S<g)&&w!==-1;w--,S++)h+=n*R[w]>>>0,R[w]=h%256>>>0,h=h/256>>>0;if(h!==0)throw new Error("Non-zero carry");g=S,u++}let m=d-g;for(;m!==d&&R[m]===0;)m++;let f=new Uint8Array(E+(d-m)),y=E;for(;m!==d;)f[y++]=R[m++];return f}r(l,"decodeUnsafe");function p(a){let u=l(a);if(u)return u;throw new Error("Non-base"+n+" character")}return r(p,"decode"),{encode:s,decodeUnsafe:l,decode:p}}r(st,"base");var ce=st;var at="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",le=ce(at);var ct=/: client error \((?:Connect|SendRequest)\):/;function lt(e){return e instanceof TypeError&&e.message.startsWith("error sending request ")&&ct.test(e.message)}r(lt,"isDenoClientError");function L(e,t){return t?e.catch(n=>{throw lt(n)?new N(n):n}):e}r(L,"wrapDenoNetworkErrors");var b=ae("zuplo:runtime:external-service");function ut(){let e,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:t}=_.instance.runtime;if(t&&t!=="undefined")try{let n=atob(t);e=JSON.parse(n)}catch{}return e}r(ut,"getServiceAuth");async function ue(e,t){let n=".proxy",i=".tunnel";if(typeof e=="string"){let o=new URL(e),c=o.hostname;if(c.endsWith(n)){let f=c.slice(0,-n.length),y=new URL(`http://${f}${o.pathname}${o.search}`);b(`Routing to proxy: ${y.toString()}`);let O=t??{};return x(y.toString(),O)}let s=c.endsWith(i),l=c.indexOf(".")===-1;if(!(s||l))throw new A(`Invalid service hostname suffix: ${c}. Use .proxy for proxy routing, .tunnel for explicit tunnel routing, or no suffix for default tunnel routing.`);let a=s?c.slice(0,-i.length):c,u=ut();if(!u)throw b("There is no external service auth configured for this zup."),new A("There are no external services configured for this zup.");b(`Using external service auth. ClientId: ${u.clientId})`);let E=t??{},g=new Headers(E.headers||{});g.set("CF-Access-Client-Id",u.clientId),g.set("CF-Access-Client-Secret",u.clientSecret),E.headers=g;let d;if(u.customServiceMapping?.[a])d=`https://${u.customServiceMapping[a]}`;else if(_.instance.useLegacyServiceRouting)d=`https://${a}.zuptunnel.com`;else{b("Using sha256 service routing");let f=_.instance.build;if(f.ACCOUNT_NAME&&f.PROJECT_NAME&&f.ENVIRONMENT_TYPE){let y=await pt(a,f.ACCOUNT_NAME,f.PROJECT_NAME,f.ENVIRONMENT_TYPE),O=fe(f.ENVIRONMENT_TYPE),h=await Y(`${f.ACCOUNT_NAME}-${f.PROJECT_NAME}-${O}`);h==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||h==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?d=`https://${y}.zuptunnel.com`:d=`https://${y}.t.zuplo.app`}else throw b("Cannot use sha256 service routing, missing build variables"),new A("Failed to generate fully qualified tunnel url.")}let R=new URL(`${d}${o.pathname}${o.search}`);b(`Calling external service: ${R.toString()}`);let m=await x(R.toString(),E);if(m.status===403&&m.headers.get("cf-access-domain")!==null)throw I.console.error("403 Forbidden when calling external service.",{clientId:u.clientId,tunnelHost:d}),new A("Could not connect to secure tunnel.");return m}else throw b("Cannot call external service with Request object"),new A("Currently, we only support fetch(<some_string>, ...).")}r(ue,"externalServiceHandler");async function pe(e,t){if(typeof e=="string"){let n=new URL(e),i=n.hostname,o=t??{},c=`http://${i}.zuplo.svc.cluster.local:9000`,s=new URL(`${c}${n.pathname}${n.search}`),l=new Headers(o.headers||{});return l.set(H,i),o.headers=l,await x(s.toString(),o)}else throw new A("Currently, we only support fetch(<some_string>, ...).")}r(pe,"clusterServiceHandler");async function pt(e,t,n,i){let o=e.toLowerCase(),c=t.toLowerCase(),s=n.toLowerCase(),l=fe(i);b(`Hashing service name: ${c}-${o}.${c}-${s}-${l}`);let p=await Y(`${c}-${o}`),a=await Y(`${c}-${s}-${l}`);return`${p}.${a}`}r(pt,"hashServiceName");async function Y(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(c=>c.toString(16).padStart(2,"0")).join("").slice(0,-1)}r(Y,"hashSegment");function fe(e){let t=e.toLowerCase();switch(t){case"production":case"preview":return t;default:return"working-copy"}}r(fe,"sanitizeEnvironmentType");var q=new Map;q.set("service:",ue);q.set("local:",pe);var x=globalThis.fetch;function W(e,t){let{transformedInit:n,mtlsCertificate:i}=ft(t);if(typeof e=="string"){let o=new URL(e),c=q.get(o.protocol);return c?L(c(e,n),_.instance.isDeno):de(e,n,i)}else return de(e,n,i)}r(W,"internalFetch");globalThis.fetch=W;function de(e,t,n){if(!n)return L(x(e,t),_.instance.isDeno);if(_.instance.isCloudflare){let o=_.instance.runtime[n];if(!o)throw new Error(`mTLS certificate binding '${n}' not found. Ensure the certificate is uploaded and properly configured.`);if(typeof o!="object"||typeof o.fetch!="function")throw new Error(`mTLS certificate binding '${n}' is not a valid mTLS certificate binding. Make sure it's configured as an mTLS certificate, not an environment variable.`);return L(o.fetch(e,t),_.instance.isDeno)}else if(_.instance.isDeno){let i=globalThis.managedDedicatedMtlsBindings?.[n];if(!i)throw new Error(`mTLS certificate binding '${n}' not found. Ensure the certificate is uploaded and properly configured.`);if(typeof i.fetch!="function")throw new Error(`mTLS certificate binding '${n}' is not a valid mTLS certificate binding.`);return L(i.fetch(e,t),!0)}else throw new Error("mTLS client certificates are not supported in this runtime environment")}r(de,"performFetch");var ft=r(e=>{if(!e||e instanceof Request)return{transformedInit:e,mtlsCertificate:void 0};let t=e;if(!t.zuplo)return{transformedInit:e,mtlsCertificate:void 0};let n=t.zuplo.mtlsCertificate,i=e;return i.cf={cacheEverything:t.zuplo?.cacheEverything,cacheTtl:t.zuplo?.cacheTtlSeconds},delete e.zuplo,{transformedInit:e,mtlsCertificate:n}},"transformInit");var dt={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:W},I=dt;var ge=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,mcpProtocolVersion20260728:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1,mcpGatewaySpecCompliance:!1,mcpServerSpecCompliance:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,mcpProtocolVersion20260728:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1,mcpGatewaySpecCompliance:!1,mcpServerSpecCompliance:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,mcpProtocolVersion20260728:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1,mcpGatewaySpecCompliance:!1,mcpServerSpecCompliance:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,mcpProtocolVersion20260728:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1,mcpGatewaySpecCompliance:!1,mcpServerSpecCompliance:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,mcpProtocolVersion20260728:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1,mcpGatewaySpecCompliance:!1,mcpServerSpecCompliance:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0,escapeOpenApiPathCharacters:!0,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,mcpProtocolVersion20260728:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1,mcpGatewaySpecCompliance:!1,mcpServerSpecCompliance:!1},"2026-03-01":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0,escapeOpenApiPathCharacters:!0,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!0,return501ForUnsupportedHttpMethods:!0,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,mcpProtocolVersion20260728:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1,mcpGatewaySpecCompliance:!1,mcpServerSpecCompliance:!1},"2026-11-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0,escapeOpenApiPathCharacters:!0,delimitOpenApiPathParameters:!0,chainResponseSendingHooks:!0,return501ForUnsupportedHttpMethods:!0,improvedSchemaValidation:!0,serializeMcpParametersByStyle:!0,sanitizeMcpToolNames:!0,omitMcpFieldsNewerThanNegotiatedVersion:!0,treatBlankOptionalStringOptionsAsUnset:!0,mcpProtocolVersion20260728:!0,failMcpResourceReadsOnErrorStatus:!0,rejectInvalidMcpResourceUris:!0,mcpGatewaySpecCompliance:!0,mcpServerSpecCompliance:!0}});var me="2025-02-06";function _e(e={}){let{runtime:t="cloudflare"}=e;return new _({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:me,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:ge[me]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:t,__ZUPLO_AUTH_API_JWT:"",ZUPLO_SERVICE_BUCKET_ID:"bckt_mock"}})}r(_e,"getMockEnvironment");var gt=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function mt(e,t){let n=e.__ZUPLO_TRUSTED_IP_HEADER?.trim();if(!n)return t?v:K;if(!gt.test(n))throw new U(`__ZUPLO_TRUSTED_IP_HEADER is set to '${n}', which is not a valid HTTP header name. Header names may only contain the RFC 9110 token characters (letters, digits, and !#$%&'*+-.^_\`|~) - spaces, colons and tabs are not allowed. Set it to a valid header name such as '${v}' or 'cf-connecting-ip'.`);return n.toLowerCase()}r(mt,"resolveTrustedIpHeader");var _=class e{static{r(this,"Environment")}config;#n;static#e;static#t=!1;static initialize(t){e.#e||(e.#e=new e(t),e.#t=!0)}static get instance(){return e.#t||(I.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),e.#e??=_e(),e.#t=!0),e.#e}constructor({build:t,runtime:n}){let i;try{if(n.ZUPLO_SYSTEM_CONFIGURATIONS){let o=new TextDecoder().decode(le.decode(n.ZUPLO_SYSTEM_CONFIGURATIONS)),c=JSON.parse(o);for(let s of Object.keys(c))n[s]||(n[s]=c[s])}if(n.__ZUPLO_CONFIG){let o=atob(n.__ZUPLO_CONFIG);i=JSON.parse(o)}}catch(o){I.console.error("Failed to parse runtime configuration",o)}this.config=i??{},this.build=t,this.runtime=n,this.instanceId=crypto.randomUUID(),this.#n=mt(n,this.isCloudflare)}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get accountName(){return this.build.ACCOUNT_NAME??this.runtime.ZUPLO_ACCOUNT_NAME??void 0}get projectName(){return this.build.PROJECT_NAME??this.runtime.ZUPLO_PROJECT_NAME??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_service_routing??void 0}get useProxyForFetchFromZups(){return this.config.use_proxy_for_fetch_from_zups??void 0}get devPortalBaseUrl(){return this.runtime.__ZUPLO_DEV_PORTAL_URL??this.config.dev_portal_url??"https://dev-portal-v4-1.zuplo.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.runtime.__ZUPLO_EDGE_API_URL??this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuploedge.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.config.auth_client_id??this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.config.auth_client_secret??this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get authPublicKey(){return this.config.auth_public_key??this.runtime.__ZUPLO_AUTH_PUBLIC_KEY}get authPrivateKey(){return this.config.auth_private_key??this.runtime.__ZUPLO_AUTH_PRIVATE_KEY}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isManagedDedicated(){return this.runtime.__ZUPLO_IS_MANAGED_DEDICATED==="true"}get trustedIpHeader(){return this.#n}get isDeno(){if(this.runtime.__ZUPLO_RUNTIME_TYPE)return this.runtime.__ZUPLO_RUNTIME_TYPE==="deno";if(this.config.runtime_type)return this.config.runtime_type==="deno";{let t=globalThis.Deno?.version?.deno;return typeof WebSocketPair!="function"&&t}}get isLocalDevelopment(){return this.build.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}get budgetRulesCaptureDisabled(){return this.runtime.__ZUPLO_BUDGET_RULES_CAPTURE==="off"}get budgetDimensionLogValuesEnabled(){return this.runtime.__ZUPLO_BUDGET_DIMENSION_LOG_VALUES==="on"}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}get rateLimitServiceTimeoutMs(){let t=this.runtime.__ZUPLO_RATE_LIMIT_TIMEOUT_MS,n=this.config.rate_limit_service_timeout_ms,i=t??n;if(!i)return 500;let o=Number(i);return Number.isFinite(o)&&o>0?o:500}};export{U as a,N as b,A as c,J as d,ae as e,ht as f,Ee as g,he as h,Re as i,Rt as j,Ot as k,yt as l,Oe as m,ye as n,Ae as o,Se as p,Te as q,At as r,St as s,Tt as t,bt as u,Pt as v,Ct as w,Lt as x,xt as y,It as z,wt as A,K as B,be as C,Pe as D,Ce as E,Le as F,xe as G,Ie as H,we as I,Ue as J,Ne as K,Me as L,De as M,ve as N,He as O,ze as P,Fe as Q,Ze as R,Ut as S,H as T,Ve as U,ke as V,Nt as W,Mt as X,Dt as Y,vt as Z,Ht as _,_ as $,I as aa};
|
|
36
|
+
/*! For license information please see chunk-M4IZPJP6.js.LEGAL.txt */
|
|
37
|
+
//# sourceMappingURL=chunk-M4IZPJP6.js.map
|