openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
39 lines (38 loc) • 1.35 kB
JavaScript
import { u as CHAT_CHANNEL_ORDER } from "./registry-C5UkPpaO.js";
import { fileURLToPath } from "node:url";
import fs from "node:fs";
import path from "node:path";
//#region src/cli/channel-options.ts
function dedupe(values) {
const seen = /* @__PURE__ */ new Set();
const resolved = [];
for (const value of values) {
if (!value || seen.has(value)) continue;
seen.add(value);
resolved.push(value);
}
return resolved;
}
let precomputedChannelOptions;
function loadPrecomputedChannelOptions() {
if (precomputedChannelOptions !== void 0) return precomputedChannelOptions;
try {
const metadataPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "cli-startup-metadata.json");
const raw = fs.readFileSync(metadataPath, "utf8");
const parsed = JSON.parse(raw);
if (Array.isArray(parsed.channelOptions)) {
precomputedChannelOptions = dedupe(parsed.channelOptions.filter((value) => typeof value === "string"));
return precomputedChannelOptions;
}
} catch {}
precomputedChannelOptions = null;
return null;
}
function resolveCliChannelOptions() {
return loadPrecomputedChannelOptions() ?? [...CHAT_CHANNEL_ORDER];
}
function formatCliChannelOptions(extra = []) {
return [...extra, ...resolveCliChannelOptions()].join("|");
}
//#endregion
export { resolveCliChannelOptions as n, formatCliChannelOptions as t };