openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
43 lines (42 loc) • 2.21 kB
JavaScript
import { t as isPlainObject } from "./plain-object-5a0EzLzX.js";
import "./utils-P__uGsPB.js";
import { a as resolveConfiguredTalkRealtimeProviderId, o as resolveConfiguredTalkSpeechProviderId } from "./talk-DRVl_bf5.js";
import { isDeepStrictEqual } from "node:util";
//#region src/gateway/config-diff.ts
/** Return dotted config paths whose values differ between two config snapshots. */
function diffConfigPaths(prev, next, prefix = "", refinementPrefixes = []) {
if (prev === next) return [];
const hasNestedRefinement = refinementPrefixes.some((entry) => prefix ? entry.startsWith(`${prefix}.`) : true);
if (isPlainObject(prev) && isPlainObject(next) || hasNestedRefinement && (isPlainObject(prev) || isPlainObject(next))) {
const prevRecord = isPlainObject(prev) ? prev : {};
const nextRecord = isPlainObject(next) ? next : {};
const keys = /* @__PURE__ */ new Set([...Object.keys(prevRecord), ...Object.keys(nextRecord)]);
const paths = [];
for (const key of keys) {
const prevValue = prevRecord[key];
const nextValue = nextRecord[key];
if (prevValue === void 0 && nextValue === void 0) continue;
const childPaths = diffConfigPaths(prevValue, nextValue, prefix ? `${prefix}.${key}` : key, refinementPrefixes);
if (childPaths.length > 0) paths.push(...childPaths);
}
return paths;
}
if (Array.isArray(prev) && Array.isArray(next)) {
if (isDeepStrictEqual(prev, next)) return [];
}
return [prefix || "<root>"];
}
function projectGatewayReloadBoundaries(config) {
return { talk: {
provider: resolveConfiguredTalkSpeechProviderId(config),
realtime: { provider: resolveConfiguredTalkRealtimeProviderId(config) }
} };
}
/** Preserve declared reload boundaries and derived capability-owner changes. */
function diffGatewayReloadPaths(prevConfig, nextConfig, reloadPrefixes) {
const changedPaths = diffConfigPaths(prevConfig, nextConfig, "", [...reloadPrefixes]);
const boundaryPaths = diffConfigPaths(projectGatewayReloadBoundaries(prevConfig), projectGatewayReloadBoundaries(nextConfig));
return [...changedPaths, ...boundaryPaths.filter((path) => !changedPaths.includes(path))];
}
//#endregion
export { diffGatewayReloadPaths as n, diffConfigPaths as t };