
    i                     D    d Z ddlmZ ddlmZmZ ddlmZ  G d d      Zy)z[Factory helpers for node executors.

Create and manage executors for different node types.
    )Dict)NodeExecutorExecutionContext)iter_node_registrationsc            
       `    e Zd ZdZed	dededeee	f   fd       Z
e	 d	dededede	fd       Zy)
NodeExecutorFactoryz>Factory class that instantiates executors for every node type.Ncontext	subgraphsreturnc                     |xs i }i }t               j                         D ]  \  }}|j                  | |      ||<    |S )a"  Create executors for every registered node type.
        
        Args:
            context: Shared execution context
            subgraphs: Mapping of subgraph nodes (used by Subgraph executors)
            
        Returns:
            Mapping from node type to executor instance
        r
   )r   itemsbuild_executor)r	   r
   	executorsnameregistrations        J/Users/bowang/.openclaw/workspace/ChatDev/runtime/node/executor/factory.pycreate_executorsz$NodeExecutorFactory.create_executors   sM     O	-/	"9";"A"A"CD,*99'Y9WIdO #D    	node_typec                 r    |xs i }t               }| |vrt        d|        ||    j                  ||      S )a  Create an executor for the requested node type.
        
        Args:
            node_type: Registered node type name
            context: Shared execution context
            subgraphs: Mapping of subgraph nodes (used by Subgraph executors)
            
        Returns:
            Executor instance for the requested type
            
        Raises:
            ValueError: If the node type is not supported
        zUnsupported node type: r   )r   
ValueErrorr   )r   r	   r
   registrationss       r   create_executorz#NodeExecutorFactory.create_executor!   sK    & O	/1M)6ykBCCY'66w)6TTr   )N)__name__
__module____qualname____doc__staticmethodr   dictr   strr   r   r    r   r   r   r      s|    H"2 t tTWYeTeOf  "  UU!U U 
	U Ur   r   N)	r   typingr   runtime.node.executor.baser   r   runtime.node.registryr   r   r"   r   r   <module>r&      s!   
  E 9-U -Ur   