openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
27 lines (26 loc) • 1.59 kB
JavaScript
import { o as runtimeProcessExternalPackageEntrypoints, s as runtimeProcessGatewayEntrypointNames } from "./runtime-process-manifest-DmUAODRC.mjs";
import { l as pathExists } from "./utils-C8YECn2Q.mjs";
import { r as resolveExternalPackageRuntimeEntrypointUrl } from "./runtime-process-url-CoHTemu-.mjs";
import { fileURLToPath } from "node:url";
import path from "node:path";
//#region src/daemon/gateway-entrypoint.ts
const GATEWAY_DIST_ENTRYPOINT_BASENAMES = runtimeProcessGatewayEntrypointNames.map((e) => path.basename(runtimeProcessExternalPackageEntrypoints[e]));
function isGatewayDistEntrypointPath(e) {
return /[/\\]dist[/\\].+\.(cjs|js|mjs)$/.test(e);
}
function buildGatewayInstallEntrypointCandidates(e) {
if (!e) return [];
return runtimeProcessGatewayEntrypointNames.map((t) => fileURLToPath(resolveExternalPackageRuntimeEntrypointUrl(t, e)));
}
function buildGatewayDistEntrypointCandidates(...e) {
const t = new Set(e.filter(isGatewayDistEntrypointPath).map(path.dirname));
return GATEWAY_DIST_ENTRYPOINT_BASENAMES.flatMap((e) => Array.from(t, (t) => path.join(t, e)));
}
async function findFirstAccessibleGatewayEntrypoint(e, t = pathExists) {
for (const n of e) if (await t(n)) return n;
}
async function resolveGatewayInstallEntrypoint(e) {
return findFirstAccessibleGatewayEntrypoint(buildGatewayInstallEntrypointCandidates(e));
}
//#endregion
export { resolveGatewayInstallEntrypoint as a, isGatewayDistEntrypointPath as i, buildGatewayInstallEntrypointCandidates as n, findFirstAccessibleGatewayEntrypoint as r, buildGatewayDistEntrypointCandidates as t };