gui.py 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. """``hermes gui`` subcommand parser."""
  2. from __future__ import annotations
  3. from typing import Callable
  4. def build_gui_parser(subparsers, *, cmd_gui: Callable) -> None:
  5. """Attach the ``gui`` subcommand to ``subparsers``."""
  6. gui_parser = subparsers.add_parser(
  7. "desktop", aliases=["gui"], help="Build and launch the native desktop app",
  8. description="Launch the Hermes Electron desktop app. By default this installs "
  9. "workspace Node dependencies, builds the current OS's unpacked "
  10. "Electron app, then launches that packaged artifact.")
  11. gui_parser.add_argument(
  12. "--source", action="store_true",
  13. help="Launch via `electron .` against apps/desktop/dist instead of the packaged app")
  14. gui_parser.add_argument(
  15. "--build-only", action="store_true",
  16. help="Build the desktop app but do not launch it (used by the installer's --update flow)")
  17. gui_parser.add_argument(
  18. "--fake-boot", action="store_true",
  19. help="Enable deterministic desktop boot delays for validating startup UI")
  20. gui_parser.add_argument(
  21. "--ignore-existing", action="store_true",
  22. help="Skip the installed Hermes runtime (~/.hermes/hermes-agent) so no local "
  23. "backend starts and Desktop offers connect or install instead. --hermes-root "
  24. "and the bundled runtime still win; a runtime installed during this launch is used.")
  25. gui_parser.add_argument(
  26. "--hermes-root",
  27. help="Override the Hermes source root used by Desktop (sets HERMES_DESKTOP_HERMES_ROOT)")
  28. gui_parser.add_argument(
  29. "--cwd",
  30. help="Initial project directory for Desktop chat sessions (sets HERMES_DESKTOP_CWD)")
  31. gui_parser.add_argument(
  32. "--skip-build", action="store_true",
  33. help="Skip npm install/package and launch the existing unpacked app from apps/desktop/release",
  34. )
  35. gui_parser.add_argument(
  36. "--local", action="store_true",
  37. help="Show the local-models UI in the desktop app (models pane, quickstart, picker rows)")
  38. gui_parser.add_argument(
  39. "--force-build", action="store_true",
  40. help="Force a full rebuild even if the content stamp matches")
  41. gui_parser.add_argument(
  42. "--setup-tcc-identity", action="store_true",
  43. help="macOS only: create/import a self-signed code-signing certificate "
  44. "in the login keychain and point desktop.macos_signing_identity at "
  45. "it, then re-sign the packaged app. Makes macOS TCC grants (Full "
  46. "Disk Access, Accessibility, Files and Folders, microphone) survive "
  47. "rebuilds with a certificate-anchored identity. Idempotent — safe "
  48. "to re-run after updates.")
  49. gui_parser.add_argument(
  50. "--identity", default="Hermes Local Signing",
  51. help="Certificate name to create/use for --setup-tcc-identity (default: Hermes Local Signing)",
  52. )
  53. gui_parser.add_argument(
  54. "--install-apparmor-profile", action="store_true",
  55. help="Linux only: install an AppArmor profile (sudo) that lets the packaged app use Chromium's "
  56. "user-namespace sandbox on hosts with kernel.apparmor_restrict_unprivileged_userns=1 "
  57. "(Ubuntu 23.10+), then exit. Survives rebuilds of the same checkout.")
  58. gui_parser.add_argument(
  59. "--close-preview",
  60. action="store_true",
  61. help="Close the preview pane and exit its fullscreen (out-of-band escape hatch when the pane captured all input)",
  62. )
  63. gui_parser.set_defaults(func=cmd_gui)