egress.py 1.2 KB

12345678910111213141516171819202122232425262728
  1. """``hermes egress`` subcommand parser."""
  2. from __future__ import annotations
  3. def build_egress_parser(subparsers) -> None:
  4. """Attach the ``egress`` subcommand to ``subparsers``."""
  5. # OUTBOUND egress firewall (iron-proxy); `hermes proxy` is the separate INBOUND
  6. # OAuth-aggregator reverse proxy.
  7. egress_parser = subparsers.add_parser(
  8. "egress", help="Manage the iron-proxy egress credential-injection firewall",
  9. description="Manage iron-proxy, the optional TLS-intercepting egress firewall "
  10. "that swaps proxy tokens for real API credentials before outbound "
  11. "requests leave a sandbox. Disabled by default. See: "
  12. "https://hermes-agent.nousresearch.com/docs/user-guide/egress/iron-proxy")
  13. from hermes_cli import proxy_cli as _proxy_cli
  14. _proxy_cli.register_cli(egress_parser)
  15. def _dispatch_egress(args):
  16. # dest='egress_command' stays disjoint from ``hermes proxy`` (dest='proxy_command').
  17. sub = getattr(args, "egress_command", None)
  18. if sub is not None and hasattr(args, "func") and args.func is not _dispatch_egress:
  19. return args.func(args)
  20. egress_parser.print_help()
  21. return 0
  22. egress_parser.set_defaults(func=_dispatch_egress)