UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

39 lines (38 loc) 1.26 kB
//#region src/security/context-visibility.ts /** Evaluates one supplemental context item against mode, kind, and sender allowlist state. */ function evaluateSupplementalContextVisibility(params) { if (params.mode === "all") return { include: true, reason: "mode_all" }; if (params.senderAllowed) return { include: true, reason: "sender_allowed" }; if (params.mode === "allowlist_quote" && params.kind === "quote") return { include: true, reason: "quote_override" }; return { include: false, reason: "blocked" }; } /** Boolean shorthand for callers that do not need the audit reason. */ function shouldIncludeSupplementalContext(params) { return evaluateSupplementalContextVisibility(params).include; } /** Filters supplemental context items and reports how many were omitted by visibility policy. */ function filterSupplementalContextItems(params) { const items = params.items.filter((item) => shouldIncludeSupplementalContext({ mode: params.mode, kind: params.kind, senderAllowed: params.isSenderAllowed(item) })); return { items, omitted: params.items.length - items.length }; } //#endregion export { filterSupplementalContextItems as n, shouldIncludeSupplementalContext as r, evaluateSupplementalContextVisibility as t };