Skip to content

Documentation / @agentick/shared / ContentBlock

Type Alias: ContentBlock ​

ContentBlock = TextBlock | ImageBlock | DocumentBlock | AudioBlock | VideoBlock | ToolUseBlock | ToolResultBlock | ReasoningBlock | JsonBlock | XmlBlock | CsvBlock | HtmlBlock | CodeBlock | GeneratedImageBlock | GeneratedFileBlock | ExecutableCodeBlock | CodeExecutionResultBlock | UserActionBlock | SystemEventBlock | StateChangeBlock | CustomContentBlock

Defined in: blocks.ts:382

Union of all content block types.

Use the type discriminator field for type narrowing:

Example ​

typescript
function handleBlock(block: ContentBlock) {
  if (block.type === 'text') {
    console.log(block.text);
  } else if (block.type === 'tool_use') {
    console.log(block.name, block.input);
  }
}

See ​

isTextBlock, isToolUseBlock, etc. - Type guard functions

Released under the ISC License.