@sap-ux/fiori-mcp-server 0.6.56 → 0.6.57

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.
Files changed (3) hide show
  1. package/README.md +96 -11
  2. package/dist/index.js +1 -1
  3. package/package.json +7 -7
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Changelog](https://img.shields.io/badge/changelog-8A2BE2)](https://github.com/SAP/open-ux-tools/blob/main/packages/fiori-mcp-server/CHANGELOG.md) [![Github repo](https://img.shields.io/badge/github-repo-blue)](https://github.com/SAP/open-ux-tools/tree/main/packages/fiori-mcp-server)
1
+ [![Changelog](https://img.shields.io/badge/changelog-8A2BE2)](https://github.com/SAP/open-ux-tools/blob/main/packages/fiori-mcp-server/CHANGELOG.md) [![Github repo](https://img.shields.io/badge/github-repo-blue)](https://github.com/SAP/open-ux-tools/tree/main/packages/fiori-mcp-server)
2
2
 
3
3
  # [`@sap-ux/fiori-mcp-server`](https://github.com/SAP/open-ux-tools/tree/main/packages/fiori-mcp-server)
4
4
 
@@ -16,11 +16,35 @@ The server helps AI models create or modify SAP Fiori applications based on prom
16
16
 
17
17
  For the best experience we recommend using this server alongside [@cap-js/mcp-server](https://www.npmjs.com/package/@cap-js/mcp-server) and [@ui5/mcp-server](https://www.npmjs.com/package/@ui5/mcp-server).
18
18
 
19
- ## [Usage](#usage)
19
+ ## [Setup](#setup)
20
20
 
21
- ### Method 1: npx
21
+ The server uses `stdio` transport and is launched via `npx` — no global installation required. Pick the section for your MCP client below.
22
+
23
+ ### Claude Code
24
+
25
+ **Option A — CLI (recommended):**
26
+ ```bash
27
+ claude mcp add fiori-mcp -- npx --yes @sap-ux/fiori-mcp-server@latest fiori-mcp
28
+ ```
29
+
30
+ **Option B — drop a `.mcp.json` file in your project root:**
31
+ ```json
32
+ {
33
+ "mcpServers": {
34
+ "fiori-mcp": {
35
+ "type": "stdio",
36
+ "timeout": 600,
37
+ "command": "npx",
38
+ "args": ["--yes", "@sap-ux/fiori-mcp-server@latest", "fiori-mcp"]
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ ### Cline
45
+
46
+ Open the Cline extension settings and add the server under **MCP Servers**:
22
47
 
23
- Configure your MCP client to start the server with command `fiori-mcp`. Here is a sample configuration for Cline:
24
48
  ```json
25
49
  {
26
50
  "mcpServers": {
@@ -28,18 +52,76 @@ Configure your MCP client to start the server with command `fiori-mcp`. Here is
28
52
  "type": "stdio",
29
53
  "timeout": 600,
30
54
  "command": "npx",
31
- "args": ["--yes","@sap-ux/fiori-mcp-server@latest", "fiori-mcp"]
55
+ "args": ["--yes", "@sap-ux/fiori-mcp-server@latest", "fiori-mcp"]
32
56
  }
33
57
  }
34
58
  }
35
59
  ```
36
- ### Method 2: npm
37
60
 
38
- First, install the required package globally using `npm`:
61
+ ### Cursor
62
+
63
+ Edit (or create) the MCP config file for your scope:
64
+
65
+ - **Global:** `~/.cursor/mcp.json`
66
+ - **Project:** `.cursor/mcp.json` in your project root
67
+
68
+ ```json
69
+ {
70
+ "mcpServers": {
71
+ "fiori-mcp": {
72
+ "type": "stdio",
73
+ "timeout": 600,
74
+ "command": "npx",
75
+ "args": ["--yes", "@sap-ux/fiori-mcp-server@latest", "fiori-mcp"]
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ ### Windsurf
82
+
83
+ Edit `~/.codeium/windsurf/mcp_config.json`:
84
+
85
+ ```json
86
+ {
87
+ "mcpServers": {
88
+ "fiori-mcp": {
89
+ "type": "stdio",
90
+ "timeout": 600,
91
+ "command": "npx",
92
+ "args": ["--yes", "@sap-ux/fiori-mcp-server@latest", "fiori-mcp"]
93
+ }
94
+ }
95
+ }
96
+ ```
97
+
98
+ ### Other clients
99
+
100
+ For any other MCP client, use the following `npx`-based configuration:
101
+
102
+ ```json
103
+ {
104
+ "mcpServers": {
105
+ "fiori-mcp": {
106
+ "type": "stdio",
107
+ "timeout": 600,
108
+ "command": "npx",
109
+ "args": ["--yes", "@sap-ux/fiori-mcp-server@latest", "fiori-mcp"]
110
+ }
111
+ }
112
+ }
113
+ ```
114
+
115
+ ### Global npm install (any client)
116
+
117
+ If you prefer **not** to use `npx`, install the package globally first:
118
+
39
119
  ```bash
40
120
  npm install -g @sap-ux/fiori-mcp-server
41
121
  ```
42
- Then, configure your MCP client to start the server with command `fiori-mcp`. Here is a sample configuration for Cline:
122
+
123
+ Then use `fiori-mcp` as the command (no `args` needed):
124
+
43
125
  ```json
44
126
  {
45
127
  "mcpServers": {
@@ -54,7 +136,12 @@ Then, configure your MCP client to start the server with command `fiori-mcp`. He
54
136
 
55
137
  ## [Rules](#rules)
56
138
 
57
- The following rules help guide the LLM to use the server correctly:
139
+ The following rules help guide the AI model to use the server correctly. Add them to your system prompt or rules file:
140
+
141
+ - **Claude Code:** `AGENTS.md` or `CLAUDE.md` in your project root
142
+ - **Cline:** Custom Instructions in the Cline extension settings
143
+ - **Cursor:** `.cursorrules` in your project root
144
+ - **Windsurf:** Global Rules or project-level `.windsurfrules`
58
145
 
59
146
  ```markdown
60
147
  ## Rules for creation or modification of SAP Fiori elements apps
@@ -71,8 +158,6 @@ The following rules help guide the LLM to use the server correctly:
71
158
  - When previewing the SAP Fiori elements application use the most specific `npm run watch-*` script for the app in the `package.json`.
72
159
  ```
73
160
 
74
- Add these rules to your existing global or project-specific [`AGENTS.md`](https://agents.md/) (specifics may vary based on respective MCP client).
75
-
76
161
  ## [Available Tools](#available-tools)
77
162
 
78
163
  #### `search_docs`
package/dist/index.js CHANGED
@@ -1496,7 +1496,7 @@ ${n.message}`:h,S=[E,t,e].filter(Boolean).join(`
1496
1496
 
1497
1497
  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 x_(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),d=f.schema;if(d.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(d)):Object.assign(c,d),Object.assign(c,u),o._zod.parent===l)for(let g in c)g==="$ref"||g==="allOf"||g in u||delete c[g];if(d.$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 d in c)d==="$ref"||d==="allOf"||d in f.def&&JSON.stringify(c[d])===JSON.stringify(f.def[d])&&delete c[d]}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:LC(t,"input",e.processors),output:LC(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch{throw new Error("Error converting schema to JSON.")}}function hu(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 hu(n.element,r);if(n.type==="set")return hu(n.valueType,r);if(n.type==="lazy")return hu(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 hu(n.innerType,r);if(n.type==="intersection")return hu(n.left,r)||hu(n.right,r);if(n.type==="record"||n.type==="map")return hu(n.keyType,r)||hu(n.valueType,r);if(n.type==="pipe")return hu(n.in,r)||hu(n.out,r);if(n.type==="object"){for(let i in n.shape)if(hu(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(let i of n.options)if(hu(i,r))return!0;return!1}if(n.type==="tuple"){for(let i of n.items)if(hu(i,r))return!0;return!!(n.rest&&hu(n.rest,r))}return!1}var Wie=(e,t={})=>r=>{let n=O_({...r,processors:t});return oi(e,n),C_(n,e),x_(n,e)},LC=(e,t,r={})=>n=>{let{libraryOptions:i,target:a}=n??{},o=O_({...i??{},target:a,io:t,processors:r});return oi(e,o),C_(o,e),x_(o,e)};var Clr={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Xie=(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=Clr[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}))])}},Jie=(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)},Zie=(e,t,r,n)=>{r.type="boolean"},Qie=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},eae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},tae=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},rae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},nae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},iae=(e,t,r,n)=>{r.not={}},aae=(e,t,r,n)=>{},oae=(e,t,r,n)=>{},sae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},cae=(e,t,r,n)=>{let i=e._zod.def,a=BI(i.entries);a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),r.enum=a},uae=(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},lae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},pae=(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},fae=(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)},dae=(e,t,r,n)=>{r.type="boolean"},hae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},mae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},gae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},yae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},vae=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},_ae=(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=oi(a.element,t,{...n,path:[...n.path,"items"]})},Eae=(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]=oi(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=oi(a.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},LG=(e,t,r,n)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((s,c)=>oi(s,t,{...n,path:[...n.path,a?"oneOf":"anyOf",c]}));a?r.oneOf=o:r.anyOf=o},Tae=(e,t,r,n)=>{let i=e._zod.def,a=oi(i.left,t,{...n,path:[...n.path,"allOf",0]}),o=oi(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},Sae=(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,d)=>oi(f,t,{...n,path:[...n.path,o,d]})),u=a.rest?oi(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)},bae=(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=oi(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=oi(a.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=oi(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)}},Aae=(e,t,r,n)=>{let i=e._zod.def,a=oi(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"}]},Oae=(e,t,r,n)=>{let i=e._zod.def;oi(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType},Cae=(e,t,r,n)=>{let i=e._zod.def;oi(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))},xae=(e,t,r,n)=>{let i=e._zod.def;oi(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)))},Pae=(e,t,r,n)=>{let i=e._zod.def;oi(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},Dae=(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;oi(a,t,n);let o=t.seen.get(e);o.ref=a},Nae=(e,t,r,n)=>{let i=e._zod.def;oi(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType,r.readOnly=!0},Rae=(e,t,r,n)=>{let i=e._zod.def;oi(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType},MG=(e,t,r,n)=>{let i=e._zod.def;oi(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType},Iae=(e,t,r,n)=>{let i=e._zod.innerType;oi(i,t,n);let a=t.seen.get(e);a.ref=i},wG={string:Xie,number:Jie,boolean:Zie,bigint:Qie,symbol:eae,null:tae,undefined:rae,void:nae,never:iae,any:aae,unknown:oae,date:sae,enum:cae,literal:uae,nan:lae,template_literal:pae,file:fae,success:dae,custom:hae,function:mae,transform:gae,map:yae,set:vae,array:_ae,object:Eae,union:LG,intersection:Tae,tuple:Sae,record:bae,nullable:Aae,nonoptional:Oae,default:Cae,prefault:xae,catch:Pae,pipe:Dae,readonly:Nae,promise:Rae,optional:MG,lazy:Iae};function P_(e,t){if("_idmap"in e){let n=e,i=O_({...t,processors:wG}),a={};for(let c of n._idmap.entries()){let[u,l]=c;oi(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;C_(i,l),o[u]=x_(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=O_({...t,processors:wG});return oi(e,r),C_(r,e),x_(r,e)}var kG=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=O_({processors:wG,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 oi(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)),C_(this.ctx,t);let n=x_(this.ctx,t),{"~standard":i,...a}=n;return a}};var nFe={};function MC(e){return!!e._zod}function D_(e,t){return MC(e)?FS(e,t):e.safeParse(t)}function $G(e){if(!e)return;let t;if(MC(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function oFe(e){if(MC(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 tb={};oo(tb,{$brand:()=>FI,$input:()=>Kq,$output:()=>Yq,NEVER:()=>dB,TimePrecision:()=>Zq,ZodAny:()=>eoe,ZodArray:()=>ioe,ZodBase64:()=>i3,ZodBase64URL:()=>a3,ZodBigInt:()=>jC,ZodBigIntFormat:()=>c3,ZodBoolean:()=>FC,ZodCIDRv4:()=>r3,ZodCIDRv6:()=>n3,ZodCUID:()=>WG,ZodCUID2:()=>XG,ZodCatch:()=>Aoe,ZodCodec:()=>h3,ZodCustom:()=>Fw,ZodCustomStringFormat:()=>UC,ZodDate:()=>Mw,ZodDefault:()=>voe,ZodDiscriminatedUnion:()=>ooe,ZodE164:()=>o3,ZodEmail:()=>HG,ZodEmoji:()=>YG,ZodEnum:()=>kC,ZodError:()=>$ae,ZodExactOptional:()=>moe,ZodFile:()=>doe,ZodFirstPartyTypeKind:()=>koe,ZodFunction:()=>woe,ZodGUID:()=>Dw,ZodIPv4:()=>e3,ZodIPv6:()=>t3,ZodISODate:()=>FG,ZodISODateTime:()=>VG,ZodISODuration:()=>BG,ZodISOTime:()=>jG,ZodIntersection:()=>soe,ZodIssueCode:()=>wlr,ZodJWT:()=>s3,ZodKSUID:()=>QG,ZodLazy:()=>Noe,ZodLiteral:()=>foe,ZodMAC:()=>Xae,ZodMap:()=>loe,ZodNaN:()=>Coe,ZodNanoID:()=>KG,ZodNever:()=>roe,ZodNonOptional:()=>f3,ZodNull:()=>Qae,ZodNullable:()=>yoe,ZodNumber:()=>VC,ZodNumberFormat:()=>eb,ZodObject:()=>kw,ZodOptional:()=>p3,ZodPipe:()=>d3,ZodPrefault:()=>Eoe,ZodPromise:()=>Ioe,ZodReadonly:()=>xoe,ZodRealError:()=>Qu,ZodRecord:()=>Vw,ZodSet:()=>poe,ZodString:()=>$C,ZodStringFormat:()=>xi,ZodSuccess:()=>boe,ZodSymbol:()=>Jae,ZodTemplateLiteral:()=>Doe,ZodTransform:()=>hoe,ZodTuple:()=>coe,ZodType:()=>Br,ZodULID:()=>JG,ZodURL:()=>Iw,ZodUUID:()=>$h,ZodUndefined:()=>Zae,ZodUnion:()=>$w,ZodUnknown:()=>toe,ZodVoid:()=>noe,ZodXID:()=>ZG,ZodXor:()=>aoe,_ZodString:()=>GG,_default:()=>_oe,_function:()=>s2e,any:()=>Lw,array:()=>pr,base64:()=>xFe,base64url:()=>PFe,bigint:()=>VFe,boolean:()=>ji,catch:()=>Ooe,check:()=>c2e,cidrv4:()=>OFe,cidrv6:()=>CFe,clone:()=>zs,codec:()=>i2e,coerce:()=>$oe,config:()=>Ca,core:()=>lp,cuid:()=>yFe,cuid2:()=>vFe,custom:()=>m3,date:()=>HFe,decode:()=>qae,decodeAsync:()=>Hae,describe:()=>u2e,discriminatedUnion:()=>Uw,e164:()=>DFe,email:()=>cFe,emoji:()=>mFe,encode:()=>Bae,encodeAsync:()=>Gae,endsWith:()=>YS,enum:()=>yi,exactOptional:()=>goe,file:()=>e2e,flattenError:()=>gC,float32:()=>MFe,float64:()=>kFe,formatError:()=>yC,fromJSONSchema:()=>m2e,function:()=>s2e,getErrorMap:()=>Mlr,globalRegistry:()=>_s,gt:()=>Pd,gte:()=>Ys,guid:()=>uFe,hash:()=>LFe,hex:()=>wFe,hostname:()=>IFe,httpUrl:()=>hFe,includes:()=>HS,instanceof:()=>p2e,int:()=>qG,int32:()=>$Fe,int64:()=>FFe,intersection:()=>BC,ipv4:()=>SFe,ipv6:()=>AFe,iso:()=>N_,json:()=>d2e,jwt:()=>NFe,keyof:()=>zFe,ksuid:()=>TFe,lazy:()=>Roe,length:()=>A_,literal:()=>Ct,locales:()=>NC,looseObject:()=>Ks,looseRecord:()=>XFe,lowercase:()=>qS,lt:()=>xd,lte:()=>du,mac:()=>bFe,map:()=>JFe,maxLength:()=>b_,maxSize:()=>Kg,meta:()=>l2e,mime:()=>KS,minLength:()=>kh,minSize:()=>Dd,multipleOf:()=>Yg,nan:()=>n2e,nanoid:()=>gFe,nativeEnum:()=>QFe,negative:()=>Aw,never:()=>u3,nonnegative:()=>Cw,nonoptional:()=>Soe,nonpositive:()=>Ow,normalize:()=>WS,null:()=>ww,nullable:()=>Nw,nullish:()=>t2e,number:()=>In,object:()=>Xe,optional:()=>Wn,overwrite:()=>rf,parse:()=>Uae,parseAsync:()=>Vae,partialRecord:()=>WFe,pipe:()=>Rw,positive:()=>bw,prefault:()=>Toe,preprocess:()=>jw,prettifyError:()=>vB,promise:()=>o2e,property:()=>xw,readonly:()=>Poe,record:()=>qn,refine:()=>Loe,regex:()=>BS,regexes:()=>Zu,registry:()=>rw,safeDecode:()=>Yae,safeDecodeAsync:()=>Wae,safeEncode:()=>zae,safeEncodeAsync:()=>Kae,safeParse:()=>Fae,safeParseAsync:()=>jae,set:()=>ZFe,setErrorMap:()=>Llr,size:()=>S_,slugify:()=>wC,startsWith:()=>zS,strictObject:()=>YFe,string:()=>fe,stringFormat:()=>RFe,stringbool:()=>f2e,success:()=>r2e,superRefine:()=>Moe,symbol:()=>BFe,templateLiteral:()=>a2e,toJSONSchema:()=>P_,toLowerCase:()=>JS,toUpperCase:()=>ZS,transform:()=>l3,treeifyError:()=>yB,trim:()=>XS,tuple:()=>uoe,uint32:()=>UFe,uint64:()=>jFe,ulid:()=>_Fe,undefined:()=>qFe,union:()=>vn,unknown:()=>Kn,uppercase:()=>GS,url:()=>zG,util:()=>et,uuid:()=>lFe,uuidv4:()=>pFe,uuidv6:()=>fFe,uuidv7:()=>dFe,void:()=>GFe,xid:()=>EFe,xor:()=>KFe});var Pw={};oo(Pw,{ZodAny:()=>eoe,ZodArray:()=>ioe,ZodBase64:()=>i3,ZodBase64URL:()=>a3,ZodBigInt:()=>jC,ZodBigIntFormat:()=>c3,ZodBoolean:()=>FC,ZodCIDRv4:()=>r3,ZodCIDRv6:()=>n3,ZodCUID:()=>WG,ZodCUID2:()=>XG,ZodCatch:()=>Aoe,ZodCodec:()=>h3,ZodCustom:()=>Fw,ZodCustomStringFormat:()=>UC,ZodDate:()=>Mw,ZodDefault:()=>voe,ZodDiscriminatedUnion:()=>ooe,ZodE164:()=>o3,ZodEmail:()=>HG,ZodEmoji:()=>YG,ZodEnum:()=>kC,ZodExactOptional:()=>moe,ZodFile:()=>doe,ZodFunction:()=>woe,ZodGUID:()=>Dw,ZodIPv4:()=>e3,ZodIPv6:()=>t3,ZodIntersection:()=>soe,ZodJWT:()=>s3,ZodKSUID:()=>QG,ZodLazy:()=>Noe,ZodLiteral:()=>foe,ZodMAC:()=>Xae,ZodMap:()=>loe,ZodNaN:()=>Coe,ZodNanoID:()=>KG,ZodNever:()=>roe,ZodNonOptional:()=>f3,ZodNull:()=>Qae,ZodNullable:()=>yoe,ZodNumber:()=>VC,ZodNumberFormat:()=>eb,ZodObject:()=>kw,ZodOptional:()=>p3,ZodPipe:()=>d3,ZodPrefault:()=>Eoe,ZodPromise:()=>Ioe,ZodReadonly:()=>xoe,ZodRecord:()=>Vw,ZodSet:()=>poe,ZodString:()=>$C,ZodStringFormat:()=>xi,ZodSuccess:()=>boe,ZodSymbol:()=>Jae,ZodTemplateLiteral:()=>Doe,ZodTransform:()=>hoe,ZodTuple:()=>coe,ZodType:()=>Br,ZodULID:()=>JG,ZodURL:()=>Iw,ZodUUID:()=>$h,ZodUndefined:()=>Zae,ZodUnion:()=>$w,ZodUnknown:()=>toe,ZodVoid:()=>noe,ZodXID:()=>ZG,ZodXor:()=>aoe,_ZodString:()=>GG,_default:()=>_oe,_function:()=>s2e,any:()=>Lw,array:()=>pr,base64:()=>xFe,base64url:()=>PFe,bigint:()=>VFe,boolean:()=>ji,catch:()=>Ooe,check:()=>c2e,cidrv4:()=>OFe,cidrv6:()=>CFe,codec:()=>i2e,cuid:()=>yFe,cuid2:()=>vFe,custom:()=>m3,date:()=>HFe,describe:()=>u2e,discriminatedUnion:()=>Uw,e164:()=>DFe,email:()=>cFe,emoji:()=>mFe,enum:()=>yi,exactOptional:()=>goe,file:()=>e2e,float32:()=>MFe,float64:()=>kFe,function:()=>s2e,guid:()=>uFe,hash:()=>LFe,hex:()=>wFe,hostname:()=>IFe,httpUrl:()=>hFe,instanceof:()=>p2e,int:()=>qG,int32:()=>$Fe,int64:()=>FFe,intersection:()=>BC,ipv4:()=>SFe,ipv6:()=>AFe,json:()=>d2e,jwt:()=>NFe,keyof:()=>zFe,ksuid:()=>TFe,lazy:()=>Roe,literal:()=>Ct,looseObject:()=>Ks,looseRecord:()=>XFe,mac:()=>bFe,map:()=>JFe,meta:()=>l2e,nan:()=>n2e,nanoid:()=>gFe,nativeEnum:()=>QFe,never:()=>u3,nonoptional:()=>Soe,null:()=>ww,nullable:()=>Nw,nullish:()=>t2e,number:()=>In,object:()=>Xe,optional:()=>Wn,partialRecord:()=>WFe,pipe:()=>Rw,prefault:()=>Toe,preprocess:()=>jw,promise:()=>o2e,readonly:()=>Poe,record:()=>qn,refine:()=>Loe,set:()=>ZFe,strictObject:()=>YFe,string:()=>fe,stringFormat:()=>RFe,stringbool:()=>f2e,success:()=>r2e,superRefine:()=>Moe,symbol:()=>BFe,templateLiteral:()=>a2e,transform:()=>l3,tuple:()=>uoe,uint32:()=>UFe,uint64:()=>jFe,ulid:()=>_Fe,undefined:()=>qFe,union:()=>vn,unknown:()=>Kn,url:()=>zG,uuid:()=>lFe,uuidv4:()=>pFe,uuidv6:()=>fFe,uuidv7:()=>dFe,void:()=>GFe,xid:()=>EFe,xor:()=>KFe});var UG={};oo(UG,{endsWith:()=>YS,gt:()=>Pd,gte:()=>Ys,includes:()=>HS,length:()=>A_,lowercase:()=>qS,lt:()=>xd,lte:()=>du,maxLength:()=>b_,maxSize:()=>Kg,mime:()=>KS,minLength:()=>kh,minSize:()=>Dd,multipleOf:()=>Yg,negative:()=>Aw,nonnegative:()=>Cw,nonpositive:()=>Ow,normalize:()=>WS,overwrite:()=>rf,positive:()=>bw,property:()=>xw,regex:()=>BS,size:()=>S_,slugify:()=>wC,startsWith:()=>zS,toLowerCase:()=>JS,toUpperCase:()=>ZS,trim:()=>XS,uppercase:()=>GS});var N_={};oo(N_,{ZodISODate:()=>FG,ZodISODateTime:()=>VG,ZodISODuration:()=>BG,ZodISOTime:()=>jG,date:()=>Lae,datetime:()=>wae,duration:()=>kae,time:()=>Mae});var VG=me("ZodISODateTime",(e,t)=>{YB.init(e,t),xi.init(e,t)});function wae(e){return Qq(VG,e)}var FG=me("ZodISODate",(e,t)=>{KB.init(e,t),xi.init(e,t)});function Lae(e){return eG(FG,e)}var jG=me("ZodISOTime",(e,t)=>{WB.init(e,t),xi.init(e,t)});function Mae(e){return tG(jG,e)}var BG=me("ZodISODuration",(e,t)=>{XB.init(e,t),xi.init(e,t)});function kae(e){return rG(BG,e)}var sFe=(e,t)=>{YI.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>yC(e,r)},flatten:{value:r=>gC(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,dC,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,dC,2)}},isEmpty:{get(){return e.issues.length===0}}})},$ae=me("ZodError",sFe),Qu=me("ZodError",sFe,{Parent:Error});var Uae=vC(Qu),Vae=EC(Qu),Fae=SC(Qu),jae=bC(Qu),Bae=_B(Qu),qae=EB(Qu),Gae=TB(Qu),Hae=SB(Qu),zae=bB(Qu),Yae=AB(Qu),Kae=OB(Qu),Wae=CB(Qu);var Br=me("ZodType",(e,t)=>(Tr.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:LC(e,"input"),output:LC(e,"output")}}),e.toJSONSchema=Wie(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(et.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)=>zs(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>Uae(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Fae(e,r,n),e.parseAsync=async(r,n)=>Vae(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>jae(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Bae(e,r,n),e.decode=(r,n)=>qae(e,r,n),e.encodeAsync=async(r,n)=>Gae(e,r,n),e.decodeAsync=async(r,n)=>Hae(e,r,n),e.safeEncode=(r,n)=>zae(e,r,n),e.safeDecode=(r,n)=>Yae(e,r,n),e.safeEncodeAsync=async(r,n)=>Kae(e,r,n),e.safeDecodeAsync=async(r,n)=>Wae(e,r,n),e.refine=(r,n)=>e.check(Loe(r,n)),e.superRefine=r=>e.check(Moe(r)),e.overwrite=r=>e.check(rf(r)),e.optional=()=>Wn(e),e.exactOptional=()=>goe(e),e.nullable=()=>Nw(e),e.nullish=()=>Wn(Nw(e)),e.nonoptional=r=>Soe(e,r),e.array=()=>pr(e),e.or=r=>vn([e,r]),e.and=r=>BC(e,r),e.transform=r=>Rw(e,l3(r)),e.default=r=>_oe(e,r),e.prefault=r=>Toe(e,r),e.catch=r=>Ooe(e,r),e.pipe=r=>Rw(e,r),e.readonly=()=>Poe(e),e.describe=r=>{let n=e.clone();return _s.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return _s.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return _s.get(e);let n=e.clone();return _s.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),GG=me("_ZodString",(e,t)=>{T_.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(n,i,a)=>Xie(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(BS(...n)),e.includes=(...n)=>e.check(HS(...n)),e.startsWith=(...n)=>e.check(zS(...n)),e.endsWith=(...n)=>e.check(YS(...n)),e.min=(...n)=>e.check(kh(...n)),e.max=(...n)=>e.check(b_(...n)),e.length=(...n)=>e.check(A_(...n)),e.nonempty=(...n)=>e.check(kh(1,...n)),e.lowercase=n=>e.check(qS(n)),e.uppercase=n=>e.check(GS(n)),e.trim=()=>e.check(XS()),e.normalize=(...n)=>e.check(WS(...n)),e.toLowerCase=()=>e.check(JS()),e.toUpperCase=()=>e.check(ZS()),e.slugify=()=>e.check(wC())}),$C=me("ZodString",(e,t)=>{T_.init(e,t),GG.init(e,t),e.email=r=>e.check(nw(HG,r)),e.url=r=>e.check(IC(Iw,r)),e.jwt=r=>e.check(Sw(s3,r)),e.emoji=r=>e.check(cw(YG,r)),e.guid=r=>e.check(RC(Dw,r)),e.uuid=r=>e.check(iw($h,r)),e.uuidv4=r=>e.check(aw($h,r)),e.uuidv6=r=>e.check(ow($h,r)),e.uuidv7=r=>e.check(sw($h,r)),e.nanoid=r=>e.check(uw(KG,r)),e.guid=r=>e.check(RC(Dw,r)),e.cuid=r=>e.check(lw(WG,r)),e.cuid2=r=>e.check(pw(XG,r)),e.ulid=r=>e.check(fw(JG,r)),e.base64=r=>e.check(_w(i3,r)),e.base64url=r=>e.check(Ew(a3,r)),e.xid=r=>e.check(dw(ZG,r)),e.ksuid=r=>e.check(hw(QG,r)),e.ipv4=r=>e.check(mw(e3,r)),e.ipv6=r=>e.check(gw(t3,r)),e.cidrv4=r=>e.check(yw(r3,r)),e.cidrv6=r=>e.check(vw(n3,r)),e.e164=r=>e.check(Tw(o3,r)),e.datetime=r=>e.check(wae(r)),e.date=r=>e.check(Lae(r)),e.time=r=>e.check(Mae(r)),e.duration=r=>e.check(kae(r))});function fe(e){return Wq($C,e)}var xi=me("ZodStringFormat",(e,t)=>{gi.init(e,t),GG.init(e,t)}),HG=me("ZodEmail",(e,t)=>{UB.init(e,t),xi.init(e,t)});function cFe(e){return nw(HG,e)}var Dw=me("ZodGUID",(e,t)=>{kB.init(e,t),xi.init(e,t)});function uFe(e){return RC(Dw,e)}var $h=me("ZodUUID",(e,t)=>{$B.init(e,t),xi.init(e,t)});function lFe(e){return iw($h,e)}function pFe(e){return aw($h,e)}function fFe(e){return ow($h,e)}function dFe(e){return sw($h,e)}var Iw=me("ZodURL",(e,t)=>{VB.init(e,t),xi.init(e,t)});function zG(e){return IC(Iw,e)}function hFe(e){return IC(Iw,{protocol:/^https?$/,hostname:Zu.domain,...et.normalizeParams(e)})}var YG=me("ZodEmoji",(e,t)=>{FB.init(e,t),xi.init(e,t)});function mFe(e){return cw(YG,e)}var KG=me("ZodNanoID",(e,t)=>{jB.init(e,t),xi.init(e,t)});function gFe(e){return uw(KG,e)}var WG=me("ZodCUID",(e,t)=>{BB.init(e,t),xi.init(e,t)});function yFe(e){return lw(WG,e)}var XG=me("ZodCUID2",(e,t)=>{qB.init(e,t),xi.init(e,t)});function vFe(e){return pw(XG,e)}var JG=me("ZodULID",(e,t)=>{GB.init(e,t),xi.init(e,t)});function _Fe(e){return fw(JG,e)}var ZG=me("ZodXID",(e,t)=>{HB.init(e,t),xi.init(e,t)});function EFe(e){return dw(ZG,e)}var QG=me("ZodKSUID",(e,t)=>{zB.init(e,t),xi.init(e,t)});function TFe(e){return hw(QG,e)}var e3=me("ZodIPv4",(e,t)=>{JB.init(e,t),xi.init(e,t)});function SFe(e){return mw(e3,e)}var Xae=me("ZodMAC",(e,t)=>{QB.init(e,t),xi.init(e,t)});function bFe(e){return Jq(Xae,e)}var t3=me("ZodIPv6",(e,t)=>{ZB.init(e,t),xi.init(e,t)});function AFe(e){return gw(t3,e)}var r3=me("ZodCIDRv4",(e,t)=>{eq.init(e,t),xi.init(e,t)});function OFe(e){return yw(r3,e)}var n3=me("ZodCIDRv6",(e,t)=>{tq.init(e,t),xi.init(e,t)});function CFe(e){return vw(n3,e)}var i3=me("ZodBase64",(e,t)=>{rq.init(e,t),xi.init(e,t)});function xFe(e){return _w(i3,e)}var a3=me("ZodBase64URL",(e,t)=>{nq.init(e,t),xi.init(e,t)});function PFe(e){return Ew(a3,e)}var o3=me("ZodE164",(e,t)=>{iq.init(e,t),xi.init(e,t)});function DFe(e){return Tw(o3,e)}var s3=me("ZodJWT",(e,t)=>{aq.init(e,t),xi.init(e,t)});function NFe(e){return Sw(s3,e)}var UC=me("ZodCustomStringFormat",(e,t)=>{oq.init(e,t),xi.init(e,t)});function RFe(e,t,r={}){return QS(UC,e,t,r)}function IFe(e){return QS(UC,"hostname",Zu.hostname,e)}function wFe(e){return QS(UC,"hex",Zu.hex,e)}function LFe(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,i=Zu[n];if(!i)throw new Error(`Unrecognized hash format: ${n}`);return QS(UC,n,i,t)}var VC=me("ZodNumber",(e,t)=>{JI.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(n,i,a)=>Jie(e,n,i,a),e.gt=(n,i)=>e.check(Pd(n,i)),e.gte=(n,i)=>e.check(Ys(n,i)),e.min=(n,i)=>e.check(Ys(n,i)),e.lt=(n,i)=>e.check(xd(n,i)),e.lte=(n,i)=>e.check(du(n,i)),e.max=(n,i)=>e.check(du(n,i)),e.int=n=>e.check(qG(n)),e.safe=n=>e.check(qG(n)),e.positive=n=>e.check(Pd(0,n)),e.nonnegative=n=>e.check(Ys(0,n)),e.negative=n=>e.check(xd(0,n)),e.nonpositive=n=>e.check(du(0,n)),e.multipleOf=(n,i)=>e.check(Yg(n,i)),e.step=(n,i)=>e.check(Yg(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 In(e){return nG(VC,e)}var eb=me("ZodNumberFormat",(e,t)=>{sq.init(e,t),VC.init(e,t)});function qG(e){return aG(eb,e)}function MFe(e){return oG(eb,e)}function kFe(e){return sG(eb,e)}function $Fe(e){return cG(eb,e)}function UFe(e){return uG(eb,e)}var FC=me("ZodBoolean",(e,t)=>{CC.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Zie(e,r,n,i)});function ji(e){return lG(FC,e)}var jC=me("ZodBigInt",(e,t)=>{ZI.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(n,i,a)=>Qie(e,n,i,a),e.gte=(n,i)=>e.check(Ys(n,i)),e.min=(n,i)=>e.check(Ys(n,i)),e.gt=(n,i)=>e.check(Pd(n,i)),e.gte=(n,i)=>e.check(Ys(n,i)),e.min=(n,i)=>e.check(Ys(n,i)),e.lt=(n,i)=>e.check(xd(n,i)),e.lte=(n,i)=>e.check(du(n,i)),e.max=(n,i)=>e.check(du(n,i)),e.positive=n=>e.check(Pd(BigInt(0),n)),e.negative=n=>e.check(xd(BigInt(0),n)),e.nonpositive=n=>e.check(du(BigInt(0),n)),e.nonnegative=n=>e.check(Ys(BigInt(0),n)),e.multipleOf=(n,i)=>e.check(Yg(n,i));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function VFe(e){return fG(jC,e)}var c3=me("ZodBigIntFormat",(e,t)=>{cq.init(e,t),jC.init(e,t)});function FFe(e){return hG(c3,e)}function jFe(e){return mG(c3,e)}var Jae=me("ZodSymbol",(e,t)=>{uq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>eae(e,r,n,i)});function BFe(e){return gG(Jae,e)}var Zae=me("ZodUndefined",(e,t)=>{lq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>rae(e,r,n,i)});function qFe(e){return yG(Zae,e)}var Qae=me("ZodNull",(e,t)=>{pq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>tae(e,r,n,i)});function ww(e){return vG(Qae,e)}var eoe=me("ZodAny",(e,t)=>{fq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>aae(e,r,n,i)});function Lw(){return _G(eoe)}var toe=me("ZodUnknown",(e,t)=>{dq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>oae(e,r,n,i)});function Kn(){return EG(toe)}var roe=me("ZodNever",(e,t)=>{hq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>iae(e,r,n,i)});function u3(e){return TG(roe,e)}var noe=me("ZodVoid",(e,t)=>{mq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>nae(e,r,n,i)});function GFe(e){return SG(noe,e)}var Mw=me("ZodDate",(e,t)=>{gq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(n,i,a)=>sae(e,n,i,a),e.min=(n,i)=>e.check(Ys(n,i)),e.max=(n,i)=>e.check(du(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 HFe(e){return bG(Mw,e)}var ioe=me("ZodArray",(e,t)=>{yq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>_ae(e,r,n,i),e.element=t.element,e.min=(r,n)=>e.check(kh(r,n)),e.nonempty=r=>e.check(kh(1,r)),e.max=(r,n)=>e.check(b_(r,n)),e.length=(r,n)=>e.check(A_(r,n)),e.unwrap=()=>e.element});function pr(e,t){return Kie(ioe,e,t)}function zFe(e){let t=e._zod.def.shape;return yi(Object.keys(t))}var kw=me("ZodObject",(e,t)=>{Yie.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Eae(e,r,n,i),et.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>yi(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Kn()}),e.loose=()=>e.clone({...e._zod.def,catchall:Kn()}),e.strict=()=>e.clone({...e._zod.def,catchall:u3()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>et.extend(e,r),e.safeExtend=r=>et.safeExtend(e,r),e.merge=r=>et.merge(e,r),e.pick=r=>et.pick(e,r),e.omit=r=>et.omit(e,r),e.partial=(...r)=>et.partial(p3,e,r[0]),e.required=(...r)=>et.required(f3,e,r[0])});function Xe(e,t){let r={type:"object",shape:e??{},...et.normalizeParams(t)};return new kw(r)}function YFe(e,t){return new kw({type:"object",shape:e,catchall:u3(),...et.normalizeParams(t)})}function Ks(e,t){return new kw({type:"object",shape:e,catchall:Kn(),...et.normalizeParams(t)})}var $w=me("ZodUnion",(e,t)=>{xC.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>LG(e,r,n,i),e.options=t.options});function vn(e,t){return new $w({type:"union",options:e,...et.normalizeParams(t)})}var aoe=me("ZodXor",(e,t)=>{$w.init(e,t),vq.init(e,t),e._zod.processJSONSchema=(r,n,i)=>LG(e,r,n,i),e.options=t.options});function KFe(e,t){return new aoe({type:"union",options:e,inclusive:!1,...et.normalizeParams(t)})}var ooe=me("ZodDiscriminatedUnion",(e,t)=>{$w.init(e,t),_q.init(e,t)});function Uw(e,t,r){return new ooe({type:"union",options:t,discriminator:e,...et.normalizeParams(r)})}var soe=me("ZodIntersection",(e,t)=>{Eq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Tae(e,r,n,i)});function BC(e,t){return new soe({type:"intersection",left:e,right:t})}var coe=me("ZodTuple",(e,t)=>{QI.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Sae(e,r,n,i),e.rest=r=>e.clone({...e._zod.def,rest:r})});function uoe(e,t,r){let n=t instanceof Tr,i=n?r:t,a=n?t:null;return new coe({type:"tuple",items:e,rest:a,...et.normalizeParams(i)})}var Vw=me("ZodRecord",(e,t)=>{Tq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>bae(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType});function qn(e,t,r){return new Vw({type:"record",keyType:e,valueType:t,...et.normalizeParams(r)})}function WFe(e,t,r){let n=zs(e);return n._zod.values=void 0,new Vw({type:"record",keyType:n,valueType:t,...et.normalizeParams(r)})}function XFe(e,t,r){return new Vw({type:"record",keyType:e,valueType:t,mode:"loose",...et.normalizeParams(r)})}var loe=me("ZodMap",(e,t)=>{Sq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>yae(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Dd(...r)),e.nonempty=r=>e.check(Dd(1,r)),e.max=(...r)=>e.check(Kg(...r)),e.size=(...r)=>e.check(S_(...r))});function JFe(e,t,r){return new loe({type:"map",keyType:e,valueType:t,...et.normalizeParams(r)})}var poe=me("ZodSet",(e,t)=>{bq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>vae(e,r,n,i),e.min=(...r)=>e.check(Dd(...r)),e.nonempty=r=>e.check(Dd(1,r)),e.max=(...r)=>e.check(Kg(...r)),e.size=(...r)=>e.check(S_(...r))});function ZFe(e,t){return new poe({type:"set",valueType:e,...et.normalizeParams(t)})}var kC=me("ZodEnum",(e,t)=>{Aq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(n,i,a)=>cae(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 kC({...t,checks:[],...et.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 kC({...t,checks:[],...et.normalizeParams(i),entries:a})}});function yi(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new kC({type:"enum",entries:r,...et.normalizeParams(t)})}function QFe(e,t){return new kC({type:"enum",entries:e,...et.normalizeParams(t)})}var foe=me("ZodLiteral",(e,t)=>{Oq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>uae(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 Ct(e,t){return new foe({type:"literal",values:Array.isArray(e)?e:[e],...et.normalizeParams(t)})}var doe=me("ZodFile",(e,t)=>{Cq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>fae(e,r,n,i),e.min=(r,n)=>e.check(Dd(r,n)),e.max=(r,n)=>e.check(Kg(r,n)),e.mime=(r,n)=>e.check(KS(Array.isArray(r)?r:[r],n))});function e2e(e){return CG(doe,e)}var hoe=me("ZodTransform",(e,t)=>{xq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>gae(e,r,n,i),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new g_(e.constructor.name);r.addIssue=a=>{if(typeof a=="string")r.issues.push(et.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(et.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 l3(e){return new hoe({type:"transform",transform:e})}var p3=me("ZodOptional",(e,t)=>{ew.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>MG(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Wn(e){return new p3({type:"optional",innerType:e})}var moe=me("ZodExactOptional",(e,t)=>{Pq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>MG(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function goe(e){return new moe({type:"optional",innerType:e})}var yoe=me("ZodNullable",(e,t)=>{Dq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Aae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Nw(e){return new yoe({type:"nullable",innerType:e})}function t2e(e){return Wn(Nw(e))}var voe=me("ZodDefault",(e,t)=>{Nq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Cae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _oe(e,t){return new voe({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():et.shallowClone(t)}})}var Eoe=me("ZodPrefault",(e,t)=>{Rq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>xae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Toe(e,t){return new Eoe({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():et.shallowClone(t)}})}var f3=me("ZodNonOptional",(e,t)=>{Iq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Oae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Soe(e,t){return new f3({type:"nonoptional",innerType:e,...et.normalizeParams(t)})}var boe=me("ZodSuccess",(e,t)=>{wq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>dae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function r2e(e){return new boe({type:"success",innerType:e})}var Aoe=me("ZodCatch",(e,t)=>{Lq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Pae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ooe(e,t){return new Aoe({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Coe=me("ZodNaN",(e,t)=>{Mq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>lae(e,r,n,i)});function n2e(e){return OG(Coe,e)}var d3=me("ZodPipe",(e,t)=>{kq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Dae(e,r,n,i),e.in=t.in,e.out=t.out});function Rw(e,t){return new d3({type:"pipe",in:e,out:t})}var h3=me("ZodCodec",(e,t)=>{d3.init(e,t),PC.init(e,t)});function i2e(e,t,r){return new h3({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}var xoe=me("ZodReadonly",(e,t)=>{$q.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Nae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Poe(e){return new xoe({type:"readonly",innerType:e})}var Doe=me("ZodTemplateLiteral",(e,t)=>{Uq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>pae(e,r,n,i)});function a2e(e,t){return new Doe({type:"template_literal",parts:e,...et.normalizeParams(t)})}var Noe=me("ZodLazy",(e,t)=>{jq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Iae(e,r,n,i),e.unwrap=()=>e._zod.def.getter()});function Roe(e){return new Noe({type:"lazy",getter:e})}var Ioe=me("ZodPromise",(e,t)=>{Fq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Rae(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function o2e(e){return new Ioe({type:"promise",innerType:e})}var woe=me("ZodFunction",(e,t)=>{Vq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>mae(e,r,n,i)});function s2e(e){return new woe({type:"function",input:Array.isArray(e?.input)?uoe(e?.input):e?.input??pr(Kn()),output:e?.output??Kn()})}var Fw=me("ZodCustom",(e,t)=>{Bq.init(e,t),Br.init(e,t),e._zod.processJSONSchema=(r,n,i)=>hae(e,r,n,i)});function c2e(e){let t=new Ci({check:"custom"});return t._zod.check=e,t}function m3(e,t){return xG(Fw,e??(()=>!0),t)}function Loe(e,t={}){return PG(Fw,e,t)}function Moe(e){return DG(e)}var u2e=NG,l2e=RG;function p2e(e,t={}){let r=new Fw({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...et.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 f2e=(...e)=>IG({Codec:h3,Boolean:FC,String:$C},...e);function d2e(e){let t=Roe(()=>vn([fe(e),In(),ji(),ww(),pr(t),qn(fe(),t)]));return t}function jw(e,t){return Rw(l3(e),t)}var wlr={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 Llr(e){Ca({customError:e})}function Mlr(){return Ca().customError}var koe;koe||(koe={});var Tt={...Pw,...UG,iso:N_},klr=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 $lr(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 Ulr(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 h2e(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return Tt.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 Tt.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=Ulr(i,t),o=Tc(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 Tt.null();if(i.length===0)return Tt.never();if(i.length===1)return Tt.literal(i[0]);if(i.every(o=>typeof o=="string"))return Tt.enum(i);let a=i.map(o=>Tt.literal(o));return a.length<2?a[0]:Tt.union([a[0],a[1],...a.slice(2)])}if(e.const!==void 0)return Tt.literal(e.const);let r=e.type;if(Array.isArray(r)){let i=r.map(a=>{let o={...e,type:a};return h2e(o,t)});return i.length===0?Tt.never():i.length===1?i[0]:Tt.union(i)}if(!r)return Tt.any();let n;switch(r){case"string":{let i=Tt.string();if(e.format){let a=e.format;a==="email"?i=i.check(Tt.email()):a==="uri"||a==="uri-reference"?i=i.check(Tt.url()):a==="uuid"||a==="guid"?i=i.check(Tt.uuid()):a==="date-time"?i=i.check(Tt.iso.datetime()):a==="date"?i=i.check(Tt.iso.date()):a==="time"?i=i.check(Tt.iso.time()):a==="duration"?i=i.check(Tt.iso.duration()):a==="ipv4"?i=i.check(Tt.ipv4()):a==="ipv6"?i=i.check(Tt.ipv6()):a==="mac"?i=i.check(Tt.mac()):a==="cidr"?i=i.check(Tt.cidrv4()):a==="cidr-v6"?i=i.check(Tt.cidrv6()):a==="base64"?i=i.check(Tt.base64()):a==="base64url"?i=i.check(Tt.base64url()):a==="e164"?i=i.check(Tt.e164()):a==="jwt"?i=i.check(Tt.jwt()):a==="emoji"?i=i.check(Tt.emoji()):a==="nanoid"?i=i.check(Tt.nanoid()):a==="cuid"?i=i.check(Tt.cuid()):a==="cuid2"?i=i.check(Tt.cuid2()):a==="ulid"?i=i.check(Tt.ulid()):a==="xid"?i=i.check(Tt.xid()):a==="ksuid"&&(i=i.check(Tt.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"?Tt.number().int():Tt.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=Tt.boolean();break}case"null":{n=Tt.null();break}case"object":{let i={},a=e.properties||{},o=new Set(e.required||[]);for(let[c,u]of Object.entries(a)){let l=Tc(u,t);i[c]=o.has(c)?l:l.optional()}if(e.propertyNames){let c=Tc(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?Tc(e.additionalProperties,t):Tt.any();if(Object.keys(i).length===0){n=Tt.record(c,u);break}let l=Tt.object(i).passthrough(),p=Tt.looseRecord(c,u);n=Tt.intersection(l,p);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let f of u){let d=Tc(c[f],t),h=Tt.string().regex(new RegExp(f));l.push(Tt.looseRecord(h,d))}let p=[];if(Object.keys(i).length>0&&p.push(Tt.object(i).passthrough()),p.push(...l),p.length===0)n=Tt.object({}).passthrough();else if(p.length===1)n=p[0];else{let f=Tt.intersection(p[0],p[1]);for(let d=2;d<p.length;d++)f=Tt.intersection(f,p[d]);n=f}break}let s=Tt.object(i);e.additionalProperties===!1?n=s.strict():typeof e.additionalProperties=="object"?n=s.catchall(Tc(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=>Tc(c,t)),s=a&&typeof a=="object"&&!Array.isArray(a)?Tc(a,t):void 0;s?n=Tt.tuple(o).rest(s):n=Tt.tuple(o),typeof e.minItems=="number"&&(n=n.check(Tt.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(Tt.maxLength(e.maxItems)))}else if(Array.isArray(a)){let o=a.map(c=>Tc(c,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?Tc(e.additionalItems,t):void 0;s?n=Tt.tuple(o).rest(s):n=Tt.tuple(o),typeof e.minItems=="number"&&(n=n.check(Tt.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(Tt.maxLength(e.maxItems)))}else if(a!==void 0){let o=Tc(a,t),s=Tt.array(o);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),n=s}else n=Tt.array(Tt.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 Tc(e,t){if(typeof e=="boolean")return e?Tt.any():Tt.never();let r=h2e(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=>Tc(u,t)),c=Tt.union(s);r=n?Tt.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>Tc(u,t)),c=Tt.xor(s);r=n?Tt.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=n?r:Tt.any();else{let s=n?r:Tc(e.allOf[0],t),c=n?0:1;for(let u=c;u<e.allOf.length;u++)s=Tt.intersection(s,Tc(e.allOf[u],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=Tt.nullable(r)),e.readOnly===!0&&(r=Tt.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))klr.has(s)||(i[s]=e[s]);return Object.keys(i).length>0&&t.registry.add(r,i),r}function m2e(e,t){if(typeof e=="boolean")return e?Tt.any():Tt.never();let r=$lr(e,t?.defaultTarget),n=e.$defs||e.definitions||{},i={version:r,defs:n,refs:new Map,processing:new Set,rootSchema:e,registry:t?.registry??_s};return Tc(e,i)}var $oe={};oo($oe,{bigint:()=>Blr,boolean:()=>jlr,date:()=>qlr,number:()=>Flr,string:()=>Vlr});function Vlr(e){return Xq($C,e)}function Flr(e){return iG(VC,e)}function jlr(e){return pG(FC,e)}function Blr(e){return dG(jC,e)}function qlr(e){return AG(Mw,e)}Ca(qq());var Voe="2025-11-25";var g2e=[Voe,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],R_="io.modelcontextprotocol/related-task",y3="2.0",Zo=m3(e=>e!==null&&(typeof e=="object"||typeof e=="function")),y2e=vn([fe(),In().int()]),v2e=fe(),Aci=Ks({ttl:In().optional(),pollInterval:In().optional()}),Hlr=Xe({ttl:In().optional()}),zlr=Xe({taskId:fe()}),Foe=Ks({progressToken:y2e.optional(),[R_]:zlr.optional()}),pp=Xe({_meta:Foe.optional()}),Bw=pp.extend({task:Hlr.optional()}),_2e=e=>Bw.safeParse(e).success,Ws=Xe({method:fe(),params:pp.loose().optional()}),nf=Xe({_meta:Foe.optional()}),af=Xe({method:fe(),params:nf.loose().optional()}),Xs=Ks({_meta:Foe.optional()}),v3=vn([fe(),In().int()]),E2e=Xe({jsonrpc:Ct(y3),id:v3,...Ws.shape}).strict(),joe=e=>E2e.safeParse(e).success,T2e=Xe({jsonrpc:Ct(y3),...af.shape}).strict(),S2e=e=>T2e.safeParse(e).success,Boe=Xe({jsonrpc:Ct(y3),id:v3,result:Xs}).strict(),qw=e=>Boe.safeParse(e).success;var Cn;(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"})(Cn||(Cn={}));var qoe=Xe({jsonrpc:Ct(y3),id:v3.optional(),error:Xe({code:In().int(),message:fe(),data:Kn().optional()})}).strict();var b2e=e=>qoe.safeParse(e).success;var A2e=vn([E2e,T2e,Boe,qoe]),Oci=vn([Boe,qoe]),_3=Xs.strict(),Ylr=nf.extend({requestId:v3.optional(),reason:fe().optional()}),E3=af.extend({method:Ct("notifications/cancelled"),params:Ylr}),Klr=Xe({src:fe(),mimeType:fe().optional(),sizes:pr(fe()).optional(),theme:yi(["light","dark"]).optional()}),Gw=Xe({icons:pr(Klr).optional()}),qC=Xe({name:fe(),title:fe().optional()}),O2e=qC.extend({...qC.shape,...Gw.shape,version:fe(),websiteUrl:fe().optional(),description:fe().optional()}),Wlr=BC(Xe({applyDefaults:ji().optional()}),qn(fe(),Kn())),Xlr=jw(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,BC(Xe({form:Wlr.optional(),url:Zo.optional()}),qn(fe(),Kn()).optional())),Jlr=Ks({list:Zo.optional(),cancel:Zo.optional(),requests:Ks({sampling:Ks({createMessage:Zo.optional()}).optional(),elicitation:Ks({create:Zo.optional()}).optional()}).optional()}),Zlr=Ks({list:Zo.optional(),cancel:Zo.optional(),requests:Ks({tools:Ks({call:Zo.optional()}).optional()}).optional()}),Qlr=Xe({experimental:qn(fe(),Zo).optional(),sampling:Xe({context:Zo.optional(),tools:Zo.optional()}).optional(),elicitation:Xlr.optional(),roots:Xe({listChanged:ji().optional()}).optional(),tasks:Jlr.optional(),extensions:qn(fe(),Zo).optional()}),epr=pp.extend({protocolVersion:fe(),capabilities:Qlr,clientInfo:O2e}),Hw=Ws.extend({method:Ct("initialize"),params:epr});var tpr=Xe({experimental:qn(fe(),Zo).optional(),logging:Zo.optional(),completions:Zo.optional(),prompts:Xe({listChanged:ji().optional()}).optional(),resources:Xe({subscribe:ji().optional(),listChanged:ji().optional()}).optional(),tools:Xe({listChanged:ji().optional()}).optional(),tasks:Zlr.optional(),extensions:qn(fe(),Zo).optional()}),rpr=Xs.extend({protocolVersion:fe(),capabilities:tpr,serverInfo:O2e,instructions:fe().optional()}),Goe=af.extend({method:Ct("notifications/initialized"),params:nf.optional()});var T3=Ws.extend({method:Ct("ping"),params:pp.optional()}),npr=Xe({progress:In(),total:Wn(In()),message:Wn(fe())}),ipr=Xe({...nf.shape,...npr.shape,progressToken:y2e}),S3=af.extend({method:Ct("notifications/progress"),params:ipr}),apr=pp.extend({cursor:v2e.optional()}),zw=Ws.extend({params:apr.optional()}),Yw=Xs.extend({nextCursor:v2e.optional()}),opr=yi(["working","input_required","completed","failed","cancelled"]),Kw=Xe({taskId:fe(),status:opr,ttl:vn([In(),ww()]),createdAt:fe(),lastUpdatedAt:fe(),pollInterval:Wn(In()),statusMessage:Wn(fe())}),GC=Xs.extend({task:Kw}),spr=nf.merge(Kw),Ww=af.extend({method:Ct("notifications/tasks/status"),params:spr}),b3=Ws.extend({method:Ct("tasks/get"),params:pp.extend({taskId:fe()})}),A3=Xs.merge(Kw),O3=Ws.extend({method:Ct("tasks/result"),params:pp.extend({taskId:fe()})}),Cci=Xs.loose(),C3=zw.extend({method:Ct("tasks/list")}),x3=Yw.extend({tasks:pr(Kw)}),P3=Ws.extend({method:Ct("tasks/cancel"),params:pp.extend({taskId:fe()})}),C2e=Xs.merge(Kw),x2e=Xe({uri:fe(),mimeType:Wn(fe()),_meta:qn(fe(),Kn()).optional()}),P2e=x2e.extend({text:fe()}),Hoe=fe().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),D2e=x2e.extend({blob:Hoe}),Xw=yi(["user","assistant"]),HC=Xe({audience:pr(Xw).optional(),priority:In().min(0).max(1).optional(),lastModified:N_.datetime({offset:!0}).optional()}),N2e=Xe({...qC.shape,...Gw.shape,uri:fe(),description:Wn(fe()),mimeType:Wn(fe()),size:Wn(In()),annotations:HC.optional(),_meta:Wn(Ks({}))}),cpr=Xe({...qC.shape,...Gw.shape,uriTemplate:fe(),description:Wn(fe()),mimeType:Wn(fe()),annotations:HC.optional(),_meta:Wn(Ks({}))}),upr=zw.extend({method:Ct("resources/list")}),lpr=Yw.extend({resources:pr(N2e)}),ppr=zw.extend({method:Ct("resources/templates/list")}),fpr=Yw.extend({resourceTemplates:pr(cpr)}),zoe=pp.extend({uri:fe()}),dpr=zoe,hpr=Ws.extend({method:Ct("resources/read"),params:dpr}),mpr=Xs.extend({contents:pr(vn([P2e,D2e]))}),gpr=af.extend({method:Ct("notifications/resources/list_changed"),params:nf.optional()}),ypr=zoe,vpr=Ws.extend({method:Ct("resources/subscribe"),params:ypr}),_pr=zoe,Epr=Ws.extend({method:Ct("resources/unsubscribe"),params:_pr}),Tpr=nf.extend({uri:fe()}),Spr=af.extend({method:Ct("notifications/resources/updated"),params:Tpr}),bpr=Xe({name:fe(),description:Wn(fe()),required:Wn(ji())}),Apr=Xe({...qC.shape,...Gw.shape,description:Wn(fe()),arguments:Wn(pr(bpr)),_meta:Wn(Ks({}))}),Opr=zw.extend({method:Ct("prompts/list")}),Cpr=Yw.extend({prompts:pr(Apr)}),xpr=pp.extend({name:fe(),arguments:qn(fe(),fe()).optional()}),Ppr=Ws.extend({method:Ct("prompts/get"),params:xpr}),Yoe=Xe({type:Ct("text"),text:fe(),annotations:HC.optional(),_meta:qn(fe(),Kn()).optional()}),Koe=Xe({type:Ct("image"),data:Hoe,mimeType:fe(),annotations:HC.optional(),_meta:qn(fe(),Kn()).optional()}),Woe=Xe({type:Ct("audio"),data:Hoe,mimeType:fe(),annotations:HC.optional(),_meta:qn(fe(),Kn()).optional()}),Dpr=Xe({type:Ct("tool_use"),name:fe(),id:fe(),input:qn(fe(),Kn()),_meta:qn(fe(),Kn()).optional()}),Npr=Xe({type:Ct("resource"),resource:vn([P2e,D2e]),annotations:HC.optional(),_meta:qn(fe(),Kn()).optional()}),Rpr=N2e.extend({type:Ct("resource_link")}),Xoe=vn([Yoe,Koe,Woe,Rpr,Npr]),Ipr=Xe({role:Xw,content:Xoe}),wpr=Xs.extend({description:fe().optional(),messages:pr(Ipr)}),Lpr=af.extend({method:Ct("notifications/prompts/list_changed"),params:nf.optional()}),Mpr=Xe({title:fe().optional(),readOnlyHint:ji().optional(),destructiveHint:ji().optional(),idempotentHint:ji().optional(),openWorldHint:ji().optional()}),kpr=Xe({taskSupport:yi(["required","optional","forbidden"]).optional()}),R2e=Xe({...qC.shape,...Gw.shape,description:fe().optional(),inputSchema:Xe({type:Ct("object"),properties:qn(fe(),Zo).optional(),required:pr(fe()).optional()}).catchall(Kn()),outputSchema:Xe({type:Ct("object"),properties:qn(fe(),Zo).optional(),required:pr(fe()).optional()}).catchall(Kn()).optional(),annotations:Mpr.optional(),execution:kpr.optional(),_meta:qn(fe(),Kn()).optional()}),Joe=zw.extend({method:Ct("tools/list")}),$pr=Yw.extend({tools:pr(R2e)}),D3=Xs.extend({content:pr(Xoe).default([]),structuredContent:qn(fe(),Kn()).optional(),isError:ji().optional()}),xci=D3.or(Xs.extend({toolResult:Kn()})),Upr=Bw.extend({name:fe(),arguments:qn(fe(),Kn()).optional()}),Jw=Ws.extend({method:Ct("tools/call"),params:Upr}),Vpr=af.extend({method:Ct("notifications/tools/list_changed"),params:nf.optional()}),Pci=Xe({autoRefresh:ji().default(!0),debounceMs:In().int().nonnegative().default(300)}),Zw=yi(["debug","info","notice","warning","error","critical","alert","emergency"]),Fpr=pp.extend({level:Zw}),Zoe=Ws.extend({method:Ct("logging/setLevel"),params:Fpr}),jpr=nf.extend({level:Zw,logger:fe().optional(),data:Kn()}),Bpr=af.extend({method:Ct("notifications/message"),params:jpr}),qpr=Xe({name:fe().optional()}),Gpr=Xe({hints:pr(qpr).optional(),costPriority:In().min(0).max(1).optional(),speedPriority:In().min(0).max(1).optional(),intelligencePriority:In().min(0).max(1).optional()}),Hpr=Xe({mode:yi(["auto","required","none"]).optional()}),zpr=Xe({type:Ct("tool_result"),toolUseId:fe().describe("The unique identifier for the corresponding tool call."),content:pr(Xoe).default([]),structuredContent:Xe({}).loose().optional(),isError:ji().optional(),_meta:qn(fe(),Kn()).optional()}),Ypr=Uw("type",[Yoe,Koe,Woe]),g3=Uw("type",[Yoe,Koe,Woe,Dpr,zpr]),Kpr=Xe({role:Xw,content:vn([g3,pr(g3)]),_meta:qn(fe(),Kn()).optional()}),Wpr=Bw.extend({messages:pr(Kpr),modelPreferences:Gpr.optional(),systemPrompt:fe().optional(),includeContext:yi(["none","thisServer","allServers"]).optional(),temperature:In().optional(),maxTokens:In().int(),stopSequences:pr(fe()).optional(),metadata:Zo.optional(),tools:pr(R2e).optional(),toolChoice:Hpr.optional()}),Xpr=Ws.extend({method:Ct("sampling/createMessage"),params:Wpr}),Qw=Xs.extend({model:fe(),stopReason:Wn(yi(["endTurn","stopSequence","maxTokens"]).or(fe())),role:Xw,content:Ypr}),Qoe=Xs.extend({model:fe(),stopReason:Wn(yi(["endTurn","stopSequence","maxTokens","toolUse"]).or(fe())),role:Xw,content:vn([g3,pr(g3)])}),Jpr=Xe({type:Ct("boolean"),title:fe().optional(),description:fe().optional(),default:ji().optional()}),Zpr=Xe({type:Ct("string"),title:fe().optional(),description:fe().optional(),minLength:In().optional(),maxLength:In().optional(),format:yi(["email","uri","date","date-time"]).optional(),default:fe().optional()}),Qpr=Xe({type:yi(["number","integer"]),title:fe().optional(),description:fe().optional(),minimum:In().optional(),maximum:In().optional(),default:In().optional()}),efr=Xe({type:Ct("string"),title:fe().optional(),description:fe().optional(),enum:pr(fe()),default:fe().optional()}),tfr=Xe({type:Ct("string"),title:fe().optional(),description:fe().optional(),oneOf:pr(Xe({const:fe(),title:fe()})),default:fe().optional()}),rfr=Xe({type:Ct("string"),title:fe().optional(),description:fe().optional(),enum:pr(fe()),enumNames:pr(fe()).optional(),default:fe().optional()}),nfr=vn([efr,tfr]),ifr=Xe({type:Ct("array"),title:fe().optional(),description:fe().optional(),minItems:In().optional(),maxItems:In().optional(),items:Xe({type:Ct("string"),enum:pr(fe())}),default:pr(fe()).optional()}),afr=Xe({type:Ct("array"),title:fe().optional(),description:fe().optional(),minItems:In().optional(),maxItems:In().optional(),items:Xe({anyOf:pr(Xe({const:fe(),title:fe()}))}),default:pr(fe()).optional()}),ofr=vn([ifr,afr]),sfr=vn([rfr,nfr,ofr]),cfr=vn([sfr,Jpr,Zpr,Qpr]),ufr=Bw.extend({mode:Ct("form").optional(),message:fe(),requestedSchema:Xe({type:Ct("object"),properties:qn(fe(),cfr),required:pr(fe()).optional()})}),lfr=Bw.extend({mode:Ct("url"),message:fe(),elicitationId:fe(),url:fe().url()}),pfr=vn([ufr,lfr]),ffr=Ws.extend({method:Ct("elicitation/create"),params:pfr}),dfr=nf.extend({elicitationId:fe()}),hfr=af.extend({method:Ct("notifications/elicitation/complete"),params:dfr}),zC=Xs.extend({action:yi(["accept","decline","cancel"]),content:jw(e=>e===null?void 0:e,qn(fe(),vn([fe(),In(),ji(),pr(fe())])).optional())}),mfr=Xe({type:Ct("ref/resource"),uri:fe()});var gfr=Xe({type:Ct("ref/prompt"),name:fe()}),yfr=pp.extend({ref:vn([gfr,mfr]),argument:Xe({name:fe(),value:fe()}),context:Xe({arguments:qn(fe(),fe()).optional()}).optional()}),vfr=Ws.extend({method:Ct("completion/complete"),params:yfr});var _fr=Xs.extend({completion:Ks({values:pr(fe()).max(100),total:Wn(In().int()),hasMore:Wn(ji())})}),Efr=Xe({uri:fe().startsWith("file://"),name:fe().optional(),_meta:qn(fe(),Kn()).optional()}),Tfr=Ws.extend({method:Ct("roots/list"),params:pp.optional()}),ese=Xs.extend({roots:pr(Efr)}),Sfr=af.extend({method:Ct("notifications/roots/list_changed"),params:nf.optional()}),Dci=vn([T3,Hw,vfr,Zoe,Ppr,Opr,upr,ppr,hpr,vpr,Epr,Jw,Joe,b3,O3,C3,P3]),Nci=vn([E3,S3,Goe,Sfr,Ww]),Rci=vn([_3,Qw,Qoe,zC,ese,A3,x3,GC]),Ici=vn([T3,Xpr,ffr,Tfr,b3,O3,C3,P3]),wci=vn([E3,S3,Bpr,Spr,gpr,Vpr,Lpr,Ww,hfr]),Lci=vn([_3,rpr,_fr,wpr,Cpr,lpr,fpr,mpr,D3,$pr,A3,x3,GC]),zr=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===Cn.UrlElicitationRequired&&n){let i=n;if(i.elicitations)return new Uoe(i.elicitations,r)}return new e(t,r,n)}},Uoe=class extends zr{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(Cn.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function I_(e){return e==="completed"||e==="failed"||e==="cancelled"}var hui=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function tse(e){let r=$G(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=oFe(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function rse(e,t){let r=D_(e,t);if(!r.success)throw r.error;return r.data}var Pfr=6e4,N3=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(E3,r=>{this._oncancel(r)}),this.setNotificationHandler(S3,r=>{this._onprogress(r)}),this.setRequestHandler(T3,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(b3,async(r,n)=>{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new zr(Cn.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(O3,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 zr(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 zr(Cn.InvalidParams,`Task not found: ${a}`);if(!I_(o.status))return await this._waitForTaskUpdate(a,n.signal),await i();if(I_(o.status)){let s=await this._taskStore.getTaskResult(a,n.sessionId);return this._clearTaskQueue(a),{...s,_meta:{...s._meta,[R_]:{taskId:a}}}}return await i()};return await i()}),this.setRequestHandler(C3,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 zr(Cn.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(P3,async(r,n)=>{try{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new zr(Cn.InvalidParams,`Task not found: ${r.params.taskId}`);if(I_(i.status))throw new zr(Cn.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 zr(Cn.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...a}}catch(i){throw i instanceof zr?i:new zr(Cn.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),zr.fromError(Cn.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),qw(a)||b2e(a)?this._onresponse(a):joe(a)?this._onrequest(a,o):S2e(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=zr.fromError(Cn.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?.[R_]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:Cn.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=_2e(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 zr(Cn.ConnectionClosed,"Request was cancelled");let d={...f,relatedRequestId:t.id};a&&!d.relatedTask&&(d.relatedTask={taskId:a});let h=d.relatedTask?.taskId??a;return h&&c&&await c.updateTaskStatus(h,"input_required"),await this.request(l,p,d)},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:Cn.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),qw(t))n(t);else{let o=new zr(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(qw(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),qw(t))i(t);else{let o=zr.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 zr?o:new zr(Cn.InternalError,String(o))}}return}let a;try{let o=await this.request(t,GC,n);if(o.task)a=o.task.taskId,yield{type:"taskCreated",task:o.task};else throw new zr(Cn.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:a},n);if(yield{type:"taskStatus",task:s},I_(s.status)){s.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)}:s.status==="failed"?yield{type:"error",error:new zr(Cn.InternalError,`Task ${a} failed`)}:s.status==="cancelled"&&(yield{type:"error",error:new zr(Cn.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 zr?o:new zr(Cn.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=b=>{l(b)};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(b){p(b);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,d={...t,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),d.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),s&&(d.params={...d.params,task:s}),c&&(d.params={...d.params,_meta:{...d.params?._meta||{},[R_]:c}});let h=b=>{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(b)}},{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(x=>this._onerror(new Error(`Failed to send cancellation: ${x}`)));let A=b instanceof zr?b:new zr(Cn.RequestTimeout,String(b));l(A)};this._responseHandlers.set(f,b=>{if(!n?.signal?.aborted){if(b instanceof Error)return l(b);try{let A=D_(r,b.result);A.success?u(A.data):l(A.error)}catch(A){l(A)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let g=n?.timeout??Pfr,E=()=>h(zr.fromError(Cn.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(f,g,n?.maxTotalTimeout,E,n?.resetTimeoutOnProgress??!1);let S=c?.taskId;if(S){let b=A=>{let x=this._responseHandlers.get(f);x?x(A):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,b),this._enqueueTaskMessage(S,{type:"request",message:d,timestamp:Date.now()}).catch(A=>{this._cleanupTimeout(f),l(A)})}else this._transport.send(d,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(b=>{this._cleanupTimeout(f),l(b)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},A3,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},x3,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},C2e,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||{},[R_]: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||{},[R_]: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||{},[R_]:r.relatedTask}}}),await this._transport.send(o,r)}setRequestHandler(t,r){let n=tse(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(i,a)=>{let o=rse(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=tse(t);this._notificationHandlers.set(n,i=>{let a=rse(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"&&joe(i.message)){let a=i.message.id,o=this._requestResolvers.get(a);o?(o(new zr(Cn.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 zr(Cn.InvalidRequest,"Request cancelled"));return}let o=setTimeout(i,n);r.addEventListener("abort",()=>{clearTimeout(o),a(new zr(Cn.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 zr(Cn.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=Ww.parse({method:"notifications/tasks/status",params:s});await this.notification(c),I_(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 zr(Cn.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(I_(s.status))throw new zr(Cn.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=Ww.parse({method:"notifications/tasks/status",params:c});await this.notification(u),I_(c.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>n.listTasks(i,r)}}};function I2e(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function w2e(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];I2e(o)&&I2e(a)?r[i]={...o,...a}:r[i]=a}return r}var _qe=mr(pH(),1),Eqe=mr(vqe(),1);function _vr(){let e=new _qe.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Eqe.default)(e),e}var dH=class{constructor(t){this._ajv=t??_vr()}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 hH=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},Qw,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},zC,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 Tqe(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 Sqe(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 mH=class extends N3{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Zw.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 dH,this.setRequestHandler(Hw,n=>this._oninitialize(n)),this.setNotificationHandler(Goe,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Zoe,async(n,i)=>{let a=i.sessionId||i.requestInfo?.headers["mcp-session-id"]||void 0,{level:o}=n.params,s=Zw.safeParse(o);return s.success&&this._loggingLevels.set(a,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new hH(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=w2e(this._capabilities,t)}setRequestHandler(t,r){let i=$G(t)?.method;if(!i)throw new Error("Schema is missing a method literal");let a;if(MC(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=D_(Jw,c);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new zr(Cn.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:p}=l.data,f=await Promise.resolve(r(c,u));if(p.task){let h=D_(GC,f);if(!h.success){let g=h.error instanceof Error?h.error.message:String(h.error);throw new zr(Cn.InvalidParams,`Invalid task creation result: ${g}`)}return h.data}let d=D_(D3,f);if(!d.success){let h=d.error instanceof Error?d.error.message:String(d.error);throw new zr(Cn.InvalidParams,`Invalid tools/call result: ${h}`)}return d.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){Sqe(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Tqe(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:g2e.includes(r)?r:Voe,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"},_3)}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},Qoe,r):this.request({method:"sampling/createMessage",params:t},Qw,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},zC,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},zC,r);if(a.action==="accept"&&a.content&&i.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(i.requestedSchema)(a.content);if(!s.valid)throw new zr(Cn.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(o){throw o instanceof zr?o:new zr(Cn.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},ese,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 Kce=mr(require("node:process"),1);var gH=class{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
1498
1498
  `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),Evr(r)}clear(){this._buffer=void 0}};function Evr(e){return A2e.parse(JSON.parse(e))}function bqe(e){return JSON.stringify(e)+`
1499
- `}var yH=class{constructor(t=Kce.default.stdin,r=Kce.default.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new gH,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=bqe(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var Oqe="0.6.56";var fb={name:"@sap-ux/fiori-mcp-server",description:"SAP Fiori - Model Context Protocol (MCP) server",version:Oqe,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.40"},dependencies:{"@sap-ux/fiori-docs-embeddings":"workspace:*","@sap-ux/store":"workspace:*","@xenova/transformers":"2.17.2","@lancedb/lancedb":"0.22.0","apache-arrow":"18.1.0","mem-fs":"2.1.0","mem-fs-editor":"9.4.0"},engines:{node:">=20.x"}};var Pqe=Xe({name:fe().describe("Name of the Fiori application. Usually derived from the `sap.app/id` field in the application's manifest.json."),appPath:fe().describe("Absolute path to the Fiori application's root directory."),projectPath:fe().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:yi(["EDMXBackend","CAPJava","CAPNodejs"]).describe("Type of project the application belongs to."),odataVersion:fe().describe("OData protocol version used by the application's main service.")}),hb=vn([fe(),pr(vn([fe(),In()]))]),Dqe=Xe({functionalityId:hb.describe("Identifier to pass as the `functionalityId` parameter when calling `get_functionality_details` or `execute_functionality`"),description:fe()}),Cqe=yi(["object","array","string","number","boolean","null","integer","any"]),xqe=Xe({type:vn([Cqe,pr(Cqe)]).optional(),description:fe().optional(),properties:Lw().optional()}).catchall(Lw()),Nqe=xqe.extend({properties:qn(fe(),vn([xqe,ji()])).optional()});var Rqe=Xe({searchPath:pr(fe()).describe("Path to search for Fiori applications (defaults to current directory). If VSCode - list of VS Code workspace folder paths(`workspace.workspaceFolders`)")}),Iqe=Xe({appPath:fe().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.")}),wqe=Xe({appPath:fe().describe("Path to the Fiori application if one exists or to the current directory. Path should be an absolute path."),functionalityId:hb.describe("The ID of the functionality to get details for")}),Lqe=Xe({functionalityId:hb.describe("The ID of the functionality to execute"),parameters:qn(fe(),Kn()).describe("Parameters for the functionality execution"),appPath:fe().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.'),Wdi=Xe({query:fe().min(2).describe("The search query for fiori elements, annotations, sapui5, fiori tools documentation")});var Jdi=fe().describe("Search results as formatted text"),Mqe=Xe({applications:pr(Pqe)}),kqe=Xe({applicationPath:fe(),functionalities:pr(Dqe)}),$qe=Xe({functionalityId:hb.describe("Identifier to pass as the `functionalityId` parameter when calling `get_functionality_details` or `execute_functionality`"),name:fe(),description:fe(),technicalDescription:fe().optional(),parameters:Nqe,prerequisites:pr(fe()).optional(),impact:fe().optional(),examples:pr(fe()).optional(),pageName:fe().optional()}),Uqe=Xe({functionalityId:hb,status:fe(),message:fe(),parameters:Kn(),appPath:fe(),changes:pr(fe()),timestamp:fe()});var v_e=mr(require("node:fs/promises")),Cf=mr(require("node:path"));var Au=mr(nE()),kut=mr(vp()),$ut=require("node:path");function $7r(){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 Au.LogLevel.Error;case"WARN":return Au.LogLevel.Warn;case"INFO":return Au.LogLevel.Info;case"DEBUG":return Au.LogLevel.Debug;case"VERBOSE":return Au.LogLevel.Verbose;case"SILLY":return Au.LogLevel.Silly;default:break}return Au.LogLevel.Error}var Mut=$7r(),Vt=new Au.ToolsLogger({logLevel:Mut??Au.LogLevel.Error,transports:Mut===void 0?[new Au.NullTransport]:[new Au.FileTransport({filename:(0,$ut.join)(kut.fioriToolsDirectory,"fiori-mcp-server.log"),maxsize:10*1024*1024,maxFiles:5})],logPrefix:"fiori-mcp"}),l$={info:(e,...t)=>{Vt.info(`@sap/ux-specification: ${e}`);for(let r of t)Vt.info(typeof r=="number"?r.toString():r)},warning:(e,...t)=>{Vt.warn(`@sap/ux-specification: ${e}`);for(let r of t)Vt.warn(typeof r=="number"?r.toString():r)},error:(e,...t)=>{Vt.error(`@sap/ux-specification: ${e}`);for(let r of t)Vt.error(typeof r=="number"?r.toString():r)},reset:()=>{}};async function Uut(){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 v_e.default.access(n),Vt.log("\u2713 Using @sap-ux/fiori-docs-embeddings package"),{dataPath:n,embeddingsPath:Cf.default.join(n,"embeddings"),searchPath:Cf.default.join(n,"search"),docsPath:Cf.default.join(n,"docs"),isExternalPackage:!0,isAvailable:!0}}catch{Vt.warn("Could not load @sap-ux/fiori-docs-embeddings package, trying local data...")}let e=Cf.default.join(__dirname,"../../data");try{return await v_e.default.access(e),Vt.log("\u2713 Using local data directory"),{dataPath:e,embeddingsPath:Cf.default.join(e,"embeddings"),searchPath:Cf.default.join(e,"search"),docsPath:Cf.default.join(e,"docs"),isExternalPackage:!1,isAvailable:!0}}catch{Vt.warn("Local data directory not available either")}let t=Cf.default.join(__dirname,"../../data");return Vt.warn("\u26A0\uFE0F No embeddings data available - running in limited mode"),{dataPath:t,embeddingsPath:Cf.default.join(t,"embeddings"),searchPath:Cf.default.join(t,"search"),docsPath:Cf.default.join(t,"docs"),isExternalPackage:!1,isAvailable:!1}}var kc=mr(vp()),p$=require("node:path");async function Ou(e){try{e=(0,p$.join)(e);try{let t=await(0,kc.createApplicationAccess)(e);return{root:t.project.root,appId:t.getAppId(),applicationAccess:t}}catch(t){Vt.warn(`Application was not found by given path. Error: ${t}`);let r=await(0,kc.findProjectRoot)(e),n=await(0,kc.getProject)(r);if(n)return{root:n.root,appId:""}}}catch(t){Vt.warn(`Project was not found by given path. Error: ${t}`);return}}var bY=e=>{let t;switch(e){case kc.DirName.View:{t=(0,p$.join)(kc.DirName.Ext,kc.DirName.View);break}case kc.DirName.Fragment:{t=(0,p$.join)(kc.DirName.Ext,kc.DirName.Fragment);break}case kc.DirName.Controller:{t=(0,p$.join)(kc.DirName.Ext,kc.DirName.Controller);break}default:t=e}return t},dm=(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,dm({...o,...s},t,r)}}let n={...e};return n.properties&&(n.properties=Object.fromEntries(Object.entries(n.properties).map(([i,a])=>[i,dm(a,t,r)]))),n.items&&(Array.isArray(n.items)?n.items=n.items.map(i=>dm(i,t,r)):n.items=dm(n.items,t,r)),n.allOf&&(n.allOf=n.allOf.map(i=>dm(i,t,r))),n.anyOf&&(n.anyOf=n.anyOf.map(i=>dm(i,t,r))),n.oneOf&&(n.oneOf=n.oneOf.map(i=>dm(i,t,r))),typeof n.additionalProperties=="object"&&(n.additionalProperties=dm(n.additionalProperties,t,r)),n},Vut=(e,t)=>({type:"object",properties:{[e]:t}}),Ba=e=>{let t=P_(e);return delete t.$schema,t},hm=(e,t)=>{try{return e.parse(t)}catch(r){throw r instanceof $ae?new Error(`Missing required fields in parameters. ${JSON.stringify(r.issues,null,4)}`):new Error("Unknown error. Recheck input parameters.")}};var GTt=require("node:util"),HTt=require("node:child_process"),zTt=mr(_be());async function CK(e="1.18.5"){let t="@sap/generator-fiori";if((await(0,zTt.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 xK=(0,GTt.promisify)(HTt.exec);var YTt=require("@lancedb/lancedb");var Ebe=mr(require("node:fs/promises")),Tbe=mr(require("node:path")),PK=class{connection=null;tables=[];tableIndex=null;metadata=null;dataPath;constructor(t){this.dataPath=t||""}async initialize(){try{Vt.log("Loading vector database from pre-built embeddings...");let t=await Uut();if(!t.isAvailable)throw new Error("No embeddings data available");this.dataPath=t.embeddingsPath,Vt.log(`Using embeddings path: ${this.dataPath} (external: ${t.isExternalPackage})`);let r=Tbe.default.join(this.dataPath,"metadata.json"),n=await Ebe.default.readFile(r,"utf-8");this.metadata=JSON.parse(n),Vt.log("\u2713 Embedding metadata loaded:"),Vt.log(` Model: ${this?.metadata?.model}`),Vt.log(` Dimensions: ${this?.metadata?.dimensions}`),Vt.log(` Total vectors: ${this?.metadata?.totalVectors}`),Vt.log(` Created: ${this?.metadata?.createdAt}`),this.connection=await(0,YTt.connect)(this.dataPath);let i=Tbe.default.join(this.dataPath,"table_index.json");try{let a=await Ebe.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)}Vt.log(`\u2713 Loaded ${this.tables.length} split tables`)}catch{Vt.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}`)}}Vt.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 Vt.error(`Semantic search failed: ${i}`),new Error(`Semantic search failed: ${i}`)}}async findSimilarToText(t,r=5){return Vt.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 Vt.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 Vt.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=[],Vt.log("Vector database connection closed"))}};var DK=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 Sbe(e,t=!1){let{query:r,maxResults:n}=e;try{let i=new PK,a=new DK;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}:
1499
+ `}var yH=class{constructor(t=Kce.default.stdin,r=Kce.default.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new gH,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=bqe(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var Oqe="0.6.57";var fb={name:"@sap-ux/fiori-mcp-server",description:"SAP Fiori - Model Context Protocol (MCP) server",version:Oqe,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.40"},dependencies:{"@sap-ux/fiori-docs-embeddings":"workspace:*","@sap-ux/store":"workspace:*","@xenova/transformers":"2.17.2","@lancedb/lancedb":"0.22.0","apache-arrow":"18.1.0","mem-fs":"2.1.0","mem-fs-editor":"9.4.0"},engines:{node:">=20.x"}};var Pqe=Xe({name:fe().describe("Name of the Fiori application. Usually derived from the `sap.app/id` field in the application's manifest.json."),appPath:fe().describe("Absolute path to the Fiori application's root directory."),projectPath:fe().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:yi(["EDMXBackend","CAPJava","CAPNodejs"]).describe("Type of project the application belongs to."),odataVersion:fe().describe("OData protocol version used by the application's main service.")}),hb=vn([fe(),pr(vn([fe(),In()]))]),Dqe=Xe({functionalityId:hb.describe("Identifier to pass as the `functionalityId` parameter when calling `get_functionality_details` or `execute_functionality`"),description:fe()}),Cqe=yi(["object","array","string","number","boolean","null","integer","any"]),xqe=Xe({type:vn([Cqe,pr(Cqe)]).optional(),description:fe().optional(),properties:Lw().optional()}).catchall(Lw()),Nqe=xqe.extend({properties:qn(fe(),vn([xqe,ji()])).optional()});var Rqe=Xe({searchPath:pr(fe()).describe("Path to search for Fiori applications (defaults to current directory). If VSCode - list of VS Code workspace folder paths(`workspace.workspaceFolders`)")}),Iqe=Xe({appPath:fe().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.")}),wqe=Xe({appPath:fe().describe("Path to the Fiori application if one exists or to the current directory. Path should be an absolute path."),functionalityId:hb.describe("The ID of the functionality to get details for")}),Lqe=Xe({functionalityId:hb.describe("The ID of the functionality to execute"),parameters:qn(fe(),Kn()).describe("Parameters for the functionality execution"),appPath:fe().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.'),Wdi=Xe({query:fe().min(2).describe("The search query for fiori elements, annotations, sapui5, fiori tools documentation")});var Jdi=fe().describe("Search results as formatted text"),Mqe=Xe({applications:pr(Pqe)}),kqe=Xe({applicationPath:fe(),functionalities:pr(Dqe)}),$qe=Xe({functionalityId:hb.describe("Identifier to pass as the `functionalityId` parameter when calling `get_functionality_details` or `execute_functionality`"),name:fe(),description:fe(),technicalDescription:fe().optional(),parameters:Nqe,prerequisites:pr(fe()).optional(),impact:fe().optional(),examples:pr(fe()).optional(),pageName:fe().optional()}),Uqe=Xe({functionalityId:hb,status:fe(),message:fe(),parameters:Kn(),appPath:fe(),changes:pr(fe()),timestamp:fe()});var v_e=mr(require("node:fs/promises")),Cf=mr(require("node:path"));var Au=mr(nE()),kut=mr(vp()),$ut=require("node:path");function $7r(){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 Au.LogLevel.Error;case"WARN":return Au.LogLevel.Warn;case"INFO":return Au.LogLevel.Info;case"DEBUG":return Au.LogLevel.Debug;case"VERBOSE":return Au.LogLevel.Verbose;case"SILLY":return Au.LogLevel.Silly;default:break}return Au.LogLevel.Error}var Mut=$7r(),Vt=new Au.ToolsLogger({logLevel:Mut??Au.LogLevel.Error,transports:Mut===void 0?[new Au.NullTransport]:[new Au.FileTransport({filename:(0,$ut.join)(kut.fioriToolsDirectory,"fiori-mcp-server.log"),maxsize:10*1024*1024,maxFiles:5})],logPrefix:"fiori-mcp"}),l$={info:(e,...t)=>{Vt.info(`@sap/ux-specification: ${e}`);for(let r of t)Vt.info(typeof r=="number"?r.toString():r)},warning:(e,...t)=>{Vt.warn(`@sap/ux-specification: ${e}`);for(let r of t)Vt.warn(typeof r=="number"?r.toString():r)},error:(e,...t)=>{Vt.error(`@sap/ux-specification: ${e}`);for(let r of t)Vt.error(typeof r=="number"?r.toString():r)},reset:()=>{}};async function Uut(){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 v_e.default.access(n),Vt.log("\u2713 Using @sap-ux/fiori-docs-embeddings package"),{dataPath:n,embeddingsPath:Cf.default.join(n,"embeddings"),searchPath:Cf.default.join(n,"search"),docsPath:Cf.default.join(n,"docs"),isExternalPackage:!0,isAvailable:!0}}catch{Vt.warn("Could not load @sap-ux/fiori-docs-embeddings package, trying local data...")}let e=Cf.default.join(__dirname,"../../data");try{return await v_e.default.access(e),Vt.log("\u2713 Using local data directory"),{dataPath:e,embeddingsPath:Cf.default.join(e,"embeddings"),searchPath:Cf.default.join(e,"search"),docsPath:Cf.default.join(e,"docs"),isExternalPackage:!1,isAvailable:!0}}catch{Vt.warn("Local data directory not available either")}let t=Cf.default.join(__dirname,"../../data");return Vt.warn("\u26A0\uFE0F No embeddings data available - running in limited mode"),{dataPath:t,embeddingsPath:Cf.default.join(t,"embeddings"),searchPath:Cf.default.join(t,"search"),docsPath:Cf.default.join(t,"docs"),isExternalPackage:!1,isAvailable:!1}}var kc=mr(vp()),p$=require("node:path");async function Ou(e){try{e=(0,p$.join)(e);try{let t=await(0,kc.createApplicationAccess)(e);return{root:t.project.root,appId:t.getAppId(),applicationAccess:t}}catch(t){Vt.warn(`Application was not found by given path. Error: ${t}`);let r=await(0,kc.findProjectRoot)(e),n=await(0,kc.getProject)(r);if(n)return{root:n.root,appId:""}}}catch(t){Vt.warn(`Project was not found by given path. Error: ${t}`);return}}var bY=e=>{let t;switch(e){case kc.DirName.View:{t=(0,p$.join)(kc.DirName.Ext,kc.DirName.View);break}case kc.DirName.Fragment:{t=(0,p$.join)(kc.DirName.Ext,kc.DirName.Fragment);break}case kc.DirName.Controller:{t=(0,p$.join)(kc.DirName.Ext,kc.DirName.Controller);break}default:t=e}return t},dm=(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,dm({...o,...s},t,r)}}let n={...e};return n.properties&&(n.properties=Object.fromEntries(Object.entries(n.properties).map(([i,a])=>[i,dm(a,t,r)]))),n.items&&(Array.isArray(n.items)?n.items=n.items.map(i=>dm(i,t,r)):n.items=dm(n.items,t,r)),n.allOf&&(n.allOf=n.allOf.map(i=>dm(i,t,r))),n.anyOf&&(n.anyOf=n.anyOf.map(i=>dm(i,t,r))),n.oneOf&&(n.oneOf=n.oneOf.map(i=>dm(i,t,r))),typeof n.additionalProperties=="object"&&(n.additionalProperties=dm(n.additionalProperties,t,r)),n},Vut=(e,t)=>({type:"object",properties:{[e]:t}}),Ba=e=>{let t=P_(e);return delete t.$schema,t},hm=(e,t)=>{try{return e.parse(t)}catch(r){throw r instanceof $ae?new Error(`Missing required fields in parameters. ${JSON.stringify(r.issues,null,4)}`):new Error("Unknown error. Recheck input parameters.")}};var GTt=require("node:util"),HTt=require("node:child_process"),zTt=mr(_be());async function CK(e="1.18.5"){let t="@sap/generator-fiori";if((await(0,zTt.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 xK=(0,GTt.promisify)(HTt.exec);var YTt=require("@lancedb/lancedb");var Ebe=mr(require("node:fs/promises")),Tbe=mr(require("node:path")),PK=class{connection=null;tables=[];tableIndex=null;metadata=null;dataPath;constructor(t){this.dataPath=t||""}async initialize(){try{Vt.log("Loading vector database from pre-built embeddings...");let t=await Uut();if(!t.isAvailable)throw new Error("No embeddings data available");this.dataPath=t.embeddingsPath,Vt.log(`Using embeddings path: ${this.dataPath} (external: ${t.isExternalPackage})`);let r=Tbe.default.join(this.dataPath,"metadata.json"),n=await Ebe.default.readFile(r,"utf-8");this.metadata=JSON.parse(n),Vt.log("\u2713 Embedding metadata loaded:"),Vt.log(` Model: ${this?.metadata?.model}`),Vt.log(` Dimensions: ${this?.metadata?.dimensions}`),Vt.log(` Total vectors: ${this?.metadata?.totalVectors}`),Vt.log(` Created: ${this?.metadata?.createdAt}`),this.connection=await(0,YTt.connect)(this.dataPath);let i=Tbe.default.join(this.dataPath,"table_index.json");try{let a=await Ebe.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)}Vt.log(`\u2713 Loaded ${this.tables.length} split tables`)}catch{Vt.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}`)}}Vt.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 Vt.error(`Semantic search failed: ${i}`),new Error(`Semantic search failed: ${i}`)}}async findSimilarToText(t,r=5){return Vt.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 Vt.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 Vt.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=[],Vt.log("Vector database connection closed"))}};var DK=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 Sbe(e,t=!1){let{query:r,maxResults:n}=e;try{let i=new PK,a=new DK;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}:
1500
1500
 
1501
1501
  `,c+=`${l.document.content}
1502
1502
  `,c+=`---
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/fiori-mcp-server",
3
3
  "description": "SAP Fiori - Model Context Protocol (MCP) server",
4
- "version": "0.6.56",
4
+ "version": "0.6.57",
5
5
  "mcpName": "io.github.SAP/fiori-mcp-server",
6
6
  "keywords": [
7
7
  "SAP Fiori tools",
@@ -51,18 +51,18 @@
51
51
  "@langchain/mcp-adapters": "1.1.3",
52
52
  "@langchain/core": "1.1.40",
53
53
  "@sap-ux/axios-extension": "1.25.35",
54
- "@sap-ux/project-access": "1.36.3",
55
54
  "@sap-ux/fiori-annotation-api": "0.9.48",
56
- "@sap-ux/fiori-docs-embeddings": "0.4.18",
55
+ "@sap-ux/project-access": "1.36.3",
57
56
  "@sap-ux/i18n": "0.3.11",
58
- "@sap-ux/odata-annotation-core-types": "0.5.8",
57
+ "@sap-ux/fiori-docs-embeddings": "0.4.18",
59
58
  "@sap-ux/logger": "0.8.5",
60
- "@sap-ux/text-document-utils": "0.3.4",
59
+ "@sap-ux/odata-annotation-core-types": "0.5.8",
61
60
  "@sap-ux/odata-entity-model": "0.3.7",
61
+ "@sap-ux/text-document-utils": "0.3.4",
62
62
  "@sap-ux/feature-toggle": "0.3.8",
63
- "@sap-ux/btp-utils": "1.1.15",
64
63
  "@sap-ux/nodejs-utils": "0.2.22",
65
- "@sap-ux/telemetry": "0.6.104"
64
+ "@sap-ux/telemetry": "0.6.104",
65
+ "@sap-ux/btp-utils": "1.1.15"
66
66
  },
67
67
  "dependencies": {
68
68
  "@xenova/transformers": "2.17.2",