test: simplify subagent reply text collection · openclaw/openclaw@08ecf78
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -44,20 +44,22 @@ vi.mock("./run-wait.js", () => {
|
44 | 44 | continue; |
45 | 45 | } |
46 | 46 | const content = (message as { content?: unknown }).content; |
47 | | -const text = Array.isArray(content) |
48 | | - ? content |
49 | | -.map((block) => |
50 | | -block && |
51 | | -typeof block === "object" && |
52 | | -typeof (block as { text?: unknown }).text === "string" |
53 | | - ? (block as { text: string }).text |
54 | | - : "", |
55 | | -) |
56 | | -.filter(Boolean) |
57 | | -.join("\n") |
58 | | - : typeof content === "string" |
59 | | - ? content |
60 | | - : ""; |
| 47 | +let text = ""; |
| 48 | +if (Array.isArray(content)) { |
| 49 | +const textBlocks: string[] = []; |
| 50 | +for (const block of content) { |
| 51 | +if ( |
| 52 | +block && |
| 53 | +typeof block === "object" && |
| 54 | +typeof (block as { text?: unknown }).text === "string" |
| 55 | +) { |
| 56 | +textBlocks.push((block as { text: string }).text); |
| 57 | +} |
| 58 | +} |
| 59 | +text = textBlocks.join("\n"); |
| 60 | +} else if (typeof content === "string") { |
| 61 | +text = content; |
| 62 | +} |
61 | 63 | if (text.trim()) { |
62 | 64 | return { text, fingerprint: JSON.stringify(message) }; |
63 | 65 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。