@f2c/mcp 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -57
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +16 -16
- package/dist/stdio.js +4 -4
- package/dist/stdio.js.map +16 -16
- package/dist/streamable-http.js +4 -4
- package/dist/streamable-http.js.map +19 -19
- package/package.json +84 -77
package/README.md
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
# F2C MCP Server
|
|
2
|
-

|
|
3
|
-
[](https://smithery.ai/server/@f2c-ai/f2c-mcp)
|
|
4
|
-
[![npm version][npm-version-src]][npm-version-href]
|
|
5
|
-
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
6
|
-
[![github][github-src]][github-href]
|
|
7
|
-
[![node][node-src]][node-href]
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
[npm-version-src]: https://img.shields.io/npm/v/@f2c/mcp?style=flat&colorA=18181B&colorB=F0DB4F
|
|
11
|
-
[npm-version-href]: https://npmjs.com/package/@f2c/mcp
|
|
12
|
-
[npm-downloads-src]: https://img.shields.io/npm/dm/@f2c/mcp?style=flat&colorA=18181B&colorB=F0DB4F
|
|
13
|
-
[npm-downloads-href]: https://npmjs.com/package/@f2c/mcp
|
|
14
|
-
[github-src]: https://img.shields.io/badge/github-@f2c/mcp-blue?style=flat&colorA=18181B&colorB=F0DB4F
|
|
15
|
-
[github-href]: https://github.com/f2c-ai/f2c-mcp
|
|
16
|
-
[node-src]: https://img.shields.io/node/v/@f2c/mcp?style=flat&colorA=18181B&colorB=F0DB4F
|
|
17
|
-
[node-href]: https://nodejs.org/en/about/previous-releases
|
|
18
|
-
|
|
19
|
-
English | [简体中文](./README-zh-CN.md)
|
|
20
|
-
|
|
21
|
-
A Model Context Protocol server for Figma Design to Code using [F2C](https://f2c.yy.com/).
|
|
22
|
-
|
|
23
|
-
<a href="https://glama.ai/mcp/servers/@f2c-ai/f2c-mcp">
|
|
24
|
-
<img width="380" height="200" src="https://glama.ai/mcp/servers/@f2c-ai/f2c-mcp/badge" alt="f2c-mcp-server MCP server" />
|
|
25
|
-
</a>
|
|
26
|
-
|
|
27
|
-
## Features
|
|
28
|
-
<img alt="f2c" src="https://raw.githubusercontent.com/f2c-ai/f2c-mcp/main/docs/bannerv3.png" />
|
|
29
|
-
|
|
30
|
-
- 🎨 Pixel-Perfect HTML/CSS:F2C converts Figma designs to pixel-perfect HTML/CSS with precision.
|
|
31
|
-
- ⚛️ Multi-Framework Support:F2C generates React, CSS Modules, and Tailwind CSS code for fast development.
|
|
32
|
-
- 🧠 Figma Design Context:F2C integrates design context, ensuring compatibility with AI tools like Cursor.
|
|
33
|
-
- 🔗 Figma File URL Parsing:F2C converts design nodes via Figma URLs, streamlining workflows.
|
|
34
|
-
- 🖼️ Remote Image Localization:F2C automates downloading Figma images to local assets for efficiency.
|
|
35
|
-
|
|
36
|
-
## How it works
|
|
37
|
-
1. [Configure the Server](docs/en/GettingStarted.md) in an MCP-supported IDE (e.g., Cursor, Trae).
|
|
38
|
-
2. Open your chat in IDE (e.g. agent mode in Cursor).
|
|
39
|
-
3. Paste a link to a Figma Node (Right-click any node in the Figma Layer panel to copy it).
|
|
40
|
-
4. Enter your requirements in the chat, such as fetching node data, downloading images, converting to code, etc.
|
|
41
|
-
|
|
42
|
-
## Configuration and Development
|
|
43
|
-
|
|
44
|
-
See [Configuration and Development](docs/en/GettingStarted.md)
|
|
45
|
-
|
|
46
|
-
## Data Privacy Notice
|
|
47
|
-
The logging tools integrated in this project are used solely for basic usage statistics and error log reporting. No sensitive information or user data is collected. All reported data is used exclusively to improve product quality and user experience.
|
|
48
|
-
|
|
49
|
-
## FAQ
|
|
50
|
-
See [FAQ](docs/en/FAQ.md)
|
|
51
|
-
|
|
52
|
-
## Credits
|
|
53
|
-
|
|
54
|
-
Thanks to:
|
|
55
|
-
|
|
56
|
-
+ [Framelink Figma MCP Server](https://github.com/GLips/Figma-Context-MCP) Give Cursor and other AI-powered coding tools access to your Figma files with this Model Context Protocol server.
|
|
57
|
-
+ [Cursor Talk to Figma MCP](https://github.com/sonnylazuardi/cursor-talk-to-figma-mcp) Allowing Cursor to communicate with Figma for reading designs and modifying them programmatically.
|
|
1
|
+
# F2C MCP Server
|
|
2
|
+

|
|
3
|
+
[](https://smithery.ai/server/@f2c-ai/f2c-mcp)
|
|
4
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
5
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
6
|
+
[![github][github-src]][github-href]
|
|
7
|
+
[![node][node-src]][node-href]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
[npm-version-src]: https://img.shields.io/npm/v/@f2c/mcp?style=flat&colorA=18181B&colorB=F0DB4F
|
|
11
|
+
[npm-version-href]: https://npmjs.com/package/@f2c/mcp
|
|
12
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@f2c/mcp?style=flat&colorA=18181B&colorB=F0DB4F
|
|
13
|
+
[npm-downloads-href]: https://npmjs.com/package/@f2c/mcp
|
|
14
|
+
[github-src]: https://img.shields.io/badge/github-@f2c/mcp-blue?style=flat&colorA=18181B&colorB=F0DB4F
|
|
15
|
+
[github-href]: https://github.com/f2c-ai/f2c-mcp
|
|
16
|
+
[node-src]: https://img.shields.io/node/v/@f2c/mcp?style=flat&colorA=18181B&colorB=F0DB4F
|
|
17
|
+
[node-href]: https://nodejs.org/en/about/previous-releases
|
|
18
|
+
|
|
19
|
+
English | [简体中文](./README-zh-CN.md)
|
|
20
|
+
|
|
21
|
+
A Model Context Protocol server for Figma Design to Code using [F2C](https://f2c.yy.com/).
|
|
22
|
+
|
|
23
|
+
<a href="https://glama.ai/mcp/servers/@f2c-ai/f2c-mcp">
|
|
24
|
+
<img width="380" height="200" src="https://glama.ai/mcp/servers/@f2c-ai/f2c-mcp/badge" alt="f2c-mcp-server MCP server" />
|
|
25
|
+
</a>
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
<img alt="f2c" src="https://raw.githubusercontent.com/f2c-ai/f2c-mcp/main/docs/bannerv3.png" />
|
|
29
|
+
|
|
30
|
+
- 🎨 Pixel-Perfect HTML/CSS:F2C converts Figma designs to pixel-perfect HTML/CSS with precision.
|
|
31
|
+
- ⚛️ Multi-Framework Support:F2C generates React, CSS Modules, and Tailwind CSS code for fast development.
|
|
32
|
+
- 🧠 Figma Design Context:F2C integrates design context, ensuring compatibility with AI tools like Cursor.
|
|
33
|
+
- 🔗 Figma File URL Parsing:F2C converts design nodes via Figma URLs, streamlining workflows.
|
|
34
|
+
- 🖼️ Remote Image Localization:F2C automates downloading Figma images to local assets for efficiency.
|
|
35
|
+
|
|
36
|
+
## How it works
|
|
37
|
+
1. [Configure the Server](docs/en/GettingStarted.md) in an MCP-supported IDE (e.g., Cursor, Trae).
|
|
38
|
+
2. Open your chat in IDE (e.g. agent mode in Cursor).
|
|
39
|
+
3. Paste a link to a Figma Node (Right-click any node in the Figma Layer panel to copy it).
|
|
40
|
+
4. Enter your requirements in the chat, such as fetching node data, downloading images, converting to code, etc.
|
|
41
|
+
|
|
42
|
+
## Configuration and Development
|
|
43
|
+
|
|
44
|
+
See [Configuration and Development](docs/en/GettingStarted.md)
|
|
45
|
+
|
|
46
|
+
## Data Privacy Notice
|
|
47
|
+
The logging tools integrated in this project are used solely for basic usage statistics and error log reporting. No sensitive information or user data is collected. All reported data is used exclusively to improve product quality and user experience.
|
|
48
|
+
|
|
49
|
+
## FAQ
|
|
50
|
+
See [FAQ](docs/en/FAQ.md)
|
|
51
|
+
|
|
52
|
+
## Credits
|
|
53
|
+
|
|
54
|
+
Thanks to:
|
|
55
|
+
|
|
56
|
+
+ [Framelink Figma MCP Server](https://github.com/GLips/Figma-Context-MCP) Give Cursor and other AI-powered coding tools access to your Figma files with this Model Context Protocol server.
|
|
57
|
+
+ [Cursor Talk to Figma MCP](https://github.com/sonnylazuardi/cursor-talk-to-figma-mcp) Allowing Cursor to communicate with Figma for reading designs and modifying them programmatically.
|
|
58
58
|
+ [Figma MCP Server](https://github.com/MatthewDailey/figma-mcp) This server provides tools for viewing, commenting, and analyzing Figma designs directly through the ModelContextProtocol.
|
package/dist/cli.js
CHANGED
|
@@ -12,11 +12,11 @@ Content-Type: ${Y.type||"application/octet-stream"}\r
|
|
|
12
12
|
`)).replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22"),M0=(f,v,J)=>{if(v.length<J)throw new TypeError(`Failed to execute '${f}' on 'FormData': ${J} arguments required, but only ${v.length} present.`)},nf;var zJ=rv(()=>{yQ();ZW();/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */({toStringTag:TQ,iterator:_G,hasInstance:kG}=Symbol),NY=Math.random,IG="append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(","),nf=class f{#v=[];constructor(...v){if(v.length)throw new TypeError("Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.")}get[TQ](){return"FormData"}[_G](){return this.entries()}static[kG](v){return v&&typeof v==="object"&&v[TQ]==="FormData"&&!IG.some((J)=>typeof v[J]!="function")}append(...v){M0("append",arguments,2),this.#v.push(UY(...v))}delete(v){M0("delete",arguments,1),v+="",this.#v=this.#v.filter(([J])=>J!==v)}get(v){M0("get",arguments,1),v+="";for(var J=this.#v,X=J.length,Q=0;Q<X;Q++)if(J[Q][0]===v)return J[Q][1];return null}getAll(v,J){return M0("getAll",arguments,1),J=[],v+="",this.#v.forEach((X)=>X[0]===v&&J.push(X[1])),J}has(v){return M0("has",arguments,1),v+="",this.#v.some((J)=>J[0]===v)}forEach(v,J){M0("forEach",arguments,1);for(var[X,Q]of this)v.call(J,Q,X,this)}set(...v){M0("set",arguments,2);var J=[],X=!0;v=UY(...v),this.#v.forEach((Q)=>{Q[0]===v[0]?X&&(X=!J.push(v)):J.push(Q)}),X&&J.push(v),this.#v=J}*entries(){yield*this.#v}*keys(){for(var[v]of this)yield v}*values(){for(var[,v]of this)yield v}}});var df;var BJ=rv(()=>{df=class df extends Error{constructor(f,v){super(f);Error.captureStackTrace(this,this.constructor),this.type=v}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}}});var V1;var lW=rv(()=>{BJ();V1=class V1 extends df{constructor(f,v,J){super(f,v);if(J)this.code=this.errno=J.code,this.erroredSysCall=J.syscall}}});var KJ,mW=(f)=>{return typeof f==="object"&&typeof f.append==="function"&&typeof f.delete==="function"&&typeof f.get==="function"&&typeof f.getAll==="function"&&typeof f.has==="function"&&typeof f.set==="function"&&typeof f.sort==="function"&&f[KJ]==="URLSearchParams"},bQ=(f)=>{return f&&typeof f==="object"&&typeof f.arrayBuffer==="function"&&typeof f.type==="string"&&typeof f.stream==="function"&&typeof f.constructor==="function"&&/^(Blob|File)$/.test(f[KJ])},SY=(f)=>{return typeof f==="object"&&(f[KJ]==="AbortSignal"||f[KJ]==="EventTarget")},RY=(f,v)=>{let J=new URL(v).hostname,X=new URL(f).hostname;return J===X||J.endsWith(`.${X}`)},gY=(f,v)=>{let J=new URL(v).protocol,X=new URL(f).protocol;return J===X};var hJ=rv(()=>{KJ=Symbol.toStringTag});var kY=fv((Fh,_Y)=>{/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */if(!globalThis.DOMException)try{let{MessageChannel:f}=require("worker_threads"),v=new f().port1,J=new ArrayBuffer;v.postMessage(J,[J,J])}catch(f){f.constructor.name==="DOMException"&&(globalThis.DOMException=f.constructor)}_Y.exports=globalThis.DOMException});var O0,IY,CY,uW,yY=(f,v)=>xY(O0.statSync(f),f,v),TY=(f,v)=>uW(f).then((J)=>xY(J,f,v)),bY=(f,v)=>uW(f).then((J)=>lY(J,f,v)),ZY=(f,v)=>lY(O0.statSync(f),f,v),xY=(f,v,J="")=>new o1([new HJ({path:v,size:f.size,lastModified:f.mtimeMs,start:0})],{type:J}),lY=(f,v,J="")=>new pf([new HJ({path:v,size:f.size,lastModified:f.mtimeMs,start:0})],IY.basename(v),{type:J,lastModified:f.mtimeMs}),HJ;var cW=rv(()=>{O0=require("node:fs"),IY=require("node:path"),CY=M1(kY());ZW();yQ();({stat:uW}=O0.promises);HJ=class HJ{#v;#f;constructor(f){this.#v=f.path,this.#f=f.start,this.size=f.size,this.lastModified=f.lastModified}slice(f,v){return new HJ({path:this.#v,lastModified:this.lastModified,size:v-f,start:this.#f+f})}async*stream(){let{mtimeMs:f}=await uW(this.#v);if(f>this.lastModified)throw new CY.default("The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.","NotReadableError");yield*O0.createReadStream(this.#v,{start:this.#f,end:this.#f+this.size-1})}get[Symbol.toStringTag](){return"Blob"}}});var cY={};d9(cY,{toFormData:()=>lG});class uY{constructor(f){this.index=0,this.flags=0,this.onHeaderEnd=V0,this.onHeaderField=V0,this.onHeadersEnd=V0,this.onHeaderValue=V0,this.onPartBegin=V0,this.onPartData=V0,this.onPartEnd=V0,this.boundaryChars={},f=`\r
|
|
13
13
|
--`+f;let v=new Uint8Array(f.length);for(let J=0;J<f.length;J++)v[J]=f.charCodeAt(J),this.boundaryChars[v[J]]=!0;this.boundary=v,this.lookbehind=new Uint8Array(this.boundary.length+8),this.state=kv.START_BOUNDARY}write(f){let v=0,J=f.length,X=this.index,{lookbehind:Q,boundary:Y,boundaryChars:w,index:G,state:K,flags:D}=this,H=this.boundary.length,F=H-1,q=f.length,h,$,j=(L)=>{this[L+"Mark"]=v},V=(L)=>{delete this[L+"Mark"]},N=(L,k,_,T)=>{if(k===void 0||k!==_)this[L](T&&T.subarray(k,_))},I=(L,k)=>{let _=L+"Mark";if(!(_ in this))return;if(k)N(L,this[_],v,f),delete this[_];else N(L,this[_],f.length,f),this[_]=0};for(v=0;v<J;v++)switch(h=f[v],K){case kv.START_BOUNDARY:if(G===Y.length-2){if(h===ZQ)D|=sf.LAST_BOUNDARY;else if(h!==$J)return;G++;break}else if(G-1===Y.length-2){if(D&sf.LAST_BOUNDARY&&h===ZQ)K=kv.END,D=0;else if(!(D&sf.LAST_BOUNDARY)&&h===DJ)G=0,N("onPartBegin"),K=kv.HEADER_FIELD_START;else return;break}if(h!==Y[G+2])G=-2;if(h===Y[G+2])G++;break;case kv.HEADER_FIELD_START:K=kv.HEADER_FIELD,j("onHeaderField"),G=0;case kv.HEADER_FIELD:if(h===$J){V("onHeaderField"),K=kv.HEADERS_ALMOST_DONE;break}if(G++,h===ZQ)break;if(h===yG){if(G===1)return;I("onHeaderField",!0),K=kv.HEADER_VALUE_START;break}if($=ZG(h),$<TG||$>bG)return;break;case kv.HEADER_VALUE_START:if(h===CG)break;j("onHeaderValue"),K=kv.HEADER_VALUE;case kv.HEADER_VALUE:if(h===$J)I("onHeaderValue",!0),N("onHeaderEnd"),K=kv.HEADER_VALUE_ALMOST_DONE;break;case kv.HEADER_VALUE_ALMOST_DONE:if(h!==DJ)return;K=kv.HEADER_FIELD_START;break;case kv.HEADERS_ALMOST_DONE:if(h!==DJ)return;N("onHeadersEnd"),K=kv.PART_DATA_START;break;case kv.PART_DATA_START:K=kv.PART_DATA,j("onPartData");case kv.PART_DATA:if(X=G,G===0){v+=F;while(v<q&&!(f[v]in w))v+=H;v-=F,h=f[v]}if(G<Y.length)if(Y[G]===h){if(G===0)I("onPartData",!0);G++}else G=0;else if(G===Y.length)if(G++,h===$J)D|=sf.PART_BOUNDARY;else if(h===ZQ)D|=sf.LAST_BOUNDARY;else G=0;else if(G-1===Y.length)if(D&sf.PART_BOUNDARY){if(G=0,h===DJ){D&=~sf.PART_BOUNDARY,N("onPartEnd"),N("onPartBegin"),K=kv.HEADER_FIELD_START;break}}else if(D&sf.LAST_BOUNDARY)if(h===ZQ)N("onPartEnd"),K=kv.END,D=0;else G=0;else G=0;if(G>0)Q[G-1]=h;else if(X>0){let L=new Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength);N("onPartData",0,X,L),X=0,j("onPartData"),v--}break;case kv.END:break;default:throw new Error(`Unexpected state entered: ${K}`)}I("onHeaderField"),I("onHeaderValue"),I("onPartData"),this.index=G,this.state=K,this.flags=D}end(){if(this.state===kv.HEADER_FIELD_START&&this.index===0||this.state===kv.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==kv.END)throw new Error("MultipartParser.end(): stream ended unexpectedly")}}function xG(f){let v=f.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!v)return;let J=v[2]||v[3]||"",X=J.slice(J.lastIndexOf("\\")+1);return X=X.replace(/%22/g,'"'),X=X.replace(/&#(\d{4});/g,(Q,Y)=>{return String.fromCharCode(Y)}),X}async function lG(f,v){if(!/multipart/i.test(v))throw new TypeError("Failed to fetch");let J=v.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!J)throw new TypeError("no or bad content-type header, no multipart boundary");let X=new uY(J[1]||J[2]),Q,Y,w,G,K,D,H=[],F=new nf,q=(N)=>{w+=V.decode(N,{stream:!0})},h=(N)=>{H.push(N)},$=()=>{let N=new pf(H,D,{type:K});F.append(G,N)},j=()=>{F.append(G,w)},V=new TextDecoder("utf-8");V.decode(),X.onPartBegin=function(){X.onPartData=q,X.onPartEnd=j,Q="",Y="",w="",G="",K="",D=null,H.length=0},X.onHeaderField=function(N){Q+=V.decode(N,{stream:!0})},X.onHeaderValue=function(N){Y+=V.decode(N,{stream:!0})},X.onHeaderEnd=function(){if(Y+=V.decode(),Q=Q.toLowerCase(),Q==="content-disposition"){let N=Y.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);if(N)G=N[2]||N[3]||"";if(D=xG(Y),D)X.onPartData=h,X.onPartEnd=$}else if(Q==="content-type")K=Y;Y="",Q=""};for await(let N of f)X.write(N);return X.end(),F}var Kf=0,kv,mY=1,sf,DJ=10,$J=13,CG=32,ZQ=45,yG=58,TG=97,bG=122,ZG=(f)=>f|32,V0=()=>{};var rY=rv(()=>{cW();zJ();kv={START_BOUNDARY:Kf++,HEADER_FIELD_START:Kf++,HEADER_FIELD:Kf++,HEADER_VALUE_START:Kf++,HEADER_VALUE:Kf++,HEADER_VALUE_ALMOST_DONE:Kf++,HEADERS_ALMOST_DONE:Kf++,PART_DATA_START:Kf++,PART_DATA:Kf++,END:Kf++},sf={PART_BOUNDARY:mY,LAST_BOUNDARY:mY*=2}});class Sf{constructor(f,{size:v=0}={}){let J=null;if(f===null)f=null;else if(mW(f))f=U1.Buffer.from(f.toString());else if(bQ(f));else if(U1.Buffer.isBuffer(f));else if(Rf.types.isAnyArrayBuffer(f))f=U1.Buffer.from(f);else if(ArrayBuffer.isView(f))f=U1.Buffer.from(f.buffer,f.byteOffset,f.byteLength);else if(f instanceof l1.default);else if(f instanceof nf)f=LY(f),J=f.type.split("=")[1];else f=U1.Buffer.from(String(f));let X=f;if(U1.Buffer.isBuffer(f))X=l1.default.Readable.from(f);else if(bQ(f))X=l1.default.Readable.from(f.stream());if(this[q1]={body:f,stream:X,boundary:J,disturbed:!1,error:null},this.size=v,f instanceof l1.default)f.on("error",(Q)=>{let Y=Q instanceof df?Q:new V1(`Invalid response body while trying to fetch ${this.url}: ${Q.message}`,"system",Q);this[q1].error=Y})}get body(){return this[q1].stream}get bodyUsed(){return this[q1].disturbed}async arrayBuffer(){let{buffer:f,byteOffset:v,byteLength:J}=await rW(this);return f.slice(v,v+J)}async formData(){let f=this.headers.get("content-type");if(f.startsWith("application/x-www-form-urlencoded")){let J=new nf,X=new URLSearchParams(await this.text());for(let[Q,Y]of X)J.append(Q,Y);return J}let{toFormData:v}=await Promise.resolve().then(() => (rY(),cY));return v(this.body,f)}async blob(){let f=this.headers&&this.headers.get("content-type")||this[q1].body&&this[q1].body.type||"",v=await this.arrayBuffer();return new o1([v],{type:f})}async json(){let f=await this.text();return JSON.parse(f)}async text(){let f=await rW(this);return new TextDecoder().decode(f)}buffer(){return rW(this)}}async function rW(f){if(f[q1].disturbed)throw new TypeError(`body used already for: ${f.url}`);if(f[q1].disturbed=!0,f[q1].error)throw f[q1].error;let{body:v}=f;if(v===null)return U1.Buffer.alloc(0);if(!(v instanceof l1.default))return U1.Buffer.alloc(0);let J=[],X=0;try{for await(let Q of v){if(f.size>0&&X+Q.length>f.size){let Y=new V1(`content size at ${f.url} over limit: ${f.size}`,"max-size");throw v.destroy(Y),Y}X+=Q.length,J.push(Q)}}catch(Q){throw Q instanceof df?Q:new V1(`Invalid response body while trying to fetch ${f.url}: ${Q.message}`,"system",Q)}if(v.readableEnded===!0||v._readableState.ended===!0)try{if(J.every((Q)=>typeof Q==="string"))return U1.Buffer.from(J.join(""));return U1.Buffer.concat(J,X)}catch(Q){throw new V1(`Could not create Buffer from response body for ${f.url}: ${Q.message}`,"system",Q)}else throw new V1(`Premature close of server response while trying to fetch ${f.url}`)}var l1,Rf,U1,mG,q1,e0=(f,v)=>{let J,X,{body:Q}=f[q1];if(f.bodyUsed)throw new Error("cannot clone body after it is used");if(Q instanceof l1.default&&typeof Q.getBoundary!=="function")J=new l1.PassThrough({highWaterMark:v}),X=new l1.PassThrough({highWaterMark:v}),Q.pipe(J),Q.pipe(X),f[q1].stream=J,Q=X;return Q},uG,MJ=(f,v)=>{if(f===null)return null;if(typeof f==="string")return"text/plain;charset=UTF-8";if(mW(f))return"application/x-www-form-urlencoded;charset=UTF-8";if(bQ(f))return f.type||null;if(U1.Buffer.isBuffer(f)||Rf.types.isAnyArrayBuffer(f)||ArrayBuffer.isView(f))return null;if(f instanceof nf)return`multipart/form-data; boundary=${v[q1].boundary}`;if(f&&typeof f.getBoundary==="function")return`multipart/form-data;boundary=${uG(f)}`;if(f instanceof l1.default)return null;return"text/plain;charset=UTF-8"},aY=(f)=>{let{body:v}=f[q1];if(v===null)return 0;if(bQ(v))return v.size;if(U1.Buffer.isBuffer(v))return v.length;if(v&&typeof v.getLengthSync==="function")return v.hasKnownLength&&v.hasKnownLength()?v.getLengthSync():null;return null},pY=async(f,{body:v})=>{if(v===null)f.end();else await mG(v,f)};var OJ=rv(()=>{l1=M1(require("node:stream")),Rf=require("node:util"),U1=require("node:buffer");yQ();zJ();lW();BJ();hJ();mG=Rf.promisify(l1.default.pipeline),q1=Symbol("Body internals");Sf.prototype.buffer=Rf.deprecate(Sf.prototype.buffer,"Please use 'response.arrayBuffer()' instead of 'response.buffer()'","node-fetch#buffer");Object.defineProperties(Sf.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0},data:{get:Rf.deprecate(()=>{},"data doesn't exist, use json(), text(), arrayBuffer(), or body instead","https://github.com/node-fetch/node-fetch/issues/1000 (response)")}});uG=Rf.deprecate((f)=>f.getBoundary(),"form-data doesn't follow the spec and requires special treatment. Use alternative package","https://github.com/node-fetch/node-fetch/issues/1167")});function nY(f=[]){return new F1(f.reduce((v,J,X,Q)=>{if(X%2===0)v.push(Q.slice(X,X+2));return v},[]).filter(([v,J])=>{try{return VJ(v),pW(v,String(J)),!0}catch{return!1}}))}var aW,xQ,VJ,pW,F1;var qJ=rv(()=>{aW=require("node:util"),xQ=M1(require("node:http")),VJ=typeof xQ.default.validateHeaderName==="function"?xQ.default.validateHeaderName:(f)=>{if(!/^[\^`\-\w!#$%&'*+.|~]+$/.test(f)){let v=new TypeError(`Header name must be a valid HTTP token [${f}]`);throw Object.defineProperty(v,"code",{value:"ERR_INVALID_HTTP_TOKEN"}),v}},pW=typeof xQ.default.validateHeaderValue==="function"?xQ.default.validateHeaderValue:(f,v)=>{if(/[^\t\u0020-\u007E\u0080-\u00FF]/.test(v)){let J=new TypeError(`Invalid character in header content ["${f}"]`);throw Object.defineProperty(J,"code",{value:"ERR_INVALID_CHAR"}),J}};F1=class F1 extends URLSearchParams{constructor(f){let v=[];if(f instanceof F1){let J=f.raw();for(let[X,Q]of Object.entries(J))v.push(...Q.map((Y)=>[X,Y]))}else if(f==null);else if(typeof f==="object"&&!aW.types.isBoxedPrimitive(f)){let J=f[Symbol.iterator];if(J==null)v.push(...Object.entries(f));else{if(typeof J!=="function")throw new TypeError("Header pairs must be iterable");v=[...f].map((X)=>{if(typeof X!=="object"||aW.types.isBoxedPrimitive(X))throw new TypeError("Each header pair must be an iterable object");return[...X]}).map((X)=>{if(X.length!==2)throw new TypeError("Each header pair must be a name/value tuple");return[...X]})}}else throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");v=v.length>0?v.map(([J,X])=>{return VJ(J),pW(J,String(X)),[String(J).toLowerCase(),String(X)]}):void 0;super(v);return new Proxy(this,{get(J,X,Q){switch(X){case"append":case"set":return(Y,w)=>{return VJ(Y),pW(Y,String(w)),URLSearchParams.prototype[X].call(J,String(Y).toLowerCase(),String(w))};case"delete":case"has":case"getAll":return(Y)=>{return VJ(Y),URLSearchParams.prototype[X].call(J,String(Y).toLowerCase())};case"keys":return()=>{return J.sort(),new Set(URLSearchParams.prototype.keys.call(J)).keys()};default:return Reflect.get(J,X,Q)}}})}get[Symbol.toStringTag](){return this.constructor.name}toString(){return Object.prototype.toString.call(this)}get(f){let v=this.getAll(f);if(v.length===0)return null;let J=v.join(", ");if(/^content-encoding$/i.test(f))J=J.toLowerCase();return J}forEach(f,v=void 0){for(let J of this.keys())Reflect.apply(f,v,[this.get(J),J,this])}*values(){for(let f of this.keys())yield this.get(f)}*entries(){for(let f of this.keys())yield[f,this.get(f)]}[Symbol.iterator](){return this.entries()}raw(){return[...this.keys()].reduce((f,v)=>{return f[v]=this.getAll(v),f},{})}[Symbol.for("nodejs.util.inspect.custom")](){return[...this.keys()].reduce((f,v)=>{let J=this.getAll(v);if(v==="host")f[v]=J[0];else f[v]=J.length>1?J:J[0];return f},{})}};Object.defineProperties(F1.prototype,["get","entries","forEach","values"].reduce((f,v)=>{return f[v]={enumerable:!0},f},{}))});var cG,lQ=(f)=>{return cG.has(f)};var nW=rv(()=>{cG=new Set([301,302,303,307,308])});var t1,w1;var iY=rv(()=>{qJ();OJ();nW();t1=Symbol("Response internals");w1=class w1 extends Sf{constructor(f=null,v={}){super(f,v);let J=v.status!=null?v.status:200,X=new F1(v.headers);if(f!==null&&!X.has("Content-Type")){let Q=MJ(f,this);if(Q)X.append("Content-Type",Q)}this[t1]={type:"default",url:v.url,status:J,statusText:v.statusText||"",headers:X,counter:v.counter,highWaterMark:v.highWaterMark}}get type(){return this[t1].type}get url(){return this[t1].url||""}get status(){return this[t1].status}get ok(){return this[t1].status>=200&&this[t1].status<300}get redirected(){return this[t1].counter>0}get statusText(){return this[t1].statusText}get headers(){return this[t1].headers}get highWaterMark(){return this[t1].highWaterMark}clone(){return new w1(e0(this,this.highWaterMark),{type:this.type,url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected,size:this.size,highWaterMark:this.highWaterMark})}static redirect(f,v=302){if(!lQ(v))throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');return new w1(null,{headers:{location:new URL(f).toString()},status:v})}static error(){let f=new w1(null,{status:0,statusText:""});return f[t1].type="error",f}static json(f=void 0,v={}){let J=JSON.stringify(f);if(J===void 0)throw new TypeError("data is not JSON serializable");let X=new F1(v&&v.headers);if(!X.has("content-type"))X.set("content-type","application/json");return new w1(J,{...v,headers:X})}get[Symbol.toStringTag](){return"Response"}};Object.defineProperties(w1.prototype,{type:{enumerable:!0},url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}})});var dY=(f)=>{if(f.search)return f.search;let v=f.href.length-1,J=f.hash||(f.href[v]==="#"?"#":"");return f.href[v-J.length]==="?"?"?":""};function sY(f,v=!1){if(f==null)return"no-referrer";if(f=new URL(f),/^(about|blob|data):$/.test(f.protocol))return"no-referrer";if(f.username="",f.password="",f.hash="",v)f.pathname="",f.search="";return f}function v7(f){if(!tY.has(f))throw new TypeError(`Invalid referrerPolicy: ${f}`);return f}function rG(f){if(/^(http|ws)s:$/.test(f.protocol))return!0;let v=f.host.replace(/(^\[)|(]$)/g,""),J=oY.isIP(v);if(J===4&&/^127\./.test(v))return!0;if(J===6&&/^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(v))return!0;if(f.host==="localhost"||f.host.endsWith(".localhost"))return!1;if(f.protocol==="file:")return!0;return!1}function vQ(f){if(/^about:(blank|srcdoc)$/.test(f))return!0;if(f.protocol==="data:")return!0;if(/^(blob|filesystem):$/.test(f.protocol))return!0;return rG(f)}function f7(f,{referrerURLCallback:v,referrerOriginCallback:J}={}){if(f.referrer==="no-referrer"||f.referrerPolicy==="")return null;let X=f.referrerPolicy;if(f.referrer==="about:client")return"no-referrer";let Q=f.referrer,Y=sY(Q),w=sY(Q,!0);if(Y.toString().length>4096)Y=w;if(v)Y=v(Y);if(J)w=J(w);let G=new URL(f.url);switch(X){case"no-referrer":return"no-referrer";case"origin":return w;case"unsafe-url":return Y;case"strict-origin":if(vQ(Y)&&!vQ(G))return"no-referrer";return w.toString();case"strict-origin-when-cross-origin":if(Y.origin===G.origin)return Y;if(vQ(Y)&&!vQ(G))return"no-referrer";return w;case"same-origin":if(Y.origin===G.origin)return Y;return"no-referrer";case"origin-when-cross-origin":if(Y.origin===G.origin)return Y;return w;case"no-referrer-when-downgrade":if(vQ(Y)&&!vQ(G))return"no-referrer";return Y;default:throw new TypeError(`Invalid referrerPolicy: ${X}`)}}function Q7(f){let v=(f.get("referrer-policy")||"").split(/[,\s]+/),J="";for(let X of v)if(X&&tY.has(X))J=X;return J}var oY,tY,eY="strict-origin-when-cross-origin";var iW=rv(()=>{oY=require("node:net");tY=new Set(["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"])});var J7,W7,tv,mQ=(f)=>{return typeof f==="object"&&typeof f[tv]==="object"},aG,of,X7=(f)=>{let{parsedURL:v}=f[tv],J=new F1(f[tv].headers);if(!J.has("Accept"))J.set("Accept","*/*");let X=null;if(f.body===null&&/^(post|put)$/i.test(f.method))X="0";if(f.body!==null){let G=aY(f);if(typeof G==="number"&&!Number.isNaN(G))X=String(G)}if(X)J.set("Content-Length",X);if(f.referrerPolicy==="")f.referrerPolicy=eY;if(f.referrer&&f.referrer!=="no-referrer")f[tv].referrer=f7(f);else f[tv].referrer="no-referrer";if(f[tv].referrer instanceof URL)J.set("Referer",f.referrer);if(!J.has("User-Agent"))J.set("User-Agent","node-fetch");if(f.compress&&!J.has("Accept-Encoding"))J.set("Accept-Encoding","gzip, deflate, br");let{agent:Q}=f;if(typeof Q==="function")Q=Q(v);let Y=dY(v),w={path:v.pathname+Y,method:f.method,headers:J[Symbol.for("nodejs.util.inspect.custom")](),insecureHTTPParser:f.insecureHTTPParser,agent:Q};return{parsedURL:v,options:w}};var Y7=rv(()=>{J7=require("node:url"),W7=require("node:util");qJ();OJ();hJ();iW();tv=Symbol("Request internals"),aG=W7.deprecate(()=>{},".data is not a valid RequestInit property, use .body instead","https://github.com/node-fetch/node-fetch/issues/1000 (request)");of=class of extends Sf{constructor(f,v={}){let J;if(mQ(f))J=new URL(f.url);else J=new URL(f),f={};if(J.username!==""||J.password!=="")throw new TypeError(`${J} is an url with embedded credentials.`);let X=v.method||f.method||"GET";if(/^(delete|get|head|options|post|put)$/i.test(X))X=X.toUpperCase();if(!mQ(v)&&"data"in v)aG();if((v.body!=null||mQ(f)&&f.body!==null)&&(X==="GET"||X==="HEAD"))throw new TypeError("Request with GET/HEAD method cannot have body");let Q=v.body?v.body:mQ(f)&&f.body!==null?e0(f):null;super(Q,{size:v.size||f.size||0});let Y=new F1(v.headers||f.headers||{});if(Q!==null&&!Y.has("Content-Type")){let K=MJ(Q,this);if(K)Y.set("Content-Type",K)}let w=mQ(f)?f.signal:null;if("signal"in v)w=v.signal;if(w!=null&&!SY(w))throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");let G=v.referrer==null?f.referrer:v.referrer;if(G==="")G="no-referrer";else if(G){let K=new URL(G);G=/^about:(\/\/)?client$/.test(K)?"client":K}else G=void 0;this[tv]={method:X,redirect:v.redirect||f.redirect||"follow",headers:Y,parsedURL:J,signal:w,referrer:G},this.follow=v.follow===void 0?f.follow===void 0?20:f.follow:v.follow,this.compress=v.compress===void 0?f.compress===void 0?!0:f.compress:v.compress,this.counter=v.counter||f.counter||0,this.agent=v.agent||f.agent,this.highWaterMark=v.highWaterMark||f.highWaterMark||16384,this.insecureHTTPParser=v.insecureHTTPParser||f.insecureHTTPParser||!1,this.referrerPolicy=v.referrerPolicy||f.referrerPolicy||""}get method(){return this[tv].method}get url(){return J7.format(this[tv].parsedURL)}get headers(){return this[tv].headers}get redirect(){return this[tv].redirect}get signal(){return this[tv].signal}get referrer(){if(this[tv].referrer==="no-referrer")return"";if(this[tv].referrer==="client")return"about:client";if(this[tv].referrer)return this[tv].referrer.toString();return}get referrerPolicy(){return this[tv].referrerPolicy}set referrerPolicy(f){this[tv].referrerPolicy=v7(f)}clone(){return new of(this)}get[Symbol.toStringTag](){return"Request"}};Object.defineProperties(of.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0},referrer:{enumerable:!0},referrerPolicy:{enumerable:!0}})});var FJ;var P7=rv(()=>{BJ();FJ=class FJ extends df{constructor(f,v="aborted"){super(f,v)}}});var sW={};d9(sW,{isRedirect:()=>lQ,fileFromSync:()=>ZY,fileFrom:()=>bY,default:()=>dW,blobFromSync:()=>yY,blobFrom:()=>TY,Response:()=>w1,Request:()=>of,Headers:()=>F1,FormData:()=>nf,File:()=>pf,FetchError:()=>V1,Blob:()=>o1,AbortError:()=>FJ});async function dW(f,v){return new Promise((J,X)=>{let Q=new of(f,v),{parsedURL:Y,options:w}=X7(Q);if(!pG.has(Y.protocol))throw new TypeError(`node-fetch cannot load ${f}. URL scheme "${Y.protocol.replace(/:$/,"")}" is not supported.`);if(Y.protocol==="data:"){let $=OY(Q.url),j=new w1($,{headers:{"Content-Type":$.typeFull}});J(j);return}let G=(Y.protocol==="https:"?G7.default:w7.default).request,{signal:K}=Q,D=null,H=()=>{let $=new FJ("The operation was aborted.");if(X($),Q.body&&Q.body instanceof L1.default.Readable)Q.body.destroy($);if(!D||!D.body)return;D.body.emit("error",$)};if(K&&K.aborted){H();return}let F=()=>{H(),h()},q=G(Y.toString(),w);if(K)K.addEventListener("abort",F);let h=()=>{if(q.abort(),K)K.removeEventListener("abort",F)};if(q.on("error",($)=>{X(new V1(`request to ${Q.url} failed, reason: ${$.message}`,"system",$)),h()}),nG(q,($)=>{if(D&&D.body)D.body.destroy($)}),process.version<"v14")q.on("socket",($)=>{let j;$.prependListener("end",()=>{j=$._eventsCount}),$.prependListener("close",(V)=>{if(D&&j<$._eventsCount&&!V){let N=new Error("Premature close");N.code="ERR_STREAM_PREMATURE_CLOSE",D.body.emit("error",N)}})});q.on("response",($)=>{q.setTimeout(0);let j=nY($.rawHeaders);if(lQ($.statusCode)){let k=j.get("Location"),_=null;try{_=k===null?null:new URL(k,Q.url)}catch{if(Q.redirect!=="manual"){X(new V1(`uri requested responds with an invalid redirect URL: ${k}`,"invalid-redirect")),h();return}}switch(Q.redirect){case"error":X(new V1(`uri requested responds with a redirect, redirect mode is set to error: ${Q.url}`,"no-redirect")),h();return;case"manual":break;case"follow":{if(_===null)break;if(Q.counter>=Q.follow){X(new V1(`maximum redirect reached at: ${Q.url}`,"max-redirect")),h();return}let T={headers:new F1(Q.headers),follow:Q.follow,counter:Q.counter+1,agent:Q.agent,compress:Q.compress,method:Q.method,body:e0(Q),signal:Q.signal,size:Q.size,referrer:Q.referrer,referrerPolicy:Q.referrerPolicy};if(!RY(Q.url,_)||!gY(Q.url,_))for(let c of["authorization","www-authenticate","cookie","cookie2"])T.headers.delete(c);if($.statusCode!==303&&Q.body&&v.body instanceof L1.default.Readable){X(new V1("Cannot follow redirect with body being a readable stream","unsupported-redirect")),h();return}if($.statusCode===303||($.statusCode===301||$.statusCode===302)&&Q.method==="POST")T.method="GET",T.body=void 0,T.headers.delete("content-length");let s=Q7(j);if(s)T.referrerPolicy=s;J(dW(new of(_,T))),h();return}default:return X(new TypeError(`Redirect option '${Q.redirect}' is not a valid value of RequestRedirect`))}}if(K)$.once("end",()=>{K.removeEventListener("abort",F)});let V=L1.pipeline($,new L1.PassThrough,(k)=>{if(k)X(k)});if(process.version<"v12.10")$.on("aborted",F);let N={url:Q.url,status:$.statusCode,statusText:$.statusMessage,headers:j,size:Q.size,counter:Q.counter,highWaterMark:Q.highWaterMark},I=j.get("Content-Encoding");if(!Q.compress||Q.method==="HEAD"||I===null||$.statusCode===204||$.statusCode===304){D=new w1(V,N),J(D);return}let L={flush:q0.default.Z_SYNC_FLUSH,finishFlush:q0.default.Z_SYNC_FLUSH};if(I==="gzip"||I==="x-gzip"){V=L1.pipeline(V,q0.default.createGunzip(L),(k)=>{if(k)X(k)}),D=new w1(V,N),J(D);return}if(I==="deflate"||I==="x-deflate"){let k=L1.pipeline($,new L1.PassThrough,(_)=>{if(_)X(_)});k.once("data",(_)=>{if((_[0]&15)===8)V=L1.pipeline(V,q0.default.createInflate(),(T)=>{if(T)X(T)});else V=L1.pipeline(V,q0.default.createInflateRaw(),(T)=>{if(T)X(T)});D=new w1(V,N),J(D)}),k.once("end",()=>{if(!D)D=new w1(V,N),J(D)});return}if(I==="br"){V=L1.pipeline(V,q0.default.createBrotliDecompress(),(k)=>{if(k)X(k)}),D=new w1(V,N),J(D);return}D=new w1(V,N),J(D)}),pY(q,Q).catch(X)})}function nG(f,v){let J=uQ.Buffer.from(`0\r
|
|
14
14
|
\r
|
|
15
|
-
`),X=!1,Q=!1,Y;f.on("response",(w)=>{let{headers:G}=w;X=G["transfer-encoding"]==="chunked"&&!G["content-length"]}),f.on("socket",(w)=>{let G=()=>{if(X&&!Q){let D=new Error("Premature close");D.code="ERR_STREAM_PREMATURE_CLOSE",v(D)}},K=(D)=>{if(Q=uQ.Buffer.compare(D.slice(-5),J)===0,!Q&&Y)Q=uQ.Buffer.compare(Y.slice(-3),J.slice(0,3))===0&&uQ.Buffer.compare(D.slice(-2),J.slice(3))===0;Y=D};w.prependListener("close",G),w.on("data",K),f.on("close",()=>{w.removeListener("close",G),w.removeListener("data",K)})})}var w7,G7,q0,L1,uQ,pG;var oW=rv(()=>{w7=M1(require("node:http")),G7=M1(require("node:https")),q0=M1(require("node:zlib")),L1=M1(require("node:stream")),uQ=require("node:buffer");VY();OJ();iY();qJ();Y7();lW();P7();nW();zJ();hJ();iW();cW();pG=new Set(["data:","http:","https:"])});var D7=fv(($H,H7)=>{(()=>{var f={52:(Q,Y)=>{Object.defineProperty(Y,"__esModule",{value:!0}),Y.ReportType=Y.ReportUrl=void 0,Y.ReportUrl="https://statistcs-hdpt.yy.com/reportGeneralStatistics";var w;(function(G){G.pluginOpenCount="f2c_plugin_open_count"})(w||(Y.ReportType=w={}))},248:(Q)=>{Q.exports=(oW(),C4(sW))},428:(Q,Y,w)=>{Object.defineProperty(Y,"__esModule",{value:!0}),Y.getGitUserInfo=K,Y.getIsGitRepository=D,Y.getUserInfoWithFallback=H;let G=w(646);function K(){let h={};try{let $=G.execSync("git config user.name",{encoding:"utf8"}).trim();if($)h.name=$;let j=G.execSync("git config user.email",{encoding:"utf8"}).trim();if(j)h.email=j}catch($){return h}return h}function D(){try{return G.execSync("git rev-parse --git-dir",{encoding:"utf8",stdio:"ignore"}),!0}catch(h){return!1}}function H(){if(D())try{let j=K(),V=j.email||j.name;if(V)return V}catch(j){}let h=F();if(h)return h;let $=q();if($)return $;return"f2c_匿名"}function F(){let h=["GIT_AUTHOR_EMAIL","GIT_COMMITTER_EMAIL","EMAIL","GIT_AUTHOR_NAME","GIT_COMMITTER_NAME","USER","USERNAME","LOGNAME"];for(let $ of h){let j=process.env[$];if(j&&j.trim())return j.trim()}return""}function q(){try{let h=G.execSync("whoami",{encoding:"utf8",timeout:5000}).trim();if(process.platform==="win32"&&h.includes("\\"))return h.split("\\").pop()||"";return h}catch(h){return""}}},646:(Q)=>{Q.exports=require("child_process")},680:function(Q,Y,w){var G=this&&this.__createBinding||(Object.create?function(h,$,j,V){if(V===void 0)V=j;var N=Object.getOwnPropertyDescriptor($,j);if(!N||("get"in N?!$.__esModule:N.writable||N.configurable))N={enumerable:!0,get:function(){return $[j]}};Object.defineProperty(h,V,N)}:function(h,$,j,V){if(V===void 0)V=j;h[V]=$[j]}),K=this&&this.__setModuleDefault||(Object.create?function(h,$){Object.defineProperty(h,"default",{enumerable:!0,value:$})}:function(h,$){h.default=$}),D=this&&this.__importStar||function(){var h=function($){return h=Object.getOwnPropertyNames||function(j){var V=[];for(var N in j)if(Object.prototype.hasOwnProperty.call(j,N))V[V.length]=N;return V},h($)};return function($){if($&&$.__esModule)return $;var j={};if($!=null){for(var V=h($),N=0;N<V.length;N++)if(V[N]!=="default")G(j,$,V[N])}return K(j,$),j}}();Object.defineProperty(Y,"__esModule",{value:!0}),Y.compatFetch=q;let H=null;async function F(){if(typeof global!=="undefined"&&global.fetch)return global.fetch;if(typeof globalThis.fetch!=="undefined")return globalThis.fetch;if(!H)try{H=await Promise.resolve().then(()=>D(w(248)))}catch(h){throw new Error("Neither native fetch nor node-fetch is available. Please install node-fetch or upgrade to Node.js 18+")}return H.default}async function q(h,$){return(await F())(h,$)}Y.default=q},782:(Q,Y)=>{Object.defineProperty(Y,"__esModule",{value:!0}),Y.createLogger=Y.Logger=Y.isHttp=Y.LogLevel=void 0;var w;(function(H){H[H.DEBUG=0]="DEBUG",H[H.INFO=1]="INFO",H[H.WARN=2]="WARN",H[H.ERROR=3]="ERROR"})(w||(Y.LogLevel=w={}));function G(){let H=process.argv.join(" ");return H.includes("streamable-http.js")||H.includes("streamable-http.ts")}Y.isHttp=G();class K{constructor(H,F=w.INFO){this.context=H,this.level=F}setLevel(H){this.level=H}log(...H){if(Y.isHttp)console.log(...H);else console.error(...H)}logWarn(...H){if(Y.isHttp)console.warn(...H);else console.error(...H)}debug(...H){if(this.level<=w.DEBUG)this.log(`[DEBUG] [${this.context}]`,...H)}info(...H){if(this.level<=w.INFO)this.log(`[INFO] [${this.context}]`,...H)}warn(...H){if(this.level<=w.WARN)this.logWarn(`[WARN] [${this.context}]`,...H)}error(...H){if(this.level<=w.ERROR)console.error(`[ERROR] [${this.context}]`,...H)}}Y.Logger=K;let D=(H,F=w.INFO)=>new K(H,F);Y.createLogger=D},799:(Q,Y)=>{Object.defineProperty(Y,"__esModule",{value:!0}),Y.detectIDE=w;function w(){try{let G=process.env,K=()=>{try{if(typeof globalThis!=="undefined"){if(globalThis.vscode||globalThis.__vscode_extension_context||globalThis.acquireVsCodeApi)return!0}}catch{}try{if(process&&process.env){if(process.env.VSCODE_EXTENSION_ID||process.env.VSCODE_EXTENSION_VERSION||process.env.npm_config_user_agent&&process.env.npm_config_user_agent.includes("vscode"))return!0}}catch{}try{if(process&&process.argv){let q=process.argv.join(" ");if(q.includes("extensionHost")||q.includes("vscode")||q.includes("code.exe"))return!0}if(process.title&&(process.title.includes("Code")||process.title.includes("vscode")||process.title.includes("extensionHost")))return!0}catch{}return!1},D=process.cwd().toLowerCase(),H="other";if([D.includes("codebuddy"),G.CODEBUDDY_VERSION!==void 0,G.CODEBUDDY_MODE!==void 0,process.title?.toLowerCase().includes("codebuddy"),typeof globalThis!=="undefined"&&globalThis.CODEBUDDY_CONTEXT!==void 0].some((q)=>q))H="codeBuddy";else if(G?.VSCODE_CWD?.toLowerCase().includes("trae")||D.includes("trae"))H="trae";else if(G?.IDE?.toLowerCase().includes("comate")||G?.VSCODE_CWD?.toLowerCase().includes("comate")||D.includes("comate"))H="comate";else if(G?.CURSOR_USER_DATA_DIR!==void 0||G?.VSCODE_CWD?.toLowerCase().includes("cursor")||D.includes("cursor"))H="cursor";else if(G?.VSCODE_CWD!==void 0||G?.VSCODE_PID!==void 0||G?.VSCODE_IPC_HOOK!==void 0||G?.VSCODE_IPC_HOOK_EXTHOST!==void 0||K())H="vscode";else if(G?.PATH?.includes("Microsoft VS Code")&&!D.includes("cursor")&&!D.includes("comate")&&!D.includes("codebuddy")&&!D.includes("trae"))H="vscode";return H}catch(G){return"other"}}},867:(Q,Y,w)=>{Object.defineProperty(Y,"__esModule",{value:!0}),Y.f2cDataReport=$,Y.reportMcpLoader=j;let G=w(680),K=w(428),D=w(782),H=w(52),F=w(799),q=D.createLogger("F2c-Report");function h(V){return(N,I)=>{let L=new AbortController;I=I||{},I.signal=L.signal;let k=setTimeout(()=>{clearTimeout(k),L.abort()},V);return G.compatFetch(H.ReportUrl,I)}}async function $(V,N,I,L){let k="",_=K.getGitUserInfo();k=_.name?_.name+"-"+_.email:_.email?_.email:"f2c_匿名";let T={...L,account:k,appid:1,dataType:V,dim1:k,dim3:N,value1:I};try{let c=await(await h(3000)(H.ReportUrl,{method:"POST",mode:"cors",credentials:"include",headers:{"Content-Type":"application/json;charset=utf-8"},body:JSON.stringify(T)})).json();if(c&&c.result!=200)q.log("上报失败",c.reason,c.result)}catch(s){q.error(s)}}async function j(){try{let V=F.detectIDE();return q.log("当前运行环境",V),$(H.ReportType.pluginOpenCount,"",1,{dim5:"f2c-mcp-"+V}),V}catch(V){}}}},v={};function J(Q){var Y=v[Q];if(Y!==void 0)return Y.exports;var w=v[Q]={exports:{}};return f[Q].call(w.exports,w,w.exports,J),w.exports}var X={};(()=>{var Q=X;Object.defineProperty(Q,"__esModule",{value:!0}),Q.ReportType=Q.reportMcpLoader=Q.f2cDataReport=void 0;var Y=J(867);Object.defineProperty(Q,"f2cDataReport",{enumerable:!0,get:function(){return Y.f2cDataReport}}),Object.defineProperty(Q,"reportMcpLoader",{enumerable:!0,get:function(){return Y.reportMcpLoader}});var w=J(52);Object.defineProperty(Q,"ReportType",{enumerable:!0,get:function(){return w.ReportType}})})(),H7.exports=X})()});_Q();var kP=60000;class WW{constructor(f){this._options=f,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.setNotificationHandler(N8,(v)=>{let J=this._requestHandlerAbortControllers.get(v.params.requestId);J===null||J===void 0||J.abort(v.params.reason)}),this.setNotificationHandler(S8,(v)=>{this._onprogress(v)}),this.setRequestHandler(L8,(v)=>({}))}_setupTimeout(f,v,J,X,Q=!1){this._timeoutInfo.set(f,{timeoutId:setTimeout(X,v),startTime:Date.now(),timeout:v,maxTotalTimeout:J,resetTimeoutOnProgress:Q,onTimeout:X})}_resetTimeout(f){let v=this._timeoutInfo.get(f);if(!v)return!1;let J=Date.now()-v.startTime;if(v.maxTotalTimeout&&J>=v.maxTotalTimeout)throw this._timeoutInfo.delete(f),new Tv(_v.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:v.maxTotalTimeout,totalElapsed:J});return clearTimeout(v.timeoutId),v.timeoutId=setTimeout(v.onTimeout,v.timeout),!0}_cleanupTimeout(f){let v=this._timeoutInfo.get(f);if(v)clearTimeout(v.timeoutId),this._timeoutInfo.delete(f)}async connect(f){var v,J,X;this._transport=f;let Q=(v=this.transport)===null||v===void 0?void 0:v.onclose;this._transport.onclose=()=>{Q===null||Q===void 0||Q(),this._onclose()};let Y=(J=this.transport)===null||J===void 0?void 0:J.onerror;this._transport.onerror=(G)=>{Y===null||Y===void 0||Y(G),this._onerror(G)};let w=(X=this._transport)===null||X===void 0?void 0:X.onmessage;this._transport.onmessage=(G,K)=>{if(w===null||w===void 0||w(G,K),dJ(G)||O6(G))this._onresponse(G);else if(h6(G))this._onrequest(G,K);else if(D6(G))this._onnotification(G);else this._onerror(new Error(`Unknown message type: ${JSON.stringify(G)}`))},await this._transport.start()}_onclose(){var f;let v=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(f=this.onclose)===null||f===void 0||f.call(this);let J=new Tv(_v.ConnectionClosed,"Connection closed");for(let X of v.values())X(J)}_onerror(f){var v;(v=this.onerror)===null||v===void 0||v.call(this,f)}_onnotification(f){var v;let J=(v=this._notificationHandlers.get(f.method))!==null&&v!==void 0?v:this.fallbackNotificationHandler;if(J===void 0)return;Promise.resolve().then(()=>J(f)).catch((X)=>this._onerror(new Error(`Uncaught error in notification handler: ${X}`)))}_onrequest(f,v){var J,X;let Q=(J=this._requestHandlers.get(f.method))!==null&&J!==void 0?J:this.fallbackRequestHandler,Y=this._transport;if(Q===void 0){Y===null||Y===void 0||Y.send({jsonrpc:"2.0",id:f.id,error:{code:_v.MethodNotFound,message:"Method not found"}}).catch((K)=>this._onerror(new Error(`Failed to send an error response: ${K}`)));return}let w=new AbortController;this._requestHandlerAbortControllers.set(f.id,w);let G={signal:w.signal,sessionId:Y===null||Y===void 0?void 0:Y.sessionId,_meta:(X=f.params)===null||X===void 0?void 0:X._meta,sendNotification:(K)=>this.notification(K,{relatedRequestId:f.id}),sendRequest:(K,D,H)=>this.request(K,D,{...H,relatedRequestId:f.id}),authInfo:v===null||v===void 0?void 0:v.authInfo,requestId:f.id,requestInfo:v===null||v===void 0?void 0:v.requestInfo};Promise.resolve().then(()=>Q(f,G)).then((K)=>{if(w.signal.aborted)return;return Y===null||Y===void 0?void 0:Y.send({result:K,jsonrpc:"2.0",id:f.id})},(K)=>{var D;if(w.signal.aborted)return;return Y===null||Y===void 0?void 0:Y.send({jsonrpc:"2.0",id:f.id,error:{code:Number.isSafeInteger(K.code)?K.code:_v.InternalError,message:(D=K.message)!==null&&D!==void 0?D:"Internal error"}})}).catch((K)=>this._onerror(new Error(`Failed to send response: ${K}`))).finally(()=>{this._requestHandlerAbortControllers.delete(f.id)})}_onprogress(f){let{progressToken:v,...J}=f.params,X=Number(v),Q=this._progressHandlers.get(X);if(!Q){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(f)}`));return}let Y=this._responseHandlers.get(X),w=this._timeoutInfo.get(X);if(w&&Y&&w.resetTimeoutOnProgress)try{this._resetTimeout(X)}catch(G){Y(G);return}Q(J)}_onresponse(f){let v=Number(f.id),J=this._responseHandlers.get(v);if(J===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(f)}`));return}if(this._responseHandlers.delete(v),this._progressHandlers.delete(v),this._cleanupTimeout(v),dJ(f))J(f);else{let X=new Tv(f.error.code,f.error.message,f.error.data);J(X)}}get transport(){return this._transport}async close(){var f;await((f=this._transport)===null||f===void 0?void 0:f.close())}request(f,v,J){let{relatedRequestId:X,resumptionToken:Q,onresumptiontoken:Y}=J!==null&&J!==void 0?J:{};return new Promise((w,G)=>{var K,D,H,F,q,h;if(!this._transport){G(new Error("Not connected"));return}if(((K=this._options)===null||K===void 0?void 0:K.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod(f.method);(D=J===null||J===void 0?void 0:J.signal)===null||D===void 0||D.throwIfAborted();let $=this._requestMessageId++,j={...f,jsonrpc:"2.0",id:$};if(J===null||J===void 0?void 0:J.onprogress)this._progressHandlers.set($,J.onprogress),j.params={...f.params,_meta:{...((H=f.params)===null||H===void 0?void 0:H._meta)||{},progressToken:$}};let V=(L)=>{var k;this._responseHandlers.delete($),this._progressHandlers.delete($),this._cleanupTimeout($),(k=this._transport)===null||k===void 0||k.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:$,reason:String(L)}},{relatedRequestId:X,resumptionToken:Q,onresumptiontoken:Y}).catch((_)=>this._onerror(new Error(`Failed to send cancellation: ${_}`))),G(L)};this._responseHandlers.set($,(L)=>{var k;if((k=J===null||J===void 0?void 0:J.signal)===null||k===void 0?void 0:k.aborted)return;if(L instanceof Error)return G(L);try{let _=v.parse(L.result);w(_)}catch(_){G(_)}}),(F=J===null||J===void 0?void 0:J.signal)===null||F===void 0||F.addEventListener("abort",()=>{var L;V((L=J===null||J===void 0?void 0:J.signal)===null||L===void 0?void 0:L.reason)});let N=(q=J===null||J===void 0?void 0:J.timeout)!==null&&q!==void 0?q:kP,I=()=>V(new Tv(_v.RequestTimeout,"Request timed out",{timeout:N}));this._setupTimeout($,N,J===null||J===void 0?void 0:J.maxTotalTimeout,I,(h=J===null||J===void 0?void 0:J.resetTimeoutOnProgress)!==null&&h!==void 0?h:!1),this._transport.send(j,{relatedRequestId:X,resumptionToken:Q,onresumptiontoken:Y}).catch((L)=>{this._cleanupTimeout($),G(L)})})}async notification(f,v){var J,X;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(f.method),((X=(J=this._options)===null||J===void 0?void 0:J.debouncedNotificationMethods)!==null&&X!==void 0?X:[]).includes(f.method)&&!f.params&&!(v===null||v===void 0?void 0:v.relatedRequestId)){if(this._pendingDebouncedNotifications.has(f.method))return;this._pendingDebouncedNotifications.add(f.method),Promise.resolve().then(()=>{var G;if(this._pendingDebouncedNotifications.delete(f.method),!this._transport)return;let K={...f,jsonrpc:"2.0"};(G=this._transport)===null||G===void 0||G.send(K,v).catch((D)=>this._onerror(D))});return}let w={...f,jsonrpc:"2.0"};await this._transport.send(w,v)}setRequestHandler(f,v){let J=f.shape.method.value;this.assertRequestHandlerCapability(J),this._requestHandlers.set(J,(X,Q)=>{return Promise.resolve(v(f.parse(X),Q))})}removeRequestHandler(f){this._requestHandlers.delete(f)}assertCanSetRequestHandler(f){if(this._requestHandlers.has(f))throw new Error(`A request handler for ${f} already exists, which would be overridden`)}setNotificationHandler(f,v){this._notificationHandlers.set(f.shape.method.value,(J)=>Promise.resolve(v(f.parse(J))))}removeNotificationHandler(f){this._notificationHandlers.delete(f)}}function S6(f,v){return Object.entries(v).reduce((J,[X,Q])=>{if(Q&&typeof Q==="object")J[X]=J[X]?{...J[X],...Q}:Q;else J[X]=Q;return J},{...f})}_Q();var g5=M1(R5());class RW extends WW{constructor(f,v){var J;super(v);this._serverInfo=f,this._capabilities=(J=v===null||v===void 0?void 0:v.capabilities)!==null&&J!==void 0?J:{},this._instructions=v===null||v===void 0?void 0:v.instructions,this.setRequestHandler(U8,(X)=>this._oninitialize(X)),this.setNotificationHandler(sJ,()=>{var X;return(X=this.oninitialized)===null||X===void 0?void 0:X.call(this)})}registerCapabilities(f){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=S6(this._capabilities,f)}assertCapabilityForMethod(f){var v,J,X;switch(f){case"sampling/createMessage":if(!((v=this._clientCapabilities)===null||v===void 0?void 0:v.sampling))throw new Error(`Client does not support sampling (required for ${f})`);break;case"elicitation/create":if(!((J=this._clientCapabilities)===null||J===void 0?void 0:J.elicitation))throw new Error(`Client does not support elicitation (required for ${f})`);break;case"roots/list":if(!((X=this._clientCapabilities)===null||X===void 0?void 0:X.roots))throw new Error(`Client does not support listing roots (required for ${f})`);break;case"ping":break}}assertNotificationCapability(f){switch(f){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${f})`);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 ${f})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${f})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${f})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(f){switch(f){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Server does not support sampling (required for ${f})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${f})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${f})`);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 ${f})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${f})`);break;case"ping":case"initialize":break}}async _oninitialize(f){let v=f.params.protocolVersion;return this._clientCapabilities=f.params.capabilities,this._clientVersion=f.params.clientInfo,{protocolVersion:G6.includes(v)?v:iJ,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"},E8)}async createMessage(f,v){return this.request({method:"sampling/createMessage",params:f},fW,v)}async elicitInput(f,v){let J=await this.request({method:"elicitation/create",params:f},QW,v);if(J.action==="accept"&&J.content)try{let X=new g5.default,Q=X.compile(f.requestedSchema);if(!Q(J.content))throw new Tv(_v.InvalidParams,`Elicitation response content does not match requested schema: ${X.errorsText(Q.errors)}`)}catch(X){if(X instanceof Tv)throw X;throw new Tv(_v.InternalError,`Error validating elicitation response: ${X}`)}return J}async listRoots(f,v){return this.request({method:"roots/list",params:f},JW,v)}async sendLoggingMessage(f){return this.notification({method:"notifications/message",params:f})}async sendResourceUpdated(f){return this.notification({method:"notifications/resources/updated",params:f})}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 k5=Symbol("Let zodToJsonSchema decide on which parser to use");var _5={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},I5=(f)=>typeof f==="string"?{..._5,name:f}:{..._5,...f};var C5=(f)=>{let v=I5(f),J=v.name!==void 0?[...v.basePath,v.definitionPath,v.name]:v.basePath;return{...v,currentPath:J,propertyPath:void 0,seen:new Map(Object.entries(v.definitions).map(([X,Q])=>[Q._def,{def:Q._def,path:[...v.basePath,v.definitionPath,X],jsonSchema:void 0}]))}};function gW(f,v,J,X){if(!X?.errorMessages)return;if(J)f.errorMessage={...f.errorMessage,[v]:J}}function qv(f,v,J,X,Q){f[v]=J,gW(f,v,X,Q)}Uf();function y5(){return{}}Uf();function T5(f,v){let J={type:"array"};if(f.type?._def&&f.type?._def?.typeName!==Z.ZodAny)J.items=Jv(f.type._def,{...v,currentPath:[...v.currentPath,"items"]});if(f.minLength)qv(J,"minItems",f.minLength.value,f.minLength.message,v);if(f.maxLength)qv(J,"maxItems",f.maxLength.value,f.maxLength.message,v);if(f.exactLength)qv(J,"minItems",f.exactLength.value,f.exactLength.message,v),qv(J,"maxItems",f.exactLength.value,f.exactLength.message,v);return J}function b5(f,v){let J={type:"integer",format:"int64"};if(!f.checks)return J;for(let X of f.checks)switch(X.kind){case"min":if(v.target==="jsonSchema7")if(X.inclusive)qv(J,"minimum",X.value,X.message,v);else qv(J,"exclusiveMinimum",X.value,X.message,v);else{if(!X.inclusive)J.exclusiveMinimum=!0;qv(J,"minimum",X.value,X.message,v)}break;case"max":if(v.target==="jsonSchema7")if(X.inclusive)qv(J,"maximum",X.value,X.message,v);else qv(J,"exclusiveMaximum",X.value,X.message,v);else{if(!X.inclusive)J.exclusiveMaximum=!0;qv(J,"maximum",X.value,X.message,v)}break;case"multipleOf":qv(J,"multipleOf",X.value,X.message,v);break}return J}function Z5(){return{type:"boolean"}}function JJ(f,v){return Jv(f.type._def,v)}var x5=(f,v)=>{return Jv(f.innerType._def,v)};function _W(f,v,J){let X=J??v.dateStrategy;if(Array.isArray(X))return{anyOf:X.map((Q,Y)=>_W(f,v,Q))};switch(X){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return BG(f,v)}}var BG=(f,v)=>{let J={type:"integer",format:"unix-time"};if(v.target==="openApi3")return J;for(let X of f.checks)switch(X.kind){case"min":qv(J,"minimum",X.value,X.message,v);break;case"max":qv(J,"maximum",X.value,X.message,v);break}return J};function l5(f,v){return{...Jv(f.innerType._def,v),default:f.defaultValue()}}function m5(f,v){return v.effectStrategy==="input"?Jv(f.schema._def,v):{}}function u5(f){return{type:"string",enum:Array.from(f.values)}}var KG=(f)=>{if("type"in f&&f.type==="string")return!1;return"allOf"in f};function c5(f,v){let J=[Jv(f.left._def,{...v,currentPath:[...v.currentPath,"allOf","0"]}),Jv(f.right._def,{...v,currentPath:[...v.currentPath,"allOf","1"]})].filter((Y)=>!!Y),X=v.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,Q=[];return J.forEach((Y)=>{if(KG(Y)){if(Q.push(...Y.allOf),Y.unevaluatedProperties===void 0)X=void 0}else{let w=Y;if("additionalProperties"in Y&&Y.additionalProperties===!1){let{additionalProperties:G,...K}=Y;w=K}else X=void 0;Q.push(w)}}),Q.length?{allOf:Q,...X}:void 0}function r5(f,v){let J=typeof f.value;if(J!=="bigint"&&J!=="number"&&J!=="boolean"&&J!=="string")return{type:Array.isArray(f.value)?"array":"object"};if(v.target==="openApi3")return{type:J==="bigint"?"integer":J,enum:[f.value]};return{type:J==="bigint"?"integer":J,const:f.value}}Uf();var kW=void 0,d1={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(kW===void 0)kW=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return kW},uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function WJ(f,v){let J={type:"string"};if(f.checks)for(let X of f.checks)switch(X.kind){case"min":qv(J,"minLength",typeof J.minLength==="number"?Math.max(J.minLength,X.value):X.value,X.message,v);break;case"max":qv(J,"maxLength",typeof J.maxLength==="number"?Math.min(J.maxLength,X.value):X.value,X.message,v);break;case"email":switch(v.emailStrategy){case"format:email":s1(J,"email",X.message,v);break;case"format:idn-email":s1(J,"idn-email",X.message,v);break;case"pattern:zod":H1(J,d1.email,X.message,v);break}break;case"url":s1(J,"uri",X.message,v);break;case"uuid":s1(J,"uuid",X.message,v);break;case"regex":H1(J,X.regex,X.message,v);break;case"cuid":H1(J,d1.cuid,X.message,v);break;case"cuid2":H1(J,d1.cuid2,X.message,v);break;case"startsWith":H1(J,RegExp(`^${IW(X.value,v)}`),X.message,v);break;case"endsWith":H1(J,RegExp(`${IW(X.value,v)}$`),X.message,v);break;case"datetime":s1(J,"date-time",X.message,v);break;case"date":s1(J,"date",X.message,v);break;case"time":s1(J,"time",X.message,v);break;case"duration":s1(J,"duration",X.message,v);break;case"length":qv(J,"minLength",typeof J.minLength==="number"?Math.max(J.minLength,X.value):X.value,X.message,v),qv(J,"maxLength",typeof J.maxLength==="number"?Math.min(J.maxLength,X.value):X.value,X.message,v);break;case"includes":{H1(J,RegExp(IW(X.value,v)),X.message,v);break}case"ip":{if(X.version!=="v6")s1(J,"ipv4",X.message,v);if(X.version!=="v4")s1(J,"ipv6",X.message,v);break}case"base64url":H1(J,d1.base64url,X.message,v);break;case"jwt":H1(J,d1.jwt,X.message,v);break;case"cidr":{if(X.version!=="v6")H1(J,d1.ipv4Cidr,X.message,v);if(X.version!=="v4")H1(J,d1.ipv6Cidr,X.message,v);break}case"emoji":H1(J,d1.emoji(),X.message,v);break;case"ulid":{H1(J,d1.ulid,X.message,v);break}case"base64":{switch(v.base64Strategy){case"format:binary":{s1(J,"binary",X.message,v);break}case"contentEncoding:base64":{qv(J,"contentEncoding","base64",X.message,v);break}case"pattern:zod":{H1(J,d1.base64,X.message,v);break}}break}case"nanoid":H1(J,d1.nanoid,X.message,v);case"toLowerCase":case"toUpperCase":case"trim":break;default:((Q)=>{})(X)}return J}function IW(f,v){return v.patternStrategy==="escape"?HG(f):f}var hG=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function HG(f){let v="";for(let J=0;J<f.length;J++){if(!hG.has(f[J]))v+="\\";v+=f[J]}return v}function s1(f,v,J,X){if(f.format||f.anyOf?.some((Q)=>Q.format)){if(!f.anyOf)f.anyOf=[];if(f.format){if(f.anyOf.push({format:f.format,...f.errorMessage&&X.errorMessages&&{errorMessage:{format:f.errorMessage.format}}}),delete f.format,f.errorMessage){if(delete f.errorMessage.format,Object.keys(f.errorMessage).length===0)delete f.errorMessage}}f.anyOf.push({format:v,...J&&X.errorMessages&&{errorMessage:{format:J}}})}else qv(f,"format",v,J,X)}function H1(f,v,J,X){if(f.pattern||f.allOf?.some((Q)=>Q.pattern)){if(!f.allOf)f.allOf=[];if(f.pattern){if(f.allOf.push({pattern:f.pattern,...f.errorMessage&&X.errorMessages&&{errorMessage:{pattern:f.errorMessage.pattern}}}),delete f.pattern,f.errorMessage){if(delete f.errorMessage.pattern,Object.keys(f.errorMessage).length===0)delete f.errorMessage}}f.allOf.push({pattern:a5(v,X),...J&&X.errorMessages&&{errorMessage:{pattern:J}}})}else qv(f,"pattern",a5(v,X),J,X)}function a5(f,v){if(!v.applyRegexFlags||!f.flags)return f.source;let J={i:f.flags.includes("i"),m:f.flags.includes("m"),s:f.flags.includes("s")},X=J.i?f.source.toLowerCase():f.source,Q="",Y=!1,w=!1,G=!1;for(let K=0;K<X.length;K++){if(Y){Q+=X[K],Y=!1;continue}if(J.i){if(w){if(X[K].match(/[a-z]/)){if(G)Q+=X[K],Q+=`${X[K-2]}-${X[K]}`.toUpperCase(),G=!1;else if(X[K+1]==="-"&&X[K+2]?.match(/[a-z]/))Q+=X[K],G=!0;else Q+=`${X[K]}${X[K].toUpperCase()}`;continue}}else if(X[K].match(/[a-z]/)){Q+=`[${X[K]}${X[K].toUpperCase()}]`;continue}}if(J.m){if(X[K]==="^"){Q+=`(^|(?<=[\r
|
|
15
|
+
`),X=!1,Q=!1,Y;f.on("response",(w)=>{let{headers:G}=w;X=G["transfer-encoding"]==="chunked"&&!G["content-length"]}),f.on("socket",(w)=>{let G=()=>{if(X&&!Q){let D=new Error("Premature close");D.code="ERR_STREAM_PREMATURE_CLOSE",v(D)}},K=(D)=>{if(Q=uQ.Buffer.compare(D.slice(-5),J)===0,!Q&&Y)Q=uQ.Buffer.compare(Y.slice(-3),J.slice(0,3))===0&&uQ.Buffer.compare(D.slice(-2),J.slice(3))===0;Y=D};w.prependListener("close",G),w.on("data",K),f.on("close",()=>{w.removeListener("close",G),w.removeListener("data",K)})})}var w7,G7,q0,L1,uQ,pG;var oW=rv(()=>{w7=M1(require("node:http")),G7=M1(require("node:https")),q0=M1(require("node:zlib")),L1=M1(require("node:stream")),uQ=require("node:buffer");VY();OJ();iY();qJ();Y7();lW();P7();nW();zJ();hJ();iW();cW();pG=new Set(["data:","http:","https:"])});var D7=fv(($H,H7)=>{(()=>{var f={52:(Q,Y)=>{Object.defineProperty(Y,"__esModule",{value:!0}),Y.ReportType=Y.ReportUrl=void 0,Y.ReportUrl="https://statistcs-hdpt.yy.com/reportGeneralStatistics";var w;(function(G){G.pluginOpenCount="f2c_plugin_open_count"})(w||(Y.ReportType=w={}))},248:(Q)=>{Q.exports=(oW(),C4(sW))},428:(Q,Y,w)=>{Object.defineProperty(Y,"__esModule",{value:!0}),Y.getGitUserInfo=K,Y.getIsGitRepository=D,Y.getUserInfoWithFallback=H;let G=w(646);function K(){let h={};try{let $=(0,G.execSync)("git config user.name",{encoding:"utf8"}).trim();if($)h.name=$;let j=(0,G.execSync)("git config user.email",{encoding:"utf8"}).trim();if(j)h.email=j}catch($){return h}return h}function D(){try{return(0,G.execSync)("git rev-parse --git-dir",{encoding:"utf8",stdio:"ignore"}),!0}catch(h){return!1}}function H(){if(D())try{let j=K(),V=j.email||j.name;if(V)return V}catch(j){}let h=F();if(h)return h;let $=q();if($)return $;return"f2c_匿名"}function F(){let h=["GIT_AUTHOR_EMAIL","GIT_COMMITTER_EMAIL","EMAIL","GIT_AUTHOR_NAME","GIT_COMMITTER_NAME","USER","USERNAME","LOGNAME"];for(let $ of h){let j=process.env[$];if(j&&j.trim())return j.trim()}return""}function q(){try{let h=(0,G.execSync)("whoami",{encoding:"utf8",timeout:5000}).trim();if(process.platform==="win32"&&h.includes("\\"))return h.split("\\").pop()||"";return h}catch(h){return""}}},646:(Q)=>{Q.exports=require("child_process")},680:function(Q,Y,w){var G=this&&this.__createBinding||(Object.create?function(h,$,j,V){if(V===void 0)V=j;var N=Object.getOwnPropertyDescriptor($,j);if(!N||("get"in N?!$.__esModule:N.writable||N.configurable))N={enumerable:!0,get:function(){return $[j]}};Object.defineProperty(h,V,N)}:function(h,$,j,V){if(V===void 0)V=j;h[V]=$[j]}),K=this&&this.__setModuleDefault||(Object.create?function(h,$){Object.defineProperty(h,"default",{enumerable:!0,value:$})}:function(h,$){h.default=$}),D=this&&this.__importStar||function(){var h=function($){return h=Object.getOwnPropertyNames||function(j){var V=[];for(var N in j)if(Object.prototype.hasOwnProperty.call(j,N))V[V.length]=N;return V},h($)};return function($){if($&&$.__esModule)return $;var j={};if($!=null){for(var V=h($),N=0;N<V.length;N++)if(V[N]!=="default")G(j,$,V[N])}return K(j,$),j}}();Object.defineProperty(Y,"__esModule",{value:!0}),Y.compatFetch=q;let H=null;async function F(){if(typeof global!=="undefined"&&global.fetch)return global.fetch;if(typeof globalThis.fetch!=="undefined")return globalThis.fetch;if(!H)try{H=await Promise.resolve().then(()=>D(w(248)))}catch(h){throw new Error("Neither native fetch nor node-fetch is available. Please install node-fetch or upgrade to Node.js 18+")}return H.default}async function q(h,$){return(await F())(h,$)}Y.default=q},782:(Q,Y)=>{Object.defineProperty(Y,"__esModule",{value:!0}),Y.createLogger=Y.Logger=Y.isHttp=Y.LogLevel=void 0;var w;(function(H){H[H.DEBUG=0]="DEBUG",H[H.INFO=1]="INFO",H[H.WARN=2]="WARN",H[H.ERROR=3]="ERROR"})(w||(Y.LogLevel=w={}));function G(){let H=process.argv.join(" ");return H.includes("streamable-http.js")||H.includes("streamable-http.ts")}Y.isHttp=G();class K{constructor(H,F=w.INFO){this.context=H,this.level=F}setLevel(H){this.level=H}log(...H){if(Y.isHttp)console.log(...H);else console.error(...H)}logWarn(...H){if(Y.isHttp)console.warn(...H);else console.error(...H)}debug(...H){if(this.level<=w.DEBUG)this.log(`[DEBUG] [${this.context}]`,...H)}info(...H){if(this.level<=w.INFO)this.log(`[INFO] [${this.context}]`,...H)}warn(...H){if(this.level<=w.WARN)this.logWarn(`[WARN] [${this.context}]`,...H)}error(...H){if(this.level<=w.ERROR)console.error(`[ERROR] [${this.context}]`,...H)}}Y.Logger=K;let D=(H,F=w.INFO)=>new K(H,F);Y.createLogger=D},799:(Q,Y)=>{Object.defineProperty(Y,"__esModule",{value:!0}),Y.detectIDE=w;function w(){try{let G=process.env,K=()=>{try{if(typeof globalThis!=="undefined"){if(globalThis.vscode||globalThis.__vscode_extension_context||globalThis.acquireVsCodeApi)return!0}}catch{}try{if(process&&process.env){if(process.env.VSCODE_EXTENSION_ID||process.env.VSCODE_EXTENSION_VERSION||process.env.npm_config_user_agent&&process.env.npm_config_user_agent.includes("vscode"))return!0}}catch{}try{if(process&&process.argv){let q=process.argv.join(" ");if(q.includes("extensionHost")||q.includes("vscode")||q.includes("code.exe"))return!0}if(process.title&&(process.title.includes("Code")||process.title.includes("vscode")||process.title.includes("extensionHost")))return!0}catch{}return!1},D=process.cwd().toLowerCase(),H="other";if([D.includes("codebuddy"),G.CODEBUDDY_VERSION!==void 0,G.CODEBUDDY_MODE!==void 0,process.title?.toLowerCase().includes("codebuddy"),typeof globalThis!=="undefined"&&globalThis.CODEBUDDY_CONTEXT!==void 0].some((q)=>q))H="codeBuddy";else if(G?.VSCODE_CWD?.toLowerCase().includes("trae")||D.includes("trae"))H="trae";else if(G?.IDE?.toLowerCase().includes("comate")||G?.VSCODE_CWD?.toLowerCase().includes("comate")||D.includes("comate"))H="comate";else if(G?.CURSOR_USER_DATA_DIR!==void 0||G?.VSCODE_CWD?.toLowerCase().includes("cursor")||D.includes("cursor"))H="cursor";else if(G?.VSCODE_CWD!==void 0||G?.VSCODE_PID!==void 0||G?.VSCODE_IPC_HOOK!==void 0||G?.VSCODE_IPC_HOOK_EXTHOST!==void 0||K())H="vscode";else if(G?.PATH?.includes("Microsoft VS Code")&&!D.includes("cursor")&&!D.includes("comate")&&!D.includes("codebuddy")&&!D.includes("trae"))H="vscode";return H}catch(G){return"other"}}},867:(Q,Y,w)=>{Object.defineProperty(Y,"__esModule",{value:!0}),Y.f2cDataReport=$,Y.reportMcpLoader=j;let G=w(680),K=w(428),D=w(782),H=w(52),F=w(799),q=(0,D.createLogger)("F2c-Report");function h(V){return(N,I)=>{let L=new AbortController;I=I||{},I.signal=L.signal;let k=setTimeout(()=>{clearTimeout(k),L.abort()},V);return(0,G.compatFetch)(H.ReportUrl,I)}}async function $(V,N,I,L){let k="",_=(0,K.getGitUserInfo)();k=_.name?_.name+"-"+_.email:_.email?_.email:"f2c_匿名";let T={...L,account:k,appid:1,dataType:V,dim1:k,dim3:N,value1:I};try{let c=await(await h(3000)(H.ReportUrl,{method:"POST",mode:"cors",credentials:"include",headers:{"Content-Type":"application/json;charset=utf-8"},body:JSON.stringify(T)})).json();if(c&&c.result!=200)q.log("上报失败",c.reason,c.result)}catch(s){q.error(s)}}async function j(){try{let V=(0,F.detectIDE)();return q.log("当前运行环境",V),$(H.ReportType.pluginOpenCount,"",1,{dim5:"f2c-mcp-"+V}),V}catch(V){}}}},v={};function J(Q){var Y=v[Q];if(Y!==void 0)return Y.exports;var w=v[Q]={exports:{}};return f[Q].call(w.exports,w,w.exports,J),w.exports}var X={};(()=>{var Q=X;Object.defineProperty(Q,"__esModule",{value:!0}),Q.ReportType=Q.reportMcpLoader=Q.f2cDataReport=void 0;var Y=J(867);Object.defineProperty(Q,"f2cDataReport",{enumerable:!0,get:function(){return Y.f2cDataReport}}),Object.defineProperty(Q,"reportMcpLoader",{enumerable:!0,get:function(){return Y.reportMcpLoader}});var w=J(52);Object.defineProperty(Q,"ReportType",{enumerable:!0,get:function(){return w.ReportType}})})(),H7.exports=X})()});_Q();var kP=60000;class WW{constructor(f){this._options=f,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.setNotificationHandler(N8,(v)=>{let J=this._requestHandlerAbortControllers.get(v.params.requestId);J===null||J===void 0||J.abort(v.params.reason)}),this.setNotificationHandler(S8,(v)=>{this._onprogress(v)}),this.setRequestHandler(L8,(v)=>({}))}_setupTimeout(f,v,J,X,Q=!1){this._timeoutInfo.set(f,{timeoutId:setTimeout(X,v),startTime:Date.now(),timeout:v,maxTotalTimeout:J,resetTimeoutOnProgress:Q,onTimeout:X})}_resetTimeout(f){let v=this._timeoutInfo.get(f);if(!v)return!1;let J=Date.now()-v.startTime;if(v.maxTotalTimeout&&J>=v.maxTotalTimeout)throw this._timeoutInfo.delete(f),new Tv(_v.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:v.maxTotalTimeout,totalElapsed:J});return clearTimeout(v.timeoutId),v.timeoutId=setTimeout(v.onTimeout,v.timeout),!0}_cleanupTimeout(f){let v=this._timeoutInfo.get(f);if(v)clearTimeout(v.timeoutId),this._timeoutInfo.delete(f)}async connect(f){var v,J,X;this._transport=f;let Q=(v=this.transport)===null||v===void 0?void 0:v.onclose;this._transport.onclose=()=>{Q===null||Q===void 0||Q(),this._onclose()};let Y=(J=this.transport)===null||J===void 0?void 0:J.onerror;this._transport.onerror=(G)=>{Y===null||Y===void 0||Y(G),this._onerror(G)};let w=(X=this._transport)===null||X===void 0?void 0:X.onmessage;this._transport.onmessage=(G,K)=>{if(w===null||w===void 0||w(G,K),dJ(G)||O6(G))this._onresponse(G);else if(h6(G))this._onrequest(G,K);else if(D6(G))this._onnotification(G);else this._onerror(new Error(`Unknown message type: ${JSON.stringify(G)}`))},await this._transport.start()}_onclose(){var f;let v=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(f=this.onclose)===null||f===void 0||f.call(this);let J=new Tv(_v.ConnectionClosed,"Connection closed");for(let X of v.values())X(J)}_onerror(f){var v;(v=this.onerror)===null||v===void 0||v.call(this,f)}_onnotification(f){var v;let J=(v=this._notificationHandlers.get(f.method))!==null&&v!==void 0?v:this.fallbackNotificationHandler;if(J===void 0)return;Promise.resolve().then(()=>J(f)).catch((X)=>this._onerror(new Error(`Uncaught error in notification handler: ${X}`)))}_onrequest(f,v){var J,X;let Q=(J=this._requestHandlers.get(f.method))!==null&&J!==void 0?J:this.fallbackRequestHandler,Y=this._transport;if(Q===void 0){Y===null||Y===void 0||Y.send({jsonrpc:"2.0",id:f.id,error:{code:_v.MethodNotFound,message:"Method not found"}}).catch((K)=>this._onerror(new Error(`Failed to send an error response: ${K}`)));return}let w=new AbortController;this._requestHandlerAbortControllers.set(f.id,w);let G={signal:w.signal,sessionId:Y===null||Y===void 0?void 0:Y.sessionId,_meta:(X=f.params)===null||X===void 0?void 0:X._meta,sendNotification:(K)=>this.notification(K,{relatedRequestId:f.id}),sendRequest:(K,D,H)=>this.request(K,D,{...H,relatedRequestId:f.id}),authInfo:v===null||v===void 0?void 0:v.authInfo,requestId:f.id,requestInfo:v===null||v===void 0?void 0:v.requestInfo};Promise.resolve().then(()=>Q(f,G)).then((K)=>{if(w.signal.aborted)return;return Y===null||Y===void 0?void 0:Y.send({result:K,jsonrpc:"2.0",id:f.id})},(K)=>{var D;if(w.signal.aborted)return;return Y===null||Y===void 0?void 0:Y.send({jsonrpc:"2.0",id:f.id,error:{code:Number.isSafeInteger(K.code)?K.code:_v.InternalError,message:(D=K.message)!==null&&D!==void 0?D:"Internal error"}})}).catch((K)=>this._onerror(new Error(`Failed to send response: ${K}`))).finally(()=>{this._requestHandlerAbortControllers.delete(f.id)})}_onprogress(f){let{progressToken:v,...J}=f.params,X=Number(v),Q=this._progressHandlers.get(X);if(!Q){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(f)}`));return}let Y=this._responseHandlers.get(X),w=this._timeoutInfo.get(X);if(w&&Y&&w.resetTimeoutOnProgress)try{this._resetTimeout(X)}catch(G){Y(G);return}Q(J)}_onresponse(f){let v=Number(f.id),J=this._responseHandlers.get(v);if(J===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(f)}`));return}if(this._responseHandlers.delete(v),this._progressHandlers.delete(v),this._cleanupTimeout(v),dJ(f))J(f);else{let X=new Tv(f.error.code,f.error.message,f.error.data);J(X)}}get transport(){return this._transport}async close(){var f;await((f=this._transport)===null||f===void 0?void 0:f.close())}request(f,v,J){let{relatedRequestId:X,resumptionToken:Q,onresumptiontoken:Y}=J!==null&&J!==void 0?J:{};return new Promise((w,G)=>{var K,D,H,F,q,h;if(!this._transport){G(new Error("Not connected"));return}if(((K=this._options)===null||K===void 0?void 0:K.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod(f.method);(D=J===null||J===void 0?void 0:J.signal)===null||D===void 0||D.throwIfAborted();let $=this._requestMessageId++,j={...f,jsonrpc:"2.0",id:$};if(J===null||J===void 0?void 0:J.onprogress)this._progressHandlers.set($,J.onprogress),j.params={...f.params,_meta:{...((H=f.params)===null||H===void 0?void 0:H._meta)||{},progressToken:$}};let V=(L)=>{var k;this._responseHandlers.delete($),this._progressHandlers.delete($),this._cleanupTimeout($),(k=this._transport)===null||k===void 0||k.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:$,reason:String(L)}},{relatedRequestId:X,resumptionToken:Q,onresumptiontoken:Y}).catch((_)=>this._onerror(new Error(`Failed to send cancellation: ${_}`))),G(L)};this._responseHandlers.set($,(L)=>{var k;if((k=J===null||J===void 0?void 0:J.signal)===null||k===void 0?void 0:k.aborted)return;if(L instanceof Error)return G(L);try{let _=v.parse(L.result);w(_)}catch(_){G(_)}}),(F=J===null||J===void 0?void 0:J.signal)===null||F===void 0||F.addEventListener("abort",()=>{var L;V((L=J===null||J===void 0?void 0:J.signal)===null||L===void 0?void 0:L.reason)});let N=(q=J===null||J===void 0?void 0:J.timeout)!==null&&q!==void 0?q:kP,I=()=>V(new Tv(_v.RequestTimeout,"Request timed out",{timeout:N}));this._setupTimeout($,N,J===null||J===void 0?void 0:J.maxTotalTimeout,I,(h=J===null||J===void 0?void 0:J.resetTimeoutOnProgress)!==null&&h!==void 0?h:!1),this._transport.send(j,{relatedRequestId:X,resumptionToken:Q,onresumptiontoken:Y}).catch((L)=>{this._cleanupTimeout($),G(L)})})}async notification(f,v){var J,X;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(f.method),((X=(J=this._options)===null||J===void 0?void 0:J.debouncedNotificationMethods)!==null&&X!==void 0?X:[]).includes(f.method)&&!f.params&&!(v===null||v===void 0?void 0:v.relatedRequestId)){if(this._pendingDebouncedNotifications.has(f.method))return;this._pendingDebouncedNotifications.add(f.method),Promise.resolve().then(()=>{var G;if(this._pendingDebouncedNotifications.delete(f.method),!this._transport)return;let K={...f,jsonrpc:"2.0"};(G=this._transport)===null||G===void 0||G.send(K,v).catch((D)=>this._onerror(D))});return}let w={...f,jsonrpc:"2.0"};await this._transport.send(w,v)}setRequestHandler(f,v){let J=f.shape.method.value;this.assertRequestHandlerCapability(J),this._requestHandlers.set(J,(X,Q)=>{return Promise.resolve(v(f.parse(X),Q))})}removeRequestHandler(f){this._requestHandlers.delete(f)}assertCanSetRequestHandler(f){if(this._requestHandlers.has(f))throw new Error(`A request handler for ${f} already exists, which would be overridden`)}setNotificationHandler(f,v){this._notificationHandlers.set(f.shape.method.value,(J)=>Promise.resolve(v(f.parse(J))))}removeNotificationHandler(f){this._notificationHandlers.delete(f)}}function S6(f,v){return Object.entries(v).reduce((J,[X,Q])=>{if(Q&&typeof Q==="object")J[X]=J[X]?{...J[X],...Q}:Q;else J[X]=Q;return J},{...f})}_Q();var g5=M1(R5());class RW extends WW{constructor(f,v){var J;super(v);this._serverInfo=f,this._capabilities=(J=v===null||v===void 0?void 0:v.capabilities)!==null&&J!==void 0?J:{},this._instructions=v===null||v===void 0?void 0:v.instructions,this.setRequestHandler(U8,(X)=>this._oninitialize(X)),this.setNotificationHandler(sJ,()=>{var X;return(X=this.oninitialized)===null||X===void 0?void 0:X.call(this)})}registerCapabilities(f){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=S6(this._capabilities,f)}assertCapabilityForMethod(f){var v,J,X;switch(f){case"sampling/createMessage":if(!((v=this._clientCapabilities)===null||v===void 0?void 0:v.sampling))throw new Error(`Client does not support sampling (required for ${f})`);break;case"elicitation/create":if(!((J=this._clientCapabilities)===null||J===void 0?void 0:J.elicitation))throw new Error(`Client does not support elicitation (required for ${f})`);break;case"roots/list":if(!((X=this._clientCapabilities)===null||X===void 0?void 0:X.roots))throw new Error(`Client does not support listing roots (required for ${f})`);break;case"ping":break}}assertNotificationCapability(f){switch(f){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${f})`);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 ${f})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${f})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${f})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(f){switch(f){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Server does not support sampling (required for ${f})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${f})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${f})`);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 ${f})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${f})`);break;case"ping":case"initialize":break}}async _oninitialize(f){let v=f.params.protocolVersion;return this._clientCapabilities=f.params.capabilities,this._clientVersion=f.params.clientInfo,{protocolVersion:G6.includes(v)?v:iJ,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"},E8)}async createMessage(f,v){return this.request({method:"sampling/createMessage",params:f},fW,v)}async elicitInput(f,v){let J=await this.request({method:"elicitation/create",params:f},QW,v);if(J.action==="accept"&&J.content)try{let X=new g5.default,Q=X.compile(f.requestedSchema);if(!Q(J.content))throw new Tv(_v.InvalidParams,`Elicitation response content does not match requested schema: ${X.errorsText(Q.errors)}`)}catch(X){if(X instanceof Tv)throw X;throw new Tv(_v.InternalError,`Error validating elicitation response: ${X}`)}return J}async listRoots(f,v){return this.request({method:"roots/list",params:f},JW,v)}async sendLoggingMessage(f){return this.notification({method:"notifications/message",params:f})}async sendResourceUpdated(f){return this.notification({method:"notifications/resources/updated",params:f})}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 k5=Symbol("Let zodToJsonSchema decide on which parser to use");var _5={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},I5=(f)=>typeof f==="string"?{..._5,name:f}:{..._5,...f};var C5=(f)=>{let v=I5(f),J=v.name!==void 0?[...v.basePath,v.definitionPath,v.name]:v.basePath;return{...v,currentPath:J,propertyPath:void 0,seen:new Map(Object.entries(v.definitions).map(([X,Q])=>[Q._def,{def:Q._def,path:[...v.basePath,v.definitionPath,X],jsonSchema:void 0}]))}};function gW(f,v,J,X){if(!X?.errorMessages)return;if(J)f.errorMessage={...f.errorMessage,[v]:J}}function qv(f,v,J,X,Q){f[v]=J,gW(f,v,X,Q)}Uf();function y5(){return{}}Uf();function T5(f,v){let J={type:"array"};if(f.type?._def&&f.type?._def?.typeName!==Z.ZodAny)J.items=Jv(f.type._def,{...v,currentPath:[...v.currentPath,"items"]});if(f.minLength)qv(J,"minItems",f.minLength.value,f.minLength.message,v);if(f.maxLength)qv(J,"maxItems",f.maxLength.value,f.maxLength.message,v);if(f.exactLength)qv(J,"minItems",f.exactLength.value,f.exactLength.message,v),qv(J,"maxItems",f.exactLength.value,f.exactLength.message,v);return J}function b5(f,v){let J={type:"integer",format:"int64"};if(!f.checks)return J;for(let X of f.checks)switch(X.kind){case"min":if(v.target==="jsonSchema7")if(X.inclusive)qv(J,"minimum",X.value,X.message,v);else qv(J,"exclusiveMinimum",X.value,X.message,v);else{if(!X.inclusive)J.exclusiveMinimum=!0;qv(J,"minimum",X.value,X.message,v)}break;case"max":if(v.target==="jsonSchema7")if(X.inclusive)qv(J,"maximum",X.value,X.message,v);else qv(J,"exclusiveMaximum",X.value,X.message,v);else{if(!X.inclusive)J.exclusiveMaximum=!0;qv(J,"maximum",X.value,X.message,v)}break;case"multipleOf":qv(J,"multipleOf",X.value,X.message,v);break}return J}function Z5(){return{type:"boolean"}}function JJ(f,v){return Jv(f.type._def,v)}var x5=(f,v)=>{return Jv(f.innerType._def,v)};function _W(f,v,J){let X=J??v.dateStrategy;if(Array.isArray(X))return{anyOf:X.map((Q,Y)=>_W(f,v,Q))};switch(X){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return BG(f,v)}}var BG=(f,v)=>{let J={type:"integer",format:"unix-time"};if(v.target==="openApi3")return J;for(let X of f.checks)switch(X.kind){case"min":qv(J,"minimum",X.value,X.message,v);break;case"max":qv(J,"maximum",X.value,X.message,v);break}return J};function l5(f,v){return{...Jv(f.innerType._def,v),default:f.defaultValue()}}function m5(f,v){return v.effectStrategy==="input"?Jv(f.schema._def,v):{}}function u5(f){return{type:"string",enum:Array.from(f.values)}}var KG=(f)=>{if("type"in f&&f.type==="string")return!1;return"allOf"in f};function c5(f,v){let J=[Jv(f.left._def,{...v,currentPath:[...v.currentPath,"allOf","0"]}),Jv(f.right._def,{...v,currentPath:[...v.currentPath,"allOf","1"]})].filter((Y)=>!!Y),X=v.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,Q=[];return J.forEach((Y)=>{if(KG(Y)){if(Q.push(...Y.allOf),Y.unevaluatedProperties===void 0)X=void 0}else{let w=Y;if("additionalProperties"in Y&&Y.additionalProperties===!1){let{additionalProperties:G,...K}=Y;w=K}else X=void 0;Q.push(w)}}),Q.length?{allOf:Q,...X}:void 0}function r5(f,v){let J=typeof f.value;if(J!=="bigint"&&J!=="number"&&J!=="boolean"&&J!=="string")return{type:Array.isArray(f.value)?"array":"object"};if(v.target==="openApi3")return{type:J==="bigint"?"integer":J,enum:[f.value]};return{type:J==="bigint"?"integer":J,const:f.value}}Uf();var kW=void 0,d1={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(kW===void 0)kW=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return kW},uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function WJ(f,v){let J={type:"string"};if(f.checks)for(let X of f.checks)switch(X.kind){case"min":qv(J,"minLength",typeof J.minLength==="number"?Math.max(J.minLength,X.value):X.value,X.message,v);break;case"max":qv(J,"maxLength",typeof J.maxLength==="number"?Math.min(J.maxLength,X.value):X.value,X.message,v);break;case"email":switch(v.emailStrategy){case"format:email":s1(J,"email",X.message,v);break;case"format:idn-email":s1(J,"idn-email",X.message,v);break;case"pattern:zod":H1(J,d1.email,X.message,v);break}break;case"url":s1(J,"uri",X.message,v);break;case"uuid":s1(J,"uuid",X.message,v);break;case"regex":H1(J,X.regex,X.message,v);break;case"cuid":H1(J,d1.cuid,X.message,v);break;case"cuid2":H1(J,d1.cuid2,X.message,v);break;case"startsWith":H1(J,RegExp(`^${IW(X.value,v)}`),X.message,v);break;case"endsWith":H1(J,RegExp(`${IW(X.value,v)}$`),X.message,v);break;case"datetime":s1(J,"date-time",X.message,v);break;case"date":s1(J,"date",X.message,v);break;case"time":s1(J,"time",X.message,v);break;case"duration":s1(J,"duration",X.message,v);break;case"length":qv(J,"minLength",typeof J.minLength==="number"?Math.max(J.minLength,X.value):X.value,X.message,v),qv(J,"maxLength",typeof J.maxLength==="number"?Math.min(J.maxLength,X.value):X.value,X.message,v);break;case"includes":{H1(J,RegExp(IW(X.value,v)),X.message,v);break}case"ip":{if(X.version!=="v6")s1(J,"ipv4",X.message,v);if(X.version!=="v4")s1(J,"ipv6",X.message,v);break}case"base64url":H1(J,d1.base64url,X.message,v);break;case"jwt":H1(J,d1.jwt,X.message,v);break;case"cidr":{if(X.version!=="v6")H1(J,d1.ipv4Cidr,X.message,v);if(X.version!=="v4")H1(J,d1.ipv6Cidr,X.message,v);break}case"emoji":H1(J,d1.emoji(),X.message,v);break;case"ulid":{H1(J,d1.ulid,X.message,v);break}case"base64":{switch(v.base64Strategy){case"format:binary":{s1(J,"binary",X.message,v);break}case"contentEncoding:base64":{qv(J,"contentEncoding","base64",X.message,v);break}case"pattern:zod":{H1(J,d1.base64,X.message,v);break}}break}case"nanoid":H1(J,d1.nanoid,X.message,v);case"toLowerCase":case"toUpperCase":case"trim":break;default:((Q)=>{})(X)}return J}function IW(f,v){return v.patternStrategy==="escape"?HG(f):f}var hG=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function HG(f){let v="";for(let J=0;J<f.length;J++){if(!hG.has(f[J]))v+="\\";v+=f[J]}return v}function s1(f,v,J,X){if(f.format||f.anyOf?.some((Q)=>Q.format)){if(!f.anyOf)f.anyOf=[];if(f.format){if(f.anyOf.push({format:f.format,...f.errorMessage&&X.errorMessages&&{errorMessage:{format:f.errorMessage.format}}}),delete f.format,f.errorMessage){if(delete f.errorMessage.format,Object.keys(f.errorMessage).length===0)delete f.errorMessage}}f.anyOf.push({format:v,...J&&X.errorMessages&&{errorMessage:{format:J}}})}else qv(f,"format",v,J,X)}function H1(f,v,J,X){if(f.pattern||f.allOf?.some((Q)=>Q.pattern)){if(!f.allOf)f.allOf=[];if(f.pattern){if(f.allOf.push({pattern:f.pattern,...f.errorMessage&&X.errorMessages&&{errorMessage:{pattern:f.errorMessage.pattern}}}),delete f.pattern,f.errorMessage){if(delete f.errorMessage.pattern,Object.keys(f.errorMessage).length===0)delete f.errorMessage}}f.allOf.push({pattern:a5(v,X),...J&&X.errorMessages&&{errorMessage:{pattern:J}}})}else qv(f,"pattern",a5(v,X),J,X)}function a5(f,v){if(!v.applyRegexFlags||!f.flags)return f.source;let J={i:f.flags.includes("i"),m:f.flags.includes("m"),s:f.flags.includes("s")},X=J.i?f.source.toLowerCase():f.source,Q="",Y=!1,w=!1,G=!1;for(let K=0;K<X.length;K++){if(Y){Q+=X[K],Y=!1;continue}if(J.i){if(w){if(X[K].match(/[a-z]/)){if(G)Q+=X[K],Q+=`${X[K-2]}-${X[K]}`.toUpperCase(),G=!1;else if(X[K+1]==="-"&&X[K+2]?.match(/[a-z]/))Q+=X[K],G=!0;else Q+=`${X[K]}${X[K].toUpperCase()}`;continue}}else if(X[K].match(/[a-z]/)){Q+=`[${X[K]}${X[K].toUpperCase()}]`;continue}}if(J.m){if(X[K]==="^"){Q+=`(^|(?<=[\r
|
|
16
16
|
]))`;continue}else if(X[K]==="$"){Q+=`($|(?=[\r
|
|
17
17
|
]))`;continue}}if(J.s&&X[K]==="."){Q+=w?`${X[K]}\r
|
|
18
18
|
`:`[${X[K]}\r
|
|
19
|
-
]`;continue}if(Q+=X[K],X[K]==="\\")Y=!0;else if(w&&X[K]==="]")w=!1;else if(!w&&X[K]==="[")w=!0}try{new RegExp(Q)}catch{return console.warn(`Could not convert regex pattern at ${v.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),f.source}return Q}function XJ(f,v){if(v.target==="openAi")console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");if(v.target==="openApi3"&&f.keyType?._def.typeName===Z.ZodEnum)return{type:"object",required:f.keyType._def.values,properties:f.keyType._def.values.reduce((X,Q)=>({...X,[Q]:Jv(f.valueType._def,{...v,currentPath:[...v.currentPath,"properties",Q]})??{}}),{}),additionalProperties:v.rejectedAdditionalProperties};let J={type:"object",additionalProperties:Jv(f.valueType._def,{...v,currentPath:[...v.currentPath,"additionalProperties"]})??v.allowedAdditionalProperties};if(v.target==="openApi3")return J;if(f.keyType?._def.typeName===Z.ZodString&&f.keyType._def.checks?.length){let{type:X,...Q}=WJ(f.keyType._def,v);return{...J,propertyNames:Q}}else if(f.keyType?._def.typeName===Z.ZodEnum)return{...J,propertyNames:{enum:f.keyType._def.values}};else if(f.keyType?._def.typeName===Z.ZodBranded&&f.keyType._def.type._def.typeName===Z.ZodString&&f.keyType._def.type._def.checks?.length){let{type:X,...Q}=JJ(f.keyType._def,v);return{...J,propertyNames:Q}}return J}function p5(f,v){if(v.mapStrategy==="record")return XJ(f,v);let J=Jv(f.keyType._def,{...v,currentPath:[...v.currentPath,"items","items","0"]})||{},X=Jv(f.valueType._def,{...v,currentPath:[...v.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[J,X],minItems:2,maxItems:2}}}function n5(f){let v=f.values,X=Object.keys(f.values).filter((Y)=>{return typeof v[v[Y]]!=="number"}).map((Y)=>v[Y]),Q=Array.from(new Set(X.map((Y)=>typeof Y)));return{type:Q.length===1?Q[0]==="string"?"string":"number":["string","number"],enum:X}}function i5(){return{not:{}}}function d5(f){return f.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var IQ={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function o5(f,v){if(v.target==="openApi3")return s5(f,v);let J=f.options instanceof Map?Array.from(f.options.values()):f.options;if(J.every((X)=>(X._def.typeName in IQ)&&(!X._def.checks||!X._def.checks.length))){let X=J.reduce((Q,Y)=>{let w=IQ[Y._def.typeName];return w&&!Q.includes(w)?[...Q,w]:Q},[]);return{type:X.length>1?X:X[0]}}else if(J.every((X)=>X._def.typeName==="ZodLiteral"&&!X.description)){let X=J.reduce((Q,Y)=>{let w=typeof Y._def.value;switch(w){case"string":case"number":case"boolean":return[...Q,w];case"bigint":return[...Q,"integer"];case"object":if(Y._def.value===null)return[...Q,"null"];case"symbol":case"undefined":case"function":default:return Q}},[]);if(X.length===J.length){let Q=X.filter((Y,w,G)=>G.indexOf(Y)===w);return{type:Q.length>1?Q:Q[0],enum:J.reduce((Y,w)=>{return Y.includes(w._def.value)?Y:[...Y,w._def.value]},[])}}}else if(J.every((X)=>X._def.typeName==="ZodEnum"))return{type:"string",enum:J.reduce((X,Q)=>[...X,...Q._def.values.filter((Y)=>!X.includes(Y))],[])};return s5(f,v)}var s5=(f,v)=>{let J=(f.options instanceof Map?Array.from(f.options.values()):f.options).map((X,Q)=>Jv(X._def,{...v,currentPath:[...v.currentPath,"anyOf",`${Q}`]})).filter((X)=>!!X&&(!v.strictUnions||typeof X==="object"&&Object.keys(X).length>0));return J.length?{anyOf:J}:void 0};function t5(f,v){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(f.innerType._def.typeName)&&(!f.innerType._def.checks||!f.innerType._def.checks.length)){if(v.target==="openApi3")return{type:IQ[f.innerType._def.typeName],nullable:!0};return{type:[IQ[f.innerType._def.typeName],"null"]}}if(v.target==="openApi3"){let X=Jv(f.innerType._def,{...v,currentPath:[...v.currentPath]});if(X&&"$ref"in X)return{allOf:[X],nullable:!0};return X&&{...X,nullable:!0}}let J=Jv(f.innerType._def,{...v,currentPath:[...v.currentPath,"anyOf","0"]});return J&&{anyOf:[J,{type:"null"}]}}function e5(f,v){let J={type:"number"};if(!f.checks)return J;for(let X of f.checks)switch(X.kind){case"int":J.type="integer",gW(J,"type",X.message,v);break;case"min":if(v.target==="jsonSchema7")if(X.inclusive)qv(J,"minimum",X.value,X.message,v);else qv(J,"exclusiveMinimum",X.value,X.message,v);else{if(!X.inclusive)J.exclusiveMinimum=!0;qv(J,"minimum",X.value,X.message,v)}break;case"max":if(v.target==="jsonSchema7")if(X.inclusive)qv(J,"maximum",X.value,X.message,v);else qv(J,"exclusiveMaximum",X.value,X.message,v);else{if(!X.inclusive)J.exclusiveMaximum=!0;qv(J,"maximum",X.value,X.message,v)}break;case"multipleOf":qv(J,"multipleOf",X.value,X.message,v);break}return J}Uf();function vY(f,v){let J=v.target==="openAi",X={type:"object",properties:{}},Q=[],Y=f.shape();for(let G in Y){let K=Y[G];if(K===void 0||K._def===void 0)continue;let D=$G(K);if(D&&J){if(K instanceof N1)K=K._def.innerType;if(!K.isNullable())K=K.nullable();D=!1}let H=Jv(K._def,{...v,currentPath:[...v.currentPath,"properties",G],propertyPath:[...v.currentPath,"properties",G]});if(H===void 0)continue;if(X.properties[G]=H,!D)Q.push(G)}if(Q.length)X.required=Q;let w=DG(f,v);if(w!==void 0)X.additionalProperties=w;return X}function DG(f,v){if(f.catchall._def.typeName!=="ZodNever")return Jv(f.catchall._def,{...v,currentPath:[...v.currentPath,"additionalProperties"]});switch(f.unknownKeys){case"passthrough":return v.allowedAdditionalProperties;case"strict":return v.rejectedAdditionalProperties;case"strip":return v.removeAdditionalStrategy==="strict"?v.allowedAdditionalProperties:v.rejectedAdditionalProperties}}function $G(f){try{return f.isOptional()}catch{return!0}}var fY=(f,v)=>{if(v.currentPath.toString()===v.propertyPath?.toString())return Jv(f.innerType._def,v);let J=Jv(f.innerType._def,{...v,currentPath:[...v.currentPath,"anyOf","1"]});return J?{anyOf:[{not:{}},J]}:{}};var QY=(f,v)=>{if(v.pipeStrategy==="input")return Jv(f.in._def,v);else if(v.pipeStrategy==="output")return Jv(f.out._def,v);let J=Jv(f.in._def,{...v,currentPath:[...v.currentPath,"allOf","0"]}),X=Jv(f.out._def,{...v,currentPath:[...v.currentPath,"allOf",J?"1":"0"]});return{allOf:[J,X].filter((Q)=>Q!==void 0)}};function JY(f,v){return Jv(f.type._def,v)}function WY(f,v){let X={type:"array",uniqueItems:!0,items:Jv(f.valueType._def,{...v,currentPath:[...v.currentPath,"items"]})};if(f.minSize)qv(X,"minItems",f.minSize.value,f.minSize.message,v);if(f.maxSize)qv(X,"maxItems",f.maxSize.value,f.maxSize.message,v);return X}function XY(f,v){if(f.rest)return{type:"array",minItems:f.items.length,items:f.items.map((J,X)=>Jv(J._def,{...v,currentPath:[...v.currentPath,"items",`${X}`]})).reduce((J,X)=>X===void 0?J:[...J,X],[]),additionalItems:Jv(f.rest._def,{...v,currentPath:[...v.currentPath,"additionalItems"]})};else return{type:"array",minItems:f.items.length,maxItems:f.items.length,items:f.items.map((J,X)=>Jv(J._def,{...v,currentPath:[...v.currentPath,"items",`${X}`]})).reduce((J,X)=>X===void 0?J:[...J,X],[])}}function YY(){return{not:{}}}function PY(){return{}}var wY=(f,v)=>{return Jv(f.innerType._def,v)};var GY=(f,v,J)=>{switch(v){case Z.ZodString:return WJ(f,J);case Z.ZodNumber:return e5(f,J);case Z.ZodObject:return vY(f,J);case Z.ZodBigInt:return b5(f,J);case Z.ZodBoolean:return Z5();case Z.ZodDate:return _W(f,J);case Z.ZodUndefined:return YY();case Z.ZodNull:return d5(J);case Z.ZodArray:return T5(f,J);case Z.ZodUnion:case Z.ZodDiscriminatedUnion:return o5(f,J);case Z.ZodIntersection:return c5(f,J);case Z.ZodTuple:return XY(f,J);case Z.ZodRecord:return XJ(f,J);case Z.ZodLiteral:return r5(f,J);case Z.ZodEnum:return u5(f);case Z.ZodNativeEnum:return n5(f);case Z.ZodNullable:return t5(f,J);case Z.ZodOptional:return fY(f,J);case Z.ZodMap:return p5(f,J);case Z.ZodSet:return WY(f,J);case Z.ZodLazy:return()=>f.getter()._def;case Z.ZodPromise:return JY(f,J);case Z.ZodNaN:case Z.ZodNever:return i5();case Z.ZodEffects:return m5(f,J);case Z.ZodAny:return y5();case Z.ZodUnknown:return PY();case Z.ZodDefault:return l5(f,J);case Z.ZodBranded:return JJ(f,J);case Z.ZodReadonly:return wY(f,J);case Z.ZodCatch:return x5(f,J);case Z.ZodPipeline:return QY(f,J);case Z.ZodFunction:case Z.ZodVoid:case Z.ZodSymbol:return;default:return((X)=>{return})(v)}};function Jv(f,v,J=!1){let X=v.seen.get(f);if(v.override){let G=v.override?.(f,v,X,J);if(G!==k5)return G}if(X&&!J){let G=MG(X,v);if(G!==void 0)return G}let Q={def:f,path:v.currentPath,jsonSchema:void 0};v.seen.set(f,Q);let Y=GY(f,f.typeName,v),w=typeof Y==="function"?Jv(Y(),v):Y;if(w)VG(f,v,w);if(v.postProcess){let G=v.postProcess(w,f,v);return Q.jsonSchema=w,G}return Q.jsonSchema=w,w}var MG=(f,v)=>{switch(v.$refStrategy){case"root":return{$ref:f.path.join("/")};case"relative":return{$ref:OG(v.currentPath,f.path)};case"none":case"seen":{if(f.path.length<v.currentPath.length&&f.path.every((J,X)=>v.currentPath[X]===J))return console.warn(`Recursive reference detected at ${v.currentPath.join("/")}! Defaulting to any`),{};return v.$refStrategy==="seen"?{}:void 0}}},OG=(f,v)=>{let J=0;for(;J<f.length&&J<v.length;J++)if(f[J]!==v[J])break;return[(f.length-J).toString(),...v.slice(J)].join("/")},VG=(f,v,J)=>{if(f.description){if(J.description=f.description,v.markdownDescription)J.markdownDescription=f.description}return J};var YJ=(f,v)=>{let J=C5(v),X=typeof v==="object"&&v.definitions?Object.entries(v.definitions).reduce((K,[D,H])=>({...K,[D]:Jv(H._def,{...J,currentPath:[...J.basePath,J.definitionPath,D]},!0)??{}}),{}):void 0,Q=typeof v==="string"?v:v?.nameStrategy==="title"?void 0:v?.name,Y=Jv(f._def,Q===void 0?J:{...J,currentPath:[...J.basePath,J.definitionPath,Q]},!1)??{},w=typeof v==="object"&&v.name!==void 0&&v.nameStrategy==="title"?v.name:void 0;if(w!==void 0)Y.title=w;let G=Q===void 0?X?{...Y,[J.definitionPath]:X}:Y:{$ref:[...J.$refStrategy==="relative"?[]:J.basePath,J.definitionPath,Q].join("/"),[J.definitionPath]:{...X,[Q]:Y}};if(J.target==="jsonSchema7")G.$schema="http://json-schema.org/draft-07/schema#";else if(J.target==="jsonSchema2019-09"||J.target==="openAi")G.$schema="https://json-schema.org/draft/2019-09/schema#";if(J.target==="openAi"&&(("anyOf"in G)||("oneOf"in G)||("allOf"in G)||("type"in G)&&Array.isArray(G.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return G};Uf();_Q();Uf();var CW;(function(f){f.Completable="McpCompletable"})(CW||(CW={}));class CQ extends wv{_parse(f){let{ctx:v}=this._processInputParams(f),J=v.data;return this._def.type._parse({data:J,path:v.path,parent:v})}unwrap(){return this._def.type}}CQ.create=(f,v)=>{return new CQ({type:f,typeName:CW.Completable,complete:v.complete,...qG(v)})};function qG(f){if(!f)return{};let{errorMap:v,invalid_type_error:J,required_error:X,description:Q}=f;if(v&&(J||X))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(v)return{errorMap:v,description:Q};return{errorMap:(w,G)=>{var K,D;let{message:H}=f;if(w.code==="invalid_enum_value")return{message:H!==null&&H!==void 0?H:G.defaultError};if(typeof G.data==="undefined")return{message:(K=H!==null&&H!==void 0?H:X)!==null&&K!==void 0?K:G.defaultError};if(w.code!=="invalid_type")return{message:G.defaultError};return{message:(D=H!==null&&H!==void 0?H:J)!==null&&D!==void 0?D:G.defaultError}},description:Q}}class yW{constructor(f,v){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new RW(f,v)}async connect(f){return await this.server.connect(f)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(T8.shape.method.value),this.server.assertCanSetRequestHandler(b8.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(T8,()=>({tools:Object.entries(this._registeredTools).filter(([,f])=>f.enabled).map(([f,v])=>{let J={name:f,title:v.title,description:v.description,inputSchema:v.inputSchema?YJ(v.inputSchema,{strictUnions:!0}):FG,annotations:v.annotations};if(v.outputSchema)J.outputSchema=YJ(v.outputSchema,{strictUnions:!0});return J})})),this.server.setRequestHandler(b8,async(f,v)=>{let J=this._registeredTools[f.params.name];if(!J)throw new Tv(_v.InvalidParams,`Tool ${f.params.name} not found`);if(!J.enabled)throw new Tv(_v.InvalidParams,`Tool ${f.params.name} disabled`);let X;if(J.inputSchema){let Q=await J.inputSchema.safeParseAsync(f.params.arguments);if(!Q.success)throw new Tv(_v.InvalidParams,`Invalid arguments for tool ${f.params.name}: ${Q.error.message}`);let Y=Q.data,w=J.callback;try{X=await Promise.resolve(w(Y,v))}catch(G){X={content:[{type:"text",text:G instanceof Error?G.message:String(G)}],isError:!0}}}else{let Q=J.callback;try{X=await Promise.resolve(Q(v))}catch(Y){X={content:[{type:"text",text:Y instanceof Error?Y.message:String(Y)}],isError:!0}}}if(J.outputSchema&&!X.isError){if(!X.structuredContent)throw new Tv(_v.InvalidParams,`Tool ${f.params.name} has an output schema but no structured content was provided`);let Q=await J.outputSchema.safeParseAsync(X.structuredContent);if(!Q.success)throw new Tv(_v.InvalidParams,`Invalid structured content for tool ${f.params.name}: ${Q.error.message}`)}return X}),this._toolHandlersInitialized=!0}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(Z8.shape.method.value),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Z8,async(f)=>{switch(f.params.ref.type){case"ref/prompt":return this.handlePromptCompletion(f,f.params.ref);case"ref/resource":return this.handleResourceCompletion(f,f.params.ref);default:throw new Tv(_v.InvalidParams,`Invalid completion reference: ${f.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion(f,v){let J=this._registeredPrompts[v.name];if(!J)throw new Tv(_v.InvalidParams,`Prompt ${v.name} not found`);if(!J.enabled)throw new Tv(_v.InvalidParams,`Prompt ${v.name} disabled`);if(!J.argsSchema)return PJ;let X=J.argsSchema.shape[f.params.argument.name];if(!(X instanceof CQ))return PJ;let Y=await X._def.complete(f.params.argument.value,f.params.context);return BY(Y)}async handleResourceCompletion(f,v){let J=Object.values(this._registeredResourceTemplates).find((Y)=>Y.resourceTemplate.uriTemplate.toString()===v.uri);if(!J){if(this._registeredResources[v.uri])return PJ;throw new Tv(_v.InvalidParams,`Resource template ${f.params.ref.uri} not found`)}let X=J.resourceTemplate.completeCallback(f.params.argument.name);if(!X)return PJ;let Q=await X(f.params.argument.value,f.params.context);return BY(Q)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(_8.shape.method.value),this.server.assertCanSetRequestHandler(k8.shape.method.value),this.server.assertCanSetRequestHandler(I8.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(_8,async(f,v)=>{let J=Object.entries(this._registeredResources).filter(([Q,Y])=>Y.enabled).map(([Q,Y])=>({uri:Q,name:Y.name,...Y.metadata})),X=[];for(let Q of Object.values(this._registeredResourceTemplates)){if(!Q.resourceTemplate.listCallback)continue;let Y=await Q.resourceTemplate.listCallback(v);for(let w of Y.resources)X.push({...Q.metadata,...w})}return{resources:[...J,...X]}}),this.server.setRequestHandler(k8,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([v,J])=>({name:v,uriTemplate:J.resourceTemplate.uriTemplate.toString(),...J.metadata}))}}),this.server.setRequestHandler(I8,async(f,v)=>{let J=new URL(f.params.uri),X=this._registeredResources[J.toString()];if(X){if(!X.enabled)throw new Tv(_v.InvalidParams,`Resource ${J} disabled`);return X.readCallback(J,v)}for(let Q of Object.values(this._registeredResourceTemplates)){let Y=Q.resourceTemplate.uriTemplate.match(J.toString());if(Y)return Q.readCallback(J,Y,v)}throw new Tv(_v.InvalidParams,`Resource ${J} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler(C8.shape.method.value),this.server.assertCanSetRequestHandler(y8.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(C8,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,f])=>f.enabled).map(([f,v])=>{return{name:f,title:v.title,description:v.description,arguments:v.argsSchema?AG(v.argsSchema):void 0}})})),this.server.setRequestHandler(y8,async(f,v)=>{let J=this._registeredPrompts[f.params.name];if(!J)throw new Tv(_v.InvalidParams,`Prompt ${f.params.name} not found`);if(!J.enabled)throw new Tv(_v.InvalidParams,`Prompt ${f.params.name} disabled`);if(J.argsSchema){let X=await J.argsSchema.safeParseAsync(f.params.arguments);if(!X.success)throw new Tv(_v.InvalidParams,`Invalid arguments for prompt ${f.params.name}: ${X.error.message}`);let Q=X.data,Y=J.callback;return await Promise.resolve(Y(Q,v))}else{let X=J.callback;return await Promise.resolve(X(v))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0}resource(f,v,...J){let X;if(typeof J[0]==="object")X=J.shift();let Q=J[0];if(typeof v==="string"){if(this._registeredResources[v])throw new Error(`Resource ${v} is already registered`);let Y=this._createRegisteredResource(f,void 0,v,X,Q);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),Y}else{if(this._registeredResourceTemplates[f])throw new Error(`Resource template ${f} is already registered`);let Y=this._createRegisteredResourceTemplate(f,void 0,v,X,Q);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),Y}}registerResource(f,v,J,X){if(typeof v==="string"){if(this._registeredResources[v])throw new Error(`Resource ${v} is already registered`);let Q=this._createRegisteredResource(f,J.title,v,J,X);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),Q}else{if(this._registeredResourceTemplates[f])throw new Error(`Resource template ${f} is already registered`);let Q=this._createRegisteredResourceTemplate(f,J.title,v,J,X);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),Q}}_createRegisteredResource(f,v,J,X,Q){let Y={name:f,title:v,metadata:X,readCallback:Q,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({uri:null}),update:(w)=>{if(typeof w.uri!=="undefined"&&w.uri!==J){if(delete this._registeredResources[J],w.uri)this._registeredResources[w.uri]=Y}if(typeof w.name!=="undefined")Y.name=w.name;if(typeof w.title!=="undefined")Y.title=w.title;if(typeof w.metadata!=="undefined")Y.metadata=w.metadata;if(typeof w.callback!=="undefined")Y.readCallback=w.callback;if(typeof w.enabled!=="undefined")Y.enabled=w.enabled;this.sendResourceListChanged()}};return this._registeredResources[J]=Y,Y}_createRegisteredResourceTemplate(f,v,J,X,Q){let Y={resourceTemplate:J,title:v,metadata:X,readCallback:Q,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({name:null}),update:(w)=>{if(typeof w.name!=="undefined"&&w.name!==f){if(delete this._registeredResourceTemplates[f],w.name)this._registeredResourceTemplates[w.name]=Y}if(typeof w.title!=="undefined")Y.title=w.title;if(typeof w.template!=="undefined")Y.resourceTemplate=w.template;if(typeof w.metadata!=="undefined")Y.metadata=w.metadata;if(typeof w.callback!=="undefined")Y.readCallback=w.callback;if(typeof w.enabled!=="undefined")Y.enabled=w.enabled;this.sendResourceListChanged()}};return this._registeredResourceTemplates[f]=Y,Y}_createRegisteredPrompt(f,v,J,X,Q){let Y={title:v,description:J,argsSchema:X===void 0?void 0:B.object(X),callback:Q,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({name:null}),update:(w)=>{if(typeof w.name!=="undefined"&&w.name!==f){if(delete this._registeredPrompts[f],w.name)this._registeredPrompts[w.name]=Y}if(typeof w.title!=="undefined")Y.title=w.title;if(typeof w.description!=="undefined")Y.description=w.description;if(typeof w.argsSchema!=="undefined")Y.argsSchema=B.object(w.argsSchema);if(typeof w.callback!=="undefined")Y.callback=w.callback;if(typeof w.enabled!=="undefined")Y.enabled=w.enabled;this.sendPromptListChanged()}};return this._registeredPrompts[f]=Y,Y}_createRegisteredTool(f,v,J,X,Q,Y,w){let G={title:v,description:J,inputSchema:X===void 0?void 0:B.object(X),outputSchema:Q===void 0?void 0:B.object(Q),annotations:Y,callback:w,enabled:!0,disable:()=>G.update({enabled:!1}),enable:()=>G.update({enabled:!0}),remove:()=>G.update({name:null}),update:(K)=>{if(typeof K.name!=="undefined"&&K.name!==f){if(delete this._registeredTools[f],K.name)this._registeredTools[K.name]=G}if(typeof K.title!=="undefined")G.title=K.title;if(typeof K.description!=="undefined")G.description=K.description;if(typeof K.paramsSchema!=="undefined")G.inputSchema=B.object(K.paramsSchema);if(typeof K.callback!=="undefined")G.callback=K.callback;if(typeof K.annotations!=="undefined")G.annotations=K.annotations;if(typeof K.enabled!=="undefined")G.enabled=K.enabled;this.sendToolListChanged()}};return this._registeredTools[f]=G,this.setToolRequestHandlers(),this.sendToolListChanged(),G}tool(f,...v){if(this._registeredTools[f])throw new Error(`Tool ${f} is already registered`);let J,X,Q,Y;if(typeof v[0]==="string")J=v.shift();if(v.length>1){let G=v[0];if(zY(G)){if(X=v.shift(),v.length>1&&typeof v[0]==="object"&&v[0]!==null&&!zY(v[0]))Y=v.shift()}else if(typeof G==="object"&&G!==null)Y=v.shift()}let w=v[0];return this._createRegisteredTool(f,void 0,J,X,Q,Y,w)}registerTool(f,v,J){if(this._registeredTools[f])throw new Error(`Tool ${f} is already registered`);let{title:X,description:Q,inputSchema:Y,outputSchema:w,annotations:G}=v;return this._createRegisteredTool(f,X,Q,Y,w,G,J)}prompt(f,...v){if(this._registeredPrompts[f])throw new Error(`Prompt ${f} is already registered`);let J;if(typeof v[0]==="string")J=v.shift();let X;if(v.length>1)X=v.shift();let Q=v[0],Y=this._createRegisteredPrompt(f,void 0,J,X,Q);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),Y}registerPrompt(f,v,J){if(this._registeredPrompts[f])throw new Error(`Prompt ${f} is already registered`);let{title:X,description:Q,argsSchema:Y}=v,w=this._createRegisteredPrompt(f,X,Q,Y,J);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),w}isConnected(){return this.server.transport!==void 0}sendResourceListChanged(){if(this.isConnected())this.server.sendResourceListChanged()}sendToolListChanged(){if(this.isConnected())this.server.sendToolListChanged()}sendPromptListChanged(){if(this.isConnected())this.server.sendPromptListChanged()}}var FG={type:"object",properties:{}};function zY(f){if(typeof f!=="object"||f===null)return!1;return Object.keys(f).length===0||Object.values(f).some(jG)}function jG(f){return f!==null&&typeof f==="object"&&"parse"in f&&typeof f.parse==="function"&&"safeParse"in f&&typeof f.safeParse==="function"}function AG(f){return Object.entries(f.shape).map(([v,J])=>({name:v,description:J.description,required:!J.isOptional()}))}function BY(f){return{completion:{values:f.slice(0,100),total:f.length,hasMore:f.length>100}}}var PJ={completion:{values:[],hasMore:!1}};wJ();var $Y=(f)=>{};var MY=(f)=>{$Y(f)};wJ();var tW=null;async function iG(){if(typeof global!=="undefined"&&global.fetch)return global.fetch;if(typeof globalThis.fetch!=="undefined")return globalThis.fetch;if(!tW)try{tW=await Promise.resolve().then(() => (oW(),sW))}catch(f){throw new Error("Neither native fetch nor node-fetch is available. Please install node-fetch or upgrade to Node.js 18+")}return tW.default}async function dG(f,v){return(await iG())(f,v)}var fQ=dG;$0();var eW=x1("F2cApi",1);class z7{f2cHost="https://f2c-figma-api-test.yy.com/api";async nodeToCode(f){let v={fileKey:f.fileKey,nodeIds:f.ids,personal_token:f.personalToken||Lf.personalToken,option:{cssFramework:"inlinecss",imgFormat:f.imgFormat||"png",scaleSize:f.scaleSize||2},format:"files"};if(f.format==="react-cssmodules")v.option.cssFramework="cssmodules";else if(f.format==="react-tailwind")v.option.cssFramework="tailwindcss";let J=this.opToUrl(`${this.f2cHost}/nodes`,v);return this.fetch(J,"json",f.ideInfo||"other")}async fetch(f,v="json",J){eW.debug("fetch",f,Lf.personalToken);try{let X={method:"GET",headers:{"F2c-Api-Platform":`mcp-${J}`}};eW.debug("fetch",f);let Q=await fQ(f,X);if(!Q.ok)throw new Error(`HTTP error! status: ${Q.status}`);return v==="text"?await Q.text():await Q.json()}catch(X){throw eW.error("HTTP error",X),X}}opToUrl(f,v={}){if(Object.keys(v).length===0)return f;let J=new URL(f);for(let[X,Q]of Object.entries(v))if(typeof Q==="object"&&Q!==null)for(let[Y,w]of Object.entries(Q))J.searchParams.append(`${X}[${Y}]`,w);else J.searchParams.append(X,Q);return J.toString()}}var B7=new z7;wJ();$0();var sG=x1("FigmaRestApi");class K7{figmaHost="https://api.figma.com/v1";async files(f){let v;if(f.ids)v=this.opToUrl(`${this.figmaHost}/files/${f.fileKey}/nodes`,f);else v=this.opToUrl(`${this.figmaHost}/files/${f.fileKey}`,f);return this.fetch(v)}async images(f){let v=this.opToUrl(`${this.figmaHost}/images/${f.fileKey}`,f);return this.fetch(v)}async imageFills(f){let v=this.opToUrl(`${this.figmaHost}/files/${f.fileKey}/images`,f);return this.fetch(v)}async meta(f){let v=this.opToUrl(`${this.figmaHost}/files/${f.fileKey}/meta`,f);return this.fetch(v)}async fetch(f,v="json"){try{let J={method:"GET",headers:{"X-FIGMA-TOKEN":Lf.personalToken}},X=await fQ(f,J);if(!X.ok)throw new Error(`HTTP error! status: ${X.status}`);return v==="text"?await X.text():await X.json()}catch(J){throw sG.error("HTTP error",J),J}}opToUrl(f,v={},J=["fileKey","personalToken"]){if(Object.keys(v).length===0)return f;if(v.personalToken)Lf.personalToken=v.personalToken;let X=new URL(f);for(let[Q,Y]of Object.entries(v))if(!J.includes(Q))X.searchParams.append(Q,Y);return X.toString()}}var h7=new K7;$0();var O7=M1(D7());Uf();var cQ=M1(require("fs")),tf=M1(require("path")),v9=M1(require("fs/promises"));$0();var e1=x1("Downloader");class $7{op;assetsPath="";savePath="";setup(f){if(this.op=f,this.op.localPath)this.assetsPath=tf.default.join(this.op.localPath,"assets"),this.savePath=this.op.localPath}async downloadImage(f,v){let{imgFormat:J}=this.op,X=this.assetsPath;try{if(!cQ.default.existsSync(X))cQ.default.mkdirSync(X,{recursive:!0});let Q=`${v}.${J}`,Y=tf.default.join(X,Q),w=await fQ(f);if(!w.ok)throw new Error(`下载失败: ${w.status} ${w.statusText}`);let G=await w.arrayBuffer();return cQ.default.writeFileSync(Y,new Uint8Array(G)),tf.default.join(tf.default.basename(X),Q).replace(/\\/g,"/")}catch(Q){throw e1.error("图片下载错误:",Q),Q}}async downLoadImageAndReplaceContent(f){try{let v=/https:\/\/figma-alpha-api\.s3\.us-west-2\.amazonaws\.com\/images\/[a-f0-9-]+/g,J=f.match(v);if(!J)return f;let X=[...new Set(J)],Q=new Map;await Promise.all(X.map(async(w)=>{let G=tf.default.basename(w),K=await this.downloadImage(w,G);Q.set(w,K)}));let Y=f;for(let[w,G]of Q.entries()){let K=new RegExp(w.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");Y=Y.replace(K,G)}return Y}catch(v){throw e1.error("内容处理错误:",v),v}}async checkLocalAndDownload(f){if(!this.op.localPath)return;await Promise.all(f.map(async(v)=>{v.content=await this.downLoadImageAndReplaceContent(v.content)}));for(let v of f)try{let J=await this.saveContentToFile(v.content,v.path);e1.debug(`Successfully saved: ${J}`)}catch(J){e1.error(`Failed to save file ${v.path}:`,J)}}async ensureDirectoryExists(f){if(!cQ.default.existsSync(f))e1.debug(`Creating directory: ${f}`),await v9.default.mkdir(f,{recursive:!0})}async saveContentToFile(f,v){try{let J=tf.default.join(this.savePath,v),X=tf.default.dirname(J);if(e1.debug(`Full path: ${J}, directory: ${X}`),await this.ensureDirectoryExists(X),v.endsWith(".html"))e1.debug("Wrapping content with HTML template"),f=this.wrapHtmlContent(f);return e1.debug(`Writing ${f.length} bytes to file`),await v9.default.writeFile(J,f),e1.info(`File saved: ${J}`),J}catch(J){throw e1.error("File save error:",v,J),J}}wrapHtmlContent(f){return e1.debug("Wrapping content with HTML template"),`<!DOCTYPE html>
|
|
19
|
+
]`;continue}if(Q+=X[K],X[K]==="\\")Y=!0;else if(w&&X[K]==="]")w=!1;else if(!w&&X[K]==="[")w=!0}try{new RegExp(Q)}catch{return console.warn(`Could not convert regex pattern at ${v.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),f.source}return Q}function XJ(f,v){if(v.target==="openAi")console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");if(v.target==="openApi3"&&f.keyType?._def.typeName===Z.ZodEnum)return{type:"object",required:f.keyType._def.values,properties:f.keyType._def.values.reduce((X,Q)=>({...X,[Q]:Jv(f.valueType._def,{...v,currentPath:[...v.currentPath,"properties",Q]})??{}}),{}),additionalProperties:v.rejectedAdditionalProperties};let J={type:"object",additionalProperties:Jv(f.valueType._def,{...v,currentPath:[...v.currentPath,"additionalProperties"]})??v.allowedAdditionalProperties};if(v.target==="openApi3")return J;if(f.keyType?._def.typeName===Z.ZodString&&f.keyType._def.checks?.length){let{type:X,...Q}=WJ(f.keyType._def,v);return{...J,propertyNames:Q}}else if(f.keyType?._def.typeName===Z.ZodEnum)return{...J,propertyNames:{enum:f.keyType._def.values}};else if(f.keyType?._def.typeName===Z.ZodBranded&&f.keyType._def.type._def.typeName===Z.ZodString&&f.keyType._def.type._def.checks?.length){let{type:X,...Q}=JJ(f.keyType._def,v);return{...J,propertyNames:Q}}return J}function p5(f,v){if(v.mapStrategy==="record")return XJ(f,v);let J=Jv(f.keyType._def,{...v,currentPath:[...v.currentPath,"items","items","0"]})||{},X=Jv(f.valueType._def,{...v,currentPath:[...v.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[J,X],minItems:2,maxItems:2}}}function n5(f){let v=f.values,X=Object.keys(f.values).filter((Y)=>{return typeof v[v[Y]]!=="number"}).map((Y)=>v[Y]),Q=Array.from(new Set(X.map((Y)=>typeof Y)));return{type:Q.length===1?Q[0]==="string"?"string":"number":["string","number"],enum:X}}function i5(){return{not:{}}}function d5(f){return f.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var IQ={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function o5(f,v){if(v.target==="openApi3")return s5(f,v);let J=f.options instanceof Map?Array.from(f.options.values()):f.options;if(J.every((X)=>(X._def.typeName in IQ)&&(!X._def.checks||!X._def.checks.length))){let X=J.reduce((Q,Y)=>{let w=IQ[Y._def.typeName];return w&&!Q.includes(w)?[...Q,w]:Q},[]);return{type:X.length>1?X:X[0]}}else if(J.every((X)=>X._def.typeName==="ZodLiteral"&&!X.description)){let X=J.reduce((Q,Y)=>{let w=typeof Y._def.value;switch(w){case"string":case"number":case"boolean":return[...Q,w];case"bigint":return[...Q,"integer"];case"object":if(Y._def.value===null)return[...Q,"null"];case"symbol":case"undefined":case"function":default:return Q}},[]);if(X.length===J.length){let Q=X.filter((Y,w,G)=>G.indexOf(Y)===w);return{type:Q.length>1?Q:Q[0],enum:J.reduce((Y,w)=>{return Y.includes(w._def.value)?Y:[...Y,w._def.value]},[])}}}else if(J.every((X)=>X._def.typeName==="ZodEnum"))return{type:"string",enum:J.reduce((X,Q)=>[...X,...Q._def.values.filter((Y)=>!X.includes(Y))],[])};return s5(f,v)}var s5=(f,v)=>{let J=(f.options instanceof Map?Array.from(f.options.values()):f.options).map((X,Q)=>Jv(X._def,{...v,currentPath:[...v.currentPath,"anyOf",`${Q}`]})).filter((X)=>!!X&&(!v.strictUnions||typeof X==="object"&&Object.keys(X).length>0));return J.length?{anyOf:J}:void 0};function t5(f,v){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(f.innerType._def.typeName)&&(!f.innerType._def.checks||!f.innerType._def.checks.length)){if(v.target==="openApi3")return{type:IQ[f.innerType._def.typeName],nullable:!0};return{type:[IQ[f.innerType._def.typeName],"null"]}}if(v.target==="openApi3"){let X=Jv(f.innerType._def,{...v,currentPath:[...v.currentPath]});if(X&&"$ref"in X)return{allOf:[X],nullable:!0};return X&&{...X,nullable:!0}}let J=Jv(f.innerType._def,{...v,currentPath:[...v.currentPath,"anyOf","0"]});return J&&{anyOf:[J,{type:"null"}]}}function e5(f,v){let J={type:"number"};if(!f.checks)return J;for(let X of f.checks)switch(X.kind){case"int":J.type="integer",gW(J,"type",X.message,v);break;case"min":if(v.target==="jsonSchema7")if(X.inclusive)qv(J,"minimum",X.value,X.message,v);else qv(J,"exclusiveMinimum",X.value,X.message,v);else{if(!X.inclusive)J.exclusiveMinimum=!0;qv(J,"minimum",X.value,X.message,v)}break;case"max":if(v.target==="jsonSchema7")if(X.inclusive)qv(J,"maximum",X.value,X.message,v);else qv(J,"exclusiveMaximum",X.value,X.message,v);else{if(!X.inclusive)J.exclusiveMaximum=!0;qv(J,"maximum",X.value,X.message,v)}break;case"multipleOf":qv(J,"multipleOf",X.value,X.message,v);break}return J}Uf();function vY(f,v){let J=v.target==="openAi",X={type:"object",properties:{}},Q=[],Y=f.shape();for(let G in Y){let K=Y[G];if(K===void 0||K._def===void 0)continue;let D=$G(K);if(D&&J){if(K instanceof N1)K=K._def.innerType;if(!K.isNullable())K=K.nullable();D=!1}let H=Jv(K._def,{...v,currentPath:[...v.currentPath,"properties",G],propertyPath:[...v.currentPath,"properties",G]});if(H===void 0)continue;if(X.properties[G]=H,!D)Q.push(G)}if(Q.length)X.required=Q;let w=DG(f,v);if(w!==void 0)X.additionalProperties=w;return X}function DG(f,v){if(f.catchall._def.typeName!=="ZodNever")return Jv(f.catchall._def,{...v,currentPath:[...v.currentPath,"additionalProperties"]});switch(f.unknownKeys){case"passthrough":return v.allowedAdditionalProperties;case"strict":return v.rejectedAdditionalProperties;case"strip":return v.removeAdditionalStrategy==="strict"?v.allowedAdditionalProperties:v.rejectedAdditionalProperties}}function $G(f){try{return f.isOptional()}catch{return!0}}var fY=(f,v)=>{if(v.currentPath.toString()===v.propertyPath?.toString())return Jv(f.innerType._def,v);let J=Jv(f.innerType._def,{...v,currentPath:[...v.currentPath,"anyOf","1"]});return J?{anyOf:[{not:{}},J]}:{}};var QY=(f,v)=>{if(v.pipeStrategy==="input")return Jv(f.in._def,v);else if(v.pipeStrategy==="output")return Jv(f.out._def,v);let J=Jv(f.in._def,{...v,currentPath:[...v.currentPath,"allOf","0"]}),X=Jv(f.out._def,{...v,currentPath:[...v.currentPath,"allOf",J?"1":"0"]});return{allOf:[J,X].filter((Q)=>Q!==void 0)}};function JY(f,v){return Jv(f.type._def,v)}function WY(f,v){let X={type:"array",uniqueItems:!0,items:Jv(f.valueType._def,{...v,currentPath:[...v.currentPath,"items"]})};if(f.minSize)qv(X,"minItems",f.minSize.value,f.minSize.message,v);if(f.maxSize)qv(X,"maxItems",f.maxSize.value,f.maxSize.message,v);return X}function XY(f,v){if(f.rest)return{type:"array",minItems:f.items.length,items:f.items.map((J,X)=>Jv(J._def,{...v,currentPath:[...v.currentPath,"items",`${X}`]})).reduce((J,X)=>X===void 0?J:[...J,X],[]),additionalItems:Jv(f.rest._def,{...v,currentPath:[...v.currentPath,"additionalItems"]})};else return{type:"array",minItems:f.items.length,maxItems:f.items.length,items:f.items.map((J,X)=>Jv(J._def,{...v,currentPath:[...v.currentPath,"items",`${X}`]})).reduce((J,X)=>X===void 0?J:[...J,X],[])}}function YY(){return{not:{}}}function PY(){return{}}var wY=(f,v)=>{return Jv(f.innerType._def,v)};var GY=(f,v,J)=>{switch(v){case Z.ZodString:return WJ(f,J);case Z.ZodNumber:return e5(f,J);case Z.ZodObject:return vY(f,J);case Z.ZodBigInt:return b5(f,J);case Z.ZodBoolean:return Z5();case Z.ZodDate:return _W(f,J);case Z.ZodUndefined:return YY();case Z.ZodNull:return d5(J);case Z.ZodArray:return T5(f,J);case Z.ZodUnion:case Z.ZodDiscriminatedUnion:return o5(f,J);case Z.ZodIntersection:return c5(f,J);case Z.ZodTuple:return XY(f,J);case Z.ZodRecord:return XJ(f,J);case Z.ZodLiteral:return r5(f,J);case Z.ZodEnum:return u5(f);case Z.ZodNativeEnum:return n5(f);case Z.ZodNullable:return t5(f,J);case Z.ZodOptional:return fY(f,J);case Z.ZodMap:return p5(f,J);case Z.ZodSet:return WY(f,J);case Z.ZodLazy:return()=>f.getter()._def;case Z.ZodPromise:return JY(f,J);case Z.ZodNaN:case Z.ZodNever:return i5();case Z.ZodEffects:return m5(f,J);case Z.ZodAny:return y5();case Z.ZodUnknown:return PY();case Z.ZodDefault:return l5(f,J);case Z.ZodBranded:return JJ(f,J);case Z.ZodReadonly:return wY(f,J);case Z.ZodCatch:return x5(f,J);case Z.ZodPipeline:return QY(f,J);case Z.ZodFunction:case Z.ZodVoid:case Z.ZodSymbol:return;default:return((X)=>{return})(v)}};function Jv(f,v,J=!1){let X=v.seen.get(f);if(v.override){let G=v.override?.(f,v,X,J);if(G!==k5)return G}if(X&&!J){let G=MG(X,v);if(G!==void 0)return G}let Q={def:f,path:v.currentPath,jsonSchema:void 0};v.seen.set(f,Q);let Y=GY(f,f.typeName,v),w=typeof Y==="function"?Jv(Y(),v):Y;if(w)VG(f,v,w);if(v.postProcess){let G=v.postProcess(w,f,v);return Q.jsonSchema=w,G}return Q.jsonSchema=w,w}var MG=(f,v)=>{switch(v.$refStrategy){case"root":return{$ref:f.path.join("/")};case"relative":return{$ref:OG(v.currentPath,f.path)};case"none":case"seen":{if(f.path.length<v.currentPath.length&&f.path.every((J,X)=>v.currentPath[X]===J))return console.warn(`Recursive reference detected at ${v.currentPath.join("/")}! Defaulting to any`),{};return v.$refStrategy==="seen"?{}:void 0}}},OG=(f,v)=>{let J=0;for(;J<f.length&&J<v.length;J++)if(f[J]!==v[J])break;return[(f.length-J).toString(),...v.slice(J)].join("/")},VG=(f,v,J)=>{if(f.description){if(J.description=f.description,v.markdownDescription)J.markdownDescription=f.description}return J};var YJ=(f,v)=>{let J=C5(v),X=typeof v==="object"&&v.definitions?Object.entries(v.definitions).reduce((K,[D,H])=>({...K,[D]:Jv(H._def,{...J,currentPath:[...J.basePath,J.definitionPath,D]},!0)??{}}),{}):void 0,Q=typeof v==="string"?v:v?.nameStrategy==="title"?void 0:v?.name,Y=Jv(f._def,Q===void 0?J:{...J,currentPath:[...J.basePath,J.definitionPath,Q]},!1)??{},w=typeof v==="object"&&v.name!==void 0&&v.nameStrategy==="title"?v.name:void 0;if(w!==void 0)Y.title=w;let G=Q===void 0?X?{...Y,[J.definitionPath]:X}:Y:{$ref:[...J.$refStrategy==="relative"?[]:J.basePath,J.definitionPath,Q].join("/"),[J.definitionPath]:{...X,[Q]:Y}};if(J.target==="jsonSchema7")G.$schema="http://json-schema.org/draft-07/schema#";else if(J.target==="jsonSchema2019-09"||J.target==="openAi")G.$schema="https://json-schema.org/draft/2019-09/schema#";if(J.target==="openAi"&&(("anyOf"in G)||("oneOf"in G)||("allOf"in G)||("type"in G)&&Array.isArray(G.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return G};Uf();_Q();Uf();var CW;(function(f){f.Completable="McpCompletable"})(CW||(CW={}));class CQ extends wv{_parse(f){let{ctx:v}=this._processInputParams(f),J=v.data;return this._def.type._parse({data:J,path:v.path,parent:v})}unwrap(){return this._def.type}}CQ.create=(f,v)=>{return new CQ({type:f,typeName:CW.Completable,complete:v.complete,...qG(v)})};function qG(f){if(!f)return{};let{errorMap:v,invalid_type_error:J,required_error:X,description:Q}=f;if(v&&(J||X))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(v)return{errorMap:v,description:Q};return{errorMap:(w,G)=>{var K,D;let{message:H}=f;if(w.code==="invalid_enum_value")return{message:H!==null&&H!==void 0?H:G.defaultError};if(typeof G.data==="undefined")return{message:(K=H!==null&&H!==void 0?H:X)!==null&&K!==void 0?K:G.defaultError};if(w.code!=="invalid_type")return{message:G.defaultError};return{message:(D=H!==null&&H!==void 0?H:J)!==null&&D!==void 0?D:G.defaultError}},description:Q}}class yW{constructor(f,v){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new RW(f,v)}async connect(f){return await this.server.connect(f)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(T8.shape.method.value),this.server.assertCanSetRequestHandler(b8.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(T8,()=>({tools:Object.entries(this._registeredTools).filter(([,f])=>f.enabled).map(([f,v])=>{let J={name:f,title:v.title,description:v.description,inputSchema:v.inputSchema?YJ(v.inputSchema,{strictUnions:!0}):FG,annotations:v.annotations};if(v.outputSchema)J.outputSchema=YJ(v.outputSchema,{strictUnions:!0});return J})})),this.server.setRequestHandler(b8,async(f,v)=>{let J=this._registeredTools[f.params.name];if(!J)throw new Tv(_v.InvalidParams,`Tool ${f.params.name} not found`);if(!J.enabled)throw new Tv(_v.InvalidParams,`Tool ${f.params.name} disabled`);let X;if(J.inputSchema){let Q=await J.inputSchema.safeParseAsync(f.params.arguments);if(!Q.success)throw new Tv(_v.InvalidParams,`Invalid arguments for tool ${f.params.name}: ${Q.error.message}`);let Y=Q.data,w=J.callback;try{X=await Promise.resolve(w(Y,v))}catch(G){X={content:[{type:"text",text:G instanceof Error?G.message:String(G)}],isError:!0}}}else{let Q=J.callback;try{X=await Promise.resolve(Q(v))}catch(Y){X={content:[{type:"text",text:Y instanceof Error?Y.message:String(Y)}],isError:!0}}}if(J.outputSchema&&!X.isError){if(!X.structuredContent)throw new Tv(_v.InvalidParams,`Tool ${f.params.name} has an output schema but no structured content was provided`);let Q=await J.outputSchema.safeParseAsync(X.structuredContent);if(!Q.success)throw new Tv(_v.InvalidParams,`Invalid structured content for tool ${f.params.name}: ${Q.error.message}`)}return X}),this._toolHandlersInitialized=!0}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(Z8.shape.method.value),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Z8,async(f)=>{switch(f.params.ref.type){case"ref/prompt":return this.handlePromptCompletion(f,f.params.ref);case"ref/resource":return this.handleResourceCompletion(f,f.params.ref);default:throw new Tv(_v.InvalidParams,`Invalid completion reference: ${f.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion(f,v){let J=this._registeredPrompts[v.name];if(!J)throw new Tv(_v.InvalidParams,`Prompt ${v.name} not found`);if(!J.enabled)throw new Tv(_v.InvalidParams,`Prompt ${v.name} disabled`);if(!J.argsSchema)return PJ;let X=J.argsSchema.shape[f.params.argument.name];if(!(X instanceof CQ))return PJ;let Y=await X._def.complete(f.params.argument.value,f.params.context);return BY(Y)}async handleResourceCompletion(f,v){let J=Object.values(this._registeredResourceTemplates).find((Y)=>Y.resourceTemplate.uriTemplate.toString()===v.uri);if(!J){if(this._registeredResources[v.uri])return PJ;throw new Tv(_v.InvalidParams,`Resource template ${f.params.ref.uri} not found`)}let X=J.resourceTemplate.completeCallback(f.params.argument.name);if(!X)return PJ;let Q=await X(f.params.argument.value,f.params.context);return BY(Q)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(_8.shape.method.value),this.server.assertCanSetRequestHandler(k8.shape.method.value),this.server.assertCanSetRequestHandler(I8.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(_8,async(f,v)=>{let J=Object.entries(this._registeredResources).filter(([Q,Y])=>Y.enabled).map(([Q,Y])=>({uri:Q,name:Y.name,...Y.metadata})),X=[];for(let Q of Object.values(this._registeredResourceTemplates)){if(!Q.resourceTemplate.listCallback)continue;let Y=await Q.resourceTemplate.listCallback(v);for(let w of Y.resources)X.push({...Q.metadata,...w})}return{resources:[...J,...X]}}),this.server.setRequestHandler(k8,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([v,J])=>({name:v,uriTemplate:J.resourceTemplate.uriTemplate.toString(),...J.metadata}))}}),this.server.setRequestHandler(I8,async(f,v)=>{let J=new URL(f.params.uri),X=this._registeredResources[J.toString()];if(X){if(!X.enabled)throw new Tv(_v.InvalidParams,`Resource ${J} disabled`);return X.readCallback(J,v)}for(let Q of Object.values(this._registeredResourceTemplates)){let Y=Q.resourceTemplate.uriTemplate.match(J.toString());if(Y)return Q.readCallback(J,Y,v)}throw new Tv(_v.InvalidParams,`Resource ${J} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler(C8.shape.method.value),this.server.assertCanSetRequestHandler(y8.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(C8,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,f])=>f.enabled).map(([f,v])=>{return{name:f,title:v.title,description:v.description,arguments:v.argsSchema?AG(v.argsSchema):void 0}})})),this.server.setRequestHandler(y8,async(f,v)=>{let J=this._registeredPrompts[f.params.name];if(!J)throw new Tv(_v.InvalidParams,`Prompt ${f.params.name} not found`);if(!J.enabled)throw new Tv(_v.InvalidParams,`Prompt ${f.params.name} disabled`);if(J.argsSchema){let X=await J.argsSchema.safeParseAsync(f.params.arguments);if(!X.success)throw new Tv(_v.InvalidParams,`Invalid arguments for prompt ${f.params.name}: ${X.error.message}`);let Q=X.data,Y=J.callback;return await Promise.resolve(Y(Q,v))}else{let X=J.callback;return await Promise.resolve(X(v))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0}resource(f,v,...J){let X;if(typeof J[0]==="object")X=J.shift();let Q=J[0];if(typeof v==="string"){if(this._registeredResources[v])throw new Error(`Resource ${v} is already registered`);let Y=this._createRegisteredResource(f,void 0,v,X,Q);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),Y}else{if(this._registeredResourceTemplates[f])throw new Error(`Resource template ${f} is already registered`);let Y=this._createRegisteredResourceTemplate(f,void 0,v,X,Q);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),Y}}registerResource(f,v,J,X){if(typeof v==="string"){if(this._registeredResources[v])throw new Error(`Resource ${v} is already registered`);let Q=this._createRegisteredResource(f,J.title,v,J,X);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),Q}else{if(this._registeredResourceTemplates[f])throw new Error(`Resource template ${f} is already registered`);let Q=this._createRegisteredResourceTemplate(f,J.title,v,J,X);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),Q}}_createRegisteredResource(f,v,J,X,Q){let Y={name:f,title:v,metadata:X,readCallback:Q,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({uri:null}),update:(w)=>{if(typeof w.uri!=="undefined"&&w.uri!==J){if(delete this._registeredResources[J],w.uri)this._registeredResources[w.uri]=Y}if(typeof w.name!=="undefined")Y.name=w.name;if(typeof w.title!=="undefined")Y.title=w.title;if(typeof w.metadata!=="undefined")Y.metadata=w.metadata;if(typeof w.callback!=="undefined")Y.readCallback=w.callback;if(typeof w.enabled!=="undefined")Y.enabled=w.enabled;this.sendResourceListChanged()}};return this._registeredResources[J]=Y,Y}_createRegisteredResourceTemplate(f,v,J,X,Q){let Y={resourceTemplate:J,title:v,metadata:X,readCallback:Q,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({name:null}),update:(w)=>{if(typeof w.name!=="undefined"&&w.name!==f){if(delete this._registeredResourceTemplates[f],w.name)this._registeredResourceTemplates[w.name]=Y}if(typeof w.title!=="undefined")Y.title=w.title;if(typeof w.template!=="undefined")Y.resourceTemplate=w.template;if(typeof w.metadata!=="undefined")Y.metadata=w.metadata;if(typeof w.callback!=="undefined")Y.readCallback=w.callback;if(typeof w.enabled!=="undefined")Y.enabled=w.enabled;this.sendResourceListChanged()}};return this._registeredResourceTemplates[f]=Y,Y}_createRegisteredPrompt(f,v,J,X,Q){let Y={title:v,description:J,argsSchema:X===void 0?void 0:B.object(X),callback:Q,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({name:null}),update:(w)=>{if(typeof w.name!=="undefined"&&w.name!==f){if(delete this._registeredPrompts[f],w.name)this._registeredPrompts[w.name]=Y}if(typeof w.title!=="undefined")Y.title=w.title;if(typeof w.description!=="undefined")Y.description=w.description;if(typeof w.argsSchema!=="undefined")Y.argsSchema=B.object(w.argsSchema);if(typeof w.callback!=="undefined")Y.callback=w.callback;if(typeof w.enabled!=="undefined")Y.enabled=w.enabled;this.sendPromptListChanged()}};return this._registeredPrompts[f]=Y,Y}_createRegisteredTool(f,v,J,X,Q,Y,w){let G={title:v,description:J,inputSchema:X===void 0?void 0:B.object(X),outputSchema:Q===void 0?void 0:B.object(Q),annotations:Y,callback:w,enabled:!0,disable:()=>G.update({enabled:!1}),enable:()=>G.update({enabled:!0}),remove:()=>G.update({name:null}),update:(K)=>{if(typeof K.name!=="undefined"&&K.name!==f){if(delete this._registeredTools[f],K.name)this._registeredTools[K.name]=G}if(typeof K.title!=="undefined")G.title=K.title;if(typeof K.description!=="undefined")G.description=K.description;if(typeof K.paramsSchema!=="undefined")G.inputSchema=B.object(K.paramsSchema);if(typeof K.callback!=="undefined")G.callback=K.callback;if(typeof K.annotations!=="undefined")G.annotations=K.annotations;if(typeof K.enabled!=="undefined")G.enabled=K.enabled;this.sendToolListChanged()}};return this._registeredTools[f]=G,this.setToolRequestHandlers(),this.sendToolListChanged(),G}tool(f,...v){if(this._registeredTools[f])throw new Error(`Tool ${f} is already registered`);let J,X,Q,Y;if(typeof v[0]==="string")J=v.shift();if(v.length>1){let G=v[0];if(zY(G)){if(X=v.shift(),v.length>1&&typeof v[0]==="object"&&v[0]!==null&&!zY(v[0]))Y=v.shift()}else if(typeof G==="object"&&G!==null)Y=v.shift()}let w=v[0];return this._createRegisteredTool(f,void 0,J,X,Q,Y,w)}registerTool(f,v,J){if(this._registeredTools[f])throw new Error(`Tool ${f} is already registered`);let{title:X,description:Q,inputSchema:Y,outputSchema:w,annotations:G}=v;return this._createRegisteredTool(f,X,Q,Y,w,G,J)}prompt(f,...v){if(this._registeredPrompts[f])throw new Error(`Prompt ${f} is already registered`);let J;if(typeof v[0]==="string")J=v.shift();let X;if(v.length>1)X=v.shift();let Q=v[0],Y=this._createRegisteredPrompt(f,void 0,J,X,Q);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),Y}registerPrompt(f,v,J){if(this._registeredPrompts[f])throw new Error(`Prompt ${f} is already registered`);let{title:X,description:Q,argsSchema:Y}=v,w=this._createRegisteredPrompt(f,X,Q,Y,J);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),w}isConnected(){return this.server.transport!==void 0}sendResourceListChanged(){if(this.isConnected())this.server.sendResourceListChanged()}sendToolListChanged(){if(this.isConnected())this.server.sendToolListChanged()}sendPromptListChanged(){if(this.isConnected())this.server.sendPromptListChanged()}}var FG={type:"object",properties:{}};function zY(f){if(typeof f!=="object"||f===null)return!1;return Object.keys(f).length===0||Object.values(f).some(jG)}function jG(f){return f!==null&&typeof f==="object"&&"parse"in f&&typeof f.parse==="function"&&"safeParse"in f&&typeof f.safeParse==="function"}function AG(f){return Object.entries(f.shape).map(([v,J])=>({name:v,description:J.description,required:!J.isOptional()}))}function BY(f){return{completion:{values:f.slice(0,100),total:f.length,hasMore:f.length>100}}}var PJ={completion:{values:[],hasMore:!1}};wJ();var $Y=(f)=>{};var MY=(f)=>{$Y(f)};wJ();var tW=null;async function iG(){if(typeof global!=="undefined"&&global.fetch)return global.fetch;if(typeof globalThis.fetch!=="undefined")return globalThis.fetch;if(!tW)try{tW=await Promise.resolve().then(() => (oW(),sW))}catch(f){throw new Error("Neither native fetch nor node-fetch is available. Please install node-fetch or upgrade to Node.js 18+")}return tW.default}async function dG(f,v){return(await iG())(f,v)}var fQ=dG;$0();var eW=x1("F2cApi",1);class z7{f2cHost="https://f2c-figma-api.yy.com/api";async nodeToCode(f){let v={fileKey:f.fileKey,nodeIds:f.ids,personal_token:f.personalToken||Lf.personalToken,option:{cssFramework:"inlinecss",imgFormat:f.imgFormat||"png",scaleSize:f.scaleSize||2},format:"files"};if(f.format==="react-cssmodules")v.option.cssFramework="cssmodules";else if(f.format==="react-tailwind")v.option.cssFramework="tailwindcss";let J=this.opToUrl(`${this.f2cHost}/nodes`,v);return this.fetch(J,"json",f.ideInfo||"other")}async fetch(f,v="json",J){eW.debug("fetch",f,Lf.personalToken);try{let X={method:"GET",headers:{"F2c-Api-Platform":`mcp-${J}`}};eW.debug("fetch",f);let Q=await fQ(f,X);if(!Q.ok)throw new Error(`HTTP error! status: ${Q.status}`);return v==="text"?await Q.text():await Q.json()}catch(X){throw eW.error("HTTP error",X),X}}opToUrl(f,v={}){if(Object.keys(v).length===0)return f;let J=new URL(f);for(let[X,Q]of Object.entries(v))if(typeof Q==="object"&&Q!==null)for(let[Y,w]of Object.entries(Q))J.searchParams.append(`${X}[${Y}]`,w);else J.searchParams.append(X,Q);return J.toString()}}var B7=new z7;wJ();$0();var sG=x1("FigmaRestApi");class K7{figmaHost="https://api.figma.com/v1";async files(f){let v;if(f.ids)v=this.opToUrl(`${this.figmaHost}/files/${f.fileKey}/nodes`,f);else v=this.opToUrl(`${this.figmaHost}/files/${f.fileKey}`,f);return this.fetch(v)}async images(f){let v=this.opToUrl(`${this.figmaHost}/images/${f.fileKey}`,f);return this.fetch(v)}async imageFills(f){let v=this.opToUrl(`${this.figmaHost}/files/${f.fileKey}/images`,f);return this.fetch(v)}async meta(f){let v=this.opToUrl(`${this.figmaHost}/files/${f.fileKey}/meta`,f);return this.fetch(v)}async fetch(f,v="json"){try{let J={method:"GET",headers:{"X-FIGMA-TOKEN":Lf.personalToken}},X=await fQ(f,J);if(!X.ok)throw new Error(`HTTP error! status: ${X.status}`);return v==="text"?await X.text():await X.json()}catch(J){throw sG.error("HTTP error",J),J}}opToUrl(f,v={},J=["fileKey","personalToken"]){if(Object.keys(v).length===0)return f;if(v.personalToken)Lf.personalToken=v.personalToken;let X=new URL(f);for(let[Q,Y]of Object.entries(v))if(!J.includes(Q))X.searchParams.append(Q,Y);return X.toString()}}var h7=new K7;$0();var O7=M1(D7());Uf();var cQ=M1(require("fs")),tf=M1(require("path")),v9=M1(require("fs/promises"));$0();var e1=x1("Downloader");class $7{op;assetsPath="";savePath="";setup(f){if(this.op=f,this.op.localPath)this.assetsPath=tf.default.join(this.op.localPath,"assets"),this.savePath=this.op.localPath}async downloadImage(f,v){let{imgFormat:J}=this.op,X=this.assetsPath;try{if(!cQ.default.existsSync(X))cQ.default.mkdirSync(X,{recursive:!0});let Q=`${v}.${J}`,Y=tf.default.join(X,Q),w=await fQ(f);if(!w.ok)throw new Error(`下载失败: ${w.status} ${w.statusText}`);let G=await w.arrayBuffer();return cQ.default.writeFileSync(Y,new Uint8Array(G)),tf.default.join(tf.default.basename(X),Q).replace(/\\/g,"/")}catch(Q){throw e1.error("图片下载错误:",Q),Q}}async downLoadImageAndReplaceContent(f){try{let v=/https:\/\/figma-alpha-api\.s3\.us-west-2\.amazonaws\.com\/images\/[a-f0-9-]+/g,J=f.match(v);if(!J)return f;let X=[...new Set(J)],Q=new Map;await Promise.all(X.map(async(w)=>{let G=tf.default.basename(w),K=await this.downloadImage(w,G);Q.set(w,K)}));let Y=f;for(let[w,G]of Q.entries()){let K=new RegExp(w.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");Y=Y.replace(K,G)}return Y}catch(v){throw e1.error("内容处理错误:",v),v}}async checkLocalAndDownload(f){if(!this.op.localPath)return;await Promise.all(f.map(async(v)=>{v.content=await this.downLoadImageAndReplaceContent(v.content)}));for(let v of f)try{let J=await this.saveContentToFile(v.content,v.path);e1.debug(`Successfully saved: ${J}`)}catch(J){e1.error(`Failed to save file ${v.path}:`,J)}}async ensureDirectoryExists(f){if(!cQ.default.existsSync(f))e1.debug(`Creating directory: ${f}`),await v9.default.mkdir(f,{recursive:!0})}async saveContentToFile(f,v){try{let J=tf.default.join(this.savePath,v),X=tf.default.dirname(J);if(e1.debug(`Full path: ${J}, directory: ${X}`),await this.ensureDirectoryExists(X),v.endsWith(".html"))e1.debug("Wrapping content with HTML template"),f=this.wrapHtmlContent(f);return e1.debug(`Writing ${f.length} bytes to file`),await v9.default.writeFile(J,f),e1.info(`File saved: ${J}`),J}catch(J){throw e1.error("File save error:",v,J),J}}wrapHtmlContent(f){return e1.debug("Wrapping content with HTML template"),`<!DOCTYPE html>
|
|
20
20
|
<html>
|
|
21
21
|
<head>
|
|
22
22
|
<meta charset="UTF-8">
|
|
@@ -26,7 +26,7 @@ Content-Type: ${Y.type||"application/octet-stream"}\r
|
|
|
26
26
|
<body>
|
|
27
27
|
${f}
|
|
28
28
|
</body>
|
|
29
|
-
</html>`}}var f9=new $7;var oG=x1("V3Tool"),M7="",V7=(f)=>{O7.reportMcpLoader().then((v)=>{M7=v||"other"}),f.tool("get_code","Generate UI code for a given node or the currently selected node in the Figma desktop app. Use the nodeId parameter to specify a node id. If no node id is provided, the currently selected node will be used. If a URL is provided, extract the node id from the URL, for example, if given the URL https://figma.com/design/:fileKey/:fileName?node-id=1-2, the extracted nodeId would be 1:2.
|
|
29
|
+
</html>`}}var f9=new $7;var oG=x1("V3Tool"),M7="",V7=(f)=>{O7.reportMcpLoader().then((v)=>{M7=v||"other"}),f.tool("get_code","Generate UI code for a given node or the currently selected node in the Figma desktop app. Use the nodeId parameter to specify a node id. If no node id is provided, the currently selected node will be used. If a URL is provided, extract the node id from the URL, for example, if given the URL https://figma.com/design/:fileKey/:fileName?node-id=1-2, the extracted nodeId would be 1:2.",{fileKey:B.string().describe("The Figma file identifier found in the file URL (e.g., https://www.figma.com/file/XXXXXXXXXXXX/). Extract the XXXXXXXXXXXX portion as the fileKey."),ids:B.string().describe('Comma-separated list of Figma node IDs for conversion. To obtain node IDs, select elements in Figma, right-click and select "Copy/Paste as" → "Copy ID".'),personalToken:B.string().optional().describe("Figma personal access token for API authentication.The parameters are not required when the tool is called."),localPath:B.string().optional().describe("Absolute path for asset(e.g., images) and code storage. Directory will be created if non-existent. Path must follow OS-specific format without special character escaping. When this path is set, all code-related static resources are stored in this directory, while other assets (e.g., images) will be saved into the subdirectory named assets under this path."),imgFormat:B.enum(["png","jpg","svg"]).default("png").describe('Export format for image assets: "png" for lossless quality, "jpg" for compressed files, or "svg" for vector graphics.'),scaleSize:B.number().min(1).max(4).default(1).describe("Image export scale factor (1-4). Higher values yield better quality at the cost of larger file sizes.")},async(v)=>{f9.setup(v);try{let J=await B7.nodeToCode({...v,format:"react-tailwind",ideInfo:M7})||[];if(await f9.checkLocalAndDownload(J),!J)return{content:[{type:"text",text:"Failed to generate any code. Please check if the provided Figma node IDs are correct or if the nodes can be converted to code."}]};let X=Array.isArray(J)?J:[J];if(X.length===0)return{content:[{type:"text",text:"Conversion succeeded but no files were generated. Please check if the selected Figma nodes contain convertible content."}]};let Q=X.filter((w)=>!w.path.endsWith("/index.scss")).map((w,G)=>`${G+1}. ${w.path}`).join(`
|
|
30
30
|
`);if(v.localPath)return{content:[{type:"text",text:`# Files Saved Locally
|
|
31
31
|
|
|
32
32
|
## Save Location
|
|
@@ -39,5 +39,5 @@ ${Q}. Convert the Tailwind to vanilla CSS if not already used in the codebase. D
|
|
|
39
39
|
`);if(f===-1)return null;let v=this._buffer.toString("utf8",0,f).replace(/\r$/,"");return this._buffer=this._buffer.subarray(f+1),tG(v)}clear(){this._buffer=void 0}}function tG(f){return V6.parse(JSON.parse(f))}function q7(f){return JSON.stringify(f)+`
|
|
40
40
|
`}class W9{constructor(f=J9.default.stdin,v=J9.default.stdout){this._stdin=f,this._stdout=v,this._readBuffer=new Q9,this._started=!1,this._ondata=(J)=>{this._readBuffer.append(J),this.processReadBuffer()},this._onerror=(J)=>{var X;(X=this.onerror)===null||X===void 0||X.call(this,J)}}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(){var f,v;while(!0)try{let J=this._readBuffer.readMessage();if(J===null)break;(f=this.onmessage)===null||f===void 0||f.call(this,J)}catch(J){(v=this.onerror)===null||v===void 0||v.call(this,J)}}async close(){var f;if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),(f=this.onclose)===null||f===void 0||f.call(this)}send(f){return new Promise((v)=>{let J=q7(f);if(this._stdout.write(J))v();else this._stdout.once("drain",v)})}}$0();var eG=x1("StdioTransport");async function F7(f){try{let v=new W9;await f.connect(v)}catch(v){eG.info(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32000,message:`Server startup failed: ${v.message}`}})),process.exit(1)}}F7(jJ);
|
|
41
41
|
|
|
42
|
-
//# debugId=
|
|
42
|
+
//# debugId=F6474D843FAF342A64756E2164756E21
|
|
43
43
|
//# sourceMappingURL=cli.js.map
|