import type { ACPContent } from '#cli/core/acp'

/**
 * Extract plain text content from ACP message content.
 *
 * The UI rendering pipeline expects a string; non-string parts are ignored.
 */
export function extractTextContent(content: ACPContent | undefined): string {
  if (!content)
    return ''
  if (typeof content === 'string')
    return content
  if (Array.isArray(content))
    return content.map(item => String(item?.text ?? '')).join('')
  return ''
}
