UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.02 kB
import"./cli-invocation-07_mWkPV.mjs";import{n as resolveRuntimeProcessDistRoot}from"./runtime-process-bootstrap.generated-DjpZOuSR.mjs";import{t as isBunRuntime}from"./runtime-binary-DNstBs1K.mjs";import path from"node:path";import{fileURLToPath,pathToFileURL}from"node:url";import{readRootJsonObjectSync}from"@openclaw/fs-safe/json"; //!src/infra/runtime-worker-url.ts function resolveRuntimeWorkerUrl(e){if(e.root!==void 0)return pathToFileURL(path.join(e.root,`dist`,e.distWorkerPath));const t=fileURLToPath(e.currentModuleUrl);const n=resolveRuntimeProcessDistRoot(t);if(n!==void 0){let t=e.distWorkerPath;if(e.package){const r=path.resolve(n,`..`);const i=readRootJsonObjectSync({rootDir:r,relativePath:`package.json`,boundaryLabel:`runtime worker package`,rejectHardlinks:false});if(!i.ok)throw new Error(`Cannot resolve runtime worker package: ${r}/package.json`);if(i.value.name===e.package.name)t=e.package.distWorkerPath}return pathToFileURL(path.join(n,t))}const r=e.sourceExtension??(path.extname(t)||`.js`);return new URL(`./${e.sourceWorkerName}${r}`,e.currentModuleUrl)}function isBunTargetRuntime(e){return e===process.execPath?Boolean(process.versions.bun):isBunRuntime(e)}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){const n=fileURLToPath(e);return runtimeNeedsTypeScriptLoader(n,t)?[`--import`,import.meta.resolve(`tsx`),n]:[...resolveRuntimeArgs(t),n]}function resolveRuntimeWorkerThreadExecArgv(e,t=process.execPath){if(typeof SEALED_RUNTIME_BUILD===`boolean`&&SEALED_RUNTIME_BUILD)return[];return e.protocol===`file:`&&runtimeNeedsTypeScriptLoader(fileURLToPath(e),t)?[`--import`,import.meta.resolve(`tsx/esm`)]:[]}export{runtimeNeedsTypeScriptLoader as a,resolveRuntimeWorkerUrl as i,resolveRuntimeWorkerArgv as n,resolveRuntimeWorkerThreadExecArgv as r,resolveRuntimeArgs as t};