'use client' import { useTranslations } from 'next-intl' import Link from 'next/link' import { Pin, ArrowUpRight } from 'lucide-react' import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' import type { AgentCompetence, AtomTier, FactKind, FactSource } from '@/lib/agent-context/agent-competence' /** * Read-only views of the agent's competence (domain-knowledge atoms) and top * learned facts, for the "Vad din agent vet" overview. Each is a standalone * Card so it can sit in its own tab. Full editable management lives in * /settings/assistant; each links there. */ const TIER_ORDER: AtomTier[] = ['horizontal', 'vertical', 'modifier'] export function CompetenceCard({ competence }: { competence: AgentCompetence }) { const t = useTranslations('agentKnowledge') const { atoms } = competence const activeAtoms = atoms.filter((a) => a.active).length const tierLabel = (tier: AtomTier) => tier === 'horizontal' ? t('tier_horizontal') : tier === 'vertical' ? t('tier_vertical') : t('tier_modifier') return ( {t('comp_title')} {t('comp_desc')} {atoms.length === 0 ? ( {t('comp_empty')} ) : ( <> {TIER_ORDER.map((tier) => { const items = atoms.filter((a) => a.tier === tier) if (items.length === 0) return null return ( {tierLabel(tier)} {items.map((a) => ( {a.title} {!a.active && tier !== 'horizontal' && ( · {t('badge_dormant')} )} ))} ) })} {t('comp_count', { total: atoms.length, active: activeAtoms })} > )} ) } export function FactsCard({ competence }: { competence: AgentCompetence }) { const t = useTranslations('agentKnowledge') const { facts, factsActiveTotal } = competence const kindLabel = (k: FactKind) => k === 'fact' ? t('kind_fact') : k === 'preference' ? t('kind_preference') : k === 'pattern' ? t('kind_pattern') : t('kind_correction') const sourceLabel = (s: FactSource) => s === 'composer' ? t('source_composer') : s === 'user_taught' ? t('source_user_taught') : s === 'agent_learned' ? t('source_agent_learned') : t('source_derived') return ( {t('facts_title')} {t('facts_desc')} {facts.length === 0 ? ( {t('facts_empty')} ) : ( <> {facts.map((f) => ( {f.is_pinned ? ( ) : ( )} {f.content} {kindLabel(f.kind)} · {sourceLabel(f.source)} ))} {factsActiveTotal > facts.length ? t('facts_more', { n: factsActiveTotal - facts.length }) : ''} > )} ) } function ManageLink({ href, label }: { href: string; label: string }) { return ( {label} ) }
{t('comp_empty')}
{t('facts_empty')}
{f.content}
{kindLabel(f.kind)} · {sourceLabel(f.source)}