@embd/mcp 0.7.9 → 0.8.2

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.
@@ -1,4 +1,4 @@
1
- import{J as D}from"./bin-abb2cdyk.js";import F from"node:process";class A{append(b){this._buffer=this._buffer?Buffer.concat([this._buffer,b]):b}readMessage(){if(!this._buffer)return null;let b=this._buffer.indexOf(`
1
+ import{J as D}from"./bin-54n4y23d.js";import F from"node:process";class A{append(b){this._buffer=this._buffer?Buffer.concat([this._buffer,b]):b}readMessage(){if(!this._buffer)return null;let b=this._buffer.indexOf(`
2
2
  `);if(b===-1)return null;let q=this._buffer.toString("utf8",0,b).replace(/\r$/,"");return this._buffer=this._buffer.subarray(b+1),G(q)}clear(){this._buffer=void 0}}function G(b){return D.parse(JSON.parse(b))}function E(b){return JSON.stringify(b)+`
3
3
  `}class H{constructor(b=F.stdin,q=F.stdout){this._stdin=b,this._stdout=q,this._readBuffer=new A,this._started=!1,this._ondata=(w)=>{this._readBuffer.append(w),this.processReadBuffer()},this._onerror=(w)=>{this.onerror?.(w)}}async start(){if(this._started)throw 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(){while(!0)try{let b=this._readBuffer.readMessage();if(b===null)break;this.onmessage?.(b)}catch(b){this.onerror?.(b)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(b){return new Promise((q)=>{let w=E(b);if(this._stdout.write(w))q();else this._stdout.once("drain",q)})}}
4
4
  export{H as a};