refactor: centralize target normalization
This commit is contained in:
@@ -31,12 +31,3 @@ export function isMessagingToolSendAction(
|
||||
if (!plugin?.actions?.extractToolSend) return false;
|
||||
return Boolean(plugin.actions.extractToolSend({ args })?.to);
|
||||
}
|
||||
|
||||
export function normalizeTargetForProvider(provider: string, raw?: string): string | undefined {
|
||||
if (!raw) return undefined;
|
||||
const providerId = normalizeChannelId(provider);
|
||||
const plugin = providerId ? getChannelPlugin(providerId) : undefined;
|
||||
const normalized =
|
||||
plugin?.messaging?.normalizeTarget?.(raw) ?? (raw.trim().toLowerCase() || undefined);
|
||||
return normalized || undefined;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { getChannelPlugin, normalizeChannelId } from "../channels/plugins/index.js";
|
||||
import { truncateUtf16Safe } from "../utils.js";
|
||||
import { type MessagingToolSend, normalizeTargetForProvider } from "./pi-embedded-messaging.js";
|
||||
import { type MessagingToolSend } from "./pi-embedded-messaging.js";
|
||||
import { normalizeTargetForProvider } from "../infra/outbound/target-normalization.js";
|
||||
|
||||
const TOOL_RESULT_MAX_CHARS = 8000;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user