§
    (Gj2  ã                  óF   — 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	dS )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_flagÚparserúargparse.ArgumentParserÚreturnÚNonec                óJ   — |                       ddt          j        ¬¦  «         dS )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)r   s    úD/home/rurouni/.hermes/hermes-agent/hermes_cli/subcommands/gateway.pyÚ_add_compat_platform_flagr      s7   € ð ×ÒØØÝÔð ñ ô ð ð ð ó    Úcmd_gatewayr   Ú	cmd_proxyÚcmd_gateway_enrollc               ó¢
  — |                       ddd¬¦  «        }|                     d¬¦  «        }|                      dd¬	¦  «        }|                     d
dddd¬¦  «         |                     dddd¬¦  «         |                     ddd¬¦  «         |                     ddd¬¦  «         |                     ddd¬¦  «         t          |¦  «         t          |¦  «         |                      dd¬	¦  «        }|                     ddd¬¦  «         |                     ddd ¬¦  «         t	          |¦  «         |                      d!d"¬	¦  «        }|                     ddd¬¦  «         |                     ddd#¬¦  «         |                      d$d%¬	¦  «        }	|	                     ddd¬¦  «         |	                     ddd&¬¦  «         t	          |	¦  «         |                      d'd(¬	¦  «        }
|
                     d)dd*¬¦  «         |
                     d+d,dd-¬¦  «         |
                     ddd¬¦  «         t	          |
¦  «         |                      d.d/¬	¦  «        }|                     ddd0¬¦  «         |                     ddd1¬¦  «         |                     d2d3d4¬5¦  «         |                     d6d7dd8d9¬:¦  «         |                     d;d7d<d=¬>¦  «         |                     d?d@dd8dA¬:¦  «         |                     dBd@d<dC¬>¦  «         |                     dDdEdt
          j        ¬>¦  «         |                      dFdG¬	¦  «        }|                     ddd¬¦  «         |                      dHdI¬	¦  «         |                      dJdK¬	¦  «         |                      dLdMdN¬¦  «        }|                     dOdPddQ¬>¦  «         |                     dRdSdTddU¬>¦  «         |                      dVdWdX¬¦  «        }|                     dYd8dZ¬[¦  «         |                     d\d]d8d^¬_¦  «         |                     d`dad8db¬_¦  «         |                     dcddd8de¬_¦  «         |                     |¬f¦  «         |                       dgdhdi¬¦  «        }|                     dj¬¦  «        }|                      ddk¬	¦  «        }|                     dldmdn¬[¦  «         |                     dod8dp¬[¦  «         |                     dqt          d8dr¬s¦  «         |                      d'dt¬	¦  «         |                      dudv¬	¦  «         |                     |¬f¦  «         |                     |¬f¦  «         d8S )wzCAttach 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.Ú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)Ú
subparsersr   r   r   Ú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_parserrM       s  € ð  ×*Ò*ØØ+Øbð +ñ ô €Nð
 (×6Ò6Ð<MÐ6ÑNÔNÐð %×/Ò/ØÐUð 0ñ ô €Kð ×ÒØØØØØAð ñ ô ð ð ×ÒØˆi Ð3Sð ñ ô ð ð ×ÒØØØIð ñ ô ð ð
 ×ÒØØð,ð	 ñ 	ô 	ð 	ð ×ÒØØðFð	 ñ ô ð õ ˜+Ñ&Ô&Ð&Ý˜.Ñ)Ô)Ð)ð '×1Ò1ØÐNð 2ñ ô €Mð ×ÒØØØ<ð ñ ô ð ð
 ×ÒØØØSð ñ ô ð õ
 ˜mÑ,Ô,Ð,ð &×0Ò0°Ð>TÐ0ÑUÔU€LØ×ÒØØØ<ð ñ ô ð ð
 ×ÒØØØ=ð ñ ô ð ð )×3Ò3ØÐ1ð 4ñ ô €Oð × Ò ØØØ<ð !ñ ô ð ð
 × Ò ØØØOð !ñ ô ð õ
 ˜oÑ.Ô.Ð.ð (×2Ò2°8ÐBWÐ2ÑXÔX€NØ×Ò °ÐDWÐÑXÔXÐXØ×ÒØØØØHð	  ñ ô ð ð ×ÒØØØ<ð  ñ ô ð õ
 ˜nÑ-Ô-Ð-ð )×3Ò3ØÐQð 4ñ ô €Oð × Ò  °<ÐFWÐ ÑXÔXÐXØ× Ò ØØØGð !ñ ô ð ð
 × Ò ØØØBð !ñ ô ð ð
 × Ò ØØØØØEð !ñ ô ð ð × Ò ØØØØ@ð	 !ñ ô ð ð × Ò ØØØØØFð !ñ ô ð ð × Ò ØØØØ?ð	 !ñ ô ð ð × Ò ØØØÝÔð	 !ñ ô ð ð +×5Ò5ØÐ5ð 6ñ ô Ðð ×"Ò"ØØØ<ð #ñ ô ð ð ×!Ò! &Ð/[Ð!Ñ\Ô\Ð\ð ×!Ò! 'Ð0OÐ!ÑPÔPÐPð 0×:Ò:ØØJð6ð	 ;ñ 	ô 	Ðð ×'Ò'ØØØØ:ð	 (ñ ô ð ð ×'Ò'ØØØØØ+ð (ñ ô ð ð (×2Ò2ØØ[ðZð	 3ñ ô €Nð ×ÒØØðRð	  ñ ô ð ð ×ÒØØØð2ð  ñ 	ô 	ð 	ð ×ÒØØØð)ð  ñ ô ð ð ×ÒØØØð%ð  ñ ô ð ð ×ÒÐ%7ÐÑ8Ô8Ð8ð ×(Ò(ØØ?ð.ð	 )ñ 	ô 	€Lð $×2Ò2¸Ð2ÑHÔHÐà"×-Ò-ØÐ7ð .ñ ô €Kð ×ÒØØØ\ð ñ ô ð ð
 ×ÒØØØOð ñ ô ð ð
 ×ÒØÝØØ(ð	 ñ ô ð ð ×ÒØÐ=ð  ñ ô ð ð ×ÒØÐCð  ñ ô ð ð ×Ò 9ÐÑ-Ô-Ð-Ø×Ò [ÐÑ1Ô1Ð1Ð1Ð1r   )r   r   r   r	   )r   r   r   r   r   r   r   r	   )
Ú__doc__Ú
__future__r   r   Útypingr   Úhermes_cli.subcommands._sharedr   r   rM   © r   r   ú<module>rS      sˆ   ððð ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø Ð Ð Ð Ð Ð à @Ð @Ð @Ð @Ð @Ð @ðð ð ð ðy2ð y2ð y2ð y2ð y2ð y2r   