import {
Box,
CircularProgress,
Typography,
Collapse,
Button,
} from '@mui/material'
import { ArrowRight, CheckCircle, Error } from '@mui/icons-material'
import type { ChatToolTraceProps } from '../types'
import { ChatToolCodeArea } from './chat-tool-code-area'
import { styles } from './styles'
import { ChatThinking } from './chat-thinking'
import { getToolLabel } from './get-tool-label'
import { McpTool } from '@carto/meridian-ds/custom-icons'
function TraceStatusIndicator({
status,
labels,
}: {
status: string
labels: ChatToolTraceProps['labels']
}) {
switch (status) {
case 'complete':
return (
{labels?.success ?? 'Success'}
)
case 'error':
return (
{labels?.error ?? 'Error'}
)
case 'running':
return
default:
return null
}
}
export function ChatToolTraceDetails({
tool,
labels = {},
}: Pick) {
const isError = tool.status === 'error'
const toolExecutedLabel = labels.toolExecuted ?? 'Tool executed'
const referenceLabel = labels.reference ?? 'Reference:'
const durationLabel = labels.duration ?? 'Duration:'
const statusLabel = labels.status ?? 'Status:'
const inputArgumentsLabel = labels.inputArguments ?? 'Input arguments:'
const outputLabel = labels.output ?? 'Output:'
return (
{tool.reference && (
{referenceLabel}
{tool.reference}
)}
{tool.duration != null && (
{durationLabel}
{tool.duration}s
)}
{statusLabel}
{tool.inputArguments && (
{inputArgumentsLabel}
)}
{tool.output && (
{outputLabel}
)}
)
}
export function ChatToolTrace({
tool,
expanded,
onExpandedChange,
labels = {},
sx,
}: ChatToolTraceProps) {
const isRunning = tool.status === 'running'
const toolExecutedLabel = labels.toolExecuted ?? 'Tool executed'
if (isRunning) {
return {getToolLabel(tool)}
}
return (
)
}