refactor(omo): deduplicate OMO/OMO Slim via OmoVariant parameterization

Introduce OmoVariant struct with STANDARD/SLIM constants to eliminate
~250 lines of copy-pasted code across DAO, service, commands, and
frontend layers. Adding a new OMO variant now requires only a single
const declaration instead of duplicating ~400 lines.
This commit is contained in:
Jason
2026-02-19 21:11:58 +08:00
parent 8e219b5eb1
commit 1b71dc721c
10 changed files with 493 additions and 741 deletions
@@ -1,6 +1,5 @@
import type { OpenCodeModel, OpenCodeProviderConfig } from "@/types";
import type { OmoGlobalConfig } from "@/types/omo";
import { parseOmoOtherFieldsObject } from "@/types/omo";
import type { PricingModelSourceOption } from "../ProviderAdvancedConfig";
// ── Default configs ──────────────────────────────────────────────────
@@ -132,28 +131,7 @@ export function toOpencodeExtraOptions(
return extra;
}
export function buildOmoProfilePreview(
agents: Record<string, Record<string, unknown>>,
categories: Record<string, Record<string, unknown>>,
otherFieldsStr: string,
): Record<string, unknown> {
const profileOnly: Record<string, unknown> = {};
if (Object.keys(agents).length > 0) {
profileOnly.agents = agents;
}
if (Object.keys(categories).length > 0) {
profileOnly.categories = categories;
}
if (otherFieldsStr.trim()) {
try {
const other = parseOmoOtherFieldsObject(otherFieldsStr);
if (other) {
Object.assign(profileOnly, other);
}
} catch {}
}
return profileOnly;
}
export { buildOmoProfilePreview } from "@/types/omo";
export const normalizePricingSource = (
value?: string,