UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

31 lines (30 loc) 1.39 kB
import { t as isBunRuntime } from "./runtime-binary-Cy5Lhult.js"; import { t as runtimeProcessEntrypoints } from "./runtime-process-entrypoints-CEMkwAJ_.js"; import { fileURLToPath, pathToFileURL } from "node:url"; import path from "node:path"; //#region src/infra/runtime-worker-url.ts /** Resolve a source worker sibling or its stable packaged path under dist. */ function resolveRuntimeWorkerUrl(params) { const currentPath = fileURLToPath(params.currentModuleUrl); const distIndex = currentPath.replaceAll(path.sep, "/").lastIndexOf("/dist/"); if (distIndex >= 0) { const distRoot = currentPath.slice(0, distIndex + 6); return pathToFileURL(path.join(distRoot, params.distWorkerPath)); } const extension = path.extname(currentPath) || ".js"; return new URL(`./${params.sourceWorkerName}${extension}`, params.currentModuleUrl); } function resolveRuntimeWorkerArgv(url, execPath = process.execPath) { const entry = fileURLToPath(url); return /\.[cm]?ts$/.test(entry) && !isBunRuntime(execPath) ? [ "--import", "tsx", entry ] : [entry]; } const sealedEntrypoints = /* @__PURE__ */ new Map(); function resolveRuntimeProcessEntrypointUrl(name) { return sealedEntrypoints.get(name) ?? resolveRuntimeWorkerUrl(runtimeProcessEntrypoints[name]); } //#endregion export { resolveRuntimeWorkerArgv as n, resolveRuntimeWorkerUrl as r, resolveRuntimeProcessEntrypointUrl as t };