openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 2.75 kB
JavaScript
import{s as e}from"./transcript-src-gRxwdYZM.mjs";const t=`--openclaw-sqlite-readonly-child`,n=e(import.meta.url),r=/^node(?:-\d+|\d+)(?:\.\d+)*(?:\.exe)?$/;function normalizeRuntimeBasename(e){let t=e.trim().replace(/^["']|["']$/g,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1)).trim().toLowerCase()}function isNodeRuntime(e){let t=normalizeRuntimeBasename(e);return/^node(?:js)?(?:\.exe)?$/.test(t)||r.test(t)}function isBunRuntime(e){let t=normalizeRuntimeBasename(e);return t===`bun`||t===`bun.exe`}const i=/* @__PURE__ */ new Set([`-r`,`--preload`,`--require`,`--import`,`--loader`,`--experimental-loader`,`--test-reporter`,`--test-global-setup`]),a=/* @__PURE__ */ new Set([...i,`-C`,`--env-file`,`--env-file-if-exists`,`--tsconfig`,`--cwd`,`--conditions`,`--icu-data-dir`,`--openssl-config`,`--title`,`--disable-warning`,`--disable-proto`,`--cpu-prof-name`,`--max-old-space-size`,`--max-semi-space-size`]),o=/* @__PURE__ */ new Set([`--inspect`,`--inspect-brk`,`--inspect-wait`,`--expose-gc`,`--jitless`,`--no-opt`,`--experimental-strip-types`,`--watch`,`--no-warnings`,`--trace-uncaught`,`--bun`]);function resolveRuntimeScriptPosition(e){let t=[],n=e[0]??``,r=n.replaceAll(`\\`,`/`).trim().toLowerCase().split(`/`).at(-1),s=isBunRuntime(n),c=r===`tsx`||r===`tsx.cmd`,l=s?`run`:c?`watch`:void 0,u,d=[];if(!isNodeRuntime(n)&&!s&&!c)return{position:{kind:`not-runtime`},operands:t,sourceIndices:d};for(let n=1;n<e.length;n++){let r=e[n];if(r===`--`){if(!u)return{position:d.length===0&&e[n+1]?n+1:{kind:`other`},operands:t,sourceIndices:d};t.push(...e.slice(n+1).map(e=>({value:e,module:!1})));break}if(r===`-e`||r===`-p`||/^--(?:eval|print|run)(?:=|$)/.test(r)){r.includes(`=`)||n++,d.push(n);continue}let c=r.indexOf(`=`),f=c<0?r:r.slice(0,c);if(r.startsWith(`-r`)&&!r.startsWith(`--`)&&r.length>2)t.push({value:r.slice(2),module:!0});else if(a.has(f)){let a=c<0?e[++n]??``:r.slice(c+1),o=!s&&f===`--test-reporter`&&/^(?:dot|spec|tap)$/.test(a);i.has(f)&&!o&&(!s||f!==`--loader`)&&t.push({value:a,module:!0})}else if(r.startsWith(`-`)){let e=`--no-${f.replace(/^--(?:no-)?/,``)}`,n=!s&&process.allowedNodeEnvironmentFlags.has(f),i=o.has(f)||s&&(f===`--hot`||f===`--no-install`)||n&&process.allowedNodeEnvironmentFlags.has(e);d.length===0&&!i&&!/^--[^=]+=/.test(r)&&(u??={kind:`unclassified`,reason:`unsupported runtime option ${r}`}),c>=0&&!i&&!n&&t.push({value:r.slice(c+1),module:!0})}else if(d.length===0&&r===l)l=void 0;else if(d.length===0){if(!u)return{position:n,operands:t,sourceIndices:d};l=void 0,t.push({value:r,module:!1})}else break}return{position:u??{kind:`other`},operands:t,sourceIndices:u?[]:d}}export{n as a,t as i,isNodeRuntime as n,resolveRuntimeScriptPosition as r,isBunRuntime as t};