openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
30 lines (29 loc) • 1.23 kB
JavaScript
import { r as asNullableRecord } from "./record-coerce-CVPuDqcc.mjs";
import { o as resolveChannelDmPolicy } from "./dm-access-l7x6KXfl.mjs";
//#region src/security/audit-open-inbound.ts
/** Resolve configured open scopes once, using the selected channel metadata's DM precedence. */
function listConfiguredOpenInboundPolicyPaths(e, t = []) {
const n = /* @__PURE__ */ new Map();
for (const e of t) {
const t = e.doctorCapabilities?.dmAllowFromMode;
if (t && e.id) for (const r of [e.id, ...e.aliases ?? []]) n.set(r, t);
}
const r = [];
const visit = (e, t, n) => {
const i = asNullableRecord(e);
if (!i) return;
if (i.groupPolicy === "open") r.push(`${t}.groupPolicy`);
if (resolveChannelDmPolicy({
account: i,
mode: n
}) === "open") {
const e = n === "nestedOnly" ? asNullableRecord(i.dm)?.policy != null : i.dmPolicy == null;
r.push(`${t}.${e ? "dm.policy" : "dmPolicy"}`);
}
for (const [e, r] of Object.entries(i)) visit(r, `${t}.${e}`, n);
};
for (const [t, r] of Object.entries(e.channels ?? {})) if (t !== "modelByChannel" && t !== "tools") visit(r, `channels.${t}`, n.get(t) ?? "topOnly");
return r.toSorted();
}
//#endregion
export { listConfiguredOpenInboundPolicyPaths as t };