
    di                        d Z ddlZddlZddlZddlZ ej
                  ej                  dej                          ej                  d      Z	dej                  ddfdZdej                  ddfd	Zdej                  ddfd
Zdej                  ddfdZdej                  ddfdZdej                  ddfdZdej                  ddfdZddZedk(  r e        yy)u  
Gemini Command Centres — CLI Entry Point
========================================
Usage:
    python3 -m core.gemini_command_centres launch
    python3 -m core.gemini_command_centres status
    python3 -m core.gemini_command_centres dispatch "task text" [--target NAME]
    python3 -m core.gemini_command_centres stop
    python3 -m core.gemini_command_centres watchdog

    # Internal use by tmux sessions:
    python3 -m core.gemini_command_centres --daemon --name orchestrator

Author: Genesis Parallel Builder
Created: 2026-02-26
    Nz1%(asctime)s [%(levelname)s] %(name)s: %(message)s)levelformatstreamzgcc.mainargsreturnc                 "    ddl m}  |d       y)zLaunch all 5 command centres.r   )
launch_allTverboseN)$core.gemini_command_centres.launcherr	   )r   r	   s     =/mnt/e/genesis-system/core/gemini_command_centres/__main__.py_cmd_launchr   !   s    ?t    c                     ddl m}  |d      }t        d |j                         D              }t	        |      }t        d| d| d       y	)
z,Print health status for all command centres.r   )statusTr
   c              3   D   K   | ]  }|j                  d       sd  yw)healthy   N)get).0vs     r   	<genexpr>z_cmd_status.<locals>.<genexpr>,   s     By1A!Bs     z
[gcc] /z centres healthyN)r   r   sumvalueslenprint)r   r   resultsr   totals        r   _cmd_statusr    '   sG    ;T"GBW^^-BBGLE	HWIQug%5
67r   c                 j    ddl m}  || j                  | j                  d      }t	        d|        y)z'Add a task to a command centre's queue.r   )dispatchT)tasktargetr   z[gcc] task_id=N)r   r"   r#   r$   r   )r   r"   task_ids      r   _cmd_dispatchr&   1   s1    =YY{{G
 
N7)
$%r   c                 8    ddl m}  |d       t        d       y)zStop all command centres.r   )stop_allTr
   z"[gcc] All command centres stopped.N)r   r(   r   )r   r(   s     r   	_cmd_stopr)   <   s    =T	
./r   c                 4    ddl m} t        d        |        y)zStart the watchdog daemon.r   )run_watchdogz+[gcc] Starting watchdog (Ctrl+C to stop)...N)$core.gemini_command_centres.watchdogr+   r   )r   r+   s     r   _cmd_watchdogr-   C   s    A	
78Nr   c                 6    ddl m}  || j                         y)uG   Start a single daemon for the named centre (internal — used by tmux).r   )main)nameN)"core.gemini_command_centres.daemonr/   r0   )r   daemon_mains     r   _cmd_daemonr3   J   s    FTYYr   c                     ddl m}  || j                        }|-t        d| j                          t	        j
                  d       t        t        j                  |d             y)z"Fetch result for a completed task.r   )
get_resultNz"[gcc] No result found for task_id=r      )indent)r   r5   r%   r   sysexitjsondumps)r   r5   results      r   _cmd_resultr=   P   sJ    ?%F~24<<.AB	$**VA
&'r   c                     t        j                  dd      } | j                  dd      }|j                  dd	       |j                  d
d	       |j                  dd	      }|j	                  dd	       |j	                  ddg dd       |j                  dd	       |j                  dd	       |j                  dd	      }|j	                  dd	       t        j                  d      }|j	                  dd !       |j	                  d"t
        d#       dt        j                  v r|j                         \  }}t        |       y | j                         }t        t        t        t        t        t         d$}|j"                  %| j%                          t        j&                  d%       |j)                  |j"                        }	|	%| j%                          t        j&                  d&        |	|       y )'Nz&python3 -m core.gemini_command_centresu;   Gemini Command Centres — 5-agent persistent daemon system)progdescriptioncommandzsub-command)desthelplaunchzLaunch all 5 command centres)rC   r   z#Check health of all command centresr"   zSend task to a command centrer#   zTask prompt textz--targetorchestrator)rE   builder
researcherscoutthinkerz%Target centre (default: orchestrator))defaultchoicesrC   stopzStop all command centreswatchdogzStart the watchdog daemonr<   zFetch result for a taskr%   zTask ID returned by dispatchF)add_helpz--daemon
store_true)actionz--name)typerJ   )rD   r   r"   rL   rM   r<   r   r   )argparseArgumentParseradd_subparsers
add_parseradd_argumentstrr8   argvparse_known_argsr3   
parse_argsr   r    r&   r)   r-   r=   rA   
print_helpr9   r   )
parser
subparsers
p_dispatchp_resultp_daemonknown_r   	_DISPATCHhandlers
             r   r/   r/   Z   s   $$5QF &&IM&JJ ()GH ()NO &&z8W&XJF);<M4	   &'AB *+FG $$X4M$NH)*HI &&6H*\:(nE SXX,,.qED !!I ||mmDLL)GDMr   __main__)r   N)__doc__rR   r:   loggingr8   basicConfigINFOstdout	getLoggerlogger	Namespacer   r    r&   r)   r-   r3   r=   r/   __name__ r   r   <module>rp      s  "    
   
,,>:: 
		:	&h(( T 8h(( 8T 8&** &t &0H&& 04 0** t  h((  T  (h(( (T (@F zF r   