import type { OpenClawConfig } from "../../../config/types.openclaw.js"; import { normalizeOptionalString } from "../../../shared/string-coerce.js"; import { sanitizeForLog } from "../../../terminal/ansi.js"; import { resolveAllowFromMode, type AllowFromMode } from "./allow-from-mode.js"; import { asObjectRecord } from "./object.js";
const topAllowFrom = account.allowFrom as Array<string | number> | undefined; const nestedAllowFrom = dm?.allowFrom as Array<string | number> | undefined;
if (hadNestedOpenPolicy) {
account.dmPolicy = "open"; delete dm.policy;
changes.push(`- ${prefix}.dmPolicy: set to "open" (migrated from ${prefix}.dm.policy)`);
}
if (
canCanonicalizeTopLevel &&
!Array.isArray(topAllowFrom) &&
Array.isArray(nestedAllowFrom) &&
hasWildcard(nestedAllowFrom)
) {
account.allowFrom = [...nestedAllowFrom]; delete dm?.allowFrom;
changes.push(
`- ${prefix}.allowFrom: moved ${hasWildcard(nestedAllowFrom) ? "wildcard " : ""}allowlist from ${prefix}.dm.allowFrom`,
);
}
if (dm && Object.keys(dm).length === 0) { delete account.dm;
}
if (mode === "nestedOnly") { if (hasWildcard(nestedAllowFrom)) { return;
} if (dm && Array.isArray(nestedAllowFrom)) {
dm.allowFrom = [...nestedAllowFrom, "*"];
changes.push(`- ${prefix}.dm.allowFrom: added "*" (required by dmPolicy="open")`);
} else { const nextDm = dm ?? {};
nextDm.allowFrom = ["*"];
account.dm = nextDm;
changes.push(`- ${prefix}.dm.allowFrom: set to ["*"] (required by dmPolicy="open")`);
} return;
}
if (mode === "topOrNested") { if (hasWildcard(topAllowFrom) || hasWildcard(nestedAllowFrom)) { return;
} if (Array.isArray(topAllowFrom)) {
account.allowFrom = [...topAllowFrom, "*"];
changes.push(`- ${prefix}.allowFrom: added "*" (required by dmPolicy="open")`);
} elseif (dm && Array.isArray(nestedAllowFrom)) {
dm.allowFrom = [...nestedAllowFrom, "*"];
changes.push(`- ${prefix}.dm.allowFrom: added "*" (required by dmPolicy="open")`);
} else {
account.allowFrom = ["*"];
changes.push(`- ${prefix}.allowFrom: set to ["*"] (required by dmPolicy="open")`);
} return;
}
if (hasWildcard(topAllowFrom)) { return;
} if (Array.isArray(topAllowFrom)) {
account.allowFrom = [...topAllowFrom, "*"];
changes.push(`- ${prefix}.allowFrom: added "*" (required by dmPolicy="open")`);
} else {
account.allowFrom = ["*"];
changes.push(`- ${prefix}.allowFrom: set to ["*"] (required by dmPolicy="open")`);
}
};
const nextChannels = next.channels as Record<string, Record<string, unknown>>; for (const [channelName, channelConfig] of Object.entries(nextChannels)) { if (!channelConfig || typeof channelConfig !== "object") { continue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.