mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-11 06:42:14 +00:00
18 lines
568 B
TypeScript
18 lines
568 B
TypeScript
// Assistant identity helpers normalize assistant identity labels and metadata.
|
|
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
|
|
|
|
/** Normalizes optional assistant identity fields and truncates them to the caller's limit. */
|
|
export function coerceIdentityValue(
|
|
value: string | undefined,
|
|
maxLength: number,
|
|
): string | undefined {
|
|
const trimmed = normalizeOptionalString(value);
|
|
if (!trimmed) {
|
|
return undefined;
|
|
}
|
|
if (trimmed.length <= maxLength) {
|
|
return trimmed;
|
|
}
|
|
return trimmed.slice(0, maxLength);
|
|
}
|