perf: avoid plugin index for target normalization

This commit is contained in:
Peter Steinberger
2026-04-11 06:48:38 +01:00
parent ddefce3c18
commit 455535a4f9
2 changed files with 7 additions and 3 deletions

View File

@@ -15,8 +15,11 @@ let resolveNormalizedTargetInput: TargetNormalizationModule["resolveNormalizedTa
let normalizeTargetForProvider: TargetNormalizationModule["normalizeTargetForProvider"];
let resetTargetNormalizerCacheForTests: TargetNormalizationModule["__testing"]["resetTargetNormalizerCacheForTests"];
vi.mock("../../channels/registry.js", () => ({
normalizeAnyChannelId: (...args: unknown[]) => normalizeChannelIdMock(...args),
}));
vi.mock("../../channels/plugins/index.js", () => ({
normalizeChannelId: (...args: unknown[]) => normalizeChannelIdMock(...args),
getChannelPlugin: (...args: unknown[]) => getChannelPluginMock(...args),
}));

View File

@@ -1,5 +1,6 @@
import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
import { getChannelPlugin } from "../../channels/plugins/index.js";
import type { ChannelDirectoryEntryKind, ChannelId } from "../../channels/plugins/types.js";
import { normalizeAnyChannelId } from "../../channels/registry.js";
import type { OpenClawConfig } from "../../config/config.js";
import { getActivePluginChannelRegistryVersion } from "../../plugins/runtime.js";
import { normalizeOptionalString } from "../../shared/string-coerce.js";
@@ -47,7 +48,7 @@ export function normalizeTargetForProvider(provider: string, raw?: string): stri
if (!fallback) {
return undefined;
}
const providerId = normalizeChannelId(provider);
const providerId = normalizeAnyChannelId(provider);
const normalizer = providerId ? resolveTargetNormalizer(providerId) : undefined;
return normalizeOptionalString(normalizer?.(raw) ?? fallback);
}