import { Header3 } from "~/components/primitives/Headers"; import { CodeBlock } from "~/components/code/CodeBlock"; import { TruncatedCopyableValue } from "~/components/primitives/TruncatedCopyableValue"; import { formatDuration, tryPrettyJson } from "./aiHelpers"; import { SpanMetricRow as MetricRow } from "./SpanMetricRow"; export type AIToolCallData = { toolName: string; toolCallId: string; args?: string; durationMs: number; }; export function extractAIToolCallData( properties: Record, durationMs: number ): AIToolCallData | undefined { const ai = properties.ai; if (!ai || typeof ai !== "object") return undefined; const a = ai as Record; if (a.operationId !== "ai.toolCall") return undefined; const toolCall = a.toolCall; if (!toolCall || typeof toolCall !== "object") return undefined; const tc = toolCall as Record; const toolName = typeof tc.name === "string" ? tc.name : undefined; if (!toolName) return undefined; return { toolName, toolCallId: typeof tc.id === "string" ? tc.id : "", args: typeof tc.args === "string" ? tc.args : undefined, durationMs, }; } export function AIToolCallSpanDetails({ data }: { data: AIToolCallData }) { return (
{/* Tool info */}
{data.toolCallId && ( } /> )}
{/* Input args */} {data.args && (
Input
)}
); }