@sap-ux/fiori-mcp-server 0.6.48 → 0.6.49
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/index.js +1 -1
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -1499,7 +1499,7 @@ ${n.message}`:d,S=[E,t,e].filter(Boolean).join(`
|
|
|
1499
1499
|
|
|
1500
1500
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let s=o[1];if(t===o[0]){a(o);continue}if(e.external){let u=e.external.registry.get(o[0])?.id;if(t!==o[0]&&u){a(o);continue}}if(e.metadataRegistry.get(o[0])?.id){a(o);continue}if(s.cycle){a(o);continue}if(s.count>1&&e.reused==="ref"){a(o);continue}}}function T_(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=o=>{let s=e.seen.get(o);if(s.ref===null)return;let c=s.def??s.schema,u={...c},l=s.ref;if(s.ref=null,l){n(l);let f=e.seen.get(l),h=f.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(h)):Object.assign(c,h),Object.assign(c,u),o._zod.parent===l)for(let g in c)g==="$ref"||g==="allOf"||g in u||delete c[g];if(h.$ref&&f.def)for(let g in c)g==="$ref"||g==="allOf"||g in f.def&&JSON.stringify(c[g])===JSON.stringify(f.def[g])&&delete c[g]}let p=o._zod.parent;if(p&&p!==l){n(p);let f=e.seen.get(p);if(f?.schema.$ref&&(c.$ref=f.schema.$ref,f.def))for(let h in c)h==="$ref"||h==="allOf"||h in f.def&&JSON.stringify(c[h])===JSON.stringify(f.def[h])&&delete c[h]}e.override({zodSchema:o,jsonSchema:c,path:s.path??[]})};for(let o of[...e.seen.entries()].reverse())n(o[0]);let i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let o=e.external.registry.get(t)?.id;if(!o)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(o)}Object.assign(i,r.def??r.schema);let a=e.external?.defs??{};for(let o of e.seen.entries()){let s=o[1];s.def&&s.defId&&(a[s.defId]=s.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?i.$defs=a:i.definitions=a);try{let o=JSON.parse(JSON.stringify(i));return Object.defineProperty(o,"~standard",{value:{...t["~standard"],jsonSchema:{input:kC(t,"input",e.processors),output:kC(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch{throw new Error("Error converting schema to JSON.")}}function tu(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return tu(n.element,r);if(n.type==="set")return tu(n.valueType,r);if(n.type==="lazy")return tu(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return tu(n.innerType,r);if(n.type==="intersection")return tu(n.left,r)||tu(n.right,r);if(n.type==="record"||n.type==="map")return tu(n.keyType,r)||tu(n.valueType,r);if(n.type==="pipe")return tu(n.in,r)||tu(n.out,r);if(n.type==="object"){for(let i in n.shape)if(tu(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(let i of n.options)if(tu(i,r))return!0;return!1}if(n.type==="tuple"){for(let i of n.items)if(tu(i,r))return!0;return!!(n.rest&&tu(n.rest,r))}return!1}var yae=(e,t={})=>r=>{let n=__({...r,processors:t});return ti(e,n),E_(n,e),T_(n,e)},kC=(e,t,r={})=>n=>{let{libraryOptions:i,target:a}=n??{},o=__({...i??{},target:a,io:t,processors:r});return ti(e,o),E_(o,e),T_(o,e)};var Efr={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vae=(e,t,r,n)=>{let i=r;i.type="string";let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof a=="number"&&(i.minLength=a),typeof o=="number"&&(i.maxLength=o),s&&(i.format=Efr[s]??s,i.format===""&&delete i.format,s==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?i.pattern=l[0].source:l.length>1&&(i.allOf=[...l.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},_ae=(e,t,r,n)=>{let i=r,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?i.type="integer":i.type="number",typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l),typeof a=="number"&&(i.minimum=a,typeof l=="number"&&t.target!=="draft-04"&&(l>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof o=="number"&&(i.maximum=o,typeof u=="number"&&t.target!=="draft-04"&&(u<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},Eae=(e,t,r,n)=>{r.type="boolean"},Tae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},Sae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},bae=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},Aae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},Oae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Cae=(e,t,r,n)=>{r.not={}},xae=(e,t,r,n)=>{},Pae=(e,t,r,n)=>{},Dae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Nae=(e,t,r,n)=>{let i=e._zod.def,a=KI(i.entries);a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),r.enum=a},Rae=(e,t,r,n)=>{let i=e._zod.def,a=[];for(let o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(o))}else a.push(o);if(a.length!==0)if(a.length===1){let o=a[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),a.every(o=>typeof o=="boolean")&&(r.type="boolean"),a.every(o=>o===null)&&(r.type="null"),r.enum=a},Iae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},wae=(e,t,r,n)=>{let i=r,a=e._zod.pattern;if(!a)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=a.source},Lae=(e,t,r,n)=>{let i=r,a={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(i,a)},Mae=(e,t,r,n)=>{r.type="boolean"},kae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},$ae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Uae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Vae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Fae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},jae=(e,t,r,n)=>{let i=r,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o=="number"&&(i.minItems=o),typeof s=="number"&&(i.maxItems=s),i.type="array",i.items=ti(a.element,t,{...n,path:[...n.path,"items"]})},Bae=(e,t,r,n)=>{let i=r,a=e._zod.def;i.type="object",i.properties={};let o=a.shape;for(let u in o)i.properties[u]=ti(o[u],t,{...n,path:[...n.path,"properties",u]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(u=>{let l=a.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type==="never"?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=ti(a.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},YG=(e,t,r,n)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((s,c)=>ti(s,t,{...n,path:[...n.path,a?"oneOf":"anyOf",c]}));a?r.oneOf=o:r.anyOf=o},qae=(e,t,r,n)=>{let i=e._zod.def,a=ti(i.left,t,{...n,path:[...n.path,"allOf",0]}),o=ti(i.right,t,{...n,path:[...n.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];r.allOf=c},Gae=(e,t,r,n)=>{let i=r,a=e._zod.def;i.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=a.items.map((f,h)=>ti(f,t,{...n,path:[...n.path,o,h]})),u=a.rest?ti(a.rest,t,{...n,path:[...n.path,s,...t.target==="openapi-3.0"?[a.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=c,u&&(i.items=u)):t.target==="openapi-3.0"?(i.items={anyOf:c},u&&i.items.anyOf.push(u),i.minItems=c.length,u||(i.maxItems=c.length)):(i.items=c,u&&(i.additionalItems=u));let{minimum:l,maximum:p}=e._zod.bag;typeof l=="number"&&(i.minItems=l),typeof p=="number"&&(i.maxItems=p)},Hae=(e,t,r,n)=>{let i=r,a=e._zod.def;i.type="object";let o=a.keyType,c=o._zod.bag?.patterns;if(a.mode==="loose"&&c&&c.size>0){let l=ti(a.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(let p of c)i.patternProperties[p.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=ti(a.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=ti(a.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=o._zod.values;if(u){let l=[...u].filter(p=>typeof p=="string"||typeof p=="number");l.length>0&&(i.required=l)}},zae=(e,t,r,n)=>{let i=e._zod.def,a=ti(i.innerType,t,n),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=i.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},Yae=(e,t,r,n)=>{let i=e._zod.def;ti(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType},Kae=(e,t,r,n)=>{let i=e._zod.def;ti(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))},Wae=(e,t,r,n)=>{let i=e._zod.def;ti(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Xae=(e,t,r,n)=>{let i=e._zod.def;ti(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},Jae=(e,t,r,n)=>{let i=e._zod.def,a=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ti(a,t,n);let o=t.seen.get(e);o.ref=a},Zae=(e,t,r,n)=>{let i=e._zod.def;ti(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType,r.readOnly=!0},Qae=(e,t,r,n)=>{let i=e._zod.def;ti(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType},KG=(e,t,r,n)=>{let i=e._zod.def;ti(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType},eoe=(e,t,r,n)=>{let i=e._zod.innerType;ti(i,t,n);let a=t.seen.get(e);a.ref=i},zG={string:vae,number:_ae,boolean:Eae,bigint:Tae,symbol:Sae,null:bae,undefined:Aae,void:Oae,never:Cae,any:xae,unknown:Pae,date:Dae,enum:Nae,literal:Rae,nan:Iae,template_literal:wae,file:Lae,success:Mae,custom:kae,function:$ae,transform:Uae,map:Vae,set:Fae,array:jae,object:Bae,union:YG,intersection:qae,tuple:Gae,record:Hae,nullable:zae,nonoptional:Yae,default:Kae,prefault:Wae,catch:Xae,pipe:Jae,readonly:Zae,promise:Qae,optional:KG,lazy:eoe};function S_(e,t){if("_idmap"in e){let n=e,i=__({...t,processors:zG}),a={};for(let c of n._idmap.entries()){let[u,l]=c;ti(l,i)}let o={},s={registry:n,uri:t?.uri,defs:a};i.external=s;for(let c of n._idmap.entries()){let[u,l]=c;E_(i,l),o[u]=T_(i,l)}if(Object.keys(a).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[c]:a}}return{schemas:o}}let r=__({...t,processors:zG});return ti(e,r),E_(r,e),T_(r,e)}var WG=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=__({processors:zG,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return ti(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),E_(this.ctx,t);let n=T_(this.ctx,t),{"~standard":i,...a}=n;return a}};var n2e={};function $C(e){return!!e._zod}function b_(e,t){return $C(e)?LS(e,t):e.safeParse(t)}function XG(e){if(!e)return;let t;if($C(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function o2e(e){if($C(e)){let a=e._zod?.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}var WS={};Za(WS,{$brand:()=>zI,$input:()=>sG,$output:()=>oG,NEVER:()=>CB,TimePrecision:()=>pG,ZodAny:()=>Soe,ZodArray:()=>Coe,ZodBase64:()=>y3,ZodBase64URL:()=>v3,ZodBigInt:()=>qC,ZodBigIntFormat:()=>T3,ZodBoolean:()=>BC,ZodCIDRv4:()=>m3,ZodCIDRv6:()=>g3,ZodCUID:()=>c3,ZodCUID2:()=>u3,ZodCatch:()=>zoe,ZodCodec:()=>x3,ZodCustom:()=>zw,ZodCustomStringFormat:()=>FC,ZodDate:()=>jw,ZodDefault:()=>Foe,ZodDiscriminatedUnion:()=>Poe,ZodE164:()=>_3,ZodEmail:()=>i3,ZodEmoji:()=>o3,ZodEnum:()=>UC,ZodError:()=>aoe,ZodExactOptional:()=>$oe,ZodFile:()=>Moe,ZodFirstPartyTypeKind:()=>ise,ZodFunction:()=>tse,ZodGUID:()=>Mw,ZodIPv4:()=>d3,ZodIPv6:()=>h3,ZodISODate:()=>QG,ZodISODateTime:()=>ZG,ZodISODuration:()=>t3,ZodISOTime:()=>e3,ZodIntersection:()=>Doe,ZodIssueCode:()=>xfr,ZodJWT:()=>E3,ZodKSUID:()=>f3,ZodLazy:()=>Zoe,ZodLiteral:()=>Loe,ZodMAC:()=>voe,ZodMap:()=>Ioe,ZodNaN:()=>Koe,ZodNanoID:()=>s3,ZodNever:()=>Aoe,ZodNonOptional:()=>O3,ZodNull:()=>Toe,ZodNullable:()=>Voe,ZodNumber:()=>jC,ZodNumberFormat:()=>KS,ZodObject:()=>Bw,ZodOptional:()=>A3,ZodPipe:()=>C3,ZodPrefault:()=>Boe,ZodPromise:()=>ese,ZodReadonly:()=>Woe,ZodRealError:()=>qu,ZodRecord:()=>Hw,ZodSet:()=>woe,ZodString:()=>VC,ZodStringFormat:()=>Si,ZodSuccess:()=>Hoe,ZodSymbol:()=>_oe,ZodTemplateLiteral:()=>Joe,ZodTransform:()=>koe,ZodTuple:()=>Noe,ZodType:()=>$r,ZodULID:()=>l3,ZodURL:()=>Uw,ZodUUID:()=>Ih,ZodUndefined:()=>Eoe,ZodUnion:()=>qw,ZodUnknown:()=>boe,ZodVoid:()=>Ooe,ZodXID:()=>p3,ZodXor:()=>xoe,_ZodString:()=>n3,_default:()=>joe,_function:()=>sje,any:()=>Fw,array:()=>or,base64:()=>x2e,base64url:()=>P2e,bigint:()=>V2e,boolean:()=>Mi,catch:()=>Yoe,check:()=>cje,cidrv4:()=>O2e,cidrv6:()=>C2e,clone:()=>Is,codec:()=>ije,coerce:()=>ase,config:()=>ya,core:()=>rp,cuid:()=>y2e,cuid2:()=>v2e,custom:()=>P3,date:()=>H2e,decode:()=>poe,decodeAsync:()=>doe,describe:()=>uje,discriminatedUnion:()=>Gw,e164:()=>D2e,email:()=>c2e,emoji:()=>m2e,encode:()=>loe,encodeAsync:()=>foe,endsWith:()=>jS,enum:()=>pi,exactOptional:()=>Uoe,file:()=>eje,flattenError:()=>vC,float32:()=>M2e,float64:()=>k2e,formatError:()=>_C,fromJSONSchema:()=>mje,function:()=>sje,getErrorMap:()=>Dfr,globalRegistry:()=>ss,gt:()=>Sd,gte:()=>ws,guid:()=>u2e,hash:()=>L2e,hex:()=>w2e,hostname:()=>I2e,httpUrl:()=>h2e,includes:()=>VS,instanceof:()=>pje,int:()=>r3,int32:()=>$2e,int64:()=>F2e,intersection:()=>GC,ipv4:()=>S2e,ipv6:()=>A2e,iso:()=>A_,json:()=>dje,jwt:()=>N2e,keyof:()=>z2e,ksuid:()=>T2e,lazy:()=>Qoe,length:()=>v_,literal:()=>wt,locales:()=>IC,looseObject:()=>Ls,looseRecord:()=>X2e,lowercase:()=>$S,lt:()=>Td,lte:()=>eu,mac:()=>b2e,map:()=>J2e,maxLength:()=>y_,maxSize:()=>qg,meta:()=>lje,mime:()=>BS,minLength:()=>Rh,minSize:()=>bd,multipleOf:()=>Bg,nan:()=>nje,nanoid:()=>g2e,nativeEnum:()=>Q2e,negative:()=>Nw,never:()=>S3,nonnegative:()=>Iw,nonoptional:()=>Goe,nonpositive:()=>Rw,normalize:()=>qS,null:()=>Vw,nullable:()=>kw,nullish:()=>tje,number:()=>On,object:()=>ze,optional:()=>qn,overwrite:()=>Yp,parse:()=>ooe,parseAsync:()=>soe,partialRecord:()=>W2e,pipe:()=>$w,positive:()=>Dw,prefault:()=>qoe,preprocess:()=>Yw,prettifyError:()=>RB,promise:()=>oje,property:()=>ww,readonly:()=>Xoe,record:()=>$n,refine:()=>rse,regex:()=>kS,regexes:()=>Bu,registry:()=>cw,safeDecode:()=>moe,safeDecodeAsync:()=>yoe,safeEncode:()=>hoe,safeEncodeAsync:()=>goe,safeParse:()=>coe,safeParseAsync:()=>uoe,set:()=>Z2e,setErrorMap:()=>Pfr,size:()=>g_,slugify:()=>MC,startsWith:()=>FS,strictObject:()=>Y2e,string:()=>ue,stringFormat:()=>R2e,stringbool:()=>fje,success:()=>rje,superRefine:()=>nse,symbol:()=>B2e,templateLiteral:()=>aje,toJSONSchema:()=>S_,toLowerCase:()=>HS,toUpperCase:()=>zS,transform:()=>b3,treeifyError:()=>NB,trim:()=>GS,tuple:()=>Roe,uint32:()=>U2e,uint64:()=>j2e,ulid:()=>_2e,undefined:()=>q2e,union:()=>Cn,unknown:()=>Bn,uppercase:()=>US,url:()=>a3,util:()=>We,uuid:()=>l2e,uuidv4:()=>p2e,uuidv6:()=>f2e,uuidv7:()=>d2e,void:()=>G2e,xid:()=>E2e,xor:()=>K2e});var Lw={};Za(Lw,{ZodAny:()=>Soe,ZodArray:()=>Coe,ZodBase64:()=>y3,ZodBase64URL:()=>v3,ZodBigInt:()=>qC,ZodBigIntFormat:()=>T3,ZodBoolean:()=>BC,ZodCIDRv4:()=>m3,ZodCIDRv6:()=>g3,ZodCUID:()=>c3,ZodCUID2:()=>u3,ZodCatch:()=>zoe,ZodCodec:()=>x3,ZodCustom:()=>zw,ZodCustomStringFormat:()=>FC,ZodDate:()=>jw,ZodDefault:()=>Foe,ZodDiscriminatedUnion:()=>Poe,ZodE164:()=>_3,ZodEmail:()=>i3,ZodEmoji:()=>o3,ZodEnum:()=>UC,ZodExactOptional:()=>$oe,ZodFile:()=>Moe,ZodFunction:()=>tse,ZodGUID:()=>Mw,ZodIPv4:()=>d3,ZodIPv6:()=>h3,ZodIntersection:()=>Doe,ZodJWT:()=>E3,ZodKSUID:()=>f3,ZodLazy:()=>Zoe,ZodLiteral:()=>Loe,ZodMAC:()=>voe,ZodMap:()=>Ioe,ZodNaN:()=>Koe,ZodNanoID:()=>s3,ZodNever:()=>Aoe,ZodNonOptional:()=>O3,ZodNull:()=>Toe,ZodNullable:()=>Voe,ZodNumber:()=>jC,ZodNumberFormat:()=>KS,ZodObject:()=>Bw,ZodOptional:()=>A3,ZodPipe:()=>C3,ZodPrefault:()=>Boe,ZodPromise:()=>ese,ZodReadonly:()=>Woe,ZodRecord:()=>Hw,ZodSet:()=>woe,ZodString:()=>VC,ZodStringFormat:()=>Si,ZodSuccess:()=>Hoe,ZodSymbol:()=>_oe,ZodTemplateLiteral:()=>Joe,ZodTransform:()=>koe,ZodTuple:()=>Noe,ZodType:()=>$r,ZodULID:()=>l3,ZodURL:()=>Uw,ZodUUID:()=>Ih,ZodUndefined:()=>Eoe,ZodUnion:()=>qw,ZodUnknown:()=>boe,ZodVoid:()=>Ooe,ZodXID:()=>p3,ZodXor:()=>xoe,_ZodString:()=>n3,_default:()=>joe,_function:()=>sje,any:()=>Fw,array:()=>or,base64:()=>x2e,base64url:()=>P2e,bigint:()=>V2e,boolean:()=>Mi,catch:()=>Yoe,check:()=>cje,cidrv4:()=>O2e,cidrv6:()=>C2e,codec:()=>ije,cuid:()=>y2e,cuid2:()=>v2e,custom:()=>P3,date:()=>H2e,describe:()=>uje,discriminatedUnion:()=>Gw,e164:()=>D2e,email:()=>c2e,emoji:()=>m2e,enum:()=>pi,exactOptional:()=>Uoe,file:()=>eje,float32:()=>M2e,float64:()=>k2e,function:()=>sje,guid:()=>u2e,hash:()=>L2e,hex:()=>w2e,hostname:()=>I2e,httpUrl:()=>h2e,instanceof:()=>pje,int:()=>r3,int32:()=>$2e,int64:()=>F2e,intersection:()=>GC,ipv4:()=>S2e,ipv6:()=>A2e,json:()=>dje,jwt:()=>N2e,keyof:()=>z2e,ksuid:()=>T2e,lazy:()=>Qoe,literal:()=>wt,looseObject:()=>Ls,looseRecord:()=>X2e,mac:()=>b2e,map:()=>J2e,meta:()=>lje,nan:()=>nje,nanoid:()=>g2e,nativeEnum:()=>Q2e,never:()=>S3,nonoptional:()=>Goe,null:()=>Vw,nullable:()=>kw,nullish:()=>tje,number:()=>On,object:()=>ze,optional:()=>qn,partialRecord:()=>W2e,pipe:()=>$w,prefault:()=>qoe,preprocess:()=>Yw,promise:()=>oje,readonly:()=>Xoe,record:()=>$n,refine:()=>rse,set:()=>Z2e,strictObject:()=>Y2e,string:()=>ue,stringFormat:()=>R2e,stringbool:()=>fje,success:()=>rje,superRefine:()=>nse,symbol:()=>B2e,templateLiteral:()=>aje,transform:()=>b3,tuple:()=>Roe,uint32:()=>U2e,uint64:()=>j2e,ulid:()=>_2e,undefined:()=>q2e,union:()=>Cn,unknown:()=>Bn,url:()=>a3,uuid:()=>l2e,uuidv4:()=>p2e,uuidv6:()=>f2e,uuidv7:()=>d2e,void:()=>G2e,xid:()=>E2e,xor:()=>K2e});var JG={};Za(JG,{endsWith:()=>jS,gt:()=>Sd,gte:()=>ws,includes:()=>VS,length:()=>v_,lowercase:()=>$S,lt:()=>Td,lte:()=>eu,maxLength:()=>y_,maxSize:()=>qg,mime:()=>BS,minLength:()=>Rh,minSize:()=>bd,multipleOf:()=>Bg,negative:()=>Nw,nonnegative:()=>Iw,nonpositive:()=>Rw,normalize:()=>qS,overwrite:()=>Yp,positive:()=>Dw,property:()=>ww,regex:()=>kS,size:()=>g_,slugify:()=>MC,startsWith:()=>FS,toLowerCase:()=>HS,toUpperCase:()=>zS,trim:()=>GS,uppercase:()=>US});var A_={};Za(A_,{ZodISODate:()=>QG,ZodISODateTime:()=>ZG,ZodISODuration:()=>t3,ZodISOTime:()=>e3,date:()=>roe,datetime:()=>toe,duration:()=>ioe,time:()=>noe});var ZG=pe("ZodISODateTime",(e,t)=>{oq.init(e,t),Si.init(e,t)});function toe(e){return fG(ZG,e)}var QG=pe("ZodISODate",(e,t)=>{sq.init(e,t),Si.init(e,t)});function roe(e){return dG(QG,e)}var e3=pe("ZodISOTime",(e,t)=>{cq.init(e,t),Si.init(e,t)});function noe(e){return hG(e3,e)}var t3=pe("ZodISODuration",(e,t)=>{uq.init(e,t),Si.init(e,t)});function ioe(e){return mG(t3,e)}var s2e=(e,t)=>{QI.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>_C(e,r)},flatten:{value:r=>vC(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,mC,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,mC,2)}},isEmpty:{get(){return e.issues.length===0}}})},aoe=pe("ZodError",s2e),qu=pe("ZodError",s2e,{Parent:Error});var ooe=EC(qu),soe=SC(qu),coe=AC(qu),uoe=OC(qu),loe=IB(qu),poe=wB(qu),foe=LB(qu),doe=MB(qu),hoe=kB(qu),moe=$B(qu),goe=UB(qu),yoe=VB(qu);var $r=pe("ZodType",(e,t)=>(gr.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:kC(e,"input"),output:kC(e,"output")}}),e.toJSONSchema=yae(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(We.mergeDefs(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>Is(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>ooe(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>coe(e,r,n),e.parseAsync=async(r,n)=>soe(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>uoe(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>loe(e,r,n),e.decode=(r,n)=>poe(e,r,n),e.encodeAsync=async(r,n)=>foe(e,r,n),e.decodeAsync=async(r,n)=>doe(e,r,n),e.safeEncode=(r,n)=>hoe(e,r,n),e.safeDecode=(r,n)=>moe(e,r,n),e.safeEncodeAsync=async(r,n)=>goe(e,r,n),e.safeDecodeAsync=async(r,n)=>yoe(e,r,n),e.refine=(r,n)=>e.check(rse(r,n)),e.superRefine=r=>e.check(nse(r)),e.overwrite=r=>e.check(Yp(r)),e.optional=()=>qn(e),e.exactOptional=()=>Uoe(e),e.nullable=()=>kw(e),e.nullish=()=>qn(kw(e)),e.nonoptional=r=>Goe(e,r),e.array=()=>or(e),e.or=r=>Cn([e,r]),e.and=r=>GC(e,r),e.transform=r=>$w(e,b3(r)),e.default=r=>joe(e,r),e.prefault=r=>qoe(e,r),e.catch=r=>Yoe(e,r),e.pipe=r=>$w(e,r),e.readonly=()=>Xoe(e),e.describe=r=>{let n=e.clone();return ss.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return ss.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return ss.get(e);let n=e.clone();return ss.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),n3=pe("_ZodString",(e,t)=>{m_.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(n,i,a)=>vae(e,n,i,a);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(kS(...n)),e.includes=(...n)=>e.check(VS(...n)),e.startsWith=(...n)=>e.check(FS(...n)),e.endsWith=(...n)=>e.check(jS(...n)),e.min=(...n)=>e.check(Rh(...n)),e.max=(...n)=>e.check(y_(...n)),e.length=(...n)=>e.check(v_(...n)),e.nonempty=(...n)=>e.check(Rh(1,...n)),e.lowercase=n=>e.check($S(n)),e.uppercase=n=>e.check(US(n)),e.trim=()=>e.check(GS()),e.normalize=(...n)=>e.check(qS(...n)),e.toLowerCase=()=>e.check(HS()),e.toUpperCase=()=>e.check(zS()),e.slugify=()=>e.check(MC())}),VC=pe("ZodString",(e,t)=>{m_.init(e,t),n3.init(e,t),e.email=r=>e.check(uw(i3,r)),e.url=r=>e.check(LC(Uw,r)),e.jwt=r=>e.check(Pw(E3,r)),e.emoji=r=>e.check(hw(o3,r)),e.guid=r=>e.check(wC(Mw,r)),e.uuid=r=>e.check(lw(Ih,r)),e.uuidv4=r=>e.check(pw(Ih,r)),e.uuidv6=r=>e.check(fw(Ih,r)),e.uuidv7=r=>e.check(dw(Ih,r)),e.nanoid=r=>e.check(mw(s3,r)),e.guid=r=>e.check(wC(Mw,r)),e.cuid=r=>e.check(gw(c3,r)),e.cuid2=r=>e.check(yw(u3,r)),e.ulid=r=>e.check(vw(l3,r)),e.base64=r=>e.check(Ow(y3,r)),e.base64url=r=>e.check(Cw(v3,r)),e.xid=r=>e.check(_w(p3,r)),e.ksuid=r=>e.check(Ew(f3,r)),e.ipv4=r=>e.check(Tw(d3,r)),e.ipv6=r=>e.check(Sw(h3,r)),e.cidrv4=r=>e.check(bw(m3,r)),e.cidrv6=r=>e.check(Aw(g3,r)),e.e164=r=>e.check(xw(_3,r)),e.datetime=r=>e.check(toe(r)),e.date=r=>e.check(roe(r)),e.time=r=>e.check(noe(r)),e.duration=r=>e.check(ioe(r))});function ue(e){return cG(VC,e)}var Si=pe("ZodStringFormat",(e,t)=>{li.init(e,t),n3.init(e,t)}),i3=pe("ZodEmail",(e,t)=>{JB.init(e,t),Si.init(e,t)});function c2e(e){return uw(i3,e)}var Mw=pe("ZodGUID",(e,t)=>{WB.init(e,t),Si.init(e,t)});function u2e(e){return wC(Mw,e)}var Ih=pe("ZodUUID",(e,t)=>{XB.init(e,t),Si.init(e,t)});function l2e(e){return lw(Ih,e)}function p2e(e){return pw(Ih,e)}function f2e(e){return fw(Ih,e)}function d2e(e){return dw(Ih,e)}var Uw=pe("ZodURL",(e,t)=>{ZB.init(e,t),Si.init(e,t)});function a3(e){return LC(Uw,e)}function h2e(e){return LC(Uw,{protocol:/^https?$/,hostname:Bu.domain,...We.normalizeParams(e)})}var o3=pe("ZodEmoji",(e,t)=>{QB.init(e,t),Si.init(e,t)});function m2e(e){return hw(o3,e)}var s3=pe("ZodNanoID",(e,t)=>{eq.init(e,t),Si.init(e,t)});function g2e(e){return mw(s3,e)}var c3=pe("ZodCUID",(e,t)=>{tq.init(e,t),Si.init(e,t)});function y2e(e){return gw(c3,e)}var u3=pe("ZodCUID2",(e,t)=>{rq.init(e,t),Si.init(e,t)});function v2e(e){return yw(u3,e)}var l3=pe("ZodULID",(e,t)=>{nq.init(e,t),Si.init(e,t)});function _2e(e){return vw(l3,e)}var p3=pe("ZodXID",(e,t)=>{iq.init(e,t),Si.init(e,t)});function E2e(e){return _w(p3,e)}var f3=pe("ZodKSUID",(e,t)=>{aq.init(e,t),Si.init(e,t)});function T2e(e){return Ew(f3,e)}var d3=pe("ZodIPv4",(e,t)=>{lq.init(e,t),Si.init(e,t)});function S2e(e){return Tw(d3,e)}var voe=pe("ZodMAC",(e,t)=>{fq.init(e,t),Si.init(e,t)});function b2e(e){return lG(voe,e)}var h3=pe("ZodIPv6",(e,t)=>{pq.init(e,t),Si.init(e,t)});function A2e(e){return Sw(h3,e)}var m3=pe("ZodCIDRv4",(e,t)=>{dq.init(e,t),Si.init(e,t)});function O2e(e){return bw(m3,e)}var g3=pe("ZodCIDRv6",(e,t)=>{hq.init(e,t),Si.init(e,t)});function C2e(e){return Aw(g3,e)}var y3=pe("ZodBase64",(e,t)=>{mq.init(e,t),Si.init(e,t)});function x2e(e){return Ow(y3,e)}var v3=pe("ZodBase64URL",(e,t)=>{gq.init(e,t),Si.init(e,t)});function P2e(e){return Cw(v3,e)}var _3=pe("ZodE164",(e,t)=>{yq.init(e,t),Si.init(e,t)});function D2e(e){return xw(_3,e)}var E3=pe("ZodJWT",(e,t)=>{vq.init(e,t),Si.init(e,t)});function N2e(e){return Pw(E3,e)}var FC=pe("ZodCustomStringFormat",(e,t)=>{_q.init(e,t),Si.init(e,t)});function R2e(e,t,r={}){return YS(FC,e,t,r)}function I2e(e){return YS(FC,"hostname",Bu.hostname,e)}function w2e(e){return YS(FC,"hex",Bu.hex,e)}function L2e(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,i=Bu[n];if(!i)throw new Error(`Unrecognized hash format: ${n}`);return YS(FC,n,i,t)}var jC=pe("ZodNumber",(e,t)=>{nw.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(n,i,a)=>_ae(e,n,i,a),e.gt=(n,i)=>e.check(Sd(n,i)),e.gte=(n,i)=>e.check(ws(n,i)),e.min=(n,i)=>e.check(ws(n,i)),e.lt=(n,i)=>e.check(Td(n,i)),e.lte=(n,i)=>e.check(eu(n,i)),e.max=(n,i)=>e.check(eu(n,i)),e.int=n=>e.check(r3(n)),e.safe=n=>e.check(r3(n)),e.positive=n=>e.check(Sd(0,n)),e.nonnegative=n=>e.check(ws(0,n)),e.negative=n=>e.check(Td(0,n)),e.nonpositive=n=>e.check(eu(0,n)),e.multipleOf=(n,i)=>e.check(Bg(n,i)),e.step=(n,i)=>e.check(Bg(n,i)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function On(e){return gG(jC,e)}var KS=pe("ZodNumberFormat",(e,t)=>{Eq.init(e,t),jC.init(e,t)});function r3(e){return vG(KS,e)}function M2e(e){return _G(KS,e)}function k2e(e){return EG(KS,e)}function $2e(e){return TG(KS,e)}function U2e(e){return SG(KS,e)}var BC=pe("ZodBoolean",(e,t)=>{PC.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Eae(e,r,n,i)});function Mi(e){return bG(BC,e)}var qC=pe("ZodBigInt",(e,t)=>{iw.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(n,i,a)=>Tae(e,n,i,a),e.gte=(n,i)=>e.check(ws(n,i)),e.min=(n,i)=>e.check(ws(n,i)),e.gt=(n,i)=>e.check(Sd(n,i)),e.gte=(n,i)=>e.check(ws(n,i)),e.min=(n,i)=>e.check(ws(n,i)),e.lt=(n,i)=>e.check(Td(n,i)),e.lte=(n,i)=>e.check(eu(n,i)),e.max=(n,i)=>e.check(eu(n,i)),e.positive=n=>e.check(Sd(BigInt(0),n)),e.negative=n=>e.check(Td(BigInt(0),n)),e.nonpositive=n=>e.check(eu(BigInt(0),n)),e.nonnegative=n=>e.check(ws(BigInt(0),n)),e.multipleOf=(n,i)=>e.check(Bg(n,i));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function V2e(e){return OG(qC,e)}var T3=pe("ZodBigIntFormat",(e,t)=>{Tq.init(e,t),qC.init(e,t)});function F2e(e){return xG(T3,e)}function j2e(e){return PG(T3,e)}var _oe=pe("ZodSymbol",(e,t)=>{Sq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Sae(e,r,n,i)});function B2e(e){return DG(_oe,e)}var Eoe=pe("ZodUndefined",(e,t)=>{bq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Aae(e,r,n,i)});function q2e(e){return NG(Eoe,e)}var Toe=pe("ZodNull",(e,t)=>{Aq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>bae(e,r,n,i)});function Vw(e){return RG(Toe,e)}var Soe=pe("ZodAny",(e,t)=>{Oq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>xae(e,r,n,i)});function Fw(){return IG(Soe)}var boe=pe("ZodUnknown",(e,t)=>{Cq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Pae(e,r,n,i)});function Bn(){return wG(boe)}var Aoe=pe("ZodNever",(e,t)=>{xq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Cae(e,r,n,i)});function S3(e){return LG(Aoe,e)}var Ooe=pe("ZodVoid",(e,t)=>{Pq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Oae(e,r,n,i)});function G2e(e){return MG(Ooe,e)}var jw=pe("ZodDate",(e,t)=>{Dq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(n,i,a)=>Dae(e,n,i,a),e.min=(n,i)=>e.check(ws(n,i)),e.max=(n,i)=>e.check(eu(n,i));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function H2e(e){return kG(jw,e)}var Coe=pe("ZodArray",(e,t)=>{Nq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>jae(e,r,n,i),e.element=t.element,e.min=(r,n)=>e.check(Rh(r,n)),e.nonempty=r=>e.check(Rh(1,r)),e.max=(r,n)=>e.check(y_(r,n)),e.length=(r,n)=>e.check(v_(r,n)),e.unwrap=()=>e.element});function or(e,t){return gae(Coe,e,t)}function z2e(e){let t=e._zod.def.shape;return pi(Object.keys(t))}var Bw=pe("ZodObject",(e,t)=>{mae.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Bae(e,r,n,i),We.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>pi(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Bn()}),e.loose=()=>e.clone({...e._zod.def,catchall:Bn()}),e.strict=()=>e.clone({...e._zod.def,catchall:S3()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>We.extend(e,r),e.safeExtend=r=>We.safeExtend(e,r),e.merge=r=>We.merge(e,r),e.pick=r=>We.pick(e,r),e.omit=r=>We.omit(e,r),e.partial=(...r)=>We.partial(A3,e,r[0]),e.required=(...r)=>We.required(O3,e,r[0])});function ze(e,t){let r={type:"object",shape:e??{},...We.normalizeParams(t)};return new Bw(r)}function Y2e(e,t){return new Bw({type:"object",shape:e,catchall:S3(),...We.normalizeParams(t)})}function Ls(e,t){return new Bw({type:"object",shape:e,catchall:Bn(),...We.normalizeParams(t)})}var qw=pe("ZodUnion",(e,t)=>{DC.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>YG(e,r,n,i),e.options=t.options});function Cn(e,t){return new qw({type:"union",options:e,...We.normalizeParams(t)})}var xoe=pe("ZodXor",(e,t)=>{qw.init(e,t),Rq.init(e,t),e._zod.processJSONSchema=(r,n,i)=>YG(e,r,n,i),e.options=t.options});function K2e(e,t){return new xoe({type:"union",options:e,inclusive:!1,...We.normalizeParams(t)})}var Poe=pe("ZodDiscriminatedUnion",(e,t)=>{qw.init(e,t),Iq.init(e,t)});function Gw(e,t,r){return new Poe({type:"union",options:t,discriminator:e,...We.normalizeParams(r)})}var Doe=pe("ZodIntersection",(e,t)=>{wq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>qae(e,r,n,i)});function GC(e,t){return new Doe({type:"intersection",left:e,right:t})}var Noe=pe("ZodTuple",(e,t)=>{aw.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Gae(e,r,n,i),e.rest=r=>e.clone({...e._zod.def,rest:r})});function Roe(e,t,r){let n=t instanceof gr,i=n?r:t,a=n?t:null;return new Noe({type:"tuple",items:e,rest:a,...We.normalizeParams(i)})}var Hw=pe("ZodRecord",(e,t)=>{Lq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Hae(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType});function $n(e,t,r){return new Hw({type:"record",keyType:e,valueType:t,...We.normalizeParams(r)})}function W2e(e,t,r){let n=Is(e);return n._zod.values=void 0,new Hw({type:"record",keyType:n,valueType:t,...We.normalizeParams(r)})}function X2e(e,t,r){return new Hw({type:"record",keyType:e,valueType:t,mode:"loose",...We.normalizeParams(r)})}var Ioe=pe("ZodMap",(e,t)=>{Mq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Vae(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(bd(...r)),e.nonempty=r=>e.check(bd(1,r)),e.max=(...r)=>e.check(qg(...r)),e.size=(...r)=>e.check(g_(...r))});function J2e(e,t,r){return new Ioe({type:"map",keyType:e,valueType:t,...We.normalizeParams(r)})}var woe=pe("ZodSet",(e,t)=>{kq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Fae(e,r,n,i),e.min=(...r)=>e.check(bd(...r)),e.nonempty=r=>e.check(bd(1,r)),e.max=(...r)=>e.check(qg(...r)),e.size=(...r)=>e.check(g_(...r))});function Z2e(e,t){return new woe({type:"set",valueType:e,...We.normalizeParams(t)})}var UC=pe("ZodEnum",(e,t)=>{$q.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(n,i,a)=>Nae(e,n,i,a),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let a={};for(let o of n)if(r.has(o))a[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new UC({...t,checks:[],...We.normalizeParams(i),entries:a})},e.exclude=(n,i)=>{let a={...t.entries};for(let o of n)if(r.has(o))delete a[o];else throw new Error(`Key ${o} not found in enum`);return new UC({...t,checks:[],...We.normalizeParams(i),entries:a})}});function pi(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new UC({type:"enum",entries:r,...We.normalizeParams(t)})}function Q2e(e,t){return new UC({type:"enum",entries:e,...We.normalizeParams(t)})}var Loe=pe("ZodLiteral",(e,t)=>{Uq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Rae(e,r,n,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function wt(e,t){return new Loe({type:"literal",values:Array.isArray(e)?e:[e],...We.normalizeParams(t)})}var Moe=pe("ZodFile",(e,t)=>{Vq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Lae(e,r,n,i),e.min=(r,n)=>e.check(bd(r,n)),e.max=(r,n)=>e.check(qg(r,n)),e.mime=(r,n)=>e.check(BS(Array.isArray(r)?r:[r],n))});function eje(e){return VG(Moe,e)}var koe=pe("ZodTransform",(e,t)=>{Fq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Uae(e,r,n,i),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new l_(e.constructor.name);r.addIssue=a=>{if(typeof a=="string")r.issues.push(We.issue(a,r.value,t));else{let o=a;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),r.issues.push(We.issue(o))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(a=>(r.value=a,r)):(r.value=i,r)}});function b3(e){return new koe({type:"transform",transform:e})}var A3=pe("ZodOptional",(e,t)=>{ow.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>KG(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function qn(e){return new A3({type:"optional",innerType:e})}var $oe=pe("ZodExactOptional",(e,t)=>{jq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>KG(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Uoe(e){return new $oe({type:"optional",innerType:e})}var Voe=pe("ZodNullable",(e,t)=>{Bq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>zae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function kw(e){return new Voe({type:"nullable",innerType:e})}function tje(e){return qn(kw(e))}var Foe=pe("ZodDefault",(e,t)=>{qq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Kae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function joe(e,t){return new Foe({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():We.shallowClone(t)}})}var Boe=pe("ZodPrefault",(e,t)=>{Gq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Wae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function qoe(e,t){return new Boe({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():We.shallowClone(t)}})}var O3=pe("ZodNonOptional",(e,t)=>{Hq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Yae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Goe(e,t){return new O3({type:"nonoptional",innerType:e,...We.normalizeParams(t)})}var Hoe=pe("ZodSuccess",(e,t)=>{zq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Mae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function rje(e){return new Hoe({type:"success",innerType:e})}var zoe=pe("ZodCatch",(e,t)=>{Yq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Xae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Yoe(e,t){return new zoe({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Koe=pe("ZodNaN",(e,t)=>{Kq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Iae(e,r,n,i)});function nje(e){return UG(Koe,e)}var C3=pe("ZodPipe",(e,t)=>{Wq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Jae(e,r,n,i),e.in=t.in,e.out=t.out});function $w(e,t){return new C3({type:"pipe",in:e,out:t})}var x3=pe("ZodCodec",(e,t)=>{C3.init(e,t),NC.init(e,t)});function ije(e,t,r){return new x3({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}var Woe=pe("ZodReadonly",(e,t)=>{Xq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Zae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Xoe(e){return new Woe({type:"readonly",innerType:e})}var Joe=pe("ZodTemplateLiteral",(e,t)=>{Jq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>wae(e,r,n,i)});function aje(e,t){return new Joe({type:"template_literal",parts:e,...We.normalizeParams(t)})}var Zoe=pe("ZodLazy",(e,t)=>{eG.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>eoe(e,r,n,i),e.unwrap=()=>e._zod.def.getter()});function Qoe(e){return new Zoe({type:"lazy",getter:e})}var ese=pe("ZodPromise",(e,t)=>{Qq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Qae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function oje(e){return new ese({type:"promise",innerType:e})}var tse=pe("ZodFunction",(e,t)=>{Zq.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>$ae(e,r,n,i)});function sje(e){return new tse({type:"function",input:Array.isArray(e?.input)?Roe(e?.input):e?.input??or(Bn()),output:e?.output??Bn()})}var zw=pe("ZodCustom",(e,t)=>{tG.init(e,t),$r.init(e,t),e._zod.processJSONSchema=(r,n,i)=>kae(e,r,n,i)});function cje(e){let t=new Ti({check:"custom"});return t._zod.check=e,t}function P3(e,t){return FG(zw,e??(()=>!0),t)}function rse(e,t={}){return jG(zw,e,t)}function nse(e){return BG(e)}var uje=qG,lje=GG;function pje(e,t={}){let r=new zw({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...We.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var fje=(...e)=>HG({Codec:x3,Boolean:BC,String:VC},...e);function dje(e){let t=Qoe(()=>Cn([ue(e),On(),Mi(),Vw(),or(t),$n(ue(),t)]));return t}function Yw(e,t){return $w(b3(e),t)}var xfr={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"};function Pfr(e){ya({customError:e})}function Dfr(){return ya().customError}var ise;ise||(ise={});var yt={...Lw,...JG,iso:A_},Nfr=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function Rfr(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function Ifr(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let n=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let i=r[1];if(!i||!t.defs[i])throw new Error(`Reference not found: ${e}`);return t.defs[i]}throw new Error(`Reference not found: ${e}`)}function hje(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return yt.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let i=e.$ref;if(t.refs.has(i))return t.refs.get(i);if(t.processing.has(i))return yt.lazy(()=>{if(!t.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return t.refs.get(i)});t.processing.add(i);let a=Ifr(i,t),o=cc(a,t);return t.refs.set(i,o),t.processing.delete(i),o}if(e.enum!==void 0){let i=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&i.length===1&&i[0]===null)return yt.null();if(i.length===0)return yt.never();if(i.length===1)return yt.literal(i[0]);if(i.every(o=>typeof o=="string"))return yt.enum(i);let a=i.map(o=>yt.literal(o));return a.length<2?a[0]:yt.union([a[0],a[1],...a.slice(2)])}if(e.const!==void 0)return yt.literal(e.const);let r=e.type;if(Array.isArray(r)){let i=r.map(a=>{let o={...e,type:a};return hje(o,t)});return i.length===0?yt.never():i.length===1?i[0]:yt.union(i)}if(!r)return yt.any();let n;switch(r){case"string":{let i=yt.string();if(e.format){let a=e.format;a==="email"?i=i.check(yt.email()):a==="uri"||a==="uri-reference"?i=i.check(yt.url()):a==="uuid"||a==="guid"?i=i.check(yt.uuid()):a==="date-time"?i=i.check(yt.iso.datetime()):a==="date"?i=i.check(yt.iso.date()):a==="time"?i=i.check(yt.iso.time()):a==="duration"?i=i.check(yt.iso.duration()):a==="ipv4"?i=i.check(yt.ipv4()):a==="ipv6"?i=i.check(yt.ipv6()):a==="mac"?i=i.check(yt.mac()):a==="cidr"?i=i.check(yt.cidrv4()):a==="cidr-v6"?i=i.check(yt.cidrv6()):a==="base64"?i=i.check(yt.base64()):a==="base64url"?i=i.check(yt.base64url()):a==="e164"?i=i.check(yt.e164()):a==="jwt"?i=i.check(yt.jwt()):a==="emoji"?i=i.check(yt.emoji()):a==="nanoid"?i=i.check(yt.nanoid()):a==="cuid"?i=i.check(yt.cuid()):a==="cuid2"?i=i.check(yt.cuid2()):a==="ulid"?i=i.check(yt.ulid()):a==="xid"?i=i.check(yt.xid()):a==="ksuid"&&(i=i.check(yt.ksuid()))}typeof e.minLength=="number"&&(i=i.min(e.minLength)),typeof e.maxLength=="number"&&(i=i.max(e.maxLength)),e.pattern&&(i=i.regex(new RegExp(e.pattern))),n=i;break}case"number":case"integer":{let i=r==="integer"?yt.number().int():yt.number();typeof e.minimum=="number"&&(i=i.min(e.minimum)),typeof e.maximum=="number"&&(i=i.max(e.maximum)),typeof e.exclusiveMinimum=="number"?i=i.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(i=i.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?i=i.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(i=i.lt(e.maximum)),typeof e.multipleOf=="number"&&(i=i.multipleOf(e.multipleOf)),n=i;break}case"boolean":{n=yt.boolean();break}case"null":{n=yt.null();break}case"object":{let i={},a=e.properties||{},o=new Set(e.required||[]);for(let[c,u]of Object.entries(a)){let l=cc(u,t);i[c]=o.has(c)?l:l.optional()}if(e.propertyNames){let c=cc(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?cc(e.additionalProperties,t):yt.any();if(Object.keys(i).length===0){n=yt.record(c,u);break}let l=yt.object(i).passthrough(),p=yt.looseRecord(c,u);n=yt.intersection(l,p);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let f of u){let h=cc(c[f],t),d=yt.string().regex(new RegExp(f));l.push(yt.looseRecord(d,h))}let p=[];if(Object.keys(i).length>0&&p.push(yt.object(i).passthrough()),p.push(...l),p.length===0)n=yt.object({}).passthrough();else if(p.length===1)n=p[0];else{let f=yt.intersection(p[0],p[1]);for(let h=2;h<p.length;h++)f=yt.intersection(f,p[h]);n=f}break}let s=yt.object(i);e.additionalProperties===!1?n=s.strict():typeof e.additionalProperties=="object"?n=s.catchall(cc(e.additionalProperties,t)):n=s.passthrough();break}case"array":{let i=e.prefixItems,a=e.items;if(i&&Array.isArray(i)){let o=i.map(c=>cc(c,t)),s=a&&typeof a=="object"&&!Array.isArray(a)?cc(a,t):void 0;s?n=yt.tuple(o).rest(s):n=yt.tuple(o),typeof e.minItems=="number"&&(n=n.check(yt.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(yt.maxLength(e.maxItems)))}else if(Array.isArray(a)){let o=a.map(c=>cc(c,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?cc(e.additionalItems,t):void 0;s?n=yt.tuple(o).rest(s):n=yt.tuple(o),typeof e.minItems=="number"&&(n=n.check(yt.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(yt.maxLength(e.maxItems)))}else if(a!==void 0){let o=cc(a,t),s=yt.array(o);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),n=s}else n=yt.array(yt.any());break}default:throw new Error(`Unsupported type: ${r}`)}return e.description&&(n=n.describe(e.description)),e.default!==void 0&&(n=n.default(e.default)),n}function cc(e,t){if(typeof e=="boolean")return e?yt.any():yt.never();let r=hje(e,t),n=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(u=>cc(u,t)),c=yt.union(s);r=n?yt.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>cc(u,t)),c=yt.xor(s);r=n?yt.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=n?r:yt.any();else{let s=n?r:cc(e.allOf[0],t),c=n?0:1;for(let u=c;u<e.allOf.length;u++)s=yt.intersection(s,cc(e.allOf[u],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=yt.nullable(r)),e.readOnly===!0&&(r=yt.readonly(r));let i={},a=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of a)s in e&&(i[s]=e[s]);let o=["contentEncoding","contentMediaType","contentSchema"];for(let s of o)s in e&&(i[s]=e[s]);for(let s of Object.keys(e))Nfr.has(s)||(i[s]=e[s]);return Object.keys(i).length>0&&t.registry.add(r,i),r}function mje(e,t){if(typeof e=="boolean")return e?yt.any():yt.never();let r=Rfr(e,t?.defaultTarget),n=e.$defs||e.definitions||{},i={version:r,defs:n,refs:new Map,processing:new Set,rootSchema:e,registry:t?.registry??ss};return cc(e,i)}var ase={};Za(ase,{bigint:()=>kfr,boolean:()=>Mfr,date:()=>$fr,number:()=>Lfr,string:()=>wfr});function wfr(e){return uG(VC,e)}function Lfr(e){return yG(jC,e)}function Mfr(e){return AG(BC,e)}function kfr(e){return CG(qC,e)}function $fr(e){return $G(jw,e)}ya(rG());var sse="2025-11-25";var gje=[sse,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],O_="io.modelcontextprotocol/related-task",N3="2.0",qo=P3(e=>e!==null&&(typeof e=="object"||typeof e=="function")),yje=Cn([ue(),On().int()]),vje=ue(),hfi=Ls({ttl:On().optional(),pollInterval:On().optional()}),Vfr=ze({ttl:On().optional()}),Ffr=ze({taskId:ue()}),cse=Ls({progressToken:yje.optional(),[O_]:Ffr.optional()}),np=ze({_meta:cse.optional()}),Kw=np.extend({task:Vfr.optional()}),_je=e=>Kw.safeParse(e).success,Ms=ze({method:ue(),params:np.loose().optional()}),Kp=ze({_meta:cse.optional()}),Wp=ze({method:ue(),params:Kp.loose().optional()}),ks=Ls({_meta:cse.optional()}),R3=Cn([ue(),On().int()]),Eje=ze({jsonrpc:wt(N3),id:R3,...Ms.shape}).strict(),use=e=>Eje.safeParse(e).success,Tje=ze({jsonrpc:wt(N3),...Wp.shape}).strict(),Sje=e=>Tje.safeParse(e).success,lse=ze({jsonrpc:wt(N3),id:R3,result:ks}).strict(),Ww=e=>lse.safeParse(e).success;var vn;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(vn||(vn={}));var pse=ze({jsonrpc:wt(N3),id:R3.optional(),error:ze({code:On().int(),message:ue(),data:Bn().optional()})}).strict();var bje=e=>pse.safeParse(e).success;var Aje=Cn([Eje,Tje,lse,pse]),mfi=Cn([lse,pse]),I3=ks.strict(),jfr=Kp.extend({requestId:R3.optional(),reason:ue().optional()}),w3=Wp.extend({method:wt("notifications/cancelled"),params:jfr}),Bfr=ze({src:ue(),mimeType:ue().optional(),sizes:or(ue()).optional(),theme:pi(["light","dark"]).optional()}),Xw=ze({icons:or(Bfr).optional()}),HC=ze({name:ue(),title:ue().optional()}),Oje=HC.extend({...HC.shape,...Xw.shape,version:ue(),websiteUrl:ue().optional(),description:ue().optional()}),qfr=GC(ze({applyDefaults:Mi().optional()}),$n(ue(),Bn())),Gfr=Yw(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,GC(ze({form:qfr.optional(),url:qo.optional()}),$n(ue(),Bn()).optional())),Hfr=Ls({list:qo.optional(),cancel:qo.optional(),requests:Ls({sampling:Ls({createMessage:qo.optional()}).optional(),elicitation:Ls({create:qo.optional()}).optional()}).optional()}),zfr=Ls({list:qo.optional(),cancel:qo.optional(),requests:Ls({tools:Ls({call:qo.optional()}).optional()}).optional()}),Yfr=ze({experimental:$n(ue(),qo).optional(),sampling:ze({context:qo.optional(),tools:qo.optional()}).optional(),elicitation:Gfr.optional(),roots:ze({listChanged:Mi().optional()}).optional(),tasks:Hfr.optional(),extensions:$n(ue(),qo).optional()}),Kfr=np.extend({protocolVersion:ue(),capabilities:Yfr,clientInfo:Oje}),Jw=Ms.extend({method:wt("initialize"),params:Kfr});var Wfr=ze({experimental:$n(ue(),qo).optional(),logging:qo.optional(),completions:qo.optional(),prompts:ze({listChanged:Mi().optional()}).optional(),resources:ze({subscribe:Mi().optional(),listChanged:Mi().optional()}).optional(),tools:ze({listChanged:Mi().optional()}).optional(),tasks:zfr.optional(),extensions:$n(ue(),qo).optional()}),Xfr=ks.extend({protocolVersion:ue(),capabilities:Wfr,serverInfo:Oje,instructions:ue().optional()}),fse=Wp.extend({method:wt("notifications/initialized"),params:Kp.optional()});var L3=Ms.extend({method:wt("ping"),params:np.optional()}),Jfr=ze({progress:On(),total:qn(On()),message:qn(ue())}),Zfr=ze({...Kp.shape,...Jfr.shape,progressToken:yje}),M3=Wp.extend({method:wt("notifications/progress"),params:Zfr}),Qfr=np.extend({cursor:vje.optional()}),Zw=Ms.extend({params:Qfr.optional()}),Qw=ks.extend({nextCursor:vje.optional()}),edr=pi(["working","input_required","completed","failed","cancelled"]),eL=ze({taskId:ue(),status:edr,ttl:Cn([On(),Vw()]),createdAt:ue(),lastUpdatedAt:ue(),pollInterval:qn(On()),statusMessage:qn(ue())}),zC=ks.extend({task:eL}),tdr=Kp.merge(eL),tL=Wp.extend({method:wt("notifications/tasks/status"),params:tdr}),k3=Ms.extend({method:wt("tasks/get"),params:np.extend({taskId:ue()})}),$3=ks.merge(eL),U3=Ms.extend({method:wt("tasks/result"),params:np.extend({taskId:ue()})}),gfi=ks.loose(),V3=Zw.extend({method:wt("tasks/list")}),F3=Qw.extend({tasks:or(eL)}),j3=Ms.extend({method:wt("tasks/cancel"),params:np.extend({taskId:ue()})}),Cje=ks.merge(eL),xje=ze({uri:ue(),mimeType:qn(ue()),_meta:$n(ue(),Bn()).optional()}),Pje=xje.extend({text:ue()}),dse=ue().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Dje=xje.extend({blob:dse}),rL=pi(["user","assistant"]),YC=ze({audience:or(rL).optional(),priority:On().min(0).max(1).optional(),lastModified:A_.datetime({offset:!0}).optional()}),Nje=ze({...HC.shape,...Xw.shape,uri:ue(),description:qn(ue()),mimeType:qn(ue()),size:qn(On()),annotations:YC.optional(),_meta:qn(Ls({}))}),rdr=ze({...HC.shape,...Xw.shape,uriTemplate:ue(),description:qn(ue()),mimeType:qn(ue()),annotations:YC.optional(),_meta:qn(Ls({}))}),ndr=Zw.extend({method:wt("resources/list")}),idr=Qw.extend({resources:or(Nje)}),adr=Zw.extend({method:wt("resources/templates/list")}),odr=Qw.extend({resourceTemplates:or(rdr)}),hse=np.extend({uri:ue()}),sdr=hse,cdr=Ms.extend({method:wt("resources/read"),params:sdr}),udr=ks.extend({contents:or(Cn([Pje,Dje]))}),ldr=Wp.extend({method:wt("notifications/resources/list_changed"),params:Kp.optional()}),pdr=hse,fdr=Ms.extend({method:wt("resources/subscribe"),params:pdr}),ddr=hse,hdr=Ms.extend({method:wt("resources/unsubscribe"),params:ddr}),mdr=Kp.extend({uri:ue()}),gdr=Wp.extend({method:wt("notifications/resources/updated"),params:mdr}),ydr=ze({name:ue(),description:qn(ue()),required:qn(Mi())}),vdr=ze({...HC.shape,...Xw.shape,description:qn(ue()),arguments:qn(or(ydr)),_meta:qn(Ls({}))}),_dr=Zw.extend({method:wt("prompts/list")}),Edr=Qw.extend({prompts:or(vdr)}),Tdr=np.extend({name:ue(),arguments:$n(ue(),ue()).optional()}),Sdr=Ms.extend({method:wt("prompts/get"),params:Tdr}),mse=ze({type:wt("text"),text:ue(),annotations:YC.optional(),_meta:$n(ue(),Bn()).optional()}),gse=ze({type:wt("image"),data:dse,mimeType:ue(),annotations:YC.optional(),_meta:$n(ue(),Bn()).optional()}),yse=ze({type:wt("audio"),data:dse,mimeType:ue(),annotations:YC.optional(),_meta:$n(ue(),Bn()).optional()}),bdr=ze({type:wt("tool_use"),name:ue(),id:ue(),input:$n(ue(),Bn()),_meta:$n(ue(),Bn()).optional()}),Adr=ze({type:wt("resource"),resource:Cn([Pje,Dje]),annotations:YC.optional(),_meta:$n(ue(),Bn()).optional()}),Odr=Nje.extend({type:wt("resource_link")}),vse=Cn([mse,gse,yse,Odr,Adr]),Cdr=ze({role:rL,content:vse}),xdr=ks.extend({description:ue().optional(),messages:or(Cdr)}),Pdr=Wp.extend({method:wt("notifications/prompts/list_changed"),params:Kp.optional()}),Ddr=ze({title:ue().optional(),readOnlyHint:Mi().optional(),destructiveHint:Mi().optional(),idempotentHint:Mi().optional(),openWorldHint:Mi().optional()}),Ndr=ze({taskSupport:pi(["required","optional","forbidden"]).optional()}),Rje=ze({...HC.shape,...Xw.shape,description:ue().optional(),inputSchema:ze({type:wt("object"),properties:$n(ue(),qo).optional(),required:or(ue()).optional()}).catchall(Bn()),outputSchema:ze({type:wt("object"),properties:$n(ue(),qo).optional(),required:or(ue()).optional()}).catchall(Bn()).optional(),annotations:Ddr.optional(),execution:Ndr.optional(),_meta:$n(ue(),Bn()).optional()}),_se=Zw.extend({method:wt("tools/list")}),Rdr=Qw.extend({tools:or(Rje)}),B3=ks.extend({content:or(vse).default([]),structuredContent:$n(ue(),Bn()).optional(),isError:Mi().optional()}),yfi=B3.or(ks.extend({toolResult:Bn()})),Idr=Kw.extend({name:ue(),arguments:$n(ue(),Bn()).optional()}),nL=Ms.extend({method:wt("tools/call"),params:Idr}),wdr=Wp.extend({method:wt("notifications/tools/list_changed"),params:Kp.optional()}),vfi=ze({autoRefresh:Mi().default(!0),debounceMs:On().int().nonnegative().default(300)}),iL=pi(["debug","info","notice","warning","error","critical","alert","emergency"]),Ldr=np.extend({level:iL}),Ese=Ms.extend({method:wt("logging/setLevel"),params:Ldr}),Mdr=Kp.extend({level:iL,logger:ue().optional(),data:Bn()}),kdr=Wp.extend({method:wt("notifications/message"),params:Mdr}),$dr=ze({name:ue().optional()}),Udr=ze({hints:or($dr).optional(),costPriority:On().min(0).max(1).optional(),speedPriority:On().min(0).max(1).optional(),intelligencePriority:On().min(0).max(1).optional()}),Vdr=ze({mode:pi(["auto","required","none"]).optional()}),Fdr=ze({type:wt("tool_result"),toolUseId:ue().describe("The unique identifier for the corresponding tool call."),content:or(vse).default([]),structuredContent:ze({}).loose().optional(),isError:Mi().optional(),_meta:$n(ue(),Bn()).optional()}),jdr=Gw("type",[mse,gse,yse]),D3=Gw("type",[mse,gse,yse,bdr,Fdr]),Bdr=ze({role:rL,content:Cn([D3,or(D3)]),_meta:$n(ue(),Bn()).optional()}),qdr=Kw.extend({messages:or(Bdr),modelPreferences:Udr.optional(),systemPrompt:ue().optional(),includeContext:pi(["none","thisServer","allServers"]).optional(),temperature:On().optional(),maxTokens:On().int(),stopSequences:or(ue()).optional(),metadata:qo.optional(),tools:or(Rje).optional(),toolChoice:Vdr.optional()}),Gdr=Ms.extend({method:wt("sampling/createMessage"),params:qdr}),aL=ks.extend({model:ue(),stopReason:qn(pi(["endTurn","stopSequence","maxTokens"]).or(ue())),role:rL,content:jdr}),Tse=ks.extend({model:ue(),stopReason:qn(pi(["endTurn","stopSequence","maxTokens","toolUse"]).or(ue())),role:rL,content:Cn([D3,or(D3)])}),Hdr=ze({type:wt("boolean"),title:ue().optional(),description:ue().optional(),default:Mi().optional()}),zdr=ze({type:wt("string"),title:ue().optional(),description:ue().optional(),minLength:On().optional(),maxLength:On().optional(),format:pi(["email","uri","date","date-time"]).optional(),default:ue().optional()}),Ydr=ze({type:pi(["number","integer"]),title:ue().optional(),description:ue().optional(),minimum:On().optional(),maximum:On().optional(),default:On().optional()}),Kdr=ze({type:wt("string"),title:ue().optional(),description:ue().optional(),enum:or(ue()),default:ue().optional()}),Wdr=ze({type:wt("string"),title:ue().optional(),description:ue().optional(),oneOf:or(ze({const:ue(),title:ue()})),default:ue().optional()}),Xdr=ze({type:wt("string"),title:ue().optional(),description:ue().optional(),enum:or(ue()),enumNames:or(ue()).optional(),default:ue().optional()}),Jdr=Cn([Kdr,Wdr]),Zdr=ze({type:wt("array"),title:ue().optional(),description:ue().optional(),minItems:On().optional(),maxItems:On().optional(),items:ze({type:wt("string"),enum:or(ue())}),default:or(ue()).optional()}),Qdr=ze({type:wt("array"),title:ue().optional(),description:ue().optional(),minItems:On().optional(),maxItems:On().optional(),items:ze({anyOf:or(ze({const:ue(),title:ue()}))}),default:or(ue()).optional()}),ehr=Cn([Zdr,Qdr]),thr=Cn([Xdr,Jdr,ehr]),rhr=Cn([thr,Hdr,zdr,Ydr]),nhr=Kw.extend({mode:wt("form").optional(),message:ue(),requestedSchema:ze({type:wt("object"),properties:$n(ue(),rhr),required:or(ue()).optional()})}),ihr=Kw.extend({mode:wt("url"),message:ue(),elicitationId:ue(),url:ue().url()}),ahr=Cn([nhr,ihr]),ohr=Ms.extend({method:wt("elicitation/create"),params:ahr}),shr=Kp.extend({elicitationId:ue()}),chr=Wp.extend({method:wt("notifications/elicitation/complete"),params:shr}),KC=ks.extend({action:pi(["accept","decline","cancel"]),content:Yw(e=>e===null?void 0:e,$n(ue(),Cn([ue(),On(),Mi(),or(ue())])).optional())}),uhr=ze({type:wt("ref/resource"),uri:ue()});var lhr=ze({type:wt("ref/prompt"),name:ue()}),phr=np.extend({ref:Cn([lhr,uhr]),argument:ze({name:ue(),value:ue()}),context:ze({arguments:$n(ue(),ue()).optional()}).optional()}),fhr=Ms.extend({method:wt("completion/complete"),params:phr});var dhr=ks.extend({completion:Ls({values:or(ue()).max(100),total:qn(On().int()),hasMore:qn(Mi())})}),hhr=ze({uri:ue().startsWith("file://"),name:ue().optional(),_meta:$n(ue(),Bn()).optional()}),mhr=Ms.extend({method:wt("roots/list"),params:np.optional()}),Sse=ks.extend({roots:or(hhr)}),ghr=Wp.extend({method:wt("notifications/roots/list_changed"),params:Kp.optional()}),_fi=Cn([L3,Jw,fhr,Ese,Sdr,_dr,ndr,adr,cdr,fdr,hdr,nL,_se,k3,U3,V3,j3]),Efi=Cn([w3,M3,fse,ghr,tL]),Tfi=Cn([I3,aL,Tse,KC,Sse,$3,F3,zC]),Sfi=Cn([L3,Gdr,ohr,mhr,k3,U3,V3,j3]),bfi=Cn([w3,M3,kdr,gdr,ldr,wdr,Pdr,tL,chr]),Afi=Cn([I3,Xfr,dhr,xdr,Edr,idr,odr,udr,B3,Rdr,$3,F3,zC]),jr=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===vn.UrlElicitationRequired&&n){let i=n;if(i.elicitations)return new ose(i.elicitations,r)}return new e(t,r,n)}},ose=class extends jr{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(vn.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function C_(e){return e==="completed"||e==="failed"||e==="cancelled"}var idi=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function bse(e){let r=XG(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=o2e(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Ase(e,t){let r=b_(e,t);if(!r.success)throw r.error;return r.data}var Shr=6e4,q3=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(w3,r=>{this._oncancel(r)}),this.setNotificationHandler(M3,r=>{this._onprogress(r)}),this.setRequestHandler(L3,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(k3,async(r,n)=>{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new jr(vn.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(U3,async(r,n)=>{let i=async()=>{let a=r.params.taskId;if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(a,n.sessionId);){if(s.type==="response"||s.type==="error"){let c=s.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),s.type==="response")l(c);else{let p=c,f=new jr(p.error.code,p.error.message,p.error.data);l(f)}else{let p=s.type==="response"?"Response":"Error";this._onerror(new Error(`${p} handler missing for request ${u}`))}continue}await this._transport?.send(s.message,{relatedRequestId:n.requestId})}}let o=await this._taskStore.getTask(a,n.sessionId);if(!o)throw new jr(vn.InvalidParams,`Task not found: ${a}`);if(!C_(o.status))return await this._waitForTaskUpdate(a,n.signal),await i();if(C_(o.status)){let s=await this._taskStore.getTaskResult(a,n.sessionId);return this._clearTaskQueue(a),{...s,_meta:{...s._meta,[O_]:{taskId:a}}}}return await i()};return await i()}),this.setRequestHandler(V3,async(r,n)=>{try{let{tasks:i,nextCursor:a}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:i,nextCursor:a,_meta:{}}}catch(i){throw new jr(vn.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(j3,async(r,n)=>{try{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new jr(vn.InvalidParams,`Task not found: ${r.params.taskId}`);if(C_(i.status))throw new jr(vn.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let a=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!a)throw new jr(vn.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...a}}catch(i){throw i instanceof jr?i:new jr(vn.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,i,a=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(i,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:a,onTimeout:i})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),jr.fromError(vn.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=a=>{n?.(a),this._onerror(a)};let i=this._transport?.onmessage;this._transport.onmessage=(a,o)=>{i?.(a,o),Ww(a)||bje(a)?this._onresponse(a):use(a)?this._onrequest(a,o):Sje(a)?this._onnotification(a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(a)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=jr.fromError(vn.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,i=this._transport,a=t.params?._meta?.[O_]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:vn.MethodNotFound,message:"Method not found"}};a&&this._taskMessageQueue?this._enqueueTaskMessage(a,{type:"error",message:l,timestamp:Date.now()},i?.sessionId).catch(p=>this._onerror(new Error(`Failed to enqueue error response: ${p}`))):i?.send(l).catch(p=>this._onerror(new Error(`Failed to send an error response: ${p}`)));return}let o=new AbortController;this._requestHandlerAbortControllers.set(t.id,o);let s=_je(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,i?.sessionId):void 0,u={signal:o.signal,sessionId:i?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(o.signal.aborted)return;let p={relatedRequestId:t.id};a&&(p.relatedTask={taskId:a}),await this.notification(l,p)},sendRequest:async(l,p,f)=>{if(o.signal.aborted)throw new jr(vn.ConnectionClosed,"Request was cancelled");let h={...f,relatedRequestId:t.id};a&&!h.relatedTask&&(h.relatedTask={taskId:a});let d=h.relatedTask?.taskId??a;return d&&c&&await c.updateTaskStatus(d,"input_required"),await this.request(l,p,h)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:a,taskStore:c,taskRequestedTtl:s?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{s&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async l=>{if(o.signal.aborted)return;let p={result:l,jsonrpc:"2.0",id:t.id};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"response",message:p,timestamp:Date.now()},i?.sessionId):await i?.send(p)},async l=>{if(o.signal.aborted)return;let p={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:vn.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"error",message:p,timestamp:Date.now()},i?.sessionId):await i?.send(p)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===o&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,i=Number(r),a=this._progressHandlers.get(i);if(!a){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let o=this._responseHandlers.get(i),s=this._timeoutInfo.get(i);if(s&&o&&s.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(c){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),o(c);return}a(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Ww(t))n(t);else{let o=new jr(t.error.code,t.error.message,t.error.data);n(o)}return}let i=this._responseHandlers.get(r);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let a=!1;if(Ww(t)&&t.result&&typeof t.result=="object"){let o=t.result;if(o.task&&typeof o.task=="object"){let s=o.task;typeof s.taskId=="string"&&(a=!0,this._taskProgressTokens.set(s.taskId,r))}}if(a||this._progressHandlers.delete(r),Ww(t))i(t);else{let o=jr.fromError(t.error.code,t.error.message,t.error.data);i(o)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:i}=n??{};if(!i){try{yield{type:"result",result:await this.request(t,r,n)}}catch(o){yield{type:"error",error:o instanceof jr?o:new jr(vn.InternalError,String(o))}}return}let a;try{let o=await this.request(t,zC,n);if(o.task)a=o.task.taskId,yield{type:"taskCreated",task:o.task};else throw new jr(vn.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:a},n);if(yield{type:"taskStatus",task:s},C_(s.status)){s.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)}:s.status==="failed"?yield{type:"error",error:new jr(vn.InternalError,`Task ${a} failed`)}:s.status==="cancelled"&&(yield{type:"error",error:new jr(vn.InternalError,`Task ${a} was cancelled`)});return}if(s.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)};return}let c=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(o){yield{type:"error",error:o instanceof jr?o:new jr(vn.InternalError,String(o))}}}request(t,r,n){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,task:s,relatedTask:c}=n??{};return new Promise((u,l)=>{let p=C=>{l(C)};if(!this._transport){p(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),s&&this.assertTaskCapability(t.method)}catch(C){p(C);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,h={...t,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),h.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),s&&(h.params={...h.params,task:s}),c&&(h.params={...h.params,_meta:{...h.params?._meta||{},[O_]:c}});let d=C=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(C)}},{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(I=>this._onerror(new Error(`Failed to send cancellation: ${I}`)));let O=C instanceof jr?C:new jr(vn.RequestTimeout,String(C));l(O)};this._responseHandlers.set(f,C=>{if(!n?.signal?.aborted){if(C instanceof Error)return l(C);try{let O=b_(r,C.result);O.success?u(O.data):l(O.error)}catch(O){l(O)}}}),n?.signal?.addEventListener("abort",()=>{d(n?.signal?.reason)});let g=n?.timeout??Shr,E=()=>d(jr.fromError(vn.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(f,g,n?.maxTotalTimeout,E,n?.resetTimeoutOnProgress??!1);let S=c?.taskId;if(S){let C=O=>{let I=this._responseHandlers.get(f);I?I(O):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,C),this._enqueueTaskMessage(S,{type:"request",message:h,timestamp:Date.now()}).catch(O=>{this._cleanupTimeout(f),l(O)})}else this._transport.send(h,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(C=>{this._cleanupTimeout(f),l(C)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},$3,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},F3,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Cje,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let s={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[O_]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:s,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let s={...t,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[O_]:r.relatedTask}}}),this._transport?.send(s,r).catch(c=>this._onerror(c))});return}let o={...t,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[O_]:r.relatedTask}}}),await this._transport.send(o,r)}setRequestHandler(t,r){let n=bse(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(i,a)=>{let o=Ase(t,i);return Promise.resolve(r(o,a))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=bse(t);this._notificationHandlers.set(n,i=>{let a=Ase(t,i);return Promise.resolve(r(a))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let i=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,i)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let i of n)if(i.type==="request"&&use(i.message)){let a=i.message.id,o=this._requestResolvers.get(a);o?(o(new jr(vn.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(a)):this._onerror(new Error(`Resolver missing for request ${a} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let i=await this._taskStore?.getTask(t);i?.pollInterval&&(n=i.pollInterval)}catch{}return new Promise((i,a)=>{if(r.aborted){a(new jr(vn.InvalidRequest,"Request cancelled"));return}let o=setTimeout(i,n);r.addEventListener("abort",()=>{clearTimeout(o),a(new jr(vn.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async i=>{if(!t)throw new Error("No request provided");return await n.createTask(i,t.id,{method:t.method,params:t.params},r)},getTask:async i=>{let a=await n.getTask(i,r);if(!a)throw new jr(vn.InvalidParams,"Failed to retrieve task: Task not found");return a},storeTaskResult:async(i,a,o)=>{await n.storeTaskResult(i,a,o,r);let s=await n.getTask(i,r);if(s){let c=tL.parse({method:"notifications/tasks/status",params:s});await this.notification(c),C_(s.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>n.getTaskResult(i,r),updateTaskStatus:async(i,a,o)=>{let s=await n.getTask(i,r);if(!s)throw new jr(vn.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(C_(s.status))throw new jr(vn.InvalidParams,`Cannot update task "${i}" from terminal status "${s.status}" to "${a}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(i,a,o,r);let c=await n.getTask(i,r);if(c){let u=tL.parse({method:"notifications/tasks/status",params:c});await this.notification(u),C_(c.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>n.listTasks(i,r)}}};function Ije(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function wje(e,t){let r={...e};for(let n in t){let i=n,a=t[i];if(a===void 0)continue;let o=r[i];Ije(o)&&Ije(a)?r[i]={...o,...a}:r[i]=a}return r}var _Ge=lr(AH(),1),EGe=lr(vGe(),1);function dEr(){let e=new _Ge.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,EGe.default)(e),e}var CH=class{constructor(t){this._ajv=t??dEr()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var xH=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let i=t.messages[t.messages.length-1],a=Array.isArray(i.content)?i.content:[i.content],o=a.some(l=>l.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=s?Array.isArray(s.content)?s.content:[s.content]:[],u=c.some(l=>l.type==="tool_use");if(o){if(a.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),p=new Set(a.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==p.size||![...l].every(f=>p.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},aL,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),i=t.mode??"form";switch(i){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let a=i==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:a},KC,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function TGe(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function SGe(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var PH=class extends q3{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(iL.options.map((n,i)=>[n,i])),this.isMessageIgnored=(n,i)=>{let a=this._loggingLevels.get(i);return a?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(a):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new CH,this.setRequestHandler(Jw,n=>this._oninitialize(n)),this.setNotificationHandler(fse,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Ese,async(n,i)=>{let a=i.sessionId||i.requestInfo?.headers["mcp-session-id"]||void 0,{level:o}=n.params,s=iL.safeParse(o);return s.success&&this._loggingLevels.set(a,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new xH(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=wje(this._capabilities,t)}setRequestHandler(t,r){let i=XG(t)?.method;if(!i)throw new Error("Schema is missing a method literal");let a;if($C(i)){let s=i;a=s._zod?.def?.value??s.value}else{let s=i;a=s._def?.value??s.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");if(a==="tools/call"){let s=async(c,u)=>{let l=b_(nL,c);if(!l.success){let d=l.error instanceof Error?l.error.message:String(l.error);throw new jr(vn.InvalidParams,`Invalid tools/call request: ${d}`)}let{params:p}=l.data,f=await Promise.resolve(r(c,u));if(p.task){let d=b_(zC,f);if(!d.success){let g=d.error instanceof Error?d.error.message:String(d.error);throw new jr(vn.InvalidParams,`Invalid task creation result: ${g}`)}return d.data}let h=b_(B3,f);if(!h.success){let d=h.error instanceof Error?h.error.message:String(h.error);throw new jr(vn.InvalidParams,`Invalid tools/call result: ${d}`)}return h.data};return super.setRequestHandler(t,s)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){SGe(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&TGe(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:gje.includes(r)?r:sse,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},I3)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],i=Array.isArray(n.content)?n.content:[n.content],a=i.some(u=>u.type==="tool_result"),o=t.messages.length>1?t.messages[t.messages.length-2]:void 0,s=o?Array.isArray(o.content)?o.content:[o.content]:[],c=s.some(u=>u.type==="tool_use");if(a){if(i.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(s.filter(p=>p.type==="tool_use").map(p=>p.id)),l=new Set(i.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(u.size!==l.size||![...u].every(p=>l.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},Tse,r):this.request({method:"sampling/createMessage",params:t},aL,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let i=t;return this.request({method:"elicitation/create",params:i},KC,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let i=t.mode==="form"?t:{...t,mode:"form"},a=await this.request({method:"elicitation/create",params:i},KC,r);if(a.action==="accept"&&a.content&&i.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(i.requestedSchema)(a.content);if(!s.valid)throw new jr(vn.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(o){throw o instanceof jr?o:new jr(vn.InternalError,`Error validating elicitation response: ${o instanceof Error?o.message:String(o)}`)}return a}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},Sse,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var gue=lr(require("node:process"),1);var DH=class{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
1501
1501
|
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),hEr(r)}clear(){this._buffer=void 0}};function hEr(e){return Aje.parse(JSON.parse(e))}function bGe(e){return JSON.stringify(e)+`
|
|
1502
|
-
`}var NH=class{constructor(t=gue.default.stdin,r=gue.default.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new DH,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=bGe(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var OGe="0.6.48";var ob={name:"@sap-ux/fiori-mcp-server",description:"SAP Fiori - Model Context Protocol (MCP) server",version:OGe,keywords:["SAP Fiori tools","SAP Fiori elements","SAP Fiori freestyle","MCP","AI"],repository:{type:"git",url:"https://github.com/SAP/open-ux-tools.git",directory:"packages/fiori-mcp-server"},bugs:{url:"https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Afiori-mcp-server"},license:"Apache-2.0",main:"dist/index.js",scripts:{"build-esbuild-base":"esbuild --bundle --platform=node --target=node20 --outdir=dist --external:vscode --external:@lancedb/lancedb --external:@xenova/transformers --external:@sap-ux/fiori-docs-embeddings --external:@sap-ux/store --main-fields=module,main src/index.ts","build-dev":"pnpm run build-esbuild-base --sourcemap=inline","build-compile":"tsc --noEmit","build-bundle":"pnpm run build-esbuild-base --minify && pnpm run copy-icons","copy-icons":`node -e "const fs=require('node:fs');const path=require('node:path');['icon.png','icon.svg'].forEach(f=>fs.copyFileSync(path.join('assets',f),path.join('dist',f)))"`,build:"npm-run-all build-compile build-bundle",watch:"tsc --watch",bundle:"npm-run-all build tgz:package tgz:rename","tgz:package":"pnpm pack","tgz:rename":"node -e \"const fs=require('fs'), p=require('./package.json'), d=new Date().toISOString().split('T')[0], oldName=p.name.startsWith('@') ? `${p.name.replace('@', '').replace('/', '-')}-${p.version}.tgz` : `${p.name}-${p.version}.tgz`; fs.renameSync(oldName, `${oldName.replace('.tgz','')}-${d}.tgz`)\"",clean:"rimraf --glob dist test/test-output *.tsbuildinfo",format:"prettier --write '**/*.{js,json,ts,yaml,yml}' --ignore-path ../../.prettierignore",lint:"eslint","lint:fix":"eslint --fix",test:"jest --ci --forceExit --detectOpenHandles --colors",inspector:"npx @modelcontextprotocol/inspector node dist/index.js","inspector-ts":"npx @modelcontextprotocol/inspector ts-node -T src/index.ts --log-level=debug",start:'npx -y supergateway --port 9881 --sessionTimeout 300000 --stdio "node ./dist/index.js"',"view:integration":"promptfoo view -y","test:integration:once":"promptfoo eval --config test/integration/scenarios/promptfooconfig.yaml --max-concurrency 1 --repeat 1 --output reports/integration.txt","test:integration:dev":"promptfoo eval --config test/integration/scenarios/test-dev.yaml --max-concurrency 1 --repeat 1 --output reports/integration.txt","test:integration:multiple":"npm run test:promptfoo -- --repeat 5"},files:["LICENSE","dist","!dist/**/*.map","assets/icon.svg","assets/icon.png"],bin:{"fiori-mcp":"./dist/index.js"},devDependencies:{"npm-run-all2":"8.0.4",esbuild:"0.27.4","@modelcontextprotocol/sdk":"1.29.0","@sap-ux/axios-extension":"workspace:*","@sap/ux-specification":"1.144.0","@sap-ux/project-access":"workspace:*","@sap-ux/fiori-annotation-api":"workspace:*","@sap-ux/annotation-converter":"0.10.21","@sap-ux/vocabularies-types":"0.15.0","@sap-ux/edmx-parser":"0.10.0","@sap-ux/fiori-docs-embeddings":"workspace:*","@sap-ux/i18n":"workspace:*","@sap-ux/logger":"workspace:*","@sap-ux/odata-annotation-core-types":"workspace:*","@sap-ux/odata-entity-model":"workspace:*","@sap-ux/text-document-utils":"workspace:*","@types/json-schema":"7.0.15","@types/mem-fs":"1.1.2","@types/mem-fs-editor":"7.0.1","@sap-ux/btp-utils":"workspace:*","@sap-ux/feature-toggle":"workspace:*","@sap-ux/nodejs-utils":"workspace:*","@sap-ux/telemetry":"workspace:*",i18next:"25.10.10","os-name":"4.0.1","ts-node":"10.9.2",zod:"4.3.6","@sap-ai-sdk/foundation-models":"2.9.0","@sap-ai-sdk/langchain":"2.9.0",promptfoo:"0.121.3","@langchain/mcp-adapters":"1.1.3","@langchain/core":"1.1.36"},dependencies:{"@sap-ux/fiori-docs-embeddings":"workspace:*","@sap-ux/store":"workspace:*","@xenova/transformers":"2.17.2","@lancedb/lancedb":"0.22.0","mem-fs":"2.1.0","mem-fs-editor":"9.4.0"},engines:{node:">=20.x"}};var PGe=ze({name:ue().describe("Name of the Fiori application. Usually derived from the `sap.app/id` field in the application's manifest.json."),appPath:ue().describe("Absolute path to the Fiori application's root directory."),projectPath:ue().describe("Absolute path to the root directory of the project containing this Fiori application. For EDMXBackend (standalone) projects, this is the same as `appPath`. For CAP projects, this points to the CAP project root, which may contain multiple Fiori applications."),projectType:pi(["EDMXBackend","CAPJava","CAPNodejs"]).describe("Type of project the application belongs to."),odataVersion:ue().describe("OData protocol version used by the application's main service.")}),cb=Cn([ue(),or(Cn([ue(),On()]))]),DGe=ze({functionalityId:cb.describe("Identifier to pass as the `functionalityId` parameter when calling `get_functionality_details` or `execute_functionality`"),description:ue()}),CGe=pi(["object","array","string","number","boolean","null","integer","any"]),xGe=ze({type:Cn([CGe,or(CGe)]).optional(),description:ue().optional(),properties:Fw().optional()}).catchall(Fw()),NGe=xGe.extend({properties:$n(ue(),Cn([xGe,Mi()])).optional()});var RGe=ze({searchPath:or(ue()).describe("Path to search for Fiori applications (defaults to current directory). If VSCode - list of VS Code workspace folder paths(`workspace.workspaceFolders`)")}),IGe=ze({appPath:ue().describe("Path to the root folder of the Fiori application (where package.json and ui5.yaml reside) if one exists or to the current directory. Path should be an absolute path.")}),wGe=ze({appPath:ue().describe("Path to the Fiori application if one exists or to the current directory. Path should be an absolute path."),functionalityId:cb.describe("The ID of the functionality to get details for")}),LGe=ze({functionalityId:cb.describe("The ID of the functionality to execute"),parameters:$n(ue(),Bn()).describe("Parameters for the functionality execution"),appPath:ue().describe("Path to the Fiori application if one exists or to the current directory. Path should be an absolute path.")}).describe('Input object for executing a functionality. Only three top-level properties are allowed: "functionalityId", "parameters", and "appPath". All other dynamic or functionality-specific inputs must be included inside the "parameters" object. Do not place any additional fields at the root level.'),Vyi=ze({query:ue().min(2).describe("The search query for fiori elements, annotations, sapui5, fiori tools documentation")});var jyi=ue().describe("Search results as formatted text"),MGe=ze({applications:or(PGe)}),kGe=ze({applicationPath:ue(),functionalities:or(DGe)}),$Ge=ze({functionalityId:cb.describe("Identifier to pass as the `functionalityId` parameter when calling `get_functionality_details` or `execute_functionality`"),name:ue(),description:ue(),technicalDescription:ue().optional(),parameters:NGe,prerequisites:or(ue()).optional(),impact:ue().optional(),examples:or(ue()).optional(),pageName:ue().optional()}),UGe=ze({functionalityId:cb,status:ue(),message:ue(),parameters:Bn(),appPath:ue(),changes:or(ue()),timestamp:ue()});var U_e=lr(require("node:fs/promises")),vf=lr(require("node:path"));var pu=lr(J_()),Ilt=lr(yf()),wlt=require("node:path");function CJr(){let e=globalThis.LOG_LEVEL,t=process.env.LOG_LEVEL,r=process.argv.find(i=>i.startsWith("--log-level="))?.split("=")[1],n=e??t??r;if(n)switch(n.toUpperCase()){case"OFF":return;case"ERROR":return pu.LogLevel.Error;case"WARN":return pu.LogLevel.Warn;case"INFO":return pu.LogLevel.Info;case"DEBUG":return pu.LogLevel.Debug;case"VERBOSE":return pu.LogLevel.Verbose;case"SILLY":return pu.LogLevel.Silly;default:break}return pu.LogLevel.Error}var Rlt=CJr(),Lt=new pu.ToolsLogger({logLevel:Rlt??pu.LogLevel.Error,transports:Rlt===void 0?[new pu.NullTransport]:[new pu.FileTransport({filename:(0,wlt.join)(Ilt.fioriToolsDirectory,"fiori-mcp-server.log"),maxsize:10*1024*1024,maxFiles:5})],logPrefix:"fiori-mcp"}),g$={info:(e,...t)=>{Lt.info(`@sap/ux-specification: ${e}`);for(let r of t)Lt.info(typeof r=="number"?r.toString():r)},warning:(e,...t)=>{Lt.warn(`@sap/ux-specification: ${e}`);for(let r of t)Lt.warn(typeof r=="number"?r.toString():r)},error:(e,...t)=>{Lt.error(`@sap/ux-specification: ${e}`);for(let r of t)Lt.error(typeof r=="number"?r.toString():r)},reset:()=>{}};async function Llt(){try{let r;try{r=require("@sap-ux/fiori-docs-embeddings")}catch{try{r=await import("@sap-ux/fiori-docs-embeddings")}catch{r=null}}if(!r||typeof r.getDataPath!="function")throw new Error("Package not found or invalid");let n=r.getDataPath();return await U_e.default.access(n),Lt.log("\u2713 Using @sap-ux/fiori-docs-embeddings package"),{dataPath:n,embeddingsPath:vf.default.join(n,"embeddings"),searchPath:vf.default.join(n,"search"),docsPath:vf.default.join(n,"docs"),isExternalPackage:!0,isAvailable:!0}}catch{Lt.warn("Could not load @sap-ux/fiori-docs-embeddings package, trying local data...")}let e=vf.default.join(__dirname,"../../data");try{return await U_e.default.access(e),Lt.log("\u2713 Using local data directory"),{dataPath:e,embeddingsPath:vf.default.join(e,"embeddings"),searchPath:vf.default.join(e,"search"),docsPath:vf.default.join(e,"docs"),isExternalPackage:!1,isAvailable:!0}}catch{Lt.warn("Local data directory not available either")}let t=vf.default.join(__dirname,"../../data");return Lt.warn("\u26A0\uFE0F No embeddings data available - running in limited mode"),{dataPath:t,embeddingsPath:vf.default.join(t,"embeddings"),searchPath:vf.default.join(t,"search"),docsPath:vf.default.join(t,"docs"),isExternalPackage:!1,isAvailable:!1}}var bc=lr(yf()),y$=require("node:path");async function fu(e){try{e=(0,y$.join)(e);try{let t=await(0,bc.createApplicationAccess)(e);return{root:t.project.root,appId:t.getAppId(),applicationAccess:t}}catch(t){Lt.warn(`Application was not found by given path. Error: ${t}`);let r=await(0,bc.findProjectRoot)(e),n=await(0,bc.getProject)(r);if(n)return{root:n.root,appId:""}}}catch(t){Lt.warn(`Project was not found by given path. Error: ${t}`);return}}var kY=e=>{let t;switch(e){case bc.DirName.View:{t=(0,y$.join)(bc.DirName.Ext,bc.DirName.View);break}case bc.DirName.Fragment:{t=(0,y$.join)(bc.DirName.Ext,bc.DirName.Fragment);break}case bc.DirName.Controller:{t=(0,y$.join)(bc.DirName.Ext,bc.DirName.Controller);break}default:t=e}return t},cm=(e,t,r=new Set)=>{if(!e||typeof e!="object")return{};if(e.$ref?.startsWith("#/definitions/")){let i=e.$ref,a=i.replace("#/definitions/",""),o=t.definitions?.[a]??null;if(r.has(i))return{...o};if(r.add(i),o){let s={...e};return delete s.$ref,cm({...o,...s},t,r)}}let n={...e};return n.properties&&(n.properties=Object.fromEntries(Object.entries(n.properties).map(([i,a])=>[i,cm(a,t,r)]))),n.items&&(Array.isArray(n.items)?n.items=n.items.map(i=>cm(i,t,r)):n.items=cm(n.items,t,r)),n.allOf&&(n.allOf=n.allOf.map(i=>cm(i,t,r))),n.anyOf&&(n.anyOf=n.anyOf.map(i=>cm(i,t,r))),n.oneOf&&(n.oneOf=n.oneOf.map(i=>cm(i,t,r))),typeof n.additionalProperties=="object"&&(n.additionalProperties=cm(n.additionalProperties,t,r)),n},Mlt=(e,t)=>({type:"object",properties:{[e]:t}}),wa=e=>{let t=S_(e);return delete t.$schema,t},um=(e,t)=>{try{return e.parse(t)}catch(r){throw r instanceof aoe?new Error(`Missing required fields in parameters. ${JSON.stringify(r.issues,null,4)}`):new Error("Unknown error. Recheck input parameters.")}};var Rbt=require("node:util"),Ibt=require("node:child_process"),wbt=lr(mAe());async function ZK(e="1.18.5"){let t="@sap/generator-fiori";if((await(0,wbt.findInstalledPackages)(t,{minVersion:e}))?.length<1)throw new Error(`Fiori generator not found. Please install the Fiori generator >=${e} with 'npm install -g ${t}' and retry this call`)}var QK=(0,Rbt.promisify)(Ibt.exec);var Lbt=require("@lancedb/lancedb");var gAe=lr(require("node:fs/promises")),yAe=lr(require("node:path")),e9=class{connection=null;tables=[];tableIndex=null;metadata=null;dataPath;constructor(t){this.dataPath=t||""}async initialize(){try{Lt.log("Loading vector database from pre-built embeddings...");let t=await Llt();if(!t.isAvailable)throw new Error("No embeddings data available");this.dataPath=t.embeddingsPath,Lt.log(`Using embeddings path: ${this.dataPath} (external: ${t.isExternalPackage})`);let r=yAe.default.join(this.dataPath,"metadata.json"),n=await gAe.default.readFile(r,"utf-8");this.metadata=JSON.parse(n),Lt.log("\u2713 Embedding metadata loaded:"),Lt.log(` Model: ${this?.metadata?.model}`),Lt.log(` Dimensions: ${this?.metadata?.dimensions}`),Lt.log(` Total vectors: ${this?.metadata?.totalVectors}`),Lt.log(` Created: ${this?.metadata?.createdAt}`),this.connection=await(0,Lbt.connect)(this.dataPath);let i=yAe.default.join(this.dataPath,"table_index.json");try{let a=await gAe.default.readFile(i,"utf-8");this.tableIndex=JSON.parse(a),this.tables=[];for(let o of this.tableIndex?.tables||[]){let s=await this.connection.openTable(o);this.tables.push(s)}Lt.log(`\u2713 Loaded ${this.tables.length} split tables`)}catch{Lt.log("No table index found, trying single table...");try{let a=await this.connection.openTable("documents");this.tables=[a],this.tableIndex={tables:["documents"],totalTables:1,maxVectorsPerTable:-1,totalVectors:this.metadata?.totalVectors||0}}catch(a){throw new Error(`No tables found: ${a}`)}}Lt.log("\u2713 Vector database loaded and ready")}catch(t){throw new Error(`Failed to load vector database: ${t}`)}}async semanticSearch(t,r=10,n){if(this.tables.length===0)throw new Error("Vector database not initialized");try{let i=[];for(let o of this.tables){let s=o.vectorSearch(t).limit(r*2);n&&(s=s.where(`category = "${n}"`));let c=await s.toArray();i.push(...c)}return i.sort((o,s)=>(o._distance||0)-(s._distance||0)),i.slice(0,r).map(o=>({document:{id:o.document_id,vector:o.vector,content:o.content,title:o.title,category:o.category,path:o.path,chunk_index:o.chunk_index,metadata:{tags:this.parseJsonField(o.tags_json)||[],headers:this.parseJsonField(o.headers_json)||[],lastModified:new Date(o.lastModified),wordCount:o.wordCount,excerpt:o.excerpt}},score:1-(o._distance||0),distance:o._distance||0}))}catch(i){throw Lt.error(`Semantic search failed: ${i}`),new Error(`Semantic search failed: ${i}`)}}async findSimilarToText(t,r=5){return Lt.warn("findSimilarToText requires embedding generation - not available in simplified mode"),[]}async findSimilarToDocument(t,r=5){if(this.tables.length===0)throw new Error("Vector database not initialized");try{let n=null;for(let s of this.tables){let c=await s.search("").where(`document_id = "${t}" AND chunk_index = 0`).limit(1).toArray();if(c.length>0){n=c[0].vector;break}}if(!n)return[];let i=[];for(let s of this.tables){let c=await s.vectorSearch(n).where(`document_id != "${t}"`).limit(r*2).toArray();i.push(...c)}let a=new Map;for(let s of i){let c=s.document_id,u=1-(s._distance||0);(!a.has(c)||a.get(c).score<u)&&a.set(c,{...s,score:u,distance:s._distance||0})}return Array.from(a.values()).sort((s,c)=>c.score-s.score).slice(0,r).map(s=>({document:{id:s.document_id,vector:s.vector,content:s.content,title:s.title,category:s.category,path:s.path,chunk_index:s.chunk_index,metadata:{tags:this.parseJsonField(s.tags_json)||[],headers:this.parseJsonField(s.headers_json)||[],lastModified:new Date(s.lastModified),wordCount:s.wordCount,excerpt:s.excerpt}},score:s.score,distance:s.distance}))}catch(n){return Lt.error(`Find similar documents failed: ${n}`),[]}}async getDocumentsByCategory(t,r){if(this.tables.length===0)throw new Error("Vector database not initialized");try{let n=[];for(let a of this.tables){let o=a.search("").where(`category = "${t}" AND chunk_index = 0`);r&&(o=o.limit(Math.ceil(r/this.tables.length)+10));let s=await o.toArray();n.push(...s)}return(r?n.slice(0,r):n).map(a=>({document:{id:a.document_id,vector:a.vector,content:a.content,title:a.title,category:a.category,path:a.path,chunk_index:a.chunk_index,metadata:{tags:this.parseJsonField(a.tags_json)||[],headers:this.parseJsonField(a.headers_json)||[],lastModified:new Date(a.lastModified),wordCount:a.wordCount,excerpt:a.excerpt}},score:1,distance:0}))}catch(n){return Lt.error(`Get documents by category failed: ${n}`),[]}}getMetadata(){return this.metadata}parseJsonField(t){try{return t?JSON.parse(t):[]}catch{return[]}}isInitialized(){return this.tables.length>0&&this.metadata!==null}async close(){this.connection&&(this.connection=null,this.tables=[],Lt.log("Vector database connection closed"))}};var t9=class{pipeline=null;initialized=!1;async initialize(){if(!this.initialized)try{let{pipeline:t}=await import("@xenova/transformers");this.pipeline=await t("feature-extraction","Xenova/all-MiniLM-L6-v2",{quantized:!1}),this.initialized=!0}catch(t){throw new Error(`Failed to initialize text embedding service: ${t}. Make sure @xenova/transformers is available.`)}}async generateEmbedding(t){if(!this.initialized||!this.pipeline)throw new Error("Text embedding service not initialized. Call initialize() first.");try{let r=t.replace(/\n+/g," ").replace(/\s+/g," ").trim().substring(0,8192);if(!r)throw new Error("Empty text provided for embedding");let n=await this.pipeline(r,{pooling:"mean",normalize:!0});return Array.from(n.data)}catch(r){throw new Error(`Failed to generate embedding: ${r}`)}}isInitialized(){return this.initialized}};async function vAe(e,t=!1){let{query:r,maxResults:n}=e;try{let i=new e9,a=new t9;await i.initialize(),await a.initialize();let o=await a.generateEmbedding(r),s=await i.semanticSearch(o,n??10);if(t){let c="";for(let[u,l]of s.entries())c+=`Result ${u+1}:
|
|
1502
|
+
`}var NH=class{constructor(t=gue.default.stdin,r=gue.default.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new DH,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=bGe(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var OGe="0.6.49";var ob={name:"@sap-ux/fiori-mcp-server",description:"SAP Fiori - Model Context Protocol (MCP) server",version:OGe,mcpName:"io.github.SAP/fiori-mcp-server",keywords:["SAP Fiori tools","SAP Fiori elements","SAP Fiori freestyle","MCP","AI"],repository:{type:"git",url:"https://github.com/SAP/open-ux-tools.git",directory:"packages/fiori-mcp-server"},bugs:{url:"https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Afiori-mcp-server"},license:"Apache-2.0",main:"dist/index.js",scripts:{"build-esbuild-base":"esbuild --bundle --platform=node --target=node20 --outdir=dist --external:vscode --external:@lancedb/lancedb --external:@xenova/transformers --external:@sap-ux/fiori-docs-embeddings --external:@sap-ux/store --main-fields=module,main src/index.ts","build-dev":"pnpm run build-esbuild-base --sourcemap=inline","build-compile":"tsc --noEmit","build-bundle":"pnpm run build-esbuild-base --minify && pnpm run copy-icons","copy-icons":`node -e "const fs=require('node:fs');const path=require('node:path');['icon.png','icon.svg'].forEach(f=>fs.copyFileSync(path.join('assets',f),path.join('dist',f)))"`,build:"npm-run-all build-compile build-bundle",watch:"tsc --watch",bundle:"npm-run-all build tgz:package tgz:rename","tgz:package":"pnpm pack","tgz:rename":"node -e \"const fs=require('fs'), p=require('./package.json'), d=new Date().toISOString().split('T')[0], oldName=p.name.startsWith('@') ? `${p.name.replace('@', '').replace('/', '-')}-${p.version}.tgz` : `${p.name}-${p.version}.tgz`; fs.renameSync(oldName, `${oldName.replace('.tgz','')}-${d}.tgz`)\"",clean:"rimraf --glob dist test/test-output *.tsbuildinfo",format:"prettier --write '**/*.{js,json,ts,yaml,yml}' --ignore-path ../../.prettierignore",lint:"eslint","lint:fix":"eslint --fix",test:"jest --ci --forceExit --detectOpenHandles --colors",inspector:"npx @modelcontextprotocol/inspector node dist/index.js","inspector-ts":"npx @modelcontextprotocol/inspector ts-node -T src/index.ts --log-level=debug",start:'npx -y supergateway --port 9881 --sessionTimeout 300000 --stdio "node ./dist/index.js"',"view:integration":"promptfoo view -y","test:integration:once":"promptfoo eval --config test/integration/scenarios/promptfooconfig.yaml --max-concurrency 1 --repeat 1 --output reports/integration.txt","test:integration:dev":"promptfoo eval --config test/integration/scenarios/test-dev.yaml --max-concurrency 1 --repeat 1 --output reports/integration.txt","test:integration:multiple":"npm run test:promptfoo -- --repeat 5"},files:["LICENSE","dist","!dist/**/*.map","assets/icon.svg","assets/icon.png"],bin:{"fiori-mcp":"./dist/index.js"},devDependencies:{"npm-run-all2":"8.0.4",esbuild:"0.27.4","@modelcontextprotocol/sdk":"1.29.0","@sap-ux/axios-extension":"workspace:*","@sap/ux-specification":"1.144.0","@sap-ux/project-access":"workspace:*","@sap-ux/fiori-annotation-api":"workspace:*","@sap-ux/annotation-converter":"0.10.21","@sap-ux/vocabularies-types":"0.15.0","@sap-ux/edmx-parser":"0.10.0","@sap-ux/fiori-docs-embeddings":"workspace:*","@sap-ux/i18n":"workspace:*","@sap-ux/logger":"workspace:*","@sap-ux/odata-annotation-core-types":"workspace:*","@sap-ux/odata-entity-model":"workspace:*","@sap-ux/text-document-utils":"workspace:*","@types/json-schema":"7.0.15","@types/mem-fs":"1.1.2","@types/mem-fs-editor":"7.0.1","@sap-ux/btp-utils":"workspace:*","@sap-ux/feature-toggle":"workspace:*","@sap-ux/nodejs-utils":"workspace:*","@sap-ux/telemetry":"workspace:*",i18next:"25.10.10","os-name":"4.0.1","ts-node":"10.9.2",zod:"4.3.6","@sap-ai-sdk/foundation-models":"2.9.0","@sap-ai-sdk/langchain":"2.9.0",promptfoo:"0.121.3","@langchain/mcp-adapters":"1.1.3","@langchain/core":"1.1.36"},dependencies:{"@sap-ux/fiori-docs-embeddings":"workspace:*","@sap-ux/store":"workspace:*","@xenova/transformers":"2.17.2","@lancedb/lancedb":"0.22.0","mem-fs":"2.1.0","mem-fs-editor":"9.4.0"},engines:{node:">=20.x"}};var PGe=ze({name:ue().describe("Name of the Fiori application. Usually derived from the `sap.app/id` field in the application's manifest.json."),appPath:ue().describe("Absolute path to the Fiori application's root directory."),projectPath:ue().describe("Absolute path to the root directory of the project containing this Fiori application. For EDMXBackend (standalone) projects, this is the same as `appPath`. For CAP projects, this points to the CAP project root, which may contain multiple Fiori applications."),projectType:pi(["EDMXBackend","CAPJava","CAPNodejs"]).describe("Type of project the application belongs to."),odataVersion:ue().describe("OData protocol version used by the application's main service.")}),cb=Cn([ue(),or(Cn([ue(),On()]))]),DGe=ze({functionalityId:cb.describe("Identifier to pass as the `functionalityId` parameter when calling `get_functionality_details` or `execute_functionality`"),description:ue()}),CGe=pi(["object","array","string","number","boolean","null","integer","any"]),xGe=ze({type:Cn([CGe,or(CGe)]).optional(),description:ue().optional(),properties:Fw().optional()}).catchall(Fw()),NGe=xGe.extend({properties:$n(ue(),Cn([xGe,Mi()])).optional()});var RGe=ze({searchPath:or(ue()).describe("Path to search for Fiori applications (defaults to current directory). If VSCode - list of VS Code workspace folder paths(`workspace.workspaceFolders`)")}),IGe=ze({appPath:ue().describe("Path to the root folder of the Fiori application (where package.json and ui5.yaml reside) if one exists or to the current directory. Path should be an absolute path.")}),wGe=ze({appPath:ue().describe("Path to the Fiori application if one exists or to the current directory. Path should be an absolute path."),functionalityId:cb.describe("The ID of the functionality to get details for")}),LGe=ze({functionalityId:cb.describe("The ID of the functionality to execute"),parameters:$n(ue(),Bn()).describe("Parameters for the functionality execution"),appPath:ue().describe("Path to the Fiori application if one exists or to the current directory. Path should be an absolute path.")}).describe('Input object for executing a functionality. Only three top-level properties are allowed: "functionalityId", "parameters", and "appPath". All other dynamic or functionality-specific inputs must be included inside the "parameters" object. Do not place any additional fields at the root level.'),Vyi=ze({query:ue().min(2).describe("The search query for fiori elements, annotations, sapui5, fiori tools documentation")});var jyi=ue().describe("Search results as formatted text"),MGe=ze({applications:or(PGe)}),kGe=ze({applicationPath:ue(),functionalities:or(DGe)}),$Ge=ze({functionalityId:cb.describe("Identifier to pass as the `functionalityId` parameter when calling `get_functionality_details` or `execute_functionality`"),name:ue(),description:ue(),technicalDescription:ue().optional(),parameters:NGe,prerequisites:or(ue()).optional(),impact:ue().optional(),examples:or(ue()).optional(),pageName:ue().optional()}),UGe=ze({functionalityId:cb,status:ue(),message:ue(),parameters:Bn(),appPath:ue(),changes:or(ue()),timestamp:ue()});var U_e=lr(require("node:fs/promises")),vf=lr(require("node:path"));var pu=lr(J_()),Ilt=lr(yf()),wlt=require("node:path");function CJr(){let e=globalThis.LOG_LEVEL,t=process.env.LOG_LEVEL,r=process.argv.find(i=>i.startsWith("--log-level="))?.split("=")[1],n=e??t??r;if(n)switch(n.toUpperCase()){case"OFF":return;case"ERROR":return pu.LogLevel.Error;case"WARN":return pu.LogLevel.Warn;case"INFO":return pu.LogLevel.Info;case"DEBUG":return pu.LogLevel.Debug;case"VERBOSE":return pu.LogLevel.Verbose;case"SILLY":return pu.LogLevel.Silly;default:break}return pu.LogLevel.Error}var Rlt=CJr(),Lt=new pu.ToolsLogger({logLevel:Rlt??pu.LogLevel.Error,transports:Rlt===void 0?[new pu.NullTransport]:[new pu.FileTransport({filename:(0,wlt.join)(Ilt.fioriToolsDirectory,"fiori-mcp-server.log"),maxsize:10*1024*1024,maxFiles:5})],logPrefix:"fiori-mcp"}),g$={info:(e,...t)=>{Lt.info(`@sap/ux-specification: ${e}`);for(let r of t)Lt.info(typeof r=="number"?r.toString():r)},warning:(e,...t)=>{Lt.warn(`@sap/ux-specification: ${e}`);for(let r of t)Lt.warn(typeof r=="number"?r.toString():r)},error:(e,...t)=>{Lt.error(`@sap/ux-specification: ${e}`);for(let r of t)Lt.error(typeof r=="number"?r.toString():r)},reset:()=>{}};async function Llt(){try{let r;try{r=require("@sap-ux/fiori-docs-embeddings")}catch{try{r=await import("@sap-ux/fiori-docs-embeddings")}catch{r=null}}if(!r||typeof r.getDataPath!="function")throw new Error("Package not found or invalid");let n=r.getDataPath();return await U_e.default.access(n),Lt.log("\u2713 Using @sap-ux/fiori-docs-embeddings package"),{dataPath:n,embeddingsPath:vf.default.join(n,"embeddings"),searchPath:vf.default.join(n,"search"),docsPath:vf.default.join(n,"docs"),isExternalPackage:!0,isAvailable:!0}}catch{Lt.warn("Could not load @sap-ux/fiori-docs-embeddings package, trying local data...")}let e=vf.default.join(__dirname,"../../data");try{return await U_e.default.access(e),Lt.log("\u2713 Using local data directory"),{dataPath:e,embeddingsPath:vf.default.join(e,"embeddings"),searchPath:vf.default.join(e,"search"),docsPath:vf.default.join(e,"docs"),isExternalPackage:!1,isAvailable:!0}}catch{Lt.warn("Local data directory not available either")}let t=vf.default.join(__dirname,"../../data");return Lt.warn("\u26A0\uFE0F No embeddings data available - running in limited mode"),{dataPath:t,embeddingsPath:vf.default.join(t,"embeddings"),searchPath:vf.default.join(t,"search"),docsPath:vf.default.join(t,"docs"),isExternalPackage:!1,isAvailable:!1}}var bc=lr(yf()),y$=require("node:path");async function fu(e){try{e=(0,y$.join)(e);try{let t=await(0,bc.createApplicationAccess)(e);return{root:t.project.root,appId:t.getAppId(),applicationAccess:t}}catch(t){Lt.warn(`Application was not found by given path. Error: ${t}`);let r=await(0,bc.findProjectRoot)(e),n=await(0,bc.getProject)(r);if(n)return{root:n.root,appId:""}}}catch(t){Lt.warn(`Project was not found by given path. Error: ${t}`);return}}var kY=e=>{let t;switch(e){case bc.DirName.View:{t=(0,y$.join)(bc.DirName.Ext,bc.DirName.View);break}case bc.DirName.Fragment:{t=(0,y$.join)(bc.DirName.Ext,bc.DirName.Fragment);break}case bc.DirName.Controller:{t=(0,y$.join)(bc.DirName.Ext,bc.DirName.Controller);break}default:t=e}return t},cm=(e,t,r=new Set)=>{if(!e||typeof e!="object")return{};if(e.$ref?.startsWith("#/definitions/")){let i=e.$ref,a=i.replace("#/definitions/",""),o=t.definitions?.[a]??null;if(r.has(i))return{...o};if(r.add(i),o){let s={...e};return delete s.$ref,cm({...o,...s},t,r)}}let n={...e};return n.properties&&(n.properties=Object.fromEntries(Object.entries(n.properties).map(([i,a])=>[i,cm(a,t,r)]))),n.items&&(Array.isArray(n.items)?n.items=n.items.map(i=>cm(i,t,r)):n.items=cm(n.items,t,r)),n.allOf&&(n.allOf=n.allOf.map(i=>cm(i,t,r))),n.anyOf&&(n.anyOf=n.anyOf.map(i=>cm(i,t,r))),n.oneOf&&(n.oneOf=n.oneOf.map(i=>cm(i,t,r))),typeof n.additionalProperties=="object"&&(n.additionalProperties=cm(n.additionalProperties,t,r)),n},Mlt=(e,t)=>({type:"object",properties:{[e]:t}}),wa=e=>{let t=S_(e);return delete t.$schema,t},um=(e,t)=>{try{return e.parse(t)}catch(r){throw r instanceof aoe?new Error(`Missing required fields in parameters. ${JSON.stringify(r.issues,null,4)}`):new Error("Unknown error. Recheck input parameters.")}};var Rbt=require("node:util"),Ibt=require("node:child_process"),wbt=lr(mAe());async function ZK(e="1.18.5"){let t="@sap/generator-fiori";if((await(0,wbt.findInstalledPackages)(t,{minVersion:e}))?.length<1)throw new Error(`Fiori generator not found. Please install the Fiori generator >=${e} with 'npm install -g ${t}' and retry this call`)}var QK=(0,Rbt.promisify)(Ibt.exec);var Lbt=require("@lancedb/lancedb");var gAe=lr(require("node:fs/promises")),yAe=lr(require("node:path")),e9=class{connection=null;tables=[];tableIndex=null;metadata=null;dataPath;constructor(t){this.dataPath=t||""}async initialize(){try{Lt.log("Loading vector database from pre-built embeddings...");let t=await Llt();if(!t.isAvailable)throw new Error("No embeddings data available");this.dataPath=t.embeddingsPath,Lt.log(`Using embeddings path: ${this.dataPath} (external: ${t.isExternalPackage})`);let r=yAe.default.join(this.dataPath,"metadata.json"),n=await gAe.default.readFile(r,"utf-8");this.metadata=JSON.parse(n),Lt.log("\u2713 Embedding metadata loaded:"),Lt.log(` Model: ${this?.metadata?.model}`),Lt.log(` Dimensions: ${this?.metadata?.dimensions}`),Lt.log(` Total vectors: ${this?.metadata?.totalVectors}`),Lt.log(` Created: ${this?.metadata?.createdAt}`),this.connection=await(0,Lbt.connect)(this.dataPath);let i=yAe.default.join(this.dataPath,"table_index.json");try{let a=await gAe.default.readFile(i,"utf-8");this.tableIndex=JSON.parse(a),this.tables=[];for(let o of this.tableIndex?.tables||[]){let s=await this.connection.openTable(o);this.tables.push(s)}Lt.log(`\u2713 Loaded ${this.tables.length} split tables`)}catch{Lt.log("No table index found, trying single table...");try{let a=await this.connection.openTable("documents");this.tables=[a],this.tableIndex={tables:["documents"],totalTables:1,maxVectorsPerTable:-1,totalVectors:this.metadata?.totalVectors||0}}catch(a){throw new Error(`No tables found: ${a}`)}}Lt.log("\u2713 Vector database loaded and ready")}catch(t){throw new Error(`Failed to load vector database: ${t}`)}}async semanticSearch(t,r=10,n){if(this.tables.length===0)throw new Error("Vector database not initialized");try{let i=[];for(let o of this.tables){let s=o.vectorSearch(t).limit(r*2);n&&(s=s.where(`category = "${n}"`));let c=await s.toArray();i.push(...c)}return i.sort((o,s)=>(o._distance||0)-(s._distance||0)),i.slice(0,r).map(o=>({document:{id:o.document_id,vector:o.vector,content:o.content,title:o.title,category:o.category,path:o.path,chunk_index:o.chunk_index,metadata:{tags:this.parseJsonField(o.tags_json)||[],headers:this.parseJsonField(o.headers_json)||[],lastModified:new Date(o.lastModified),wordCount:o.wordCount,excerpt:o.excerpt}},score:1-(o._distance||0),distance:o._distance||0}))}catch(i){throw Lt.error(`Semantic search failed: ${i}`),new Error(`Semantic search failed: ${i}`)}}async findSimilarToText(t,r=5){return Lt.warn("findSimilarToText requires embedding generation - not available in simplified mode"),[]}async findSimilarToDocument(t,r=5){if(this.tables.length===0)throw new Error("Vector database not initialized");try{let n=null;for(let s of this.tables){let c=await s.search("").where(`document_id = "${t}" AND chunk_index = 0`).limit(1).toArray();if(c.length>0){n=c[0].vector;break}}if(!n)return[];let i=[];for(let s of this.tables){let c=await s.vectorSearch(n).where(`document_id != "${t}"`).limit(r*2).toArray();i.push(...c)}let a=new Map;for(let s of i){let c=s.document_id,u=1-(s._distance||0);(!a.has(c)||a.get(c).score<u)&&a.set(c,{...s,score:u,distance:s._distance||0})}return Array.from(a.values()).sort((s,c)=>c.score-s.score).slice(0,r).map(s=>({document:{id:s.document_id,vector:s.vector,content:s.content,title:s.title,category:s.category,path:s.path,chunk_index:s.chunk_index,metadata:{tags:this.parseJsonField(s.tags_json)||[],headers:this.parseJsonField(s.headers_json)||[],lastModified:new Date(s.lastModified),wordCount:s.wordCount,excerpt:s.excerpt}},score:s.score,distance:s.distance}))}catch(n){return Lt.error(`Find similar documents failed: ${n}`),[]}}async getDocumentsByCategory(t,r){if(this.tables.length===0)throw new Error("Vector database not initialized");try{let n=[];for(let a of this.tables){let o=a.search("").where(`category = "${t}" AND chunk_index = 0`);r&&(o=o.limit(Math.ceil(r/this.tables.length)+10));let s=await o.toArray();n.push(...s)}return(r?n.slice(0,r):n).map(a=>({document:{id:a.document_id,vector:a.vector,content:a.content,title:a.title,category:a.category,path:a.path,chunk_index:a.chunk_index,metadata:{tags:this.parseJsonField(a.tags_json)||[],headers:this.parseJsonField(a.headers_json)||[],lastModified:new Date(a.lastModified),wordCount:a.wordCount,excerpt:a.excerpt}},score:1,distance:0}))}catch(n){return Lt.error(`Get documents by category failed: ${n}`),[]}}getMetadata(){return this.metadata}parseJsonField(t){try{return t?JSON.parse(t):[]}catch{return[]}}isInitialized(){return this.tables.length>0&&this.metadata!==null}async close(){this.connection&&(this.connection=null,this.tables=[],Lt.log("Vector database connection closed"))}};var t9=class{pipeline=null;initialized=!1;async initialize(){if(!this.initialized)try{let{pipeline:t}=await import("@xenova/transformers");this.pipeline=await t("feature-extraction","Xenova/all-MiniLM-L6-v2",{quantized:!1}),this.initialized=!0}catch(t){throw new Error(`Failed to initialize text embedding service: ${t}. Make sure @xenova/transformers is available.`)}}async generateEmbedding(t){if(!this.initialized||!this.pipeline)throw new Error("Text embedding service not initialized. Call initialize() first.");try{let r=t.replace(/\n+/g," ").replace(/\s+/g," ").trim().substring(0,8192);if(!r)throw new Error("Empty text provided for embedding");let n=await this.pipeline(r,{pooling:"mean",normalize:!0});return Array.from(n.data)}catch(r){throw new Error(`Failed to generate embedding: ${r}`)}}isInitialized(){return this.initialized}};async function vAe(e,t=!1){let{query:r,maxResults:n}=e;try{let i=new e9,a=new t9;await i.initialize(),await a.initialize();let o=await a.generateEmbedding(r),s=await i.semanticSearch(o,n??10);if(t){let c="";for(let[u,l]of s.entries())c+=`Result ${u+1}:
|
|
1503
1503
|
|
|
1504
1504
|
`,c+=`${l.document.content}
|
|
1505
1505
|
`,c+=`---
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/fiori-mcp-server",
|
|
3
3
|
"description": "SAP Fiori - Model Context Protocol (MCP) server",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.49",
|
|
5
|
+
"mcpName": "io.github.SAP/fiori-mcp-server",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"SAP Fiori tools",
|
|
7
8
|
"SAP Fiori elements",
|
|
@@ -52,16 +53,16 @@
|
|
|
52
53
|
"@sap-ux/axios-extension": "1.25.29",
|
|
53
54
|
"@sap-ux/project-access": "1.35.19",
|
|
54
55
|
"@sap-ux/fiori-annotation-api": "0.9.41",
|
|
56
|
+
"@sap-ux/fiori-docs-embeddings": "0.4.16",
|
|
55
57
|
"@sap-ux/i18n": "0.3.10",
|
|
56
58
|
"@sap-ux/logger": "0.8.5",
|
|
57
59
|
"@sap-ux/odata-annotation-core-types": "0.5.7",
|
|
58
60
|
"@sap-ux/odata-entity-model": "0.3.7",
|
|
59
|
-
"@sap-ux/text-document-utils": "0.3.3",
|
|
60
61
|
"@sap-ux/btp-utils": "1.1.12",
|
|
61
|
-
"@sap-ux/feature-toggle": "0.3.8",
|
|
62
62
|
"@sap-ux/nodejs-utils": "0.2.19",
|
|
63
|
+
"@sap-ux/feature-toggle": "0.3.8",
|
|
63
64
|
"@sap-ux/telemetry": "0.6.96",
|
|
64
|
-
"@sap-ux/
|
|
65
|
+
"@sap-ux/text-document-utils": "0.3.3"
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
68
|
"@xenova/transformers": "2.17.2",
|