import { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Brain, ChevronDown, ChevronUp, Eye, CheckCircle, XCircle } from 'lucide-react'; import type { NegotiationMessage, LabConstraints, Protocol } from '@/types'; import { cn } from '@/lib/utils'; import CharacterAvatar from '@/components/CharacterAvatar'; interface AgentThoughtsProps { messages: NegotiationMessage[]; labConstraints: LabConstraints; protocol: Protocol | null; className?: string; } export default function AgentThoughts({ messages, labConstraints, protocol, className, }: AgentThoughtsProps) { const [expanded, setExpanded] = useState(true); if (messages.length === 0) return null; const lastScientist = [...messages].reverse().find((m) => m.role === 'scientist'); const lastLabManager = [...messages].reverse().find((m) => m.role === 'lab_manager'); return (
{expanded && (
{/* Scientist's reasoning */}
Dr. Elara's Reasoning
{lastScientist ? (
{lastScientist.action_type && (
Strategy: {lastScientist.action_type.replace(/_/g, ' ')}
)}

{lastScientist.message.length > 150 ? lastScientist.message.slice(0, 150) + '...' : lastScientist.message}

{protocol && (
PROPOSED
Samples: {protocol.sample_size} Days: {protocol.duration_days} Tech: {protocol.technique} Controls: {protocol.controls.length}
)}
) : (

Waiting to propose...

)}
{/* Lab Manager's constraint analysis */}
Takuma's Analysis
{lastLabManager ? (
{/* Constraint checks */}
0} detail={`$${labConstraints.budget_remaining.toLocaleString()} remaining`} /> 0} detail={`${labConstraints.equipment_available.length} items available`} /> 0} detail={`${labConstraints.reagents_available.length} in stock`} /> 0} detail={`${labConstraints.staff_count} available`} /> 0 ? `${labConstraints.booking_conflicts.length} conflict(s)` : 'None'} />

{lastLabManager.message.length > 100 ? lastLabManager.message.slice(0, 100) + '...' : lastLabManager.message}

) : (

Waiting for proposal...

)}
)}
); } function ConstraintCheck({ label, ok, detail }: { label: string; ok: boolean; detail: string }) { return (
{ok ? ( ) : ( )} {label} {detail}
); }