openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
36 lines (35 loc) • 1.31 kB
JavaScript
import { n as sanitizeForLog } from "./ansi-CZa2t0Hf.mjs";
import { t as ensureOpenDmPolicyAllowFromWildcard } from "./dm-access-l7x6KXfl.mjs";
import { n as iterateDoctorChannelAccounts, r as getDoctorChannelCapabilities } from "./allowlist-Su3Ie_Ov.mjs";
//#region src/commands/doctor/shared/open-policy-allowfrom.ts
function collectOpenPolicyAllowFromWarnings(e) {
if (e.changes.length === 0) return [];
return [...e.changes.map((e) => sanitizeForLog(e)), `- Run "${e.doctorFixCommand}" to add missing allowFrom wildcards.`];
}
function maybeRepairOpenPolicyAllowFrom(e) {
const t = e.channels;
if (!t || typeof t !== "object") return {
config: e,
changes: []
};
const n = structuredClone(e);
const r = [];
const i = n.channels;
for (const [e, t] of Object.entries(i)) {
if (!t || typeof t !== "object") continue;
const n = getDoctorChannelCapabilities(e);
if (n.openDmRequiresAllowFromWildcard === false) continue;
for (const { account: i, prefix: a } of iterateDoctorChannelAccounts(t, `channels.${e}`)) ensureOpenDmPolicyAllowFromWildcard({
entry: i,
mode: n.dmAllowFromMode,
pathPrefix: a,
changes: r
});
}
return {
config: r.length > 0 ? n : e,
changes: r
};
}
//#endregion
export { maybeRepairOpenPolicyAllowFrom as n, collectOpenPolicyAllowFromWarnings as t };