mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 18:51:04 +00:00
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import type { ChannelDoctorLegacyConfigRule } from "openclaw/plugin-sdk/channel-contract";
|
|
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
|
import { isRecord } from "openclaw/plugin-sdk/text-runtime";
|
|
import { ELEVENLABS_TALK_PROVIDER_ID, migrateElevenLabsLegacyTalkConfig } from "./config-compat.js";
|
|
|
|
export function hasLegacyTalkFields(value: unknown): boolean {
|
|
const talk = isRecord(value) ? value : null;
|
|
if (!talk) {
|
|
return false;
|
|
}
|
|
return ["voiceId", "voiceAliases", "modelId", "outputFormat", "apiKey"].some((key) =>
|
|
Object.prototype.hasOwnProperty.call(talk, key),
|
|
);
|
|
}
|
|
|
|
export const legacyConfigRules: ChannelDoctorLegacyConfigRule[] = [
|
|
{
|
|
path: ["talk"],
|
|
message:
|
|
"talk.voiceId/talk.voiceAliases/talk.modelId/talk.outputFormat/talk.apiKey are legacy; use talk.providers.<provider> and run openclaw doctor --fix.",
|
|
match: hasLegacyTalkFields,
|
|
},
|
|
];
|
|
|
|
export const ELEVENLABS_TALK_LEGACY_CONFIG_RULES = legacyConfigRules;
|
|
|
|
export function normalizeCompatibilityConfig({ cfg }: { cfg: OpenClawConfig }): {
|
|
config: OpenClawConfig;
|
|
changes: string[];
|
|
} {
|
|
return migrateElevenLabsLegacyTalkConfig(cfg);
|
|
}
|
|
|
|
export { ELEVENLABS_TALK_PROVIDER_ID };
|