import { type ChangeEvent, type FormEvent, type HTMLAttributes, type Ref, } from "react"; import { Loader2, Send, Wrench } from "lucide-react"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { buildReasoningSteps, getToolTraceSummary, type AgentChatMessage, type AgentReasoningStep, type AgentToolTrace, } from "./agentChatModel"; export type { AgentChatMessage, AgentToolTrace } from "./agentChatModel"; type AgentConversationProps = HTMLAttributes & { messages: AgentChatMessage[]; isSubmitting?: boolean; scrollRef?: Ref; }; type AgentMessageProps = HTMLAttributes & { message: AgentChatMessage; }; type AgentPromptInputProps = { value: string; placeholder: string; disabled: boolean; isSubmitting: boolean; onChange: (value: string) => void; onSubmit: (event: FormEvent) => void; }; export function AgentConversation({ messages, isSubmitting = false, scrollRef, className, ...props }: AgentConversationProps) { return (
{messages.map((message) => ( ))} {isSubmitting && }
); } export function AgentMessage({ message, className, ...props }: AgentMessageProps) { const isUser = message.role === "user"; return (

{isUser ? "User" : "Assistant"}

{message.content}

{!isUser && message.toolTrace && message.toolTrace.length > 0 && ( )}
); } function AgentToolTracePanel({ toolTrace }: { toolTrace: AgentToolTrace[] }) { const steps = buildReasoningSteps(toolTrace); return (
So wurde gearbeitet ({getToolTraceSummary(toolTrace)})
{steps.map((step, stepIndex) => ( ))}
); } function ReasoningStep({ step }: { step: AgentReasoningStep }) { return (

{step.label}

{step.description}

); } function AgentThinkingIndicator() { return (
Denk mit der KI nach...

Antwort wird vorbereitet

Der Agent prueft den aktuellen Finanzkontext.

); } export function AgentPromptInput({ value, placeholder, disabled, isSubmitting, onChange, onSubmit, }: AgentPromptInputProps) { const submitDisabled = disabled || value.trim().length === 0; const handleChange = (event: ChangeEvent) => onChange(event.target.value); return (