mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 16:54:59 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -18,7 +18,9 @@ export const LEGACY_CONFIG_MIGRATIONS_PART_2: LegacyConfigMigration[] = [
|
||||
const agentRoot = getRecord(raw.agent);
|
||||
const defaults = getRecord(getRecord(raw.agents)?.defaults);
|
||||
const agent = agentRoot ?? defaults;
|
||||
if (!agent) return;
|
||||
if (!agent) {
|
||||
return;
|
||||
}
|
||||
const label = agentRoot ? "agent" : "agents.defaults";
|
||||
|
||||
const legacyModel = typeof agent.model === "string" ? String(agent.model) : undefined;
|
||||
@@ -45,7 +47,9 @@ export const LEGACY_CONFIG_MIGRATIONS_PART_2: LegacyConfigMigration[] = [
|
||||
legacyModelFallbacks.length > 0 ||
|
||||
legacyImageModelFallbacks.length > 0 ||
|
||||
Object.keys(legacyAliases).length > 0;
|
||||
if (!hasLegacy) return;
|
||||
if (!hasLegacy) {
|
||||
return;
|
||||
}
|
||||
|
||||
const models =
|
||||
agent.models && typeof agent.models === "object"
|
||||
@@ -53,26 +57,44 @@ export const LEGACY_CONFIG_MIGRATIONS_PART_2: LegacyConfigMigration[] = [
|
||||
: {};
|
||||
|
||||
const ensureModel = (rawKey?: string) => {
|
||||
if (typeof rawKey !== "string") return;
|
||||
if (typeof rawKey !== "string") {
|
||||
return;
|
||||
}
|
||||
const key = rawKey.trim();
|
||||
if (!key) return;
|
||||
if (!models[key]) models[key] = {};
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
if (!models[key]) {
|
||||
models[key] = {};
|
||||
}
|
||||
};
|
||||
|
||||
ensureModel(legacyModel);
|
||||
ensureModel(legacyImageModel);
|
||||
for (const key of legacyAllowed) ensureModel(key);
|
||||
for (const key of legacyModelFallbacks) ensureModel(key);
|
||||
for (const key of legacyImageModelFallbacks) ensureModel(key);
|
||||
for (const key of legacyAllowed) {
|
||||
ensureModel(key);
|
||||
}
|
||||
for (const key of legacyModelFallbacks) {
|
||||
ensureModel(key);
|
||||
}
|
||||
for (const key of legacyImageModelFallbacks) {
|
||||
ensureModel(key);
|
||||
}
|
||||
for (const target of Object.values(legacyAliases)) {
|
||||
if (typeof target !== "string") continue;
|
||||
if (typeof target !== "string") {
|
||||
continue;
|
||||
}
|
||||
ensureModel(target);
|
||||
}
|
||||
|
||||
for (const [alias, targetRaw] of Object.entries(legacyAliases)) {
|
||||
if (typeof targetRaw !== "string") continue;
|
||||
if (typeof targetRaw !== "string") {
|
||||
continue;
|
||||
}
|
||||
const target = targetRaw.trim();
|
||||
if (!target) continue;
|
||||
if (!target) {
|
||||
continue;
|
||||
}
|
||||
const entry =
|
||||
models[target] && typeof models[target] === "object"
|
||||
? (models[target] as Record<string, unknown>)
|
||||
@@ -159,7 +181,9 @@ export const LEGACY_CONFIG_MIGRATIONS_PART_2: LegacyConfigMigration[] = [
|
||||
describe: "Move routing.agents/defaultAgentId to agents.list",
|
||||
apply: (raw, changes) => {
|
||||
const routing = getRecord(raw.routing);
|
||||
if (!routing) return;
|
||||
if (!routing) {
|
||||
return;
|
||||
}
|
||||
|
||||
const routingAgents = getRecord(routing.agents);
|
||||
const agents = ensureRecord(raw, "agents");
|
||||
@@ -169,7 +193,9 @@ export const LEGACY_CONFIG_MIGRATIONS_PART_2: LegacyConfigMigration[] = [
|
||||
for (const [rawId, entryRaw] of Object.entries(routingAgents)) {
|
||||
const agentId = String(rawId ?? "").trim();
|
||||
const entry = getRecord(entryRaw);
|
||||
if (!agentId || !entry) continue;
|
||||
if (!agentId || !entry) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const target = ensureAgentEntry(list, agentId);
|
||||
const entryCopy: Record<string, unknown> = { ...entry };
|
||||
@@ -251,7 +277,9 @@ export const LEGACY_CONFIG_MIGRATIONS_PART_2: LegacyConfigMigration[] = [
|
||||
describe: "Move routing bindings/groupChat/queue/agentToAgent/transcribeAudio",
|
||||
apply: (raw, changes) => {
|
||||
const routing = getRecord(raw.routing);
|
||||
if (!routing) return;
|
||||
if (!routing) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (routing.bindings !== undefined) {
|
||||
if (raw.bindings === undefined) {
|
||||
@@ -362,13 +390,19 @@ export const LEGACY_CONFIG_MIGRATIONS_PART_2: LegacyConfigMigration[] = [
|
||||
changes.push("Removed audio.transcription (tools.media.audio.models already set).");
|
||||
}
|
||||
delete audio.transcription;
|
||||
if (Object.keys(audio).length === 0) delete raw.audio;
|
||||
else raw.audio = audio;
|
||||
if (Object.keys(audio).length === 0) {
|
||||
delete raw.audio;
|
||||
} else {
|
||||
raw.audio = audio;
|
||||
}
|
||||
} else {
|
||||
delete audio.transcription;
|
||||
changes.push("Removed audio.transcription (unsupported transcription CLI).");
|
||||
if (Object.keys(audio).length === 0) delete raw.audio;
|
||||
else raw.audio = audio;
|
||||
if (Object.keys(audio).length === 0) {
|
||||
delete raw.audio;
|
||||
} else {
|
||||
raw.audio = audio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user