@optilogic/chat 1.3.4 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/agent-response/components/ActivityIndicators.tsx","../src/components/agent-response/utils.ts","../src/components/agent-response/components/MetadataRow.tsx","../src/components/agent-response/components/ThinkingSection.tsx","../src/components/agent-response/components/ActionBar.tsx","../src/components/hitl-interactions/HITLQuestionPanel.tsx","../src/components/hitl-interactions/HITLInteractionRecord.tsx","../src/components/agent-response/components/HITLSection.tsx","../src/components/agent-response/components/TruncatedMessage.tsx","../src/components/agent-response/hooks/useThinkingTimer.ts","../src/components/agent-response/types.ts","../src/components/agent-timeline/utils.ts","../src/components/agent-response/reducer.ts","../src/components/agent-response/hooks/useAgentResponseAccumulator.ts","../src/components/agent-timeline/TimelineItem.tsx","../src/components/agent-timeline/TimelineAgentBlock.tsx","../src/components/agent-timeline/AgentTimeline.tsx","../src/components/agent-response/AgentResponse.tsx","../src/components/user-prompt/UserPrompt.tsx","../src/components/user-prompt-input/UserPromptInput.tsx","../src/components/inline-actions/parseResponseSegments.ts","../src/components/inline-actions/ActionMarkdownRenderer.tsx","../src/components/inline-actions/prompts.ts"],"names":["React","jsxs","cn","Popover","jsx","PopoverTrigger","Activity","PopoverContent","Wrench","Book","HardDrive","React2","ChevronUp","ChevronDown","LoadingSpinner","useState","useCallback","ChevronRight","React3","React4","Check","Copy","ThumbsUp","ThumbsDown","React5","useRef","useEffect","useMemo","formatTime","Button","Textarea","React6","React7","MessageCircleQuestion","React8","thinkingStartTime","next","Brain","BookOpen","MessageSquare","AlertCircle","Fragment","ChevronsDownUp","ChevronsUpDown","React9","React10","Text","React11","SlateEditor","Tooltip","IconButton","Square","Loader2","Send"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAM,kBAAA,GAA2BA,kBAAA,CAAA,UAAA;AAAA,EAC/B,CAAC,EAAE,SA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;AAGA,IAAA,MAAM,SAAA,GAAY,QAAA,CAAS,OAAA,CAAQ,UAAU,CAAA;AAC7C,IAAA,IAAI,CAAC,SAAA,EAAW;AAEd,MAAA,uBACEA,cAAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UAEC,SAAA,EAAU,qFAAA;AAAA,UAEV,QAAA,kBAAAA,eAAC,MAAA,EAAA,EAAM,QAAA,EAAA,IAAA,CAAK,UAAU,OAAA,CAAQ,OAAA,EAAS,IAAA,EAAM,CAAC,CAAA,EAAE;AAAA,SAAA;AAAA,QAH3C,mBAAmB,KAAK,CAAA;AAAA,OAI/B;AAAA,IAEJ;AAEA,IAAA,uBACEA,cAAAA;AAAA,MAAC,SAAA;AAAA,MAAA;AAAA,QAEC,SAAS,OAAA,CAAQ,OAAA;AAAA,QACjB,QAAA;AAAA,QACA;AAAA,OAAA;AAAA,MAHK,CAAA,OAAA,EAAU,OAAA,CAAQ,UAAU,CAAA,CAAA,EAAI,KAAK,CAAA;AAAA,KAI5C;AAAA,EAEJ,CAAC,CAAA,EACH,CAAA;AAEJ;;;AClDO,IAAM,oBAAA,GAAuB;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","file":"index.cjs","sourcesContent":["/**\n * Activity Indicators Component\n *\n * Displays tool, knowledge, memory icons with counts and popovers\n */\n\nimport * as React from \"react\";\nimport { Wrench, Book, HardDrive, Activity } from \"lucide-react\";\nimport { cn, Popover, PopoverTrigger, PopoverContent } from \"@optilogic/core\";\nimport type { ToolCall, KnowledgeItem, MemoryItem, StatusItem } from \"../types\";\n\nexport interface ActivityIndicatorsProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Tool calls to display */\n toolCalls: ToolCall[];\n /** Knowledge items to display */\n knowledge: KnowledgeItem[];\n /** Memory items to display */\n memory: MemoryItem[];\n /** Status updates to display */\n statusUpdates?: StatusItem[];\n}\n\n/**\n * ActivityIndicators Component\n *\n * Displays icons with counts for tool calls, knowledge retrieval, and memory access.\n * Each icon has a popover showing details when clicked.\n *\n * @example\n * <ActivityIndicators\n * toolCalls={state.toolCalls}\n * knowledge={state.knowledge}\n * memory={state.memory}\n * />\n */\nconst ActivityIndicators = React.forwardRef<HTMLDivElement, ActivityIndicatorsProps>(\n ({ toolCalls, knowledge, memory, statusUpdates = [], className, ...props }, ref) => {\n const hasAnyActivity =\n toolCalls.length > 0 || knowledge.length > 0 || memory.length > 0 || statusUpdates.length > 0;\n\n if (!hasAnyActivity) return null;\n\n return (\n <div ref={ref} className={cn(\"flex items-center gap-2\", className)} {...props}>\n {/* Status Updates */}\n {statusUpdates.length > 0 && (\n <Popover>\n <PopoverTrigger asChild>\n <button\n className=\"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors\"\n onClick={(e) => e.stopPropagation()}\n >\n <Activity className=\"w-3.5 h-3.5\" />\n <span className=\"text-xs\">{statusUpdates.length}</span>\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-80\">\n <div className=\"space-y-2\">\n <h4 className=\"font-medium text-sm\">Status Updates</h4>\n <div className=\"space-y-2 max-h-60 overflow-auto\">\n {statusUpdates.map((item) => (\n <div key={item.id} className=\"p-2 bg-muted rounded text-xs\">\n {item.agent && (\n <div className=\"font-medium text-muted-foreground\">{item.agent}</div>\n )}\n <div className={item.agent ? \"mt-1\" : \"\"}>{item.message}</div>\n </div>\n ))}\n </div>\n </div>\n </PopoverContent>\n </Popover>\n )}\n\n {/* Tool Calls */}\n {toolCalls.length > 0 && (\n <Popover>\n <PopoverTrigger asChild>\n <button\n className=\"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors\"\n onClick={(e) => e.stopPropagation()}\n >\n <Wrench className=\"w-3.5 h-3.5\" />\n <span className=\"text-xs\">{toolCalls.length}</span>\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-80\">\n <div className=\"space-y-2\">\n <h4 className=\"font-medium text-sm\">Tool Calls</h4>\n <div className=\"space-y-2 max-h-60 overflow-auto\">\n {toolCalls.map((tool) => (\n <div key={tool.id} className=\"p-2 bg-muted rounded text-xs\">\n <div className=\"font-medium\">{tool.name}</div>\n {tool.arguments && (\n <pre className=\"mt-1 text-muted-foreground overflow-x-auto\">\n {JSON.stringify(tool.arguments, null, 2)}\n </pre>\n )}\n </div>\n ))}\n </div>\n </div>\n </PopoverContent>\n </Popover>\n )}\n\n {/* Knowledge */}\n {knowledge.length > 0 && (\n <Popover>\n <PopoverTrigger asChild>\n <button\n className=\"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors\"\n onClick={(e) => e.stopPropagation()}\n >\n <Book className=\"w-3.5 h-3.5\" />\n <span className=\"text-xs\">{knowledge.length}</span>\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-80\">\n <div className=\"space-y-2\">\n <h4 className=\"font-medium text-sm\">Knowledge Retrieved</h4>\n <div className=\"space-y-2 max-h-60 overflow-auto\">\n {knowledge.map((item) => (\n <div key={item.id} className=\"p-2 bg-muted rounded text-xs\">\n <div className=\"font-medium\">{item.source}</div>\n <div className=\"mt-1 text-muted-foreground\">\n {item.content}\n </div>\n </div>\n ))}\n </div>\n </div>\n </PopoverContent>\n </Popover>\n )}\n\n {/* Memory */}\n {memory.length > 0 && (\n <Popover>\n <PopoverTrigger asChild>\n <button\n className=\"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors\"\n onClick={(e) => e.stopPropagation()}\n >\n <HardDrive className=\"w-3.5 h-3.5\" />\n <span className=\"text-xs\">{memory.length}</span>\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-80\">\n <div className=\"space-y-2\">\n <h4 className=\"font-medium text-sm\">Memory Accessed</h4>\n <div className=\"space-y-2 max-h-60 overflow-auto\">\n {memory.map((item) => (\n <div key={item.id} className=\"p-2 bg-muted rounded text-xs\">\n <div className=\"font-medium\">{item.type}</div>\n <div className=\"mt-1 text-muted-foreground\">\n {item.content}\n </div>\n </div>\n ))}\n </div>\n </div>\n </PopoverContent>\n </Popover>\n )}\n </div>\n );\n }\n);\nActivityIndicators.displayName = \"ActivityIndicators\";\n\nexport { ActivityIndicators };\n","/**\n * Agent Response Utility Functions\n */\n\n/**\n * Format elapsed time for display\n * - Under 60s: \"Xs\" (e.g., \"23s\")\n * - 60+ seconds while active: \"M:SS\" (e.g., \"1:23\")\n * - Complete under 60s: \"Xs\" (e.g., \"45s\")\n * - Complete 60-119s: \"1.X min\" (e.g., \"1.2 min\")\n * - Complete 120+ s: \"X.X min\" (e.g., \"2.5 min\")\n */\nexport function formatTime(seconds: number, isComplete: boolean): string {\n if (seconds < 1) {\n return isComplete ? \"<1s\" : \"0s\";\n }\n\n if (isComplete) {\n // Completed state formatting\n if (seconds < 60) {\n return `${Math.round(seconds)}s`;\n }\n const minutes = seconds / 60;\n return `${minutes.toFixed(1)} min`;\n }\n\n // Active state formatting\n if (seconds < 60) {\n return `${Math.floor(seconds)}s`;\n }\n const mins = Math.floor(seconds / 60);\n const secs = Math.floor(seconds % 60);\n return `${mins}:${secs.toString().padStart(2, \"0\")}`;\n}\n\n/**\n * Format total time for action bar display\n */\nexport function formatTotalTime(seconds: number): string {\n if (seconds < 1) {\n return \"<1s\";\n }\n if (seconds < 60) {\n return `${seconds.toFixed(1)}s`;\n }\n const minutes = seconds / 60;\n return `${minutes.toFixed(1)}m`;\n}\n","/**\n * Metadata Row Component\n *\n * Displays thinking toggle, timer, and activity indicators\n */\n\nimport * as React from \"react\";\nimport { ChevronDown, ChevronUp } from \"lucide-react\";\nimport { cn, LoadingSpinner } from \"@optilogic/core\";\nimport { ActivityIndicators } from \"./ActivityIndicators\";\nimport { formatTime } from \"../utils\";\nimport type { AgentResponseStatus, ToolCall, KnowledgeItem, MemoryItem, StatusItem } from \"../types\";\n\nexport interface MetadataRowProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Whether there is thinking content */\n hasThinking: boolean;\n /** Whether the thinking section is expanded */\n isExpanded: boolean;\n /** Toggle callback for thinking expansion */\n onToggle: () => void;\n /** Tool calls to display */\n toolCalls: ToolCall[];\n /** Knowledge items to display */\n knowledge: KnowledgeItem[];\n /** Memory items to display */\n memory: MemoryItem[];\n /** Status updates to display */\n statusUpdates?: StatusItem[];\n /** Optional content to display in the middle area between left content and activity indicators */\n statusContent?: React.ReactNode;\n /** Current response status */\n status: AgentResponseStatus;\n /** Elapsed time in seconds */\n elapsedTime: number;\n}\n\n/**\n * MetadataRow Component\n *\n * Displays the metadata row with thinking toggle, timer, and activity indicators.\n * When thinking content is present, the row is clickable to toggle expansion.\n *\n * @example\n * <MetadataRow\n * hasThinking={!!state.thinking}\n * isExpanded={thinkingExpanded}\n * onToggle={toggleThinking}\n * toolCalls={state.toolCalls}\n * knowledge={state.knowledge}\n * memory={state.memory}\n * status={state.status}\n * elapsedTime={elapsedTime}\n * />\n */\nconst MetadataRow = React.forwardRef<HTMLDivElement, MetadataRowProps>(\n (\n {\n hasThinking,\n isExpanded,\n onToggle,\n toolCalls,\n knowledge,\n memory,\n statusUpdates = [],\n statusContent,\n status,\n elapsedTime,\n className,\n ...props\n },\n ref\n ) => {\n const isProcessing = status === \"processing\";\n const isComplete = status === \"complete\";\n const hasActivity =\n toolCalls.length > 0 || knowledge.length > 0 || memory.length > 0 || statusUpdates.length > 0;\n\n // Determine what to show on the left side\n const renderLeftContent = () => {\n // If we have thinking text, show collapse toggle + label + timer\n if (hasThinking) {\n return (\n <div className=\"flex items-center gap-1.5\">\n {isExpanded ? (\n <ChevronUp className=\"w-3.5 h-3.5 text-muted-foreground\" />\n ) : (\n <ChevronDown className=\"w-3.5 h-3.5 text-muted-foreground\" />\n )}\n <span className=\"text-xs text-muted-foreground\">\n {isComplete\n ? `Thought for ${formatTime(elapsedTime, true)}`\n : `Thinking... ${formatTime(elapsedTime, false)}`}\n </span>\n </div>\n );\n }\n\n // If processing but no thinking text yet, show spinner\n if (isProcessing) {\n return (\n <div className=\"flex items-center gap-1.5\">\n <LoadingSpinner size=\"sm\" variant=\"muted\" className=\"w-3.5 h-3.5\" />\n <span className=\"text-xs text-muted-foreground\">Processing</span>\n </div>\n );\n }\n\n // Complete with no thinking - show nothing on left (just activity on right)\n return null;\n };\n\n const leftContent = renderLeftContent();\n\n // If nothing to show (no thinking, not processing, no activity, no status content), hide the row\n if (!leftContent && !hasActivity && !statusContent) {\n return null;\n }\n\n // Always use a div for the row to avoid nesting buttons\n // When there's thinking, only the left side is clickable\n return (\n <div\n ref={ref}\n className={cn(\"w-full flex items-center justify-between px-3 py-2\", className)}\n {...props}\n >\n {/* Left content - clickable when there's thinking */}\n {hasThinking ? (\n <button\n onClick={onToggle}\n className=\"flex items-center gap-1.5 hover:bg-muted/50 -ml-1.5 pl-1.5 pr-2 py-0.5 rounded transition-colors shrink-0\"\n >\n {leftContent}\n </button>\n ) : (\n <div className=\"flex items-center gap-1.5 shrink-0\">\n {leftContent}\n </div>\n )}\n\n {/* Middle content - status content slot */}\n {statusContent && (\n <div className=\"flex-1 min-w-0 mx-2\">\n {statusContent}\n </div>\n )}\n\n <ActivityIndicators\n toolCalls={toolCalls}\n knowledge={knowledge}\n memory={memory}\n statusUpdates={statusUpdates}\n />\n </div>\n );\n }\n);\nMetadataRow.displayName = \"MetadataRow\";\n\nexport { MetadataRow };\n","/**\n * Thinking Section Component\n *\n * Collapsible section for displaying agent thinking/reasoning content.\n * Supports both plain text and structured collapsible sub-sections.\n */\n\nimport * as React from \"react\";\nimport { useState, useCallback } from \"react\";\nimport { ChevronDown, ChevronRight } from \"lucide-react\";\nimport { cn } from \"@optilogic/core\";\nimport type { ThinkingStep } from \"../types\";\n\nexport interface ThinkingSectionProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"content\"> {\n /** The thinking content to display (string or structured steps) */\n content: string | ThinkingStep[];\n /** Whether the section is expanded */\n isExpanded: boolean;\n /**\n * Custom markdown renderer for the thinking content.\n * If not provided, the content will be rendered as plain preformatted text.\n */\n renderMarkdown?: (content: string) => React.ReactNode;\n}\n\n/**\n * Internal component for rendering a collapsible thinking step\n */\ninterface ThinkingStepItemProps {\n step: ThinkingStep;\n renderMarkdown?: (content: string) => React.ReactNode;\n}\n\nconst ThinkingStepItem: React.FC<ThinkingStepItemProps> = ({ step, renderMarkdown }) => {\n const [isCollapsed, setIsCollapsed] = useState(step.isCollapsed ?? false);\n\n const toggleCollapse = useCallback(() => {\n setIsCollapsed((prev) => !prev);\n }, []);\n\n const indentPadding = step.depth * 16;\n\n return (\n <div className=\"border-b border-border/50 last:border-b-0\">\n <button\n onClick={toggleCollapse}\n className=\"w-full flex items-center gap-1.5 py-1.5 px-2 hover:bg-muted/50 transition-colors text-left\"\n style={{ paddingLeft: `${indentPadding + 8}px` }}\n >\n {isCollapsed ? (\n <ChevronRight className=\"w-3 h-3 text-muted-foreground flex-shrink-0\" />\n ) : (\n <ChevronDown className=\"w-3 h-3 text-muted-foreground flex-shrink-0\" />\n )}\n <span className=\"text-xs font-medium text-foreground/80\">{step.label}</span>\n </button>\n\n {!isCollapsed && (\n <div\n className=\"pb-2 px-2\"\n style={{ paddingLeft: `${indentPadding + 28}px` }}\n >\n {renderMarkdown ? (\n <div className=\"text-xs text-muted-foreground\">\n {renderMarkdown(step.content)}\n </div>\n ) : (\n <pre className=\"text-xs text-muted-foreground whitespace-pre-wrap font-mono\">\n {step.content}\n </pre>\n )}\n </div>\n )}\n </div>\n );\n};\n\n/**\n * ThinkingSection Component\n *\n * Displays the agent's thinking/reasoning content in a collapsible panel.\n * Supports both plain text content and structured collapsible sub-sections.\n *\n * @example\n * // Plain text content\n * <ThinkingSection content={state.thinking} isExpanded={isExpanded} />\n *\n * @example\n * // Structured content with sub-sections\n * <ThinkingSection\n * content={[\n * { id: \"1\", label: \"Analysis\", content: \"...\", depth: 0 },\n * { id: \"2\", label: \"Sub-analysis\", content: \"...\", depth: 1 },\n * ]}\n * isExpanded={isExpanded}\n * />\n */\nconst ThinkingSection = React.forwardRef<HTMLDivElement, ThinkingSectionProps>(\n ({ content, isExpanded, renderMarkdown, className, ...props }, ref) => {\n if (!isExpanded || !content || (Array.isArray(content) && content.length === 0)) {\n return null;\n }\n\n const isStructured = Array.isArray(content);\n\n return (\n <div\n ref={ref}\n className={cn(\"px-3 pb-3 border-t border-border\", className)}\n {...props}\n >\n <div className=\"mt-2 max-h-[200px] overflow-y-auto\">\n {isStructured ? (\n <div className=\"space-y-0\">\n {content.map((step) => (\n <ThinkingStepItem\n key={step.id}\n step={step}\n renderMarkdown={renderMarkdown}\n />\n ))}\n </div>\n ) : renderMarkdown ? (\n <div className=\"text-xs text-muted-foreground\">\n {renderMarkdown(content)}\n </div>\n ) : (\n <pre className=\"text-xs text-muted-foreground whitespace-pre-wrap font-mono\">\n {content}\n </pre>\n )}\n </div>\n </div>\n );\n }\n);\nThinkingSection.displayName = \"ThinkingSection\";\n\nexport { ThinkingSection };\n","/**\n * Action Bar Component\n *\n * Displays copy, feedback, and timing actions for the response\n */\n\nimport * as React from \"react\";\nimport { useState, useCallback } from \"react\";\nimport { Copy, Check, ThumbsUp, ThumbsDown } from \"lucide-react\";\nimport { cn } from \"@optilogic/core\";\nimport { formatTotalTime } from \"../utils\";\nimport type { FeedbackValue } from \"../types\";\n\nexport interface ActionBarProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The response text (for copying) */\n response: string;\n /** Whether the action bar is visible */\n isVisible: boolean;\n /** Total time in seconds */\n totalTimeSeconds: number;\n /** Current feedback value */\n feedback?: FeedbackValue;\n /** Callback when feedback changes */\n onFeedbackChange?: (feedback: FeedbackValue) => void;\n /** Callback when response is copied */\n onResponseCopy?: (response: string) => void;\n}\n\n/**\n * ActionBar Component\n *\n * Displays action buttons for copying the response, providing feedback,\n * and showing total response time.\n *\n * @example\n * <ActionBar\n * response={state.response}\n * isVisible={isHovered}\n * totalTimeSeconds={totalTime}\n * feedback={feedback}\n * onFeedbackChange={setFeedback}\n * onCopy={handleCopy}\n * />\n */\nconst ActionBar = React.forwardRef<HTMLDivElement, ActionBarProps>(\n (\n {\n response,\n isVisible,\n totalTimeSeconds,\n feedback,\n onFeedbackChange,\n onResponseCopy,\n className,\n ...props\n },\n ref\n ) => {\n const [copied, setCopied] = useState(false);\n\n const handleCopy = useCallback(async () => {\n try {\n await navigator.clipboard.writeText(response);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n onResponseCopy?.(response);\n } catch (err) {\n console.error(\"Failed to copy response:\", err);\n }\n }, [response, onResponseCopy]);\n\n const handleThumbsUp = useCallback(() => {\n const newValue = feedback === \"up\" ? null : \"up\";\n onFeedbackChange?.(newValue);\n }, [feedback, onFeedbackChange]);\n\n const handleThumbsDown = useCallback(() => {\n const newValue = feedback === \"down\" ? null : \"down\";\n onFeedbackChange?.(newValue);\n }, [feedback, onFeedbackChange]);\n\n const isThumbsUp = feedback === \"up\";\n const isThumbsDown = feedback === \"down\";\n\n return (\n <div\n ref={ref}\n className={cn(\n \"flex items-center justify-between px-4 py-2\",\n \"transition-opacity duration-200\",\n isVisible ? \"opacity-100\" : \"opacity-0 pointer-events-none\",\n className\n )}\n {...props}\n >\n {/* Left side - action buttons */}\n <div className=\"flex items-center gap-1\">\n {/* Copy button */}\n <button\n onClick={handleCopy}\n className=\"p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground\"\n title={copied ? \"Copied!\" : \"Copy response\"}\n >\n {copied ? (\n <Check className=\"w-4 h-4 text-green-500\" />\n ) : (\n <Copy className=\"w-4 h-4\" />\n )}\n </button>\n\n {/* Thumbs up */}\n <button\n onClick={handleThumbsUp}\n className={cn(\n \"p-1.5 rounded hover:bg-muted transition-colors\",\n isThumbsUp\n ? \"text-green-500\"\n : \"text-muted-foreground hover:text-foreground\"\n )}\n title=\"Good response\"\n >\n <ThumbsUp className={cn(\"w-4 h-4\", isThumbsUp && \"fill-current\")} />\n </button>\n\n {/* Thumbs down */}\n <button\n onClick={handleThumbsDown}\n className={cn(\n \"p-1.5 rounded hover:bg-muted transition-colors\",\n isThumbsDown\n ? \"text-red-500\"\n : \"text-muted-foreground hover:text-foreground\"\n )}\n title=\"Poor response\"\n >\n <ThumbsDown className={cn(\"w-4 h-4\", isThumbsDown && \"fill-current\")} />\n </button>\n </div>\n\n {/* Right side - timing info */}\n <span className=\"text-xs text-muted-foreground\">\n Total time: {formatTotalTime(totalTimeSeconds)}\n </span>\n </div>\n );\n }\n);\nActionBar.displayName = \"ActionBar\";\n\nexport { ActionBar };\n","/**\n * HITLQuestionPanel — Human-in-the-Loop clarifying question panel.\n *\n * Renders in the input area (replacing UserPromptInput) when the agent asks a\n * clarifying question via the HumanInTheLoop tool. Shows the question details\n * and lets the user respond via option buttons or free-form text.\n *\n * Option clicks select/toggle rather than immediately submitting. The \"Send\n * response\" button enables once all questions have a selected option OR the\n * textarea has text. On submit, selected options and free-form text are\n * combined into a single formatted string for the backend.\n */\n\nimport * as React from \"react\";\nimport { useState, useEffect, useRef, useCallback, useMemo } from \"react\";\nimport { cn, Button, Textarea } from \"@optilogic/core\";\n\nexport interface HITLQuestion {\n reason: string;\n questions: string[];\n options: Record<string, string[]> | null;\n context: string | null;\n /** Timeout in seconds. When omitted, no countdown is shown and the panel never times out. */\n timeoutSeconds?: number;\n receivedAt: number;\n}\n\nexport interface HITLResponseData {\n /** Raw selected option text per question, keyed by question text */\n selectedOptions: Record<string, string>;\n /** Freeform text entered by the user (untrimmed) */\n freeformText: string;\n}\n\nexport interface HITLQuestionPanelProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onSubmit\"> {\n question: HITLQuestion;\n onSubmit: (response: string, data: HITLResponseData) => void;\n onStop: () => void;\n}\n\n/**\n * Build a single response string from selected options and optional free-form text.\n * Format is designed to be easily parsed by the LLM consuming the response.\n */\nexport function buildResponseString(\n questions: string[],\n selectedOptions: Record<string, string>,\n freeformText: string\n): string {\n const parts: string[] = [];\n\n for (const q of questions) {\n const answer = selectedOptions[q];\n if (answer) {\n parts.push(`Q: ${q}\\nA: ${answer}`);\n }\n }\n\n const trimmed = freeformText.trim();\n if (trimmed) {\n parts.push(`Additional context: ${trimmed}`);\n }\n\n return parts.join(\"\\n\\n\");\n}\n\nconst HITLQuestionPanel = React.forwardRef<\n HTMLDivElement,\n HITLQuestionPanelProps\n>(({ question, onSubmit, onStop, className, ...props }, ref) => {\n const [freeformText, setFreeformText] = useState(\"\");\n const [selectedOptions, setSelectedOptions] = useState<\n Record<string, string>\n >({});\n const hasTimeout = question.timeoutSeconds != null;\n const [secondsLeft, setSecondsLeft] = useState(() =>\n hasTimeout\n ? Math.max(\n 0,\n Math.round(\n question.timeoutSeconds! - (Date.now() - question.receivedAt) / 1000\n )\n )\n : Infinity\n );\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n // Focus the textarea on mount\n useEffect(() => {\n textareaRef.current?.focus();\n }, []);\n\n // Countdown timer (only when timeoutSeconds is provided)\n useEffect(() => {\n if (!hasTimeout) return;\n const interval = setInterval(() => {\n const remaining = Math.max(\n 0,\n Math.round(\n question.timeoutSeconds! - (Date.now() - question.receivedAt) / 1000\n )\n );\n setSecondsLeft(remaining);\n if (remaining <= 0) clearInterval(interval);\n }, 1000);\n return () => clearInterval(interval);\n }, [hasTimeout, question.timeoutSeconds, question.receivedAt]);\n\n const timedOut = hasTimeout && secondsLeft <= 0;\n\n // Which questions have options defined?\n const questionsWithOptions = useMemo(\n () => question.questions.filter((q) => question.options?.[q]?.length),\n [question.questions, question.options]\n );\n\n const allOptionsSelected =\n questionsWithOptions.length > 0 &&\n questionsWithOptions.every((q) => selectedOptions[q]);\n\n const hasFreeformText = freeformText.trim().length > 0;\n\n const canSubmit = !timedOut && (allOptionsSelected || hasFreeformText);\n\n const handleOptionClick = useCallback(\n (questionText: string, option: string) => {\n if (timedOut) return;\n setSelectedOptions((prev) => {\n // Toggle: deselect if already selected, otherwise select\n if (prev[questionText] === option) {\n const next = { ...prev };\n delete next[questionText];\n return next;\n }\n return { ...prev, [questionText]: option };\n });\n },\n [timedOut]\n );\n\n const handleSubmit = useCallback(() => {\n if (!canSubmit) return;\n const combined = buildResponseString(\n question.questions,\n selectedOptions,\n freeformText\n );\n onSubmit(combined, { selectedOptions, freeformText });\n }, [canSubmit, question.questions, selectedOptions, freeformText, onSubmit]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n },\n [handleSubmit]\n );\n\n const formatTime = (s: number) => {\n const m = Math.floor(s / 60);\n const sec = s % 60;\n return `${m}:${sec.toString().padStart(2, \"0\")}`;\n };\n\n return (\n <div\n ref={ref}\n className={cn(\n \"rounded-lg border border-border bg-muted p-4 space-y-3\",\n className\n )}\n {...props}\n >\n {/* Header: reason + countdown */}\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"flex-1\">\n <p className=\"text-sm font-medium text-foreground\">\n {question.reason}\n </p>\n </div>\n {hasTimeout && (\n <span\n className={cn(\n \"text-xs font-mono whitespace-nowrap\",\n secondsLeft <= 30 ? \"text-destructive\" : \"text-muted-foreground\"\n )}\n >\n {timedOut ? \"Timed out\" : formatTime(secondsLeft)}\n </span>\n )}\n </div>\n\n {/* Context (if provided) */}\n {question.context && (\n <div className=\"text-xs text-muted-foreground bg-background rounded p-2 border border-border max-h-24 overflow-y-auto\">\n <pre className=\"whitespace-pre-wrap font-mono\">\n {question.context}\n </pre>\n </div>\n )}\n\n {/* Questions */}\n <div className=\"space-y-3\">\n {question.questions.map((q, i) => (\n <div key={i}>\n <p className=\"text-sm text-foreground\">{q}</p>\n\n {/* Options for this question (if provided) */}\n {question.options?.[q] && (\n <div className=\"flex flex-wrap gap-2 mt-1.5\">\n {question.options[q].map((option, j) => {\n const isSelected = selectedOptions[q] === option;\n return (\n <Button\n key={j}\n variant={isSelected ? \"primary\" : \"outline\"}\n size=\"sm\"\n onClick={() => handleOptionClick(q, option)}\n disabled={timedOut}\n >\n {option}\n </Button>\n );\n })}\n </div>\n )}\n </div>\n ))}\n </div>\n\n {/* Free-form input — always shown for additional context */}\n <Textarea\n ref={textareaRef}\n value={freeformText}\n onChange={(e) => setFreeformText(e.target.value)}\n onKeyDown={handleKeyDown}\n disabled={timedOut}\n placeholder=\"Add additional context or type a full response...\"\n rows={2}\n className=\"resize-none\"\n />\n\n <div className=\"flex items-center justify-between\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={onStop}\n className=\"text-destructive hover:text-destructive hover:bg-destructive/10\"\n >\n Stop agent\n </Button>\n\n <Button\n variant=\"primary\"\n size=\"sm\"\n onClick={handleSubmit}\n disabled={!canSubmit}\n >\n Send response\n </Button>\n </div>\n </div>\n );\n});\nHITLQuestionPanel.displayName = \"HITLQuestionPanel\";\n\nexport { HITLQuestionPanel };\n","/**\n * HITLInteractionRecord — Displays a completed HITL Q&A interaction\n * in the chat message history.\n *\n * Rendered below AgentResponse in the agent message block. Shows the full detail\n * of each clarifying question the agent asked and the user's response.\n */\n\nimport * as React from \"react\";\nimport { useMemo } from \"react\";\nimport { cn } from \"@optilogic/core\";\nimport type { HITLQuestion } from \"./HITLQuestionPanel\";\n\nexport interface HITLInteraction {\n question: HITLQuestion;\n response: string;\n respondedAt: number;\n}\n\nexport interface HITLInteractionRecordProps\n extends React.HTMLAttributes<HTMLDivElement> {\n interaction: HITLInteraction;\n}\n\n/**\n * Parse the formatted response string (produced by buildResponseString) back\n * into a per-question answer map and optional additional context.\n */\nfunction parseResponse(response: string): {\n answers: Record<string, string>;\n additionalContext: string | null;\n} {\n const answers: Record<string, string> = {};\n let additionalContext: string | null = null;\n\n const blocks = response.split(\"\\n\\n\");\n for (const block of blocks) {\n const qaMatch = block.match(/^Q: (.+)\\nA: (.+)$/s);\n if (qaMatch) {\n answers[qaMatch[1].trim()] = qaMatch[2].trim();\n } else if (block.startsWith(\"Additional context: \")) {\n additionalContext = block.slice(\"Additional context: \".length).trim();\n }\n }\n\n return { answers, additionalContext };\n}\n\nconst HITLInteractionRecord = React.forwardRef<\n HTMLDivElement,\n HITLInteractionRecordProps\n>(({ interaction, className, ...props }, ref) => {\n const { question, response, respondedAt } = interaction;\n const timestamp = new Date(respondedAt).toLocaleTimeString([], {\n hour: \"2-digit\",\n minute: \"2-digit\",\n });\n\n const { answers, additionalContext } = useMemo(\n () => parseResponse(response),\n [response]\n );\n\n // Check if parsing found any structured answers; if not, fall back to\n // showing the raw response string (for responses not built by buildResponseString).\n const hasParsedAnswers = Object.keys(answers).length > 0;\n\n return (\n <div\n ref={ref}\n className={cn(\n \"rounded-lg border border-border bg-muted p-3 space-y-2 text-sm\",\n className\n )}\n {...props}\n >\n {/* Header */}\n <div className=\"flex items-center justify-between\">\n <span className=\"font-medium text-muted-foreground\">\n Clarifying Question\n </span>\n <span className=\"text-xs text-muted-foreground\">{timestamp}</span>\n </div>\n\n {/* Reason */}\n <p className=\"text-foreground font-medium\">{question.reason}</p>\n\n {/* Context (if provided) */}\n {question.context && (\n <div className=\"text-xs text-muted-foreground bg-background rounded p-2 border border-border\">\n <pre className=\"whitespace-pre-wrap font-mono\">\n {question.context}\n </pre>\n </div>\n )}\n\n {/* Questions with inline answers */}\n <div className=\"space-y-2\">\n {question.questions.map((q, i) => (\n <div key={i}>\n <p className=\"text-foreground\">{q}</p>\n {question.options?.[q] && (\n <p className=\"text-xs text-muted-foreground ml-2\">\n Options: {question.options[q].join(\", \")}\n </p>\n )}\n {hasParsedAnswers && answers[q] && (\n <p className=\"text-xs text-foreground ml-2 mt-0.5 bg-background rounded px-2 py-1 border border-border\">\n <span className=\"text-muted-foreground\">Answer: </span>\n {answers[q]}\n </p>\n )}\n </div>\n ))}\n </div>\n\n {/* Additional context from freeform text, or raw fallback */}\n {hasParsedAnswers && additionalContext && (\n <div className=\"border-t border-border pt-2\">\n <span className=\"text-muted-foreground text-xs\">\n Additional context:\n </span>\n <p className=\"text-foreground mt-0.5\">{additionalContext}</p>\n </div>\n )}\n\n {/* Fallback: show raw response if it wasn't in the parsed Q/A format */}\n {!hasParsedAnswers && (\n <div className=\"border-t border-border pt-2\">\n <span className=\"text-muted-foreground text-xs\">Response:</span>\n <p className=\"text-foreground mt-0.5\">{response}</p>\n </div>\n )}\n </div>\n );\n});\nHITLInteractionRecord.displayName = \"HITLInteractionRecord\";\n\nexport { HITLInteractionRecord };\n","/**\n * HITL Section Component\n *\n * Collapsible section for displaying completed HITL (Human-in-the-Loop)\n * interactions within an AgentResponse. Follows the same pattern as\n * ThinkingSection for consistent UX.\n */\n\nimport * as React from \"react\";\nimport { useState, useCallback } from \"react\";\nimport { ChevronDown, ChevronRight, MessageCircleQuestion } from \"lucide-react\";\nimport { cn } from \"@optilogic/core\";\nimport { HITLInteractionRecord } from \"../../hitl-interactions\";\nimport type { HITLInteraction } from \"../../hitl-interactions\";\n\nexport interface HITLSectionProps\n extends React.HTMLAttributes<HTMLDivElement> {\n /** The HITL interactions to display */\n interactions: HITLInteraction[];\n /** Whether the section starts expanded (uncontrolled) */\n defaultExpanded?: boolean;\n /** Whether the section is expanded (controlled) */\n isExpanded?: boolean;\n /** Callback when expansion state changes (controlled) */\n onExpandedChange?: (expanded: boolean) => void;\n}\n\nconst HITLSection = React.forwardRef<HTMLDivElement, HITLSectionProps>(\n (\n {\n interactions,\n defaultExpanded = false,\n isExpanded: controlledExpanded,\n onExpandedChange,\n className,\n ...props\n },\n ref\n ) => {\n const [uncontrolledExpanded, setUncontrolledExpanded] =\n useState(defaultExpanded);\n\n const isControlled = controlledExpanded !== undefined;\n const isExpanded = isControlled ? controlledExpanded : uncontrolledExpanded;\n\n const toggleExpanded = useCallback(() => {\n const newValue = !isExpanded;\n if (isControlled) {\n onExpandedChange?.(newValue);\n } else {\n setUncontrolledExpanded(newValue);\n }\n }, [isExpanded, isControlled, onExpandedChange]);\n\n if (!interactions || interactions.length === 0) {\n return null;\n }\n\n return (\n <div\n ref={ref}\n className={cn(\"border-t border-border\", className)}\n {...props}\n >\n {/* Collapsible header */}\n <button\n onClick={toggleExpanded}\n className=\"w-full flex items-center gap-2 py-2 px-3 hover:bg-muted/50 transition-colors text-left\"\n >\n {isExpanded ? (\n <ChevronDown className=\"w-3.5 h-3.5 text-muted-foreground flex-shrink-0\" />\n ) : (\n <ChevronRight className=\"w-3.5 h-3.5 text-muted-foreground flex-shrink-0\" />\n )}\n <MessageCircleQuestion className=\"w-3.5 h-3.5 text-muted-foreground flex-shrink-0\" />\n <span className=\"text-xs font-medium text-foreground/80\">\n Clarifying Questions ({interactions.length})\n </span>\n </button>\n\n {/* Expanded content */}\n {isExpanded && (\n <div className=\"px-3 pb-3 space-y-2\">\n {interactions.map((interaction, i) => (\n <HITLInteractionRecord key={i} interaction={interaction} />\n ))}\n </div>\n )}\n </div>\n );\n }\n);\nHITLSection.displayName = \"HITLSection\";\n\nexport { HITLSection };\n","/**\n * Truncated Message Component\n *\n * Renders a single-line text message with CSS-based truncation (text-overflow: ellipsis).\n * Designed as a standalone utility that can be used anywhere, including as\n * the statusContent slot in MetadataRow.\n */\n\nimport * as React from \"react\";\nimport { cn } from \"@optilogic/core\";\n\nexport interface TruncatedMessageProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The message string to display (truncated with ellipsis if it overflows) */\n message: string;\n}\n\n/**\n * TruncatedMessage Component\n *\n * Displays a single-line text message that truncates with an ellipsis when\n * it overflows its container. Uses CSS text-overflow for zero-JS truncation.\n *\n * @example\n * <TruncatedMessage message=\"Searching the knowledge base for relevant documents...\" />\n *\n * @example\n * // Inside MetadataRow's statusContent slot\n * <AgentResponse\n * state={state}\n * statusContent={<TruncatedMessage message=\"Running analysis...\" />}\n * />\n */\nconst TruncatedMessage = React.forwardRef<HTMLDivElement, TruncatedMessageProps>(\n ({ message, className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn(\n \"text-xs text-muted-foreground truncate min-w-0\",\n className\n )}\n title={message}\n {...props}\n >\n {message}\n </div>\n );\n }\n);\nTruncatedMessage.displayName = \"TruncatedMessage\";\n\nexport { TruncatedMessage };\n","/**\n * useThinkingTimer Hook\n *\n * Tracks elapsed time during agent thinking/processing\n */\n\nimport { useState, useEffect } from \"react\";\nimport type { AgentResponseStatus } from \"../types\";\n\nexport interface UseThinkingTimerOptions {\n startTime: number | null;\n endTime: number | null;\n status: AgentResponseStatus;\n}\n\n/**\n * Custom hook for thinking timer\n * Returns elapsed time in seconds\n */\nexport function useThinkingTimer({\n startTime,\n endTime,\n status,\n}: UseThinkingTimerOptions): number {\n const [elapsed, setElapsed] = useState(0);\n\n useEffect(() => {\n if (!startTime) {\n setElapsed(0);\n return;\n }\n\n // If complete, calculate final elapsed time\n if (status === \"complete\" && endTime) {\n setElapsed((endTime - startTime) / 1000);\n return;\n }\n\n // If still processing, update every second\n if (status === \"processing\") {\n const updateElapsed = () => {\n setElapsed((Date.now() - startTime) / 1000);\n };\n\n updateElapsed(); // Initial update\n const interval = setInterval(updateElapsed, 1000);\n return () => clearInterval(interval);\n }\n }, [startTime, endTime, status]);\n\n return elapsed;\n}\n","/**\n * Agent Response Component Types\n *\n * Type definitions for the library-ready agent response component\n */\n\nimport type { TimelineEntry } from \"../agent-timeline/types\";\n\n/**\n * Status of the agent response cycle\n */\nexport type AgentResponseStatus = \"idle\" | \"processing\" | \"complete\";\n\n/**\n * Feedback value for the response\n */\nexport type FeedbackValue = \"up\" | \"down\" | null;\n\n/**\n * Tool call information from the agent\n */\nexport interface ToolCall {\n id: string;\n name: string;\n arguments?: Record<string, unknown>;\n timestamp: number;\n /** Agent that made this call (multi-agent scenarios) */\n agentName?: string | null;\n /** Parent agent name */\n parentAgent?: string | null;\n /** Nesting depth in agent hierarchy */\n depth?: number;\n}\n\n/**\n * Knowledge retrieval information\n */\nexport interface KnowledgeItem {\n id: string;\n source: string;\n content: string;\n timestamp: number;\n /** Agent that retrieved this (multi-agent scenarios) */\n agentName?: string | null;\n /** Parent agent name */\n parentAgent?: string | null;\n /** Nesting depth in agent hierarchy */\n depth?: number;\n}\n\n/**\n * Memory access information\n */\nexport interface MemoryItem {\n id: string;\n type: string;\n content: string;\n timestamp: number;\n /** Agent that accessed this (multi-agent scenarios) */\n agentName?: string | null;\n /** Parent agent name */\n parentAgent?: string | null;\n /** Nesting depth in agent hierarchy */\n depth?: number;\n}\n\n/**\n * Potential response (sub-agent intermediate AI response)\n */\nexport interface PotentialResponse {\n id: string;\n content: string;\n timestamp: number;\n agentName?: string | null;\n parentAgent?: string | null;\n depth?: number;\n}\n\n/**\n * Status update information from the agent\n */\nexport interface StatusItem {\n id: string;\n message: string;\n timestamp: number;\n /** Optional agent name if in multi-agent scenario */\n agent?: string;\n /** Agent that produced this (multi-agent scenarios) */\n agentName?: string | null;\n /** Parent agent name */\n parentAgent?: string | null;\n /** Nesting depth in agent hierarchy */\n depth?: number;\n}\n\n/**\n * A single step in structured thinking content\n */\nexport interface ThinkingStep {\n /** Unique identifier for the step */\n id: string;\n /** Label/title shown in the collapsible header */\n label: string;\n /** Content of the thinking step */\n content: string;\n /** Nesting depth (0 = root level, 1 = first indent, etc.) */\n depth: number;\n /** Whether this step should start collapsed (default: false) */\n isCollapsed?: boolean;\n /** Timestamp for timeline ordering */\n timestamp?: number;\n /** Agent that produced this (multi-agent scenarios) */\n agentName?: string | null;\n /** Parent agent name */\n parentAgent?: string | null;\n}\n\n/**\n * Union type for thinking content\n * - string: plain text (backward compatible)\n * - ThinkingStep[]: structured with collapsible sub-sections\n */\nexport type ThinkingContent = string | ThinkingStep[];\n\n/**\n * State shape for the agent response component\n */\nexport interface AgentResponseState {\n /** Current status of the response cycle */\n status: AgentResponseStatus;\n /** Accumulated thinking/reasoning text */\n thinking: string;\n /** Structured thinking steps (if provided, takes precedence over thinking string) */\n thinkingSteps?: ThinkingStep[];\n /** Tool calls made during processing */\n toolCalls: ToolCall[];\n /** Knowledge items retrieved */\n knowledge: KnowledgeItem[];\n /** Memory items accessed */\n memory: MemoryItem[];\n /** Status updates from the agent */\n statusUpdates: StatusItem[];\n /** Potential responses (sub-agent intermediate AI responses) */\n potentialResponses?: PotentialResponse[];\n /** Custom timeline entries (consumer-provided) */\n customTimelineEntries?: TimelineEntry[];\n /** Final response text */\n response: string;\n /** Timeline entries derived from all accumulator arrays (for AgentTimeline) */\n timelineEntries?: TimelineEntry[];\n /** Timestamp when first thinking message was received (for timer) */\n thinkingStartTime: number | null;\n /** Timestamp when response was completed (for final timer display) */\n responseCompleteTime: number | null;\n /** Timestamp when first message of any type was received (for total time) */\n firstMessageTime: number | null;\n}\n\n/**\n * WebSocket message payload for agent responses\n */\nexport interface AgentMessage {\n type: \"status\" | \"thinking\" | \"tool_call\" | \"knowledge\" | \"memory\" | \"response\" | \"status_update\" | \"potential_response\";\n /** Message content - for simple string payloads */\n message?: string;\n /** Alternative content field */\n content?: string;\n /**\n * Optional event timestamp (epoch ms). When supplied, the reducer uses this\n * for the item's `timestamp` and any state-level timing fields it sets\n * (`firstMessageTime`, `thinkingStartTime`, `responseCompleteTime`) instead\n * of `Date.now()`. Provide this when replaying historical events so durations\n * reflect the original run rather than load time.\n */\n timestamp?: number;\n /** For status messages */\n status?: string;\n /** Agent name (multi-agent scenarios) */\n agentName?: string | null;\n /** Parent agent name (multi-agent scenarios) */\n parentAgent?: string | null;\n /** Agent nesting depth (0 = root) */\n depth?: number;\n /** Title/label for timeline display */\n title?: string | null;\n /** For tool_call messages */\n tool?: {\n id: string;\n name: string;\n arguments?: Record<string, unknown>;\n };\n /** For knowledge messages */\n knowledge?: {\n id: string;\n source: string;\n content: string;\n };\n /** For memory messages */\n memory?: {\n id: string;\n type: string;\n content: string;\n };\n /** For status_update messages */\n statusUpdate?: {\n id: string;\n message: string;\n agent?: string;\n };\n /** For structured thinking step messages */\n thinkingStep?: {\n id?: string;\n label: string;\n content: string;\n depth?: number;\n isCollapsed?: boolean;\n };\n}\n\n/**\n * Generic websocket message wrapper type\n */\nexport interface GenericWebSocketMessage {\n topic: string;\n message: AgentMessage;\n accountId?: string;\n}\n\n/**\n * Initial state for the agent response component\n */\nexport const initialAgentResponseState: AgentResponseState = {\n status: \"idle\",\n thinking: \"\",\n toolCalls: [],\n knowledge: [],\n memory: [],\n statusUpdates: [],\n potentialResponses: [],\n customTimelineEntries: [],\n response: \"\",\n thinkingStartTime: null,\n responseCompleteTime: null,\n firstMessageTime: null,\n};\n","import type { TimelineEntry, AgentRun, DisplayEntry } from \"./types\";\nimport type { AgentResponseState } from \"../agent-response/types\";\n\n/**\n * Build a flat, chronologically sorted array of TimelineEntry from the\n * accumulator state. Maps each typed array (toolCalls, knowledge, etc.)\n * to unified TimelineEntry objects with per-source stable IDs.\n */\nexport function buildTimelineEntries(state: AgentResponseState): TimelineEntry[] {\n const entries: TimelineEntry[] = [];\n\n // Thinking steps (structured)\n if (state.thinkingSteps) {\n let idx = 0;\n for (const step of state.thinkingSteps) {\n entries.push({\n id: `tl-think-${idx++}`,\n type: \"thinking\",\n agentName: step.agentName ?? null,\n parentAgent: step.parentAgent ?? null,\n depth: step.depth ?? 0,\n content: step.content,\n title: step.label,\n timestamp: step.timestamp ?? 0,\n });\n }\n } else if (state.thinking) {\n // Plain text thinking (legacy) — single entry\n entries.push({\n id: \"tl-think-0\",\n type: \"thinking\",\n agentName: null,\n parentAgent: null,\n depth: 0,\n content: state.thinking,\n title: null,\n timestamp: state.thinkingStartTime ?? 0,\n });\n }\n\n // Tool calls\n let toolIdx = 0;\n for (const tool of state.toolCalls) {\n entries.push({\n id: `tl-tool-${toolIdx++}`,\n type: \"tool_call\",\n agentName: tool.agentName ?? null,\n parentAgent: tool.parentAgent ?? null,\n depth: tool.depth ?? 0,\n content: tool.name,\n title: null,\n timestamp: tool.timestamp,\n });\n }\n\n // Knowledge items\n let knowIdx = 0;\n for (const item of state.knowledge) {\n entries.push({\n id: `tl-know-${knowIdx++}`,\n type: \"knowledge\",\n agentName: item.agentName ?? null,\n parentAgent: item.parentAgent ?? null,\n depth: item.depth ?? 0,\n content: item.content,\n title: item.source,\n timestamp: item.timestamp,\n });\n }\n\n // Memory items\n let memIdx = 0;\n for (const item of state.memory) {\n entries.push({\n id: `tl-mem-${memIdx++}`,\n type: \"memory\",\n agentName: item.agentName ?? null,\n parentAgent: item.parentAgent ?? null,\n depth: item.depth ?? 0,\n content: item.content,\n title: item.type,\n timestamp: item.timestamp,\n });\n }\n\n // Status updates\n let statIdx = 0;\n for (const item of state.statusUpdates) {\n entries.push({\n id: `tl-stat-${statIdx++}`,\n type: \"status_update\",\n agentName: item.agentName ?? item.agent ?? null,\n parentAgent: item.parentAgent ?? null,\n depth: item.depth ?? 0,\n content: item.message,\n title: null,\n timestamp: item.timestamp,\n });\n }\n\n // Potential responses → ai_response timeline entries\n if (state.potentialResponses) {\n let respIdx = 0;\n for (const resp of state.potentialResponses) {\n entries.push({\n id: `tl-resp-${respIdx++}`,\n type: \"ai_response\",\n agentName: resp.agentName ?? null,\n parentAgent: resp.parentAgent ?? null,\n depth: resp.depth ?? 0,\n content: resp.content,\n title: null,\n timestamp: resp.timestamp,\n });\n }\n }\n\n // Merge any custom timeline entries (consumer-provided)\n if (state.customTimelineEntries) {\n entries.push(...state.customTimelineEntries);\n }\n\n // Sort chronologically\n entries.sort((a, b) => a.timestamp - b.timestamp);\n\n return entries;\n}\n\n/**\n * Group a sorted array of timeline entries into consecutive \"agent runs\".\n * A new run starts whenever the agentName changes.\n * Each run's entries are deduplicated.\n */\nexport function groupIntoAgentRuns(entries: TimelineEntry[]): AgentRun[] {\n const runs: AgentRun[] = [];\n let currentRun: AgentRun | null = null;\n\n for (const entry of entries) {\n const name = entry.agentName || \"Agent\";\n\n if (!currentRun || currentRun.agentName !== name) {\n // Start a new run\n currentRun = {\n agentName: name,\n parentAgent: entry.parentAgent,\n depth: entry.depth,\n entries: [],\n };\n runs.push(currentRun);\n }\n\n currentRun.entries.push({ entry, count: 1 });\n }\n\n // Deduplicate within each run\n for (const run of runs) {\n run.entries = deduplicateEntries(run.entries);\n }\n\n return runs;\n}\n\n/**\n * Collapse consecutive entries with identical type AND content into\n * a single DisplayEntry with count > 1.\n * Handles patterns like \"Loading documents\" appearing 8 times.\n */\nexport function deduplicateEntries(entries: DisplayEntry[]): DisplayEntry[] {\n if (entries.length === 0) return [];\n\n const result: DisplayEntry[] = [entries[0]];\n\n for (let i = 1; i < entries.length; i++) {\n const prev = result[result.length - 1];\n const curr = entries[i];\n\n if (\n prev.entry.type === curr.entry.type &&\n prev.entry.content === curr.entry.content\n ) {\n // Merge into previous\n prev.count += curr.count;\n } else {\n result.push({ ...curr });\n }\n }\n\n return result;\n}\n","/**\n * Pure reducer for agent response messages.\n *\n * Used by `useAgentResponseAccumulator` for live streaming, and exported so\n * non-React callers (e.g. server-side or store-based replay of historical\n * conversations) can rebuild the same `AgentResponseState` from a sequence of\n * `AgentMessage` events without rendering a component.\n *\n * Replay note on stable IDs: when a payload omits a per-item id\n * (`tool.id`, `thinkingStep.id`, `knowledge.id`, `memory.id`,\n * `statusUpdate.id`), the reducer falls back to `${type}-${Date.now()}`. That\n * is fine for live streams but will produce different React keys on each\n * replay. Callers reconstructing `AgentMessage` events from persisted rows\n * should populate these ids from a stable source (e.g. the supplement-row\n * primary key) so timeline keys remain consistent across reloads.\n */\n\nimport {\n initialAgentResponseState,\n type AgentResponseState,\n type AgentMessage,\n type ToolCall,\n type KnowledgeItem,\n type MemoryItem,\n type StatusItem,\n type ThinkingStep,\n type PotentialResponse,\n} from \"./types\";\nimport { buildTimelineEntries } from \"../agent-timeline/utils\";\n\n/**\n * Pure reducer: apply a single `AgentMessage` to the accumulated state.\n *\n * `payload.timestamp` (epoch ms), if supplied, is used for the new item's\n * `timestamp` and any state-level timing fields this call sets\n * (`firstMessageTime`, `thinkingStartTime`, `responseCompleteTime`). When\n * absent, `Date.now()` is used — matching the prior live-streaming behaviour.\n *\n * @example\n * const state = events.reduce(reduceAgentMessage, initialAgentResponseState);\n */\nexport function reduceAgentMessage(\n prev: AgentResponseState,\n payload: AgentMessage,\n): AgentResponseState {\n const now = payload.timestamp ?? Date.now();\n\n // If we receive a non-status message while idle, transition to processing\n let newStatus = prev.status;\n const isFirstMessage = prev.status === \"idle\" && payload.type !== \"status\";\n if (isFirstMessage) {\n newStatus = \"processing\";\n }\n\n // Track first message time for total time calculation\n const firstMessageTime =\n prev.firstMessageTime ?? (isFirstMessage ? now : null);\n\n switch (payload.type) {\n case \"status\":\n // \"Harness connected\" resets to idle\n if (\n payload.message === \"Harness connected\" ||\n payload.status === \"Harness connected\"\n ) {\n return { ...initialAgentResponseState };\n }\n return { ...prev, status: newStatus };\n\n case \"thinking\": {\n // Check if this is a structured thinking step\n if (payload.thinkingStep) {\n const newStep: ThinkingStep = {\n id: payload.thinkingStep.id || `step-${now}`,\n label: payload.thinkingStep.label,\n content: payload.thinkingStep.content,\n depth: payload.thinkingStep.depth ?? payload.depth ?? 0,\n isCollapsed: payload.thinkingStep.isCollapsed,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n };\n const thinkingStartTime = prev.thinkingStartTime ?? now;\n const next = {\n ...prev,\n status: newStatus,\n thinkingSteps: [...(prev.thinkingSteps || []), newStep],\n thinkingStartTime,\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n\n // Plain text thinking — concatenate for backward compat AND\n // push a ThinkingStep so the timeline gets individual entries.\n const newThinking = payload.message || payload.content || \"\";\n // Add line break between thinking messages\n const separator = prev.thinking && newThinking ? \"\\n\\n\" : \"\";\n // Set thinkingStartTime on first thinking message\n const thinkingStartTime =\n prev.thinkingStartTime ?? (newThinking ? now : null);\n const prevSteps = prev.thinkingSteps || [];\n const plainStep: ThinkingStep = {\n id: `step-${prevSteps.length}`,\n label: newThinking,\n content: newThinking,\n depth: payload.depth ?? 0,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n };\n const next = {\n ...prev,\n status: newStatus,\n thinking: prev.thinking + separator + newThinking,\n thinkingSteps: [...prevSteps, plainStep],\n thinkingStartTime,\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n\n case \"tool_call\": {\n // Handle both formats: { message: \"ToolName\" } or { tool: { id, name, arguments } }\n const toolName = payload.message || payload.tool?.name;\n if (toolName) {\n const newToolCall: ToolCall = {\n id: payload.tool?.id || `tool-${now}`,\n name: toolName,\n arguments: payload.tool?.arguments,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n depth: payload.depth,\n };\n const next = {\n ...prev,\n status: newStatus,\n toolCalls: [...prev.toolCalls, newToolCall],\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n return { ...prev, status: newStatus, firstMessageTime };\n }\n\n case \"knowledge\": {\n // Handle both formats: { message: \"content\" } or { knowledge: { id, source, content } }\n const knowledgeContent = payload.message || payload.knowledge?.content;\n if (knowledgeContent) {\n const newKnowledge: KnowledgeItem = {\n id: payload.knowledge?.id || `knowledge-${now}`,\n source: payload.knowledge?.source || \"unknown\",\n content: knowledgeContent,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n depth: payload.depth,\n };\n const next = {\n ...prev,\n status: newStatus,\n knowledge: [...prev.knowledge, newKnowledge],\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n return { ...prev, status: newStatus, firstMessageTime };\n }\n\n case \"memory\": {\n // Handle both formats: { message: \"content\" } or { memory: { id, type, content } }\n const memoryContent = payload.message || payload.memory?.content;\n if (memoryContent) {\n const newMemory: MemoryItem = {\n id: payload.memory?.id || `memory-${now}`,\n type: payload.memory?.type || \"unknown\",\n content: memoryContent,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n depth: payload.depth,\n };\n const next = {\n ...prev,\n status: newStatus,\n memory: [...prev.memory, newMemory],\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n return { ...prev, status: newStatus, firstMessageTime };\n }\n\n case \"response\":\n return {\n ...prev,\n status: \"complete\",\n response: payload.message || payload.content || \"\",\n responseCompleteTime: now,\n firstMessageTime: prev.firstMessageTime ?? now,\n };\n\n case \"status_update\": {\n const statusMessage = payload.message || payload.statusUpdate?.message;\n if (statusMessage) {\n const newStatusItem: StatusItem = {\n id: payload.statusUpdate?.id || `status-${now}`,\n message: statusMessage,\n agent: payload.statusUpdate?.agent,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n depth: payload.depth,\n };\n const next = {\n ...prev,\n status: newStatus,\n statusUpdates: [...prev.statusUpdates, newStatusItem],\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n return { ...prev, status: newStatus, firstMessageTime };\n }\n\n case \"potential_response\": {\n const respContent = payload.message || payload.content || \"\";\n if (respContent) {\n const newResp: PotentialResponse = {\n id: `resp-${now}`,\n content: respContent,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n depth: payload.depth,\n };\n const next = {\n ...prev,\n status: newStatus,\n potentialResponses: [...(prev.potentialResponses || []), newResp],\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n return { ...prev, status: newStatus, firstMessageTime };\n }\n\n default:\n return { ...prev, status: newStatus, firstMessageTime };\n }\n}\n","/**\n * useAgentResponseAccumulator Hook\n *\n * Accumulates agent response messages into a unified state.\n *\n * Thin wrapper around `reduceAgentMessage` — the pure reducer can be used\n * directly outside React for replaying historical events.\n */\n\nimport { useState, useCallback } from \"react\";\nimport {\n initialAgentResponseState,\n type AgentResponseState,\n type AgentMessage,\n type GenericWebSocketMessage,\n} from \"../types\";\nimport { reduceAgentMessage } from \"../reducer\";\n\nexport interface UseAgentResponseAccumulatorOptions {\n /** WebSocket topic to filter messages (optional, for convenience) */\n topic?: string;\n}\n\nexport interface UseAgentResponseAccumulatorReturn {\n /** Current accumulated state */\n state: AgentResponseState;\n\n /** Handler to process incoming messages */\n handleMessage: (message: unknown) => void;\n\n /** Reset state to initial */\n reset: () => void;\n}\n\n/**\n * Hook for accumulating agent response messages into a unified state\n *\n * @example\n * const { state, handleMessage, reset } = useAgentResponseAccumulator({ topic: \"agent\" });\n *\n * // In your WebSocket handler:\n * websocket.onmessage = (event) => {\n * handleMessage(JSON.parse(event.data));\n * };\n */\nexport function useAgentResponseAccumulator(\n options?: UseAgentResponseAccumulatorOptions\n): UseAgentResponseAccumulatorReturn {\n const [state, setState] = useState<AgentResponseState>(initialAgentResponseState);\n const topic = options?.topic;\n\n const handleMessage = useCallback(\n (message: unknown) => {\n let payload: AgentMessage;\n\n if (topic) {\n const msg = message as GenericWebSocketMessage;\n if (msg.topic !== topic) return;\n payload = msg.message;\n } else {\n payload = message as AgentMessage;\n }\n\n setState((prev) => reduceAgentMessage(prev, payload));\n },\n [topic]\n );\n\n const reset = useCallback(() => {\n setState(initialAgentResponseState);\n }, []);\n\n return { state, handleMessage, reset };\n}\n","import type { ReactNode } from \"react\";\nimport {\n Brain,\n Wrench,\n BookOpen,\n HardDrive,\n Activity,\n MessageSquare,\n AlertCircle,\n} from \"lucide-react\";\nimport type { DisplayEntry, TimelineEntryType } from \"./types\";\n\nconst ICON_MAP: Record<TimelineEntryType, typeof Brain> = {\n thinking: Brain,\n tool_call: Wrench,\n knowledge: BookOpen,\n memory: HardDrive,\n status_update: Activity,\n ai_response: MessageSquare,\n error: AlertCircle,\n};\n\ninterface TimelineItemProps {\n displayEntry: DisplayEntry;\n renderMarkdown?: (content: string) => ReactNode;\n /** Controlled expanded state (lifted to AgentTimeline) */\n isExpanded: boolean;\n onToggleExpanded: () => void;\n}\n\nexport function TimelineItem({\n displayEntry,\n renderMarkdown,\n isExpanded,\n onToggleExpanded,\n}: TimelineItemProps) {\n const { entry, count } = displayEntry;\n\n const Icon = ICON_MAP[entry.type] ?? Activity;\n\n // Determine if content is long enough to warrant truncation\n const isLong = entry.content.length > 200 || entry.content.split(\"\\n\").length > 3;\n const canExpand = isLong || entry.type === \"ai_response\";\n\n return (\n <div className=\"py-1 flex items-start gap-2 group\">\n {/* Type icon */}\n <Icon className=\"w-3.5 h-3.5 text-muted-foreground flex-shrink-0 mt-0.5\" />\n\n {/* Content */}\n <div className=\"min-w-0 flex-1\">\n {isExpanded && entry.type === \"ai_response\" && renderMarkdown ? (\n // Expanded AI response: rendered markdown\n <div>\n {renderMarkdown(entry.content)}\n <button\n onClick={onToggleExpanded}\n className=\"text-[10px] text-muted-foreground/70 hover:text-muted-foreground mt-1\"\n >\n Show less\n </button>\n </div>\n ) : isExpanded ? (\n // Expanded non-AI: plain text\n <div>\n <pre className=\"text-xs text-muted-foreground whitespace-pre-wrap font-mono\">\n {entry.content}\n </pre>\n <button\n onClick={onToggleExpanded}\n className=\"text-[10px] text-muted-foreground/70 hover:text-muted-foreground mt-1\"\n >\n Show less\n </button>\n </div>\n ) : (\n // Collapsed: truncated with optional expand\n <div className=\"flex items-baseline gap-1.5 min-w-0\">\n <div\n className={`text-xs text-muted-foreground min-w-0 ${canExpand ? \"line-clamp-2 cursor-pointer hover:text-foreground/80\" : \"\"}`}\n onClick={canExpand ? onToggleExpanded : undefined}\n >\n {entry.content}\n </div>\n\n {/* Dedup count badge */}\n {count > 1 && (\n <span className=\"text-[10px] text-muted-foreground/60 whitespace-nowrap flex-shrink-0\">\n (x{count})\n </span>\n )}\n </div>\n )}\n </div>\n </div>\n );\n}\n","import type { ReactNode } from \"react\";\nimport { ChevronDown, ChevronRight } from \"lucide-react\";\nimport type { AgentRun } from \"./types\";\nimport { TimelineItem } from \"./TimelineItem\";\n\ninterface TimelineAgentBlockProps {\n block: AgentRun;\n renderMarkdown?: (content: string) => ReactNode;\n /** If true, skip the collapsible header and render entries directly */\n isSingleAgent: boolean;\n /** Controlled collapsed state (lifted to AgentTimeline) */\n isCollapsed: boolean;\n onToggleCollapsed: () => void;\n /** Set of entry IDs whose content is expanded (lifted to AgentTimeline) */\n expandedItems: Set<string>;\n onToggleItemExpanded: (entryId: string) => void;\n}\n\nexport function TimelineAgentBlock({\n block,\n renderMarkdown,\n isSingleAgent,\n isCollapsed,\n onToggleCollapsed,\n expandedItems,\n onToggleItemExpanded,\n}: TimelineAgentBlockProps) {\n const indentPx = block.depth * 16;\n\n // Skip header only for a single root-level agent (depth 0).\n // If filtering leaves only a sub-agent, still show the header for context.\n if (isSingleAgent && block.depth === 0) {\n return (\n <div style={{ paddingLeft: `${indentPx}px` }}>\n {block.entries.map((displayEntry, i) => (\n <TimelineItem\n key={displayEntry.entry.id + \"-\" + i}\n displayEntry={displayEntry}\n renderMarkdown={renderMarkdown}\n isExpanded={expandedItems.has(displayEntry.entry.id)}\n onToggleExpanded={() => onToggleItemExpanded(displayEntry.entry.id)}\n />\n ))}\n </div>\n );\n }\n\n return (\n <div style={{ paddingLeft: `${indentPx}px` }}>\n {/* Agent header */}\n <button\n onClick={onToggleCollapsed}\n className=\"w-full flex items-center gap-1.5 py-1 hover:bg-muted/50 -ml-1 pl-1 pr-2 rounded transition-colors text-left\"\n >\n {isCollapsed ? (\n <ChevronRight className=\"w-3 h-3 text-muted-foreground flex-shrink-0\" />\n ) : (\n <ChevronDown className=\"w-3 h-3 text-muted-foreground flex-shrink-0\" />\n )}\n <span className=\"text-xs font-medium text-foreground/80\">\n {block.agentName}\n </span>\n <span className=\"text-[10px] text-muted-foreground/60\">\n ({block.entries.reduce((sum, e) => sum + e.count, 0)})\n </span>\n </button>\n\n {/* Entries */}\n {!isCollapsed && (\n <div className=\"ml-4\">\n {block.entries.map((displayEntry, i) => (\n <TimelineItem\n key={displayEntry.entry.id + \"-\" + i}\n displayEntry={displayEntry}\n renderMarkdown={renderMarkdown}\n isExpanded={expandedItems.has(displayEntry.entry.id)}\n onToggleExpanded={() => onToggleItemExpanded(displayEntry.entry.id)}\n />\n ))}\n </div>\n )}\n </div>\n );\n}\n","import { useMemo, useRef, useState, useCallback, type ReactNode } from \"react\";\nimport {\n Brain,\n Wrench,\n BookOpen,\n HardDrive,\n Activity,\n MessageSquare,\n AlertCircle,\n ChevronsDownUp,\n ChevronsUpDown,\n} from \"lucide-react\";\nimport type { TimelineEntry, TimelineEntryType } from \"./types\";\nimport { groupIntoAgentRuns } from \"./utils\";\nimport { TimelineAgentBlock } from \"./TimelineAgentBlock\";\n\n/** Externalized UI state that survives component remounts */\nexport interface TimelineUIState {\n expandedItems: Set<string>;\n collapsedRuns: Set<string>;\n activeFilters: Set<TimelineEntryType>;\n}\n\nexport function createTimelineUIState(): TimelineUIState {\n return {\n expandedItems: new Set(),\n collapsedRuns: new Set(),\n activeFilters: new Set(),\n };\n}\n\n/** Icon + label config for each entry type */\nconst TYPE_CONFIG: {\n type: TimelineEntryType;\n icon: typeof Brain;\n label: string;\n}[] = [\n { type: \"status_update\", icon: Activity, label: \"Status\" },\n { type: \"thinking\", icon: Brain, label: \"Thinking\" },\n { type: \"tool_call\", icon: Wrench, label: \"Tools\" },\n { type: \"knowledge\", icon: BookOpen, label: \"Knowledge\" },\n { type: \"memory\", icon: HardDrive, label: \"Memory\" },\n { type: \"ai_response\", icon: MessageSquare, label: \"AI\" },\n { type: \"error\", icon: AlertCircle, label: \"Errors\" },\n];\n\ninterface AgentTimelineProps {\n entries: TimelineEntry[];\n renderMarkdown?: (content: string) => ReactNode;\n /**\n * External UI state store. When provided, expand/collapse/filter state\n * is read from and written to this object (which should be ref-backed\n * in the parent) so it survives component remounts during streaming.\n */\n uiState?: TimelineUIState;\n /**\n * Maximum height of the scrollable timeline container.\n * Defaults to \"300px\". Set to \"none\" to disable.\n */\n maxHeight?: string;\n}\n\nexport function AgentTimeline({ entries, renderMarkdown, uiState, maxHeight = \"300px\" }: AgentTimelineProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Render tick: forces re-renders AND invalidates useMemo deps when we mutate Sets in-place\n const [renderTick, setRenderTick] = useState(0);\n const forceRender = useCallback(() => setRenderTick((t) => t + 1), []);\n\n // Resolve state: prefer external uiState (ref-backed, survives remounts)\n // Fall back to internal state if no external store provided\n const [internalExpandedItems] = useState<Set<string>>(() => new Set());\n const [internalCollapsedRuns] = useState<Set<string>>(() => new Set());\n const [internalActiveFilters] = useState<Set<TimelineEntryType>>(() => new Set());\n\n const expandedItems = uiState?.expandedItems ?? internalExpandedItems;\n const collapsedRuns = uiState?.collapsedRuns ?? internalCollapsedRuns;\n const activeFilters = uiState?.activeFilters ?? internalActiveFilters;\n\n // Compute which types actually exist in the entries\n const availableTypes = useMemo(() => {\n const types = new Set<TimelineEntryType>();\n for (const entry of entries) {\n types.add(entry.type);\n }\n return types;\n }, [entries]);\n\n // Filter entries, then group into runs\n // eslint-disable-next-line react-hooks/exhaustive-deps -- renderTick invalidates when mutated Sets change\n const filteredEntries = useMemo(\n () =>\n activeFilters.size === 0\n ? entries\n : entries.filter((e) => activeFilters.has(e.type)),\n [entries, activeFilters, renderTick],\n );\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const agentRuns = useMemo(() => groupIntoAgentRuns(filteredEntries), [filteredEntries, renderTick]);\n\n // --- Mutators (mutate the set in-place + trigger re-render) ---\n\n const toggleFilter = useCallback((type: TimelineEntryType) => {\n if (activeFilters.has(type)) {\n activeFilters.delete(type);\n } else {\n activeFilters.add(type);\n }\n forceRender();\n }, [activeFilters, forceRender]);\n\n const clearFilters = useCallback(() => {\n activeFilters.clear();\n forceRender();\n }, [activeFilters, forceRender]);\n\n const toggleItemExpanded = useCallback((entryId: string) => {\n if (expandedItems.has(entryId)) {\n expandedItems.delete(entryId);\n } else {\n expandedItems.add(entryId);\n }\n forceRender();\n }, [expandedItems, forceRender]);\n\n const collapseAll = useCallback(() => {\n collapsedRuns.clear();\n agentRuns.forEach((run, i) => {\n collapsedRuns.add(`${run.agentName}-${i}`);\n });\n expandedItems.clear();\n forceRender();\n }, [agentRuns, collapsedRuns, expandedItems, forceRender]);\n\n const expandAll = useCallback(() => {\n collapsedRuns.clear();\n agentRuns.forEach((run, i) => {\n collapsedRuns.add(`${run.agentName}-${i}:expanded`);\n });\n forceRender();\n }, [agentRuns, collapsedRuns, forceRender]);\n\n if (entries.length === 0) return null;\n\n const isSingle = agentRuns.length === 1;\n const hasActiveFilter = activeFilters.size > 0;\n\n const scrollStyle = maxHeight !== \"none\" ? { maxHeight } : undefined;\n\n return (\n <div\n ref={containerRef}\n className={maxHeight !== \"none\" ? \"overflow-y-auto\" : \"\"}\n style={scrollStyle}\n >\n {/* Filter + controls bar (sticky within scroll container) */}\n <div className=\"sticky top-0 z-10 bg-background flex items-center gap-1 py-1.5 mb-1 border-b border-border/50 flex-wrap pl-2\">\n {/* Type filter chips */}\n {TYPE_CONFIG.filter((tc) => availableTypes.has(tc.type)).map((tc) => {\n const isActive = activeFilters.has(tc.type);\n const count = entries.filter((e) => e.type === tc.type).length;\n return (\n <button\n key={tc.type}\n onClick={() => toggleFilter(tc.type)}\n className={`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] transition-colors ${\n isActive\n ? \"bg-accent text-accent-foreground ring-1 ring-accent-foreground/20\"\n : \"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/50\"\n }`}\n title={`${isActive ? \"Hide\" : \"Show only\"} ${tc.label}`}\n >\n <tc.icon className=\"w-3 h-3\" />\n <span>{count}</span>\n </button>\n );\n })}\n\n {/* Clear filter button */}\n {hasActiveFilter && (\n <button\n onClick={clearFilters}\n className=\"text-[10px] text-muted-foreground/60 hover:text-muted-foreground px-1\"\n >\n Clear\n </button>\n )}\n\n {/* Spacer */}\n <div className=\"flex-1\" />\n\n {/* Collapse/expand all */}\n {!isSingle && (\n <>\n <button\n onClick={collapseAll}\n className=\"inline-flex items-center gap-0.5 text-[10px] text-muted-foreground/60 hover:text-muted-foreground px-1 py-0.5 rounded hover:bg-muted/50 transition-colors\"\n title=\"Collapse all\"\n >\n <ChevronsDownUp className=\"w-3 h-3\" />\n </button>\n <button\n onClick={expandAll}\n className=\"inline-flex items-center gap-0.5 text-[10px] text-muted-foreground/60 hover:text-muted-foreground px-1 py-0.5 rounded hover:bg-muted/50 transition-colors\"\n title=\"Expand all\"\n >\n <ChevronsUpDown className=\"w-3 h-3\" />\n </button>\n </>\n )}\n </div>\n\n {/* Timeline content */}\n {filteredEntries.length === 0 ? (\n <div className=\"text-[10px] text-muted-foreground/50 py-2 text-center\">\n No entries match the selected filters\n </div>\n ) : (\n <div className=\"space-y-0.5\">\n {agentRuns.map((run, i) => {\n const runKey = `${run.agentName}-${i}`;\n const defaultCollapsed = run.depth > 0;\n const isCollapsed = collapsedRuns.has(runKey)\n ? true\n : collapsedRuns.has(`${runKey}:expanded`)\n ? false\n : defaultCollapsed;\n\n return (\n <TimelineAgentBlock\n key={runKey}\n block={run}\n renderMarkdown={renderMarkdown}\n isSingleAgent={isSingle}\n isCollapsed={isCollapsed}\n onToggleCollapsed={() => {\n if (isCollapsed) {\n collapsedRuns.delete(runKey);\n collapsedRuns.add(`${runKey}:expanded`);\n } else {\n collapsedRuns.delete(`${runKey}:expanded`);\n collapsedRuns.add(runKey);\n }\n forceRender();\n }}\n expandedItems={expandedItems}\n onToggleItemExpanded={toggleItemExpanded}\n />\n );\n })}\n </div>\n )}\n </div>\n );\n}\n","/**\n * AgentResponse Component\n *\n * A library-ready presentational component for displaying AI agent responses.\n * Displays thinking, tool calls, knowledge retrieval, memory access, and final response.\n */\n\nimport * as React from \"react\";\nimport { useState, useRef, useMemo, useCallback } from \"react\";\nimport { cn } from \"@optilogic/core\";\nimport { MetadataRow, ThinkingSection, ActionBar, HITLSection } from \"./components\";\nimport { useThinkingTimer } from \"./hooks\";\nimport type { AgentResponseState, FeedbackValue } from \"./types\";\nimport type { HITLInteraction } from \"../hitl-interactions\";\nimport { AgentTimeline, createTimelineUIState } from \"../agent-timeline\";\nimport type { TimelineUIState } from \"../agent-timeline\";\n\nexport interface AgentResponseClassNames {\n /** Classes for the inner container (border, rounded corners, overflow) */\n container?: string;\n /** Classes for the response content section (background, padding) */\n response?: string;\n}\n\nexport interface AgentResponseProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The response state to render */\n state: AgentResponseState;\n\n /** Optional unique ID (for list keys) */\n id?: string;\n\n /** Optional timestamp to display */\n timestamp?: Date;\n\n /** Feedback state (controlled) */\n feedback?: FeedbackValue;\n onFeedbackChange?: (feedback: FeedbackValue) => void;\n\n /** Callback when the response is copied via the action bar */\n onResponseCopy?: (response: string) => void;\n\n /** Thinking section expansion (controlled or uncontrolled) */\n defaultThinkingExpanded?: boolean;\n thinkingExpanded?: boolean;\n onThinkingExpandedChange?: (expanded: boolean) => void;\n\n /** Action bar visibility mode */\n actionsVisible?: boolean | \"hover\";\n\n /**\n * Optional HITL (Human-in-the-Loop) interactions to display as a\n * collapsible section within the response. When provided, a \"Clarifying\n * Questions\" section appears between the thinking/metadata area and\n * the response content.\n */\n hitlInteractions?: HITLInteraction[];\n\n /** Whether the HITL section starts expanded (default: false) */\n defaultHITLExpanded?: boolean;\n\n /**\n * Optional content to display in the MetadataRow's middle area,\n * between the thinking toggle (left) and activity indicators (right).\n * Typically used for ephemeral status messages during processing.\n * The parent is responsible for setting and clearing this content.\n *\n * @example\n * <AgentResponse\n * state={state}\n * statusContent={\n * state.status !== 'complete'\n * ? <TruncatedMessage message=\"Analyzing data...\" />\n * : undefined\n * }\n * />\n */\n statusContent?: React.ReactNode;\n\n /**\n * Custom markdown renderer for the response content.\n * If not provided, the response will be rendered as plain text.\n *\n * @example\n * <AgentResponse\n * state={state}\n * renderMarkdown={(content) => <MyMarkdownRenderer content={content} />}\n * />\n */\n renderMarkdown?: (content: string) => React.ReactNode;\n\n /**\n * Custom markdown renderer for the thinking content.\n * If not provided, the thinking will be rendered as plain preformatted text.\n *\n * @example\n * <AgentResponse\n * state={state}\n * renderThinkingMarkdown={(content) => <MyMarkdownRenderer content={content} />}\n * />\n */\n renderThinkingMarkdown?: (content: string) => React.ReactNode;\n\n /**\n * Maximum height of the AgentTimeline scrollable container.\n * Defaults to \"300px\". Set to \"none\" to disable the constraint.\n */\n timelineMaxHeight?: string;\n\n /**\n * Class name overrides for internal elements.\n * Use this to customize the container border/background or response section styling.\n *\n * @example\n * // Transparent background and borders\n * <AgentResponse\n * state={state}\n * classNames={{\n * container: \"border-transparent\",\n * response: \"bg-transparent\",\n * }}\n * />\n */\n classNames?: AgentResponseClassNames;\n}\n\n/**\n * AgentResponse Component\n *\n * A complete component for displaying AI agent responses including:\n * - Thinking/reasoning content (collapsible)\n * - Tool calls, knowledge retrieval, and memory access indicators\n * - Final response with optional markdown rendering\n * - Action bar with copy and feedback buttons\n *\n * @example\n * // Basic usage with useAgentResponseAccumulator hook\n * const { state, handleMessage } = useAgentResponseAccumulator();\n *\n * <AgentResponse state={state} />\n *\n * @example\n * // With markdown rendering and feedback\n * <AgentResponse\n * state={state}\n * renderMarkdown={(content) => <ReactMarkdown>{content}</ReactMarkdown>}\n * feedback={feedback}\n * onFeedbackChange={setFeedback}\n * />\n *\n * @example\n * // Controlled thinking expansion\n * <AgentResponse\n * state={state}\n * thinkingExpanded={isExpanded}\n * onThinkingExpandedChange={setIsExpanded}\n * />\n */\nconst AgentResponse = React.forwardRef<HTMLDivElement, AgentResponseProps>(\n (\n {\n state,\n id,\n timestamp,\n feedback,\n onFeedbackChange,\n onResponseCopy,\n defaultThinkingExpanded = false,\n thinkingExpanded: controlledThinkingExpanded,\n onThinkingExpandedChange,\n actionsVisible = \"hover\",\n hitlInteractions,\n defaultHITLExpanded = false,\n statusContent,\n renderMarkdown,\n renderThinkingMarkdown,\n timelineMaxHeight,\n classNames,\n className,\n ...props\n },\n ref\n ) => {\n // Ref-backed timeline UI state (survives remounts during streaming)\n const timelineUIStateRef = useRef<TimelineUIState>(createTimelineUIState());\n\n // Uncontrolled thinking expanded state\n const [uncontrolledExpanded, setUncontrolledExpanded] = useState(defaultThinkingExpanded);\n\n // Determine if thinking is controlled\n const isThinkingControlled = controlledThinkingExpanded !== undefined;\n const thinkingExpanded = isThinkingControlled\n ? controlledThinkingExpanded\n : uncontrolledExpanded;\n\n // Toggle thinking handler\n const toggleThinking = useCallback(() => {\n const newValue = !thinkingExpanded;\n if (isThinkingControlled) {\n onThinkingExpandedChange?.(newValue);\n } else {\n setUncontrolledExpanded(newValue);\n }\n }, [thinkingExpanded, isThinkingControlled, onThinkingExpandedChange]);\n\n // Hover state for action bar visibility\n const [isHovered, setIsHovered] = useState(false);\n\n // Thinking timer\n const elapsedTime = useThinkingTimer({\n startTime: state.thinkingStartTime,\n endTime: state.responseCompleteTime,\n status: state.status,\n });\n\n // Calculate total time (from first message to response complete)\n const totalTimeSeconds = useMemo(() => {\n if (!state.firstMessageTime || !state.responseCompleteTime) return 0;\n return (state.responseCompleteTime - state.firstMessageTime) / 1000;\n }, [state.firstMessageTime, state.responseCompleteTime]);\n\n // Check if we have any thinking content (plain text, structured, or timeline)\n const hasTimelineEntries = !!(state.timelineEntries && state.timelineEntries.length > 0);\n const hasThinkingContent =\n !!state.thinking || (state.thinkingSteps && state.thinkingSteps.length > 0) || hasTimelineEntries || false;\n\n const hasHITLInteractions =\n hitlInteractions && hitlInteractions.length > 0;\n\n // Derived state: has any content been received?\n const hasAnyContent =\n hasThinkingContent ||\n state.toolCalls.length > 0 ||\n state.knowledge.length > 0 ||\n state.memory.length > 0 ||\n state.statusUpdates.length > 0 ||\n hasHITLInteractions ||\n state.response;\n\n // Derived state: should show metadata row?\n const showMetadataRow =\n hasThinkingContent ||\n state.toolCalls.length > 0 ||\n state.knowledge.length > 0 ||\n state.memory.length > 0 ||\n state.statusUpdates.length > 0 ||\n state.status === \"processing\";\n\n // Determine action bar visibility\n const showActionBar = state.status === \"complete\" && state.response;\n const isActionBarVisible =\n actionsVisible === true ||\n (actionsVisible === \"hover\" && isHovered);\n\n // If no content, render nothing\n if (!hasAnyContent) {\n return null;\n }\n\n return (\n <div\n ref={ref}\n className={className}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n {...props}\n >\n {/* Message Content Container */}\n <div className={cn(\"border border-border rounded-lg overflow-hidden\", classNames?.container)}>\n {/* Metadata Row - show if there's any metadata or thinking */}\n {showMetadataRow && (\n <>\n <MetadataRow\n hasThinking={hasThinkingContent}\n isExpanded={thinkingExpanded}\n onToggle={toggleThinking}\n toolCalls={state.toolCalls}\n knowledge={state.knowledge}\n memory={state.memory}\n statusUpdates={state.statusUpdates}\n statusContent={statusContent}\n status={state.status}\n elapsedTime={elapsedTime}\n />\n\n {/* Thinking Content - AgentTimeline when timeline entries exist, ThinkingSection otherwise */}\n {hasTimelineEntries ? (\n thinkingExpanded && (\n <div className=\"pb-3 border-t border-border\">\n <AgentTimeline\n entries={state.timelineEntries!}\n renderMarkdown={renderThinkingMarkdown}\n uiState={timelineUIStateRef.current}\n maxHeight={timelineMaxHeight}\n />\n </div>\n )\n ) : (\n <ThinkingSection\n content={\n state.thinkingSteps && state.thinkingSteps.length > 0\n ? state.thinkingSteps\n : state.thinking\n }\n isExpanded={thinkingExpanded}\n renderMarkdown={renderThinkingMarkdown}\n />\n )}\n </>\n )}\n\n {/* HITL Interactions - collapsible section */}\n {hasHITLInteractions && (\n <HITLSection\n interactions={hitlInteractions}\n defaultExpanded={defaultHITLExpanded}\n />\n )}\n\n {/* Response Section */}\n {state.response && (\n <div\n className={cn(\n \"bg-muted/50 p-4\",\n showMetadataRow && \"border-t border-border\",\n classNames?.response\n )}\n >\n {renderMarkdown ? (\n renderMarkdown(state.response)\n ) : (\n <span className=\"whitespace-pre-wrap\">{state.response}</span>\n )}\n </div>\n )}\n </div>\n\n {/* Action Bar - outside the message container, visible on hover when complete */}\n {showActionBar && (\n <ActionBar\n response={state.response}\n isVisible={isActionBarVisible}\n totalTimeSeconds={totalTimeSeconds}\n feedback={feedback}\n onFeedbackChange={onFeedbackChange}\n onResponseCopy={onResponseCopy}\n />\n )}\n </div>\n );\n }\n);\nAgentResponse.displayName = \"AgentResponse\";\n\nexport { AgentResponse };\n","import * as React from \"react\";\nimport { cn } from \"@optilogic/core\";\n\nexport interface UserPromptProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The text content of the user's message */\n content: string;\n /** Optional timestamp to display below the message */\n timestamp?: Date;\n}\n\n/**\n * UserPrompt component\n *\n * Displays a user's chat message in a styled bubble.\n * Used alongside AgentResponse to create chat interfaces.\n *\n * @example\n * ```tsx\n * <UserPrompt\n * content=\"What is the weather today?\"\n * timestamp={new Date()}\n * />\n * ```\n *\n * @example\n * ```tsx\n * // Custom styling\n * <UserPrompt\n * content=\"Hello world\"\n * className=\"max-w-full\"\n * />\n * ```\n */\nexport const UserPrompt = React.forwardRef<HTMLDivElement, UserPromptProps>(\n ({ content, timestamp, className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn(\n \"w-fit max-w-[80%] rounded-lg px-4 pt-3.5 pb-3\",\n \"bg-secondary text-secondary-foreground\",\n className\n )}\n {...props}\n >\n <p className=\"whitespace-pre-wrap\">{content}</p>\n {timestamp && (\n <p className=\"text-xs text-secondary-foreground/70 mt-1\">\n {timestamp.toLocaleTimeString([], {\n hour: \"2-digit\",\n minute: \"2-digit\",\n })}\n </p>\n )}\n </div>\n );\n }\n);\n\nUserPrompt.displayName = \"UserPrompt\";\n","import * as React from \"react\";\nimport { Send, Loader2, Square } from \"lucide-react\";\nimport { cn, IconButton, Tooltip } from \"@optilogic/core\";\nimport {\n SlateEditor,\n Text,\n type SlateEditorRef,\n type NodeEntry,\n type DecoratedRange,\n type RenderLeafProps,\n} from \"@optilogic/editor\";\nimport type { UserPromptInputProps, UserPromptInputRef } from \"./types\";\n\n/**\n * Creates a decorate function that highlights code blocks.\n * Handles both complete (```...```) and unclosed (```...) code blocks.\n */\nfunction createCodeBlockDecorate(entry: NodeEntry): DecoratedRange[] {\n const [node, path] = entry;\n const ranges: DecoratedRange[] = [];\n\n if (!Text.isText(node)) {\n return ranges;\n }\n\n const { text } = node;\n\n // Find all ``` positions\n const backtickPositions: number[] = [];\n let searchStart = 0;\n while (true) {\n const pos = text.indexOf(\"```\", searchStart);\n if (pos === -1) break;\n backtickPositions.push(pos);\n searchStart = pos + 3;\n }\n\n // Process pairs of backticks (and handle unclosed blocks)\n let i = 0;\n while (i < backtickPositions.length) {\n const openPos = backtickPositions[i];\n const closePos = backtickPositions[i + 1];\n\n // Mark opening delimiter\n ranges.push({\n anchor: { path, offset: openPos },\n focus: { path, offset: openPos + 3 },\n codeDelimiter: true,\n } as DecoratedRange);\n\n if (closePos !== undefined) {\n // Complete code block - mark content and closing delimiter\n if (closePos > openPos + 3) {\n ranges.push({\n anchor: { path, offset: openPos + 3 },\n focus: { path, offset: closePos },\n codeBlock: true,\n } as DecoratedRange);\n }\n ranges.push({\n anchor: { path, offset: closePos },\n focus: { path, offset: closePos + 3 },\n codeDelimiter: true,\n } as DecoratedRange);\n i += 2; // Move past both opening and closing\n } else {\n // Unclosed code block - mark everything to end as code\n if (text.length > openPos + 3) {\n ranges.push({\n anchor: { path, offset: openPos + 3 },\n focus: { path, offset: text.length },\n codeBlock: true,\n } as DecoratedRange);\n }\n i += 1; // Move past opening only\n }\n }\n\n return ranges;\n}\n\n/**\n * Custom leaf renderer for code block styling\n */\nfunction CodeBlockLeaf({ attributes, children, leaf }: RenderLeafProps) {\n const leafAny = leaf as { codeBlock?: boolean; codeDelimiter?: boolean };\n\n if (leafAny.codeBlock) {\n return (\n <span\n {...attributes}\n className=\"bg-muted/50 text-muted-foreground font-mono text-sm rounded px-1\"\n >\n {children}\n </span>\n );\n }\n\n if (leafAny.codeDelimiter) {\n return (\n <span\n {...attributes}\n className=\"text-muted-foreground/50 font-mono text-sm\"\n >\n {children}\n </span>\n );\n }\n\n return <span {...attributes}>{children}</span>;\n}\n\n/**\n * UserPromptInput Component\n *\n * A rich text input for user messages that wraps SlateEditor.\n * Features:\n * - Code block styling with triple backticks\n * - Send button with loading state\n * - Action slot for additional buttons\n * - Tag support (optional)\n *\n * @example\n * <UserPromptInput\n * placeholder=\"Type your message...\"\n * onSubmit={(text) => sendMessage(text)}\n * renderActions={() => (\n * <IconButton icon={<Paperclip />} aria-label=\"Attach file\" />\n * )}\n * />\n */\nexport const UserPromptInput = React.forwardRef<\n UserPromptInputRef,\n UserPromptInputProps\n>(\n (\n {\n value = \"\",\n onChange,\n onSubmit,\n clearOnSubmit = true,\n placeholder = \"Type your message...\",\n disabled = false,\n isSubmitting = false,\n onStop,\n stopTooltip,\n stopClassName,\n disableWhileSubmitting = true,\n autoFocus = false,\n refocusAfterSubmit = false,\n onReady,\n minRows = 1,\n maxRows = 6,\n renderActions,\n enableTags = false,\n onTagCreate,\n onTagDelete,\n className,\n ...props\n },\n ref\n ) => {\n const editorRef = React.useRef<SlateEditorRef>(null);\n const [internalValue, setInternalValue] = React.useState(value);\n const prevIsSubmitting = React.useRef(isSubmitting);\n const hasEmittedReady = React.useRef(false);\n\n // Sync internal value with prop\n React.useEffect(() => {\n setInternalValue(value);\n }, [value]);\n\n // Handle autoFocus - use double RAF to ensure Slate is fully initialized\n React.useEffect(() => {\n if (autoFocus) {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n editorRef.current?.focus();\n });\n });\n }\n }, [autoFocus]);\n\n // Emit onReady callback when editor is initialized\n React.useEffect(() => {\n if (!hasEmittedReady.current && onReady) {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n hasEmittedReady.current = true;\n onReady();\n });\n });\n }\n }, [onReady]);\n\n // Refocus after submit completes\n React.useEffect(() => {\n if (refocusAfterSubmit && prevIsSubmitting.current && !isSubmitting) {\n requestAnimationFrame(() => {\n editorRef.current?.focus();\n });\n }\n prevIsSubmitting.current = isSubmitting;\n }, [isSubmitting, refocusAfterSubmit]);\n\n // Expose ref methods\n React.useImperativeHandle(\n ref,\n () => ({\n focus: () => {\n try {\n editorRef.current?.focus();\n } catch {\n // Retry after Slate initializes (handles early calls)\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n editorRef.current?.focus();\n });\n });\n }\n },\n clear: () => {\n editorRef.current?.clear();\n setInternalValue(\"\");\n },\n getText: () => editorRef.current?.getText() ?? \"\",\n insertText: (text: string) => editorRef.current?.insertText(text),\n }),\n []\n );\n\n const handleChange = React.useCallback(\n (newValue: string) => {\n setInternalValue(newValue);\n onChange?.(newValue);\n },\n [onChange]\n );\n\n const handleSubmit = React.useCallback(\n (text: string) => {\n if (disabled || isSubmitting) return;\n if (!text.trim()) return;\n\n onSubmit?.(text.trim());\n\n if (clearOnSubmit) {\n editorRef.current?.clear();\n setInternalValue(\"\");\n }\n },\n [disabled, isSubmitting, onSubmit, clearOnSubmit]\n );\n\n const handleSendClick = React.useCallback(() => {\n const text = editorRef.current?.getText() ?? \"\";\n handleSubmit(text);\n }, [handleSubmit]);\n\n const hasContent = internalValue.trim().length > 0;\n const canSubmit = hasContent && !disabled && !isSubmitting;\n\n return (\n <div\n className={cn(\n \"rounded-lg border border-input bg-background\",\n disabled && \"opacity-50 cursor-not-allowed\",\n className\n )}\n {...props}\n >\n {/* Editor area */}\n <div className=\"pl-2 pr-0 pt-1 pb-1\">\n <SlateEditor\n ref={editorRef}\n value={internalValue}\n onChange={handleChange}\n onSubmit={handleSubmit}\n clearOnSubmit={false}\n placeholder={placeholder}\n disabled={disabled || (disableWhileSubmitting && isSubmitting)}\n enableTags={enableTags}\n onTagCreate={onTagCreate}\n onTagDelete={onTagDelete}\n minRows={minRows}\n maxRows={maxRows}\n decorate={createCodeBlockDecorate}\n renderLeaf={CodeBlockLeaf}\n />\n </div>\n\n {/* Actions row */}\n <div className=\"flex items-center justify-between pl-2 pr-1 pb-1 pt-1\">\n {/* Left actions slot */}\n <div className=\"flex items-center gap-1\">{renderActions?.()}</div>\n\n {/* Send/Stop button */}\n {isSubmitting && onStop ? (\n <Tooltip content={stopTooltip} disabled={!stopTooltip}>\n <IconButton\n icon={<Square />}\n variant=\"filled\"\n size=\"sm\"\n aria-label={stopTooltip || \"Stop\"}\n onClick={onStop}\n className={stopClassName}\n />\n </Tooltip>\n ) : (\n <IconButton\n icon={\n isSubmitting ? (\n <Loader2 className=\"animate-spin\" />\n ) : (\n <Send />\n )\n }\n variant=\"filled\"\n size=\"sm\"\n aria-label={isSubmitting ? \"Sending...\" : \"Send message\"}\n disabled={!canSubmit}\n onClick={handleSendClick}\n />\n )}\n </div>\n </div>\n );\n }\n);\n\nUserPromptInput.displayName = \"UserPromptInput\";\n","import type { ResponseSegment } from \"./types\";\n\n/**\n * Regex to match ```json:action fenced code blocks.\n * Captures the JSON content between the fences.\n */\nconst ACTION_BLOCK_REGEX = /```json:action\\s*\\n([\\s\\S]*?)```/g;\n\n/**\n * Parse response text into interleaved markdown and action segments.\n *\n * Finds ```json:action ... ``` fenced code blocks, extracts them as\n * action segments, and returns the surrounding text as markdown segments.\n *\n * Malformed JSON or blocks missing a \"type\" field are left as markdown\n * (rendered as raw code blocks) for graceful degradation.\n */\nexport function parseResponseSegments(text: string): ResponseSegment[] {\n if (!text) return [];\n\n const segments: ResponseSegment[] = [];\n let lastIndex = 0;\n\n // Reset regex state (global regexes are stateful)\n ACTION_BLOCK_REGEX.lastIndex = 0;\n\n let match: RegExpExecArray | null;\n while ((match = ACTION_BLOCK_REGEX.exec(text)) !== null) {\n // Add markdown segment for text before this match\n const before = text.slice(lastIndex, match.index);\n if (before.trim()) {\n segments.push({ kind: \"markdown\", content: before });\n }\n\n // Try to parse the JSON content\n const jsonContent = match[1].trim();\n let parsed: Record<string, unknown> | null = null;\n try {\n parsed = JSON.parse(jsonContent);\n } catch {\n // Malformed JSON — fall back to markdown\n }\n\n if (parsed && typeof parsed === \"object\" && typeof parsed.type === \"string\") {\n segments.push({\n kind: \"action\",\n actionType: parsed.type as string,\n payload: parsed,\n });\n } else {\n // Missing \"type\" field or invalid JSON — render as raw code block\n const rawBlock = match[0];\n segments.push({ kind: \"markdown\", content: rawBlock });\n }\n\n lastIndex = match.index + match[0].length;\n }\n\n // Add trailing markdown segment\n const trailing = text.slice(lastIndex);\n if (trailing.trim()) {\n segments.push({ kind: \"markdown\", content: trailing });\n }\n\n return segments;\n}\n","import { useMemo } from \"react\";\nimport { parseResponseSegments } from \"./parseResponseSegments\";\nimport type { ActionMarkdownRendererProps } from \"./types\";\n\n/**\n * Renders agent response text with inline action components.\n *\n * Parses the response for ```json:action blocks, renders markdown\n * segments via the provided renderMarkdown function, and renders\n * action segments via the component registry.\n *\n * Unknown action types fall back to a raw JSON code block display.\n */\nexport function ActionMarkdownRenderer({\n content,\n registry,\n renderMarkdown,\n onAction,\n isLatest,\n}: ActionMarkdownRendererProps) {\n const segments = useMemo(() => parseResponseSegments(content), [content]);\n\n // If no action blocks found, render as plain markdown (skip extra wrapper divs)\n if (segments.length === 1 && segments[0].kind === \"markdown\") {\n return <>{renderMarkdown(segments[0].content)}</>;\n }\n\n return (\n <>\n {segments.map((segment, index) => {\n if (segment.kind === \"markdown\") {\n return <div key={`md-${index}`}>{renderMarkdown(segment.content)}</div>;\n }\n\n // Action segment — look up registered component\n const Component = registry[segment.actionType];\n if (!Component) {\n // Fallback: render raw JSON as a styled code block\n return (\n <pre\n key={`action-fallback-${index}`}\n className=\"my-4 p-4 rounded-lg border border-border bg-muted text-sm font-mono overflow-x-auto\"\n >\n <code>{JSON.stringify(segment.payload, null, 2)}</code>\n </pre>\n );\n }\n\n return (\n <Component\n key={`action-${segment.actionType}-${index}`}\n payload={segment.payload}\n onAction={onAction}\n isLatest={isLatest}\n />\n );\n })}\n </>\n );\n}\n","/**\n * System prompt instructions for agents that emit inline action blocks.\n *\n * Import and append to your agent's system prompt so it knows the\n * json:action format. The XML tags ensure clear boundaries for the LLM.\n *\n * When adding a new action type, add an entry under \"Available action types\"\n * and create the corresponding React component + registry entry.\n */\nexport const INLINE_ACTION_PROMPT = `\n<inline_actions>\nWhen your response should include interactive components (like query viewers,\ndata tables, or executable actions), embed them as fenced code blocks using\nthe \\`json:action\\` language tag:\n\n\\`\\`\\`json:action\n{\n \"type\": \"action-type-here\",\n ...action-specific fields\n}\n\\`\\`\\`\n\nRules:\n- Each block must contain valid JSON with a \"type\" field.\n- The \"type\" must match a registered action component on the frontend.\n- Multiple action blocks per response are allowed.\n- Surround action blocks with normal markdown text for user context.\n- The action block is rendered as an interactive component in the chat UI.\n- SQL strings inside JSON must be properly escaped (newlines as \\\\n, quotes as \\\\\").\n\nAvailable action types:\n\n- \"optimap-query\": Displays SQL queries with a button to execute them and\n update the 3D globe map.\n Required fields:\n - type: \"optimap-query\"\n - locations_sql: string (the validated locations SQL query)\n - routes_sql: string (the validated routes SQL query)\n - database_name: string (the target database name)\n</inline_actions>\n`;\n"]}
1
+ {"version":3,"sources":["../src/components/agent-response/components/ActivityIndicators.tsx","../src/components/agent-response/utils.ts","../src/components/agent-response/components/MetadataRow.tsx","../src/components/agent-response/components/ThinkingSection.tsx","../src/components/agent-response/components/ActionBar.tsx","../src/components/hitl-interactions/HITLQuestionPanel.tsx","../src/components/hitl-interactions/HITLInteractionRecord.tsx","../src/components/agent-response/components/HITLSection.tsx","../src/components/agent-response/components/TruncatedMessage.tsx","../src/components/agent-response/hooks/useThinkingTimer.ts","../src/components/agent-response/types.ts","../src/components/agent-timeline/utils.ts","../src/components/agent-response/reducer.ts","../src/components/agent-response/hooks/useAgentResponseAccumulator.ts","../src/components/agent-timeline/TimelineItem.tsx","../src/components/agent-timeline/TimelineAgentBlock.tsx","../src/components/agent-timeline/AgentTimeline.tsx","../src/components/agent-response/AgentResponse.tsx","../src/components/user-prompt/UserPrompt.tsx","../src/components/user-prompt-input/UserPromptInput.tsx","../src/components/inline-actions/parseResponseSegments.ts","../src/components/inline-actions/ActionMarkdownRenderer.tsx","../src/components/inline-actions/prompts.ts"],"names":["React","jsxs","cn","Popover","jsx","PopoverTrigger","Activity","PopoverContent","Wrench","Book","HardDrive","React2","ChevronUp","ChevronDown","LoadingSpinner","useState","useCallback","ChevronRight","React3","React4","Check","Copy","ThumbsUp","ThumbsDown","React5","useRef","useEffect","useMemo","formatTime","Button","Textarea","React6","React7","MessageCircleQuestion","React8","thinkingStartTime","next","Brain","BookOpen","MessageSquare","AlertCircle","Fragment","ChevronsDownUp","ChevronsUpDown","React9","React10","Text","React11","SlateEditor","Tooltip","IconButton","Square","Loader2","Send"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAM,kBAAA,GAA2BA,kBAAA,CAAA,UAAA;AAAA,EAC/B,C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AAA,EAAU,qFAAA;AAAA,UAEV,QAAA,kBAAAA,eAAC,MAAA,EAAA,EAAM,QAAA,EAAA,IAAA,CAAK,UAAU,OAAA,CAAQ,OAAA,EAAS,IAAA,EAAM,CAAC,CAAA,EAAE;AAAA,SAAA;AAAA,QAH3C,mBAAmB,KAAK,CAAA;AAAA,OAI/B;AAAA,IAEJ;AAEA,IAAA,uBACEA,cAAAA;AAAA,MAAC,SAAA;AAAA,MAAA;AAAA,QAEC,SAAS,OAAA,CAAQ,OAAA;AAAA,QACjB,QAAA;AAAA,QACA;AAAA,OAAA;AAAA,MAHK,CAAA,OAAA,EAAU,OAAA,CAAQ,UAAU,CAAA,CAAA,EAAI,KAAK,CAAA;AAAA,KAI5C;AAAA,EAEJ,CAAC,CAAA,EACH,CAAA;AAEJ;;;AClDO,IAAM,oBAAA,GAAuB;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","file":"index.cjs","sourcesContent":["/**\n * Activity Indicators Component\n *\n * Displays tool, knowledge, memory icons with counts and popovers\n */\n\nimport * as React from \"react\";\nimport { Wrench, Book, HardDrive, Activity } from \"lucide-react\";\nimport { cn, Popover, PopoverTrigger, PopoverContent } from \"@optilogic/core\";\nimport type { ToolCall, KnowledgeItem, MemoryItem, StatusItem } from \"../types\";\n\nexport interface ActivityIndicatorsProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Tool calls to display */\n toolCalls: ToolCall[];\n /** Knowledge items to display */\n knowledge: KnowledgeItem[];\n /** Memory items to display */\n memory: MemoryItem[];\n /** Status updates to display */\n statusUpdates?: StatusItem[];\n /** Tour anchor (`data-tour`) on the status updates popover trigger. */\n statusUpdateAnchor?: string;\n /** Tour anchor (`data-tour`) on the tool calls popover trigger. */\n toolCallsAnchor?: string;\n /** Tour anchor (`data-tour`) on the knowledge popover trigger. */\n knowledgeAnchor?: string;\n /** Tour anchor (`data-tour`) on the memory popover trigger. */\n memoryAnchor?: string;\n}\n\n/**\n * ActivityIndicators Component\n *\n * Displays icons with counts for tool calls, knowledge retrieval, and memory access.\n * Each icon has a popover showing details when clicked.\n *\n * @example\n * <ActivityIndicators\n * toolCalls={state.toolCalls}\n * knowledge={state.knowledge}\n * memory={state.memory}\n * />\n */\nconst ActivityIndicators = React.forwardRef<HTMLDivElement, ActivityIndicatorsProps>(\n (\n {\n toolCalls,\n knowledge,\n memory,\n statusUpdates = [],\n statusUpdateAnchor,\n toolCallsAnchor,\n knowledgeAnchor,\n memoryAnchor,\n className,\n ...props\n },\n ref,\n ) => {\n const hasAnyActivity =\n toolCalls.length > 0 || knowledge.length > 0 || memory.length > 0 || statusUpdates.length > 0;\n\n if (!hasAnyActivity) return null;\n\n return (\n <div ref={ref} className={cn(\"flex items-center gap-2\", className)} {...props}>\n {/* Status Updates */}\n {statusUpdates.length > 0 && (\n <Popover>\n <PopoverTrigger asChild>\n <button\n data-tour={statusUpdateAnchor}\n className=\"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors\"\n onClick={(e) => e.stopPropagation()}\n >\n <Activity className=\"w-3.5 h-3.5\" />\n <span className=\"text-xs\">{statusUpdates.length}</span>\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-80\">\n <div className=\"space-y-2\">\n <h4 className=\"font-medium text-sm\">Status Updates</h4>\n <div className=\"space-y-2 max-h-60 overflow-auto\">\n {statusUpdates.map((item) => (\n <div key={item.id} className=\"p-2 bg-muted rounded text-xs\">\n {item.agent && (\n <div className=\"font-medium text-muted-foreground\">{item.agent}</div>\n )}\n <div className={item.agent ? \"mt-1\" : \"\"}>{item.message}</div>\n </div>\n ))}\n </div>\n </div>\n </PopoverContent>\n </Popover>\n )}\n\n {/* Tool Calls */}\n {toolCalls.length > 0 && (\n <Popover>\n <PopoverTrigger asChild>\n <button\n data-tour={toolCallsAnchor}\n className=\"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors\"\n onClick={(e) => e.stopPropagation()}\n >\n <Wrench className=\"w-3.5 h-3.5\" />\n <span className=\"text-xs\">{toolCalls.length}</span>\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-80\">\n <div className=\"space-y-2\">\n <h4 className=\"font-medium text-sm\">Tool Calls</h4>\n <div className=\"space-y-2 max-h-60 overflow-auto\">\n {toolCalls.map((tool) => (\n <div key={tool.id} className=\"p-2 bg-muted rounded text-xs\">\n <div className=\"font-medium\">{tool.name}</div>\n {tool.arguments && (\n <pre className=\"mt-1 text-muted-foreground overflow-x-auto\">\n {JSON.stringify(tool.arguments, null, 2)}\n </pre>\n )}\n </div>\n ))}\n </div>\n </div>\n </PopoverContent>\n </Popover>\n )}\n\n {/* Knowledge */}\n {knowledge.length > 0 && (\n <Popover>\n <PopoverTrigger asChild>\n <button\n data-tour={knowledgeAnchor}\n className=\"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors\"\n onClick={(e) => e.stopPropagation()}\n >\n <Book className=\"w-3.5 h-3.5\" />\n <span className=\"text-xs\">{knowledge.length}</span>\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-80\">\n <div className=\"space-y-2\">\n <h4 className=\"font-medium text-sm\">Knowledge Retrieved</h4>\n <div className=\"space-y-2 max-h-60 overflow-auto\">\n {knowledge.map((item) => (\n <div key={item.id} className=\"p-2 bg-muted rounded text-xs\">\n <div className=\"font-medium\">{item.source}</div>\n <div className=\"mt-1 text-muted-foreground\">\n {item.content}\n </div>\n </div>\n ))}\n </div>\n </div>\n </PopoverContent>\n </Popover>\n )}\n\n {/* Memory */}\n {memory.length > 0 && (\n <Popover>\n <PopoverTrigger asChild>\n <button\n data-tour={memoryAnchor}\n className=\"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors\"\n onClick={(e) => e.stopPropagation()}\n >\n <HardDrive className=\"w-3.5 h-3.5\" />\n <span className=\"text-xs\">{memory.length}</span>\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-80\">\n <div className=\"space-y-2\">\n <h4 className=\"font-medium text-sm\">Memory Accessed</h4>\n <div className=\"space-y-2 max-h-60 overflow-auto\">\n {memory.map((item) => (\n <div key={item.id} className=\"p-2 bg-muted rounded text-xs\">\n <div className=\"font-medium\">{item.type}</div>\n <div className=\"mt-1 text-muted-foreground\">\n {item.content}\n </div>\n </div>\n ))}\n </div>\n </div>\n </PopoverContent>\n </Popover>\n )}\n </div>\n );\n }\n);\nActivityIndicators.displayName = \"ActivityIndicators\";\n\nexport { ActivityIndicators };\n","/**\n * Agent Response Utility Functions\n */\n\n/**\n * Format elapsed time for display\n * - Under 60s: \"Xs\" (e.g., \"23s\")\n * - 60+ seconds while active: \"M:SS\" (e.g., \"1:23\")\n * - Complete under 60s: \"Xs\" (e.g., \"45s\")\n * - Complete 60-119s: \"1.X min\" (e.g., \"1.2 min\")\n * - Complete 120+ s: \"X.X min\" (e.g., \"2.5 min\")\n */\nexport function formatTime(seconds: number, isComplete: boolean): string {\n if (seconds < 1) {\n return isComplete ? \"<1s\" : \"0s\";\n }\n\n if (isComplete) {\n // Completed state formatting\n if (seconds < 60) {\n return `${Math.round(seconds)}s`;\n }\n const minutes = seconds / 60;\n return `${minutes.toFixed(1)} min`;\n }\n\n // Active state formatting\n if (seconds < 60) {\n return `${Math.floor(seconds)}s`;\n }\n const mins = Math.floor(seconds / 60);\n const secs = Math.floor(seconds % 60);\n return `${mins}:${secs.toString().padStart(2, \"0\")}`;\n}\n\n/**\n * Format total time for action bar display\n */\nexport function formatTotalTime(seconds: number): string {\n if (seconds < 1) {\n return \"<1s\";\n }\n if (seconds < 60) {\n return `${seconds.toFixed(1)}s`;\n }\n const minutes = seconds / 60;\n return `${minutes.toFixed(1)}m`;\n}\n","/**\n * Metadata Row Component\n *\n * Displays thinking toggle, timer, and activity indicators\n */\n\nimport * as React from \"react\";\nimport { ChevronDown, ChevronUp } from \"lucide-react\";\nimport { cn, LoadingSpinner } from \"@optilogic/core\";\nimport { ActivityIndicators } from \"./ActivityIndicators\";\nimport { formatTime } from \"../utils\";\nimport type { AgentResponseStatus, ToolCall, KnowledgeItem, MemoryItem, StatusItem } from \"../types\";\n\nexport interface MetadataRowProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Whether there is thinking content */\n hasThinking: boolean;\n /** Whether the thinking section is expanded */\n isExpanded: boolean;\n /** Toggle callback for thinking expansion */\n onToggle: () => void;\n /** Tool calls to display */\n toolCalls: ToolCall[];\n /** Knowledge items to display */\n knowledge: KnowledgeItem[];\n /** Memory items to display */\n memory: MemoryItem[];\n /** Status updates to display */\n statusUpdates?: StatusItem[];\n /** Optional content to display in the middle area between left content and activity indicators */\n statusContent?: React.ReactNode;\n /** Current response status */\n status: AgentResponseStatus;\n /** Elapsed time in seconds */\n elapsedTime: number;\n /** Tour anchor (`data-tour`) on the thinking expand/collapse toggle button. */\n thinkingToggleAnchor?: string;\n /** Tour anchor forwarded to the status updates popover trigger inside ActivityIndicators. */\n statusUpdateAnchor?: string;\n /** Tour anchor forwarded to the tool calls popover trigger inside ActivityIndicators. */\n toolCallsAnchor?: string;\n /** Tour anchor forwarded to the knowledge popover trigger inside ActivityIndicators. */\n knowledgeAnchor?: string;\n /** Tour anchor forwarded to the memory popover trigger inside ActivityIndicators. */\n memoryAnchor?: string;\n}\n\n/**\n * MetadataRow Component\n *\n * Displays the metadata row with thinking toggle, timer, and activity indicators.\n * When thinking content is present, the row is clickable to toggle expansion.\n *\n * @example\n * <MetadataRow\n * hasThinking={!!state.thinking}\n * isExpanded={thinkingExpanded}\n * onToggle={toggleThinking}\n * toolCalls={state.toolCalls}\n * knowledge={state.knowledge}\n * memory={state.memory}\n * status={state.status}\n * elapsedTime={elapsedTime}\n * />\n */\nconst MetadataRow = React.forwardRef<HTMLDivElement, MetadataRowProps>(\n (\n {\n hasThinking,\n isExpanded,\n onToggle,\n toolCalls,\n knowledge,\n memory,\n statusUpdates = [],\n statusContent,\n status,\n elapsedTime,\n thinkingToggleAnchor,\n statusUpdateAnchor,\n toolCallsAnchor,\n knowledgeAnchor,\n memoryAnchor,\n className,\n ...props\n },\n ref\n ) => {\n const isProcessing = status === \"processing\";\n const isComplete = status === \"complete\";\n const hasActivity =\n toolCalls.length > 0 || knowledge.length > 0 || memory.length > 0 || statusUpdates.length > 0;\n\n // Determine what to show on the left side\n const renderLeftContent = () => {\n // If we have thinking text, show collapse toggle + label + timer\n if (hasThinking) {\n return (\n <div className=\"flex items-center gap-1.5\">\n {isExpanded ? (\n <ChevronUp className=\"w-3.5 h-3.5 text-muted-foreground\" />\n ) : (\n <ChevronDown className=\"w-3.5 h-3.5 text-muted-foreground\" />\n )}\n <span className=\"text-xs text-muted-foreground\">\n {isComplete\n ? `Thought for ${formatTime(elapsedTime, true)}`\n : `Thinking... ${formatTime(elapsedTime, false)}`}\n </span>\n </div>\n );\n }\n\n // If processing but no thinking text yet, show spinner\n if (isProcessing) {\n return (\n <div className=\"flex items-center gap-1.5\">\n <LoadingSpinner size=\"sm\" variant=\"muted\" className=\"w-3.5 h-3.5\" />\n <span className=\"text-xs text-muted-foreground\">Processing</span>\n </div>\n );\n }\n\n // Complete with no thinking - show nothing on left (just activity on right)\n return null;\n };\n\n const leftContent = renderLeftContent();\n\n // If nothing to show (no thinking, not processing, no activity, no status content), hide the row\n if (!leftContent && !hasActivity && !statusContent) {\n return null;\n }\n\n // Always use a div for the row to avoid nesting buttons\n // When there's thinking, only the left side is clickable\n return (\n <div\n ref={ref}\n className={cn(\"w-full flex items-center justify-between px-3 py-2\", className)}\n {...props}\n >\n {/* Left content - clickable when there's thinking */}\n {hasThinking ? (\n <button\n data-tour={thinkingToggleAnchor}\n onClick={onToggle}\n className=\"flex items-center gap-1.5 hover:bg-muted/50 -ml-1.5 pl-1.5 pr-2 py-0.5 rounded transition-colors shrink-0\"\n >\n {leftContent}\n </button>\n ) : (\n <div className=\"flex items-center gap-1.5 shrink-0\">\n {leftContent}\n </div>\n )}\n\n {/* Middle content - status content slot */}\n {statusContent && (\n <div className=\"flex-1 min-w-0 mx-2\">\n {statusContent}\n </div>\n )}\n\n <ActivityIndicators\n toolCalls={toolCalls}\n knowledge={knowledge}\n memory={memory}\n statusUpdates={statusUpdates}\n statusUpdateAnchor={statusUpdateAnchor}\n toolCallsAnchor={toolCallsAnchor}\n knowledgeAnchor={knowledgeAnchor}\n memoryAnchor={memoryAnchor}\n />\n </div>\n );\n }\n);\nMetadataRow.displayName = \"MetadataRow\";\n\nexport { MetadataRow };\n","/**\n * Thinking Section Component\n *\n * Collapsible section for displaying agent thinking/reasoning content.\n * Supports both plain text and structured collapsible sub-sections.\n */\n\nimport * as React from \"react\";\nimport { useState, useCallback } from \"react\";\nimport { ChevronDown, ChevronRight } from \"lucide-react\";\nimport { cn } from \"@optilogic/core\";\nimport type { ThinkingStep } from \"../types\";\n\nexport interface ThinkingSectionProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"content\"> {\n /** The thinking content to display (string or structured steps) */\n content: string | ThinkingStep[];\n /** Whether the section is expanded */\n isExpanded: boolean;\n /**\n * Custom markdown renderer for the thinking content.\n * If not provided, the content will be rendered as plain preformatted text.\n */\n renderMarkdown?: (content: string) => React.ReactNode;\n}\n\n/**\n * Internal component for rendering a collapsible thinking step\n */\ninterface ThinkingStepItemProps {\n step: ThinkingStep;\n renderMarkdown?: (content: string) => React.ReactNode;\n}\n\nconst ThinkingStepItem: React.FC<ThinkingStepItemProps> = ({ step, renderMarkdown }) => {\n const [isCollapsed, setIsCollapsed] = useState(step.isCollapsed ?? false);\n\n const toggleCollapse = useCallback(() => {\n setIsCollapsed((prev) => !prev);\n }, []);\n\n const indentPadding = step.depth * 16;\n\n return (\n <div className=\"border-b border-border/50 last:border-b-0\">\n <button\n onClick={toggleCollapse}\n className=\"w-full flex items-center gap-1.5 py-1.5 px-2 hover:bg-muted/50 transition-colors text-left\"\n style={{ paddingLeft: `${indentPadding + 8}px` }}\n >\n {isCollapsed ? (\n <ChevronRight className=\"w-3 h-3 text-muted-foreground flex-shrink-0\" />\n ) : (\n <ChevronDown className=\"w-3 h-3 text-muted-foreground flex-shrink-0\" />\n )}\n <span className=\"text-xs font-medium text-foreground/80\">{step.label}</span>\n </button>\n\n {!isCollapsed && (\n <div\n className=\"pb-2 px-2\"\n style={{ paddingLeft: `${indentPadding + 28}px` }}\n >\n {renderMarkdown ? (\n <div className=\"text-xs text-muted-foreground\">\n {renderMarkdown(step.content)}\n </div>\n ) : (\n <pre className=\"text-xs text-muted-foreground whitespace-pre-wrap font-mono\">\n {step.content}\n </pre>\n )}\n </div>\n )}\n </div>\n );\n};\n\n/**\n * ThinkingSection Component\n *\n * Displays the agent's thinking/reasoning content in a collapsible panel.\n * Supports both plain text content and structured collapsible sub-sections.\n *\n * @example\n * // Plain text content\n * <ThinkingSection content={state.thinking} isExpanded={isExpanded} />\n *\n * @example\n * // Structured content with sub-sections\n * <ThinkingSection\n * content={[\n * { id: \"1\", label: \"Analysis\", content: \"...\", depth: 0 },\n * { id: \"2\", label: \"Sub-analysis\", content: \"...\", depth: 1 },\n * ]}\n * isExpanded={isExpanded}\n * />\n */\nconst ThinkingSection = React.forwardRef<HTMLDivElement, ThinkingSectionProps>(\n ({ content, isExpanded, renderMarkdown, className, ...props }, ref) => {\n if (!isExpanded || !content || (Array.isArray(content) && content.length === 0)) {\n return null;\n }\n\n const isStructured = Array.isArray(content);\n\n return (\n <div\n ref={ref}\n className={cn(\"px-3 pb-3 border-t border-border\", className)}\n {...props}\n >\n <div className=\"mt-2 max-h-[200px] overflow-y-auto\">\n {isStructured ? (\n <div className=\"space-y-0\">\n {content.map((step) => (\n <ThinkingStepItem\n key={step.id}\n step={step}\n renderMarkdown={renderMarkdown}\n />\n ))}\n </div>\n ) : renderMarkdown ? (\n <div className=\"text-xs text-muted-foreground\">\n {renderMarkdown(content)}\n </div>\n ) : (\n <pre className=\"text-xs text-muted-foreground whitespace-pre-wrap font-mono\">\n {content}\n </pre>\n )}\n </div>\n </div>\n );\n }\n);\nThinkingSection.displayName = \"ThinkingSection\";\n\nexport { ThinkingSection };\n","/**\n * Action Bar Component\n *\n * Displays copy, feedback, and timing actions for the response\n */\n\nimport * as React from \"react\";\nimport { useState, useCallback } from \"react\";\nimport { Copy, Check, ThumbsUp, ThumbsDown } from \"lucide-react\";\nimport { cn } from \"@optilogic/core\";\nimport { formatTotalTime } from \"../utils\";\nimport type { FeedbackValue } from \"../types\";\n\nexport interface ActionBarProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The response text (for copying) */\n response: string;\n /** Whether the action bar is visible */\n isVisible: boolean;\n /** Total time in seconds */\n totalTimeSeconds: number;\n /** Current feedback value */\n feedback?: FeedbackValue;\n /** Callback when feedback changes */\n onFeedbackChange?: (feedback: FeedbackValue) => void;\n /** Callback when response is copied */\n onResponseCopy?: (response: string) => void;\n /**\n * Tour anchor (rendered as `data-tour`) on the copy button.\n * Use with the `data-tour` convention to target this button from a tour step.\n */\n copyAnchor?: string;\n /** Tour anchor (`data-tour`) on the thumbs up button. */\n thumbsUpAnchor?: string;\n /** Tour anchor (`data-tour`) on the thumbs down button. */\n thumbsDownAnchor?: string;\n}\n\n/**\n * ActionBar Component\n *\n * Displays action buttons for copying the response, providing feedback,\n * and showing total response time.\n *\n * @example\n * <ActionBar\n * response={state.response}\n * isVisible={isHovered}\n * totalTimeSeconds={totalTime}\n * feedback={feedback}\n * onFeedbackChange={setFeedback}\n * onCopy={handleCopy}\n * />\n */\nconst ActionBar = React.forwardRef<HTMLDivElement, ActionBarProps>(\n (\n {\n response,\n isVisible,\n totalTimeSeconds,\n feedback,\n onFeedbackChange,\n onResponseCopy,\n copyAnchor,\n thumbsUpAnchor,\n thumbsDownAnchor,\n className,\n ...props\n },\n ref\n ) => {\n const [copied, setCopied] = useState(false);\n\n const handleCopy = useCallback(async () => {\n try {\n await navigator.clipboard.writeText(response);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n onResponseCopy?.(response);\n } catch (err) {\n console.error(\"Failed to copy response:\", err);\n }\n }, [response, onResponseCopy]);\n\n const handleThumbsUp = useCallback(() => {\n const newValue = feedback === \"up\" ? null : \"up\";\n onFeedbackChange?.(newValue);\n }, [feedback, onFeedbackChange]);\n\n const handleThumbsDown = useCallback(() => {\n const newValue = feedback === \"down\" ? null : \"down\";\n onFeedbackChange?.(newValue);\n }, [feedback, onFeedbackChange]);\n\n const isThumbsUp = feedback === \"up\";\n const isThumbsDown = feedback === \"down\";\n\n return (\n <div\n ref={ref}\n className={cn(\n \"flex items-center justify-between px-4 py-2\",\n \"transition-opacity duration-200\",\n isVisible ? \"opacity-100\" : \"opacity-0 pointer-events-none\",\n className\n )}\n {...props}\n >\n {/* Left side - action buttons */}\n <div className=\"flex items-center gap-1\">\n {/* Copy button */}\n <button\n data-tour={copyAnchor}\n onClick={handleCopy}\n className=\"p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground\"\n title={copied ? \"Copied!\" : \"Copy response\"}\n >\n {copied ? (\n <Check className=\"w-4 h-4 text-green-500\" />\n ) : (\n <Copy className=\"w-4 h-4\" />\n )}\n </button>\n\n {/* Thumbs up */}\n <button\n data-tour={thumbsUpAnchor}\n onClick={handleThumbsUp}\n className={cn(\n \"p-1.5 rounded hover:bg-muted transition-colors\",\n isThumbsUp\n ? \"text-green-500\"\n : \"text-muted-foreground hover:text-foreground\"\n )}\n title=\"Good response\"\n >\n <ThumbsUp className={cn(\"w-4 h-4\", isThumbsUp && \"fill-current\")} />\n </button>\n\n {/* Thumbs down */}\n <button\n data-tour={thumbsDownAnchor}\n onClick={handleThumbsDown}\n className={cn(\n \"p-1.5 rounded hover:bg-muted transition-colors\",\n isThumbsDown\n ? \"text-red-500\"\n : \"text-muted-foreground hover:text-foreground\"\n )}\n title=\"Poor response\"\n >\n <ThumbsDown className={cn(\"w-4 h-4\", isThumbsDown && \"fill-current\")} />\n </button>\n </div>\n\n {/* Right side - timing info */}\n <span className=\"text-xs text-muted-foreground\">\n Total time: {formatTotalTime(totalTimeSeconds)}\n </span>\n </div>\n );\n }\n);\nActionBar.displayName = \"ActionBar\";\n\nexport { ActionBar };\n","/**\n * HITLQuestionPanel — Human-in-the-Loop clarifying question panel.\n *\n * Renders in the input area (replacing UserPromptInput) when the agent asks a\n * clarifying question via the HumanInTheLoop tool. Shows the question details\n * and lets the user respond via option buttons or free-form text.\n *\n * Option clicks select/toggle rather than immediately submitting. The \"Send\n * response\" button enables once all questions have a selected option OR the\n * textarea has text. On submit, selected options and free-form text are\n * combined into a single formatted string for the backend.\n */\n\nimport * as React from \"react\";\nimport { useState, useEffect, useRef, useCallback, useMemo } from \"react\";\nimport { cn, Button, Textarea } from \"@optilogic/core\";\n\nexport interface HITLQuestion {\n reason: string;\n questions: string[];\n options: Record<string, string[]> | null;\n context: string | null;\n /** Timeout in seconds. When omitted, no countdown is shown and the panel never times out. */\n timeoutSeconds?: number;\n receivedAt: number;\n}\n\nexport interface HITLResponseData {\n /** Raw selected option text per question, keyed by question text */\n selectedOptions: Record<string, string>;\n /** Freeform text entered by the user (untrimmed) */\n freeformText: string;\n}\n\nexport interface HITLQuestionPanelProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onSubmit\"> {\n question: HITLQuestion;\n onSubmit: (response: string, data: HITLResponseData) => void;\n onStop: () => void;\n}\n\n/**\n * Build a single response string from selected options and optional free-form text.\n * Format is designed to be easily parsed by the LLM consuming the response.\n */\nexport function buildResponseString(\n questions: string[],\n selectedOptions: Record<string, string>,\n freeformText: string\n): string {\n const parts: string[] = [];\n\n for (const q of questions) {\n const answer = selectedOptions[q];\n if (answer) {\n parts.push(`Q: ${q}\\nA: ${answer}`);\n }\n }\n\n const trimmed = freeformText.trim();\n if (trimmed) {\n parts.push(`Additional context: ${trimmed}`);\n }\n\n return parts.join(\"\\n\\n\");\n}\n\nconst HITLQuestionPanel = React.forwardRef<\n HTMLDivElement,\n HITLQuestionPanelProps\n>(({ question, onSubmit, onStop, className, ...props }, ref) => {\n const [freeformText, setFreeformText] = useState(\"\");\n const [selectedOptions, setSelectedOptions] = useState<\n Record<string, string>\n >({});\n const hasTimeout = question.timeoutSeconds != null;\n const [secondsLeft, setSecondsLeft] = useState(() =>\n hasTimeout\n ? Math.max(\n 0,\n Math.round(\n question.timeoutSeconds! - (Date.now() - question.receivedAt) / 1000\n )\n )\n : Infinity\n );\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n // Focus the textarea on mount\n useEffect(() => {\n textareaRef.current?.focus();\n }, []);\n\n // Countdown timer (only when timeoutSeconds is provided)\n useEffect(() => {\n if (!hasTimeout) return;\n const interval = setInterval(() => {\n const remaining = Math.max(\n 0,\n Math.round(\n question.timeoutSeconds! - (Date.now() - question.receivedAt) / 1000\n )\n );\n setSecondsLeft(remaining);\n if (remaining <= 0) clearInterval(interval);\n }, 1000);\n return () => clearInterval(interval);\n }, [hasTimeout, question.timeoutSeconds, question.receivedAt]);\n\n const timedOut = hasTimeout && secondsLeft <= 0;\n\n // Which questions have options defined?\n const questionsWithOptions = useMemo(\n () => question.questions.filter((q) => question.options?.[q]?.length),\n [question.questions, question.options]\n );\n\n const allOptionsSelected =\n questionsWithOptions.length > 0 &&\n questionsWithOptions.every((q) => selectedOptions[q]);\n\n const hasFreeformText = freeformText.trim().length > 0;\n\n const canSubmit = !timedOut && (allOptionsSelected || hasFreeformText);\n\n const handleOptionClick = useCallback(\n (questionText: string, option: string) => {\n if (timedOut) return;\n setSelectedOptions((prev) => {\n // Toggle: deselect if already selected, otherwise select\n if (prev[questionText] === option) {\n const next = { ...prev };\n delete next[questionText];\n return next;\n }\n return { ...prev, [questionText]: option };\n });\n },\n [timedOut]\n );\n\n const handleSubmit = useCallback(() => {\n if (!canSubmit) return;\n const combined = buildResponseString(\n question.questions,\n selectedOptions,\n freeformText\n );\n onSubmit(combined, { selectedOptions, freeformText });\n }, [canSubmit, question.questions, selectedOptions, freeformText, onSubmit]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n },\n [handleSubmit]\n );\n\n const formatTime = (s: number) => {\n const m = Math.floor(s / 60);\n const sec = s % 60;\n return `${m}:${sec.toString().padStart(2, \"0\")}`;\n };\n\n return (\n <div\n ref={ref}\n className={cn(\n \"rounded-lg border border-border bg-muted p-4 space-y-3\",\n className\n )}\n {...props}\n >\n {/* Header: reason + countdown */}\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"flex-1\">\n <p className=\"text-sm font-medium text-foreground\">\n {question.reason}\n </p>\n </div>\n {hasTimeout && (\n <span\n className={cn(\n \"text-xs font-mono whitespace-nowrap\",\n secondsLeft <= 30 ? \"text-destructive\" : \"text-muted-foreground\"\n )}\n >\n {timedOut ? \"Timed out\" : formatTime(secondsLeft)}\n </span>\n )}\n </div>\n\n {/* Context (if provided) */}\n {question.context && (\n <div className=\"text-xs text-muted-foreground bg-background rounded p-2 border border-border max-h-24 overflow-y-auto\">\n <pre className=\"whitespace-pre-wrap font-mono\">\n {question.context}\n </pre>\n </div>\n )}\n\n {/* Questions */}\n <div className=\"space-y-3\">\n {question.questions.map((q, i) => (\n <div key={i}>\n <p className=\"text-sm text-foreground\">{q}</p>\n\n {/* Options for this question (if provided) */}\n {question.options?.[q] && (\n <div className=\"flex flex-wrap gap-2 mt-1.5\">\n {question.options[q].map((option, j) => {\n const isSelected = selectedOptions[q] === option;\n return (\n <Button\n key={j}\n variant={isSelected ? \"primary\" : \"outline\"}\n size=\"sm\"\n onClick={() => handleOptionClick(q, option)}\n disabled={timedOut}\n >\n {option}\n </Button>\n );\n })}\n </div>\n )}\n </div>\n ))}\n </div>\n\n {/* Free-form input — always shown for additional context */}\n <Textarea\n ref={textareaRef}\n value={freeformText}\n onChange={(e) => setFreeformText(e.target.value)}\n onKeyDown={handleKeyDown}\n disabled={timedOut}\n placeholder=\"Add additional context or type a full response...\"\n rows={2}\n className=\"resize-none\"\n />\n\n <div className=\"flex items-center justify-between\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={onStop}\n className=\"text-destructive hover:text-destructive hover:bg-destructive/10\"\n >\n Stop agent\n </Button>\n\n <Button\n variant=\"primary\"\n size=\"sm\"\n onClick={handleSubmit}\n disabled={!canSubmit}\n >\n Send response\n </Button>\n </div>\n </div>\n );\n});\nHITLQuestionPanel.displayName = \"HITLQuestionPanel\";\n\nexport { HITLQuestionPanel };\n","/**\n * HITLInteractionRecord — Displays a completed HITL Q&A interaction\n * in the chat message history.\n *\n * Rendered below AgentResponse in the agent message block. Shows the full detail\n * of each clarifying question the agent asked and the user's response.\n */\n\nimport * as React from \"react\";\nimport { useMemo } from \"react\";\nimport { cn } from \"@optilogic/core\";\nimport type { HITLQuestion } from \"./HITLQuestionPanel\";\n\nexport interface HITLInteraction {\n question: HITLQuestion;\n response: string;\n respondedAt: number;\n}\n\nexport interface HITLInteractionRecordProps\n extends React.HTMLAttributes<HTMLDivElement> {\n interaction: HITLInteraction;\n}\n\n/**\n * Parse the formatted response string (produced by buildResponseString) back\n * into a per-question answer map and optional additional context.\n */\nfunction parseResponse(response: string): {\n answers: Record<string, string>;\n additionalContext: string | null;\n} {\n const answers: Record<string, string> = {};\n let additionalContext: string | null = null;\n\n const blocks = response.split(\"\\n\\n\");\n for (const block of blocks) {\n const qaMatch = block.match(/^Q: (.+)\\nA: (.+)$/s);\n if (qaMatch) {\n answers[qaMatch[1].trim()] = qaMatch[2].trim();\n } else if (block.startsWith(\"Additional context: \")) {\n additionalContext = block.slice(\"Additional context: \".length).trim();\n }\n }\n\n return { answers, additionalContext };\n}\n\nconst HITLInteractionRecord = React.forwardRef<\n HTMLDivElement,\n HITLInteractionRecordProps\n>(({ interaction, className, ...props }, ref) => {\n const { question, response, respondedAt } = interaction;\n const timestamp = new Date(respondedAt).toLocaleTimeString([], {\n hour: \"2-digit\",\n minute: \"2-digit\",\n });\n\n const { answers, additionalContext } = useMemo(\n () => parseResponse(response),\n [response]\n );\n\n // Check if parsing found any structured answers; if not, fall back to\n // showing the raw response string (for responses not built by buildResponseString).\n const hasParsedAnswers = Object.keys(answers).length > 0;\n\n return (\n <div\n ref={ref}\n className={cn(\n \"rounded-lg border border-border bg-muted p-3 space-y-2 text-sm\",\n className\n )}\n {...props}\n >\n {/* Header */}\n <div className=\"flex items-center justify-between\">\n <span className=\"font-medium text-muted-foreground\">\n Clarifying Question\n </span>\n <span className=\"text-xs text-muted-foreground\">{timestamp}</span>\n </div>\n\n {/* Reason */}\n <p className=\"text-foreground font-medium\">{question.reason}</p>\n\n {/* Context (if provided) */}\n {question.context && (\n <div className=\"text-xs text-muted-foreground bg-background rounded p-2 border border-border\">\n <pre className=\"whitespace-pre-wrap font-mono\">\n {question.context}\n </pre>\n </div>\n )}\n\n {/* Questions with inline answers */}\n <div className=\"space-y-2\">\n {question.questions.map((q, i) => (\n <div key={i}>\n <p className=\"text-foreground\">{q}</p>\n {question.options?.[q] && (\n <p className=\"text-xs text-muted-foreground ml-2\">\n Options: {question.options[q].join(\", \")}\n </p>\n )}\n {hasParsedAnswers && answers[q] && (\n <p className=\"text-xs text-foreground ml-2 mt-0.5 bg-background rounded px-2 py-1 border border-border\">\n <span className=\"text-muted-foreground\">Answer: </span>\n {answers[q]}\n </p>\n )}\n </div>\n ))}\n </div>\n\n {/* Additional context from freeform text, or raw fallback */}\n {hasParsedAnswers && additionalContext && (\n <div className=\"border-t border-border pt-2\">\n <span className=\"text-muted-foreground text-xs\">\n Additional context:\n </span>\n <p className=\"text-foreground mt-0.5\">{additionalContext}</p>\n </div>\n )}\n\n {/* Fallback: show raw response if it wasn't in the parsed Q/A format */}\n {!hasParsedAnswers && (\n <div className=\"border-t border-border pt-2\">\n <span className=\"text-muted-foreground text-xs\">Response:</span>\n <p className=\"text-foreground mt-0.5\">{response}</p>\n </div>\n )}\n </div>\n );\n});\nHITLInteractionRecord.displayName = \"HITLInteractionRecord\";\n\nexport { HITLInteractionRecord };\n","/**\n * HITL Section Component\n *\n * Collapsible section for displaying completed HITL (Human-in-the-Loop)\n * interactions within an AgentResponse. Follows the same pattern as\n * ThinkingSection for consistent UX.\n */\n\nimport * as React from \"react\";\nimport { useState, useCallback } from \"react\";\nimport { ChevronDown, ChevronRight, MessageCircleQuestion } from \"lucide-react\";\nimport { cn } from \"@optilogic/core\";\nimport { HITLInteractionRecord } from \"../../hitl-interactions\";\nimport type { HITLInteraction } from \"../../hitl-interactions\";\n\nexport interface HITLSectionProps\n extends React.HTMLAttributes<HTMLDivElement> {\n /** The HITL interactions to display */\n interactions: HITLInteraction[];\n /** Whether the section starts expanded (uncontrolled) */\n defaultExpanded?: boolean;\n /** Whether the section is expanded (controlled) */\n isExpanded?: boolean;\n /** Callback when expansion state changes (controlled) */\n onExpandedChange?: (expanded: boolean) => void;\n}\n\nconst HITLSection = React.forwardRef<HTMLDivElement, HITLSectionProps>(\n (\n {\n interactions,\n defaultExpanded = false,\n isExpanded: controlledExpanded,\n onExpandedChange,\n className,\n ...props\n },\n ref\n ) => {\n const [uncontrolledExpanded, setUncontrolledExpanded] =\n useState(defaultExpanded);\n\n const isControlled = controlledExpanded !== undefined;\n const isExpanded = isControlled ? controlledExpanded : uncontrolledExpanded;\n\n const toggleExpanded = useCallback(() => {\n const newValue = !isExpanded;\n if (isControlled) {\n onExpandedChange?.(newValue);\n } else {\n setUncontrolledExpanded(newValue);\n }\n }, [isExpanded, isControlled, onExpandedChange]);\n\n if (!interactions || interactions.length === 0) {\n return null;\n }\n\n return (\n <div\n ref={ref}\n className={cn(\"border-t border-border\", className)}\n {...props}\n >\n {/* Collapsible header */}\n <button\n onClick={toggleExpanded}\n className=\"w-full flex items-center gap-2 py-2 px-3 hover:bg-muted/50 transition-colors text-left\"\n >\n {isExpanded ? (\n <ChevronDown className=\"w-3.5 h-3.5 text-muted-foreground flex-shrink-0\" />\n ) : (\n <ChevronRight className=\"w-3.5 h-3.5 text-muted-foreground flex-shrink-0\" />\n )}\n <MessageCircleQuestion className=\"w-3.5 h-3.5 text-muted-foreground flex-shrink-0\" />\n <span className=\"text-xs font-medium text-foreground/80\">\n Clarifying Questions ({interactions.length})\n </span>\n </button>\n\n {/* Expanded content */}\n {isExpanded && (\n <div className=\"px-3 pb-3 space-y-2\">\n {interactions.map((interaction, i) => (\n <HITLInteractionRecord key={i} interaction={interaction} />\n ))}\n </div>\n )}\n </div>\n );\n }\n);\nHITLSection.displayName = \"HITLSection\";\n\nexport { HITLSection };\n","/**\n * Truncated Message Component\n *\n * Renders a single-line text message with CSS-based truncation (text-overflow: ellipsis).\n * Designed as a standalone utility that can be used anywhere, including as\n * the statusContent slot in MetadataRow.\n */\n\nimport * as React from \"react\";\nimport { cn } from \"@optilogic/core\";\n\nexport interface TruncatedMessageProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The message string to display (truncated with ellipsis if it overflows) */\n message: string;\n}\n\n/**\n * TruncatedMessage Component\n *\n * Displays a single-line text message that truncates with an ellipsis when\n * it overflows its container. Uses CSS text-overflow for zero-JS truncation.\n *\n * @example\n * <TruncatedMessage message=\"Searching the knowledge base for relevant documents...\" />\n *\n * @example\n * // Inside MetadataRow's statusContent slot\n * <AgentResponse\n * state={state}\n * statusContent={<TruncatedMessage message=\"Running analysis...\" />}\n * />\n */\nconst TruncatedMessage = React.forwardRef<HTMLDivElement, TruncatedMessageProps>(\n ({ message, className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn(\n \"text-xs text-muted-foreground truncate min-w-0\",\n className\n )}\n title={message}\n {...props}\n >\n {message}\n </div>\n );\n }\n);\nTruncatedMessage.displayName = \"TruncatedMessage\";\n\nexport { TruncatedMessage };\n","/**\n * useThinkingTimer Hook\n *\n * Tracks elapsed time during agent thinking/processing\n */\n\nimport { useState, useEffect } from \"react\";\nimport type { AgentResponseStatus } from \"../types\";\n\nexport interface UseThinkingTimerOptions {\n startTime: number | null;\n endTime: number | null;\n status: AgentResponseStatus;\n}\n\n/**\n * Custom hook for thinking timer\n * Returns elapsed time in seconds\n */\nexport function useThinkingTimer({\n startTime,\n endTime,\n status,\n}: UseThinkingTimerOptions): number {\n const [elapsed, setElapsed] = useState(0);\n\n useEffect(() => {\n if (!startTime) {\n setElapsed(0);\n return;\n }\n\n // If complete, calculate final elapsed time\n if (status === \"complete\" && endTime) {\n setElapsed((endTime - startTime) / 1000);\n return;\n }\n\n // If still processing, update every second\n if (status === \"processing\") {\n const updateElapsed = () => {\n setElapsed((Date.now() - startTime) / 1000);\n };\n\n updateElapsed(); // Initial update\n const interval = setInterval(updateElapsed, 1000);\n return () => clearInterval(interval);\n }\n }, [startTime, endTime, status]);\n\n return elapsed;\n}\n","/**\n * Agent Response Component Types\n *\n * Type definitions for the library-ready agent response component\n */\n\nimport type { TimelineEntry } from \"../agent-timeline/types\";\n\n/**\n * Status of the agent response cycle\n */\nexport type AgentResponseStatus = \"idle\" | \"processing\" | \"complete\";\n\n/**\n * Feedback value for the response\n */\nexport type FeedbackValue = \"up\" | \"down\" | null;\n\n/**\n * Tool call information from the agent\n */\nexport interface ToolCall {\n id: string;\n name: string;\n arguments?: Record<string, unknown>;\n timestamp: number;\n /** Agent that made this call (multi-agent scenarios) */\n agentName?: string | null;\n /** Parent agent name */\n parentAgent?: string | null;\n /** Nesting depth in agent hierarchy */\n depth?: number;\n}\n\n/**\n * Knowledge retrieval information\n */\nexport interface KnowledgeItem {\n id: string;\n source: string;\n content: string;\n timestamp: number;\n /** Agent that retrieved this (multi-agent scenarios) */\n agentName?: string | null;\n /** Parent agent name */\n parentAgent?: string | null;\n /** Nesting depth in agent hierarchy */\n depth?: number;\n}\n\n/**\n * Memory access information\n */\nexport interface MemoryItem {\n id: string;\n type: string;\n content: string;\n timestamp: number;\n /** Agent that accessed this (multi-agent scenarios) */\n agentName?: string | null;\n /** Parent agent name */\n parentAgent?: string | null;\n /** Nesting depth in agent hierarchy */\n depth?: number;\n}\n\n/**\n * Potential response (sub-agent intermediate AI response)\n */\nexport interface PotentialResponse {\n id: string;\n content: string;\n timestamp: number;\n agentName?: string | null;\n parentAgent?: string | null;\n depth?: number;\n}\n\n/**\n * Status update information from the agent\n */\nexport interface StatusItem {\n id: string;\n message: string;\n timestamp: number;\n /** Optional agent name if in multi-agent scenario */\n agent?: string;\n /** Agent that produced this (multi-agent scenarios) */\n agentName?: string | null;\n /** Parent agent name */\n parentAgent?: string | null;\n /** Nesting depth in agent hierarchy */\n depth?: number;\n}\n\n/**\n * A single step in structured thinking content\n */\nexport interface ThinkingStep {\n /** Unique identifier for the step */\n id: string;\n /** Label/title shown in the collapsible header */\n label: string;\n /** Content of the thinking step */\n content: string;\n /** Nesting depth (0 = root level, 1 = first indent, etc.) */\n depth: number;\n /** Whether this step should start collapsed (default: false) */\n isCollapsed?: boolean;\n /** Timestamp for timeline ordering */\n timestamp?: number;\n /** Agent that produced this (multi-agent scenarios) */\n agentName?: string | null;\n /** Parent agent name */\n parentAgent?: string | null;\n}\n\n/**\n * Union type for thinking content\n * - string: plain text (backward compatible)\n * - ThinkingStep[]: structured with collapsible sub-sections\n */\nexport type ThinkingContent = string | ThinkingStep[];\n\n/**\n * State shape for the agent response component\n */\nexport interface AgentResponseState {\n /** Current status of the response cycle */\n status: AgentResponseStatus;\n /** Accumulated thinking/reasoning text */\n thinking: string;\n /** Structured thinking steps (if provided, takes precedence over thinking string) */\n thinkingSteps?: ThinkingStep[];\n /** Tool calls made during processing */\n toolCalls: ToolCall[];\n /** Knowledge items retrieved */\n knowledge: KnowledgeItem[];\n /** Memory items accessed */\n memory: MemoryItem[];\n /** Status updates from the agent */\n statusUpdates: StatusItem[];\n /** Potential responses (sub-agent intermediate AI responses) */\n potentialResponses?: PotentialResponse[];\n /** Custom timeline entries (consumer-provided) */\n customTimelineEntries?: TimelineEntry[];\n /** Final response text */\n response: string;\n /** Timeline entries derived from all accumulator arrays (for AgentTimeline) */\n timelineEntries?: TimelineEntry[];\n /** Timestamp when first thinking message was received (for timer) */\n thinkingStartTime: number | null;\n /** Timestamp when response was completed (for final timer display) */\n responseCompleteTime: number | null;\n /** Timestamp when first message of any type was received (for total time) */\n firstMessageTime: number | null;\n}\n\n/**\n * WebSocket message payload for agent responses\n */\nexport interface AgentMessage {\n type: \"status\" | \"thinking\" | \"tool_call\" | \"knowledge\" | \"memory\" | \"response\" | \"status_update\" | \"potential_response\";\n /** Message content - for simple string payloads */\n message?: string;\n /** Alternative content field */\n content?: string;\n /**\n * Optional event timestamp (epoch ms). When supplied, the reducer uses this\n * for the item's `timestamp` and any state-level timing fields it sets\n * (`firstMessageTime`, `thinkingStartTime`, `responseCompleteTime`) instead\n * of `Date.now()`. Provide this when replaying historical events so durations\n * reflect the original run rather than load time.\n */\n timestamp?: number;\n /** For status messages */\n status?: string;\n /** Agent name (multi-agent scenarios) */\n agentName?: string | null;\n /** Parent agent name (multi-agent scenarios) */\n parentAgent?: string | null;\n /** Agent nesting depth (0 = root) */\n depth?: number;\n /** Title/label for timeline display */\n title?: string | null;\n /** For tool_call messages */\n tool?: {\n id: string;\n name: string;\n arguments?: Record<string, unknown>;\n };\n /** For knowledge messages */\n knowledge?: {\n id: string;\n source: string;\n content: string;\n };\n /** For memory messages */\n memory?: {\n id: string;\n type: string;\n content: string;\n };\n /** For status_update messages */\n statusUpdate?: {\n id: string;\n message: string;\n agent?: string;\n };\n /** For structured thinking step messages */\n thinkingStep?: {\n id?: string;\n label: string;\n content: string;\n depth?: number;\n isCollapsed?: boolean;\n };\n}\n\n/**\n * Generic websocket message wrapper type\n */\nexport interface GenericWebSocketMessage {\n topic: string;\n message: AgentMessage;\n accountId?: string;\n}\n\n/**\n * Initial state for the agent response component\n */\nexport const initialAgentResponseState: AgentResponseState = {\n status: \"idle\",\n thinking: \"\",\n toolCalls: [],\n knowledge: [],\n memory: [],\n statusUpdates: [],\n potentialResponses: [],\n customTimelineEntries: [],\n response: \"\",\n thinkingStartTime: null,\n responseCompleteTime: null,\n firstMessageTime: null,\n};\n","import type { TimelineEntry, AgentRun, DisplayEntry } from \"./types\";\nimport type { AgentResponseState } from \"../agent-response/types\";\n\n/**\n * Build a flat, chronologically sorted array of TimelineEntry from the\n * accumulator state. Maps each typed array (toolCalls, knowledge, etc.)\n * to unified TimelineEntry objects with per-source stable IDs.\n */\nexport function buildTimelineEntries(state: AgentResponseState): TimelineEntry[] {\n const entries: TimelineEntry[] = [];\n\n // Thinking steps (structured)\n if (state.thinkingSteps) {\n let idx = 0;\n for (const step of state.thinkingSteps) {\n entries.push({\n id: `tl-think-${idx++}`,\n type: \"thinking\",\n agentName: step.agentName ?? null,\n parentAgent: step.parentAgent ?? null,\n depth: step.depth ?? 0,\n content: step.content,\n title: step.label,\n timestamp: step.timestamp ?? 0,\n });\n }\n } else if (state.thinking) {\n // Plain text thinking (legacy) — single entry\n entries.push({\n id: \"tl-think-0\",\n type: \"thinking\",\n agentName: null,\n parentAgent: null,\n depth: 0,\n content: state.thinking,\n title: null,\n timestamp: state.thinkingStartTime ?? 0,\n });\n }\n\n // Tool calls\n let toolIdx = 0;\n for (const tool of state.toolCalls) {\n entries.push({\n id: `tl-tool-${toolIdx++}`,\n type: \"tool_call\",\n agentName: tool.agentName ?? null,\n parentAgent: tool.parentAgent ?? null,\n depth: tool.depth ?? 0,\n content: tool.name,\n title: null,\n timestamp: tool.timestamp,\n });\n }\n\n // Knowledge items\n let knowIdx = 0;\n for (const item of state.knowledge) {\n entries.push({\n id: `tl-know-${knowIdx++}`,\n type: \"knowledge\",\n agentName: item.agentName ?? null,\n parentAgent: item.parentAgent ?? null,\n depth: item.depth ?? 0,\n content: item.content,\n title: item.source,\n timestamp: item.timestamp,\n });\n }\n\n // Memory items\n let memIdx = 0;\n for (const item of state.memory) {\n entries.push({\n id: `tl-mem-${memIdx++}`,\n type: \"memory\",\n agentName: item.agentName ?? null,\n parentAgent: item.parentAgent ?? null,\n depth: item.depth ?? 0,\n content: item.content,\n title: item.type,\n timestamp: item.timestamp,\n });\n }\n\n // Status updates\n let statIdx = 0;\n for (const item of state.statusUpdates) {\n entries.push({\n id: `tl-stat-${statIdx++}`,\n type: \"status_update\",\n agentName: item.agentName ?? item.agent ?? null,\n parentAgent: item.parentAgent ?? null,\n depth: item.depth ?? 0,\n content: item.message,\n title: null,\n timestamp: item.timestamp,\n });\n }\n\n // Potential responses → ai_response timeline entries\n if (state.potentialResponses) {\n let respIdx = 0;\n for (const resp of state.potentialResponses) {\n entries.push({\n id: `tl-resp-${respIdx++}`,\n type: \"ai_response\",\n agentName: resp.agentName ?? null,\n parentAgent: resp.parentAgent ?? null,\n depth: resp.depth ?? 0,\n content: resp.content,\n title: null,\n timestamp: resp.timestamp,\n });\n }\n }\n\n // Merge any custom timeline entries (consumer-provided)\n if (state.customTimelineEntries) {\n entries.push(...state.customTimelineEntries);\n }\n\n // Sort chronologically\n entries.sort((a, b) => a.timestamp - b.timestamp);\n\n return entries;\n}\n\n/**\n * Group a sorted array of timeline entries into consecutive \"agent runs\".\n * A new run starts whenever the agentName changes.\n * Each run's entries are deduplicated.\n */\nexport function groupIntoAgentRuns(entries: TimelineEntry[]): AgentRun[] {\n const runs: AgentRun[] = [];\n let currentRun: AgentRun | null = null;\n\n for (const entry of entries) {\n const name = entry.agentName || \"Agent\";\n\n if (!currentRun || currentRun.agentName !== name) {\n // Start a new run\n currentRun = {\n agentName: name,\n parentAgent: entry.parentAgent,\n depth: entry.depth,\n entries: [],\n };\n runs.push(currentRun);\n }\n\n currentRun.entries.push({ entry, count: 1 });\n }\n\n // Deduplicate within each run\n for (const run of runs) {\n run.entries = deduplicateEntries(run.entries);\n }\n\n return runs;\n}\n\n/**\n * Collapse consecutive entries with identical type AND content into\n * a single DisplayEntry with count > 1.\n * Handles patterns like \"Loading documents\" appearing 8 times.\n */\nexport function deduplicateEntries(entries: DisplayEntry[]): DisplayEntry[] {\n if (entries.length === 0) return [];\n\n const result: DisplayEntry[] = [entries[0]];\n\n for (let i = 1; i < entries.length; i++) {\n const prev = result[result.length - 1];\n const curr = entries[i];\n\n if (\n prev.entry.type === curr.entry.type &&\n prev.entry.content === curr.entry.content\n ) {\n // Merge into previous\n prev.count += curr.count;\n } else {\n result.push({ ...curr });\n }\n }\n\n return result;\n}\n","/**\n * Pure reducer for agent response messages.\n *\n * Used by `useAgentResponseAccumulator` for live streaming, and exported so\n * non-React callers (e.g. server-side or store-based replay of historical\n * conversations) can rebuild the same `AgentResponseState` from a sequence of\n * `AgentMessage` events without rendering a component.\n *\n * Replay note on stable IDs: when a payload omits a per-item id\n * (`tool.id`, `thinkingStep.id`, `knowledge.id`, `memory.id`,\n * `statusUpdate.id`), the reducer falls back to `${type}-${Date.now()}`. That\n * is fine for live streams but will produce different React keys on each\n * replay. Callers reconstructing `AgentMessage` events from persisted rows\n * should populate these ids from a stable source (e.g. the supplement-row\n * primary key) so timeline keys remain consistent across reloads.\n */\n\nimport {\n initialAgentResponseState,\n type AgentResponseState,\n type AgentMessage,\n type ToolCall,\n type KnowledgeItem,\n type MemoryItem,\n type StatusItem,\n type ThinkingStep,\n type PotentialResponse,\n} from \"./types\";\nimport { buildTimelineEntries } from \"../agent-timeline/utils\";\n\n/**\n * Pure reducer: apply a single `AgentMessage` to the accumulated state.\n *\n * `payload.timestamp` (epoch ms), if supplied, is used for the new item's\n * `timestamp` and any state-level timing fields this call sets\n * (`firstMessageTime`, `thinkingStartTime`, `responseCompleteTime`). When\n * absent, `Date.now()` is used — matching the prior live-streaming behaviour.\n *\n * @example\n * const state = events.reduce(reduceAgentMessage, initialAgentResponseState);\n */\nexport function reduceAgentMessage(\n prev: AgentResponseState,\n payload: AgentMessage,\n): AgentResponseState {\n const now = payload.timestamp ?? Date.now();\n\n // If we receive a non-status message while idle, transition to processing\n let newStatus = prev.status;\n const isFirstMessage = prev.status === \"idle\" && payload.type !== \"status\";\n if (isFirstMessage) {\n newStatus = \"processing\";\n }\n\n // Track first message time for total time calculation\n const firstMessageTime =\n prev.firstMessageTime ?? (isFirstMessage ? now : null);\n\n switch (payload.type) {\n case \"status\":\n // \"Harness connected\" resets to idle\n if (\n payload.message === \"Harness connected\" ||\n payload.status === \"Harness connected\"\n ) {\n return { ...initialAgentResponseState };\n }\n return { ...prev, status: newStatus };\n\n case \"thinking\": {\n // Check if this is a structured thinking step\n if (payload.thinkingStep) {\n const newStep: ThinkingStep = {\n id: payload.thinkingStep.id || `step-${now}`,\n label: payload.thinkingStep.label,\n content: payload.thinkingStep.content,\n depth: payload.thinkingStep.depth ?? payload.depth ?? 0,\n isCollapsed: payload.thinkingStep.isCollapsed,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n };\n const thinkingStartTime = prev.thinkingStartTime ?? now;\n const next = {\n ...prev,\n status: newStatus,\n thinkingSteps: [...(prev.thinkingSteps || []), newStep],\n thinkingStartTime,\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n\n // Plain text thinking — concatenate for backward compat AND\n // push a ThinkingStep so the timeline gets individual entries.\n const newThinking = payload.message || payload.content || \"\";\n // Add line break between thinking messages\n const separator = prev.thinking && newThinking ? \"\\n\\n\" : \"\";\n // Set thinkingStartTime on first thinking message\n const thinkingStartTime =\n prev.thinkingStartTime ?? (newThinking ? now : null);\n const prevSteps = prev.thinkingSteps || [];\n const plainStep: ThinkingStep = {\n id: `step-${prevSteps.length}`,\n label: newThinking,\n content: newThinking,\n depth: payload.depth ?? 0,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n };\n const next = {\n ...prev,\n status: newStatus,\n thinking: prev.thinking + separator + newThinking,\n thinkingSteps: [...prevSteps, plainStep],\n thinkingStartTime,\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n\n case \"tool_call\": {\n // Handle both formats: { message: \"ToolName\" } or { tool: { id, name, arguments } }\n const toolName = payload.message || payload.tool?.name;\n if (toolName) {\n const newToolCall: ToolCall = {\n id: payload.tool?.id || `tool-${now}`,\n name: toolName,\n arguments: payload.tool?.arguments,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n depth: payload.depth,\n };\n const next = {\n ...prev,\n status: newStatus,\n toolCalls: [...prev.toolCalls, newToolCall],\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n return { ...prev, status: newStatus, firstMessageTime };\n }\n\n case \"knowledge\": {\n // Handle both formats: { message: \"content\" } or { knowledge: { id, source, content } }\n const knowledgeContent = payload.message || payload.knowledge?.content;\n if (knowledgeContent) {\n const newKnowledge: KnowledgeItem = {\n id: payload.knowledge?.id || `knowledge-${now}`,\n source: payload.knowledge?.source || \"unknown\",\n content: knowledgeContent,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n depth: payload.depth,\n };\n const next = {\n ...prev,\n status: newStatus,\n knowledge: [...prev.knowledge, newKnowledge],\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n return { ...prev, status: newStatus, firstMessageTime };\n }\n\n case \"memory\": {\n // Handle both formats: { message: \"content\" } or { memory: { id, type, content } }\n const memoryContent = payload.message || payload.memory?.content;\n if (memoryContent) {\n const newMemory: MemoryItem = {\n id: payload.memory?.id || `memory-${now}`,\n type: payload.memory?.type || \"unknown\",\n content: memoryContent,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n depth: payload.depth,\n };\n const next = {\n ...prev,\n status: newStatus,\n memory: [...prev.memory, newMemory],\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n return { ...prev, status: newStatus, firstMessageTime };\n }\n\n case \"response\":\n return {\n ...prev,\n status: \"complete\",\n response: payload.message || payload.content || \"\",\n responseCompleteTime: now,\n firstMessageTime: prev.firstMessageTime ?? now,\n };\n\n case \"status_update\": {\n const statusMessage = payload.message || payload.statusUpdate?.message;\n if (statusMessage) {\n const newStatusItem: StatusItem = {\n id: payload.statusUpdate?.id || `status-${now}`,\n message: statusMessage,\n agent: payload.statusUpdate?.agent,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n depth: payload.depth,\n };\n const next = {\n ...prev,\n status: newStatus,\n statusUpdates: [...prev.statusUpdates, newStatusItem],\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n return { ...prev, status: newStatus, firstMessageTime };\n }\n\n case \"potential_response\": {\n const respContent = payload.message || payload.content || \"\";\n if (respContent) {\n const newResp: PotentialResponse = {\n id: `resp-${now}`,\n content: respContent,\n timestamp: now,\n agentName: payload.agentName,\n parentAgent: payload.parentAgent,\n depth: payload.depth,\n };\n const next = {\n ...prev,\n status: newStatus,\n potentialResponses: [...(prev.potentialResponses || []), newResp],\n firstMessageTime,\n };\n return { ...next, timelineEntries: buildTimelineEntries(next) };\n }\n return { ...prev, status: newStatus, firstMessageTime };\n }\n\n default:\n return { ...prev, status: newStatus, firstMessageTime };\n }\n}\n","/**\n * useAgentResponseAccumulator Hook\n *\n * Accumulates agent response messages into a unified state.\n *\n * Thin wrapper around `reduceAgentMessage` — the pure reducer can be used\n * directly outside React for replaying historical events.\n */\n\nimport { useState, useCallback } from \"react\";\nimport {\n initialAgentResponseState,\n type AgentResponseState,\n type AgentMessage,\n type GenericWebSocketMessage,\n} from \"../types\";\nimport { reduceAgentMessage } from \"../reducer\";\n\nexport interface UseAgentResponseAccumulatorOptions {\n /** WebSocket topic to filter messages (optional, for convenience) */\n topic?: string;\n}\n\nexport interface UseAgentResponseAccumulatorReturn {\n /** Current accumulated state */\n state: AgentResponseState;\n\n /** Handler to process incoming messages */\n handleMessage: (message: unknown) => void;\n\n /** Reset state to initial */\n reset: () => void;\n}\n\n/**\n * Hook for accumulating agent response messages into a unified state\n *\n * @example\n * const { state, handleMessage, reset } = useAgentResponseAccumulator({ topic: \"agent\" });\n *\n * // In your WebSocket handler:\n * websocket.onmessage = (event) => {\n * handleMessage(JSON.parse(event.data));\n * };\n */\nexport function useAgentResponseAccumulator(\n options?: UseAgentResponseAccumulatorOptions\n): UseAgentResponseAccumulatorReturn {\n const [state, setState] = useState<AgentResponseState>(initialAgentResponseState);\n const topic = options?.topic;\n\n const handleMessage = useCallback(\n (message: unknown) => {\n let payload: AgentMessage;\n\n if (topic) {\n const msg = message as GenericWebSocketMessage;\n if (msg.topic !== topic) return;\n payload = msg.message;\n } else {\n payload = message as AgentMessage;\n }\n\n setState((prev) => reduceAgentMessage(prev, payload));\n },\n [topic]\n );\n\n const reset = useCallback(() => {\n setState(initialAgentResponseState);\n }, []);\n\n return { state, handleMessage, reset };\n}\n","import type { ReactNode } from \"react\";\nimport {\n Brain,\n Wrench,\n BookOpen,\n HardDrive,\n Activity,\n MessageSquare,\n AlertCircle,\n} from \"lucide-react\";\nimport type { DisplayEntry, TimelineEntryType } from \"./types\";\n\nconst ICON_MAP: Record<TimelineEntryType, typeof Brain> = {\n thinking: Brain,\n tool_call: Wrench,\n knowledge: BookOpen,\n memory: HardDrive,\n status_update: Activity,\n ai_response: MessageSquare,\n error: AlertCircle,\n};\n\ninterface TimelineItemProps {\n displayEntry: DisplayEntry;\n renderMarkdown?: (content: string) => ReactNode;\n /** Controlled expanded state (lifted to AgentTimeline) */\n isExpanded: boolean;\n onToggleExpanded: () => void;\n}\n\nexport function TimelineItem({\n displayEntry,\n renderMarkdown,\n isExpanded,\n onToggleExpanded,\n}: TimelineItemProps) {\n const { entry, count } = displayEntry;\n\n const Icon = ICON_MAP[entry.type] ?? Activity;\n\n // Determine if content is long enough to warrant truncation\n const isLong = entry.content.length > 200 || entry.content.split(\"\\n\").length > 3;\n const canExpand = isLong || entry.type === \"ai_response\";\n\n return (\n <div className=\"py-1 flex items-start gap-2 group\">\n {/* Type icon */}\n <Icon className=\"w-3.5 h-3.5 text-muted-foreground flex-shrink-0 mt-0.5\" />\n\n {/* Content */}\n <div className=\"min-w-0 flex-1\">\n {isExpanded && entry.type === \"ai_response\" && renderMarkdown ? (\n // Expanded AI response: rendered markdown\n <div>\n {renderMarkdown(entry.content)}\n <button\n onClick={onToggleExpanded}\n className=\"text-[10px] text-muted-foreground/70 hover:text-muted-foreground mt-1\"\n >\n Show less\n </button>\n </div>\n ) : isExpanded ? (\n // Expanded non-AI: plain text\n <div>\n <pre className=\"text-xs text-muted-foreground whitespace-pre-wrap font-mono\">\n {entry.content}\n </pre>\n <button\n onClick={onToggleExpanded}\n className=\"text-[10px] text-muted-foreground/70 hover:text-muted-foreground mt-1\"\n >\n Show less\n </button>\n </div>\n ) : (\n // Collapsed: truncated with optional expand\n <div className=\"flex items-baseline gap-1.5 min-w-0\">\n <div\n className={`text-xs text-muted-foreground min-w-0 ${canExpand ? \"line-clamp-2 cursor-pointer hover:text-foreground/80\" : \"\"}`}\n onClick={canExpand ? onToggleExpanded : undefined}\n >\n {entry.content}\n </div>\n\n {/* Dedup count badge */}\n {count > 1 && (\n <span className=\"text-[10px] text-muted-foreground/60 whitespace-nowrap flex-shrink-0\">\n (x{count})\n </span>\n )}\n </div>\n )}\n </div>\n </div>\n );\n}\n","import type { ReactNode } from \"react\";\nimport { ChevronDown, ChevronRight } from \"lucide-react\";\nimport type { AgentRun } from \"./types\";\nimport { TimelineItem } from \"./TimelineItem\";\n\ninterface TimelineAgentBlockProps {\n block: AgentRun;\n renderMarkdown?: (content: string) => ReactNode;\n /** If true, skip the collapsible header and render entries directly */\n isSingleAgent: boolean;\n /** Controlled collapsed state (lifted to AgentTimeline) */\n isCollapsed: boolean;\n onToggleCollapsed: () => void;\n /** Set of entry IDs whose content is expanded (lifted to AgentTimeline) */\n expandedItems: Set<string>;\n onToggleItemExpanded: (entryId: string) => void;\n}\n\nexport function TimelineAgentBlock({\n block,\n renderMarkdown,\n isSingleAgent,\n isCollapsed,\n onToggleCollapsed,\n expandedItems,\n onToggleItemExpanded,\n}: TimelineAgentBlockProps) {\n const indentPx = block.depth * 16;\n\n // Skip header only for a single root-level agent (depth 0).\n // If filtering leaves only a sub-agent, still show the header for context.\n if (isSingleAgent && block.depth === 0) {\n return (\n <div style={{ paddingLeft: `${indentPx}px` }}>\n {block.entries.map((displayEntry, i) => (\n <TimelineItem\n key={displayEntry.entry.id + \"-\" + i}\n displayEntry={displayEntry}\n renderMarkdown={renderMarkdown}\n isExpanded={expandedItems.has(displayEntry.entry.id)}\n onToggleExpanded={() => onToggleItemExpanded(displayEntry.entry.id)}\n />\n ))}\n </div>\n );\n }\n\n return (\n <div style={{ paddingLeft: `${indentPx}px` }}>\n {/* Agent header */}\n <button\n onClick={onToggleCollapsed}\n className=\"w-full flex items-center gap-1.5 py-1 hover:bg-muted/50 -ml-1 pl-1 pr-2 rounded transition-colors text-left\"\n >\n {isCollapsed ? (\n <ChevronRight className=\"w-3 h-3 text-muted-foreground flex-shrink-0\" />\n ) : (\n <ChevronDown className=\"w-3 h-3 text-muted-foreground flex-shrink-0\" />\n )}\n <span className=\"text-xs font-medium text-foreground/80\">\n {block.agentName}\n </span>\n <span className=\"text-[10px] text-muted-foreground/60\">\n ({block.entries.reduce((sum, e) => sum + e.count, 0)})\n </span>\n </button>\n\n {/* Entries */}\n {!isCollapsed && (\n <div className=\"ml-4\">\n {block.entries.map((displayEntry, i) => (\n <TimelineItem\n key={displayEntry.entry.id + \"-\" + i}\n displayEntry={displayEntry}\n renderMarkdown={renderMarkdown}\n isExpanded={expandedItems.has(displayEntry.entry.id)}\n onToggleExpanded={() => onToggleItemExpanded(displayEntry.entry.id)}\n />\n ))}\n </div>\n )}\n </div>\n );\n}\n","import { useMemo, useRef, useState, useCallback, type ReactNode } from \"react\";\nimport {\n Brain,\n Wrench,\n BookOpen,\n HardDrive,\n Activity,\n MessageSquare,\n AlertCircle,\n ChevronsDownUp,\n ChevronsUpDown,\n} from \"lucide-react\";\nimport type { TimelineEntry, TimelineEntryType } from \"./types\";\nimport { groupIntoAgentRuns } from \"./utils\";\nimport { TimelineAgentBlock } from \"./TimelineAgentBlock\";\n\n/** Externalized UI state that survives component remounts */\nexport interface TimelineUIState {\n expandedItems: Set<string>;\n collapsedRuns: Set<string>;\n activeFilters: Set<TimelineEntryType>;\n}\n\nexport function createTimelineUIState(): TimelineUIState {\n return {\n expandedItems: new Set(),\n collapsedRuns: new Set(),\n activeFilters: new Set(),\n };\n}\n\n/** Icon + label config for each entry type */\nconst TYPE_CONFIG: {\n type: TimelineEntryType;\n icon: typeof Brain;\n label: string;\n}[] = [\n { type: \"status_update\", icon: Activity, label: \"Status\" },\n { type: \"thinking\", icon: Brain, label: \"Thinking\" },\n { type: \"tool_call\", icon: Wrench, label: \"Tools\" },\n { type: \"knowledge\", icon: BookOpen, label: \"Knowledge\" },\n { type: \"memory\", icon: HardDrive, label: \"Memory\" },\n { type: \"ai_response\", icon: MessageSquare, label: \"AI\" },\n { type: \"error\", icon: AlertCircle, label: \"Errors\" },\n];\n\ninterface AgentTimelineProps {\n entries: TimelineEntry[];\n renderMarkdown?: (content: string) => ReactNode;\n /**\n * External UI state store. When provided, expand/collapse/filter state\n * is read from and written to this object (which should be ref-backed\n * in the parent) so it survives component remounts during streaming.\n */\n uiState?: TimelineUIState;\n /**\n * Maximum height of the scrollable timeline container.\n * Defaults to \"300px\". Set to \"none\" to disable.\n */\n maxHeight?: string;\n}\n\nexport function AgentTimeline({ entries, renderMarkdown, uiState, maxHeight = \"300px\" }: AgentTimelineProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Render tick: forces re-renders AND invalidates useMemo deps when we mutate Sets in-place\n const [renderTick, setRenderTick] = useState(0);\n const forceRender = useCallback(() => setRenderTick((t) => t + 1), []);\n\n // Resolve state: prefer external uiState (ref-backed, survives remounts)\n // Fall back to internal state if no external store provided\n const [internalExpandedItems] = useState<Set<string>>(() => new Set());\n const [internalCollapsedRuns] = useState<Set<string>>(() => new Set());\n const [internalActiveFilters] = useState<Set<TimelineEntryType>>(() => new Set());\n\n const expandedItems = uiState?.expandedItems ?? internalExpandedItems;\n const collapsedRuns = uiState?.collapsedRuns ?? internalCollapsedRuns;\n const activeFilters = uiState?.activeFilters ?? internalActiveFilters;\n\n // Compute which types actually exist in the entries\n const availableTypes = useMemo(() => {\n const types = new Set<TimelineEntryType>();\n for (const entry of entries) {\n types.add(entry.type);\n }\n return types;\n }, [entries]);\n\n // Filter entries, then group into runs\n // eslint-disable-next-line react-hooks/exhaustive-deps -- renderTick invalidates when mutated Sets change\n const filteredEntries = useMemo(\n () =>\n activeFilters.size === 0\n ? entries\n : entries.filter((e) => activeFilters.has(e.type)),\n [entries, activeFilters, renderTick],\n );\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const agentRuns = useMemo(() => groupIntoAgentRuns(filteredEntries), [filteredEntries, renderTick]);\n\n // --- Mutators (mutate the set in-place + trigger re-render) ---\n\n const toggleFilter = useCallback((type: TimelineEntryType) => {\n if (activeFilters.has(type)) {\n activeFilters.delete(type);\n } else {\n activeFilters.add(type);\n }\n forceRender();\n }, [activeFilters, forceRender]);\n\n const clearFilters = useCallback(() => {\n activeFilters.clear();\n forceRender();\n }, [activeFilters, forceRender]);\n\n const toggleItemExpanded = useCallback((entryId: string) => {\n if (expandedItems.has(entryId)) {\n expandedItems.delete(entryId);\n } else {\n expandedItems.add(entryId);\n }\n forceRender();\n }, [expandedItems, forceRender]);\n\n const collapseAll = useCallback(() => {\n collapsedRuns.clear();\n agentRuns.forEach((run, i) => {\n collapsedRuns.add(`${run.agentName}-${i}`);\n });\n expandedItems.clear();\n forceRender();\n }, [agentRuns, collapsedRuns, expandedItems, forceRender]);\n\n const expandAll = useCallback(() => {\n collapsedRuns.clear();\n agentRuns.forEach((run, i) => {\n collapsedRuns.add(`${run.agentName}-${i}:expanded`);\n });\n forceRender();\n }, [agentRuns, collapsedRuns, forceRender]);\n\n if (entries.length === 0) return null;\n\n const isSingle = agentRuns.length === 1;\n const hasActiveFilter = activeFilters.size > 0;\n\n const scrollStyle = maxHeight !== \"none\" ? { maxHeight } : undefined;\n\n return (\n <div\n ref={containerRef}\n className={maxHeight !== \"none\" ? \"overflow-y-auto\" : \"\"}\n style={scrollStyle}\n >\n {/* Filter + controls bar (sticky within scroll container) */}\n <div className=\"sticky top-0 z-10 bg-background flex items-center gap-1 py-1.5 mb-1 border-b border-border/50 flex-wrap pl-2\">\n {/* Type filter chips */}\n {TYPE_CONFIG.filter((tc) => availableTypes.has(tc.type)).map((tc) => {\n const isActive = activeFilters.has(tc.type);\n const count = entries.filter((e) => e.type === tc.type).length;\n return (\n <button\n key={tc.type}\n onClick={() => toggleFilter(tc.type)}\n className={`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] transition-colors ${\n isActive\n ? \"bg-accent text-accent-foreground ring-1 ring-accent-foreground/20\"\n : \"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/50\"\n }`}\n title={`${isActive ? \"Hide\" : \"Show only\"} ${tc.label}`}\n >\n <tc.icon className=\"w-3 h-3\" />\n <span>{count}</span>\n </button>\n );\n })}\n\n {/* Clear filter button */}\n {hasActiveFilter && (\n <button\n onClick={clearFilters}\n className=\"text-[10px] text-muted-foreground/60 hover:text-muted-foreground px-1\"\n >\n Clear\n </button>\n )}\n\n {/* Spacer */}\n <div className=\"flex-1\" />\n\n {/* Collapse/expand all */}\n {!isSingle && (\n <>\n <button\n onClick={collapseAll}\n className=\"inline-flex items-center gap-0.5 text-[10px] text-muted-foreground/60 hover:text-muted-foreground px-1 py-0.5 rounded hover:bg-muted/50 transition-colors\"\n title=\"Collapse all\"\n >\n <ChevronsDownUp className=\"w-3 h-3\" />\n </button>\n <button\n onClick={expandAll}\n className=\"inline-flex items-center gap-0.5 text-[10px] text-muted-foreground/60 hover:text-muted-foreground px-1 py-0.5 rounded hover:bg-muted/50 transition-colors\"\n title=\"Expand all\"\n >\n <ChevronsUpDown className=\"w-3 h-3\" />\n </button>\n </>\n )}\n </div>\n\n {/* Timeline content */}\n {filteredEntries.length === 0 ? (\n <div className=\"text-[10px] text-muted-foreground/50 py-2 text-center\">\n No entries match the selected filters\n </div>\n ) : (\n <div className=\"space-y-0.5\">\n {agentRuns.map((run, i) => {\n const runKey = `${run.agentName}-${i}`;\n const defaultCollapsed = run.depth > 0;\n const isCollapsed = collapsedRuns.has(runKey)\n ? true\n : collapsedRuns.has(`${runKey}:expanded`)\n ? false\n : defaultCollapsed;\n\n return (\n <TimelineAgentBlock\n key={runKey}\n block={run}\n renderMarkdown={renderMarkdown}\n isSingleAgent={isSingle}\n isCollapsed={isCollapsed}\n onToggleCollapsed={() => {\n if (isCollapsed) {\n collapsedRuns.delete(runKey);\n collapsedRuns.add(`${runKey}:expanded`);\n } else {\n collapsedRuns.delete(`${runKey}:expanded`);\n collapsedRuns.add(runKey);\n }\n forceRender();\n }}\n expandedItems={expandedItems}\n onToggleItemExpanded={toggleItemExpanded}\n />\n );\n })}\n </div>\n )}\n </div>\n );\n}\n","/**\n * AgentResponse Component\n *\n * A library-ready presentational component for displaying AI agent responses.\n * Displays thinking, tool calls, knowledge retrieval, memory access, and final response.\n */\n\nimport * as React from \"react\";\nimport { useState, useRef, useMemo, useCallback } from \"react\";\nimport { cn } from \"@optilogic/core\";\nimport { MetadataRow, ThinkingSection, ActionBar, HITLSection } from \"./components\";\nimport { useThinkingTimer } from \"./hooks\";\nimport type { AgentResponseState, FeedbackValue } from \"./types\";\nimport type { HITLInteraction } from \"../hitl-interactions\";\nimport { AgentTimeline, createTimelineUIState } from \"../agent-timeline\";\nimport type { TimelineUIState } from \"../agent-timeline\";\n\nexport interface AgentResponseClassNames {\n /** Classes for the inner container (border, rounded corners, overflow) */\n container?: string;\n /** Classes for the response content section (background, padding) */\n response?: string;\n}\n\n/**\n * Tour anchors (`data-tour` attribute values) to attach to specific elements\n * inside an AgentResponse so a tour or test harness can target them.\n *\n * Each value, when provided, is rendered as `data-tour={value}` on the\n * corresponding element. Omit a field to skip stamping the attribute on that\n * element. Pair with the matching CSS selector form:\n *\n * <AgentResponse anchors={{ copyAction: \"chat-action-copy\" }} />\n * // selector: '[data-tour=\"chat-action-copy\"]'\n *\n * This is the standard convention in the @optilogic component library for\n * threading tour IDs into elements that are rendered by internal\n * sub-components and not otherwise reachable from the caller.\n */\nexport interface AgentResponseAnchors {\n /** Status updates popover trigger in the metadata row (live status indicator). */\n statusUpdate?: string;\n /** Thinking expand/collapse toggle button in the metadata row. */\n thinkingToggle?: string;\n /** Thinking section content panel (when expanded). */\n thinkingSection?: string;\n /** Tool calls popover trigger in the metadata row. */\n toolCalls?: string;\n /** Knowledge popover trigger in the metadata row. */\n knowledge?: string;\n /** Memory popover trigger in the metadata row. */\n memory?: string;\n /** Copy button in the action bar. */\n copyAction?: string;\n /** Thumbs up button in the action bar. */\n thumbsUp?: string;\n /** Thumbs down button in the action bar. */\n thumbsDown?: string;\n}\n\nexport interface AgentResponseProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The response state to render */\n state: AgentResponseState;\n\n /** Optional unique ID (for list keys) */\n id?: string;\n\n /** Optional timestamp to display */\n timestamp?: Date;\n\n /** Feedback state (controlled) */\n feedback?: FeedbackValue;\n onFeedbackChange?: (feedback: FeedbackValue) => void;\n\n /** Callback when the response is copied via the action bar */\n onResponseCopy?: (response: string) => void;\n\n /** Thinking section expansion (controlled or uncontrolled) */\n defaultThinkingExpanded?: boolean;\n thinkingExpanded?: boolean;\n onThinkingExpandedChange?: (expanded: boolean) => void;\n\n /** Action bar visibility mode */\n actionsVisible?: boolean | \"hover\";\n\n /**\n * Optional HITL (Human-in-the-Loop) interactions to display as a\n * collapsible section within the response. When provided, a \"Clarifying\n * Questions\" section appears between the thinking/metadata area and\n * the response content.\n */\n hitlInteractions?: HITLInteraction[];\n\n /** Whether the HITL section starts expanded (default: false) */\n defaultHITLExpanded?: boolean;\n\n /**\n * Optional content to display in the MetadataRow's middle area,\n * between the thinking toggle (left) and activity indicators (right).\n * Typically used for ephemeral status messages during processing.\n * The parent is responsible for setting and clearing this content.\n *\n * @example\n * <AgentResponse\n * state={state}\n * statusContent={\n * state.status !== 'complete'\n * ? <TruncatedMessage message=\"Analyzing data...\" />\n * : undefined\n * }\n * />\n */\n statusContent?: React.ReactNode;\n\n /**\n * Custom markdown renderer for the response content.\n * If not provided, the response will be rendered as plain text.\n *\n * @example\n * <AgentResponse\n * state={state}\n * renderMarkdown={(content) => <MyMarkdownRenderer content={content} />}\n * />\n */\n renderMarkdown?: (content: string) => React.ReactNode;\n\n /**\n * Custom markdown renderer for the thinking content.\n * If not provided, the thinking will be rendered as plain preformatted text.\n *\n * @example\n * <AgentResponse\n * state={state}\n * renderThinkingMarkdown={(content) => <MyMarkdownRenderer content={content} />}\n * />\n */\n renderThinkingMarkdown?: (content: string) => React.ReactNode;\n\n /**\n * Maximum height of the AgentTimeline scrollable container.\n * Defaults to \"300px\". Set to \"none\" to disable the constraint.\n */\n timelineMaxHeight?: string;\n\n /**\n * Class name overrides for internal elements.\n * Use this to customize the container border/background or response section styling.\n *\n * @example\n * // Transparent background and borders\n * <AgentResponse\n * state={state}\n * classNames={{\n * container: \"border-transparent\",\n * response: \"bg-transparent\",\n * }}\n * />\n */\n classNames?: AgentResponseClassNames;\n\n /**\n * Tour anchors threaded into internal sub-components. See\n * {@link AgentResponseAnchors} for the available element keys.\n *\n * @example\n * <AgentResponse\n * state={state}\n * anchors={{\n * copyAction: \"chat-action-copy\",\n * thumbsUp: \"chat-action-thumbs-up\",\n * thumbsDown: \"chat-action-thumbs-down\",\n * }}\n * />\n */\n anchors?: AgentResponseAnchors;\n}\n\n/**\n * AgentResponse Component\n *\n * A complete component for displaying AI agent responses including:\n * - Thinking/reasoning content (collapsible)\n * - Tool calls, knowledge retrieval, and memory access indicators\n * - Final response with optional markdown rendering\n * - Action bar with copy and feedback buttons\n *\n * @example\n * // Basic usage with useAgentResponseAccumulator hook\n * const { state, handleMessage } = useAgentResponseAccumulator();\n *\n * <AgentResponse state={state} />\n *\n * @example\n * // With markdown rendering and feedback\n * <AgentResponse\n * state={state}\n * renderMarkdown={(content) => <ReactMarkdown>{content}</ReactMarkdown>}\n * feedback={feedback}\n * onFeedbackChange={setFeedback}\n * />\n *\n * @example\n * // Controlled thinking expansion\n * <AgentResponse\n * state={state}\n * thinkingExpanded={isExpanded}\n * onThinkingExpandedChange={setIsExpanded}\n * />\n */\nconst AgentResponse = React.forwardRef<HTMLDivElement, AgentResponseProps>(\n (\n {\n state,\n id,\n timestamp,\n feedback,\n onFeedbackChange,\n onResponseCopy,\n defaultThinkingExpanded = false,\n thinkingExpanded: controlledThinkingExpanded,\n onThinkingExpandedChange,\n actionsVisible = \"hover\",\n hitlInteractions,\n defaultHITLExpanded = false,\n statusContent,\n renderMarkdown,\n renderThinkingMarkdown,\n timelineMaxHeight,\n classNames,\n anchors,\n className,\n ...props\n },\n ref\n ) => {\n // Ref-backed timeline UI state (survives remounts during streaming)\n const timelineUIStateRef = useRef<TimelineUIState>(createTimelineUIState());\n\n // Uncontrolled thinking expanded state\n const [uncontrolledExpanded, setUncontrolledExpanded] = useState(defaultThinkingExpanded);\n\n // Determine if thinking is controlled\n const isThinkingControlled = controlledThinkingExpanded !== undefined;\n const thinkingExpanded = isThinkingControlled\n ? controlledThinkingExpanded\n : uncontrolledExpanded;\n\n // Toggle thinking handler\n const toggleThinking = useCallback(() => {\n const newValue = !thinkingExpanded;\n if (isThinkingControlled) {\n onThinkingExpandedChange?.(newValue);\n } else {\n setUncontrolledExpanded(newValue);\n }\n }, [thinkingExpanded, isThinkingControlled, onThinkingExpandedChange]);\n\n // Hover state for action bar visibility\n const [isHovered, setIsHovered] = useState(false);\n\n // Thinking timer\n const elapsedTime = useThinkingTimer({\n startTime: state.thinkingStartTime,\n endTime: state.responseCompleteTime,\n status: state.status,\n });\n\n // Calculate total time (from first message to response complete)\n const totalTimeSeconds = useMemo(() => {\n if (!state.firstMessageTime || !state.responseCompleteTime) return 0;\n return (state.responseCompleteTime - state.firstMessageTime) / 1000;\n }, [state.firstMessageTime, state.responseCompleteTime]);\n\n // Check if we have any thinking content (plain text, structured, or timeline)\n const hasTimelineEntries = !!(state.timelineEntries && state.timelineEntries.length > 0);\n const hasThinkingContent =\n !!state.thinking || (state.thinkingSteps && state.thinkingSteps.length > 0) || hasTimelineEntries || false;\n\n const hasHITLInteractions =\n hitlInteractions && hitlInteractions.length > 0;\n\n // Derived state: has any content been received?\n const hasAnyContent =\n hasThinkingContent ||\n state.toolCalls.length > 0 ||\n state.knowledge.length > 0 ||\n state.memory.length > 0 ||\n state.statusUpdates.length > 0 ||\n hasHITLInteractions ||\n state.response;\n\n // Derived state: should show metadata row?\n const showMetadataRow =\n hasThinkingContent ||\n state.toolCalls.length > 0 ||\n state.knowledge.length > 0 ||\n state.memory.length > 0 ||\n state.statusUpdates.length > 0 ||\n state.status === \"processing\";\n\n // Determine action bar visibility\n const showActionBar = state.status === \"complete\" && state.response;\n const isActionBarVisible =\n actionsVisible === true ||\n (actionsVisible === \"hover\" && isHovered);\n\n // If no content, render nothing\n if (!hasAnyContent) {\n return null;\n }\n\n return (\n <div\n ref={ref}\n className={className}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n {...props}\n >\n {/* Message Content Container */}\n <div className={cn(\"border border-border rounded-lg overflow-hidden\", classNames?.container)}>\n {/* Metadata Row - show if there's any metadata or thinking */}\n {showMetadataRow && (\n <>\n <MetadataRow\n hasThinking={hasThinkingContent}\n isExpanded={thinkingExpanded}\n onToggle={toggleThinking}\n toolCalls={state.toolCalls}\n knowledge={state.knowledge}\n memory={state.memory}\n statusUpdates={state.statusUpdates}\n statusContent={statusContent}\n status={state.status}\n elapsedTime={elapsedTime}\n thinkingToggleAnchor={anchors?.thinkingToggle}\n statusUpdateAnchor={anchors?.statusUpdate}\n toolCallsAnchor={anchors?.toolCalls}\n knowledgeAnchor={anchors?.knowledge}\n memoryAnchor={anchors?.memory}\n />\n\n {/* Thinking Content - AgentTimeline when timeline entries exist, ThinkingSection otherwise */}\n {hasTimelineEntries ? (\n thinkingExpanded && (\n <div className=\"pb-3 border-t border-border\" data-tour={anchors?.thinkingSection}>\n <AgentTimeline\n entries={state.timelineEntries!}\n renderMarkdown={renderThinkingMarkdown}\n uiState={timelineUIStateRef.current}\n maxHeight={timelineMaxHeight}\n />\n </div>\n )\n ) : (\n <ThinkingSection\n data-tour={anchors?.thinkingSection}\n content={\n state.thinkingSteps && state.thinkingSteps.length > 0\n ? state.thinkingSteps\n : state.thinking\n }\n isExpanded={thinkingExpanded}\n renderMarkdown={renderThinkingMarkdown}\n />\n )}\n </>\n )}\n\n {/* HITL Interactions - collapsible section */}\n {hasHITLInteractions && (\n <HITLSection\n interactions={hitlInteractions}\n defaultExpanded={defaultHITLExpanded}\n />\n )}\n\n {/* Response Section */}\n {state.response && (\n <div\n className={cn(\n \"bg-muted/50 p-4\",\n showMetadataRow && \"border-t border-border\",\n classNames?.response\n )}\n >\n {renderMarkdown ? (\n renderMarkdown(state.response)\n ) : (\n <span className=\"whitespace-pre-wrap\">{state.response}</span>\n )}\n </div>\n )}\n </div>\n\n {/* Action Bar - outside the message container, visible on hover when complete */}\n {showActionBar && (\n <ActionBar\n response={state.response}\n isVisible={isActionBarVisible}\n totalTimeSeconds={totalTimeSeconds}\n feedback={feedback}\n onFeedbackChange={onFeedbackChange}\n onResponseCopy={onResponseCopy}\n copyAnchor={anchors?.copyAction}\n thumbsUpAnchor={anchors?.thumbsUp}\n thumbsDownAnchor={anchors?.thumbsDown}\n />\n )}\n </div>\n );\n }\n);\nAgentResponse.displayName = \"AgentResponse\";\n\nexport { AgentResponse };\n","import * as React from \"react\";\nimport { cn } from \"@optilogic/core\";\n\nexport interface UserPromptProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The text content of the user's message */\n content: string;\n /** Optional timestamp to display below the message */\n timestamp?: Date;\n}\n\n/**\n * UserPrompt component\n *\n * Displays a user's chat message in a styled bubble.\n * Used alongside AgentResponse to create chat interfaces.\n *\n * @example\n * ```tsx\n * <UserPrompt\n * content=\"What is the weather today?\"\n * timestamp={new Date()}\n * />\n * ```\n *\n * @example\n * ```tsx\n * // Custom styling\n * <UserPrompt\n * content=\"Hello world\"\n * className=\"max-w-full\"\n * />\n * ```\n */\nexport const UserPrompt = React.forwardRef<HTMLDivElement, UserPromptProps>(\n ({ content, timestamp, className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn(\n \"w-fit max-w-[80%] rounded-lg px-4 pt-3.5 pb-3\",\n \"bg-secondary text-secondary-foreground\",\n className\n )}\n {...props}\n >\n <p className=\"whitespace-pre-wrap\">{content}</p>\n {timestamp && (\n <p className=\"text-xs text-secondary-foreground/70 mt-1\">\n {timestamp.toLocaleTimeString([], {\n hour: \"2-digit\",\n minute: \"2-digit\",\n })}\n </p>\n )}\n </div>\n );\n }\n);\n\nUserPrompt.displayName = \"UserPrompt\";\n","import * as React from \"react\";\nimport { Send, Loader2, Square } from \"lucide-react\";\nimport { cn, IconButton, Tooltip } from \"@optilogic/core\";\nimport {\n SlateEditor,\n Text,\n type SlateEditorRef,\n type NodeEntry,\n type DecoratedRange,\n type RenderLeafProps,\n} from \"@optilogic/editor\";\nimport type { UserPromptInputProps, UserPromptInputRef } from \"./types\";\n\n/**\n * Creates a decorate function that highlights code blocks.\n * Handles both complete (```...```) and unclosed (```...) code blocks.\n */\nfunction createCodeBlockDecorate(entry: NodeEntry): DecoratedRange[] {\n const [node, path] = entry;\n const ranges: DecoratedRange[] = [];\n\n if (!Text.isText(node)) {\n return ranges;\n }\n\n const { text } = node;\n\n // Find all ``` positions\n const backtickPositions: number[] = [];\n let searchStart = 0;\n while (true) {\n const pos = text.indexOf(\"```\", searchStart);\n if (pos === -1) break;\n backtickPositions.push(pos);\n searchStart = pos + 3;\n }\n\n // Process pairs of backticks (and handle unclosed blocks)\n let i = 0;\n while (i < backtickPositions.length) {\n const openPos = backtickPositions[i];\n const closePos = backtickPositions[i + 1];\n\n // Mark opening delimiter\n ranges.push({\n anchor: { path, offset: openPos },\n focus: { path, offset: openPos + 3 },\n codeDelimiter: true,\n } as DecoratedRange);\n\n if (closePos !== undefined) {\n // Complete code block - mark content and closing delimiter\n if (closePos > openPos + 3) {\n ranges.push({\n anchor: { path, offset: openPos + 3 },\n focus: { path, offset: closePos },\n codeBlock: true,\n } as DecoratedRange);\n }\n ranges.push({\n anchor: { path, offset: closePos },\n focus: { path, offset: closePos + 3 },\n codeDelimiter: true,\n } as DecoratedRange);\n i += 2; // Move past both opening and closing\n } else {\n // Unclosed code block - mark everything to end as code\n if (text.length > openPos + 3) {\n ranges.push({\n anchor: { path, offset: openPos + 3 },\n focus: { path, offset: text.length },\n codeBlock: true,\n } as DecoratedRange);\n }\n i += 1; // Move past opening only\n }\n }\n\n return ranges;\n}\n\n/**\n * Custom leaf renderer for code block styling\n */\nfunction CodeBlockLeaf({ attributes, children, leaf }: RenderLeafProps) {\n const leafAny = leaf as { codeBlock?: boolean; codeDelimiter?: boolean };\n\n if (leafAny.codeBlock) {\n return (\n <span\n {...attributes}\n className=\"bg-muted/50 text-muted-foreground font-mono text-sm rounded px-1\"\n >\n {children}\n </span>\n );\n }\n\n if (leafAny.codeDelimiter) {\n return (\n <span\n {...attributes}\n className=\"text-muted-foreground/50 font-mono text-sm\"\n >\n {children}\n </span>\n );\n }\n\n return <span {...attributes}>{children}</span>;\n}\n\n/**\n * UserPromptInput Component\n *\n * A rich text input for user messages that wraps SlateEditor.\n * Features:\n * - Code block styling with triple backticks\n * - Send button with loading state\n * - Action slot for additional buttons\n * - Tag support (optional)\n *\n * @example\n * <UserPromptInput\n * placeholder=\"Type your message...\"\n * onSubmit={(text) => sendMessage(text)}\n * renderActions={() => (\n * <IconButton icon={<Paperclip />} aria-label=\"Attach file\" />\n * )}\n * />\n */\nexport const UserPromptInput = React.forwardRef<\n UserPromptInputRef,\n UserPromptInputProps\n>(\n (\n {\n value = \"\",\n onChange,\n onSubmit,\n clearOnSubmit = true,\n placeholder = \"Type your message...\",\n disabled = false,\n isSubmitting = false,\n onStop,\n stopTooltip,\n stopClassName,\n disableWhileSubmitting = true,\n autoFocus = false,\n refocusAfterSubmit = false,\n onReady,\n minRows = 1,\n maxRows = 6,\n renderActions,\n enableTags = false,\n onTagCreate,\n onTagDelete,\n anchors,\n className,\n ...props\n },\n ref\n ) => {\n const editorRef = React.useRef<SlateEditorRef>(null);\n const [internalValue, setInternalValue] = React.useState(value);\n const prevIsSubmitting = React.useRef(isSubmitting);\n const hasEmittedReady = React.useRef(false);\n\n // Sync internal value with prop\n React.useEffect(() => {\n setInternalValue(value);\n }, [value]);\n\n // Handle autoFocus - use double RAF to ensure Slate is fully initialized\n React.useEffect(() => {\n if (autoFocus) {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n editorRef.current?.focus();\n });\n });\n }\n }, [autoFocus]);\n\n // Emit onReady callback when editor is initialized\n React.useEffect(() => {\n if (!hasEmittedReady.current && onReady) {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n hasEmittedReady.current = true;\n onReady();\n });\n });\n }\n }, [onReady]);\n\n // Refocus after submit completes\n React.useEffect(() => {\n if (refocusAfterSubmit && prevIsSubmitting.current && !isSubmitting) {\n requestAnimationFrame(() => {\n editorRef.current?.focus();\n });\n }\n prevIsSubmitting.current = isSubmitting;\n }, [isSubmitting, refocusAfterSubmit]);\n\n // Expose ref methods\n React.useImperativeHandle(\n ref,\n () => ({\n focus: () => {\n try {\n editorRef.current?.focus();\n } catch {\n // Retry after Slate initializes (handles early calls)\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n editorRef.current?.focus();\n });\n });\n }\n },\n clear: () => {\n editorRef.current?.clear();\n setInternalValue(\"\");\n },\n getText: () => editorRef.current?.getText() ?? \"\",\n insertText: (text: string) => editorRef.current?.insertText(text),\n }),\n []\n );\n\n const handleChange = React.useCallback(\n (newValue: string) => {\n setInternalValue(newValue);\n onChange?.(newValue);\n },\n [onChange]\n );\n\n const handleSubmit = React.useCallback(\n (text: string) => {\n if (disabled || isSubmitting) return;\n if (!text.trim()) return;\n\n onSubmit?.(text.trim());\n\n if (clearOnSubmit) {\n editorRef.current?.clear();\n setInternalValue(\"\");\n }\n },\n [disabled, isSubmitting, onSubmit, clearOnSubmit]\n );\n\n const handleSendClick = React.useCallback(() => {\n const text = editorRef.current?.getText() ?? \"\";\n handleSubmit(text);\n }, [handleSubmit]);\n\n const hasContent = internalValue.trim().length > 0;\n const canSubmit = hasContent && !disabled && !isSubmitting;\n\n return (\n <div\n className={cn(\n \"rounded-lg border border-input bg-background\",\n disabled && \"opacity-50 cursor-not-allowed\",\n className\n )}\n {...props}\n >\n {/* Editor area */}\n <div className=\"pl-2 pr-0 pt-1 pb-1\">\n <SlateEditor\n ref={editorRef}\n value={internalValue}\n onChange={handleChange}\n onSubmit={handleSubmit}\n clearOnSubmit={false}\n placeholder={placeholder}\n disabled={disabled || (disableWhileSubmitting && isSubmitting)}\n enableTags={enableTags}\n onTagCreate={onTagCreate}\n onTagDelete={onTagDelete}\n minRows={minRows}\n maxRows={maxRows}\n decorate={createCodeBlockDecorate}\n renderLeaf={CodeBlockLeaf}\n />\n </div>\n\n {/* Actions row */}\n <div className=\"flex items-center justify-between pl-2 pr-1 pb-1 pt-1\">\n {/* Left actions slot */}\n <div className=\"flex items-center gap-1\">{renderActions?.()}</div>\n\n {/* Send/Stop button */}\n {isSubmitting && onStop ? (\n <Tooltip content={stopTooltip} disabled={!stopTooltip}>\n <IconButton\n data-tour={anchors?.stopButton}\n icon={<Square />}\n variant=\"filled\"\n size=\"sm\"\n aria-label={stopTooltip || \"Stop\"}\n onClick={onStop}\n className={stopClassName}\n />\n </Tooltip>\n ) : (\n <IconButton\n data-tour={anchors?.sendButton}\n icon={\n isSubmitting ? (\n <Loader2 className=\"animate-spin\" />\n ) : (\n <Send />\n )\n }\n variant=\"filled\"\n size=\"sm\"\n aria-label={isSubmitting ? \"Sending...\" : \"Send message\"}\n disabled={!canSubmit}\n onClick={handleSendClick}\n />\n )}\n </div>\n </div>\n );\n }\n);\n\nUserPromptInput.displayName = \"UserPromptInput\";\n","import type { ResponseSegment } from \"./types\";\n\n/**\n * Regex to match ```json:action fenced code blocks.\n * Captures the JSON content between the fences.\n */\nconst ACTION_BLOCK_REGEX = /```json:action\\s*\\n([\\s\\S]*?)```/g;\n\n/**\n * Parse response text into interleaved markdown and action segments.\n *\n * Finds ```json:action ... ``` fenced code blocks, extracts them as\n * action segments, and returns the surrounding text as markdown segments.\n *\n * Malformed JSON or blocks missing a \"type\" field are left as markdown\n * (rendered as raw code blocks) for graceful degradation.\n */\nexport function parseResponseSegments(text: string): ResponseSegment[] {\n if (!text) return [];\n\n const segments: ResponseSegment[] = [];\n let lastIndex = 0;\n\n // Reset regex state (global regexes are stateful)\n ACTION_BLOCK_REGEX.lastIndex = 0;\n\n let match: RegExpExecArray | null;\n while ((match = ACTION_BLOCK_REGEX.exec(text)) !== null) {\n // Add markdown segment for text before this match\n const before = text.slice(lastIndex, match.index);\n if (before.trim()) {\n segments.push({ kind: \"markdown\", content: before });\n }\n\n // Try to parse the JSON content\n const jsonContent = match[1].trim();\n let parsed: Record<string, unknown> | null = null;\n try {\n parsed = JSON.parse(jsonContent);\n } catch {\n // Malformed JSON — fall back to markdown\n }\n\n if (parsed && typeof parsed === \"object\" && typeof parsed.type === \"string\") {\n segments.push({\n kind: \"action\",\n actionType: parsed.type as string,\n payload: parsed,\n });\n } else {\n // Missing \"type\" field or invalid JSON — render as raw code block\n const rawBlock = match[0];\n segments.push({ kind: \"markdown\", content: rawBlock });\n }\n\n lastIndex = match.index + match[0].length;\n }\n\n // Add trailing markdown segment\n const trailing = text.slice(lastIndex);\n if (trailing.trim()) {\n segments.push({ kind: \"markdown\", content: trailing });\n }\n\n return segments;\n}\n","import { useMemo } from \"react\";\nimport { parseResponseSegments } from \"./parseResponseSegments\";\nimport type { ActionMarkdownRendererProps } from \"./types\";\n\n/**\n * Renders agent response text with inline action components.\n *\n * Parses the response for ```json:action blocks, renders markdown\n * segments via the provided renderMarkdown function, and renders\n * action segments via the component registry.\n *\n * Unknown action types fall back to a raw JSON code block display.\n */\nexport function ActionMarkdownRenderer({\n content,\n registry,\n renderMarkdown,\n onAction,\n isLatest,\n}: ActionMarkdownRendererProps) {\n const segments = useMemo(() => parseResponseSegments(content), [content]);\n\n // If no action blocks found, render as plain markdown (skip extra wrapper divs)\n if (segments.length === 1 && segments[0].kind === \"markdown\") {\n return <>{renderMarkdown(segments[0].content)}</>;\n }\n\n return (\n <>\n {segments.map((segment, index) => {\n if (segment.kind === \"markdown\") {\n return <div key={`md-${index}`}>{renderMarkdown(segment.content)}</div>;\n }\n\n // Action segment — look up registered component\n const Component = registry[segment.actionType];\n if (!Component) {\n // Fallback: render raw JSON as a styled code block\n return (\n <pre\n key={`action-fallback-${index}`}\n className=\"my-4 p-4 rounded-lg border border-border bg-muted text-sm font-mono overflow-x-auto\"\n >\n <code>{JSON.stringify(segment.payload, null, 2)}</code>\n </pre>\n );\n }\n\n return (\n <Component\n key={`action-${segment.actionType}-${index}`}\n payload={segment.payload}\n onAction={onAction}\n isLatest={isLatest}\n />\n );\n })}\n </>\n );\n}\n","/**\n * System prompt instructions for agents that emit inline action blocks.\n *\n * Import and append to your agent's system prompt so it knows the\n * json:action format. The XML tags ensure clear boundaries for the LLM.\n *\n * When adding a new action type, add an entry under \"Available action types\"\n * and create the corresponding React component + registry entry.\n */\nexport const INLINE_ACTION_PROMPT = `\n<inline_actions>\nWhen your response should include interactive components (like query viewers,\ndata tables, or executable actions), embed them as fenced code blocks using\nthe \\`json:action\\` language tag:\n\n\\`\\`\\`json:action\n{\n \"type\": \"action-type-here\",\n ...action-specific fields\n}\n\\`\\`\\`\n\nRules:\n- Each block must contain valid JSON with a \"type\" field.\n- The \"type\" must match a registered action component on the frontend.\n- Multiple action blocks per response are allowed.\n- Surround action blocks with normal markdown text for user context.\n- The action block is rendered as an interactive component in the chat UI.\n- SQL strings inside JSON must be properly escaped (newlines as \\\\n, quotes as \\\\\").\n\nAvailable action types:\n\n- \"optimap-query\": Displays SQL queries with a button to execute them and\n update the 3D globe map.\n Required fields:\n - type: \"optimap-query\"\n - locations_sql: string (the validated locations SQL query)\n - routes_sql: string (the validated routes SQL query)\n - database_name: string (the target database name)\n</inline_actions>\n`;\n"]}