/**
* Card HTML generation utilities for Panel
*/
import { escapeHtml } from '../utils'
import styles from './Panel.module.css'
type CardType = 'default' | 'input' | 'output' | 'question' | 'observation'
interface CardOptions {
icon: string
content: string | string[]
meta?: string
type?: CardType
}
/** Create a single history card */
export function createCard({ icon, content, meta, type }: CardOptions): string {
const typeClass = type ? styles[type] : ''
const contentHtml = Array.isArray(content)
? `
${content.join('')}
`
: `${escapeHtml(content)}`
return `
${icon}
${contentHtml}
${meta ? `
${meta}
` : ''}
`
}
/** Create reflection lines from reflection object */
export function createReflectionLines(reflection: {
evaluation_previous_goal?: string
memory?: string
next_goal?: string
}): string[] {
const lines: string[] = []
if (reflection.evaluation_previous_goal) {
lines.push(`🔍 ${escapeHtml(reflection.evaluation_previous_goal)}
`)
}
if (reflection.memory) {
lines.push(`💾 ${escapeHtml(reflection.memory)}
`)
}
if (reflection.next_goal) {
lines.push(`🎯 ${escapeHtml(reflection.next_goal)}
`)
}
return lines
}