mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 01:31:08 +00:00
21 lines
634 B
TypeScript
21 lines
634 B
TypeScript
export function normalizeStructuredPromptSection(text: string): string {
|
|
return text
|
|
.replace(/\r\n?/g, "\n")
|
|
.replace(/[ \t]+$/gm, "")
|
|
.trim();
|
|
}
|
|
|
|
export function normalizePromptCapabilityIds(capabilities: ReadonlyArray<string>): string[] {
|
|
const seen = new Set<string>();
|
|
const normalized: string[] = [];
|
|
for (const capability of capabilities) {
|
|
const value = normalizeStructuredPromptSection(capability).toLowerCase();
|
|
if (!value || seen.has(value)) {
|
|
continue;
|
|
}
|
|
seen.add(value);
|
|
normalized.push(value);
|
|
}
|
|
return normalized.toSorted((left, right) => left.localeCompare(right));
|
|
}
|