openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
23 lines (22 loc) • 850 B
JavaScript
//#region src/channels/command-gating.ts
/** Resolves whether any configured authorizer permits a control command. */
function resolveCommandAuthorizedFromAuthorizers(e) {
const { useAccessGroups: t, authorizers: n } = e;
const r = e.modeWhenAccessGroupsOff ?? "allow";
if (!t) {
if (r === "allow") return true;
if (r === "deny") return false;
if (!n.some((e) => e.configured)) return true;
}
return n.some((e) => e.configured && e.allowed);
}
/** Resolves command authorization and whether the current text command should be blocked. */
function resolveControlCommandGate(e) {
const t = resolveCommandAuthorizedFromAuthorizers(e);
return {
commandAuthorized: t,
shouldBlock: e.allowTextCommands && e.hasControlCommand && !t
};
}
//#endregion
export { resolveControlCommandGate as n, resolveCommandAuthorizedFromAuthorizers as t };