UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

36 lines (35 loc) 1.52 kB
import { r as readConfigMachineState } from "./config-machine-state-BCereLZr.js"; //#region src/hooks/configured.ts /** Capture discovery and explicit selection from one config/install snapshot. */ function resolveInternalHookSelection(config) { const internal = config.hooks?.internal; const installs = readConfigMachineState("hooks.internal.installs"); const names = /* @__PURE__ */ new Set(); const declaredNames = /* @__PURE__ */ new Set(); let open = (internal?.load?.extraDirs ?? []).some((dir) => dir.trim().length > 0); for (const [name, entry] of Object.entries(internal?.entries ?? {})) { const trimmed = name.trim(); if (trimmed) { declaredNames.add(trimmed); if (entry?.enabled !== false) names.add(trimmed); } } for (const [installId, install] of Object.entries(installs ?? {})) { const hookNames = install.hooks ?? []; open ||= hookNames.length === 0 && Boolean(installId.trim()); for (const name of hookNames) { const trimmed = name.trim(); if (trimmed) { declaredNames.add(trimmed); names.add(trimmed); } } } return { configured: internal?.enabled !== false && (internal?.enabled === true || Object.values(internal?.entries ?? {}).some((entry) => entry?.enabled !== false) || open || Object.keys(installs ?? {}).length > 0), names: internal?.enabled === false ? /* @__PURE__ */ new Set() : open || declaredNames.size === 0 && internal?.enabled === true ? null : names, declaredNames }; } //#endregion export { resolveInternalHookSelection as t };