mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-16 12:30:49 +00:00
16 lines
504 B
TypeScript
16 lines
504 B
TypeScript
export function extractFirstTextBlock(message: unknown): string | undefined {
|
|
if (!message || typeof message !== "object") {
|
|
return undefined;
|
|
}
|
|
const content = (message as { content?: unknown }).content;
|
|
if (!Array.isArray(content) || content.length === 0) {
|
|
return undefined;
|
|
}
|
|
const first = content[0];
|
|
if (!first || typeof first !== "object") {
|
|
return undefined;
|
|
}
|
|
const text = (first as { text?: unknown }).text;
|
|
return typeof text === "string" ? text : undefined;
|
|
}
|