UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

49 lines (48 loc) • 1.83 kB
import { t as resolveHookKey } from "./frontmatter-CTZaq8xF.mjs"; import { r as shouldIncludeHook } from "./config-DHhSuG97.mjs"; import { n as readHookInstallsAsync } from "./installs-C2M3Yvip.mjs"; //#region src/hooks/configured.ts /** Capture discovery and explicit selection from one config/install snapshot. */ async function resolveInternalHookSelection(e) { const t = e.hooks?.internal; const n = await readHookInstallsAsync(); const r = /* @__PURE__ */ new Set(); const i = /* @__PURE__ */ new Set(); let a = (t?.load?.extraDirs ?? []).some((e) => e.trim().length > 0); for (const [e, n] of Object.entries(t?.entries ?? {})) { const t = e.trim(); if (t) { i.add(t); if (n?.enabled !== false) r.add(t); } } for (const [e, t] of Object.entries(n ?? {})) { const n = t.hooks ?? []; a ||= n.length === 0 && Boolean(e.trim()); for (const e of n) { const t = e.trim(); if (t) { i.add(t); r.add(t); } } } return { configured: t?.enabled !== false && (t?.enabled === true || Object.values(t?.entries ?? {}).some((e) => e?.enabled !== false) || a || Object.keys(n ?? {}).length > 0), names: t?.enabled === false ? /* @__PURE__ */ new Set() : a || i.size === 0 && t?.enabled === true ? null : r, declaredNames: i }; } /** True when an explicit selection names this entry, by hook name or resolved hook key. */ function isHookNameSelected(e, t) { return Boolean(e?.has(t.hook.name) || e?.has(resolveHookKey(t.hook.name, t))); } /** Shared selection and eligibility gate; importing handlers remains the loader's job. */ function isHookLoadable(e) { return (!e.names || isHookNameSelected(e.names, e.entry)) && shouldIncludeHook({ entry: e.entry, config: e.config }); } //#endregion export { isHookNameSelected as n, resolveInternalHookSelection as r, isHookLoadable as t };