refactor: dedupe cli lowercase helpers

This commit is contained in:
Peter Steinberger
2026-04-07 17:35:58 +01:00
parent cebfa70277
commit 1a3f141215
28 changed files with 96 additions and 63 deletions

View File

@@ -25,6 +25,7 @@ import { buildOutboundBaseSessionKey } from "../infra/outbound/base-session-key.
import type { OutboundDeliveryResult } from "../infra/outbound/deliver.js";
import type { PluginRuntime } from "../plugins/runtime/types.js";
import type { OpenClawPluginApi } from "../plugins/types.js";
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
export type {
AnyAgentTool,
@@ -237,8 +238,8 @@ export function getChatChannelMeta(id: ChatChannelId): ChannelMeta {
export function stripChannelTargetPrefix(raw: string, ...providers: string[]): string {
const trimmed = raw.trim();
for (const provider of providers) {
const prefix = `${provider.toLowerCase()}:`;
if (trimmed.toLowerCase().startsWith(prefix)) {
const prefix = `${normalizeLowercaseStringOrEmpty(provider)}:`;
if (normalizeLowercaseStringOrEmpty(trimmed).startsWith(prefix)) {
return trimmed.slice(prefix.length).trim();
}
}