feat(plugins): merge openai vendor seams into one plugin

This commit is contained in:
Peter Steinberger
2026-03-15 17:50:16 -07:00
parent bc5054ce68
commit b54e37c71f
26 changed files with 833 additions and 548 deletions

View File

@@ -40,7 +40,6 @@ export const BUNDLED_ENABLED_BY_DEFAULT = new Set<string>([
"nvidia",
"ollama",
"openai",
"openai-codex",
"opencode",
"opencode-go",
"openrouter",
@@ -59,11 +58,22 @@ export const BUNDLED_ENABLED_BY_DEFAULT = new Set<string>([
"zai",
]);
const PLUGIN_ID_ALIASES: Readonly<Record<string, string>> = {
"openai-codex": "openai",
};
function normalizePluginId(id: string): string {
const trimmed = id.trim();
return PLUGIN_ID_ALIASES[trimmed] ?? trimmed;
}
const normalizeList = (value: unknown): string[] => {
if (!Array.isArray(value)) {
return [];
}
return value.map((entry) => (typeof entry === "string" ? entry.trim() : "")).filter(Boolean);
return value
.map((entry) => (typeof entry === "string" ? normalizePluginId(entry) : ""))
.filter(Boolean);
};
const normalizeSlotValue = (value: unknown): string | null | undefined => {
@@ -86,11 +96,12 @@ const normalizePluginEntries = (entries: unknown): NormalizedPluginsConfig["entr
}
const normalized: NormalizedPluginsConfig["entries"] = {};
for (const [key, value] of Object.entries(entries)) {
if (!key.trim()) {
const normalizedKey = normalizePluginId(key);
if (!normalizedKey) {
continue;
}
if (!value || typeof value !== "object" || Array.isArray(value)) {
normalized[key] = {};
normalized[normalizedKey] = {};
continue;
}
const entry = value as Record<string, unknown>;
@@ -108,10 +119,12 @@ const normalizePluginEntries = (entries: unknown): NormalizedPluginsConfig["entr
allowPromptInjection: hooks.allowPromptInjection,
}
: undefined;
normalized[key] = {
enabled: typeof entry.enabled === "boolean" ? entry.enabled : undefined,
hooks: normalizedHooks,
config: "config" in entry ? entry.config : undefined,
normalized[normalizedKey] = {
...normalized[normalizedKey],
enabled:
typeof entry.enabled === "boolean" ? entry.enabled : normalized[normalizedKey]?.enabled,
hooks: normalizedHooks ?? normalized[normalizedKey]?.hooks,
config: "config" in entry ? entry.config : normalized[normalizedKey]?.config,
};
}
return normalized;