mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:51:25 +00:00
refactor(agents): share text block extraction helper
This commit is contained in:
16
src/agents/content-blocks.ts
Normal file
16
src/agents/content-blocks.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export function collectTextContentBlocks(content: unknown): string[] {
|
||||
if (!Array.isArray(content)) {
|
||||
return [];
|
||||
}
|
||||
const parts: string[] = [];
|
||||
for (const block of content) {
|
||||
if (!block || typeof block !== "object") {
|
||||
continue;
|
||||
}
|
||||
const rec = block as { type?: unknown; text?: unknown };
|
||||
if (rec.type === "text" && typeof rec.text === "string") {
|
||||
parts.push(rec.text);
|
||||
}
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
Reference in New Issue
Block a user