function m(n){const i=n.shellOrigin;let a=0;const s=new Map;addEventListener("message",r=>{if(r.source!==parent||r.origin!==i)return;const e=r.data;if(!e||e.__frame_cap_r!==!0)return;const t=typeof e.id=="string"?e.id:null;if(!t)return;const o=s.get(t);o&&(s.delete(t),clearTimeout(o.timer),e.error!=null?o.reject(e.error):o.resolve(e.result))});const c=(r,e)=>new Promise((t,o)=>{const l="c"+ ++a,u=setTimeout(()=>{s.delete(l),o({code:"upstream_error",message:"no reply from shell"})},13e4);s.set(l,{resolve:t,reject:o,timer:u}),parent.postMessage({__frame_cap:!0,cap:"mcp",id:l,method:r,args:e},i)}),p=n.pipe("mcp");n.mount("mcp",{callTool:p.wrap("callTool",(r,e,t)=>c("callTool",[r,e,t])),listTools:p.wrap("listTools",()=>c("listTools",[]))})}export{m as install};
