Function: serializeBlockToText()
Makaio Framework / ai-adapters-core / serializeBlockToText
Function: serializeBlockToText()
Section titled “Function: serializeBlockToText()”serializeBlockToText(
block):string
Defined in: ../../../adapters/core/src/utils/serialize-block-to-text.ts:25
Serialize a MessageBlock to plain text for contexts where native block rendering is unavailable — for example, media blocks in text positions, or history serialization for providers that only accept string content.
textandreasoningblocks return their content verbatim.tool_callblocks emit a bracketed label followed by JSON-serialized args.tool_outputblocks emit a bracketed label with the call ID and output body.imageanddocumentblocks emit a static placeholder.attachmentblocks emit the display name when present, otherwise the file name.
Parameters
Section titled “Parameters”{ content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; }
The message block to serialize.
Type Literal
Section titled “Type Literal”{ attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; }
The message block to serialize.
attachmentType
Section titled “attachmentType”"file" | "directory" = AttachmentTypeSchema
Whether the attachment is a file or directory
displayName?
Section titled “displayName?”string = ...
Optional human-readable display name override
fileName
Section titled “fileName”string = ...
Original filename with extension (e.g. “api-spec.yaml”) — for display and type inference
filePath
Section titled “filePath”string = ...
Server-side file path — always populated before message reaches adapters
source
Section titled “source”{ data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; } = ContentSourceSchema
Inline content — base64 for binary, raw string for text
"attachment" = ...
Type Literal
Section titled “Type Literal”{ content: string; metadata?: Record<string, unknown>; type: "reasoning"; }
The message block to serialize.
content
Section titled “content”string = ...
metadata?
Section titled “metadata?”Record<string, unknown> = ...
Optional provider/runtime metadata for reasoning blocks.
"reasoning" = ...
Returns
Section titled “Returns”string
Plain-text representation of the block.