openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
44 lines (43 loc) • 1.65 kB
JavaScript
import { t as asBoolean } from "./boolean-2vRuVafy.mjs";
import { r as asNullableRecord } from "./record-coerce-CVPuDqcc.mjs";
//#region src/config/dangerous-name-matching.ts
/** Returns true only for the explicit dangerous name-matching opt-in flag. */
function isDangerousNameMatchingEnabled(e) {
return e?.dangerouslyAllowNameMatching === true;
}
/** Resolves account-level dangerous name matching, inheriting the provider flag when unset. */
function resolveDangerousNameMatchingEnabled(e) {
return asBoolean(e.accountConfig?.dangerouslyAllowNameMatching) ?? isDangerousNameMatchingEnabled(e.providerConfig);
}
/** Collects provider/account scopes that policy and doctor surfaces can audit. */
function collectProviderDangerousNameMatchingScopes(e, t) {
const n = [];
const r = asNullableRecord(asNullableRecord(e.channels)?.[t]);
if (!r) return n;
const i = `channels.${t}`;
const a = `${i}.dangerouslyAllowNameMatching`;
const o = isDangerousNameMatchingEnabled(r);
n.push({
prefix: i,
account: r,
dangerousNameMatchingEnabled: o,
dangerousFlagPath: a
});
const s = asNullableRecord(r.accounts);
if (!s) return n;
for (const e of Object.keys(s)) {
const t = asNullableRecord(s[e]);
if (!t) continue;
const r = `${i}.accounts.${e}`;
const c = asBoolean(t.dangerouslyAllowNameMatching);
n.push({
prefix: r,
account: t,
dangerousNameMatchingEnabled: c ?? o,
dangerousFlagPath: c == null ? a : `${r}.dangerouslyAllowNameMatching`
});
}
return n;
}
//#endregion
export { isDangerousNameMatchingEnabled as n, resolveDangerousNameMatchingEnabled as r, collectProviderDangerousNameMatchingScopes as t };