+
    ‚°ñjD  ã                  óž   € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIH	t	 Rt
RtRsRsRsR R ltR	 R
 ltR R ltR R ltR R ltR tR tR# )ag  Loads the optional comfy-agent package and fronts it to ComfyUI.

ComfyUI owns a thin v1 contract and nothing more: it discovers the
``comfyui.agent`` "v1" entry point, creates the host, hands it the live aiohttp
app once (``register(app)``) so the host mounts its own routes on ComfyUI's
origin, starts it after the server is listening, stops it on shutdown, and
publishes the host's state as the ``agent`` feature flag plus an ``agent_status``
websocket message on every change. Everything else -- the agent process, its
storage, restarts, the proxy and the loopback/same-origin trust boundary --
lives in the package.

A v1 host must provide:
    register(app) -> None
    start(*, comfy_url: str, comfy_path: str, logger, on_change=None) -> None
    stop(timeout: float = ...) -> None
    status() -> {"state": "starting"|"ready"|"failed", "reason": str | None, ...}
)ÚannotationsN)Úfeature_flagszcomfyui.agentÚv1Fc               ó   € V ^8„  d   QhRR/# ©é   ÚreturnÚNone© )Úformats   "Ú2C:\Ai_Coding\apps\studio\ComfyUI\app\agent_host.pyÚ__annotate__r   '   s   € ÷ rñ r dñ ró    c               ó†   € \         P                  ! R P                  RV  2.R VP                  4        4       O4      4       R# )Ú z[agent-event] c              3  ó@   "  € T F  w  rVf   K  V RV 2x € K  	  R # 5i)NÚ=r
   )Ú.0ÚkÚvs   &  r   Ú	<genexpr>Úemit_event.<locals>.<genexpr>(   s!   é € Ð6nÉnÁdÀaÐ`a´z¸!¸¸A¸a¸SµzËnùs   ‚�N)ÚloggingÚinfoÚjoinÚitems)ÚeventÚfieldss   ",r   Ú
emit_eventr   '   s2   € Ü‡L‚L�—‘˜^¨E¨7Ð3ÐoÑ6nÈfÏlÉlÌnÓ6nÐoÓpÖqr   c               ó   € V ^8„  d   QhRR/# )r   r   Úboolr
   )r   s   "r   r   r   +   s   € ÷ !ñ !ˆdñ !r   c            	     óL  a€  \         P                  P                  \        R7       U u/ uF  q P                  V bK  	  pp \
        V9  dï   \        P                  P                  \        P                  P                  \        P                  P                  \        P                  4      4      R4      pRV R2pV'       dB   \        P                  ! R\        V4       R\
         RV R24       R	R
RR/s\#        RRR7       M+\        P                  ! RV R24       R	R
RR/s\#        R4       \%        4        R# V\
        ,          P'                  4       ! 4       o\(        ;QJ d    V3R lR 4       F  '       d   K   RM	  RM! V3R lR 4       4      '       g*   \+        R\
         R\-        S4      P.                   R24      hSs\%        4        \         RJ # u up i   \2        \4        3 d8    \        P6                  ! R4       R	R
RR/s\#        RRR7       \%        4         R# i ; i)z~Find and create the agent host. Reports why when it can't; nothing about
the installed package can stop ComfyUI from starting.)Úgroupzagent_requirements.txtzpip install -U -r "Ú"z1The installed comfy-agent offers agent protocols z; this ComfyUI needs z. Update it with `z` to use the agent.ÚstateÚfailedÚreasonÚoutdatedÚagent_error©r&   zu`--enable-agent` was passed but the comfy-agent package is not installed, so the agent is disabled. Install it with `z`.Úpackage_missingFc              3  óP   <"  € T F  p\        \        SVR 4      4      x € K  	  R # 5i)N)ÚcallableÚgetattr)r   ÚnameÚhosts   & €r   r   Úload.<locals>.<genexpr>B   s$   øé € ÐkÑCj¸4”8œG D¨$°Ó5×6Ð6ÓCjùs   ƒ#&Tzthe z entry point returned z, not an agent hostz/Could not load the local agent; it is disabled.ÚunknownN)ÚstartÚstopÚstatusÚregister)Ú	importlibÚmetadataÚentry_pointsÚENTRY_POINT_GROUPr.   ÚPROTOCOLÚosÚpathr   ÚdirnameÚabspathÚfolder_pathsÚ__file__r   ÚwarningÚsortedÚ_failurer   Ú_publish_flagÚloadÚallÚ	TypeErrorÚtypeÚ__name__Ú_hostÚ	ExceptionÚ
SystemExitÚ	exception)Úepr8   ÚreqÚinstallr/   s       @r   rE   rE   +   s   ø€ ðÜ.7×.@Ñ.@×.MÑ.MÔTeÐ.MÔ.fÓgÑ.f¨Ÿ™ šÑ.fˆÐgÜ˜<Ô'ô —'‘'—,‘,œrŸw™wŸ™¬r¯w©w¯©¼|×?TÑ?TÓ/UÓVÐXpÓqˆCØ+¨C¨5°Ð2ˆGßÜ—’Ð"SÔTZÐ[gÓThÐSiÐi~ô  @Hð  Ið  I[ð  \cð  [dð  dwð  !xô  yØ# X¨x¸ÐD�Ü˜=°Ö<ä—’ð  #Xð  Y`ð  Xað  acð  !dô  eØ# X¨xÐ9JÐK�ÜÐ,Ô-ÜŒOÙØœHÕ%×*Ñ*Ô,Ó.ˆß‹sÔkÑCjÓk�s�sŠsÔkÑCjÓk×kÒkÜ˜d¤8 *Ð,BÄ4ÈÃ:×CVÑCVÐBWÐWjÐkÓlÐlØˆô „OÜ�tÐÐùò9 høô* ”zÐ"ô Ü×ÒÐKÔLØ˜X x°Ð;ˆÜ�=¨Õ3ÜŒÚðúsB   ƒ&G ©G¾BG ÃA6G Ä9*G Å$G Å;G Æ+G ÇG ÇAH#È"H#c               ó   € V ^8„  d   QhRR/# r   r
   )r   s   "r   r   r   O   s   € ÷ ñ �Tñ r   c                óì   € \         e	   \        e   R#  \         P                  V 4       R#   \        \        3 d8    \
        P                  ! R4       RRRR/s\        RRR7       \        4         R# i ; i)	a4  Mount the agent's own API routes onto ComfyUI's aiohttp ``app``.

ComfyUI calls this once while it registers its routes (before the router
freezes); the host mounts /api/agent and /api/workflows onto the live app.
No-op when the package did not load; a failure here disables the agent, not
ComfyUI's startup.NzAThe local agent's routes could not be registered; it is disabled.r$   r%   r&   r1   r(   r)   )	rJ   rC   r5   rK   rL   r   rM   r   rD   )Úapps   &r   r5   r5   O   sb   € ô ‚}œÒ,ÙðÜ�‰�sÖøÜ”zÐ"ô Ü×ÒÐ]Ô^Ø˜X x°Ð;ˆÜ�=¨Õ3Ü�ð	ús   ”+ «AA3Á2A3c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   ÚschemeÚstrÚaddressÚportÚintr   r	   r
   )r   s   "r   r   r   b   s(   € ÷ %ñ %˜#ð %¨ð %°3ð %¸4ñ %r   c                ó  a aaa€ \         e	   \        e   R# VR9   d   RM
VR8X  d   RMTpRV9   d   V RV RV 2M	V RV RV 2oRoVV 3R	 loVV3R
 lpS P                  e   S P                  P                  RV4       R# V! 4        R# )zEStart the loaded host once the server is listening. Main thread only.Nz	127.0.0.1z::z::1Ú:z://[z]:z://c                 óV   <€ \        4       p V S8w  d   V oSP                  R V 4       R# R# )Úagent_statusN)rD   Ú	send_sync)ÚflagÚ	last_sentÚservers    €€r   Ú	on_changeÚstart.<locals>.on_changen   s.   ø€ ô ‹ˆØ�9ÔØˆIØ×Ñ˜^¨TÖ2ñ r   c                 ó‚  <€  \         P                  S \        P                  P	                  \        P                  P                  \        P                  4      4      \        P                  ! 4       SR 7       R#   \        \        3 d5    \        P                  ! R4       RRRR/s\        RRR7       S! 4         R# i ; i)	)Ú	comfy_urlÚ
comfy_pathÚloggerrb   z%The local agent could not be started.r$   r%   r&   Úspawn_failedr(   r)   N)rJ   r2   r;   r<   r=   r>   r?   r@   r   Ú	getLoggerrK   rL   rM   rC   r   )re   rb   s   €€r   ÚrunÚstart.<locals>.runy   s›   ø€ ð	Ü�K‰K )¼¿¹¿¹ÌÏÉÏÉÔXd×XmÑXmÓHnÓ8oÔx÷  yJò  yJó  yLð  XaˆKö  bøÜœ:Ð&ô 	Ü×ÒÐEÔFØ ¨8°^ÐDˆHÜ�}¨^Õ<Ù�Kð		ús   ƒA4A9 Á9AB>Â=B>)Ú z0.0.0.0)rJ   rC   ÚloopÚrun_in_executor)	ra   rU   rW   rX   r/   rj   re   r`   rb   s	   f&&&  @@@r   r2   r2   b   s�   û€ ô
 ‚}œÒ,ÙØ! _Ô4‰;À7ÈdÄ?¹%ÐX_€DØ14¸´�6�(˜$˜t˜f B t fÑ-ÀVÀHÈCÐPTÈvÐUVÐW[ÐV\ÐB]€Ià€Iö	3öð ‡{�{ÒØ�‰×#Ñ# D¨#Ö.áŽr   c               ó   € V ^8„  d   QhRR/# r   r
   )r   s   "r   r   r   Š   s   € ÷ Gñ Gˆdñ Gr   c                 ó    € \         e    \         P                  4        R # R #   \        \        3 d    \        P
                  ! R4        R # i ; i)Nz%The local agent could not be stopped.)rJ   r3   rK   rL   r   rM   r
   r   r   r3   r3   Š   sC   € ÜÒð	GÜ�J‰JŽLñ øô œ:Ð&ô 	GÜ×ÒÐE×Fð	Gús   Š" ¢'AÁAc                 óŒ   € \        4       p V f#   \        P                  P                  RR4       V # V \        P                  R&   V # )zÔMirror the current agent flag into the shared server feature-flag dict so
new connections read it via ``get_server_features()``; omitted when there is
no value. Returns the flag so callers can detect transitions.NÚagent)Úfeature_flagr   ÚSERVER_FEATURE_FLAGSÚpop)r_   s    r   rD   rD   ’   sD   € ô ‹>€DØ‚|Ü×*Ñ*×.Ñ.¨w¸Ô=ð €Kð 7;Œ×*Ñ*¨7Ñ3Ø€Kr   c                 ó¤  € \         f	   \        f   \         #  \        P                  4       p RV R,          /pV P                  R4      '       d   V R,          VR&   V#   \         d3    \
        P                  ! R4       RRRR/s \        RRR7       \         u # \         d.    \        '       g   Rs	\
        P                  ! R	4       RRRR/u # i ; i)
zKThe `agent` feature flag: the host's state, and its reason when it has one.r$   r&   z;The local agent's status could not be read; it is disabled.r%   r1   r(   r)   Tz+The local agent's status could not be read.)
rC   rJ   r4   ÚgetrL   r   rM   r   rK   Ú_status_logged)r4   r_   s     r   rs   rs   ž   s¾   € ô Òœuš}Üˆð8Ü—‘“ˆØ˜ �Ð)ˆØ�:‰:�h×ÒØ# HÕ-ˆD�‰NØˆøÜô Ü×ÒÐWÔXØ˜X x°Ð;ˆÜ�=¨Õ3ÜŠÜô 8ß‹~Ø!ˆNÜ×ÒÐKÔLØ˜ 8¨YÐ7Ò7ð	8ús)   ˜5A ÁA Á:CÂCÂ!CÂ.CÃC)Ú__doc__Ú
__future__r   Úimportlib.metadatar6   r   r;   r?   Ú	comfy_apir   r9   r:   rJ   rC   rx   r   rE   r5   r2   r3   rD   rs   r
   r   r   Ú<module>r}      sa   ðñõ$ #ã Û Û 	ã Ý #à#Ð Ø€à€ð €à€õrõ!õHõ&%õPGò	ô8r   