test: simplify gateway live profile parsing · openclaw/openclaw@917684d
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -118,10 +118,13 @@ function parseFilter(raw?: string): Set<string> | null {
|
118 | 118 | if (!trimmed || trimmed === "all") { |
119 | 119 | return null; |
120 | 120 | } |
121 | | -const ids = trimmed |
122 | | -.split(",") |
123 | | -.map((s) => s.trim()) |
124 | | -.filter(Boolean); |
| 121 | +const ids: string[] = []; |
| 122 | +for (const rawId of trimmed.split(",")) { |
| 123 | +const id = rawId.trim(); |
| 124 | +if (id.length > 0) { |
| 125 | +ids.push(id); |
| 126 | +} |
| 127 | +} |
125 | 128 | return ids.length ? new Set(ids) : null; |
126 | 129 | } |
127 | 130 | |
@@ -394,7 +397,7 @@ function isMeaningful(text: string): boolean {
|
394 | 397 | if (trimmed.length < 60) { |
395 | 398 | return false; |
396 | 399 | } |
397 | | -const words = trimmed.split(/\s+/g).filter(Boolean); |
| 400 | +const words = trimmed.split(/\s+/g); |
398 | 401 | if (words.length < 12) { |
399 | 402 | return false; |
400 | 403 | } |
@@ -1388,17 +1391,17 @@ function extractTranscriptMessageText(message: unknown): string {
|
1388 | 1391 | if (!Array.isArray(record.content)) { |
1389 | 1392 | return ""; |
1390 | 1393 | } |
1391 | | -return record.content |
1392 | | -.map((entry) => { |
1393 | | -if (!entry || typeof entry !== "object") { |
1394 | | -return ""; |
1395 | | -} |
| 1394 | +const textParts: string[] = []; |
| 1395 | +for (const entry of record.content) { |
| 1396 | +if (entry && typeof entry === "object") { |
1396 | 1397 | const text = (entry as { text?: unknown }).text; |
1397 | | -return typeof text === "string" && text.trim() ? text.trim() : ""; |
1398 | | -}) |
1399 | | -.filter(Boolean) |
1400 | | -.join("\n") |
1401 | | -.trim(); |
| 1398 | +const trimmed = typeof text === "string" ? text.trim() : ""; |
| 1399 | +if (trimmed.length > 0) { |
| 1400 | +textParts.push(trimmed); |
| 1401 | +} |
| 1402 | +} |
| 1403 | +} |
| 1404 | +return textParts.join("\n").trim(); |
1402 | 1405 | } |
1403 | 1406 | |
1404 | 1407 | async function readSessionAssistantTexts(sessionKey: string, modelKey?: string): Promise<string[]> { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。