openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
47 lines (46 loc) • 2.48 kB
JavaScript
import { n as redactConfigSnapshot } from "./redact-snapshot-BahM1-hq.mjs";
import { a as getRuntimeConfigAppliedHash, d as hashRuntimeConfigValue } from "./runtime-snapshot-CifcQ780.mjs";
import { d as getActivePluginRegistryVersion } from "./runtime-zG-NbNbr.mjs";
import { c as readConfigFileSnapshot } from "./io.runtime-FunTy0y1.mjs";
import "./config-B-SAEPyK.mjs";
//#region src/gateway/config-get-response.ts
let configGetResponseCache;
function createConfigGetResponse(snapshot, uiHints, revisionProjector) {
const redacted = redactConfigSnapshot(snapshot, uiHints);
const appliedConfigHash = getRuntimeConfigAppliedHash();
return {
...redacted,
hash: redacted.hash ? revisionProjector.projectRawHash(redacted.hash) : redacted.hash,
configRevisionHash: snapshot.valid ? revisionProjector.projectResolvedHash(hashRuntimeConfigValue(snapshot.sourceConfig)) : null,
appliedConfigHash: appliedConfigHash ? revisionProjector.projectResolvedHash(appliedConfigHash) : null
};
}
/** Reads and projects config.get once per watcher-owned runtime and plugin-schema revision. */
async function readConfigGetResponse(params) {
const readResponse = async () => createConfigGetResponse(await readConfigFileSnapshot(), params.loadUiHints(), params.revisionProjector);
const getHotReloadStatus = params.getHotReloadStatus;
if (!getHotReloadStatus || getHotReloadStatus() !== "active") return readResponse();
const appliedConfigHash = getRuntimeConfigAppliedHash();
const pluginRegistryVersion = getActivePluginRegistryVersion();
if (configGetResponseCache?.getHotReloadStatus === getHotReloadStatus && configGetResponseCache.revisionProjector === params.revisionProjector && configGetResponseCache.appliedConfigHash === appliedConfigHash && configGetResponseCache.pluginRegistryVersion === pluginRegistryVersion) return await configGetResponseCache.promise;
const promise = readResponse();
configGetResponseCache = {
getHotReloadStatus,
revisionProjector: params.revisionProjector,
appliedConfigHash,
pluginRegistryVersion,
promise
};
try {
return await promise;
} catch (error) {
if (configGetResponseCache?.promise === promise) configGetResponseCache = void 0;
throw error;
}
}
/** Invalidates cached config.get work when the watcher observes or accepts a candidate. */
function invalidateConfigGetResponseCache() {
configGetResponseCache = void 0;
}
//#endregion
export { readConfigGetResponse as n, invalidateConfigGetResponseCache as t };