+
    .pÐjï§  ã                  óŽ  € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIHt R t	RRRR	R
RRRR. R’ORRRRRRRRR/RRRRRRRR/RRRRRRRRRR/RRRR RRRR!/RR"RR#RRRR$/./RR%RR&R
R'RR(/RR)RR*R
RRR+/RR,RR-R
RRR.R. R“ORRR.RR/RRRR0/RR1RR2RRRR3/RR4RR5RRRRRR6/RR7RR8RRRR9/./RR:RR;R
R<RR=R. R”ORRR=RR>RRRR?/RR@RRARRRRB/RRCRRDRRRRRRE/RRFRRGRRRRH/./RRIRRJR
RKRRLR. R•ORRRLRRMRRRRN/RRORRPRRRRQ/./.t
RR RS ltRT RU ltRV RW ltRX RY ltRZ R[ ltR\ R] ltR^ R_ ltR` Ra ltRR–RR—/tRb Rc ltRd Re ltRf Rg ltRh Ri ltRj Rk lt^ RlRm]Rn3^RoRp]Rq3^RrRm]Rs3/tR˜tRt tRu tRv Rw ltRx tRy Rz ltR{ R| lt R} R~ lt!RRR€R/R� R‚ llt"R™t#RƒRƒR„R„RR…/t$R†RšR‡R›RˆRœ/t%R‰ RŠ lt&R‹ RŒ lt'R� RŽ lt(R� R� lt)R‘ t*R# )�aW  Gateway platform setup wizard (hermes gateway setup): platform registry/status table, per-platform setup prompts, service offer.

Extracted from ``hermes_cli/gateway.py``. Bodies read facade helpers through ``_gw()`` (late
binding on ``hermes_cli.gateway``) so the seams tests and callers patch on the facade keep
intercepting the moved code.
)ÚannotationsN)Úprint_success)Úprint_warningc                 ó   € ^ RI Hp  V # )é    ©Úgateway)Ú
hermes_clir   r   s    Ú./opt/hermes/hermes_cli/gateway_setup_wizard.pyÚ_gwr      s
   € Ý"Ø€Nó    ÚkeyÚ
mattermostÚlabelÚ
MattermostÚemojiu   ðŸ’¬Ú	token_varÚMATTERMOST_TOKENÚsetup_instructionsÚvarsÚnameÚMATTERMOST_URLÚpromptz(Server URL (e.g. https://mm.example.com)ÚpasswordFÚhelpz@Your Mattermost server URL. Works with any self-hosted instance.z	Bot tokenTz&Paste the bot token from step 2 above.ÚMATTERMOST_ALLOWED_USERSz"Allowed user IDs (comma-separated)Úis_allowlistz*Your Mattermost user ID from step 4 above.ÚMATTERMOST_HOME_CHANNELzVHome channel ID (for cron/notification delivery, or empty to set later with /set-home)z@Channel ID where Hermes delivers cron results and notifications.ÚMATTERMOST_REPLY_MODEuT   Reply mode â€” 'off' for flat messages, 'thread' for threaded replies (default: off)zFoff = flat channel messages, thread = replies nest under your message.ÚsignalÚSignalu   ðŸ“¡ÚSIGNAL_HTTP_URLÚweixinzWeixin / WeChatÚWEIXIN_ACCOUNT_IDÚbluebubbleszBlueBubbles (iMessage)ÚBLUEBUBBLES_SERVER_URLz6BlueBubbles server URL (e.g. http://192.168.1.10:1234)u.   The URL shown in BlueBubbles Settings â†’ API.ÚBLUEBUBBLES_PASSWORDzBlueBubbles server passwordu3   The password shown in BlueBubbles Settings â†’ API.ÚBLUEBUBBLES_ALLOWED_USERSz]Pre-authorized phone numbers or iMessage IDs (comma-separated, or leave empty for DM pairing)u_   Optional â€” pre-authorize specific users. Leave empty to use DM pairing instead (recommended).ÚBLUEBUBBLES_HOME_CHANNELzKHome channel (phone number or iMessage ID for cron/notifications, or empty)zFPhone number or Apple ID to deliver cron results and notifications to.ÚqqbotúQQ Botu   ðŸ�§Ú	QQ_APP_IDzQQ Bot App IDz!Your QQ Bot App ID from q.qq.com.ÚQQ_CLIENT_SECRETzQQ Bot App Secretz%Your QQ Bot App Secret from q.qq.com.ÚQQ_ALLOWED_USERSzCAllowed user OpenIDs (comma-separated, leave empty for open access)u9   Optional â€” restrict DM access to specific user OpenIDs.ÚQQBOT_HOME_CHANNELz<Home channel (user/group OpenID for cron delivery, or empty)z4OpenID to deliver cron results and notifications to.ÚyuanbaoÚYuanbaou   ðŸ’ŽÚYUANBAO_APP_IDzApp IDz0The App ID from your Yuanbao IM Bot credentials.ÚYUANBAO_APP_SECRETz
App Secretz@The App Secret (used for HMAC signing) from your Yuanbao IM Bot.c               ó   € V ^8„  d   QhRR/# )é   Úreturnz
list[dict]© )Úformats   "r
   Ú__annotate__r8   |   s   € ÷ ñ ˜
ñ r   c                 ó*  €  ^ RI Hp  V ! 4        \        P                  R8H  p\        4       P                   Uu. uF-  q2'       d   VP                  R4      R8X  d   K"  \        V4      NK/  	  ppV Uu/ uF  q3R,          VbK  	  pp ^ RIHp TP                  4        F™  pTP                  T9   g   T'       d   TP                  R8X  d   K/  TP                  RTP                  RTP                   R	TP"                  R
TP$                  '       d   TP$                  ^ ,          MRRTP&                  RT/4       K›  	  T#   \         d0   p\        4       P                  P                  RT4        Rp?ELaRp?ii ; iu upi u upi   \         d    Tu # i ; i)aY  Built-in ``_PLATFORMS`` plus registry plugin platforms (same dict shape, source in
``_registry_entry``). Plugins are discovered here (idempotent) so the setup menu works without a
running gateway; user-installed ones still need ``plugins.enabled`` (untrusted code). Matrix is
hidden on Windows: python-olm has no wheel or native build (use WSL).)Údiscover_pluginsz7plugin discovery failed during platform enumeration: %sNÚwin32r   Úmatrix)Úplatform_registryr   r   r   Ú Úinstall_hintÚ_registry_entry)Úhermes_cli.pluginsr:   Ú	Exceptionr   ÚloggerÚdebugÚsysÚplatformÚ
_PLATFORMSÚgetÚdictÚgateway.platform_registryr=   Úall_entriesr   Úappendr   r   Úrequired_envr?   )r:   ÚeÚhide_matrixÚpÚ	platformsÚby_keyr=   Úentrys           r
   Ú_all_platformsrT   |   sZ  € ð
YÝ7ÙÔô —,‘, 'Ñ)€KÜ"%£%×"2Ò"2ÓeÑ"2˜Q¾;È1Ï5É5ÐQVË<Ð[cÑKc””�a–Ñ"2€IÐeÙ#,Ó-¡9˜a��h˜Šk¡9€FÐ-ðÝ?ð #×.Ñ.Ö0ˆØ�:‰:˜Ô§K°E·J±JÀ(Ô4JÙØ×ÑØ�5—:‘:˜w¨¯©°W¸e¿k¹kØ°%×2D×2DÐ2D˜×+Ñ+¨AÖ.È"Ø˜E×.Ñ.Ð0AÀ5ð
ö 	ñ 1ð Ðøô) ô YÜ‹�‰×ÑÐTÐVW×XÒXûðYüò fùÚ-øô ô ØÒðús:   ‚D; ¸E8ÁE8Á1E=ÂF Ä;E5Å$E0Å0E5ÆFÆFc               ó    € V ^8„  d   QhRRRR/# )r4   rF   rI   r5   Ústrr6   )r7   s   "r
   r8   r8   ›   s   € ÷ Hñ H˜tð H¨ñ Hr   c                ó\  € V P                  R4      pVe^    VP                  e)   ^ RIHp \	        VP                  V! RR7      4      4      pM\	        VP                  4       4      p V'       d   R# R# V P                  RR	4      pV'       g   R# R
RRR/P                  V P                  R4      4      pWE3 Uu. uF.  qf'       g   K  \	        \        4       P                  V4      4      NK0  	  pp\        V4      '       d   R# \        V4      '       d   R# R#   \         d    Rp L¾i ; iu upi )zTPlain-text status string; uncolored because ANSI codes break curses menu width math.r@   )ÚPlatformConfigT)ÚenabledFÚ
configuredúnot configuredr   r>   r   ÚSIGNAL_ACCOUNTr"   ÚWEIXIN_TOKENr   zpartially configured)rH   Úis_connectedÚgateway.configrX   ÚboolÚcheck_fnrB   r   Úget_env_valueÚallÚany)rF   rS   rX   rZ   r   Ú
second_varÚvÚpresents   &       r
   Ú_platform_statusrh   ›   s  € à�L‰LÐ*Ó+€EØÒð	Ø×!Ñ!Ò-Ý9Ü! %×"4Ñ"4±^ÈDÔ5QÓ"RÓS‘
ä! %§.¡.Ó"2Ó3‘
÷  *ˆ|Ð?Ð/?Ð?à—‘˜[¨"Ó-€IßÙàÐ,¨h¸ÐG×KÑKÈHÏLÉLÐY^ÓL_Ó`€JØ6?Ñ5LÓRÑ5L°ÓPQÔ+Œt”C“E×'Ñ'¨Ó*Ö+Ñ5L€GÐRÜ
ˆ7‡|‚|ÙÜ%(¨§\¢\Ð!ÐGÐ7GÐGøô ô 	ØŠJð	üò Ss#   —5D ÁD Â8	D)Ã&D)ÄD&Ä%D&c               ó$   € V ^8„  d   QhRRRRRR/# )r4   Úplatform_keyrV   Úbehaviorr5   ÚNoner6   )r7   s   "r
   r8   r8   ¶   s'   € ÷ dñ d¸ð dÈð dÐPTñ dr   c                ó@   € \        4       P                  V RVRR7       R# )zBPersist a platform-specific unauthorized-DM policy in config.yaml.Úunauthorized_dm_behaviorT)ÚrawN)r   Úwrite_platform_config_field)rj   rk   s   &&r
   Ú&_set_platform_unauthorized_dm_behaviorrq   ¶   s   € äƒE×%Ñ% lÐ4NÐPXÐ^bÐ%Öcr   c               ó    € V ^8„  d   QhRRRR/# )r4   ÚtitlerV   r5   rl   r6   )r7   s   "r
   r8   r8   »   s   € ÷ Rñ R˜sð R tñ Rr   c                ó    € \        4        \        \        4       P                  R V  R2\        4       P                  P                  4      4       R# )u     â”€â”€â”€ u    Setup â”€â”€â”€N)Úprintr   ÚcolorÚColorsÚCYAN)rs   s   &r
   Ú_print_setup_headerry   »   s2   € Ü	„GÜ	Œ#‹%�+‰+˜ U GÐ+;Ð<¼c»e¿l¹l×>OÑ>OÓ
PÖQr   c               ó$   € V ^8„  d   QhRRRRRR/# )r4   r   rV   Úenv_varsr5   r`   r6   )r7   s   "r
   r8   r8   À   s!   € ÷ ñ  ð °ð ¸ñ r   c                ó  € \         ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       dE   \        4        \        4       P                  V  R24       \        4       P	                  RV  R2R4      # R# )zXFalse when ``label`` is already configured (all ``env_vars`` set) and the user declines.c              3  óT   "  € T F  p\        4       P                  V4      x € K   	  R # 5i©N)r   rb   )Ú.0rf   s   & r
   Ú	<genexpr>Ú'_confirm_reconfigure.<locals>.<genexpr>Â   s    é € Ð
4©8 aŒ3‹5×Ñ˜q×!Ð!«8ùs   ‚&(FTz is already configured.z  Reconfigure Ú?)rc   ru   r   r   Úprompt_yes_no)r   r{   s   &*r
   Ú_confirm_reconfigurer„   À   sa   € ç
ƒsÑ
4©8Ó
4‡s‡s‚sÑ
4©8Ó
4×4Ò4ÜŒÜ‹×Ñ˜u˜gÐ%<Ð=Ô>Ü‹u×"Ñ" ^°E°7¸!Ð#<¸eÓDÐDÙr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r4   Úhome_varrV   Úuser_idÚwhatr5   rl   r6   )r7   s   "r
   r8   r8   É   s.   € ÷ @ñ @ #ð @°ð @¸3ð @À4ñ @r   c                óÂ   € \        4       P                  RV RV R2R4      '       d8   \        4       P                  W4       \        4       P                  RV 24       R# R# )zLOffer to persist ``user_id`` as ``home_var`` (e.g. "your Telegram user ID").z  Use z (z) as the home channel?Tú  Home channel set to N)r   rƒ   Úsave_env_valuer   )r†   r‡   rˆ   s   &&&r
   Ú_offer_home_channelrŒ   É   sU   € ä
ƒu×Ñ˜V D 6¨¨G¨9Ð4JÐKÈT×RÒRÜ‹×Ñ˜XÔ/Ü‹×ÑÐ4°W°IÐ>Ö?ñ Sr   c               ó    € V ^8„  d   QhRRRR/# )r4   ÚvaluesrV   r5   rl   r6   )r7   s   "r
   r8   r8   Ð   s   € ÷ *ñ *˜sð * tñ *r   c                 ój   € V P                  4        F  w  r\        4       P                  W4       K   	  R # r~   )Úitemsr   r‹   )rŽ   r   Úvalues   ,  r
   Ú_save_env_valuesr’   Ð   s$   € Ø—|‘|–~‰ˆÜ‹×Ñ˜TÖ)ó &r   c               ó$   € V ^8„  d   QhRRRRRR/# )r4   Úprompt_textrV   Údefaultr5   r6   )r7   s   "r
   r8   r8   Õ   s&   € ÷ Oñ O˜Sð O¨3ð O°3ñ Or   c                óX   € \        4       P                  WRR7      P                  RR4      # )z3Comma-separated ID prompt with whitespace stripped.F©r   Ú r>   )r   r   Úreplace)r”   r•   s   &&r
   Ú_prompt_csvrš   Õ   s$   € ä‹5�<‰<˜°uˆ<Ó=×EÑEÀcÈ2ÓNÐNr   c               ó    € V ^8„  d   QhRRRR/# )r4   rj   rV   r5   rl   r6   )r7   s   "r
   r8   r8   é   s   € ÷ Vñ V¨cð V°dñ Vr   c                ór  € V R8H  p\        4        \        V,          vr#\        4       P                  RW24      pV^ 8X  d@   \        4       P	                  V'       d   RMRR4       \        4       P                  R4       R# V^8X  dI   V'       d   \        RR4       \        4       P                  R4       \        4       P                  R	4       R# V^8X  d(   \        V R
4       \        4       P                  R4       R# V'       d   \        4       P                  R4       R# \        4       P                  R4       R# )u`   No allowlist was given â€” ask open access vs DM pairing vs decline vs skip/silent, and persist.Úemailz+  How should unauthorized users be handled?ÚEMAIL_ALLOW_ALL_USERSÚGATEWAY_ALLOW_ALL_USERSÚtrueu2     Open access enabled â€” anyone can use your bot!ÚpairuB     DM pairing mode â€” users will receive a code to request access.z8  Approve with: hermes pairing approve <platform> <code>Údeclinez[  Unknown senders get one polite decline, then silence (unauthorized_dm_behavior: decline).z(  Unknown email senders will be ignored.u9     Skipped â€” configure later with 'hermes gateway setup'N)	ru   Ú_UNAUTHORIZED_ACCESS_CHOICESr   Úprompt_choicer‹   r   rq   r   Ú
print_info)rj   Úis_emailÚdefault_idxÚaccess_choicesÚ
access_idxs   &    r
   Ú_prompt_unauthorized_accessrª   é   sâ   € à˜wÑ&€HÜ	„GÜ#?ÀÕ#IÐ €KÜ“×$Ñ$Ð%RÐTbÓp€JØ�Q„Ü‹×Ñ¿Ñ4ÐF_ÐagÔhÜ‹×ÑÐPÖQØ	�qŒßÜ2°7¸FÔCÜ‹×ÑÐ`ÔaÜ‹×ÑÐSÖTØ	�qŒÜ.¨|¸YÔGÜ‹×ÑÐyÖzß	Ü‹×ÑÐFÖGä‹×ÑÐTÖUr   c               ó    € V ^8„  d   QhRRRR/# )r4   r   rV   r5   ztuple[bool, object]r6   )r7   s   "r
   r8   r8      s   € ÷ ñ  Cð Ð,?ñ r   c                ó„  € \        4        \        4       P                  RRR4       \        4       P                  RRR7      P	                  4       R8w  d   R#  ^ RIHpHp T! 4       pT'       dc   T! TP                  4      '       dK   \        4       P                  YP                  4       \        4       P                  R	4       R
TP                  3# T'       d   \        4       P                  R4       \        4        \        4       P                  R4       R#   \         d    \        4       P                  R4       Ru # i ; i)zDOffer the managed-bot QR flow. Returns (token_saved, owner_user_id).z>  Telegram can be configured automatically with a managed bot:u:     [1] Automatic (scan QR â†’ confirm in Telegram â†’ done)z  [2] Manual BotFather tokenz  Choice [1/2]Ú1)r•   )Úauto_setup_telegram_bot_resultÚis_valid_telegram_bot_tokenz1  Automatic setup is unavailable in this install.z  Saved TELEGRAM_BOT_TOKENTz5  Automatic setup returned an invalid Telegram token.z!  Falling back to manual setup...)FN)ru   r   Ú_print_info_linesr   ÚstripÚhermes_cli.telegram_managed_botr®   r¯   ÚImportErrorr   Útokenr‹   r   Úowner_user_idr¥   )r   r®   r¯   Úresults   &   r
   Ú_telegram_auto_setupr·      sý   € ä	„GÜƒE×ÑØHØDÐFdôô ƒu‡|�|Ð$¨c€|Ó2×8Ñ8Ó:¸cÔAØÐð÷	
ñ ,Ó-€FßÑ-¨f¯l©l×;Ò;Ü‹×Ñ˜Y¯©Ô5Ü‹×ÑÐ8Ô9Ø�V×)Ñ)Ð)Ð)ßÜ‹×ÑÐSÔTÜ	„GÜƒE×ÑÐ8Ô9ØÐøô ô Ü‹×ÑÐOÔPØÒðús   ÁD Ä&D?Ä>D?c               ó    € V ^8„  d   QhRRRR/# )r4   ÚcleanedrV   r5   r6   )r7   s   "r
   r8   r8     s   € ÷ ñ  ð ¨ñ r   c                ó¦  € . pV P                  R4       Fª  pVP                  4       pVP                  R4      '       d8   VP                  R4      '       d!   VP	                  R4      P                  R4      pVP                  4       P                  R4      '       d
   VR,          pV'       g   K™  VP                  V4       K¬  	  RP                  V4      # )zVStrip common Discord prefixes (user:123, <@123>, <@!123>) from a comma-separated list.Ú,z<@Ú>z<@!zuser::é   NN)	Úsplitr±   Ú
startswithÚendswithÚlstripÚrstripÚlowerrL   Újoin)r¹   ÚpartsÚuids   &  r
   Ú_clean_discord_idsrÇ     sœ   € à€EØ�}‰}˜SÖ!ˆØ�i‰i‹kˆØ�>‰>˜$×Ò C§L¡L°×$5Ò$5Ø—*‘*˜UÓ#×*Ñ*¨3Ó/ˆCØ�9‰9‹;×!Ñ! '×*Ò*Ø�b•'ˆCß‰3Ø�L‰L˜Öñ "ð �8‰8�E‹?Ðr   c               ó$   € V ^8„  d   QhRRRRRR/# )r4   ÚvarrI   rj   rV   r5   ú
str | Noner6   )r7   s   "r
   r8   r8   *  s!   € ÷ ñ ˜tð °3ð Èzñ r   c                ó¢  € RV R,          9   Ed   V'       dþ   \        V4      p\        4       P                  RV 24       \        4       P                  RR4      '       d·   \        4       P	                  RRR7      pV.pVP                  R	R
4      P                  R4       F&  pV'       g   K  We9  g   K  VP                  V4       K(  	  RP                  V4      p\        4       P                  V R,          V4       \        4       P                  R4       V# \        4       P                  RRR4       \        4       P	                  RV R,           2RR7      pV'       g   \        V4       R# VP                  R	R
4      pRV R,          9   d   \        V4      p\        4       P                  V R,          V4       \        4       P                  R4       V# )zYAllowlist prompt for one var; returns the saved value or None (open-access prompt shown).ÚTELEGRAMr   z"  Detected your Telegram user ID: z-  Allow this Telegram account to use the bot?Tz9  Additional allowed user IDs (comma-separated, optional)Fr—   r˜   r>   r»   u7     Saved â€” only these users can interact with the bot.ú7  The gateway DENIES all users by default for security.z7  Enter user IDs to create an allowlist, or leave emptyz-  and you'll be asked about open access next.ú  r   NÚDISCORD)rV   r   r   rƒ   r   r™   r¾   rL   rÄ   r‹   r°   rª   rÇ   )	rÉ   rj   Úauto_owner_user_idÚdetected_idÚextraÚidsrÆ   r¹   r‘   s	   &&&      r
   Ú_prompt_allowlist_varrÔ   *  sq  € à�S˜•[Õ ×%7ÜÐ,Ó-ˆÜ‹×ÑÐ@ÀÀÐNÔOÜ‹5×ÑÐNÐPT×UÒUÜ“E—L‘LÐ!\Ðgl�LÓmˆEØ�-ˆCØ—}‘} S¨"Ó-×3Ñ3°CÖ8�ß‘3˜3ž>Ø—J‘J˜s–Oñ 9ð —h‘h˜s“mˆGÜ‹E× Ñ   V¥¨gÔ6Ü‹E×ÑÐ YÔZØˆNäƒE×ÑØAØAØ7ôô
 ‹E�L‰L˜2˜c (�m˜_Ð-¸ˆLÓ>€EßÜ# LÔ1ÙØ�m‰m˜C Ó$€GØ�C˜•KÔÜ$ WÓ-ˆÜƒE×Ñ˜˜V� gÔ.ÜƒE×ÑÐQÔRØ€Nr   c               ó   € V ^8„  d   QhRR/# )r4   rF   rI   r6   )r7   s   "r
   r8   r8   K  s   € ÷ >8ñ >8 tñ >8r   c                óà  € ^ RI Hp V R,          V R,          V R,          rCp\        V RV 24       V P                  R4      pV'       d*   \	        4        \        4       P                  ! R V 4       !   \        W44      '       g   R# R	RrvV P                  R
4      R8X  d   \        V4      w  rgRpV R,           U	u. uFA  p	V	R,          V8X  g/   V	P                  R4      '       g   V! V	R,          4      '       d   K?  V	NKC  	  p
p	V
 EF¹  p\	        4        \        4       P                  RVR,           24       \        4       P                  VR,          4      pV'       d+   VR,          V8w  d   \        4       P                  RV 24       V'       d*   VR,          V8X  d   \        4       P                  R4       K´  VP                  R4      '       d$   \        W°P                  R
4      V4      pVe   TpKî  \        4       P                  RVR,           2VP                  RR	4      R7      pV'       dH   \        4       P                  VR,          V4       \        4       P                  RVR,           24       EKr  VR,          V8X  d!   \        4       P                  RV R24        R# \        4       P                  R4       EK¼  	  VP!                  4        R2p\        4       P                  V4      pV'       dK   V'       gC   VR8X  d<   VP#                  R4      ^ ,          P%                  4       pV'       d   \'        VVR4       \	        4        \        4       P                  V RV R24       R# u up	i )z2Interactive setup for Telegram, Discord, or Slack.)Úis_setup_hidden_envr   r   r   r˜   r   c              3  ó,   "  € T F
  pR V 2x € K  	  R# 5i)rÎ   Nr6   )r   Úlines   & r
   r€   Ú+_setup_standard_platform.<locals>.<genexpr>T  s   é € Ð!G¹,°$ B t f¥+»,ùs   ‚NFr   Útelegramr   r   r   rÎ   r   z  Current: z!  Token saved by automatic setup.r   r   r—   z  Saved u     Skipped â€” z won't work without this.z  Skipped (can configure later)Ú_HOME_CHANNELÚTelegramr»   zyour user IDz configured!)Úhermes_cli.setup_hidden_envr×   ry   rH   ru   r   r°   r„   r·   r¥   rb   rÔ   r   r‹   r   r   Úupperr¾   r±   rŒ   )rF   Ú_is_setup_hidden_envr   r   r   ÚinstructionsÚauto_token_savedrÐ   Úallowed_val_setrf   Ú
setup_varsrÉ   ÚexistingÚsavedr‘   r†   Úhome_valÚfirst_ids   &                 r
   Ú_setup_standard_platformré   K  sÇ  € åWØ& wÕ/°¸'Õ1BÀHÈ[ÕDY�)€EÜ˜5˜'  5 'Ð*Ô+à—<‘<Ð 4Ó5€LßÜŒÜ‹×ÒÑ!G¹,Ó!GÒHä ×1Ò1Ùà+0°$Ð(Ø‡|�|�EÓ˜jÔ(Ü/CÀIÓ/NÑ,Ðà€Oð ˜FÖ#óÙ#ˆaØˆV�9˜	Ô! Q§U¡U¨>×%:Ò%:ÑBVÐWXÐY_ÕW`×Ba÷ 	
ˆÑ#ð ð ô
 ˆÜŒÜ‹×Ñ˜2˜c &�k˜]Ð+Ô,Ü“5×&Ñ& s¨6¥{Ó3ˆß˜˜F� yÔ0Ü‹E×Ñ˜{¨8¨*Ð5Ô6ç  F¥¨yÔ 8Ü‹E×ÑÐ@ÔAÙà�7‰7�>×"Ò"Ü)¨#¯|©|¸EÓ/BÐDVÓWˆEØÒ Ø"'�Ùä“—‘˜r # h¥- Ð1¸C¿G¹GÀJÐPUÓ<V�ÓWˆßÜ‹E× Ñ   V¥¨eÔ4Ü‹E×Ñ (¨3¨v­;¨-Ð 8×9Ø��[˜IÔ%Ü‹E×Ñ .°°Ð7PÐ QÔRÚä‹E×ÑÐ>×?ñ3 ð8 —+‘+“-� Ð.€HÜ‹u×"Ñ" 8Ó,€HßŸx¨E°ZÔ,?Ø"×(Ñ(¨Ó-¨aÕ0×6Ñ6Ó8ˆßÜ ¨(°NÔCä	„GÜƒE×Ñ˜5˜'  5 '¨Ð6Ö7ùòSs   Â9)M+Ã#M+Ã:M+ÚpairingÚfalseú  DM pairing enabled.Úopenr    z$  Open DM access enabled for Weixin.Údisabledz  Direct messages disabled.c                 óò	  € \        R4       \        4        \        4       P                  RRRR4       \	        RRR4      '       g   R	#  ^ R
IHp Hp T ! 4       '       g5   \        4       P                  R4       \        4       P                  R4       R	# \        4        \        4       P                  RR4      '       g   \        4       P                  R4       R	#  \        4       P                  P                  T! \        \        4       P                  4       4      4      4      pT'       g   \        4       P#                  R4       R	# TP%                  RR4      pTP%                  RR4      p\        4       P'                  RT4       \        4       P'                  RTP%                  RR4      4       TP%                  RR4      '       d+   \        4       P'                  RTP%                  RR4      4       \        4       P'                  R\        4       P)                  R4      ;'       g    R4       \        4        . R1Op\        4       P+                  RT^ 4      pT^8X  d?   \-        RT;'       g    R4      p\/        RR TR!7       \        4       P1                  R"4       MY\2        P%                  T\2        ^,          4      w  ršr¼\/        YšRR!7       T! T4       T^ 8X  d   \        4       P                  R#4       \        4        \        4       P                  ! \5          . R2Op\        4       P+                  R$T^ 4      pT^ 8X  d(   \/        R%RR&7       \        4       P                  R'4       M`T^8X  d(   \/        R(RR&7       \        4       P#                  R)4       M2\-        R*R4      p\/        RTR&7       \        4       P1                  R+4       T'       d   \        4        \7        R,TR-4       \        4        \        4       P1                  R.4       \        4       P                  R/T 24       T'       d   \        4       P                  R0T 24       R	# R	#   \         dA   p\        4       P                  RT 24       \        4       P                  R4        R	p?R	# R	p?ii ; i  \          d(    \        4        \        4       P#                  R4        R	# \         d(   p\        4       P                  RT 24        R	p?R	# R	p?ii ; i)3z8Interactive setup for Weixin / WeChat personal accounts.u   ðŸ’¬ Weixin / WeChatz>  1. Hermes will open Tencent iLink QR login in this terminal.z0  2. Use WeChat to scan and confirm the QR code.zG  3. Hermes will store the returned account_id/token in ~/.hermes/.env.zL  4. This adapter supports native text, image, video, and document delivery.ÚWeixinr#   r]   N)Úcheck_weixin_requirementsÚqr_loginz   Weixin adapter import failed: z1  Install gateway dependencies first, then retry.z>  Missing dependencies: Weixin needs aiohttp and cryptography.z2  Install them, then rerun `hermes gateway setup`.z  Start QR login now?Tz  Cancelled.z  Weixin setup cancelled.z  QR login failed: z  QR login did not complete.Ú
account_idr>   r‡   r´   Úbase_urlÚWEIXIN_BASE_URLÚWEIXIN_CDN_BASE_URLz%https://novac2c.cdn.weixin.qq.com/c2cú+  How should direct messages be authorized?z+  Allowed Weixin user IDs (comma-separated)Ú	allowlistrë   )ÚWEIXIN_DM_POLICYÚWEIXIN_ALLOW_ALL_USERSÚWEIXIN_ALLOWED_USERSz  Weixin allowlist saved.zY  Unknown DM users can request access and you approve them with `hermes pairing approve`.z$  How should group chats be handled?rî   )ÚWEIXIN_GROUP_POLICYÚWEIXIN_GROUP_ALLOWED_USERSz  Group chats disabled.rí   zM  All group chats enabled (only takes effect if iLink delivers group events).z?  Allowed group chat IDs (comma-separated, not member user IDs)zK  Group allowlist saved (only takes effect if iLink delivers group events).ÚWEIXIN_HOME_CHANNELzyour Weixin user IDzWeixin configured!z  Account ID: z  User ID: )ú%Use DM pairing approval (recommended)úAllow all direct messageszOnly allow listed user IDszDisable direct messages)z!Disable group chats (recommended)zAllow all group chatsz Only allow listed group chat IDs)ry   ru   r   r°   r„   Úgateway.platforms.weixinrñ   rò   rB   Úprint_errorr¥   rƒ   ÚasyncioÚrunrV   Úget_hermes_homeÚKeyboardInterruptr   rH   r‹   rb   r¤   rš   r’   r   Ú_WEIXIN_DM_POLICIESÚ_WEIXIN_GROUP_NOTErŒ   )rñ   rò   ÚexcÚcredentialsró   r‡   r¨   r©   rø   ÚpolicyÚ	allow_allÚemitÚmessageÚgroup_choicesÚ	group_idxÚallow_groupss                   r
   Ú_setup_weixinr  ž  sã  € äÐ.Ô/Ü	„GÜƒE×ÑØHØ:ØQØVô	ô   Ð*=¸~×NÒNÙðßPñ %×&Ò&Ü‹×ÑÐZÔ[Ü‹×ÑÐMÔNÙä	„GÜ‹5×ÑÐ6¸×=Ò=Ü‹×Ñ˜Ô(ÙðÜ“e—m‘m×'Ñ'©´´S³U×5JÑ5JÓ5LÓ1MÓ(NÓOˆ÷ Ü‹×ÑÐ:Ô;Ùà—‘ ¨rÓ2€JØ�o‰o˜i¨Ó,€GÜƒE×ÑÐ,¨jÔ9ÜƒE×Ñ˜¨¯©¸À"Ó)EÔFØ‡��z 2×&Ò&Ü‹×ÑÐ.°·±À
ÈBÓ0OÔPÜƒE×ÑØœs›u×2Ñ2Ð3HÓI×tÐtÐMtôô 
„Gò€Nô “×$Ñ$Ð%RÐTbÐdeÓf€JØ�Q„ÜÐ MÈwÏ}È}ÐZ\Ó]ˆ	ÜØ(ÀÐ_hõ	
ô 	‹×ÑÐ7Õ8ä+>×+BÑ+BÀ:ÔObÐcdÕOeÓ+fÑ(ˆ˜4Ü¨&ÐikÕlÙˆWŒØ˜Œ?Ü‹E×ÑØkôô 
„GÜƒE×ÒÔ/Ñ0ò€Mô “×#Ñ#Ð$JÈMÐ[\Ó]€IØ�A„~Ü¨ZÐTVÕWÜ‹×ÑÐ2Õ3Ø	�aŒÜ¨VÐPRÕSÜ‹×ÑÐkÕlä"Ð#dÐfhÓiˆÜ¨[ÐUaÕbÜ‹×ÑÐiÔjçÜŒÜÐ1°7Ð<QÔRä	„GÜƒE×ÑÐ,Ô-ÜƒE×Ñ�~ j \Ð2Ô3ßÜ‹×Ñ˜; w iÐ0Ö1ñ øôi ô Ü‹×ÑÐ<¸S¸EÐBÔCÜ‹×ÑÐLÔMÝûðûô" ô ÜŒÜ‹×ÑÐ7Ô8ÚÜô Ü‹×ÑÐ/°¨uÐ5Ô6Ýûðús=   ÁQ ÃAR ÑRÑ5RÒRÒ.S6ÓS6ÓS6ÓS1Ó1S6c                 ó&  € \        R4       \        RRR4      '       g   R# \        4        RR.p Rp\        4       P	                  RV ^ 4      ^ 8X  d0    ^ R	IHp V! 4       pT'       g   \        4       P                  R4       V'       gÏ   \        4        \        4       P                  RR4       \        4        \        4       P                  RRR7      pV'       g   \        4       P                  R4       R# \        4       P                  RRR7      pV'       g   \        4       P                  R4       R# RVP                  4       RVP                  4       RR/p\        4       P                  RVR,          4       \        4       P                  RVR,          4       VP                  RR4      p\        4        . R-Op\        4       P	                  RV^ 4      pV^ 8X  d¾   \        4       P                  RR4       RpV'       dM   \        4        \        4       P                  RV R2R4      '       d   Tp\        4       P!                  RV 24       \        4       P                  RV4       \        4       P!                  R 4       \        4       P                  R!4       MjV^8X  d(   \#        R"RR#7       \        4       P                  R$4       M<\%        R%T;'       g    R4      p	\#        RV	R#7       \        4       P!                  R&4       \        4        V'       d   \'        R'VR(4       Mu\        4       P                  R)RR7      p
V
'       dS   \        4       P                  R'V
P                  4       4       \        4       P!                  R*V
P                  4        24       \        4        \        4       P!                  R+4       \        4       P                  R,VR,           24       R#   \         d(    \        4        \        4       P                  R
4        R# i ; i).uI   Interactive setup for QQ Bot â€” scan-to-configure or manual credentials.u   ðŸ�§ QQ Botr*   r+   r,   Nz3Scan QR code to add bot automatically (recommended)z-Enter existing App ID and App Secret manuallyz&  How would you like to set up QQ Bot?)Úqr_registerz  QQ Bot setup cancelled.z:  QR setup did not complete. Continuing with manual input.z:  Go to https://q.qq.com to register a QQ Bot application.z<  Note your App ID and App Secret from the application page.z  App IDFr—   u2     Skipped â€” QQ Bot won't work without an App ID.z  App SecretTu6     Skipped â€” QQ Bot won't work without an App Secret.Úapp_idÚclient_secretÚuser_openidr>   r÷   ÚQQ_ALLOW_ALL_USERSrë   z  Add yourself (z) to the allow list?z  Allow list set to r-   rì   zJ  Unknown users can request access; approve with `hermes pairing approve`.r    )r  r-   z$  Open DM access enabled for QQ Bot.z(  Allowed user OpenIDs (comma-separated)z  Allowlist saved.r.   zyour QQ user IDz8  Home channel OpenID (for cron/notifications, or empty)rŠ   u   ðŸ�§ QQ Bot configured!z
  App ID: )rÿ   r   zOnly allow listed user OpenIDs)ry   r„   ru   r   r¤   Úgateway.platforms.qqbotr  r  r   r¥   r°   r   r±   r‹   rH   rƒ   r   r’   rš   rŒ   )Úmethod_choicesr
  r  r  Ú
app_secretr  r¨   r©   Úallowedrø   Úhome_channels              r
   Ú_setup_qqbotr    s+  € ä˜Ô&ä ¨+Ð7I×JÒJÙä	„GØKÐM|Ð}€NØ€KÜ
ƒu×ÑÐCÀ^ÐUVÓWÐ[\Ô\ð	Ý;Ù%›-ˆK÷
 Ü‹E×ÑÐYÔZçÜŒÜ‹×ÑØHØJô	
ô 	ŒÜ“—‘˜j°5�Ó9ˆßÜ‹E×ÑÐ TÔUÙÜ“U—\‘\ .¸4�\Ó@ˆ
ßÜ‹E×ÑÐ XÔYÙØ §¡£°À*×BRÑBRÓBTÐVcÐegÐhˆäƒE×Ñ˜ k°(Õ&;Ô<ÜƒE×ÑÐ+¨[¸Õ-IÔJà—/‘/ -°Ó4€Kä	„GÚ}€NÜ“×$Ñ$Ð%RÐTbÐdeÓf€JØ�Q„Ü‹×ÑÐ1°7Ô;ØˆßÜŒGÜ‹u×"Ñ"Ð%5°k°]ÐBVÐ#WÐY]×^Ò^Ø%�Ü“×#Ñ#Ð&:¸;¸-Ð$HÔIÜ‹×ÑÐ/°Ô9Ü‹×ÑÐ3Ô4Ü‹×ÑÐeÕfØ	�qŒÜ¨FÀRÕHÜ‹×ÑÐBÕCäÐ JÈK×L]ÐL]Ð[]Ó^ˆ	Ü¨GÀiÕPÜ‹×ÑÐ0Ô1ä	„GßÜÐ0°+Ð?PÕQä“u—|‘|Ð$^Ðin�|ÓoˆßÜ‹E× Ñ Ð!5°|×7IÑ7IÓ7KÔLÜ‹E×ÑÐ"8¸×9KÑ9KÓ9MÐ8NÐ OÔPä	„GÜƒE×ÑÐ1Ô2ÜƒE×Ñ�z +¨hÕ"7Ð!8Ð9Ö:øô} !ô 	ÜŒGÜ‹E×ÑÐ ;Ô<Úð	ús   ÁO Ï.PÐPc               ó    € V ^8„  d   QhRRRR/# )r4   r”   rV   r5   rÊ   r6   )r7   s   "r
   r8   r8   U  s   € ÷ ñ  Cð ¨Jñ r   c                ó˜   €  \        4       P                  V 4      P                  4       #   \        \        3 d    \        R4        R# i ; i)zZ``line_input`` for the Signal wizard; None (after printing the cancel line) on EOF/Ctrl+C.z
  Setup cancelled.N)r   Ú
line_inputr±   ÚEOFErrorr  ru   )r”   s   &r
   Ú_signal_line_inputr#  U  sD   € ðÜ‹u×Ñ Ó,×2Ñ2Ó4Ð4øÜÔ'Ð(ô ÜÐ$Ô%Úðús   ‚&) ©A	ÁA	c            	     óx	  € \        R4       \        4       P                  R4      p \        4       P                  R4      p\        RRR4      '       g   R# \	        4        \
        P                  ! R4      '       d   \        4       P                  R4       Me\        4       P                  R4       \        4       P                  R	R
RRR4       \	        4        \        4       P                  RRR4       \	        4        \	        4        \        4       P                  R4       T ;'       g    Rp\        RV R24      pVf   R# T;'       g    Tp\        4       P                  R4        ^ RIpVP                  VP                  R4       R2RR7      pVP                  ^È8X  d   \        4       P                  R4       MJ\        4       P                  RVP                   R24       \        4       P!                  RR4      '       g   R#  \        4       P%                  RV4       \	        4        \        4       P                  R#R$4       T;'       g    R%p\        R&V'       d   R'V R(2MR% R 24      pVf   R# T;'       g    TpV'       g   \        4       P'                  R)4       R# \        4       P%                  RV4       \	        4        \        4       P                  R*R+4       \        4       P                  R,4      ;'       g    Tp	\        R-V	 R24      p
V
f   R# \        4       P%                  R,T
;'       g    T	4       \	        4        \        4       P!                  R.R4      '       d”   \	        4        \        4       P                  R/4       \        4       P                  R04      ;'       g    R%p\        R1T;'       g    R2 R24      pVf   R# \        4       P%                  R0T;'       g    T;'       g    R24       \	        4        \        4       P                  R34       \        4       P                  R4V 2R5V 2R6R7\        4       P                  R04      '       d   R8MR9 24       R#   \"         dQ   p\        4       P                  RT R T 24       \        4       P!                  R!R"4      '       g    Rp?R#  Rp?EL´Rp?ii ; i):z'Interactive setup for Signal messenger.u   ðŸ“¡ Signalr!   r\   r    Nz
signal-clizsignal-cli found on PATH.zsignal-cli not found on PATH.z7  Signal requires signal-cli running as an HTTP daemon.z  Install options:zF    Linux:  download from https://github.com/AsamK/signal-cli/releasesz#    macOS:  brew install signal-cliz)    Docker: bbernhard/signal-cli-rest-apiz;  After installing, link your account and start the daemon:z$    signal-cli link -n "HermesAgent"zA    signal-cli --account +YOURNUMBER daemon --http 127.0.0.1:8080z8  Enter the URL where signal-cli HTTP daemon is running.zhttp://127.0.0.1:8080z  HTTP URL [z]: z  Testing connection...Ú/z/api/v1/checkg      $@)Útimeoutz!  signal-cli daemon is reachable!z#  signal-cli responded with status Ú.z  Continue anyway?Fz   Could not reach signal-cli at ú: z8  Save this URL anyway? (you can start signal-cli later)Tz9  Enter your Signal account phone number in E.164 format.z  Example: +15551234567r>   z  Account numberz [Ú]z  Account number is required.rÍ   zB  Enter phone numbers or UUIDs of allowed users (comma-separated).ÚSIGNAL_ALLOWED_USERSz  Allowed users [z<  Enable group messaging? (disabled by default for security)z0  Enter group IDs to allow, or * for all groups.ÚSIGNAL_GROUP_ALLOWED_USERSz  Group IDs [Ú*zSignal configured!z  URL: z  Account: z0  DM auth: via SIGNAL_ALLOWED_USERS + DM pairingz
  Groups: rY   rî   )ry   r   rb   r„   ru   ÚshutilÚwhichr   r   r°   r¥   r#  ÚhttpxrH   rÂ   Ústatus_coderƒ   rB   r‹   r  )Úexisting_urlÚexisting_accountÚdefault_urlÚurlr/  ÚresprN   Údefault_accountÚaccountÚdefault_allowedr  Úexisting_groupsÚgroupss                r
   Ú_setup_signalr;  ^  sù  € ä˜Ô&ä“5×&Ñ&Ð'8Ó9€LÜ“u×*Ñ*Ð+;Ó<ÐÜ Ð*;Ð=M×NÒNÙä	„GÜ‡|‚|�L×!Ò!Ü‹×ÑÐ7Õ8ä‹×ÑÐ;Ô<Ü‹×ÑØEÐG[ØTØ1Ð3^ô	
ô
 	ŒÜ‹×ÑØIØ2ØOô	
ô
 	Œä	„GÜƒE×ÑÐOÔPØ×9Ð9Ð"9€KÜ
˜|¨K¨=¸Ð<Ó
=€CØ
‚{ÙØ
×
Ð
�€CäƒE×ÑÐ.Ô/ðÛØ�y‰y˜CŸJ™J s›OÐ,¨MÐ:ÀDˆyÓIˆØ×Ñ˜sÔ"Ü‹E×ÑÐ CÕDä‹E×ÑÐ"EÀd×FVÑFVÐEWÐWXÐ YÔZÜ“5×&Ñ&Ð';¸U×CÒCÙð Dô ƒE×ÑÐ*¨CÔ0ä	„GÜƒE×ÑÐWÐYrÔsØ&×,Ð,¨"€OÜ Ð#3Ï°b¸Ð8IÈÑ4KÐdfÐ3gÐgiÐ!jÓk€GØ‚ÙØ×(Ð(˜€GßÜ‹×ÑÐ9Ô:ÙäƒE×ÑÐ)¨7Ô3ä	„GÜƒE×ÑØAØLôô “e×)Ñ)Ð*@ÓA×LÐLÀW€OÜ Ð#4°_Ð4EÀSÐ!IÓJ€GØ‚ÙÜƒE×ÑÐ/°×1KÐ1K¸OÔLä	„GÜ
ƒu×ÑÐYÐ[`×aÒaÜŒÜ‹×ÑÐKÔLÜ›%×-Ñ-Ð.JÓK×QÐQÈrˆÜ# m°O×4JÐ4JÀsÐ3KÈ3Ð$OÓPˆØŠ>ÙÜ‹×ÑÐ9¸6×;[Ð;[À_×;[Ð;[ÐX[Ô\ä	„GÜƒE×ÑÐ,Ô-ÜƒE×ÑØ
�#�ˆ˜; w iÐ0Ð2dØ
¤#£%×"5Ñ"5Ð6R×"SÒ"S‘YÐYcÐdÐeöøôW ô Ü‹×ÑÐ>¸s¸eÀ2ÀaÀSÐIÔJÜ‹u×"Ñ"Ð#]Ð_c×dÒdÝõ eûðús    Å"AQ Æ6AQ ÑR9Ñ)?R4Ò4R9c               ó   € V ^8„  d   QhRR/# )r4   r   rV   r6   )r7   s   "r
   r8   r8   ¼  s   € ÷ 
ñ 
˜3ñ 
r   c           
     óÌ   € ^ RI Hp R\        4       P                  P                  R\        4       P                  P
                  R\        R\        R\        /P                  V 4      # )z]Resolve a built-in platform's setup function; late-bound to dodge the hermes_cli.setup cycle.)Úsetupr$   Úwebhooksr   r"   r)   )
r	   r>  r   Úsetup_platformsÚ_setup_bluebubblesÚ_setup_webhooksr;  r  r  rH   )r   Ú_ss   & r
   Ú_builtin_setup_fnrD  ¼  sQ   € å&ð 	”s“u×,Ñ,×?Ñ?Ø”C“E×)Ñ)×9Ñ9Ø”-Ø”-Ø”ð÷ 
�cˆ#ƒhðr   c               ó    € V ^8„  d   QhRRRR/# )r4   rF   rI   r5   rl   r6   )r7   s   "r
   r8   r8   É  s   € ÷ :ñ : $ð :¨4ñ :r   c                óÀ  € V P                  R4      pVe   VP                  MRpVf   \        V R,          4      pVe
   V! 4        R# V P                  R4      '       d   \        4       P	                  V 4       R# V P                  RV R,          4      p\        V P                  RR4       RV 24       V'       d   VP                  M. pV'       d-   \        4       P                  R	R
P                  V4       24       M&\        4       P                  RV RV R,           24       V P                  R4      '       d&   \        4       P                  RV R,           24       R# R# )z²Plugin ``setup_fn`` -> built-in by key -> ``_setup_standard_platform`` (``vars``) -> env-var hint.
Bundled plugins auto-load; user plugins must already be in ``plugins.enabled``.r@   Nr   r   r   r   u   ðŸ”Œr˜   z(  Set these env vars in ~/.hermes/.env: z, z  Configure z( in config.yaml under gateway.platforms.r?   rÎ   )	rH   Úsetup_fnrD  r   ré   ry   rM   r¥   rÄ   )rF   rS   Úfnr   Úrequireds   &    r
   Ú_configure_platformrJ  É  s#  € ð �L‰LÐ*Ó+€EØ Ò,ˆ�Š°$€BØ	‚zÜ˜x¨�Ó/ˆØ	‚~Ù
ŒÙØ‡|�|�F×ÒÜ‹×&Ñ& xÔ0Ùà�L‰L˜ (¨5¥/Ó2€EÜ˜8Ÿ<™<¨°Ó8Ð9¸¸5¸'ÐBÔCß%*ˆu×!Ò!°€HßÜ‹×ÑÐCÀDÇIÁIÈhÓDWÐCXÐYÕZä‹×Ñ˜<¨ wÐ.VÐW_Ð`eÕWfÐVgÐhÔiØ‡|�|�N×#Ò#Ü‹×Ñ˜2˜h ~Õ6Ð7Ð8Ö9ñ $r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r4   ÚactionrV   ÚquestionÚfailed_labelr5   rl   r6   )r7   s   "r
   r8   r8   â  s/   € ÷ Qñ Q¨ð Q¸ð QÈ3ð QÐ]añ Qr   c                ó2  € \        4       P                  4       '       d:   \        4       P                  4       '       d   \        4       P                  V 4       R# \        4       P	                  VR4      '       d    \        4       P
                  ! V 3RV/VB  R# R# )zZWizard start/restart prompt; prints remediation instead when system scope would need root.TrN  N)r   Úsupports_systemd_servicesÚ$_system_scope_wizard_would_need_rootÚ_print_system_scope_remediationrƒ   Ú_setup_service_action)rL  rM  rN  Úkwargss   &&&,r
   Ú_wizard_offer_service_actionrU  â  sg   € ä
ƒu×&Ñ&×(Ò(¬S«U×-WÑ-W×-YÒ-YÜ‹×-Ñ-¨fÖ5Ü	‹×	Ñ	˜X t×	,Ò	,Ü‹×#Ò# FÑP¸ÐPÈÔPñ 
-r   ÚwindowsÚsystemc          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r4   rL  rV   rN  rV  r`   rW  r5   rl   r6   )r7   s   "r
   r8   r8   ê  s4   € ÷ 4ñ 4Øð4Ø"%ð4Ø04ð4ØEIð4à	ñ4r   c               ó  €  \        4       P                  VR7      pVe&   \        4       P                  Y@V R8X  d   RMT4       R# V R8X  d>   V'       d4   \        4       P                  4        \        4       P	                  R4       R# R# R#   \        4       P
                   dK   p\        4       P                  RT R24       \        4       P                  \        T4      4        Rp?R# Rp?i\        4       P                   dD   p\        4       P                  RT RT 24       \        4       P                  T 4        Rp?R# Rp?i\        P                   d+   p\        4       P                  RT RT 24        Rp?R# Rp?ii ; i)zÀRun a wizard service start/restart, printing remediation instead of raising. ``windows=False``
skips Windows (pre-platform status block never offers it); ``system`` is a fresh install's scope.©rV  NÚrestartzStart manually: hermes gatewayrÎ   u     â€” user systemd not reachable:r(  )r   Ú_service_backendÚ_service_callÚstop_profile_gatewayr¥   ÚUserSystemdUnavailableErrorr  Ú_print_indentedrV   ÚSystemScopeRequiresRootErrorrR  Ú
subprocessÚCalledProcessError)rL  rN  rV  rW  ÚbackendrN   s   &$$$  r
   rS  rS  ê  s*  € ð
4Ü“%×(Ñ(°Ð(Ó9ˆØÒÜ‹E×Ñ ¸À9Ô9L±ÐRXÖYØ�yÔ §WÜ‹E×&Ñ&Ô(Ü‹E×ÑÐ=Ö>ñ &-Ñ øô ‹5×,Ñ,ô &Ü‹×Ñ˜B˜|˜nÐ,LÐMÔNÜ‹×Ñœc !›f×%Ò%ûÜ‹5×-Ñ-ô 6ä‹×Ñ˜B˜|˜n¨B¨q¨cÐ2Ô3Ü‹×-Ñ-¨f×5Ò5ûÜ×(Ñ(ô 4Ü‹×Ñ˜B˜|˜n¨B¨q¨cÐ2×3Ò3ûð4úsB   ‚AB ÁB Á1B ÂFÂ$?C)Ã)FÄ8EÅFÅFÅF Æ FÚsystemdÚlaunchdzScheduled TaskÚwslÚtermuxÚunsupportedc               ó   € V ^8„  d   QhRR/# ©r4   r5   rl   r6   )r7   s   "r
   r8   r8     s   € ÷ Yñ Y dñ Yr   c                 ó  € \        4        \        4       P                  4       p \        4       P                  4       p\        4       P	                  4       '       dA   \        4       P                  4       '       d#   \        4       P                  4        \        4        \        4       P	                  4       '       dA   \        4       P                  4       '       d#   \        4       P                  4        \        4        V '       d$   V'       d   \        4       P                  R4       R
# V '       d+   \        4       P                  R4       \        RRRRR7       R
# \        4       P                  R4       \        4       P                  R	4       R
# )z\Pre-platform service status: warnings, then offer to start an installed-but-stopped service.z)Gateway service is installed and running.z-Gateway service is installed but not running.Ústartz  Start it now?zFailed to startFrZ  z%Gateway service is not installed yet.z<You'll be offered to install it after configuring platforms.N)ru   r   Ú_is_service_installedÚ_is_service_runningrP  Úhas_conflicting_systemd_unitsÚ$print_systemd_scope_conflict_warningÚhas_legacy_hermes_unitsÚprint_legacy_unit_warningr   r   rU  r¥   )Úservice_installedÚservice_runnings     r
   Ú_wizard_service_status_blockrv    sí   € ä	„GÜ›×3Ñ3Ó5ÐÜ“e×/Ñ/Ó1€Oä
ƒu×&Ñ&×(Ò(¬S«U×-PÑ-P×-RÒ-RÜ‹×2Ñ2Ô4ÜŒä
ƒu×&Ñ&×(Ò(¬S«U×-JÑ-J×-LÒ-LÜ‹×'Ñ'Ô)ÜŒçŸ_Ü‹×ÑÐGÖHß	Ü‹×ÑÐKÔLÜ$ WÐ.?ÐARÐ\a×bä‹×ÑÐ@ÔAÜ‹×ÑÐWÖXr   c               ó   € V ^8„  d   QhRR/# rk  r6   )r7   s   "r
   r8   r8   7  s   € ÷ 
5ñ 
5˜tñ 
5r   c            
     ó²  €  \        4        \        4       P                  R4       \        4       P                  4       p V  Uu. uF$  qR,           RVR,           R\	        V4       R2NK&  	  upR.,           p\        4       P                  RV\        V4      ^,
          4      pV\        V 4      8X  d   R	# \        4       P                  W,          4       KÓ  u upi )
TzMessaging Platformsr   r˜   r   z  (Ú)ÚDonezSelect a platform to configure:N)ru   r   Úprint_headerrT   rh   r¤   ÚlenrJ  )rQ   rP   Ú
menu_itemsÚchoices       r
   Ú_wizard_platform_loopr  7  s·   € Ø
ÜŒÜ‹×ÑÐ0Ô1ä“E×(Ñ(Ó*ˆ	ÙU^Ó_ÑU^ÐPQ˜7�˜ A a¨¥j \°Ô5EÀaÓ5HÐ4IÈÓKÑU^Ñ_ÐciÐbjÕjˆ
Ü“×$Ñ$Ð%FÈ
ÔTWÐXbÓTcÐfgÕTgÓhˆØ”S˜“^Ô#ÙÜ‹×!Ñ! )Õ"3Ö4ùò	 `s   Á*Cc               ó    € V ^8„  d   QhRRRR/# )r4   rd  rV   r5   rl   r6   )r7   s   "r
   r8   r8   D  s   € ÷ +Kñ +K Sð +K¨Tñ +Kr   c                ó’  € \        4       P                  4       '       d   RMRp\        4       P                  RR4      p\        4       P                  R\        V ,           RV 2R4      pV'       g�   V'       g…   \        4       P	                  R4       \        4       P	                  R4       \        4       P                  4       '       d   \        4       P	                  R	4       \        4       P	                  R
4       R#  RRrTV R8X  d   \        4       P                  RVR7      w  rEMNV R8X  d   \        4       P                  RVR7       M+\        4       P                  4       P                  RW#R7       R# \        4        V'       d,   V'       d"   \        4       P                  RRVR8H  R7       R# R# R#   \        P                   dA   p\        4       P                  RT 24       \        4       P	                  R4        Rp?R# Rp?i\         d7    \        4       P!                  R4       \        4       P	                  R4        R# i ; i)a­  Fresh install from the wizard: ask start-now / start-on-login once, install, then start.

The Windows installer owns its start decision (Scheduled Task and Startup-folder
paths start the gateway themselves when start_now is true, and a UAC hand-off
installs and starts in the elevated child), so the wizard forwards the answers
and returns without a second start. Each install-intent question is asked exactly
once per setup run.z. (note: services may not survive WSL restarts)r>   z  Start the gateway now?Tz5  Start the gateway automatically on login/boot as a z	 service?z%  Skipped start and auto-start setup.z/  You can install later: hermes gateway installzA  Or as a boot-time service: sudo hermes gateway install --systemz+  Or run in foreground:  hermes gateway runNre  F)ÚforceÚenable_on_startuprf  )r‚  Ú	start_now)r‚  r„  Ústart_on_loginrm  úStart failedrW  )rN  rW  z  Install failed: z.  You can try manually: hermes gateway installz+  Gateway service install did not complete.)r   Úis_wslrƒ   Ú_WIZARD_BACKEND_LABELSr¥   rP  Ú install_linux_gateway_from_setupÚlaunchd_installÚ_gw_windowsÚinstallru   rS  rb  rc  r  Ú
SystemExitr   )rd  Úwsl_noter„  r…  Úinstalled_scopeÚdid_installrN   s   &      r
   Ú_wizard_install_servicer‘  D  s×  € ô DGÃ5Ç<Á<Ç>Â>Ñ?ÐWY€HÜ“×#Ñ#Ð$>ÀÓE€IÜ“U×(Ñ(Ø
?Ô@VÐW^Õ@_Ð?`Ð`iØˆ*ð	àó€N÷
 ŸÜ‹×ÑÐ@ÔAÜ‹×ÑÐJÔKÜ‹5×*Ñ*×,Ò,Ü‹E×ÑÐ`ÔaÜ‹×ÑÐFÔGÙðKØ'+¨T˜Ø�iÔÜ+.«5×+QÑ+QØ¨~ð ,Ró ,Ñ(ˆO˜[ð ˜	Ô!Ü‹E×!Ñ!¨¸Ð!ÕCä‹E×ÑÓ×'Ñ'¨e¸yÐ'ÔhÙÜŒßŸ9Ü‹E×'Ñ'¨¸nÐUdÐhpÑUpÐ'Öqñ %‰;øä×(Ñ(ô KÜ‹×ÑÐ.¨q¨cÐ2Ô3Ü‹×ÑÐI×JÒJûÜô Kô 	‹×ÑÐIÔJÜ‹×ÑÐI×Jð	Kús1   Ã=A4F2 Å3F2 ÆF2 Æ2IÇ5HÈIÈ3IÉIc               ó   € V ^8„  d   QhRR/# rk  r6   )r7   s   "r
   r8   r8   r  s   € ÷ hñ h˜Dñ hr   c                 ó"  a€ \        4        \        \        4       P                  R\        4       P                  P                  4      4       \        4       P                  4       '       d   R# \        4       P                  4       p \        4       P                  4       pV'       d   \        RRR4       R# V '       d   \        RRR4       R# \        4        \        4       P                  4       pVe   \        4       P                  V4       R# \        4       P                  4       '       d   RR	upoM4\        4       P                  4       '       d   ^ R
IHp RV! 4       upoMRR	upo\        4       P                  ! V3R l\         V,           4       !   R# )zSOffer to install/start/restart the gateway once at least one platform has progress.Nr[  z)  Restart the gateway to pick up changes?zRestart failedrm  z  Start the gateway service?r†  rg  r>   )Údisplay_hermes_homerh  ri  c              3  óF   <"  € T F  qP                  SR 7      x € K  	  R# 5i))ÚhomeN)r7   )r   rÙ   r–  s   & €r
   r€   Ú%_wizard_post_setup.<locals>.<genexpr>Œ  s   øé € Ð!fÑEe¸T§+¡+°4 +×"8Ð"8ÓEeùs   ƒ!u®   â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€)ru   r   rv   rw   ÚDIMÚ _served_profile_needs_no_servicern  ro  rU  r\  r‘  r‡  Ú	is_termuxÚhermes_constantsr”  r°   Ú_WIZARD_NO_SERVICE_LINES)rt  ru  rd  ÚreasonÚ_dhhr–  s        @r
   Ú_wizard_post_setuprŸ  r  s  ø€ ä	„GÜ	Œ#‹%�+‰+�j¤#£%§,¡,×"2Ñ"2Ó
3Ô4Ü
ƒu×-Ñ-×/Ò/ÙÜ›×3Ñ3Ó5ÐÜ“e×/Ñ/Ó1€OçÜ$ YÐ0[Ð]mÖnß	Ü$ WÐ.LÈnÖ]äŒÜ“%×(Ñ(Ó*ˆØÒÜ‹E×)Ñ)¨'Ô2ÙÜ‹5�<‰<�>Š>Ø  "ˆLˆF‘DÜ‹U�_‰_×ÒÝDØ#¡T£VˆLˆF‘Dà(¨"ˆLˆF�DÜ‹×ÒÔ!fÔE]Ð^dÖEeÓ!fÔgr   c                 ó¾  a€ \        4       P                  4       '       d   \        4       P                  R4       R# \        4        \         FB  p \        \        4       P                  V \        4       P                  P                  4      4       KD  	  \        4        \        4        R R lo\        ;QJ d5    V3R l\        4       P                  4        4       F  '       g   K   RM*	  RM&! V3R l\        4       P                  4        4       4      '       d   \        4       P                  4        M#\        4        \        4       P                  R4       \        4        R# )	z<Interactive setup for messaging platforms + gateway service.zrun gateway setupNc               ó    € V ^8„  d   QhRRRR/# )r4   ÚstatusrV   r5   r`   r6   )r7   s   "r
   r8   Ú#gateway_setup.<locals>.__annotate__�  s   € ÷ kñ k˜Sð k Tñ kr   c                óš   € V P                  4       pVR 8H  ;'       g+    VP                  R4      ;'       g    VP                  R4      '       * # )r[   Ú	partiallyzplugin disabled)rÃ   r¿   )r¢  Úss   & r
   Ú_is_progressÚ#gateway_setup.<locals>._is_progress�  s?   € Ø�L‰L‹NˆØÐ)Ñ)×iÐi¨Q¯\©\¸+Ó-F×iÐiÈ!Ï,É,ÐWhÓJiÔjÐjr   c              3  ób   <"  € T F$  pS! \        4       P                  V4      4      x € K&  	  R # 5ir~   )r   rh   )r   rP   r§  s   & €r
   r€   Ú gateway_setup.<locals>.<genexpr>¡  s(   øé € Ð
SÑ<R°q‰<œ›×.Ñ.¨qÓ1×2Ð2Ó<Rùs   ƒ,/TFz?No platforms configured. Run 'hermes gateway setup' when ready.)r   Ú
is_managedÚmanaged_errorru   Ú_WIZARD_BANNERrv   rw   ÚMAGENTArv  r  rd   rT   rŸ  r¥   )Úbanner_liner§  s    @r
   Úgateway_setupr°  �  sÎ   ø€ ä
ƒu×Ñ×ÒÜ‹×ÑÐ/Ô0Ùä	„Gß%ˆÜŒc‹e�k‰k˜+¤s£u§|¡|×';Ñ';Ó<Ö=ñ &ô !Ô"ÜÔõk÷ ƒsÔ
S¼C»E×<PÑ<PÔ<RÓ
S‡s‡s‚sÔ
S¼C»E×<PÑ<PÔ<RÓ
S×SÒSÜ‹× Ñ Õ"äŒÜ‹×ÑÐZÔ[ä	†Gr   )uC   1. In Mattermost: Integrations â†’ Bot Accounts â†’ Add Bot AccountuE      (System Console â†’ Integrations â†’ Bot Accounts must be enabled)z:2. Give it a username (e.g. hermes) and copy the bot tokenuK   3. Works with any self-hosted Mattermost instance â€” enter your server URLuA   4. To find your user ID: click your avatar (top-left) â†’ Profileu8      Your user ID is displayed there â€” click it to copy.uI      âš  This is NOT your username â€” it's a 26-character alphanumeric ID.uL   5. To get a channel ID: click the channel name â†’ View Info â†’ copy the ID)	zF1. Install BlueBubbles on a Mac that will act as your iMessage server:z   https://bluebubbles.app/uG   2. Complete the BlueBubbles setup wizard â€” sign in with your Apple IDuD   3. In BlueBubbles Settings â†’ API, note the Server URL and passwordz84. The server URL is typically http://<your-mac-ip>:1234z<5. Hermes connects via the BlueBubbles REST API and receivesz(   incoming messages via a local webhookzJ6. To authorize users, use DM pairing: hermes pairing generate bluebubblesuD      Share the code â€” the user sends it via iMessage to get approved)z,1. Register a QQ Bot application at q.qq.comz<2. Note your App ID and App Secret from the application pagez;3. Enable the required intents (C2C, Group, Guild messages)z'4. Configure sandbox or publish the bot)z=1. Download the Yuanbao app from https://yuanbao.tencent.com/u8   2. In the app, go to PAI â†’ My Bot and create a new botz;3. After the bot is created, copy the App ID and App SecretzH4. Enter them below and Hermes will connect automatically over WebSocket)é   z9Enable open access (any email sender can message the bot)z=Use DM pairing (unknown email senders receive a pairing code)úAPolitely decline unknown senders (one-time message, then silence)zKeep unknown senders silent)é   z/Enable open access (anyone can message the bot)zXUse DM pairing (unknown users request access, you approve with 'hermes pairing approve')r²  z7Skip for now (bot will deny all users until configured))zH  Note: QR login connects an iLink bot identity (e.g. ...@im.bot), not azM  scriptable personal WeChat account. Ordinary WeChat groups typically cannotzN  invite an @im.bot identity, and iLink does not deliver ordinary-group eventszI  to most bot accounts. The settings below only apply when iLink actuallyuO     delivers group events for your account type â€” otherwise DM remains the onlyz,  working channel regardless of this choice.)u±   â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”�u@   â”‚             â˜¤ Gateway Setup                            â”‚u±   â”œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¤u?   â”‚  Configure messaging platforms and the gateway service. â”‚u>   â”‚  Press Ctrl+C at any time to exit.                     â”‚u±   â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜)z*  WSL detected but systemd is not running.ú'  Run in foreground: hermes gateway runz<  For persistence:   tmux new -s hermes 'hermes gateway run'zM  To enable systemd: add systemd=true to /etc/wsl.conf, then 'wsl --shutdown')z/  Termux does not use systemd/launchd services.r´  zp  Or start it manually in the background (best effort): nohup hermes gateway run >{home}/logs/gateway.log 2>&1 &)z1  Service install not supported on this platform.r´  )+Ú__doc__Ú
__future__r   r-  rb  rE   Úhermes_cli.setupr   r   r   rG   rT   rh   rq   ry   r„   rŒ   r’   rš   r£   rª   r·   rÇ   rÔ   ré   r  r  r  r  r#  r;  rD  rJ  rU  rS  r­  rˆ  rœ  rv  r  r‘  rŸ  r°  r6   r   r
   Ú<module>r¸     sü  ðñõ #ã Û Û 
Ý *Ý *òð 	ˆ|˜W l°G¸VÀ[ÐRdØò 	
ð 	ØÐ% xÐ1[Ø˜ Ð(jðlàÐ'¨°;À
ÈDØÐ=ð?àÐ/°Ð;_Ø˜ °°fÐ>jðlàÐ.ØÐoØ˜ Ð(jðlð Ð,ØÐmØ˜ØÐ]ð_ð
ðð8 ˆH�g˜x¨°&¸+ÐGXÐYØ
ˆH�gÐ0°'¸6À;ÐPcÐdàˆ}˜gÐ'?Ø�˜Ð&>Øò 

ð 	ØÐ-ØÐOÐQ[Ð]bØÐEðGð Ð+¨XÐ7TÐV`ÐbfØÐJðLàÐ0ØÐvØ˜ °ØÐvðxð Ð/ØÐdØ˜ØÐ]ð_ð
ðð> 	ˆw˜ ¨7°F¸KÈØò 
ð 	Ø�[ (¨O¸ZÈØÐ8ð:àÐ'¨Ð3FÈ
ÐTXØÐ<ð>àÐ'ØÐ\Ø˜ °ØÐPðRð Ð)ØÐUÐWaÐchØÐKðMð
ðð. 	ˆy˜' 9¨g°v¸{ÐL\Øò 
ð 	ØÐ% x°¸:ÀuØÐGðIàÐ)¨8°\À:ÈtØÐWðYð
ððgb€
õJõ>Hõ6dõ
Rõ
õ@õ*õ
Oð 	ð 'ð
 
ð Cð Ð õVõ.õ8õõB>8ðF ˆ	�7˜MÐ+BÐCØˆ�˜Ð'MÐNØˆ
�G˜]Ð,IÐJðÐ ðÐ òe2òPL;õ^ò[õ|
õ:õ2Qð4Ø7;ð4ØLQ÷4ð.€ð $ Y°	¸9ÀiÐQaÐbÐ ð
 
ð ð
 ð ð ð ðÐ õ Yõ0
5õ+Kõ\hô:r   