exports.id=2415,exports.ids=[2415],exports.modules={17511:a=>{"use strict";a.exports={IS_DEV:!1,TARGET_HOSTS:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com","daily-cloudcode-pa.sandbox.googleapis.com","api.individual.githubcopilot.com","q.us-east-1.amazonaws.com","api2.cursor.sh","openrouter.ai","api.openrouter.ai"],URL_PATTERNS:{antigravity:[":generateContent",":streamGenerateContent"],copilot:["/chat/completions","/v1/messages","/responses"],kiro:["/generateAssistantResponse"],cursor:["/BidiAppend","/RunSSE","/RunPoll","/Run"],openrouter:["/models","/api/v1/models","/api/v1/key","/api/v1/auth/key","/chat/completions","/v1/chat/completions","/api/v1/chat/completions","/v1/messages","/responses","/api/v1/responses"]},MODEL_SYNONYMS:{antigravity:{"gemini-default":"gemini-3-flash","gemini-3-flash-agent":"gemini-3-flash","gemini-3.1-flash-lite":"gemini-3-flash",tab_flash_lite_preview:"gemini-3-flash","gemini-2.5-flash-lite":"gemini-3-flash","gemini-2.5-flash":"gemini-3-flash",__defaults:{"gemini-3.1-pro-high":"gemini-3.1-pro-high","gemini-3.1-pro-low":"gemini-3.1-pro-low","gemini-3-flash-agent":"cx/gpt-5.5","gemini-3-flash":"cx/gpt-5.5","claude-sonnet-4-6":"claude-sonnet-4-6","claude-opus-4-6-thinking":"claude-opus-4-6-thinking","gpt-oss-120b-medium":"gpt-oss-120b-medium"}}},MODEL_PATTERNS:{antigravity:[{match:/flash/i,alias:"gemini-3-flash"},{match:/pro.*low|low.*pro/i,alias:"gemini-3.1-pro-low"},{match:/gemini.*pro|pro.*gemini/i,alias:"gemini-3.1-pro-high"},{match:/opus/i,alias:"claude-opus-4-6-thinking"},{match:/sonnet|claude/i,alias:"claude-sonnet-4-6"},{match:/gpt.*oss|oss/i,alias:"gpt-oss-120b-medium"}]},LOG_BLACKLIST_URL_PARTS:["recordCodeAssistMetrics","recordTrajectoryAnalytics","fetchAdminControls","listExperiments","fetchUserInfo"],getToolForHost:function(a){let b=(a||"").split(":")[0];return"api.individual.githubcopilot.com"===b?"copilot":"daily-cloudcode-pa.googleapis.com"===b||"cloudcode-pa.googleapis.com"===b||"daily-cloudcode-pa.sandbox.googleapis.com"===b?"antigravity":"q.us-east-1.amazonaws.com"===b?"kiro":"api2.cursor.sh"===b?"cursor":"openrouter.ai"===b||"api.openrouter.ai"===b?"openrouter":null}}},49120:(a,b,c)=>{"use strict";c.r(b),c.d(b,{APP_NAME:()=>j,DATA_DIR:()=>p,DB_FILE:()=>q,LEGACY_APP_NAME:()=>k,getDataDir:()=>o,getLegacyDataDir:()=>n,migrateLegacyDataFilesIfNeeded:()=>r});var d=c(29021),e=c.n(d),f=c(33873),g=c.n(f),h=c(21820),i=c.n(h);let j="openrouterx",k="9router",l=["db.json","usage.json","log.txt","disabledModels.json","request-details.json"];function m(a){return"win32"===process.platform?g().join(process.env.APPDATA||g().join(i().homedir(),"AppData","Roaming"),a):g().join(i().homedir(),`.${a}`)}function n(){return m(k)}function o(){let a=process.env.DATA_DIR;if(!a)return m(j);try{return e().mkdirSync(a,{recursive:!0}),a}catch(b){if(b?.code==="EACCES"||b?.code==="EPERM")return console.warn(`[DATA_DIR] '${a}' not writable -> fallback ~/.${j}`),m(j);throw b}}let p=o(),q=g().join(p,"db.json");function r(){if(process.env.DATA_DIR)return!1;let a=n();if(a===p||!e().existsSync(a))return!1;let b=!1;for(let c of(e().existsSync(p)||e().mkdirSync(p,{recursive:!0}),l)){let d=g().join(a,c),f=g().join(p,c);e().existsSync(d)&&!e().existsSync(f)&&(e().copyFileSync(d,f),b=!0)}return b}r()},64809:(a,b,c)=>{"use strict";let{exec:d,execSync:e}=c(79646),f="win32"===process.platform;function g(){if(f)try{return e("net session >nul 2>&1",{windowsHide:!0,stdio:"ignore"}),!0}catch{return!1}return"function"==typeof process.getuid&&0===process.getuid()}function h(a){return`'${String(a).replace(/'/g,"''")}'`}a.exports={isAdmin:g,runElevatedPowerShell:function(a){if(!f)return Promise.reject(Error("Windows-only"));let b=Buffer.from(a,"utf16le").toString("base64");if(g())return new Promise((a,c)=>{d(`powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand ${b}`,{windowsHide:!0},(b,d,e)=>{b?c(Error(e||b.message)):a(d)})});let c=`
    $proc = Start-Process powershell -ArgumentList @(
      '-NoProfile','-NonInteractive','-ExecutionPolicy','Bypass',
      '-WindowStyle','Hidden','-EncodedCommand','${b}'
    ) -Verb RunAs -Wait -PassThru -WindowStyle Hidden;
    if ($proc.ExitCode -ne 0) { throw "Elevated command exited with code $($proc.ExitCode)" }
  `;return new Promise((a,b)=>{d(`powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command ${h(c)}`,{windowsHide:!0},(c,d,e)=>{if(c){let a=e||c.message;a.includes("canceled by the user")||a.includes("operation was canceled")?b(Error("User canceled UAC prompt")):b(Error(a))}else a(d)})})},quotePs:h}},66936:(a,b,c)=>{"use strict";let{exec:d,spawn:e,execSync:f}=c(79646),g=c(29021),h=c(33873);c(21820);let{log:i,err:j}=c(87777),{TOOL_HOSTS:k}=c(85341),{runElevatedPowerShell:l,isAdmin:m}=c(64809);function n(a,b,c){let d=`${a}.openrouterx.new`,e=`${a}.openrouterx.bak`;try{g.writeFileSync(d,c,"utf8");try{g.unlinkSync(e)}catch{}g.renameSync(a,e);try{g.renameSync(d,a)}catch(c){try{g.renameSync(e,a)}catch{g.writeFileSync(a,b,"utf8")}throw c}try{g.unlinkSync(e)}catch{}}finally{try{g.unlinkSync(d)}catch{}}}let o="win32"===process.platform,p="darwin"===process.platform,q=o?h.join(process.env.SystemRoot||"C:\\Windows","System32","drivers","etc","hosts"):"/etc/hosts",r="com.apple/openrouterx-mitm-antigravity",s=["216.239.32.223","216.239.34.223","216.239.36.223","216.239.38.223"],t=["142.250.","142.251.","172.217."],u=o?["127.0.0.1"]:["127.0.0.1","::1"];function v(a=process.env){return"1"===String(a.OPENROUTERX_MITM_ANTIGRAVITY_PF||"").trim()}function w(a,b,c){return String(a||"").split(/\r?\n/).some(a=>(function(a,b,c){let d=String(a||"").trim();if(!d||d.startsWith("#"))return!1;let e=d.split(/\s+/);return e[0]===b&&e.slice(1).includes(c)})(a,c,b))}function x(a,b,c=u){return c.every(c=>w(a,b,c))}function y(a,b,c=u){return b.flatMap(b=>c.filter(c=>!w(a,b,c)).map(a=>`${a} ${b}`))}function z(){if(o)return!1;try{return f("command -v sudo",{stdio:"ignore",windowsHide:!0}),!0}catch{return!1}}function A(){if(o||!z())return!0;try{return f("sudo -n true",{stdio:"ignore",windowsHide:!0}),!0}catch{return!1}}function B(a,b){return new Promise((c,d)=>{let f=z(),g=f?e("sudo",["-S","sh","-c",a],{stdio:["pipe","pipe","pipe"],windowsHide:!0}):e("sh",["-c",a],{stdio:["ignore","pipe","pipe"],windowsHide:!0}),h="",i="";g.stdout.on("data",a=>{h+=a}),g.stderr.on("data",a=>{i+=a}),g.on("close",a=>{0===a?c(h):d(Error(i||`Exit code ${a}`))}),f&&(g.stdin.write(`${b}
`),g.stdin.end())})}async function C(a){o||(p?await B("dscacheutil -flushcache && killall -HUP mDNSResponder",a):await B("resolvectl flush-caches 2>/dev/null || true",a))}function D(a){return`'${String(a).replace(/'/g,"'\\''")}'`}async function E(){return[...s]}async function F(a){if(!p)return;if(!v()){await G(a),i("\uD83C\uDF10 PF antigravity: skipped (hosts-only mode; set OPENROUTERX_MITM_ANTIGRAVITY_PF=1 to opt in)");return}let b=await E();if(0===b.length)return;await H(a,b);let c=function(){if(!p)return"";try{return f("route -n get default 2>/dev/null | awk '/interface:/{print $2; exit}'",{encoding:"utf8",windowsHide:!0}).trim()||"en0"}catch{return"en0"}}(),d=`table <openrouterx_antigravity> persist { ${b.join(", ")} }
rdr pass on ${c} inet proto tcp from any to <openrouterx_antigravity> port 443 -> 127.0.0.1 port 443
`,e=`pfctl -E >/dev/null 2>&1 || true && printf '%s' ${D(d)} | pfctl -a ${D(r)} -f -`;await B(e,a),i(`🌐 PF antigravity: ✅ redirect active on ${c} (${b.length} IPs)`)}async function G(a){if(!p)return;let b=[...new Set([...await E(),...(function(){if(!p)return[];try{return[...f("ifconfig lo0",{encoding:"utf8",windowsHide:!0}).matchAll(/^\s+inet\s+(\d+\.\d+\.\d+\.\d+)\s+/gm)].map(a=>a[1])}catch{return[]}})().filter(a=>t.some(b=>a.startsWith(b)))])];await B(`pfctl -a ${D(r)} -F all >/dev/null 2>&1 || true`,a),await I(a,b),i("\uD83C\uDF10 PF antigravity: ✅ redirect removed")}async function H(a,b){if(!p||!b.length)return;let c=b.map(a=>`ifconfig lo0 alias ${a}/32 2>/dev/null || true`);await B(c.join("; "),a),i(`🌐 lo0 antigravity: ✅ aliases active (${b.length} IPs)`)}async function I(a,b){if(!p||!b.length)return;let c=b.map(a=>`ifconfig lo0 -alias ${a} 2>/dev/null || true`);await B(c.join("; "),a)}async function J(a,b){"antigravity"===a&&await F(b)}async function K(a,b){"antigravity"===a&&await G(b)}function L(a=null){try{let b=g.readFileSync(q,"utf8");if(a)return x(b,a);return k.antigravity.every(a=>x(b,a))}catch{return!1}}async function M(a,b){let c=k[a];if(!c)throw Error(`Unknown tool: ${a}`);let d=g.readFileSync(q,"utf8"),e=y(d,c);if(0===e.length){i(`🌐 DNS ${a}: already active`),await J(a,b);return}try{if(o){let a=d.replace(/[\r\n\s]+$/g,""),b=e.join("\r\n"),c=`${a}\r
${b}\r
`;n(q,d,c),await l("ipconfig /flushdns | Out-Null")}else{let a=d.replace(/[\r\n\s]+$/g,""),c=e.join("\n"),f=`${a}
${c}
`.replace(/'/g,"'\\''");await B(`printf '%s' '${f}' | tee ${q} > /dev/null`,b),await C(b)}await J(a,b),i(`🌐 DNS ${a}: ✅ added ${e.join(", ")}`)}catch(a){throw Error(a.message?.includes("incorrect password")?"Wrong sudo password":`Failed to add DNS entry: ${a.message}`)}}async function N(a,b){let c=k[a];if(!c)throw Error(`Unknown tool: ${a}`);let d=c.filter(a=>L(a));if(0===d.length){i(`🌐 DNS ${a}: already inactive`),await K(a,b);return}try{if(o){let a=g.readFileSync(q,"utf8"),b=a.split(/\r?\n/).filter(a=>!d.some(b=>a.includes(b))).join("\r\n").replace(/[\r\n\s]+$/g,"")+"\r\n";n(q,a,b),await l("ipconfig /flushdns | Out-Null")}else{let a=(g.readFileSync(q,"utf8").split(/\r?\n/).filter(a=>!d.some(b=>a.includes(b))).join("\n").replace(/[\r\n\s]+$/g,"")+"\n").replace(/'/g,"'\\''");await B(`printf '%s' '${a}' | tee ${q} > /dev/null`,b),await C(b)}await K(a,b),i(`🌐 DNS ${a}: ✅ removed ${d.join(", ")}`)}catch(a){throw Error(a.message?.includes("incorrect password")?"Wrong sudo password":`Failed to remove DNS entry: ${a.message}`)}}async function O(a){for(let b of Object.keys(k))try{await N(b,a)}catch(a){j(`DNS ${b}: failed to remove — ${a.message}`)}}a.exports={TOOL_HOSTS:k,addDNSEntry:M,removeDNSEntry:N,removeAllDNSEntries:O,removeAllDNSEntriesSync:function(){try{if(p){try{f(`pfctl -a ${r} -F all >/dev/null 2>&1 || true`,{stdio:"ignore"})}catch{}for(let a of s)try{f(`ifconfig lo0 -alias ${a} 2>/dev/null || true`,{stdio:"ignore"})}catch{}}if(!g.existsSync(q))return;let a=Object.values(k).flat(),b=g.readFileSync(q,"utf8"),c=o?"\r\n":"\n",d=b.split(/\r?\n/).filter(b=>!a.some(a=>b.includes(a))).join(c).replace(/[\r\n\s]+$/g,"")+c;if(d===b)return;if(g.writeFileSync(q,d,"utf8"),o)try{f("ipconfig /flushdns",{windowsHide:!0,stdio:"ignore"})}catch{}else if(p)try{f("dscacheutil -flushcache && killall -HUP mDNSResponder",{stdio:"ignore"})}catch{}else try{f("resolvectl flush-caches 2>/dev/null || true",{stdio:"ignore"})}catch{}}catch{}},execWithPassword:B,isSudoAvailable:z,canRunSudoWithoutPassword:A,isSudoPasswordRequired:function(){return!o&&z()&&!A()},checkDNSEntry:L,checkAllDNSStatus:function(){try{let a=g.readFileSync(q,"utf8"),b={};for(let[c,d]of Object.entries(k))b[c]=d.every(b=>x(a,b));return b}catch{return Object.fromEntries(Object.keys(k).map(a=>[a,!1]))}},getMissingHostsEntries:y,hostHasRequiredLoopbacks:x,isMacAntigravityPfRedirectEnabled:v}},78335:()=>{},82193:(a,b,c)=>{"use strict";c(29021);let d=c(33873),e=c(21820),f="openrouterx",g=process.env.DATA_DIR?process.env.DATA_DIR:"win32"===process.platform?d.join(process.env.APPDATA||d.join(e.homedir(),"AppData","Roaming"),f):d.join(e.homedir(),`.${f}`),h=d.join(g,"mitm");a.exports={DATA_DIR:g,MITM_DIR:h}},85341:a=>{"use strict";a.exports={TOOL_HOSTS:{antigravity:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com","daily-cloudcode-pa.sandbox.googleapis.com"],copilot:["api.individual.githubcopilot.com"],kiro:["q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],cursor:["api2.cursor.sh"],openrouter:["openrouter.ai","api.openrouter.ai"]}}},87777:(a,b,c)=>{"use strict";let d=c(29021),e=c(33873),f=c(74075),{DATA_DIR:g}=c(82193),{LOG_BLACKLIST_URL_PARTS:h}=c(17511);function i(){return new Date().toLocaleTimeString("en-US",{hour12:!1})}let j=function(){let a=[e.join(g,"logs","mitm"),e.join(c(21820).tmpdir(),"openrouterx","logs","mitm")];for(let b of a)try{return d.existsSync(b)||d.mkdirSync(b,{recursive:!0}),b}catch{}return a[1]}(),k=/^\s*(\{\s*\}|\[\s*\]|null)?\s*$/;function l(a,b=80){return String(a).replace(/[^a-zA-Z0-9]/g,"_").substring(0,b)}function m(a){return!!a&&h.some(b=>a.includes(b))}a.exports={log:a=>console.log(`[${i()}] [MITM] ${a}`),err:a=>console.error(`[${i()}] ❌ [MITM] ${a}`),dumpRequest:function(a,b,c="raw"){if(m(a.url))return null;try{let f=new Date().toISOString().replace(/[:.]/g,"-"),g=l((a.headers.host||"")+a.url),h=e.join(j,`${f}_${c}_${g}.req.json`),i=null;try{i=JSON.parse(b.toString())}catch{}return d.writeFileSync(h,JSON.stringify({method:a.method,url:a.url,host:a.headers.host,headers:a.headers,body:i??b.toString("utf8")},null,2)),h}catch{return null}},createResponseDumper:function(a,b="raw"){if(m(a.url))return null;let c=new Date().toISOString().replace(/[:.]/g,"-"),g=l((a.headers.host||"")+a.url),h=e.join(j,`${c}_${b}_${g}.res.txt`),i=0,n={},o=[];return{writeHeader:(a,b)=>{i=a,n=b||{}},writeChunk:a=>{null!=a&&o.push(Buffer.isBuffer(a)?a:Buffer.from(a))},end:()=>{try{let a=Buffer.concat(o),b=n["content-encoding"]||n["Content-Encoding"],c=(function(a,b){if(!a||0===a.length)return a;try{let c=(b||"").toLowerCase();if(c.includes("gzip"))return f.gunzipSync(a);if(c.includes("br"))return f.brotliDecompressSync(a);if(c.includes("deflate"))return f.inflateSync(a)}catch{}return a})(a,b).toString("utf8");if(k.test(c))return;let e={...n};delete e["content-encoding"],delete e["Content-Encoding"];let g=`STATUS: ${i}
HEADERS: ${JSON.stringify(e,null,2)}
---BODY---
${c}`;d.writeFileSync(h,g)}catch{}},file:h}},clearDumpDir:function(){try{if(!d.existsSync(j))return;for(let a of d.readdirSync(j))try{d.rmSync(e.join(j,a),{recursive:!0,force:!0})}catch{}}catch{}}}},96487:()=>{}};