openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
40 lines (39 loc) • 1.38 kB
JavaScript
//#region src/channels/plugins/legacy-state-migration-preview.ts
function buildLegacyMigrationPreview(e) {
if (e.kind === "plugin-state-import") return e.preview ?? `- ${e.label}: ${e.sourcePath}`;
return `- ${e.label}: ${e.sourcePath} → ${e.targetPath}`;
}
//#endregion
//#region src/plugin-sdk/doctor-migration-plan-adapter.ts
/** Adapts legacy channel migration plans to the canonical plugin doctor contract. */
function definePluginDoctorMigrationFromPlans(e) {
const resolvePlans = async (t) => {
const n = await e.resolvePlans({
cfg: t.config,
env: t.env,
stateDir: t.stateDir,
oauthDir: t.oauthDir
}) ?? [];
return Array.from(n, (e) => e.kind === "plugin-state-import" && !e.stateDir ? {
...e,
stateDir: t.stateDir
} : e);
};
return {
id: e.id,
label: e.label,
...e.doctorOnly === true ? { doctorOnly: true } : {},
collectBackupResources: e.collectBackupResources,
async detectLegacyState(e) {
const t = await resolvePlans(e);
return t.length > 0 ? { preview: t.map((e) => buildLegacyMigrationPreview(e)) } : null;
},
async migrateLegacyState(e) {
const t = await resolvePlans(e);
const { runLegacyMigrationPlans: n } = await import("./state-migrations.plugin-state-BaY7fB3y.mjs");
return await n(t);
}
};
}
//#endregion
export { buildLegacyMigrationPreview as n, definePluginDoctorMigrationFromPlans as t };