File: C:/Users/fred/.codex/plugins/cache/openai-bundled/chrome/latest/scripts/installManifest.mjs
import D from"path";var s={channel:"prod",extensionId:"hehggadaopoacecdllhhajmbjkdcmajg",extensionHostName:"com.openai.codexextension"};import{existsSync as I}from"node:fs";import p from"node:os";import A from"node:path";var O={darwin:"macos",win32:"windows",linux:"linux"},l=t=>{let e=p.arch(),n=O[p.platform()],o=n==="windows"?"extension-host.exe":"extension-host";if(!n||e!=="arm64"&&e!=="x64")throw new Error("Invalid platform or architecture: "+p.platform()+" "+p.arch());return A.resolve(t,`extension-host/${n}/${e}/${o}`)},u=async t=>{let e=l(t);if(!I(e))throw new Error(`Missing bundled Browser Use extension host binary at ${e}.`)};import h from"node:os";import R from"node:path";var g=t=>{let e=`${t.extensionHostName}.json`,o={darwin:["Library/Application Support/Google/Chrome/NativeMessagingHosts"],linux:[".config/google-chrome/NativeMessagingHosts"],win32:["AppData/Local/OpenAI/extension"]}[h.platform()];if(!o)throw new Error("Unsupported platform: "+h.platform());return o.map(i=>R.resolve(h.homedir(),i,e))};import{mkdir as H,writeFile as w}from"node:fs/promises";import{dirname as x,resolve as v}from"node:path";var E="extension-host-config.json",b="127.0.0.1",M=0,_="Codex chrome native messaging host";function $({browserClientPath:t,channel:e,codexCliPath:n,extensionId:o,nodePath:i,nodeReplPath:a,proxyHost:c=b,proxyPort:f=M}){let m=F(f,"proxyPort",{allowZero:!0});return{schemaVersion:1,...e==null?{}:{channel:r(e,"channel")},...t==null?{}:{browserClientPath:r(t,"browserClientPath")},codexCliPath:r(n,"codexCliPath"),...o==null?{}:{extensionId:r(o,"extensionId")},nodePath:r(i,"nodePath"),nodeReplPath:r(a,"nodeReplPath"),proxyHost:r(c,"proxyHost"),proxyPort:m}}function S(t,e){return $({browserClientPath:v(t,"scripts","browser-client.mjs"),...e})}async function y({appServerHostConfig:t,description:e=_,extensionHostName:n,extensionHostPath:o,extensionId:i,manifestPaths:a}){let c={allowed_origins:[`chrome-extension://${r(i,"extensionId")}/`],description:e,name:r(n,"extensionHostName"),path:r(o,"extensionHostPath"),type:"stdio"},f=`${JSON.stringify(c,null,2)}
`,m=await T({appServerHostConfig:{...t,extensionId:r(i,"extensionId")},extensionHostPath:o});return await Promise.all(a.map(async P=>{await H(x(P),{recursive:!0}),await w(P,f,"utf8")})),{configPath:m,manifestPaths:a}}async function T({appServerHostConfig:t,extensionHostPath:e}){let n=v(x(e),E);return await H(x(n),{recursive:!0}),await w(n,`${JSON.stringify(t,null,2)}
`,"utf8"),n}function r(t,e){if(typeof t!="string"||t.trim()==="")throw new Error(`Missing ${e}.`);return t}function F(t,e,{allowZero:n=!1}={}){if(typeof t!="number"||!Number.isInteger(t)||t<(n?0:1)||t>65535)throw new Error(`${e} must be a TCP port between ${n?0:1} and 65535.`);return t}import d from"path";var C=t=>{let e=d.resolve(t).split(d.sep),n=e.lastIndexOf("cache");return n<1||e[n-1]!=="plugins"||e.length<=n+3?t:d.resolve(t,"..","latest")};import{execFile as j}from"node:child_process";import{platform as k}from"node:os";import{promisify as L}from"node:util";var U=L(j),N=async t=>{if(k()!=="win32")return;let e=[`HKCU\\Software\\Google\\Chrome\\NativeMessagingHosts\\${t.extensionHostName}`],n=g(t)[0];if(!n)throw new Error("Invalid Windows path returned");for(let o of e)await U("reg",["add",o,"/ve","/t","REG_SZ","/d",n,"/f"])};var lt=async t=>{let e=C(D.resolve(import.meta.dirname,".."));await u(e),await y({appServerHostConfig:S(e,{channel:s.channel,...t.appServerRuntimePaths}),extensionHostName:s.extensionHostName,extensionHostPath:l(e),extensionId:s.extensionId,manifestPaths:g(s)}),await N(s)};export{lt as install};