#!/usr/bin/env node
var s=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var p=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var E=p((v,l)=>{var u=s("fs"),f=s("path"),_=s("os"),{execSync:m}=s("child_process");function x(){if(process.env.BRIDGE_CONTEXT_EXCHANGE)return process.env.BRIDGE_CONTEXT_EXCHANGE;let e=f.join(__dirname,"native-host","exchange.json");if(u.existsSync(e))return e;if(process.platform==="win32")try{let r=m('reg query "HKEY_CURRENT_USER\\Software\\Google\\Chrome\\NativeMessagingHosts\\com.bridgecontext.host" /ve').toString().match(/REG_SZ\s+(.*)/);if(r&&r[1]){let c=r[1].trim(),o=JSON.parse(u.readFileSync(c,"utf8"));if(o.path){let d=f.join(f.dirname(o.path),"exchange.json");if(u.existsSync(d))return d}}}catch{}return f.join(process.cwd(),"native-host","exchange.json")}var h=x();async function g(){process.stderr.write(`\u{1F309} BridgeContext MCP Server active
`);let e="";process.stdin.on("data",t=>{e+=t.toString();let n;for(;(n=e.indexOf(`
`))>=0;){let i=e.slice(0,n);e=e.slice(n+1),i.trim()&&S(i)}})}function S(e){try{let t=JSON.parse(e),{method:n,params:i,id:r}=t;if(n==="initialize")a(r,{capabilities:{tools:{}},serverInfo:{name:"bridge-context-mcp",version:"1.0.0"}});else if(n==="tools/list")a(r,{tools:[{name:"get_current_context",description:"Retrieve the latest AI context bridged from the browser. Use this to get information the user has just researched or captured in their browser.",inputSchema:{type:"object",properties:{}}}]});else if(n==="tools/call"&&i.name==="get_current_context")if(u.existsSync(h))try{let c=u.readFileSync(h,"utf8"),o=JSON.parse(c);a(r,{content:[{type:"text",text:`--- BRIDGE CONTEXT ---
Title: ${o.name}
Description: ${o.desc}
Payload:
${o.data}`}]})}catch(c){a(r,{content:[{type:"text",text:"Error reading context: "+c.message}],isError:!0})}else a(r,{content:[{type:"text",text:"No context available. Please bridge context from your browser first."}]})}catch{}}function a(e,t){process.stdout.write(JSON.stringify({jsonrpc:"2.0",id:e,result:t})+`
`)}function y(){return{connect:async()=>{process.stderr.write(`\u2601\uFE0F Smithery Sandbox Connect Simulation
`)},listTools:async()=>({tools:[{name:"get_current_context",description:"Retrieve the latest AI context bridged from the browser."}]})}}s.main===l&&g();l.exports={createSandboxServer:y}});export default E();
//# sourceMappingURL=module.js.map