fix(config): apply filtered doctor compat at read time
parent
78639eff76
commit
7d54f2a3c2
@ -0,0 +1 @@
|
||||
export { normalizeCompatibilityConfig, legacyConfigRules } from "./src/doctor-contract.js";
|
||||
@ -1,12 +1,32 @@
|
||||
import { resolveChannelPreviewStreamMode } from "openclaw/plugin-sdk/channel-streaming";
|
||||
|
||||
export type DiscordPreviewStreamMode = "off" | "partial" | "block";
|
||||
|
||||
function parsePreviewStreamingMode(value: unknown): DiscordPreviewStreamMode | undefined {
|
||||
return value === "off" || value === "partial" || value === "block" ? value : undefined;
|
||||
}
|
||||
|
||||
export function resolveDiscordPreviewStreamMode(
|
||||
params: {
|
||||
streamMode?: unknown;
|
||||
streaming?: unknown;
|
||||
} = {},
|
||||
): DiscordPreviewStreamMode {
|
||||
return resolveChannelPreviewStreamMode(params, "off");
|
||||
const parsedStreaming =
|
||||
params.streaming && typeof params.streaming === "object" && !Array.isArray(params.streaming)
|
||||
? parsePreviewStreamingMode(
|
||||
(params.streaming as Record<string, unknown>).mode ??
|
||||
(params.streaming as Record<string, unknown>).streaming,
|
||||
)
|
||||
: parsePreviewStreamingMode(params.streaming);
|
||||
if (parsedStreaming) {
|
||||
return parsedStreaming;
|
||||
}
|
||||
|
||||
const legacy = parsePreviewStreamingMode(params.streamMode);
|
||||
if (legacy) {
|
||||
return legacy;
|
||||
}
|
||||
if (typeof params.streaming === "boolean") {
|
||||
return params.streaming ? "partial" : "off";
|
||||
}
|
||||
return "off";
|
||||
}
|
||||
|
||||
@ -1,19 +1,18 @@
|
||||
import { iterateBootstrapChannelPlugins } from "../../../channels/plugins/bootstrap-registry.js";
|
||||
import type { OpenClawConfig } from "../../../config/types.js";
|
||||
import {
|
||||
applyPluginDoctorCompatibilityMigrations,
|
||||
collectRelevantDoctorPluginIds,
|
||||
} from "../../../plugins/doctor-contract-registry.js";
|
||||
|
||||
export function applyChannelDoctorCompatibilityMigrations(cfg: Record<string, unknown>): {
|
||||
next: Record<string, unknown>;
|
||||
changes: string[];
|
||||
} {
|
||||
let nextCfg = cfg as OpenClawConfig & Record<string, unknown>;
|
||||
const changes: string[] = [];
|
||||
for (const plugin of iterateBootstrapChannelPlugins()) {
|
||||
const mutation = plugin.doctor?.normalizeCompatibilityConfig?.({ cfg: nextCfg });
|
||||
if (!mutation || mutation.changes.length === 0) {
|
||||
continue;
|
||||
}
|
||||
nextCfg = mutation.config as OpenClawConfig & Record<string, unknown>;
|
||||
changes.push(...mutation.changes);
|
||||
}
|
||||
return { next: nextCfg, changes };
|
||||
const compat = applyPluginDoctorCompatibilityMigrations(cfg as OpenClawConfig, {
|
||||
pluginIds: collectRelevantDoctorPluginIds(cfg),
|
||||
});
|
||||
return {
|
||||
next: compat.config as OpenClawConfig & Record<string, unknown>,
|
||||
changes: compat.changes,
|
||||
};
|
||||
}
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
import { applyLegacyDoctorMigrations } from "./legacy-config-migrate.js";
|
||||
|
||||
export function applyRuntimeLegacyConfigMigrations(raw: unknown): {
|
||||
next: Record<string, unknown> | null;
|
||||
changes: string[];
|
||||
} {
|
||||
return applyLegacyDoctorMigrations(raw);
|
||||
}
|
||||
Loading…
Reference in New Issue