
    Cj                        S SK Jr  S SKrS SKJr  S SKJr  S	S jr S
       SS jjr S
       SS jjr	SSS jjr
g)    )annotationsN)Agent)Handoffc                    S/nUR                  [        U 5      5        UR                  [        U 5      5        UR                  S5        SR                  U5      $ )z
Generates the main graph structure in DOT format for the given agent.

Args:
    agent (Agent): The agent for which the graph is to be generated.

Returns:
    str: The DOT format string representing the graph.
zq
    digraph G {
        graph [splines=true];
        node [fontname="Arial"];
        edge [penwidth=1.5];
    } )appendget_all_nodesget_all_edgesjoin)agentpartss     q/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/agents/extensions/visualization.pyget_main_graphr   	   sL    	E 
LLu%&	LLu%&	LL775>    c                   Uc
  [        5       nU R                  U;   a  gUR                  U R                  5        / nU(       d=  UR                  S5        UR                  SU R                   SU R                   S35        U R                   H/  nUR                  SUR                   SUR                   S35        M1     U R
                   H/  nUR                  SUR                   SUR                   S35        M1     U R                   H  n[        U[        5      (       a,  UR                  SUR                   SUR                   S35        [        U[        5      (       d  M[  UR                  U;  a,  UR                  SUR                   SUR                   S35        UR                  [        X`U5      5        M     SR                  U5      $ )	z
Recursively generates the nodes for the given agent and its handoffs in DOT format.

Args:
    agent (Agent): The agent for which the nodes are to be generated.

Returns:
    str: The DOT format string representing the nodes.
r   z"__start__" [label="__start__", shape=ellipse, style=filled, fillcolor=lightblue, width=0.5, height=0.3];"__end__" [label="__end__", shape=ellipse, style=filled, fillcolor=lightblue, width=0.5, height=0.3];"z
" [label="zJ", shape=box, style=filled, fillcolor=lightyellow, width=1.5, height=0.8];zM", shape=ellipse, style=filled, fillcolor=lightgreen, width=0.5, height=0.3];zF", shape=box, style=filled, fillcolor=lightgrey, width=1, height=0.5];zY", shape=box, style=filled, style=rounded, fillcolor=lightyellow, width=1.5, height=0.8];)setnameaddr	   toolsmcp_servershandoffs
isinstancer   
agent_namer   r
   r   r   parentvisitedr   tool
mcp_serverhandoffs          r   r
   r
   !   s    %zzWKK

E ;	
 	

|:ejj\ 2= =	

 		{*TYYK 0< =	
  ''

 
:??*; <9 :	
 ( >>gw''LLG&&'z'2D2D1E FA B
 gu%%||7*~Z~ >E F
 LLww?@ "  775>r   c                   Uc
  [        5       nU R                  U;   a  gUR                  U R                  5        / nU(       d  UR                  SU R                   S35        U R                   HI  nUR                  SU R                   SUR                   SUR                   SU R                   S3	5        MK     U R
                   HI  nUR                  SU R                   SUR                   SUR                   SU R                   S	3	5        MK     U R                   H  n[        U[        5      (       a,  UR                  S
U R                   SUR                   S35        [        U[        5      (       d  M[  UR                  S
U R                   SUR                   S35        UR                  [        X`U5      5        M     U R                  (       d  UR                  SU R                   S35        SR                  U5      $ )a%  
Recursively generates the edges for the given agent and its handoffs in DOT format.

Args:
    agent (Agent): The agent for which the edges are to be generated.
    parent (Agent, optional): The parent agent. Defaults to None.

Returns:
    str: The DOT format string representing the edges.
r   z"__start__" -> "z";z

        "z" -> "z)" [style=dotted, penwidth=1.5];
        "z" [style=dotted, penwidth=1.5];z)" [style=dashed, penwidth=1.5];
        "z" [style=dashed, penwidth=1.5];z
            "r   z" -> "__end__";)r   r   r   r	   r   r   r   r   r   r   r   r   r   r   s          r   r   r   b   s    %zzWKK

E'

|267 

**VDII; '

))F5::,&EI 	J 
 ''
 

**VJOO, -

//	&,KO 	P (
 >>gw''LL jj\ 2 2329 :gu%%LL jj\~R3 4LLww?@ " >>qO45775>r   c                x    [        U 5      n[        R                  " U5      nU(       a  UR                  USSS9  U$ )a+  
Draws the graph for the given agent and optionally saves it as a PNG file.

Args:
    agent (Agent): The agent for which the graph is to be drawn.
    filename (str): The name of the file to save the graph as a PNG.

Returns:
    graphviz.Source: The graphviz Source object representing the graph.
pngT)formatcleanup)r   graphvizSourcerender)r   filenamedot_codegraphs       r   
draw_graphr-      s6     e$HOOH%EXeT:Lr   )r   r   returnstr)NN)r   r   r   zAgent | Noner   zset[str] | Noner.   r/   )N)r   r   r*   z
str | Noner.   zgraphviz.Source)
__future__r   r'   agentsr   agents.handoffsr   r   r
   r   r-    r   r   <module>r4      su    "   #2 KO>>&>8G>>D KO..&.8G..br   