UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.53 kB
import{i as consumeRootOptionToken,l as isValueToken}from"./cli-root-options-eez2TgAl.mjs"; //!extensions/browser/cli-output-mode.ts const BROWSER_BOOLEAN_OPTIONS=/* @__PURE__ */ new Set([`--json`,`--expect-final`]);const BROWSER_VALUE_OPTIONS=/* @__PURE__ */ new Set([`--browser-profile`,`--url`,`--token`,`--timeout`,`--gateway-url`]);function consumeOption(e,t){const n=e[t];if(!n||n===`--`||!n.startsWith(`-`))return 0;const r=n.indexOf(`=`);const i=r===-1?n:n.slice(0,r);if(BROWSER_BOOLEAN_OPTIONS.has(i))return r===-1?1:0;if(!BROWSER_VALUE_OPTIONS.has(i))return 0;if(r!==-1)return n.slice(r+1).trim()?1:0;return isValueToken(e[t+1])?2:1}function resolveBrowserCommandPath(e){const t=e.slice(2);let n=false;const r=[];for(let e=0;e<t.length;e+=1){const i=t[e];if(!i||i===`--`)break;const a=consumeRootOptionToken(t,e);if(a>0){e+=a-1;continue}if(!n){if(i===`browser`)n=true;continue}const o=consumeOption(t,e);if(o>0){e+=o-1;continue}if(i.startsWith(`-`))break;r.push(i)}return r}function resolveBrowserLazySubcommand(e){return resolveBrowserCommandPath(e)[0]??null}function isBrowserMachineOutput(e){const t=resolveBrowserCommandPath(e.argv);return t[0]===`evaluate`||t[0]===`console`||t[0]===`cookies`&&t.length===1||t[0]===`storage`&&[`local`,`session`].includes(t[1]??``)&&t[2]===`get`||t[0]===`extension`&&t[1]===`native-host`||t[0]===`extension`&&[`setup`,`install`,`status`,`uninstall-host`,`pair`,`cdp`].includes(t[1]??``)&&e.argv.includes(`--json`)}export{resolveBrowserLazySubcommand as n,isBrowserMachineOutput as t};