openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
80 lines (79 loc) • 2.97 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { i as resolveChannelConfigRecord, n as hasMeaningfulChannelConfigShallow } from "./channel-config-activation-BzEa8FnN.mjs";
import { a as listBundledChannelIdsForPackageState, n as hasBundledChannelPackageState } from "./package-state-probes-BxreN8Qk.mjs";
import { a as getBundledChannelSetupSecrets, i as getBundledChannelSetupPlugin, n as getBundledChannelPlugin, r as getBundledChannelSecrets } from "./bundled-BnH1gY8j.mjs";
//#region src/channels/plugins/merge-plugin-section.ts
function mergeChannelPluginSection(e, t) {
if (e && t && typeof e === "object" && typeof t === "object") {
const n = { ...e };
for (const [e, r] of Object.entries(t)) if (r !== void 0) n[e] = r;
return n;
}
return t ?? e;
}
function mergeChannelPlugins(e, t, n) {
return {
...e,
...t,
meta: mergeChannelPluginSection(e.meta, t.meta),
capabilities: mergeChannelPluginSection(e.capabilities, t.capabilities),
commands: mergeChannelPluginSection(e.commands, t.commands),
doctor: mergeChannelPluginSection(e.doctor, t.doctor),
reload: mergeChannelPluginSection(e.reload, t.reload),
config: mergeChannelPluginSection(e.config, t.config),
...n === "merge" ? { setup: mergeChannelPluginSection(e.setup, t.setup) } : {},
messaging: mergeChannelPluginSection(e.messaging, t.messaging),
actions: mergeChannelPluginSection(e.actions, t.actions),
secrets: mergeChannelPluginSection(e.secrets, t.secrets)
};
}
//#endregion
//#region src/channels/plugins/bootstrap-registry.ts
/**
* Loads a bundled channel plugin for bootstrap, merging runtime and setup artifacts.
*/
function getBootstrapChannelPlugin(e) {
const t = normalizeOptionalString(e);
if (!t) return;
let n;
let r;
try {
n = getBundledChannelPlugin(t);
r = getBundledChannelSetupPlugin(t);
} catch {
return;
}
return n && r ? mergeChannelPlugins(n, r, "override") : r ?? n;
}
/**
* Loads bootstrap secret metadata from bundled runtime and setup artifacts.
*/
function getBootstrapChannelSecrets(e) {
const t = normalizeOptionalString(e);
if (!t) return;
try {
const e = getBundledChannelSecrets(t);
const n = getBundledChannelSetupSecrets(t);
return mergeChannelPluginSection(e, n);
} catch {
return;
}
}
//#endregion
//#region src/config/channel-configured.ts
function isChannelConfigured(e, t, n = process.env) {
if (hasMeaningfulChannelConfigShallow(resolveChannelConfigRecord(e, t), t)) return true;
if (listBundledChannelIdsForPackageState("configuredState").includes(t.trim())) return hasBundledChannelPackageState({
metadataKey: "configuredState",
channelId: t,
cfg: e,
env: n
});
const r = getBootstrapChannelPlugin(t);
return Boolean(r?.config?.hasConfiguredState?.({
cfg: e,
env: n
}));
}
//#endregion
export { mergeChannelPlugins as a, mergeChannelPluginSection as i, getBootstrapChannelPlugin as n, getBootstrapChannelSecrets as r, isChannelConfigured as t };