@mcp-use/inspector 0.26.0-canary.2 → 0.26.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/dist/cdn/inspector.js +5 -5
- package/dist/client/components/ChatTab.d.ts +3 -1
- package/dist/client/components/ChatTab.d.ts.map +1 -1
- package/dist/client/index.js +31 -31
- package/dist/web/assets/{browser-B_LthXkF.js → browser-CqnU_bMs.js} +3 -3
- package/dist/web/assets/{chunk-K62RPXX3-m5T4bXFA.js → chunk-RJUJMGGE-Ckike6v2.js} +1 -1
- package/dist/web/assets/{chunk-RPN2XO5I-EMCV_H09.js → chunk-RPN2XO5I-BsQOpC8p.js} +1 -1
- package/dist/web/assets/{chunk_array-ol9zR_b5.js → chunk_array-Drzz3Bxj.js} +1 -1
- package/dist/web/assets/{client-SJRPCX3Q-CAgEsWul.js → client-2CASVELM-BYYvwD7E.js} +3 -3
- package/dist/web/assets/{client-q_D5_7Eq.js → client-CnWipjEl.js} +1 -1
- package/dist/web/assets/{dist-Bvkkc_bB.js → dist-CFOVbGE_.js} +1 -1
- package/dist/web/assets/{dist-BRe-es5a.js → dist-DXjAPY-W.js} +1 -1
- package/dist/web/assets/{dist-unGqErRO.js → dist-jBWD8iGG.js} +1 -1
- package/dist/web/assets/{function_calling-mTmlMu6F.js → function_calling-BLGGrcJY.js} +1 -1
- package/dist/web/assets/{index-DcdtRBRp.js → index-DnLjyl1f.js} +9 -9
- package/dist/web/assets/{llms-BOLUXqOP.js → llms-CUFNg0bG.js} +1 -1
- package/dist/web/assets/messages-D9QOZWGX.js +1 -0
- package/dist/web/assets/react-DDmrI2D-.js +1 -0
- package/dist/web/assets/{rpc-logger-TPNV75J4-ZVeT46IF.js → rpc-logger-TPNV75J4-DaBpv6Xr.js} +1 -1
- package/dist/web/assets/{stdio-RLVYPS7O-BhCCJZ3-.js → stdio-IOUVQROQ-CeewE_Ia.js} +1 -1
- package/dist/web/assets/{tools-DZuEEnb5.js → tools-Bn2uguc_.js} +1 -1
- package/dist/web/index.html +4 -4
- package/package.json +3 -3
- package/dist/web/assets/messages-DrWl8Wj3.js +0 -1
- package/dist/web/assets/react-LnMlWwhU.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./chunk-3GQAWCBQ-C-9Cm0Np.js";import{n as t}from"./chunk-QWQYAQCK-CyFuZlX8.js";import{I as n,_r as r}from"./json-schema-processors-DSIsU0go.js";import{F as i,N as a,P as o,_ as s,c,g as l,i as u,n as d,r as f,t as p}from"./client-q_D5_7Eq.js";import{S as m,a as ee,d as te,f as h,m as g,o as _,p as ne,s as v,t as re,v as y}from"./schemas-79owEkeD.js";var ie={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`},ae;(function(e){})(ae||={});function oe(e){return n(re,e)}function b(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function se(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{...b(t.headers),...b(r.headers)}:t.headers}):e}var ce=globalThis.crypto;async function le(e){return(await ce).getRandomValues(new Uint8Array(e))}async function ue(e){let t=``;for(;t.length<e;){let n=await le(e-t.length);for(let e of n)e<198&&(t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e%66])}return t}async function de(e){return await ue(e)}async function fe(e){let t=await(await ce).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function pe(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await de(e);return{code_verifier:t,code_challenge:await fe(t)}}var x=m().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:ie.custom,message:`URL must be parseable`,fatal:!0}),r}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),me=h({resource:y().url(),authorization_servers:_(x).optional(),jwks_uri:y().url().optional(),scopes_supported:_(y()).optional(),bearer_methods_supported:_(y()).optional(),resource_signing_alg_values_supported:_(y()).optional(),resource_name:y().optional(),resource_documentation:y().optional(),resource_policy_uri:y().url().optional(),resource_tos_uri:y().url().optional(),tls_client_certificate_bound_access_tokens:v().optional(),authorization_details_types_supported:_(y()).optional(),dpop_signing_alg_values_supported:_(y()).optional(),dpop_bound_access_tokens_required:v().optional()}),he=h({issuer:y(),authorization_endpoint:x,token_endpoint:x,registration_endpoint:x.optional(),scopes_supported:_(y()).optional(),response_types_supported:_(y()),response_modes_supported:_(y()).optional(),grant_types_supported:_(y()).optional(),token_endpoint_auth_methods_supported:_(y()).optional(),token_endpoint_auth_signing_alg_values_supported:_(y()).optional(),service_documentation:x.optional(),revocation_endpoint:x.optional(),revocation_endpoint_auth_methods_supported:_(y()).optional(),revocation_endpoint_auth_signing_alg_values_supported:_(y()).optional(),introspection_endpoint:y().optional(),introspection_endpoint_auth_methods_supported:_(y()).optional(),introspection_endpoint_auth_signing_alg_values_supported:_(y()).optional(),code_challenge_methods_supported:_(y()).optional(),client_id_metadata_document_supported:v().optional()}),ge=g({...h({issuer:y(),authorization_endpoint:x,token_endpoint:x,userinfo_endpoint:x.optional(),jwks_uri:x,registration_endpoint:x.optional(),scopes_supported:_(y()).optional(),response_types_supported:_(y()),response_modes_supported:_(y()).optional(),grant_types_supported:_(y()).optional(),acr_values_supported:_(y()).optional(),subject_types_supported:_(y()),id_token_signing_alg_values_supported:_(y()),id_token_encryption_alg_values_supported:_(y()).optional(),id_token_encryption_enc_values_supported:_(y()).optional(),userinfo_signing_alg_values_supported:_(y()).optional(),userinfo_encryption_alg_values_supported:_(y()).optional(),userinfo_encryption_enc_values_supported:_(y()).optional(),request_object_signing_alg_values_supported:_(y()).optional(),request_object_encryption_alg_values_supported:_(y()).optional(),request_object_encryption_enc_values_supported:_(y()).optional(),token_endpoint_auth_methods_supported:_(y()).optional(),token_endpoint_auth_signing_alg_values_supported:_(y()).optional(),display_values_supported:_(y()).optional(),claim_types_supported:_(y()).optional(),claims_supported:_(y()).optional(),service_documentation:y().optional(),claims_locales_supported:_(y()).optional(),ui_locales_supported:_(y()).optional(),claims_parameter_supported:v().optional(),request_parameter_supported:v().optional(),request_uri_parameter_supported:v().optional(),require_request_uri_registration:v().optional(),op_policy_uri:x.optional(),op_tos_uri:x.optional(),client_id_metadata_document_supported:v().optional()}).shape,...he.pick({code_challenge_methods_supported:!0}).shape}),_e=g({access_token:y(),id_token:y().optional(),token_type:y(),expires_in:oe().optional(),scope:y().optional(),refresh_token:y().optional()}).strip(),ve=g({error:y(),error_description:y().optional(),error_uri:y().optional()}),ye=x.optional().or(te(``).transform(()=>void 0)),be=g({redirect_uris:_(x),token_endpoint_auth_method:y().optional(),grant_types:_(y()).optional(),response_types:_(y()).optional(),client_name:y().optional(),client_uri:x.optional(),logo_uri:ye,scope:y().optional(),contacts:_(y()).optional(),tos_uri:ye,policy_uri:y().optional(),jwks_uri:x.optional(),jwks:ee().optional(),software_id:y().optional(),software_version:y().optional(),software_statement:y().optional()}).strip(),xe=g({client_id:y(),client_secret:y().optional(),client_id_issued_at:ne().optional(),client_secret_expires_at:ne().optional()}).strip(),Se=be.merge(xe);g({error:y(),error_description:y().optional()}).strip(),g({token:y(),token_type_hint:y().optional()}).strip();function Ce(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function we({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var S=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Te=class extends S{};Te.errorCode=`invalid_request`;var C=class extends S{};C.errorCode=`invalid_client`;var w=class extends S{};w.errorCode=`invalid_grant`;var T=class extends S{};T.errorCode=`unauthorized_client`;var Ee=class extends S{};Ee.errorCode=`unsupported_grant_type`;var De=class extends S{};De.errorCode=`invalid_scope`;var E=class extends S{};E.errorCode=`access_denied`;var D=class extends S{};D.errorCode=`server_error`;var Oe=class extends S{};Oe.errorCode=`temporarily_unavailable`;var ke=class extends S{};ke.errorCode=`unsupported_response_type`;var Ae=class extends S{};Ae.errorCode=`unsupported_token_type`;var je=class extends S{};je.errorCode=`invalid_token`;var Me=class extends S{};Me.errorCode=`method_not_allowed`;var Ne=class extends S{};Ne.errorCode=`too_many_requests`;var O=class extends S{};O.errorCode=`invalid_client_metadata`;var Pe=class extends S{};Pe.errorCode=`insufficient_scope`;var Fe=class extends S{};Fe.errorCode=`invalid_target`;var Ie={[Te.errorCode]:Te,[C.errorCode]:C,[w.errorCode]:w,[T.errorCode]:T,[Ee.errorCode]:Ee,[De.errorCode]:De,[E.errorCode]:E,[D.errorCode]:D,[Oe.errorCode]:Oe,[ke.errorCode]:ke,[Ae.errorCode]:Ae,[je.errorCode]:je,[Me.errorCode]:Me,[Ne.errorCode]:Ne,[O.errorCode]:O,[Pe.errorCode]:Pe,[Fe.errorCode]:Fe},k=class extends Error{constructor(e){super(e??`Unauthorized`)}};function Le(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}var Re=`code`,ze=`S256`;function Be(e,t){let n=e.client_secret!==void 0;return t.length===0?n?`client_secret_post`:`none`:`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&Le(e.token_endpoint_auth_method)&&t.includes(e.token_endpoint_auth_method)?e.token_endpoint_auth_method:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function Ve(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:He(i,a,n);return;case`client_secret_post`:Ue(i,a,r);return;case`none`:We(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function He(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function Ue(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function We(e,t){t.set(`client_id`,e)}async function Ge(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=ve.parse(JSON.parse(n));return new(Ie[e]||D)(t||``,r)}catch(e){return new D(`${t?`HTTP ${t}: `:``}Invalid OAuth error response: ${e}. Raw body: ${n}`)}}async function A(e,t){try{return await Ke(e,t)}catch(n){if(n instanceof C||n instanceof T)return await e.invalidateCredentials?.(`all`),await Ke(e,t);if(n instanceof w)return await e.invalidateCredentials?.(`tokens`),await Ke(e,t);throw n}}async function Ke(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o=await e.discoveryState?.(),s,c,l,u=i;if(!u&&o?.resourceMetadataUrl&&(u=new URL(o.resourceMetadataUrl)),o?.authorizationServerUrl){if(c=o.authorizationServerUrl,s=o.resourceMetadata,l=o.authorizationServerMetadata??await rt(c,{fetchFn:a}),!s)try{s=await Xe(t,{resourceMetadataUrl:u},a)}catch{}(l!==o.authorizationServerMetadata||s!==o.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}else{let n=await it(t,{resourceMetadataUrl:u,fetchFn:a});c=n.authorizationServerUrl,l=n.authorizationServerMetadata,s=n.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}let d=await Je(t,e,s),f=await Promise.resolve(e.clientInformation());if(!f){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);let t=l?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!qe(r))throw new O(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)f={client_id:r},await e.saveClientInformation?.(f);else{if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);let t=await ut(c,{metadata:l,clientMetadata:e.clientMetadata,fetchFn:a});await e.saveClientInformation(t),f=t}}let p=!e.redirectUrl;if(n!==void 0||p){let t=await lt(e,c,{metadata:l,resource:d,authorizationCode:n,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}let m=await e.tokens();if(m?.refresh_token)try{let t=await ct(c,{metadata:l,clientInformation:f,refreshToken:m.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}catch(e){if(!(!(e instanceof S)||e instanceof D))throw e}let ee=e.state?await e.state():void 0,{authorizationUrl:te,codeVerifier:h}=await at(c,{metadata:l,clientInformation:f,state:ee,redirectUrl:e.redirectUrl,scope:r||s?.scopes_supported?.join(` `)||e.clientMetadata.scope,resource:d});return await e.saveCodeVerifier(h),await e.redirectToAuthorization(te),`REDIRECT`}function qe(e){if(!e)return!1;try{let t=new URL(e);return t.protocol===`https:`&&t.pathname!==`/`}catch{return!1}}async function Je(e,t,n){let r=Ce(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!we({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function j(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return{};let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return{};let i=Ye(e,`resource_metadata`)||void 0,a;if(i)try{a=new URL(i)}catch{}let o=Ye(e,`scope`)||void 0,s=Ye(e,`error`)||void 0;return{resourceMetadataUrl:a,scope:o,error:s}}function Ye(e,t){let n=e.headers.get(`WWW-Authenticate`);if(!n)return null;let r=RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),i=n.match(r);return i?i[1]||i[2]:null}async function Xe(e,t,n=fetch){let r=await tt(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.body?.cancel(),Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw await r.body?.cancel(),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return me.parse(await r.json())}async function Ze(e,t,n=fetch){try{return await n(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?Ze(e,void 0,n):void 0;throw r}}function Qe(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function $e(e,t,n=fetch){return await Ze(e,{"MCP-Protocol-Version":t},n)}function et(e,t){return!e||e.status>=400&&e.status<500&&t!==`/`}async function tt(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??`2025-11-25`,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=Qe(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await $e(o,a,n);return!r?.metadataUrl&&et(s,i.pathname)&&(s=await $e(new URL(`/.well-known/${t}`,i),a,n)),s}function nt(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function rt(e,{fetchFn:t=fetch,protocolVersion:n=s}={}){let r={"MCP-Protocol-Version":n,Accept:`application/json`},i=nt(e);for(let{url:e,type:n}of i){let i=await Ze(e,r,t);if(i){if(!i.ok){if(await i.body?.cancel(),i.status>=400&&i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?he.parse(await i.json()):ge.parse(await i.json())}}}async function it(e,t){let n,r;try{n=await Xe(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),n.authorization_servers&&n.authorization_servers.length>0&&(r=n.authorization_servers[0])}catch{}r||=String(new URL(`/`,e));let i=await rt(r,{fetchFn:t?.fetchFn});return{authorizationServerUrl:r,authorizationServerMetadata:i,resourceMetadata:n}}async function at(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(Re))throw Error(`Incompatible auth server: does not support response type ${Re}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(ze))throw Error(`Incompatible auth server: does not support code challenge method ${ze}`)}else s=new URL(`/authorize`,e);let c=await pe(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,Re),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,ze),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,o.href),{authorizationUrl:s,codeVerifier:l}}function ot(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function st(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=t?.token_endpoint?new URL(t.token_endpoint):new URL(`/token`,e),c=new Headers({"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`});a&&n.set(`resource`,a.href),i?await i(c,n,s,t):r&&Ve(Be(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await Ge(l);return _e.parse(await l.json())}async function ct(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await st(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}async function lt(e,t,{metadata:n,resource:r,authorizationCode:i,fetchFn:a}={}){let o=e.clientMetadata.scope,s;if(e.prepareTokenRequest&&(s=await e.prepareTokenRequest(o)),!s){if(!i)throw Error(`Either provider.prepareTokenRequest() or authorizationCode is required`);if(!e.redirectUrl)throw Error(`redirectUrl is required for authorization_code flow`);s=ot(i,await e.codeVerifier(),e.redirectUrl)}let c=await e.clientInformation();return st(t,{metadata:n,tokenRequestParams:s,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:a})}async function ut(e,{metadata:t,clientMetadata:n,fetchFn:r}){let i;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);i=new URL(t.registration_endpoint)}else i=new URL(`/register`,e);let a=await(r??fetch)(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!a.ok)throw await Ge(a);return Se.parse(await a.json())}var dt=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function ft(e){}function pt(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=ft,onError:n=ft,onRetry:r=ft,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=mt(`${a}${t}`);for(let e of n)d(e);a=r,o=!1}function d(e){if(e===``){p();return}if(e.startsWith(`:`)){i&&i(e.slice(e.startsWith(`: `)?2:1));return}let t=e.indexOf(`:`);if(t!==-1){let n=e.slice(0,t),r=e[t+1]===` `?2:1;f(n,e.slice(t+r),e);return}f(e,``,e)}function f(e,t,i){switch(e){case`event`:l=t;break;case`data`:c=`${c}${t}
|
|
1
|
+
import{t as e}from"./chunk-3GQAWCBQ-C-9Cm0Np.js";import{n as t}from"./chunk-QWQYAQCK-CyFuZlX8.js";import{I as n,_r as r}from"./json-schema-processors-DSIsU0go.js";import{F as i,N as a,P as o,_ as s,c,g as l,i as u,n as d,r as f,t as p}from"./client-CnWipjEl.js";import{S as m,a as ee,d as te,f as h,m as g,o as _,p as ne,s as v,t as re,v as y}from"./schemas-79owEkeD.js";var ie={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`},ae;(function(e){})(ae||={});function oe(e){return n(re,e)}function b(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function se(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{...b(t.headers),...b(r.headers)}:t.headers}):e}var ce=globalThis.crypto;async function le(e){return(await ce).getRandomValues(new Uint8Array(e))}async function ue(e){let t=``;for(;t.length<e;){let n=await le(e-t.length);for(let e of n)e<198&&(t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e%66])}return t}async function de(e){return await ue(e)}async function fe(e){let t=await(await ce).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function pe(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await de(e);return{code_verifier:t,code_challenge:await fe(t)}}var x=m().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:ie.custom,message:`URL must be parseable`,fatal:!0}),r}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),me=h({resource:y().url(),authorization_servers:_(x).optional(),jwks_uri:y().url().optional(),scopes_supported:_(y()).optional(),bearer_methods_supported:_(y()).optional(),resource_signing_alg_values_supported:_(y()).optional(),resource_name:y().optional(),resource_documentation:y().optional(),resource_policy_uri:y().url().optional(),resource_tos_uri:y().url().optional(),tls_client_certificate_bound_access_tokens:v().optional(),authorization_details_types_supported:_(y()).optional(),dpop_signing_alg_values_supported:_(y()).optional(),dpop_bound_access_tokens_required:v().optional()}),he=h({issuer:y(),authorization_endpoint:x,token_endpoint:x,registration_endpoint:x.optional(),scopes_supported:_(y()).optional(),response_types_supported:_(y()),response_modes_supported:_(y()).optional(),grant_types_supported:_(y()).optional(),token_endpoint_auth_methods_supported:_(y()).optional(),token_endpoint_auth_signing_alg_values_supported:_(y()).optional(),service_documentation:x.optional(),revocation_endpoint:x.optional(),revocation_endpoint_auth_methods_supported:_(y()).optional(),revocation_endpoint_auth_signing_alg_values_supported:_(y()).optional(),introspection_endpoint:y().optional(),introspection_endpoint_auth_methods_supported:_(y()).optional(),introspection_endpoint_auth_signing_alg_values_supported:_(y()).optional(),code_challenge_methods_supported:_(y()).optional(),client_id_metadata_document_supported:v().optional()}),ge=g({...h({issuer:y(),authorization_endpoint:x,token_endpoint:x,userinfo_endpoint:x.optional(),jwks_uri:x,registration_endpoint:x.optional(),scopes_supported:_(y()).optional(),response_types_supported:_(y()),response_modes_supported:_(y()).optional(),grant_types_supported:_(y()).optional(),acr_values_supported:_(y()).optional(),subject_types_supported:_(y()),id_token_signing_alg_values_supported:_(y()),id_token_encryption_alg_values_supported:_(y()).optional(),id_token_encryption_enc_values_supported:_(y()).optional(),userinfo_signing_alg_values_supported:_(y()).optional(),userinfo_encryption_alg_values_supported:_(y()).optional(),userinfo_encryption_enc_values_supported:_(y()).optional(),request_object_signing_alg_values_supported:_(y()).optional(),request_object_encryption_alg_values_supported:_(y()).optional(),request_object_encryption_enc_values_supported:_(y()).optional(),token_endpoint_auth_methods_supported:_(y()).optional(),token_endpoint_auth_signing_alg_values_supported:_(y()).optional(),display_values_supported:_(y()).optional(),claim_types_supported:_(y()).optional(),claims_supported:_(y()).optional(),service_documentation:y().optional(),claims_locales_supported:_(y()).optional(),ui_locales_supported:_(y()).optional(),claims_parameter_supported:v().optional(),request_parameter_supported:v().optional(),request_uri_parameter_supported:v().optional(),require_request_uri_registration:v().optional(),op_policy_uri:x.optional(),op_tos_uri:x.optional(),client_id_metadata_document_supported:v().optional()}).shape,...he.pick({code_challenge_methods_supported:!0}).shape}),_e=g({access_token:y(),id_token:y().optional(),token_type:y(),expires_in:oe().optional(),scope:y().optional(),refresh_token:y().optional()}).strip(),ve=g({error:y(),error_description:y().optional(),error_uri:y().optional()}),ye=x.optional().or(te(``).transform(()=>void 0)),be=g({redirect_uris:_(x),token_endpoint_auth_method:y().optional(),grant_types:_(y()).optional(),response_types:_(y()).optional(),client_name:y().optional(),client_uri:x.optional(),logo_uri:ye,scope:y().optional(),contacts:_(y()).optional(),tos_uri:ye,policy_uri:y().optional(),jwks_uri:x.optional(),jwks:ee().optional(),software_id:y().optional(),software_version:y().optional(),software_statement:y().optional()}).strip(),xe=g({client_id:y(),client_secret:y().optional(),client_id_issued_at:ne().optional(),client_secret_expires_at:ne().optional()}).strip(),Se=be.merge(xe);g({error:y(),error_description:y().optional()}).strip(),g({token:y(),token_type_hint:y().optional()}).strip();function Ce(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function we({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var S=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Te=class extends S{};Te.errorCode=`invalid_request`;var C=class extends S{};C.errorCode=`invalid_client`;var w=class extends S{};w.errorCode=`invalid_grant`;var T=class extends S{};T.errorCode=`unauthorized_client`;var Ee=class extends S{};Ee.errorCode=`unsupported_grant_type`;var De=class extends S{};De.errorCode=`invalid_scope`;var E=class extends S{};E.errorCode=`access_denied`;var D=class extends S{};D.errorCode=`server_error`;var Oe=class extends S{};Oe.errorCode=`temporarily_unavailable`;var ke=class extends S{};ke.errorCode=`unsupported_response_type`;var Ae=class extends S{};Ae.errorCode=`unsupported_token_type`;var je=class extends S{};je.errorCode=`invalid_token`;var Me=class extends S{};Me.errorCode=`method_not_allowed`;var Ne=class extends S{};Ne.errorCode=`too_many_requests`;var O=class extends S{};O.errorCode=`invalid_client_metadata`;var Pe=class extends S{};Pe.errorCode=`insufficient_scope`;var Fe=class extends S{};Fe.errorCode=`invalid_target`;var Ie={[Te.errorCode]:Te,[C.errorCode]:C,[w.errorCode]:w,[T.errorCode]:T,[Ee.errorCode]:Ee,[De.errorCode]:De,[E.errorCode]:E,[D.errorCode]:D,[Oe.errorCode]:Oe,[ke.errorCode]:ke,[Ae.errorCode]:Ae,[je.errorCode]:je,[Me.errorCode]:Me,[Ne.errorCode]:Ne,[O.errorCode]:O,[Pe.errorCode]:Pe,[Fe.errorCode]:Fe},k=class extends Error{constructor(e){super(e??`Unauthorized`)}};function Le(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}var Re=`code`,ze=`S256`;function Be(e,t){let n=e.client_secret!==void 0;return t.length===0?n?`client_secret_post`:`none`:`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&Le(e.token_endpoint_auth_method)&&t.includes(e.token_endpoint_auth_method)?e.token_endpoint_auth_method:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function Ve(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:He(i,a,n);return;case`client_secret_post`:Ue(i,a,r);return;case`none`:We(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function He(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function Ue(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function We(e,t){t.set(`client_id`,e)}async function Ge(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=ve.parse(JSON.parse(n));return new(Ie[e]||D)(t||``,r)}catch(e){return new D(`${t?`HTTP ${t}: `:``}Invalid OAuth error response: ${e}. Raw body: ${n}`)}}async function A(e,t){try{return await Ke(e,t)}catch(n){if(n instanceof C||n instanceof T)return await e.invalidateCredentials?.(`all`),await Ke(e,t);if(n instanceof w)return await e.invalidateCredentials?.(`tokens`),await Ke(e,t);throw n}}async function Ke(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o=await e.discoveryState?.(),s,c,l,u=i;if(!u&&o?.resourceMetadataUrl&&(u=new URL(o.resourceMetadataUrl)),o?.authorizationServerUrl){if(c=o.authorizationServerUrl,s=o.resourceMetadata,l=o.authorizationServerMetadata??await rt(c,{fetchFn:a}),!s)try{s=await Xe(t,{resourceMetadataUrl:u},a)}catch{}(l!==o.authorizationServerMetadata||s!==o.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}else{let n=await it(t,{resourceMetadataUrl:u,fetchFn:a});c=n.authorizationServerUrl,l=n.authorizationServerMetadata,s=n.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}let d=await Je(t,e,s),f=await Promise.resolve(e.clientInformation());if(!f){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);let t=l?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!qe(r))throw new O(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)f={client_id:r},await e.saveClientInformation?.(f);else{if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);let t=await ut(c,{metadata:l,clientMetadata:e.clientMetadata,fetchFn:a});await e.saveClientInformation(t),f=t}}let p=!e.redirectUrl;if(n!==void 0||p){let t=await lt(e,c,{metadata:l,resource:d,authorizationCode:n,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}let m=await e.tokens();if(m?.refresh_token)try{let t=await ct(c,{metadata:l,clientInformation:f,refreshToken:m.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}catch(e){if(!(!(e instanceof S)||e instanceof D))throw e}let ee=e.state?await e.state():void 0,{authorizationUrl:te,codeVerifier:h}=await at(c,{metadata:l,clientInformation:f,state:ee,redirectUrl:e.redirectUrl,scope:r||s?.scopes_supported?.join(` `)||e.clientMetadata.scope,resource:d});return await e.saveCodeVerifier(h),await e.redirectToAuthorization(te),`REDIRECT`}function qe(e){if(!e)return!1;try{let t=new URL(e);return t.protocol===`https:`&&t.pathname!==`/`}catch{return!1}}async function Je(e,t,n){let r=Ce(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!we({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function j(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return{};let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return{};let i=Ye(e,`resource_metadata`)||void 0,a;if(i)try{a=new URL(i)}catch{}let o=Ye(e,`scope`)||void 0,s=Ye(e,`error`)||void 0;return{resourceMetadataUrl:a,scope:o,error:s}}function Ye(e,t){let n=e.headers.get(`WWW-Authenticate`);if(!n)return null;let r=RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),i=n.match(r);return i?i[1]||i[2]:null}async function Xe(e,t,n=fetch){let r=await tt(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.body?.cancel(),Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw await r.body?.cancel(),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return me.parse(await r.json())}async function Ze(e,t,n=fetch){try{return await n(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?Ze(e,void 0,n):void 0;throw r}}function Qe(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function $e(e,t,n=fetch){return await Ze(e,{"MCP-Protocol-Version":t},n)}function et(e,t){return!e||e.status>=400&&e.status<500&&t!==`/`}async function tt(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??`2025-11-25`,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=Qe(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await $e(o,a,n);return!r?.metadataUrl&&et(s,i.pathname)&&(s=await $e(new URL(`/.well-known/${t}`,i),a,n)),s}function nt(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function rt(e,{fetchFn:t=fetch,protocolVersion:n=s}={}){let r={"MCP-Protocol-Version":n,Accept:`application/json`},i=nt(e);for(let{url:e,type:n}of i){let i=await Ze(e,r,t);if(i){if(!i.ok){if(await i.body?.cancel(),i.status>=400&&i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?he.parse(await i.json()):ge.parse(await i.json())}}}async function it(e,t){let n,r;try{n=await Xe(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),n.authorization_servers&&n.authorization_servers.length>0&&(r=n.authorization_servers[0])}catch{}r||=String(new URL(`/`,e));let i=await rt(r,{fetchFn:t?.fetchFn});return{authorizationServerUrl:r,authorizationServerMetadata:i,resourceMetadata:n}}async function at(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(Re))throw Error(`Incompatible auth server: does not support response type ${Re}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(ze))throw Error(`Incompatible auth server: does not support code challenge method ${ze}`)}else s=new URL(`/authorize`,e);let c=await pe(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,Re),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,ze),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,o.href),{authorizationUrl:s,codeVerifier:l}}function ot(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function st(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=t?.token_endpoint?new URL(t.token_endpoint):new URL(`/token`,e),c=new Headers({"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`});a&&n.set(`resource`,a.href),i?await i(c,n,s,t):r&&Ve(Be(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await Ge(l);return _e.parse(await l.json())}async function ct(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await st(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}async function lt(e,t,{metadata:n,resource:r,authorizationCode:i,fetchFn:a}={}){let o=e.clientMetadata.scope,s;if(e.prepareTokenRequest&&(s=await e.prepareTokenRequest(o)),!s){if(!i)throw Error(`Either provider.prepareTokenRequest() or authorizationCode is required`);if(!e.redirectUrl)throw Error(`redirectUrl is required for authorization_code flow`);s=ot(i,await e.codeVerifier(),e.redirectUrl)}let c=await e.clientInformation();return st(t,{metadata:n,tokenRequestParams:s,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:a})}async function ut(e,{metadata:t,clientMetadata:n,fetchFn:r}){let i;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);i=new URL(t.registration_endpoint)}else i=new URL(`/register`,e);let a=await(r??fetch)(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!a.ok)throw await Ge(a);return Se.parse(await a.json())}var dt=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function ft(e){}function pt(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=ft,onError:n=ft,onRetry:r=ft,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=mt(`${a}${t}`);for(let e of n)d(e);a=r,o=!1}function d(e){if(e===``){p();return}if(e.startsWith(`:`)){i&&i(e.slice(e.startsWith(`: `)?2:1));return}let t=e.indexOf(`:`);if(t!==-1){let n=e.slice(0,t),r=e[t+1]===` `?2:1;f(n,e.slice(t+r),e);return}f(e,``,e)}function f(e,t,i){switch(e){case`event`:l=t;break;case`data`:c=`${c}${t}
|
|
2
2
|
`;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new dt(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new dt(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function p(){c.length>0&&t({id:s,event:l||void 0,data:c.endsWith(`
|
|
3
3
|
`)?c.slice(0,-1):c}),s=void 0,c=``,l=``}function m(e={}){a&&e.consume&&d(a),o=!0,s=void 0,c=``,l=``,a=``}return{feed:u,reset:m}}function mt(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`\r`,r),a=e.indexOf(`
|
|
4
4
|
`,r),o=-1;if(i!==-1&&a!==-1?o=Math.min(i,a):i===-1?a!==-1&&(o=a):o=i===e.length-1?-1:i,o===-1){n=e.slice(r);break}else{let n=e.slice(r,o);t.push(n),r=o+1,e[r-1]===`\r`&&e[r]===`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./chunk-3GQAWCBQ-C-9Cm0Np.js";import{_ as t,a as n,b as r,i,m as a,o,p as s,s as c,v as l}from"./schemas-79owEkeD.js";import{f as u}from"./chunk-
|
|
1
|
+
import{t as e}from"./chunk-3GQAWCBQ-C-9Cm0Np.js";import{_ as t,a as n,b as r,i,m as a,o,p as s,s as c,v as l}from"./schemas-79owEkeD.js";import{f as u}from"./chunk-RJUJMGGE-Ckike6v2.js";var d=class{static{e(this,`JSONSchemaToZod`)}static convert(e){return this.parseSchema(e)}static matchesCondition(e,t){if(!t.properties)return!0;if(typeof e!=`object`||!e||Array.isArray(e))return!1;let n=e;for(let[e,r]of Object.entries(t.properties)){if(!(e in n)){if(`const`in r)return!1;continue}let t=n[e];if(`const`in r&&t!==r.const||`minimum`in r&&typeof t==`number`&&t<r.minimum||`maximum`in r&&typeof t==`number`&&t>r.maximum)return!1}return!0}static validateConditionalSchema(e,t,n){this.validateRequiredProperties(e,t,n),this.validatePropertyPatterns(e,t,n),this.validateNestedConditions(e,t,n)}static validateRequiredProperties(e,t,n){if(t.required){if(typeof e!=`object`||!e){for(let e of t.required)n.addIssue({code:u.custom,message:`Required property '${e}' is missing`,path:[e]});return}for(let r of t.required)r in e||n.addIssue({code:u.custom,message:`Required property '${r}' is missing`,path:[r]})}}static validatePropertyPatterns(e,t,n){if(!t.properties||typeof e!=`object`||!e||Array.isArray(e))return;let r=e;for(let[e,i]of Object.entries(t.properties)){if(!(e in r))continue;let t=r[e];i.pattern&&typeof t==`string`&&(new RegExp(i.pattern).test(t)||n.addIssue({code:u.custom,message:`String '${t}' does not match pattern '${i.pattern}'`,path:[e]}))}}static validateNestedConditions(e,t,n){!t.if||!t.then||(this.matchesCondition(e,t.if)?this.validateConditionalSchema(e,t.then,n):t.else&&this.validateConditionalSchema(e,t.else,n))}static parseSchema(e){let t;return t=Array.isArray(e.type)?this.handleTypeArray(e):e.oneOf||e.anyOf||e.allOf?this.parseCombinator(e):e.if&&e.then||e.properties&&(!e.type||e.type===`object`)?this.parseObject(e):this.handleSingleType(e),e.description&&typeof t.describe==`function`&&(t=t.describe(e.description)),t}static handleTypeArray(e){if(!Array.isArray(e.type))throw Error(`Expected schema.type to be an array`);return e.type.includes(`null`)?this.handleNullableType(e):this.createUnionFromTypes(e.type,e)}static handleNullableType(e){if(!Array.isArray(e.type))throw Error(`Expected schema.type to be an array`);let t={...e};return t.type=e.type.filter(e=>e!==`null`),t.type.length===1?this.handleSingleType({...e,type:t.type[0]}).nullable():this.parseSchema(t).nullable()}static createUnionFromTypes(e,t){return r(e.map(e=>{let n={...t,type:e};return this.parseSchema(n)}))}static handleSingleType(e){if(e.type===void 0)return e.oneOf||e.anyOf||e.allOf?this.parseCombinator(e):e.properties?this.parseObject(e):n();switch(e.type){case`string`:return this.parseString(e);case`number`:case`integer`:return this.parseNumberSchema(e);case`boolean`:return c();case`array`:return this.parseArray(e);case`object`:return this.parseObject(e);default:throw Error(`Unsupported schema type`)}}static parseNumberSchema(e){let t=s(),n=t;return n=this.applyNumberBounds(t,e),n=this.applyNumberMultipleOf(t,e),n=this.applyNumberEnum(t,e),n=this.applyIntegerConstraint(t,e),n}static applyNumberBounds(e,t){let n=e;return t.minimum!==void 0&&(n=t.exclusiveMinimum?n.gt(t.minimum):n.gte(t.minimum)),t.maximum!==void 0&&(n=t.exclusiveMaximum?n.lt(t.maximum):n.lte(t.maximum)),n}static applyNumberMultipleOf(e,t){return t.multipleOf===void 0?e:e.refine(e=>e%t.multipleOf===0,{message:`Number must be a multiple of ${t.multipleOf}`})}static applyNumberEnum(e,t){if(!t.enum)return e;let n=t.enum.filter(e=>typeof e==`number`);return n.length===0?e:e.refine(e=>n.includes(e),{message:`Number must be one of: ${n.join(`, `)}`})}static applyIntegerConstraint(e,t){return t.type===`integer`?e.refine(e=>Number.isInteger(e),{message:`Number must be an integer`}):e}static parseString(e){let t=l(),n=t;return e.format?this.applyStringFormat(t,e):(n=this.applyStringPattern(t,e),n=this.applyStringLength(t,e),n=this.applyStringEnum(t,e),n)}static applyStringFormat(e,t){if(!t.format)return e;switch(t.format){case`email`:return e.email();case`date-time`:return e.datetime();case`uri`:return e.url();case`uuid`:return e.uuid();case`date`:return e.date();default:return e}}static applyStringPattern(e,t){if(!t.pattern)return e;let n=new RegExp(t.pattern);return e.regex(n,{message:`String must match pattern: ${t.pattern}`})}static applyStringLength(e,t){let n=e;return t.minLength!==void 0&&(e=e.min(t.minLength)),t.maxLength!==void 0&&(e=e.max(t.maxLength)),n}static applyStringEnum(e,t){return t.enum?e.refine(e=>t.enum?.includes(e),{message:`Value must be one of: ${t.enum?.join(`, `)}`}):e}static parseArray(e){if(Array.isArray(e.items))return r(e.items.map(e=>this.parseSchema(e)));let t=o(e.items?this.parseSchema(e.items):n()),i=t;return i=this.applyArrayConstraints(t,e),i}static applyArrayConstraints(e,t){return t.minItems!==void 0&&(e=e.min(t.minItems)),t.maxItems!==void 0&&(e=e.max(t.maxItems)),t.uniqueItems?e.refine(e=>new Set(e).size===e.length,{message:`Array items must be unique`}):e}static parseObject(e){if(e.if&&e.then)return this.parseConditional(e);if(!e.properties&&e.additionalProperties&&typeof e.additionalProperties==`object`){let n=this.parseSchema(e.additionalProperties);return t(l(),n)}let n={};return this.processObjectProperties(e,n),this.processAdditionalProperties(e,a(n))}static processObjectProperties(e,t){let n=new Set(e.required||[]);if(e.properties)for(let[r,i]of Object.entries(e.properties)){let e=this.parseSchema(i);t[r]=n.has(r)?e:e.optional()}}static processAdditionalProperties(e,t){if(e.additionalProperties===!0)return t.passthrough();if(e.additionalProperties&&typeof e.additionalProperties==`object`){let n=this.parseSchema(e.additionalProperties);return t.catchall(n)}else return t.strict()}static parseConditional(e){let t=this.createBaseObjectSchema(e),n=e.if,r=e.then,i=e.else;return t.superRefine((t,a)=>{let o=this.applyDefaultValues(t,e);this.matchesCondition(o,n)?this.validateConditionalSchema(o,r,a):i&&this.validateConditionalSchema(o,i,a)})}static createBaseObjectSchema(e){let t={},n=new Set(e.required||[]);for(let[r,i]of Object.entries(e.properties||{})){let e=this.parseSchema(i);t[r]=n.has(r)?e:e.optional()}let r=a(t);return this.processAdditionalProperties(e,r)}static applyDefaultValues(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return e;let n={...e};if(!t.properties)return n;for(let[e,r]of Object.entries(t.properties))!(e in n)&&`default`in r&&(n[e]=r.default);return n}static parseCombinator(e){if(e.oneOf)return this.parseOneOf(e.oneOf);if(e.anyOf)return this.parseAnyOf(e.anyOf);if(e.allOf)return this.parseAllOf(e.allOf);throw Error(`Unsupported schema type`)}static parseOneOf(e){return this.createUnionFromSchemas(e)}static parseAnyOf(e){return this.createUnionFromSchemas(e)}static createUnionFromSchemas(e){if(e.length===0)return n();if(e.length===1)return this.parseSchema(e[0]);let t=[];for(let n of e)n.type===`null`?t.push(i()):t.push(this.parseSchema(n));return t.length>=2?r(t):t.length===1?t[0]:n()}static parseAllOf(e){if(e.length===0)return n();if(e.length===1)return this.parseSchema(e[0]);let t=e.reduce((e,t)=>this.mergeSchemas(e,t));return this.parseSchema(t)}static mergeSchemas(e,t){let n={...e,...t};return e.properties&&t.properties&&(n.properties={...e.properties,...t.properties}),e.required&&t.required&&(n.required=[...new Set([...e.required,...t.required])]),n}};export{d as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{it as e,mr as t}from"./index-
|
|
1
|
+
import{it as e,mr as t}from"./index-DnLjyl1f.js";var n={};t(n,{Embeddings:()=>r});var r=class{caller;constructor(t){this.caller=new e(t??{})}},i={};t(i,{chunkArray:()=>a});var a=(e,t)=>e.reduce((e,n,r)=>{let i=Math.floor(r/t);return e[i]=(e[i]||[]).concat([n]),e},[]);export{r as n,n as r,i as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/stdio-
|
|
2
|
-
import{n as e,t}from"./chunk-3GQAWCBQ-C-9Cm0Np.js";import{n}from"./chunk-QWQYAQCK-CyFuZlX8.js";import{c as r,i,n as a}from"./client-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/stdio-IOUVQROQ-CeewE_Ia.js","assets/chunk-zsgVPwQN.js","assets/client-CnWipjEl.js","assets/preload-helper-XLr9-hSf.js","assets/schemas-79owEkeD.js","assets/json-schema-processors-DSIsU0go.js","assets/chunk-3GQAWCBQ-C-9Cm0Np.js","assets/chunk-QWQYAQCK-CyFuZlX8.js","assets/path-BzTN_bR6.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e,t}from"./chunk-3GQAWCBQ-C-9Cm0Np.js";import{n}from"./chunk-QWQYAQCK-CyFuZlX8.js";import{c as r,i,n as a}from"./client-CnWipjEl.js";import{a as o,i as s,o as c,r as l,t as u}from"./chunk-RJUJMGGE-Ckike6v2.js";import{t as d}from"./preload-helper-XLr9-hSf.js";import{t as f}from"./chunk-RPN2XO5I-BsQOpC8p.js";import{i as p,n as m,o as h,t as g}from"./path-BzTN_bR6.js";h(),g();var _=class{static{t(this,`BaseCodeExecutor`)}client;_connecting=!1;constructor(e){this.client=e}async ensureServersConnected(){let e=this.client.getServerNames(),t=Object.keys(this.client.getAllActiveSessions()),r=e.filter(e=>!t.includes(e));if(r.length>0&&!this._connecting){this._connecting=!0;try{n.debug(`Connecting to configured servers for code execution: ${r.join(`, `)}`),await this.client.createAllSessions()}finally{this._connecting=!1}}else if(r.length>0&&this._connecting){n.debug(`Waiting for ongoing server connection...`);let e=Date.now();for(;this._connecting&&Date.now()-e<5e3;)await new Promise(e=>setTimeout(e,100))}}getToolNamespaces(){let e=[],t=this.client.getAllActiveSessions();for(let[r,i]of Object.entries(t))if(r!==`code_mode`)try{let t=i.connector,a;try{a=t.tools}catch(e){n.warn(`Tools not available for server ${r}: ${e}`);continue}if(!a||a.length===0)continue;e.push({serverName:r,tools:a,session:i})}catch(e){n.warn(`Failed to load tools for server ${r}: ${e}`)}return e}createSearchToolsFunction(){return async(e=``,t=`full`)=>{let r=[],i=new Set,a=e.toLowerCase(),o=this.client.getAllActiveSessions();for(let[e,a]of Object.entries(o))if(e!==`code_mode`)try{let n=a.connector.tools;n&&n.length>0&&i.add(e);for(let i of n)t===`names`?r.push({name:i.name,server:e}):t===`descriptions`?r.push({name:i.name,server:e,description:i.description}):r.push({name:i.name,server:e,description:i.description,input_schema:i.inputSchema})}catch(t){n.warn(`Failed to search tools in server ${e}: ${t}`)}let s=r;return e&&(s=r.filter(e=>{let t=e.name.toLowerCase().includes(a),n=e.description?.toLowerCase().includes(a),r=e.server.toLowerCase().includes(a);return t||n||r})),{meta:{total_tools:r.length,namespaces:Array.from(i).sort(),result_count:s.length},results:s}}}},v=class extends _{static{t(this,`E2BCodeExecutor`)}e2bApiKey;codeExecSandbox=null;SandboxClass=null;timeoutMs;constructor(e,t){super(e),this.e2bApiKey=t.apiKey,this.timeoutMs=t.timeoutMs??3e5}async ensureSandboxClass(){if(!this.SandboxClass)try{this.SandboxClass=(await d(()=>import(`@e2b/code-interpreter`),[])).Sandbox}catch{throw Error(`@e2b/code-interpreter is not installed. The E2B code executor requires this optional dependency. Install it with: yarn add @e2b/code-interpreter`)}}async getOrCreateCodeExecSandbox(){return this.codeExecSandbox?this.codeExecSandbox:(await this.ensureSandboxClass(),n.debug(`Starting E2B sandbox for code execution...`),this.codeExecSandbox=await this.SandboxClass.create(`base`,{apiKey:this.e2bApiKey,timeoutMs:this.timeoutMs}),this.codeExecSandbox)}generateShim(e){let t=`
|
|
3
3
|
// MCP Bridge Shim
|
|
4
4
|
global.__callMcpTool = async (server, tool, args) => {
|
|
5
5
|
const id = Math.random().toString(36).substring(7);
|
|
@@ -88,4 +88,4 @@ ${this.generateShim(c)}
|
|
|
88
88
|
throw e;
|
|
89
89
|
}
|
|
90
90
|
})()
|
|
91
|
-
`;o=await new y.Script(n,{filename:`agent_code.js`}).runInNewContext(t,{timeout:r,displayErrors:!0})}catch(e){s=e.message||String(e),(e.code===`ERR_SCRIPT_EXECUTION_TIMEOUT`||e.message===`Script execution timed out.`||typeof s==`string`&&(s.includes(`timed out`)||s.includes(`timeout`)))&&(s=`Script execution timed out`),e.stack&&n.debug(`Code execution error stack: ${e.stack}`)}let c=(Date.now()-a)/1e3;return{result:o,logs:i,error:s,execution_time:c}}async _buildContext(e){let n=t((...t)=>{e.push(t.map(e=>typeof e==`object`?JSON.stringify(e,null,2):String(e)).join(` `))},`logHandler`),r={console:{log:n,error:t((...e)=>{n(`[ERROR]`,...e)},`error`),warn:t((...e)=>{n(`[WARN]`,...e)},`warn`),info:n,debug:n},Object,Array,String,Number,Boolean,Date,Math,JSON,RegExp,Map,Set,Promise,parseInt,parseFloat,isNaN,isFinite,encodeURI,decodeURI,encodeURIComponent,decodeURIComponent,setTimeout,clearTimeout,search_tools:this.createSearchToolsFunction(),__tool_namespaces:[]},i={},a=this.getToolNamespaces();for(let{serverName:e,tools:t,session:n}of a){let a={};for(let e of t){let t=e.name;a[t]=async e=>{let r=await n.connector.callTool(t,e||{});if(r.content&&r.content.length>0){let e=r.content[0];if(e.type===`text`)try{return JSON.parse(e.text)}catch{return e.text}return e}return r}}r[e]=a,i[e]=!0}return r.__tool_namespaces=Object.keys(i),y.createContext(r)}async cleanup(){}},E=class extends a{static{t(this,`CodeModeConnector`)}mcpClient;_tools;constructor(e){super(),this.mcpClient=e,this.connected=!0,this._tools=this._createToolsList()}async connect(){this.connected=!0}async disconnect(){this.connected=!1}get publicIdentifier(){return{name:`code_mode`,version:`1.0.0`}}_createToolsList(){return[{name:`execute_code`,description:`Execute JavaScript/TypeScript code with access to MCP tools. This is the PRIMARY way to interact with MCP servers in code mode. Write code that discovers tools using search_tools(), calls tools as async functions (e.g., await github.get_pull_request(...)), processes data efficiently, and returns results. Use 'await' for async operations and 'return' to return values. Available in code: search_tools(), __tool_namespaces, and server.tool_name() functions.`,inputSchema:{type:`object`,properties:{code:{type:`string`,description:`JavaScript/TypeScript code to execute. Use 'await' for async operations. Use 'return' to return a value. Available: search_tools(), server.tool_name(), __tool_namespaces`},timeout:{type:`number`,description:`Execution timeout in milliseconds`,default:3e4}},required:[`code`]}},{name:`search_tools`,description:`Search and discover available MCP tools across all servers. Use this to find out what tools are available before writing code. Returns tool information including names, descriptions, and schemas. Can filter by query and control detail level.`,inputSchema:{type:`object`,properties:{query:{type:`string`,description:`Search query to filter tools by name or description`,default:``},detail_level:{type:`string`,description:`Detail level: 'names', 'descriptions', or 'full'`,enum:[`names`,`descriptions`,`full`],default:`full`}}}}]}get tools(){return this._tools}async initialize(){return this.toolsCache=this._tools,{capabilities:{},version:`1.0.0`}}async callTool(e,t){if(e===`execute_code`){let e=t.code,n=t.timeout||3e4,r=await this.mcpClient.executeCode(e,n);return{content:[{type:`text`,text:JSON.stringify(r)}]}}else if(e===`search_tools`){let e=t.query||``,n=t.detail_level,r=await this.mcpClient.searchTools(e,n&&n in[`names`,`descriptions`,`full`]?n:`full`);return{content:[{type:`text`,text:JSON.stringify(r)}]}}throw Error(`Unknown tool: ${e}`)}};function D(t){let{readFileSync:n}=e(`fs`),r=n(t,`utf-8`);return JSON.parse(r)}t(D,`loadConfigFile`);function O(e){return`requestedSchema`in e&&e.requestedSchema!=null}t(O,`hasRequestedSchema`);function k(e){let t={};if(!O(e))return t;let n=e.requestedSchema.properties??{};for(let[e,r]of Object.entries(n)){let n=r;if(`default`in n){let r=n.default;(typeof r==`string`||typeof r==`number`||typeof r==`boolean`||Array.isArray(r)&&r.every(e=>typeof e==`string`))&&(t[e]=r)}}return t}t(k,`getDefaults`);function A(e,t){let n=k(e);return t==null?n:{...n,...t}}t(A,`applyDefaults`);function j(e){return{action:`accept`,content:k(e)}}t(j,`acceptWithDefaults`);function M(e){return{action:`accept`,content:e}}t(M,`accept`);function N(e){return{action:`decline`}}t(N,`decline`);function P(){return{action:`cancel`}}t(P,`cancel`);function F(e){return N(e)}t(F,`reject`);function I(e,t){if(!O(e))return{valid:!0};try{let n=f.convert(e.requestedSchema).safeParse(t);return n.success?{valid:!0}:{valid:!1,errors:n.error.issues.map(e=>e.path.length>0?`${e.path.join(`.`)}: ${e.message}`:e.message)}}catch{return{valid:!1,errors:[`Unsupported or invalid schema`]}}}t(I,`validate`);function L(e,t,r){let a=Object.keys(e.mcpServers??{}),o=!!(r.onSampling??r.samplingCallback),s=!!(r.onElicitation??r.elicitationCallback);i.getInstance().trackMCPClientInit({codeMode:t,sandbox:!1,allCallbacks:o&&s,verify:!1,servers:a,numServers:a.length,isBrowser:!1}).catch(e=>n.debug(`Failed to track MCPClient init: ${e}`))}t(L,`trackNodeClientInit`);var R=class e extends u{static{t(this,`MCPClient`)}static getPackageVersion(){return r()}codeMode=!1;_codeExecutor=null;_customCodeExecutor=null;_codeExecutorConfig=`vm`;_executorOptions;_globalCallbacks;constructor(e,t){e?super(typeof e==`string`?D(e):e):super();let n=!1,r=`vm`,i;t?.codeMode&&(typeof t.codeMode==`boolean`?n=t.codeMode:(n=t.codeMode.enabled,r=t.codeMode.executor??`vm`,i=t.codeMode.executorOptions)),this.codeMode=n,this._codeExecutorConfig=r,this._executorOptions=i;let a=this.config;this._globalCallbacks={onSampling:t?.onSampling??t?.samplingCallback??a?.onSampling??a?.samplingCallback,samplingCallback:t?.samplingCallback??a?.samplingCallback,onElicitation:t?.onElicitation??t?.elicitationCallback??a?.onElicitation??a?.elicitationCallback,elicitationCallback:t?.elicitationCallback??a?.elicitationCallback,onNotification:t?.onNotification??a?.onNotification},t?.samplingCallback&&!t?.onSampling&&console.warn(`[MCPClient] The "samplingCallback" option is deprecated. Use "onSampling" instead.`),t?.elicitationCallback&&!t?.onElicitation&&console.warn(`[MCPClient] The "elicitationCallback" option is deprecated. Use "onElicitation" instead.`),this.codeMode&&this._setupCodeModeConnector(),L(this.config,this.codeMode,this._globalCallbacks)}static fromDict(t,n){return new e(t,n)}static fromConfigFile(t,n){return new e(D(t),n)}saveConfig(e){let t=m.dirname(e);p.existsSync(t)||p.mkdirSync(t,{recursive:!0}),p.writeFileSync(e,JSON.stringify(this.config,null,2),`utf-8`)}async createConnectorFromConfig(e){let t=c(e,this._globalCallbacks),n={...e,clientInfo:e.clientInfo??this.config.clientInfo};if(`command`in n&&`args`in n){let{StdioConnector:e}=await d(async()=>{let{StdioConnector:e}=await import(`./stdio-
|
|
91
|
+
`;o=await new y.Script(n,{filename:`agent_code.js`}).runInNewContext(t,{timeout:r,displayErrors:!0})}catch(e){s=e.message||String(e),(e.code===`ERR_SCRIPT_EXECUTION_TIMEOUT`||e.message===`Script execution timed out.`||typeof s==`string`&&(s.includes(`timed out`)||s.includes(`timeout`)))&&(s=`Script execution timed out`),e.stack&&n.debug(`Code execution error stack: ${e.stack}`)}let c=(Date.now()-a)/1e3;return{result:o,logs:i,error:s,execution_time:c}}async _buildContext(e){let n=t((...t)=>{e.push(t.map(e=>typeof e==`object`?JSON.stringify(e,null,2):String(e)).join(` `))},`logHandler`),r={console:{log:n,error:t((...e)=>{n(`[ERROR]`,...e)},`error`),warn:t((...e)=>{n(`[WARN]`,...e)},`warn`),info:n,debug:n},Object,Array,String,Number,Boolean,Date,Math,JSON,RegExp,Map,Set,Promise,parseInt,parseFloat,isNaN,isFinite,encodeURI,decodeURI,encodeURIComponent,decodeURIComponent,setTimeout,clearTimeout,search_tools:this.createSearchToolsFunction(),__tool_namespaces:[]},i={},a=this.getToolNamespaces();for(let{serverName:e,tools:t,session:n}of a){let a={};for(let e of t){let t=e.name;a[t]=async e=>{let r=await n.connector.callTool(t,e||{});if(r.content&&r.content.length>0){let e=r.content[0];if(e.type===`text`)try{return JSON.parse(e.text)}catch{return e.text}return e}return r}}r[e]=a,i[e]=!0}return r.__tool_namespaces=Object.keys(i),y.createContext(r)}async cleanup(){}},E=class extends a{static{t(this,`CodeModeConnector`)}mcpClient;_tools;constructor(e){super(),this.mcpClient=e,this.connected=!0,this._tools=this._createToolsList()}async connect(){this.connected=!0}async disconnect(){this.connected=!1}get publicIdentifier(){return{name:`code_mode`,version:`1.0.0`}}_createToolsList(){return[{name:`execute_code`,description:`Execute JavaScript/TypeScript code with access to MCP tools. This is the PRIMARY way to interact with MCP servers in code mode. Write code that discovers tools using search_tools(), calls tools as async functions (e.g., await github.get_pull_request(...)), processes data efficiently, and returns results. Use 'await' for async operations and 'return' to return values. Available in code: search_tools(), __tool_namespaces, and server.tool_name() functions.`,inputSchema:{type:`object`,properties:{code:{type:`string`,description:`JavaScript/TypeScript code to execute. Use 'await' for async operations. Use 'return' to return a value. Available: search_tools(), server.tool_name(), __tool_namespaces`},timeout:{type:`number`,description:`Execution timeout in milliseconds`,default:3e4}},required:[`code`]}},{name:`search_tools`,description:`Search and discover available MCP tools across all servers. Use this to find out what tools are available before writing code. Returns tool information including names, descriptions, and schemas. Can filter by query and control detail level.`,inputSchema:{type:`object`,properties:{query:{type:`string`,description:`Search query to filter tools by name or description`,default:``},detail_level:{type:`string`,description:`Detail level: 'names', 'descriptions', or 'full'`,enum:[`names`,`descriptions`,`full`],default:`full`}}}}]}get tools(){return this._tools}async initialize(){return this.toolsCache=this._tools,{capabilities:{},version:`1.0.0`}}async callTool(e,t){if(e===`execute_code`){let e=t.code,n=t.timeout||3e4,r=await this.mcpClient.executeCode(e,n);return{content:[{type:`text`,text:JSON.stringify(r)}]}}else if(e===`search_tools`){let e=t.query||``,n=t.detail_level,r=await this.mcpClient.searchTools(e,n&&n in[`names`,`descriptions`,`full`]?n:`full`);return{content:[{type:`text`,text:JSON.stringify(r)}]}}throw Error(`Unknown tool: ${e}`)}};function D(t){let{readFileSync:n}=e(`fs`),r=n(t,`utf-8`);return JSON.parse(r)}t(D,`loadConfigFile`);function O(e){return`requestedSchema`in e&&e.requestedSchema!=null}t(O,`hasRequestedSchema`);function k(e){let t={};if(!O(e))return t;let n=e.requestedSchema.properties??{};for(let[e,r]of Object.entries(n)){let n=r;if(`default`in n){let r=n.default;(typeof r==`string`||typeof r==`number`||typeof r==`boolean`||Array.isArray(r)&&r.every(e=>typeof e==`string`))&&(t[e]=r)}}return t}t(k,`getDefaults`);function A(e,t){let n=k(e);return t==null?n:{...n,...t}}t(A,`applyDefaults`);function j(e){return{action:`accept`,content:k(e)}}t(j,`acceptWithDefaults`);function M(e){return{action:`accept`,content:e}}t(M,`accept`);function N(e){return{action:`decline`}}t(N,`decline`);function P(){return{action:`cancel`}}t(P,`cancel`);function F(e){return N(e)}t(F,`reject`);function I(e,t){if(!O(e))return{valid:!0};try{let n=f.convert(e.requestedSchema).safeParse(t);return n.success?{valid:!0}:{valid:!1,errors:n.error.issues.map(e=>e.path.length>0?`${e.path.join(`.`)}: ${e.message}`:e.message)}}catch{return{valid:!1,errors:[`Unsupported or invalid schema`]}}}t(I,`validate`);function L(e,t,r){let a=Object.keys(e.mcpServers??{}),o=!!(r.onSampling??r.samplingCallback),s=!!(r.onElicitation??r.elicitationCallback);i.getInstance().trackMCPClientInit({codeMode:t,sandbox:!1,allCallbacks:o&&s,verify:!1,servers:a,numServers:a.length,isBrowser:!1}).catch(e=>n.debug(`Failed to track MCPClient init: ${e}`))}t(L,`trackNodeClientInit`);var R=class e extends u{static{t(this,`MCPClient`)}static getPackageVersion(){return r()}codeMode=!1;_codeExecutor=null;_customCodeExecutor=null;_codeExecutorConfig=`vm`;_executorOptions;_globalCallbacks;constructor(e,t){e?super(typeof e==`string`?D(e):e):super();let n=!1,r=`vm`,i;t?.codeMode&&(typeof t.codeMode==`boolean`?n=t.codeMode:(n=t.codeMode.enabled,r=t.codeMode.executor??`vm`,i=t.codeMode.executorOptions)),this.codeMode=n,this._codeExecutorConfig=r,this._executorOptions=i;let a=this.config;this._globalCallbacks={onSampling:t?.onSampling??t?.samplingCallback??a?.onSampling??a?.samplingCallback,samplingCallback:t?.samplingCallback??a?.samplingCallback,onElicitation:t?.onElicitation??t?.elicitationCallback??a?.onElicitation??a?.elicitationCallback,elicitationCallback:t?.elicitationCallback??a?.elicitationCallback,onNotification:t?.onNotification??a?.onNotification},t?.samplingCallback&&!t?.onSampling&&console.warn(`[MCPClient] The "samplingCallback" option is deprecated. Use "onSampling" instead.`),t?.elicitationCallback&&!t?.onElicitation&&console.warn(`[MCPClient] The "elicitationCallback" option is deprecated. Use "onElicitation" instead.`),this.codeMode&&this._setupCodeModeConnector(),L(this.config,this.codeMode,this._globalCallbacks)}static fromDict(t,n){return new e(t,n)}static fromConfigFile(t,n){return new e(D(t),n)}saveConfig(e){let t=m.dirname(e);p.existsSync(t)||p.mkdirSync(t,{recursive:!0}),p.writeFileSync(e,JSON.stringify(this.config,null,2),`utf-8`)}async createConnectorFromConfig(e){let t=c(e,this._globalCallbacks),n={...e,clientInfo:e.clientInfo??this.config.clientInfo};if(`command`in n&&`args`in n){let{StdioConnector:e}=await d(async()=>{let{StdioConnector:e}=await import(`./stdio-IOUVQROQ-CeewE_Ia.js`);return{StdioConnector:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])),r=n;return new e({command:r.command,args:r.args,env:r.env,clientInfo:o(n.clientInfo),onSampling:t.onSampling,onElicitation:t.onElicitation,onNotification:t.onNotification})}return s(n,{onSampling:t.onSampling,onElicitation:t.onElicitation,onNotification:t.onNotification})}_setupCodeModeConnector(){n.debug(`Code mode connector initialized as internal meta server`);let e=new l(new E(this));this.sessions.code_mode=e,this.activeSessions.push(`code_mode`)}_ensureCodeExecutor(){if(!this._codeExecutor){let e=this._codeExecutorConfig;if(e instanceof _)this._codeExecutor=e;else if(typeof e==`function`)throw this._customCodeExecutor=e,Error(`Custom executor function should be handled in executeCode`);else if(e===`e2b`){let e=this._executorOptions;if(e?.apiKey)this._codeExecutor=new v(this,e);else{n.warn(`E2B executor requires apiKey. Falling back to VM.`);try{this._codeExecutor=new T(this,this._executorOptions)}catch{throw Error(`VM executor is not available in this environment and E2B API key is not provided. Please provide an E2B API key or run in a Node.js environment.`)}}}else try{this._codeExecutor=new T(this,this._executorOptions)}catch{let e=this._executorOptions,t=e?.apiKey||{}.E2B_API_KEY;if(t)n.info(`VM executor not available in this environment. Falling back to E2B.`),this._codeExecutor=new v(this,{...e,apiKey:t});else throw Error(`VM executor is not available in this environment. Please provide an E2B API key via executorOptions or E2B_API_KEY environment variable, or run in a Node.js environment.`)}}return this._codeExecutor}async executeCode(e,t){if(!this.codeMode)throw Error(`Code execution mode is not enabled`);return this._customCodeExecutor?this._customCodeExecutor(e,t):this._ensureCodeExecutor().execute(e,t)}async searchTools(e=``,t=`full`){if(!this.codeMode)throw Error(`Code execution mode is not enabled`);return this._ensureCodeExecutor().createSearchToolsFunction()(e,t)}getServerNames(){let e=this.codeMode;return super.getServerNames().filter(t=>!e||t!==`code_mode`)}async close(){this._codeExecutor&&=(await this._codeExecutor.cleanup(),null),await this.closeAllSessions()}};export{R as MCPClient};
|
|
@@ -58,7 +58,7 @@ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Rec
|
|
|
58
58
|
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);N.object({method:N.literal(`ui/open-link`),params:N.object({url:N.string().describe(`URL to open in the host's browser`)})}),N.object({isError:N.boolean().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),N.object({isError:N.boolean().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough(),N.object({method:N.literal(`ui/notifications/sandbox-proxy-ready`),params:N.object({})});var qg=N.object({connectDomains:N.array(N.string()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).`),resourceDomains:N.array(N.string()).optional().describe(`Origins for static resources (scripts, images, styles, fonts).`),frameDomains:N.array(N.string()).optional().describe(`Origins for nested iframes (frame-src directive).`),baseUriDomains:N.array(N.string()).optional().describe(`Allowed base URIs for the document (base-uri directive).`)}),Jg=N.object({camera:N.object({}).optional().describe("Request camera access (Permission Policy `camera` feature)."),microphone:N.object({}).optional().describe("Request microphone access (Permission Policy `microphone` feature)."),geolocation:N.object({}).optional().describe("Request geolocation access (Permission Policy `geolocation` feature)."),clipboardWrite:N.object({}).optional().describe("Request clipboard write access (Permission Policy `clipboard-write` feature).")});N.object({method:N.literal(`ui/notifications/size-changed`),params:N.object({width:N.number().optional().describe(`New width in pixels.`),height:N.number().optional().describe(`New height in pixels.`)})}),N.object({method:N.literal(`ui/notifications/tool-input`),params:N.object({arguments:N.record(N.string(),N.unknown().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),N.object({method:N.literal(`ui/notifications/tool-input-partial`),params:N.object({arguments:N.record(N.string(),N.unknown().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),N.object({method:N.literal(`ui/notifications/tool-cancelled`),params:N.object({reason:N.string().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})});var Yg=N.object({fonts:N.string().optional()}),Xg=N.object({variables:Kg.optional().describe(`CSS variables for theming the app.`),css:Yg.optional().describe(`CSS blocks that apps can inject.`)});N.object({method:N.literal(`ui/resource-teardown`),params:N.object({})}),N.record(N.string(),N.unknown());var Zg=N.object({text:N.object({}).optional().describe(`Host supports text content blocks.`),image:N.object({}).optional().describe(`Host supports image content blocks.`),audio:N.object({}).optional().describe(`Host supports audio content blocks.`),resource:N.object({}).optional().describe(`Host supports resource content blocks.`),resourceLink:N.object({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:N.object({}).optional().describe(`Host supports structured content.`)}),Qg=N.object({experimental:N.object({}).optional().describe(`Experimental features (structure TBD).`),openLinks:N.object({}).optional().describe(`Host supports opening external URLs.`),serverTools:N.object({listChanged:N.boolean().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:N.object({listChanged:N.boolean().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:N.object({}).optional().describe(`Host accepts log messages.`),sandbox:N.object({permissions:Jg.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:qg.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:Zg.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:Zg.optional().describe(`Host supports receiving content messages (ui/message) from the view.`)}),$g=N.object({experimental:N.object({}).optional().describe(`Experimental features (structure TBD).`),tools:N.object({listChanged:N.boolean().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:N.array(Wg).optional().describe(`Display modes the app supports.`)});N.object({method:N.literal(`ui/notifications/initialized`),params:N.object({}).optional()}),N.object({csp:qg.optional().describe(`Content Security Policy configuration.`),permissions:Jg.optional().describe(`Sandbox permissions requested by the UI.`),domain:N.string().optional().describe(`Dedicated origin for view sandbox.`),prefersBorder:N.boolean().optional().describe(`Visual boundary preference - true if UI prefers a visible border.`)}),N.object({method:N.literal(`ui/request-display-mode`),params:N.object({mode:Wg.describe(`The display mode being requested.`)})}),N.object({mode:Wg.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough();var e_=N.union([N.literal(`model`),N.literal(`app`)]).describe(`Tool visibility scope - who can access the tool.`);N.object({resourceUri:N.string().optional(),visibility:N.array(e_).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
59
59
|
- "model": Tool visible to and callable by the agent
|
|
60
60
|
- "app": Tool callable by the app from this server only`)}),N.object({mimeTypes:N.array(N.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),N.object({method:N.literal(`ui/message`),params:N.object({role:N.literal(`user`).describe(`Message role, currently only "user" is supported.`),content:N.array(Bt).describe(`Message content blocks (text, image, etc.).`)})}),N.object({method:N.literal(`ui/notifications/sandbox-resource-ready`),params:N.object({html:N.string().describe(`HTML content to load into the inner iframe.`),sandbox:N.string().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:qg.optional().describe(`CSP configuration from resource metadata.`),permissions:Jg.optional().describe(`Sandbox permissions from resource metadata.`)})}),N.object({method:N.literal(`ui/notifications/tool-result`),params:Yt.describe(`Standard MCP tool execution result.`)});var t_=N.object({toolInfo:N.object({id:he.optional().describe(`JSON-RPC id of the tools/call request.`),tool:Kt.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:Ug.optional().describe(`Current color theme preference.`),styles:Xg.optional().describe(`Style configuration for theming the app.`),displayMode:Wg.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:N.array(Wg).optional().describe(`Display modes the host supports.`),containerDimensions:N.union([N.object({height:N.number().describe(`Fixed container height in pixels.`)}),N.object({maxHeight:N.union([N.number(),N.undefined()]).optional().describe(`Maximum container height in pixels.`)})]).and(N.union([N.object({width:N.number().describe(`Fixed container width in pixels.`)}),N.object({maxWidth:N.union([N.number(),N.undefined()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
61
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:N.string().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:N.string().optional().describe(`User's timezone in IANA format.`),userAgent:N.string().optional().describe(`Host application identifier.`),platform:N.union([N.literal(`web`),N.literal(`desktop`),N.literal(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:N.object({touch:N.boolean().optional().describe(`Whether the device supports touch input.`),hover:N.boolean().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:N.object({top:N.number().describe(`Top safe area inset in pixels.`),right:N.number().describe(`Right safe area inset in pixels.`),bottom:N.number().describe(`Bottom safe area inset in pixels.`),left:N.number().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();N.object({method:N.literal(`ui/notifications/host-context-changed`),params:t_.describe(`Partial context update containing only changed fields.`)}),N.object({method:N.literal(`ui/update-model-context`),params:N.object({content:N.array(Bt).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:N.record(N.string(),N.unknown().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),N.object({method:N.literal(`ui/initialize`),params:N.object({appInfo:Ae.describe(`App identification (name and version).`),appCapabilities:$g.describe(`Features and capabilities this app provides.`),protocolVersion:N.string().describe(`Protocol version this app supports.`)})}),N.object({protocolVersion:N.string().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Ae.describe(`Host application identification and version.`),hostCapabilities:Qg.describe(`Features and capabilities provided by the host.`),hostContext:t_.describe(`Rich context about the host environment.`)}).passthrough();var n_=`text/html;profile=mcp-app`,r_=`1.22.2-canary.2`;function i_(){return r_}a(i_,`getPackageVersion`);var a_=class{static{a(this,`BaseTelemetryEvent`)}},o_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`MCPAgentExecutionEvent`)}get name(){return`mcp_agent_execution`}get properties(){return{execution_method:this.data.executionMethod,query:this.data.query,query_length:this.data.query.length,success:this.data.success,model_provider:this.data.modelProvider,model_name:this.data.modelName,server_count:this.data.serverCount,server_identifiers:this.data.serverIdentifiers,total_tools_available:this.data.totalToolsAvailable,tools_available_names:this.data.toolsAvailableNames,max_steps_configured:this.data.maxStepsConfigured,memory_enabled:this.data.memoryEnabled,use_server_manager:this.data.useServerManager,max_steps_used:this.data.maxStepsUsed,manage_connector:this.data.manageConnector,external_history_used:this.data.externalHistoryUsed,steps_taken:this.data.stepsTaken??null,tools_used_count:this.data.toolsUsedCount??null,tools_used_names:this.data.toolsUsedNames??null,response:this.data.response??null,response_length:this.data.response?this.data.response.length:null,execution_time_ms:this.data.executionTimeMs??null,error_type:this.data.errorType??null,conversation_history_length:this.data.conversationHistoryLength??null}}};function s_(e,t){let n=Array.from(e.registrations.tools.values()),r=Array.from(e.registrations.prompts.values()),i=Array.from(e.registrations.resources.values()),a=Array.from(e.registrations.resourceTemplates.values()),o=i.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null,uri:e.config.uri??null,mime_type:e.config.mimeType??null})),s=o.filter(e=>e.mime_type===`text/html+skybridge`),c=o.filter(e=>e.mime_type===`text/uri-list`||e.mime_type===`text/html`),l=o.filter(e=>e.mime_type===n_);return{transport:t,toolsNumber:e.registeredTools.length,resourcesNumber:e.registeredResources.length,promptsNumber:e.registeredPrompts.length,auth:!!e.oauthProvider,name:e.config.name,description:e.config.description??null,baseUrl:e.serverBaseUrl??null,toolNames:e.registeredTools.length>0?e.registeredTools:null,resourceNames:e.registeredResources.length>0?e.registeredResources:null,promptNames:e.registeredPrompts.length>0?e.registeredPrompts:null,tools:n.length>0?n.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null,input_schema:e.config.schema?JSON.stringify(e.config.schema):null,output_schema:e.config.outputSchema?JSON.stringify(e.config.outputSchema):null})):null,resources:o.length>0?o:null,prompts:r.length>0?r.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null,args:e.config.args?JSON.stringify(e.config.args):null})):null,templates:a.length>0?a.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null})):null,capabilities:{logging:!0,resources:{subscribe:!0,listChanged:!0}},appsSdkResources:s.length>0?s:null,appsSdkResourcesNumber:s.length,mcpUiResources:c.length>0?c:null,mcpUiResourcesNumber:c.length,mcpAppsResources:l.length>0?l:null,mcpAppsResourcesNumber:l.length}}a(s_,`createServerRunEventData`);var c_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ServerRunEvent`)}get name(){return`server_run`}get properties(){return{transport:this.data.transport,tools_number:this.data.toolsNumber,resources_number:this.data.resourcesNumber,prompts_number:this.data.promptsNumber,auth:this.data.auth,name:this.data.name,description:this.data.description??null,base_url:this.data.baseUrl??null,tool_names:this.data.toolNames??null,resource_names:this.data.resourceNames??null,prompt_names:this.data.promptNames??null,tools:this.data.tools??null,resources:this.data.resources??null,prompts:this.data.prompts??null,templates:this.data.templates??null,capabilities:this.data.capabilities?JSON.stringify(this.data.capabilities):null,apps_sdk_resources:this.data.appsSdkResources?JSON.stringify(this.data.appsSdkResources):null,apps_sdk_resources_number:this.data.appsSdkResourcesNumber??0,mcp_ui_resources:this.data.mcpUiResources?JSON.stringify(this.data.mcpUiResources):null,mcp_ui_resources_number:this.data.mcpUiResourcesNumber??0,mcp_apps_resources:this.data.mcpAppsResources?JSON.stringify(this.data.mcpAppsResources):null,mcp_apps_resources_number:this.data.mcpAppsResourcesNumber??0}}},l_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ServerInitializeEvent`)}get name(){return`server_initialize_call`}get properties(){return{protocol_version:this.data.protocolVersion,client_info:JSON.stringify(this.data.clientInfo),client_capabilities:JSON.stringify(this.data.clientCapabilities),session_id:this.data.sessionId??null}}},u_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ServerToolCallEvent`)}get name(){return`server_tool_call`}get properties(){return{tool_name:this.data.toolName,length_input_argument:this.data.lengthInputArgument,success:this.data.success,error_type:this.data.errorType??null,execution_time_ms:this.data.executionTimeMs??null}}},d_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ServerResourceCallEvent`)}get name(){return`server_resource_call`}get properties(){return{name:this.data.name,description:this.data.description,contents:this.data.contents,success:this.data.success,error_type:this.data.errorType??null}}},f_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ServerPromptCallEvent`)}get name(){return`server_prompt_call`}get properties(){return{name:this.data.name,description:this.data.description,success:this.data.success,error_type:this.data.errorType??null}}},p_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ServerContextEvent`)}get name(){return`server_context_${this.data.contextType}`}get properties(){return{context_type:this.data.contextType,notification_type:this.data.notificationType??null}}},m_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`MCPClientInitEvent`)}get name(){return`mcpclient_init`}get properties(){return{code_mode:this.data.codeMode,sandbox:this.data.sandbox,all_callbacks:this.data.allCallbacks,verify:this.data.verify,servers:this.data.servers,num_servers:this.data.numServers,is_browser:this.data.isBrowser}}},h_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ConnectorInitEvent`)}get name(){return`connector_init`}get properties(){return{connector_type:this.data.connectorType,server_command:this.data.serverCommand??null,server_args:this.data.serverArgs??null,server_url:this.data.serverUrl??null,public_identifier:this.data.publicIdentifier??null}}},g_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ClientAddServerEvent`)}get name(){return`client_add_server`}get properties(){let{serverName:e,serverConfig:t}=this.data,n=t.url;return{server_name:e,server_url_domain:n?this._extractHostname(n):null,transport:t.transport??null,has_auth:!!(t.authToken||t.authProvider)}}_extractHostname(e){try{return new URL(e).hostname}catch{return null}}},__=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ClientRemoveServerEvent`)}get name(){return`client_remove_server`}get properties(){return{server_name:this.data.serverName}}};function v_(e){return e._llm_type||e.constructor.name.toLowerCase()}a(v_,`getModelProvider`);function y_(e){if(`_identifyingParams`in e){let t=e._identifyingParams;if(typeof t==`object`&&t){for(let e of[`model`,`modelName`,`model_name`,`modelId`,`model_id`,`deploymentName`,`deployment_name`])if(e in t)return String(t[e])}}return e.model||e.modelName||e.constructor.name}a(y_,`getModelName`);function b_(e){return[v_(e),y_(e)]}a(b_,`extractModelInfo`);function x_(){if(typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.randomUUID==`function`)return globalThis.crypto.randomUUID();if(typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues==`function`){let e=new Uint8Array(16);globalThis.crypto.getRandomValues(e);let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.substring(0,8)}-${t.substring(8,12)}-${t.substring(12,16)}-${t.substring(16,20)}-${t.substring(20)}`}return`${Date.now()}-${Math.random().toString(36).substring(2,15)}-${Math.random().toString(36).substring(2,15)}`}a(x_,`generateUUID`);function S_(){if(typeof window<`u`&&window.crypto&&typeof window.crypto.getRandomValues==`function`){let e=new Uint8Array(8);return window.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}if(typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues==`function`){let e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}return Math.random().toString(36).substring(2,15)}a(S_,`secureRandomString`);var C_=`mcp_use_user_id`;function w_(){return typeof localStorage<`u`&&typeof localStorage.getItem==`function`&&typeof localStorage.setItem==`function`&&typeof localStorage.removeItem==`function`}a(w_,`isLocalStorageFunctional`);function T_(){try{return typeof window<`u`&&typeof document<`u`?`browser`:`unknown`}catch{return`unknown`}}a(T_,`detectRuntimeEnvironment`);function E_(e){if(e===`browser`)try{if(w_())return localStorage.setItem(`__mcp_use_test__`,`1`),localStorage.removeItem(`__mcp_use_test__`),`localStorage`}catch{}return`session-only`}a(E_,`getStorageCapability`);var D_=null;function O_(){return D_===null&&(D_=T_()),D_}a(O_,`getRuntimeEnvironment`);var k_=class e{static{a(this,`Telemetry`)}static instance=null;PROJECT_API_KEY=`phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI`;HOST=`https://eu.i.posthog.com`;UNKNOWN_USER_ID=`UNKNOWN_USER_ID`;_currUserId=null;_posthogBrowserClient=null;_posthogLoading=null;_runtimeEnvironment;_storageCapability;_source;constructor(){this._runtimeEnvironment=O_(),this._storageCapability=E_(this._runtimeEnvironment),this._source=this._getSourceFromLocalStorage()||this._runtimeEnvironment;let e=this._checkTelemetryDisabled(),t=this._runtimeEnvironment!==`unknown`;e?(this._posthogBrowserClient=null,o.debug(`Telemetry disabled via localStorage`)):t?(o.info(`Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false in localStorage to disable.`),this._posthogLoading=this._initPostHogBrowser()):(this._posthogBrowserClient=null,o.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`))}_getSourceFromLocalStorage(){try{if(w_())return localStorage.getItem(`MCP_USE_TELEMETRY_SOURCE`)}catch{}return null}_checkTelemetryDisabled(){return!!(w_()&&localStorage.getItem(`MCP_USE_ANONYMIZED_TELEMETRY`)===`false`)}async _initPostHogBrowser(){try{let e=await te(()=>import(`./module-DCsrdi7m.js`),[]),t=e.default||e.posthog;if(!t||typeof t.init!=`function`)throw Error(`posthog-js module did not export expected interface`);t.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:`localStorage`,autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:a(()=>{o.debug(`PostHog browser client initialized`)},`loaded`)}),this._posthogBrowserClient=t}catch(e){o.warn(`Failed to initialize PostHog browser telemetry: ${e}`),this._posthogBrowserClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return e.instance||=new e,e.instance}setSource(e){this._source=e;try{w_()&&localStorage.setItem(`MCP_USE_TELEMETRY_SOURCE`,e)}catch{}o.debug(`Telemetry source set to: ${e}`)}getSource(){return this._source}get isEnabled(){return this._posthogBrowserClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case`localStorage`:this._currUserId=this._getUserIdFromLocalStorage();break;default:try{this._currUserId=`session-${x_()}`}catch{this._currUserId=`session-${Date.now()}-${S_()}`}break}}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromLocalStorage(){try{if(!w_())throw Error(`localStorage is not available or not functional`);localStorage.setItem(`__mcp_use_test__`,`1`),localStorage.removeItem(`__mcp_use_test__`);let e=localStorage.getItem(C_);if(!e){try{e=x_()}catch{e=`${Date.now()}-${S_()}`}localStorage.setItem(C_,e)}return e}catch(e){o.debug(`Failed to access localStorage for user ID: ${e}`);let t;try{t=`session-${x_()}`}catch{t=`session-${Date.now()}-${S_()}`}return t}}async capture(e){if(this._posthogLoading&&await this._posthogLoading,!this._posthogBrowserClient)return;let t=this.userId,n={...e.properties};if(n.mcp_use_version=i_(),n.language=`typescript`,n.source=this._source,n.runtime=this._runtimeEnvironment,this._posthogBrowserClient)try{this._posthogBrowserClient.capture(e.name,{...n,distinct_id:t})}catch(t){o.debug(`Failed to track PostHog Browser event ${e.name}: ${t}`)}}async trackAgentExecution(e){if(!this.isEnabled)return;let t=new o_(e);await this.capture(t)}async trackServerRunFromServer(e,t){if(!this.isEnabled)return;let n=new c_(s_(e,t));await this.capture(n)}async trackServerInitialize(e){if(!this.isEnabled)return;let t=new l_(e);await this.capture(t)}async trackServerToolCall(e){if(!this.isEnabled)return;let t=new u_(e);await this.capture(t)}async trackServerResourceCall(e){if(!this.isEnabled)return;let t=new d_(e);await this.capture(t)}async trackServerPromptCall(e){if(!this.isEnabled)return;let t=new f_(e);await this.capture(t)}async trackServerContext(e){if(!this.isEnabled)return;let t=new p_(e);await this.capture(t)}async trackMCPClientInit(e){if(!this.isEnabled)return;let t=new m_(e);await this.capture(t)}async trackConnectorInit(e){if(!this.isEnabled)return;let t=new h_(e);await this.capture(t)}async trackClientAddServer(e,t){if(!this.isEnabled)return;let n=new g_({serverName:e,serverConfig:t});await this.capture(n)}async trackClientRemoveServer(e){if(!this.isEnabled)return;let t=new __({serverName:e});await this.capture(t)}async trackUseMcpConnection(e){this.isEnabled&&await this.capture({name:`usemcp_connection`,properties:{url_domain:new URL(e.url).hostname,transport_type:e.transportType,success:e.success,error_type:e.errorType??null,connection_time_ms:e.connectionTimeMs??null,has_oauth:e.hasOAuth,has_sampling:e.hasSampling,has_elicitation:e.hasElicitation}})}async trackUseMcpToolCall(e){this.isEnabled&&await this.capture({name:`usemcp_tool_call`,properties:{tool_name:e.toolName,success:e.success,error_type:e.errorType??null,execution_time_ms:e.executionTimeMs??null}})}async trackUseMcpResourceRead(e){this.isEnabled&&await this.capture({name:`usemcp_resource_read`,properties:{resource_uri_scheme:e.resourceUri.split(`:`)[0],success:e.success,error_type:e.errorType??null}})}identify(e,t){if(this._posthogBrowserClient)try{this._posthogBrowserClient.identify(e,t)}catch(e){o.debug(`Failed to identify user: ${e}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(e){o.debug(`Failed to reset user: ${e}`)}this._currUserId=null}flush(){}shutdown(){}async trackPackageDownload(e){}},A_=k_;function j_(e){A_.getInstance().setSource(e)}a(j_,`setTelemetrySource`);var M_=class{static{a(this,`BaseConnector`)}client=null;connectionManager=null;toolsCache=null;capabilitiesCache=null;serverInfoCache=null;connected=!1;opts;notificationHandlers=[];rootsCache=[];constructor(e={}){let t={...e,onSampling:e.onSampling??e.samplingCallback,onElicitation:e.onElicitation??e.elicitationCallback};e.samplingCallback&&!e.onSampling&&o.warn(`[BaseConnector] The "samplingCallback" option is deprecated. Use "onSampling" instead.`),e.elicitationCallback&&!e.onElicitation&&console.warn(`[BaseConnector] The "elicitationCallback" option is deprecated. Use "onElicitation" instead.`),this.opts=t,t.roots&&(this.rootsCache=[...t.roots]),t.onNotification&&this.notificationHandlers.push(t.onNotification)}trackConnectorInit(e){let t=this.constructor.name;k_.getInstance().trackConnectorInit({connectorType:t,...e}).catch(e=>o.debug(`Failed to track connector init: ${e}`))}onNotification(e){this.notificationHandlers.push(e),this.client&&this.setupNotificationHandler()}setupNotificationHandler(){if(!this.client)return;let e=a(async e=>{for(let t of this.notificationHandlers)try{await t(e)}catch(e){o.error(`Error in notification handler:`,e)}},`forwardToUserHandlers`);this.client.fallbackNotificationHandler=async t=>{switch(t.method){case`notifications/tools/list_changed`:await this.refreshToolsCache();break;case`notifications/resources/list_changed`:await this.onResourcesListChanged();break;case`notifications/prompts/list_changed`:await this.onPromptsListChanged();break;default:break}await e(t)};let t=this.client._notificationHandlers;for(let n of[`notifications/progress`,`notifications/cancelled`]){let r=t.get(n);r&&t.set(n,async t=>{await r(t),await e(t)})}}async refreshToolsCache(){if(this.client)try{o.debug(`[Auto] Refreshing tools cache due to list_changed notification`),this.toolsCache=(await this.client.listTools()).tools??[],o.debug(`[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`)}catch(e){o.warn(`[Auto] Failed to refresh tools cache:`,e)}}async onResourcesListChanged(){o.debug(`[Auto] Resources list changed - clients should re-fetch if needed`)}async onPromptsListChanged(){o.debug(`[Auto] Prompts list changed - clients should re-fetch if needed`)}async setRoots(e){this.rootsCache=[...e],this.client&&(o.debug(`Sending roots/list_changed notification with ${e.length} root(s)`),await this.client.sendRootsListChanged())}getRoots(){return[...this.rootsCache]}setupRootsHandler(){this.client&&this.client.setRequestHandler(Nn,async(e,t)=>(o.debug(`Server requested roots list, returning ${this.rootsCache.length} root(s)`),{roots:this.rootsCache}))}setupSamplingHandler(){if(!this.client){o.debug(`setupSamplingHandler: No client available`);return}let e=this.opts.onSampling??this.opts.samplingCallback;if(!e){o.debug(`setupSamplingHandler: No sampling callback provided`);return}o.debug(`setupSamplingHandler: Setting up sampling request handler`),this.client.setRequestHandler(pn,async(t,n)=>(o.debug(`Server requested sampling, forwarding to callback`),await e(t.params))),o.debug(`setupSamplingHandler: Sampling handler registered successfully`)}setupElicitationHandler(){if(!this.client){o.debug(`setupElicitationHandler: No client available`);return}let e=this.opts.onElicitation??this.opts.elicitationCallback;if(!e){o.debug(`setupElicitationHandler: No elicitation callback provided`);return}o.debug(`setupElicitationHandler: Setting up elicitation request handler`),this.client.setRequestHandler(Cn,async(t,n)=>(o.debug(`Server requested elicitation, forwarding to callback`),await e(t.params))),o.debug(`setupElicitationHandler: Elicitation handler registered successfully`)}async disconnect(){if(!this.connected){o.debug(`Not connected to MCP implementation`);return}o.debug(`Disconnecting from MCP implementation`),await this.cleanupResources(),this.connected=!1,o.debug(`Disconnected from MCP implementation`)}get isClientConnected(){return this.client!=null}async initialize(e=this.opts.defaultRequestOptions??{}){if(!this.client)throw Error(`MCP client is not connected`);o.debug(`Caching server capabilities & tools`);let t=this.client.getServerCapabilities();this.capabilitiesCache=t||null;let n=this.client.getServerVersion();this.serverInfoCache=n||null;try{this.toolsCache=(await this.client.listTools(void 0,e)).tools??[],o.debug(`Fetched ${this.toolsCache.length} tools from server`)}catch(e){let t=e;t.code===-32601?o.debug(`Server does not implement tools/list, assuming no tools`):o.debug(`Failed to list tools, assuming empty:`,t.message),this.toolsCache=[]}return o.debug(`Server capabilities:`,t),o.debug(`Server info:`,n),t}get tools(){if(!this.toolsCache)throw Error(`MCP client is not initialized; call initialize() first`);return this.toolsCache}get serverCapabilities(){return this.capabilitiesCache||{}}get serverInfo(){return this.serverInfoCache}async callTool(e,t,n){if(!this.client)throw Error(`MCP client is not connected`);let r=n?{...n}:void 0;r?.resetTimeoutOnProgress&&!r.onprogress&&(r.onprogress=()=>{},o.debug(`[BaseConnector] Added onprogress callback for tool '${e}' to enable progressToken`)),o.debug(`Calling tool '${e}' with args`,t);let i=await this.client.callTool({name:e,arguments:t},void 0,r);return o.debug(`Tool '${e}' returned`,i),i}async listTools(e){if(!this.client)throw Error(`MCP client is not connected`);o.debug(`[listTools] Fetching fresh tools from server...`);let t=await this.client.listTools(void 0,e),n=t.tools?[...t.tools]:[];return o.debug(`[listTools] Returned ${n.length} tools:`,n.map(e=>e.name)),n}async listResources(e,t){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Listing resources`,e?`with cursor: ${e}`:``),await this.client.listResources({cursor:e},t)}async listAllResources(e){if(!this.client)throw Error(`MCP client is not connected`);if(!this.capabilitiesCache?.resources)return o.debug(`Server does not advertise resources capability, skipping`),{resources:[]};try{o.debug(`Listing all resources (with auto-pagination)`);let t=[],n;do{let r=await this.client.listResources({cursor:n},e);t.push(...r.resources||[]),n=r.nextCursor}while(n);return{resources:t}}catch(e){if(e.code===-32601)return o.debug(`Server advertised resources but method not found`),{resources:[]};throw e}}async listResourceTemplates(e){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Listing resource templates`),await this.client.listResourceTemplates(void 0,e)}async complete(e,t){if(!this.client)throw Error(`MCP client is not connected`);o.debug(`[complete] Requesting completions for:`,e.ref);let n=await this.client.complete(e,t);return o.debug(`[complete] Received ${n.completion.values.length} suggestions`),n}async readResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Reading resource ${e}`),await this.client.readResource({uri:e},t)}async subscribeToResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Subscribing to resource: ${e}`),await this.client.subscribeResource({uri:e},t)}async unsubscribeFromResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Unsubscribing from resource: ${e}`),await this.client.unsubscribeResource({uri:e},t)}async listPrompts(){if(!this.client)throw Error(`MCP client is not connected`);if(!this.capabilitiesCache?.prompts)return o.debug(`Server does not advertise prompts capability, skipping`),{prompts:[]};try{return o.debug(`Listing prompts`),await this.client.listPrompts()}catch(e){if(e.code===-32601)return o.debug(`Server advertised prompts but method not found`),{prompts:[]};throw e}}async getPrompt(e,t){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Getting prompt ${e}`),await this.client.getPrompt({name:e,arguments:t})}async request(e,t=null,n){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Sending raw request '${e}' with params`,t),await this.client.request({method:e,params:t??{}},void 0,n)}async cleanupResources(){let e=[];if(this.client)try{typeof this.client.close==`function`&&await this.client.close()}catch(t){let n=`Error closing client: ${t}`;o.warn(n),e.push(n)}finally{this.client=null}if(this.connectionManager)try{await this.connectionManager.stop()}catch(t){let n=`Error stopping connection manager: ${t}`;o.warn(n),e.push(n)}finally{this.connectionManager=null}this.toolsCache=null,e.length&&o.warn(`Resource cleanup finished with ${e.length} issue(s)`)}},N_=class{static{a(this,`ConnectionManager`)}_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),o.debug(`Starting ${this.constructor.name}`),this._task=this.connectionTask(),await this._readyPromise,this._exception)throw this._exception;if(this._connection===null)throw Error(`Connection was not established`);return this._connection}async stop(){if(this._task&&this._abortController){o.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(e){e instanceof Error&&e.name===`AbortError`?o.debug(`${this.constructor.name} task aborted successfully`):o.warn(`Error stopping ${this.constructor.name} task: ${e}`)}}await this._donePromise,o.debug(`${this.constructor.name} task completed`)}reset(){this._readyPromise=new Promise(e=>this._readyResolver=e),this._donePromise=new Promise(e=>this._doneResolver=e),this._exception=null,this._connection=null,this._task=null,this._abortController=new AbortController}async connectionTask(){o.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),o.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(e){this._exception=e,o.error(`Error in ${this.constructor.name} task: ${e}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(e){o.warn(`Error closing connection in ${this.constructor.name}: ${e}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((e,t)=>{if(!this._abortController)return;let n=this._abortController.signal;if(n.aborted){e();return}let r=a(()=>{n.removeEventListener(`abort`,r),e()},`onAbort`);n.addEventListener(`abort`,r)})}},P_=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),F_=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=P_(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),Q=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=P_(),n=F_(),r=P_();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=F_();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=ie(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ie(this.rhs,e,n),this}get names(){return re(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=ie(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(ae(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>w(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(oe(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=ie(this.condition,e,t),this}get names(){let e=super.names;return re(e,this.condition),this.else&&w(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=ie(this.iteration,e,t),this}get names(){return w(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return re(re(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=ie(this.iterable,e,t),this}get names(){return w(super.names,this.iterable.names)}},ee=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};ee.kind=`func`;var S=class extends p{render(e){return`return `+super.render(e)}};S.kind=`return`;var C=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&w(e,this.catch.names),this.finally&&w(e,this.finally.names),e}},te=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};te.kind=`catch`;var ne=class extends m{render(e){return`finally`+super.render(e)}};ne.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
61
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:N.string().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:N.string().optional().describe(`User's timezone in IANA format.`),userAgent:N.string().optional().describe(`Host application identifier.`),platform:N.union([N.literal(`web`),N.literal(`desktop`),N.literal(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:N.object({touch:N.boolean().optional().describe(`Whether the device supports touch input.`),hover:N.boolean().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:N.object({top:N.number().describe(`Top safe area inset in pixels.`),right:N.number().describe(`Right safe area inset in pixels.`),bottom:N.number().describe(`Bottom safe area inset in pixels.`),left:N.number().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();N.object({method:N.literal(`ui/notifications/host-context-changed`),params:t_.describe(`Partial context update containing only changed fields.`)}),N.object({method:N.literal(`ui/update-model-context`),params:N.object({content:N.array(Bt).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:N.record(N.string(),N.unknown().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),N.object({method:N.literal(`ui/initialize`),params:N.object({appInfo:Ae.describe(`App identification (name and version).`),appCapabilities:$g.describe(`Features and capabilities this app provides.`),protocolVersion:N.string().describe(`Protocol version this app supports.`)})}),N.object({protocolVersion:N.string().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Ae.describe(`Host application identification and version.`),hostCapabilities:Qg.describe(`Features and capabilities provided by the host.`),hostContext:t_.describe(`Rich context about the host environment.`)}).passthrough();var n_=`text/html;profile=mcp-app`,r_=`1.22.2`;function i_(){return r_}a(i_,`getPackageVersion`);var a_=class{static{a(this,`BaseTelemetryEvent`)}},o_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`MCPAgentExecutionEvent`)}get name(){return`mcp_agent_execution`}get properties(){return{execution_method:this.data.executionMethod,query:this.data.query,query_length:this.data.query.length,success:this.data.success,model_provider:this.data.modelProvider,model_name:this.data.modelName,server_count:this.data.serverCount,server_identifiers:this.data.serverIdentifiers,total_tools_available:this.data.totalToolsAvailable,tools_available_names:this.data.toolsAvailableNames,max_steps_configured:this.data.maxStepsConfigured,memory_enabled:this.data.memoryEnabled,use_server_manager:this.data.useServerManager,max_steps_used:this.data.maxStepsUsed,manage_connector:this.data.manageConnector,external_history_used:this.data.externalHistoryUsed,steps_taken:this.data.stepsTaken??null,tools_used_count:this.data.toolsUsedCount??null,tools_used_names:this.data.toolsUsedNames??null,response:this.data.response??null,response_length:this.data.response?this.data.response.length:null,execution_time_ms:this.data.executionTimeMs??null,error_type:this.data.errorType??null,conversation_history_length:this.data.conversationHistoryLength??null}}};function s_(e,t){let n=Array.from(e.registrations.tools.values()),r=Array.from(e.registrations.prompts.values()),i=Array.from(e.registrations.resources.values()),a=Array.from(e.registrations.resourceTemplates.values()),o=i.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null,uri:e.config.uri??null,mime_type:e.config.mimeType??null})),s=o.filter(e=>e.mime_type===`text/html+skybridge`),c=o.filter(e=>e.mime_type===`text/uri-list`||e.mime_type===`text/html`),l=o.filter(e=>e.mime_type===n_);return{transport:t,toolsNumber:e.registeredTools.length,resourcesNumber:e.registeredResources.length,promptsNumber:e.registeredPrompts.length,auth:!!e.oauthProvider,name:e.config.name,description:e.config.description??null,baseUrl:e.serverBaseUrl??null,toolNames:e.registeredTools.length>0?e.registeredTools:null,resourceNames:e.registeredResources.length>0?e.registeredResources:null,promptNames:e.registeredPrompts.length>0?e.registeredPrompts:null,tools:n.length>0?n.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null,input_schema:e.config.schema?JSON.stringify(e.config.schema):null,output_schema:e.config.outputSchema?JSON.stringify(e.config.outputSchema):null})):null,resources:o.length>0?o:null,prompts:r.length>0?r.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null,args:e.config.args?JSON.stringify(e.config.args):null})):null,templates:a.length>0?a.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null})):null,capabilities:{logging:!0,resources:{subscribe:!0,listChanged:!0}},appsSdkResources:s.length>0?s:null,appsSdkResourcesNumber:s.length,mcpUiResources:c.length>0?c:null,mcpUiResourcesNumber:c.length,mcpAppsResources:l.length>0?l:null,mcpAppsResourcesNumber:l.length}}a(s_,`createServerRunEventData`);var c_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ServerRunEvent`)}get name(){return`server_run`}get properties(){return{transport:this.data.transport,tools_number:this.data.toolsNumber,resources_number:this.data.resourcesNumber,prompts_number:this.data.promptsNumber,auth:this.data.auth,name:this.data.name,description:this.data.description??null,base_url:this.data.baseUrl??null,tool_names:this.data.toolNames??null,resource_names:this.data.resourceNames??null,prompt_names:this.data.promptNames??null,tools:this.data.tools??null,resources:this.data.resources??null,prompts:this.data.prompts??null,templates:this.data.templates??null,capabilities:this.data.capabilities?JSON.stringify(this.data.capabilities):null,apps_sdk_resources:this.data.appsSdkResources?JSON.stringify(this.data.appsSdkResources):null,apps_sdk_resources_number:this.data.appsSdkResourcesNumber??0,mcp_ui_resources:this.data.mcpUiResources?JSON.stringify(this.data.mcpUiResources):null,mcp_ui_resources_number:this.data.mcpUiResourcesNumber??0,mcp_apps_resources:this.data.mcpAppsResources?JSON.stringify(this.data.mcpAppsResources):null,mcp_apps_resources_number:this.data.mcpAppsResourcesNumber??0}}},l_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ServerInitializeEvent`)}get name(){return`server_initialize_call`}get properties(){return{protocol_version:this.data.protocolVersion,client_info:JSON.stringify(this.data.clientInfo),client_capabilities:JSON.stringify(this.data.clientCapabilities),session_id:this.data.sessionId??null}}},u_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ServerToolCallEvent`)}get name(){return`server_tool_call`}get properties(){return{tool_name:this.data.toolName,length_input_argument:this.data.lengthInputArgument,success:this.data.success,error_type:this.data.errorType??null,execution_time_ms:this.data.executionTimeMs??null}}},d_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ServerResourceCallEvent`)}get name(){return`server_resource_call`}get properties(){return{name:this.data.name,description:this.data.description,contents:this.data.contents,success:this.data.success,error_type:this.data.errorType??null}}},f_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ServerPromptCallEvent`)}get name(){return`server_prompt_call`}get properties(){return{name:this.data.name,description:this.data.description,success:this.data.success,error_type:this.data.errorType??null}}},p_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ServerContextEvent`)}get name(){return`server_context_${this.data.contextType}`}get properties(){return{context_type:this.data.contextType,notification_type:this.data.notificationType??null}}},m_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`MCPClientInitEvent`)}get name(){return`mcpclient_init`}get properties(){return{code_mode:this.data.codeMode,sandbox:this.data.sandbox,all_callbacks:this.data.allCallbacks,verify:this.data.verify,servers:this.data.servers,num_servers:this.data.numServers,is_browser:this.data.isBrowser}}},h_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ConnectorInitEvent`)}get name(){return`connector_init`}get properties(){return{connector_type:this.data.connectorType,server_command:this.data.serverCommand??null,server_args:this.data.serverArgs??null,server_url:this.data.serverUrl??null,public_identifier:this.data.publicIdentifier??null}}},g_=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ClientAddServerEvent`)}get name(){return`client_add_server`}get properties(){let{serverName:e,serverConfig:t}=this.data,n=t.url;return{server_name:e,server_url_domain:n?this._extractHostname(n):null,transport:t.transport??null,has_auth:!!(t.authToken||t.authProvider)}}_extractHostname(e){try{return new URL(e).hostname}catch{return null}}},__=class extends a_{constructor(e){super(),this.data=e}static{a(this,`ClientRemoveServerEvent`)}get name(){return`client_remove_server`}get properties(){return{server_name:this.data.serverName}}};function v_(e){return e._llm_type||e.constructor.name.toLowerCase()}a(v_,`getModelProvider`);function y_(e){if(`_identifyingParams`in e){let t=e._identifyingParams;if(typeof t==`object`&&t){for(let e of[`model`,`modelName`,`model_name`,`modelId`,`model_id`,`deploymentName`,`deployment_name`])if(e in t)return String(t[e])}}return e.model||e.modelName||e.constructor.name}a(y_,`getModelName`);function b_(e){return[v_(e),y_(e)]}a(b_,`extractModelInfo`);function x_(){if(typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.randomUUID==`function`)return globalThis.crypto.randomUUID();if(typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues==`function`){let e=new Uint8Array(16);globalThis.crypto.getRandomValues(e);let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.substring(0,8)}-${t.substring(8,12)}-${t.substring(12,16)}-${t.substring(16,20)}-${t.substring(20)}`}return`${Date.now()}-${Math.random().toString(36).substring(2,15)}-${Math.random().toString(36).substring(2,15)}`}a(x_,`generateUUID`);function S_(){if(typeof window<`u`&&window.crypto&&typeof window.crypto.getRandomValues==`function`){let e=new Uint8Array(8);return window.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}if(typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues==`function`){let e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}return Math.random().toString(36).substring(2,15)}a(S_,`secureRandomString`);var C_=`mcp_use_user_id`;function w_(){return typeof localStorage<`u`&&typeof localStorage.getItem==`function`&&typeof localStorage.setItem==`function`&&typeof localStorage.removeItem==`function`}a(w_,`isLocalStorageFunctional`);function T_(){try{return typeof window<`u`&&typeof document<`u`?`browser`:`unknown`}catch{return`unknown`}}a(T_,`detectRuntimeEnvironment`);function E_(e){if(e===`browser`)try{if(w_())return localStorage.setItem(`__mcp_use_test__`,`1`),localStorage.removeItem(`__mcp_use_test__`),`localStorage`}catch{}return`session-only`}a(E_,`getStorageCapability`);var D_=null;function O_(){return D_===null&&(D_=T_()),D_}a(O_,`getRuntimeEnvironment`);var k_=class e{static{a(this,`Telemetry`)}static instance=null;PROJECT_API_KEY=`phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI`;HOST=`https://eu.i.posthog.com`;UNKNOWN_USER_ID=`UNKNOWN_USER_ID`;_currUserId=null;_posthogBrowserClient=null;_posthogLoading=null;_runtimeEnvironment;_storageCapability;_source;constructor(){this._runtimeEnvironment=O_(),this._storageCapability=E_(this._runtimeEnvironment),this._source=this._getSourceFromLocalStorage()||this._runtimeEnvironment;let e=this._checkTelemetryDisabled(),t=this._runtimeEnvironment!==`unknown`;e?(this._posthogBrowserClient=null,o.debug(`Telemetry disabled via localStorage`)):t?(o.info(`Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false in localStorage to disable.`),this._posthogLoading=this._initPostHogBrowser()):(this._posthogBrowserClient=null,o.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`))}_getSourceFromLocalStorage(){try{if(w_())return localStorage.getItem(`MCP_USE_TELEMETRY_SOURCE`)}catch{}return null}_checkTelemetryDisabled(){return!!(w_()&&localStorage.getItem(`MCP_USE_ANONYMIZED_TELEMETRY`)===`false`)}async _initPostHogBrowser(){try{let e=await te(()=>import(`./module-DCsrdi7m.js`),[]),t=e.default||e.posthog;if(!t||typeof t.init!=`function`)throw Error(`posthog-js module did not export expected interface`);t.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:`localStorage`,autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:a(()=>{o.debug(`PostHog browser client initialized`)},`loaded`)}),this._posthogBrowserClient=t}catch(e){o.warn(`Failed to initialize PostHog browser telemetry: ${e}`),this._posthogBrowserClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return e.instance||=new e,e.instance}setSource(e){this._source=e;try{w_()&&localStorage.setItem(`MCP_USE_TELEMETRY_SOURCE`,e)}catch{}o.debug(`Telemetry source set to: ${e}`)}getSource(){return this._source}get isEnabled(){return this._posthogBrowserClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case`localStorage`:this._currUserId=this._getUserIdFromLocalStorage();break;default:try{this._currUserId=`session-${x_()}`}catch{this._currUserId=`session-${Date.now()}-${S_()}`}break}}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromLocalStorage(){try{if(!w_())throw Error(`localStorage is not available or not functional`);localStorage.setItem(`__mcp_use_test__`,`1`),localStorage.removeItem(`__mcp_use_test__`);let e=localStorage.getItem(C_);if(!e){try{e=x_()}catch{e=`${Date.now()}-${S_()}`}localStorage.setItem(C_,e)}return e}catch(e){o.debug(`Failed to access localStorage for user ID: ${e}`);let t;try{t=`session-${x_()}`}catch{t=`session-${Date.now()}-${S_()}`}return t}}async capture(e){if(this._posthogLoading&&await this._posthogLoading,!this._posthogBrowserClient)return;let t=this.userId,n={...e.properties};if(n.mcp_use_version=i_(),n.language=`typescript`,n.source=this._source,n.runtime=this._runtimeEnvironment,this._posthogBrowserClient)try{this._posthogBrowserClient.capture(e.name,{...n,distinct_id:t})}catch(t){o.debug(`Failed to track PostHog Browser event ${e.name}: ${t}`)}}async trackAgentExecution(e){if(!this.isEnabled)return;let t=new o_(e);await this.capture(t)}async trackServerRunFromServer(e,t){if(!this.isEnabled)return;let n=new c_(s_(e,t));await this.capture(n)}async trackServerInitialize(e){if(!this.isEnabled)return;let t=new l_(e);await this.capture(t)}async trackServerToolCall(e){if(!this.isEnabled)return;let t=new u_(e);await this.capture(t)}async trackServerResourceCall(e){if(!this.isEnabled)return;let t=new d_(e);await this.capture(t)}async trackServerPromptCall(e){if(!this.isEnabled)return;let t=new f_(e);await this.capture(t)}async trackServerContext(e){if(!this.isEnabled)return;let t=new p_(e);await this.capture(t)}async trackMCPClientInit(e){if(!this.isEnabled)return;let t=new m_(e);await this.capture(t)}async trackConnectorInit(e){if(!this.isEnabled)return;let t=new h_(e);await this.capture(t)}async trackClientAddServer(e,t){if(!this.isEnabled)return;let n=new g_({serverName:e,serverConfig:t});await this.capture(n)}async trackClientRemoveServer(e){if(!this.isEnabled)return;let t=new __({serverName:e});await this.capture(t)}async trackUseMcpConnection(e){this.isEnabled&&await this.capture({name:`usemcp_connection`,properties:{url_domain:new URL(e.url).hostname,transport_type:e.transportType,success:e.success,error_type:e.errorType??null,connection_time_ms:e.connectionTimeMs??null,has_oauth:e.hasOAuth,has_sampling:e.hasSampling,has_elicitation:e.hasElicitation}})}async trackUseMcpToolCall(e){this.isEnabled&&await this.capture({name:`usemcp_tool_call`,properties:{tool_name:e.toolName,success:e.success,error_type:e.errorType??null,execution_time_ms:e.executionTimeMs??null}})}async trackUseMcpResourceRead(e){this.isEnabled&&await this.capture({name:`usemcp_resource_read`,properties:{resource_uri_scheme:e.resourceUri.split(`:`)[0],success:e.success,error_type:e.errorType??null}})}identify(e,t){if(this._posthogBrowserClient)try{this._posthogBrowserClient.identify(e,t)}catch(e){o.debug(`Failed to identify user: ${e}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(e){o.debug(`Failed to reset user: ${e}`)}this._currUserId=null}flush(){}shutdown(){}async trackPackageDownload(e){}},A_=k_;function j_(e){A_.getInstance().setSource(e)}a(j_,`setTelemetrySource`);var M_=class{static{a(this,`BaseConnector`)}client=null;connectionManager=null;toolsCache=null;capabilitiesCache=null;serverInfoCache=null;connected=!1;opts;notificationHandlers=[];rootsCache=[];constructor(e={}){let t={...e,onSampling:e.onSampling??e.samplingCallback,onElicitation:e.onElicitation??e.elicitationCallback};e.samplingCallback&&!e.onSampling&&o.warn(`[BaseConnector] The "samplingCallback" option is deprecated. Use "onSampling" instead.`),e.elicitationCallback&&!e.onElicitation&&console.warn(`[BaseConnector] The "elicitationCallback" option is deprecated. Use "onElicitation" instead.`),this.opts=t,t.roots&&(this.rootsCache=[...t.roots]),t.onNotification&&this.notificationHandlers.push(t.onNotification)}trackConnectorInit(e){let t=this.constructor.name;k_.getInstance().trackConnectorInit({connectorType:t,...e}).catch(e=>o.debug(`Failed to track connector init: ${e}`))}onNotification(e){this.notificationHandlers.push(e),this.client&&this.setupNotificationHandler()}setupNotificationHandler(){if(!this.client)return;let e=a(async e=>{for(let t of this.notificationHandlers)try{await t(e)}catch(e){o.error(`Error in notification handler:`,e)}},`forwardToUserHandlers`);this.client.fallbackNotificationHandler=async t=>{switch(t.method){case`notifications/tools/list_changed`:await this.refreshToolsCache();break;case`notifications/resources/list_changed`:await this.onResourcesListChanged();break;case`notifications/prompts/list_changed`:await this.onPromptsListChanged();break;default:break}await e(t)};let t=this.client._notificationHandlers;for(let n of[`notifications/progress`,`notifications/cancelled`]){let r=t.get(n);r&&t.set(n,async t=>{await r(t),await e(t)})}}async refreshToolsCache(){if(this.client)try{o.debug(`[Auto] Refreshing tools cache due to list_changed notification`),this.toolsCache=(await this.client.listTools()).tools??[],o.debug(`[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`)}catch(e){o.warn(`[Auto] Failed to refresh tools cache:`,e)}}async onResourcesListChanged(){o.debug(`[Auto] Resources list changed - clients should re-fetch if needed`)}async onPromptsListChanged(){o.debug(`[Auto] Prompts list changed - clients should re-fetch if needed`)}async setRoots(e){this.rootsCache=[...e],this.client&&(o.debug(`Sending roots/list_changed notification with ${e.length} root(s)`),await this.client.sendRootsListChanged())}getRoots(){return[...this.rootsCache]}setupRootsHandler(){this.client&&this.client.setRequestHandler(Nn,async(e,t)=>(o.debug(`Server requested roots list, returning ${this.rootsCache.length} root(s)`),{roots:this.rootsCache}))}setupSamplingHandler(){if(!this.client){o.debug(`setupSamplingHandler: No client available`);return}let e=this.opts.onSampling??this.opts.samplingCallback;if(!e){o.debug(`setupSamplingHandler: No sampling callback provided`);return}o.debug(`setupSamplingHandler: Setting up sampling request handler`),this.client.setRequestHandler(pn,async(t,n)=>(o.debug(`Server requested sampling, forwarding to callback`),await e(t.params))),o.debug(`setupSamplingHandler: Sampling handler registered successfully`)}setupElicitationHandler(){if(!this.client){o.debug(`setupElicitationHandler: No client available`);return}let e=this.opts.onElicitation??this.opts.elicitationCallback;if(!e){o.debug(`setupElicitationHandler: No elicitation callback provided`);return}o.debug(`setupElicitationHandler: Setting up elicitation request handler`),this.client.setRequestHandler(Cn,async(t,n)=>(o.debug(`Server requested elicitation, forwarding to callback`),await e(t.params))),o.debug(`setupElicitationHandler: Elicitation handler registered successfully`)}async disconnect(){if(!this.connected){o.debug(`Not connected to MCP implementation`);return}o.debug(`Disconnecting from MCP implementation`),await this.cleanupResources(),this.connected=!1,o.debug(`Disconnected from MCP implementation`)}get isClientConnected(){return this.client!=null}async initialize(e=this.opts.defaultRequestOptions??{}){if(!this.client)throw Error(`MCP client is not connected`);o.debug(`Caching server capabilities & tools`);let t=this.client.getServerCapabilities();this.capabilitiesCache=t||null;let n=this.client.getServerVersion();this.serverInfoCache=n||null;try{this.toolsCache=(await this.client.listTools(void 0,e)).tools??[],o.debug(`Fetched ${this.toolsCache.length} tools from server`)}catch(e){let t=e;t.code===-32601?o.debug(`Server does not implement tools/list, assuming no tools`):o.debug(`Failed to list tools, assuming empty:`,t.message),this.toolsCache=[]}return o.debug(`Server capabilities:`,t),o.debug(`Server info:`,n),t}get tools(){if(!this.toolsCache)throw Error(`MCP client is not initialized; call initialize() first`);return this.toolsCache}get serverCapabilities(){return this.capabilitiesCache||{}}get serverInfo(){return this.serverInfoCache}async callTool(e,t,n){if(!this.client)throw Error(`MCP client is not connected`);let r=n?{...n}:void 0;r?.resetTimeoutOnProgress&&!r.onprogress&&(r.onprogress=()=>{},o.debug(`[BaseConnector] Added onprogress callback for tool '${e}' to enable progressToken`)),o.debug(`Calling tool '${e}' with args`,t);let i=await this.client.callTool({name:e,arguments:t},void 0,r);return o.debug(`Tool '${e}' returned`,i),i}async listTools(e){if(!this.client)throw Error(`MCP client is not connected`);o.debug(`[listTools] Fetching fresh tools from server...`);let t=await this.client.listTools(void 0,e),n=t.tools?[...t.tools]:[];return o.debug(`[listTools] Returned ${n.length} tools:`,n.map(e=>e.name)),n}async listResources(e,t){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Listing resources`,e?`with cursor: ${e}`:``),await this.client.listResources({cursor:e},t)}async listAllResources(e){if(!this.client)throw Error(`MCP client is not connected`);if(!this.capabilitiesCache?.resources)return o.debug(`Server does not advertise resources capability, skipping`),{resources:[]};try{o.debug(`Listing all resources (with auto-pagination)`);let t=[],n;do{let r=await this.client.listResources({cursor:n},e);t.push(...r.resources||[]),n=r.nextCursor}while(n);return{resources:t}}catch(e){if(e.code===-32601)return o.debug(`Server advertised resources but method not found`),{resources:[]};throw e}}async listResourceTemplates(e){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Listing resource templates`),await this.client.listResourceTemplates(void 0,e)}async complete(e,t){if(!this.client)throw Error(`MCP client is not connected`);o.debug(`[complete] Requesting completions for:`,e.ref);let n=await this.client.complete(e,t);return o.debug(`[complete] Received ${n.completion.values.length} suggestions`),n}async readResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Reading resource ${e}`),await this.client.readResource({uri:e},t)}async subscribeToResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Subscribing to resource: ${e}`),await this.client.subscribeResource({uri:e},t)}async unsubscribeFromResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Unsubscribing from resource: ${e}`),await this.client.unsubscribeResource({uri:e},t)}async listPrompts(){if(!this.client)throw Error(`MCP client is not connected`);if(!this.capabilitiesCache?.prompts)return o.debug(`Server does not advertise prompts capability, skipping`),{prompts:[]};try{return o.debug(`Listing prompts`),await this.client.listPrompts()}catch(e){if(e.code===-32601)return o.debug(`Server advertised prompts but method not found`),{prompts:[]};throw e}}async getPrompt(e,t){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Getting prompt ${e}`),await this.client.getPrompt({name:e,arguments:t})}async request(e,t=null,n){if(!this.client)throw Error(`MCP client is not connected`);return o.debug(`Sending raw request '${e}' with params`,t),await this.client.request({method:e,params:t??{}},void 0,n)}async cleanupResources(){let e=[];if(this.client)try{typeof this.client.close==`function`&&await this.client.close()}catch(t){let n=`Error closing client: ${t}`;o.warn(n),e.push(n)}finally{this.client=null}if(this.connectionManager)try{await this.connectionManager.stop()}catch(t){let n=`Error stopping connection manager: ${t}`;o.warn(n),e.push(n)}finally{this.connectionManager=null}this.toolsCache=null,e.length&&o.warn(`Resource cleanup finished with ${e.length} issue(s)`)}},N_=class{static{a(this,`ConnectionManager`)}_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),o.debug(`Starting ${this.constructor.name}`),this._task=this.connectionTask(),await this._readyPromise,this._exception)throw this._exception;if(this._connection===null)throw Error(`Connection was not established`);return this._connection}async stop(){if(this._task&&this._abortController){o.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(e){e instanceof Error&&e.name===`AbortError`?o.debug(`${this.constructor.name} task aborted successfully`):o.warn(`Error stopping ${this.constructor.name} task: ${e}`)}}await this._donePromise,o.debug(`${this.constructor.name} task completed`)}reset(){this._readyPromise=new Promise(e=>this._readyResolver=e),this._donePromise=new Promise(e=>this._doneResolver=e),this._exception=null,this._connection=null,this._task=null,this._abortController=new AbortController}async connectionTask(){o.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),o.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(e){this._exception=e,o.error(`Error in ${this.constructor.name} task: ${e}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(e){o.warn(`Error closing connection in ${this.constructor.name}: ${e}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((e,t)=>{if(!this._abortController)return;let n=this._abortController.signal;if(n.aborted){e();return}let r=a(()=>{n.removeEventListener(`abort`,r),e()},`onAbort`);n.addEventListener(`abort`,r)})}},P_=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),F_=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=P_(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),Q=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=P_(),n=F_(),r=P_();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=F_();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=ie(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ie(this.rhs,e,n),this}get names(){return re(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=ie(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(ae(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>w(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(oe(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=ie(this.condition,e,t),this}get names(){let e=super.names;return re(e,this.condition),this.else&&w(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=ie(this.iteration,e,t),this}get names(){return w(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return re(re(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=ie(this.iterable,e,t),this}get names(){return w(super.names,this.iterable.names)}},ee=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};ee.kind=`func`;var S=class extends p{render(e){return`return `+super.render(e)}};S.kind=`return`;var C=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&w(e,this.catch.names),this.finally&&w(e,this.finally.names),e}},te=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};te.kind=`catch`;var ne=class extends m{render(e){return`finally`+super.render(e)}};ne.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
62
62
|
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new S;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(S)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new C;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new te(e),t(e)}return n&&(this._currNode=r.finally=new ne,this.code(n)),this._endBlockNode(te,ne)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new ee(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(ee)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function w(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function re(e,n){return n instanceof t._CodeOrName?w(e,n.names):e}function ie(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function ae(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function oe(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${de(e)}`}e.not=oe;var se=ue(e.operators.AND);function T(...e){return e.reduce(se)}e.and=T;var ce=ue(e.operators.OR);function le(...e){return e.reduce(ce)}e.or=le;function ue(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${de(n)} ${e} ${de(r)}`}function de(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),$=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=Q(),n=P_();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),I_=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=Q();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),L_=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=Q(),n=$(),r=I_();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),R_=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=L_(),n=Q(),r=I_(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),z_=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),B_=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),V_=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=z_(),n=B_(),r=L_(),i=Q(),a=$(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
63
63
|
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
64
64
|
|| (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
|