UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 1.86 kB
import"./plugin-model-catalog-read.worker-cli-invocation-DL76jDxC.mjs";import{t as e}from"./plugin-model-catalog-read.worker-runtime-binary-DvOoTd1n.mjs";import t from"node:path";import{fileURLToPath as n,pathToFileURL as r}from"node:url";import{readRootJsonObjectSync as i}from"@openclaw/fs-safe/json";resolveRuntimeProcessDistRoot(n(import.meta.url));function resolveRuntimeProcessDistRoot(e){let n=e.replaceAll(t.sep,`/`).lastIndexOf(`/dist/`);return n>=0?e.slice(0,n+6):void 0}function resolveRuntimeWorkerUrl(e){if(e.root!==void 0)return r(t.join(e.root,`dist`,e.distWorkerPath));let a=n(e.currentModuleUrl),o=resolveRuntimeProcessDistRoot(a);if(o!==void 0){let n=e.distWorkerPath;if(e.package){let r=t.resolve(o,`..`),a=i({rootDir:r,relativePath:`package.json`,boundaryLabel:`runtime worker package`,rejectHardlinks:!1});if(!a.ok)throw Error(`Cannot resolve runtime worker package: ${r}/package.json`);a.value.name===e.package.name&&(n=e.package.distWorkerPath)}return r(t.join(o,n))}let s=e.sourceExtension??(t.extname(a)||`.js`);return new URL(`./${e.sourceWorkerName}${s}`,e.currentModuleUrl)}function isBunTargetRuntime(t){return t===process.execPath?!!process.versions.bun:e(t)}function resolveRuntimeArgs(e=process.execPath){return isBunTargetRuntime(e)?[`--no-install`]:[]}function runtimeNeedsTypeScriptLoader(e,t=process.execPath){return/\.[cm]?ts$/.test(e)&&!isBunTargetRuntime(t)}function resolveRuntimeWorkerArgv(e,t=process.execPath){let r=n(e);return runtimeNeedsTypeScriptLoader(r,t)?[`--import`,import.meta.resolve(`tsx`),r]:[...resolveRuntimeArgs(t),r]}function resolveRuntimeWorkerThreadExecArgv(e,t=process.execPath){return e.protocol===`file:`&&runtimeNeedsTypeScriptLoader(n(e),t)?[`--import`,import.meta.resolve(`tsx/esm`)]:[]}export{resolveRuntimeWorkerThreadExecArgv as n,resolveRuntimeWorkerUrl as r,resolveRuntimeWorkerArgv as t};