"use client"; import { Handle, Position, type Node, type NodeProps } from "@xyflow/react"; import BaseNodeWrapper from "./base-node-wrapper"; type AgentOutputNodeData = { isSkeleton?: boolean; stepId?: string; stepIndex?: number; stepTotal?: number; title?: string; channel?: string; outputType?: string; body?: string; _status?: string; _statusMessage?: string; }; type AgentOutputNodeType = Node; export default function AgentOutputNode({ data, selected }: NodeProps) { const nodeData = data as AgentOutputNodeData; const isSkeleton = nodeData.isSkeleton === true; const hasStepCounter = typeof nodeData.stepIndex === "number" && Number.isFinite(nodeData.stepIndex) && typeof nodeData.stepTotal === "number" && Number.isFinite(nodeData.stepTotal) && nodeData.stepTotal > 0; const safeStepIndex = typeof nodeData.stepIndex === "number" && Number.isFinite(nodeData.stepIndex) ? Math.max(0, Math.floor(nodeData.stepIndex)) : 0; const safeStepTotal = typeof nodeData.stepTotal === "number" && Number.isFinite(nodeData.stepTotal) ? Math.max(1, Math.floor(nodeData.stepTotal)) : 1; const stepCounter = hasStepCounter ? `${safeStepIndex + 1}/${safeStepTotal}` : null; const resolvedTitle = nodeData.title ?? (isSkeleton ? "Planned output" : "Agent output"); return (

{resolvedTitle}

{isSkeleton ? ( Skeleton ) : null}
{isSkeleton ? (

Planned output{stepCounter ? ` - ${stepCounter}` : ""} {nodeData.stepId ? ` - ${nodeData.stepId}` : ""}

) : null}

Channel

{nodeData.channel ?? "-"}

Output Type

{nodeData.outputType ?? "-"}

Body

{isSkeleton ? (

Planned content

) : (

{nodeData.body ?? ""}

)}
); }