Ë
    ÿ`gjÁ3  ã                  óT   — d Z ddlmZ ddlZddlmZ ddlmZ dd„Z	 	 	 	 	 	 	 	 d	d„Z	y)
a-  ``hermes gateway`` and ``hermes proxy`` subcommand parsers.

Extracted verbatim from ``hermes_cli/main.py:main()`` (god-file Phase 2).
Both parsers are built together because they shared one inline block (the
``gateway`` section also defined ``proxy``). Handlers injected to avoid
importing ``main``.
é    )ÚannotationsN)ÚCallable)Úadd_accept_hooks_flagc                óH   — | j                  ddt        j                  ¬«       y)a{  Accept stale `gateway <verb> --platform X` docs without advertising it.

    Gateway service lifecycle commands operate on the gateway process, not a
    single messaging adapter.  Photon briefly printed a per-platform start
    command during setup; keep that command parseable so users following the
    old hint don't get blocked by argparse before the gateway can start.
    z
--platformÚplatform©ÚdestÚhelpN)Úadd_argumentÚargparseÚSUPPRESS)Úparsers    úQ/root/.hermes/venv/lib/python3.12/site-packages/hermes_cli/subcommands/gateway.pyÚ_add_compat_platform_flagr      s&   € ð ×ÑØØÜ×Ñð õ ó    c               óþ  — | j                  ddd¬«      }|j                  d¬«      }|j                  dd¬	«      }|j                  d
dddd¬«       |j                  dddd¬«       |j                  ddd¬«       |j                  ddd¬«       |j                  ddd¬«       |j                  ddd¬«       t        |«       t        |«       |j                  dd¬	«      }|j                  ddd ¬«       |j                  d!dd"¬«       t	        |«       |j                  d#d$¬	«      }|j                  ddd ¬«       |j                  d!dd%¬«       |j                  d&d'¬	«      }	|	j                  ddd ¬«       |	j                  d!dd(¬«       t	        |	«       |j                  d)d*¬	«      }
|
j                  d+dd,¬«       |
j                  d-d.dd/¬«       |
j                  ddd ¬«       t	        |
«       |j                  d0d1¬	«      }|j                  ddd2¬«       |j                  ddd3¬«       |j                  d4d5d6¬7«       |j                  d8d9dd:d;¬<«       |j                  d=d9d>d?¬@«       |j                  dAdBdd:dC¬<«       |j                  dDdBd>dE¬@«       |j                  dFdGdt
        j                  ¬@«       |j                  dHdI¬	«      }|j                  ddd ¬«       |j                  dJdK¬	«       |j                  dLdM¬	«       |j                  dNdOdP¬«      }|j                  dQdRddS¬@«       |j                  dTdUdVddW¬@«       |j                  dXdYdZ¬«      }|j                  d[d:d\¬]«       |j                  d^d_d:d`¬a«       |j                  dbdcd:dd¬a«       |j                  dedfd:dg¬a«       |j                  |¬h«       | j                  didjdk¬«      }|j                  dl¬«      }|j                  ddm¬	«      }|j                  dndodp¬]«       |j                  dqd:dr¬]«       |j                  dst        d:dt¬u«       |j                  d)dv¬	«       |j                  dwdx¬	«       |j                  |¬h«       |j                  |¬h«       y:)yzCAttach the ``gateway`` and ``proxy`` subcommands to ``subparsers``.ÚgatewayzMessaging gateway managementzLManage the messaging gateway (Telegram, Discord, WhatsApp, Weixin, and more))r
   ÚdescriptionÚgateway_command)r	   Úrunz?Run gateway in foreground (recommended for WSL, Docker, Termux))r
   z-vz	--verboseÚcountr   z2Increase stderr log verbosity (-v=INFO, -vv=DEBUG))ÚactionÚdefaultr
   z-qz--quietÚ
store_truezSuppress all stderr log output)r   r
   z	--replacez:Replace any existing gateway instance (useful for systemd)z--forcezÝStart a foreground gateway even when a systemd/launchd/s6 service already supervises this profile. Without --force, the command refuses because a second dispatcher escapes the service and can corrupt shared gateway state.z--no-supervisea¯  Inside the s6-overlay Docker image, normally `gateway run` is automatically redirected to the supervised s6 service (so the gateway gets auto-restart on crash, plus a supervised dashboard if HERMES_DASHBOARD is set). Pass --no-supervise to opt out and get the historical pre-s6 foreground behavior: the gateway is the container's main process and the container exits with the gateway's exit code. No effect outside an s6 container.z--external-supervisorzøDeclare that an external process manager owns this foreground gateway. In-chat restarts and updates exit back to that manager instead of spawning a detached replacement. Use this when a launchd/systemd wrapper strips its native environment markers.Ústartz6Start the installed systemd/launchd background servicez--systemz-Target the Linux system-level gateway servicez--allzDKill ALL stale gateway processes across all profiles before startingÚstopzStop gateway servicez.Stop ALL gateway processes across all profilesÚrestartzRestart gateway servicez@Kill ALL gateway processes across all profiles before restartingÚstatuszShow gateway statusz--deepzDeep status checkz-lz--fullz9Show full, untruncated service/log output where supportedÚinstallz7Install gateway as a systemd/launchd background servicezForce reinstallz8Install as a Linux system-level service (starts at boot)z--run-as-userÚrun_as_userz3User account the Linux system service should run asr   z--start-nowÚ	start_nowNz6Start the gateway service immediately after installing)r	   r   r   r
   z--no-start-nowÚstore_falsez1Do not start the gateway service after installing)r	   r   r
   z--start-on-loginÚstart_on_loginz7Enable the service to start automatically on login/bootz--no-start-on-loginz0Do not enable the service to start on login/bootz--elevated-handoffÚelevated_handoffÚ	uninstallzUninstall gateway serviceÚlistz*List all profiles and their gateway statusÚsetupzConfigure messaging platformszmigrate-legacyz;Remove legacy hermes.service units from pre-rename installszÖStop, disable, and remove legacy Hermes gateway unit files (e.g. hermes.service) left over from older installs. Profile units (hermes-gateway-<profile>.service) and unrelated third-party services are never touched.z	--dry-runÚdry_runz+List what would be removed without doing itz-yz--yesÚyeszSkip the confirmation promptÚenrollzLEnroll this gateway with a relay connector (writes relay auth creds to .env)a–  Redeem a single-use enrollment token with a relay connector. Authenticates as your Nous Portal account (the connector derives the authoritative tenant from it), mints this gateway's per-gateway secret and per-tenant delivery key, and writes GATEWAY_RELAY_ID / GATEWAY_RELAY_SECRET / GATEWAY_RELAY_DELIVERY_KEY into ~/.hermes/.env. Requires being logged in (hermes setup). Not available in managed installs.z--tokenz†The single-use enrollment token from the connector (delivered with your gateway config). Also settable via GATEWAY_RELAY_ENROLL_TOKEN.)r   r
   z--connector-urlÚconnector_urlz®The connector base/relay URL, e.g. wss://connector.example.com/relay or https://connector.example.com. Also settable via GATEWAY_RELAY_URL / gateway.relay_url in config.yaml.)r	   r   r
   z--gateway-idÚ
gateway_idz[A stable id for this gateway instance (kill-switch granularity). Defaults to gw-<hostname>.z
--wake-urlÚwake_urlua  Phase 5 Â§5.2 wake URL: a reachable URL the connector pokes (payload-free GET) to wake this gateway when buffered work arrives while it's idle/suspended, so it reconnects and drains. Persisted as GATEWAY_RELAY_WAKE_URL in ~/.hermes/.env and forwarded at provision. Optional â€” without it the gateway still drains whenever it next reconnects on its own.)ÚfuncÚproxyz0Local OpenAI-compatible proxy to OAuth providerszÝRun a local HTTP server that forwards OpenAI-compatible requests to an OAuth-authenticated provider (e.g. Nous Portal). External apps can point at the proxy with any bearer token; the proxy attaches your real credentials.Úproxy_commandzRun the proxy in the foregroundz
--providerÚnouszMUpstream provider: nous or xai (default: nous). See `hermes proxy providers`.z--hostz@Bind address (default: 127.0.0.1). Use 0.0.0.0 to expose on LAN.z--portzBind port (default: 8645))Útyper   r
   z$Show which proxy upstreams are readyÚ	providersz'List available proxy upstream providers)	Ú
add_parserÚadd_subparsersr   r   r   r   r   Úset_defaultsÚint)Ú
subparsersÚcmd_gatewayÚ	cmd_proxyÚcmd_gateway_enrollÚgateway_parserÚgateway_subparsersÚgateway_runÚgateway_startÚgateway_stopÚgateway_restartÚgateway_statusÚgateway_installÚgateway_uninstallÚgateway_migrate_legacyÚgateway_enrollÚproxy_parserÚproxy_subparsersÚproxy_starts                     r   Úbuild_gateway_parserrJ       ss  € ð  ×*Ñ*ØØ+Øbð +ó €Nð
 (×6Ñ6Ð<MÐ6ÓNÐð %×/Ñ/ØÐUð 0ó €Kð ×ÑØØØØØAð ô ð ×ÑØˆi Ð3Sð ô ð ×ÑØØØIð ô ð
 ×ÑØØð,ð	 ô 	ð ×ÑØØðFð	 ô ð ×ÑØØðMð	 ô 	ô ˜+Ô&Ü˜.Ô)ð '×1Ñ1ØÐNð 2ó €Mð ×ÑØØØ<ð ô ð
 ×ÑØØØSð ô ô
 ˜mÔ,ð &×0Ñ0°Ð>TÐ0ÓU€LØ×ÑØØØ<ð ô ð
 ×ÑØØØ=ð ô ð )×3Ñ3ØÐ1ð 4ó €Oð × Ñ ØØØ<ð !ô ð
 × Ñ ØØØOð !ô ô
 ˜oÔ.ð (×2Ñ2°8ÐBWÐ2ÓX€NØ×Ñ °ÐDWÐÔXØ×ÑØØØØHð	  ô ð ×ÑØØØ<ð  ô ô
 ˜nÔ-ð )×3Ñ3ØÐQð 4ó €Oð × Ñ  °<ÐFWÐ ÔXØ× Ñ ØØØGð !ô ð
 × Ñ ØØØBð !ô ð
 × Ñ ØØØØØEð !ô ð × Ñ ØØØØ@ð	 !ô ð × Ñ ØØØØØFð !ô ð × Ñ ØØØØ?ð	 !ô ð × Ñ ØØØÜ×Ñð	 !ô ð +×5Ñ5ØÐ5ð 6ó Ðð ×"Ñ"ØØØ<ð #ô ð ×!Ñ! &Ð/[Ð!Ô\ð ×!Ñ! 'Ð0OÐ!ÔPð 0×:Ñ:ØØJð6ð	 ;ó 	Ðð ×'Ñ'ØØØØ:ð	 (ô ð ×'Ñ'ØØØØØ+ð (ô ð (×2Ñ2ØØ[ðZð	 3ó €Nð ×ÑØØðRð	  ô ð ×ÑØØØð2ð  ô 	ð ×ÑØØØð)ð  ô ð ×ÑØØØð%ð  ô ð ×ÑÐ%7ÐÔ8ð ×(Ñ(ØØ?ð.ð	 )ó 	€Lð $×2Ñ2¸Ð2ÓHÐà"×-Ñ-ØÐ7ð .ó €Kð ×ÑØØØ\ð ô ð
 ×ÑØØØOð ô ð
 ×ÑØÜØØ(ð	 ô ð ×ÑØÐ=ð  ô ð ×ÑØÐCð  ô ð ×Ñ 9ÐÔ-Ø×Ñ [ÐÕ1r   )r   zargparse.ArgumentParserÚreturnÚNone)r9   r   r:   r   r;   r   rK   rL   )
Ú__doc__Ú
__future__r   r   Útypingr   Úhermes_cli.subcommands._sharedr   r   rJ   © r   r   ú<module>rR      sG   ðñõ #ã Ý å @óðC2Ø (ðC2Ø5=ðC2ØS[ðC2à	ôC2r   