UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

48 lines (47 loc) • 2.21 kB
import { i as getRuntimeConfigAppliedHash, j as hashRuntimeConfigValue } from "./runtime-snapshot-WbwbY5b7.mjs"; import { d as getActivePluginRegistryVersion } from "./runtime-ezCEpumg.mjs"; import { s as readConfigFileSnapshot } from "./io.runtime-DsJ2dLCQ.mjs"; import "./config-CMA-J084.mjs"; import { n as redactConfigSnapshot } from "./redact-snapshot-HHllfRSn.mjs"; import { r as loadGatewayConfigRedactionHints } from "./runtime-schema-XjYfZSYY.mjs"; //#region src/gateway/config-get-response.ts let configGetResponseCache; function createConfigGetResponse(e, t, n) { const r = redactConfigSnapshot(e, t); const i = getRuntimeConfigAppliedHash(); return { ...r, hash: r.hash ? n.projectRawHash(r.hash) : r.hash, configRevisionHash: e.valid ? n.projectResolvedHash(hashRuntimeConfigValue(e.sourceConfig)) : null, appliedConfigHash: i ? n.projectResolvedHash(i) : null }; } /** Reads and projects config.get once per watcher-owned runtime and plugin-schema revision. */ async function readConfigGetResponse(e) { const readResponse = async () => createConfigGetResponse(await readConfigFileSnapshot(), loadGatewayConfigRedactionHints(), e.revisionProjector); const t = e.getHotReloadStatus; if (!t || t() !== "active") return readResponse(); const n = getRuntimeConfigAppliedHash(); const r = getActivePluginRegistryVersion(); if (configGetResponseCache?.getHotReloadStatus === t && configGetResponseCache.revisionProjector === e.revisionProjector && configGetResponseCache.appliedConfigHash === n && configGetResponseCache.pluginRegistryVersion === r) return await configGetResponseCache.promise; const i = readResponse(); configGetResponseCache = { getHotReloadStatus: t, revisionProjector: e.revisionProjector, appliedConfigHash: n, pluginRegistryVersion: r, promise: i }; try { return await i; } catch (e) { if (configGetResponseCache?.promise === i) configGetResponseCache = void 0; throw e; } } /** 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 };