openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
113 lines (112 loc) • 3.43 kB
JavaScript
import { E as hasLegacyAccountStreamingAliases, L as asNullableRecord, a as defineChannelAliasMigration, k as normalizeChannelConfigEntries, n as defineKeyMoveMigration } from "./runtime-doctor-migrations-JGL9tD-z.js";
//#region extensions/googlechat/src/doctor-contract.ts
const streamingAliasMigration = defineChannelAliasMigration({
channelId: "googlechat",
streaming: {
defaultMode: "partial",
deliveryOnly: true
},
accountStreamingInheritsDefaultAccount: true,
dm: {
root: true,
accounts: true
}
});
function hasLegacyGoogleChatStreamMode(e) {
return asNullableRecord(e)?.streamMode !== void 0;
}
function hasRetiredReactions(e) {
return Object.hasOwn(asNullableRecord(asNullableRecord(e)?.actions) ?? {}, "reactions");
}
const groupAllowMigration = defineKeyMoveMigration({
scope: ["groups", "*"],
from: ["allow"],
to: ["enabled"]
});
function normalizeGoogleChatEntry(e) {
let t = e.entry;
let n = false;
if (t.streamMode !== void 0) {
t = { ...t };
delete t.streamMode;
e.changes.push(`Removed ${e.pathPrefix}.streamMode (legacy key no longer used).`);
n = true;
}
if (hasRetiredReactions(t)) {
const r = { ...asNullableRecord(t.actions) };
delete r.reactions;
t = { ...t };
if (Object.keys(r).length > 0) t.actions = r;
else delete t.actions;
e.changes.push(`Removed ${e.pathPrefix}.actions.reactions (Google Chat does not support reactions).`);
n = true;
}
const r = groupAllowMigration.normalize({
...e,
entry: t
});
t = r.entry;
n = n || r.changed;
return {
entry: t,
changed: n
};
}
const legacyConfigRules = [
{
path: ["channels", "googlechat"],
message: "channels.googlechat.actions.reactions is retired and ignored. Run \"openclaw doctor --fix\".",
match: hasRetiredReactions
},
{
path: [
"channels",
"googlechat",
"accounts"
],
message: "channels.googlechat.accounts.<id>.actions.reactions is retired and ignored. Run \"openclaw doctor --fix\".",
match: (e) => hasLegacyAccountStreamingAliases(e, hasRetiredReactions)
},
{
path: ["channels", "googlechat"],
message: "channels.googlechat.streamMode is legacy and no longer used; it is removed on load.",
match: hasLegacyGoogleChatStreamMode
},
{
path: [
"channels",
"googlechat",
"accounts"
],
message: "channels.googlechat.accounts.<id>.streamMode is legacy and no longer used; it is removed on load.",
match: (e) => hasLegacyAccountStreamingAliases(e, hasLegacyGoogleChatStreamMode)
},
{
path: ["channels", "googlechat"],
message: "channels.googlechat.groups.<id>.allow is legacy; use channels.googlechat.groups.<id>.enabled instead. Run \"openclaw doctor --fix\".",
match: groupAllowMigration.hasLegacy
},
{
path: [
"channels",
"googlechat",
"accounts"
],
message: "channels.googlechat.accounts.<id>.groups.<id>.allow is legacy; use channels.googlechat.accounts.<id>.groups.<id>.enabled instead. Run \"openclaw doctor --fix\".",
match: (e) => hasLegacyAccountStreamingAliases(e, groupAllowMigration.hasLegacy)
},
...streamingAliasMigration.legacyConfigRules
];
function normalizeCompatibilityConfig({ cfg: e }) {
const t = normalizeChannelConfigEntries({
cfg: e,
channelId: "googlechat",
normalizeEntry: normalizeGoogleChatEntry
});
return streamingAliasMigration.normalizeChannelConfig({
cfg: t.config,
changes: t.changes
});
}
//#endregion
export { legacyConfigRules, normalizeCompatibilityConfig };