// Agent Builder — Visual flow-builder section (animated) // Recreates the node-canvas reference and animates the wiring. const COMPONENTS = [ { c: "#22c5e8", t: "Input & Output" }, { c: "#7c4dff", t: "Models & Agents" }, { c: "#f0337f", t: "LLM Operations" }, { c: "#f5c518", t: "Knowledge" }, ]; // node positions as % of the canvas box (mirrors the reference layout) const NODES = [ { id: "input", cls: "", accent: "#22c5e8", label: "Chat Input", body: "User Message", left: 3, top: 17 }, { id: "agent", cls: "is-agent", accent: "#7c4dff", label: "Agent", body: "Análise · 2 tools", left: 39, top: 46 }, { id: "guard", cls: "", accent: "#f0337f", label: "Guardrails", body: "PII · LGPD", left: 73, top: 11 }, ]; // directed wires between node ids — the wire is drawn grey; the pulse is coloured const WIRES = [ { from: "input", to: "agent", color: "#22c5e8" }, { from: "agent", to: "guard", color: "#7c4dff" }, ]; function FlowBuilder() { const canvasRef = useRef(null); const nodeRefs = useRef({}); const [links, setLinks] = useState([]); const [box, setBox] = useState({ w: 0, h: 0 }); const [entered, setEntered] = useState(false); const measure = () => { const canvas = canvasRef.current; if (!canvas) return; const W = canvas.clientWidth, H = canvas.clientHeight; const anchor = (id, side) => { const el = nodeRefs.current[id]; if (!el) return { x: 0, y: 0 }; const x = side === "right" ? el.offsetLeft + el.offsetWidth : el.offsetLeft; const y = el.offsetTop + el.offsetHeight / 2; return { x, y }; }; const out = WIRES.map((w) => { const s = anchor(w.from, "right"); const t = anchor(w.to, "left"); const mx = s.x + (t.x - s.x) * 0.5; const d = `M ${s.x},${s.y} C ${mx},${s.y} ${mx},${t.y} ${t.x},${t.y}`; return { d, color: w.color }; }); setBox({ w: W, h: H }); setLinks(out); }; useEffect(() => { const raf = requestAnimationFrame(() => { measure(); requestAnimationFrame(() => setEntered(true)); }); window.addEventListener("resize", measure); return () => { cancelAnimationFrame(raf); window.removeEventListener("resize", measure); }; }, []); return (
agentbuilder.maitha.com / construir
{links.map((l, i) => )} {NODES.map((n, idx) => (
{ nodeRefs.current[n.id] = el; }} className={"fnode " + n.cls} style={{ left: n.left + "%", top: n.top + "%" }} >
{n.label}
{n.body}
))} {links.map((l, i) => ( ))}
); } Object.assign(window, { FlowBuilder });