__init__.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. """google_meet plugin — let the agent join a Meet call, transcribe it, follow up.
  2. Headless Chromium (Playwright) joins the URL, enables live captions and scrapes them into a
  3. transcript. Realtime mode adds agent speech (OpenAI Realtime + virtual audio device); remote
  4. nodes run the bot on another machine. Explicit-by-design: only joins ``https://meet.google.com/``
  5. URLs passed in — no calendar scanning, auto-dial or consent announcement.
  6. """
  7. from __future__ import annotations
  8. import logging
  9. import platform
  10. from plugins.google_meet import process_manager as pm
  11. from plugins.google_meet.cli import meet_command as _meet_command, register_cli as _register_meet_cli
  12. from plugins.google_meet.tools import (
  13. MEET_JOIN_SCHEMA, MEET_LEAVE_SCHEMA, MEET_SAY_SCHEMA, MEET_STATUS_SCHEMA, MEET_TRANSCRIPT_SCHEMA,
  14. check_meet_requirements, handle_meet_join, handle_meet_leave, handle_meet_say, handle_meet_status,
  15. handle_meet_transcript)
  16. logger = logging.getLogger(__name__)
  17. _TOOLS = (
  18. ("meet_join", MEET_JOIN_SCHEMA, handle_meet_join, "📞"),
  19. ("meet_status", MEET_STATUS_SCHEMA, handle_meet_status, "🟢"),
  20. ("meet_transcript", MEET_TRANSCRIPT_SCHEMA, handle_meet_transcript, "📝"),
  21. ("meet_leave", MEET_LEAVE_SCHEMA, handle_meet_leave, "👋"),
  22. ("meet_say", MEET_SAY_SCHEMA, handle_meet_say, "🗣️"))
  23. def _on_session_end(**kwargs) -> None:
  24. """Leave a still-running call so we don't orphan a headless Chromium (never raises)."""
  25. try:
  26. status = pm.status()
  27. if status.get("ok") and status.get("alive"):
  28. pm.stop(reason="session ended")
  29. except Exception as e: # pragma: no cover — defensive
  30. logger.debug("google_meet on_session_end cleanup failed: %s", e)
  31. def register(ctx) -> None:
  32. """Register tools, CLI, and lifecycle hooks (called once by the plugin loader)."""
  33. # Windows: no tested audio-routing path and flaky guest-join Chromium — refuse rather than half-work.
  34. system = platform.system().lower()
  35. if system not in {"linux", "darwin"}:
  36. logger.info("google_meet plugin: platform=%s not supported (linux/macos only)", system)
  37. return
  38. for name, schema, handler, emoji in _TOOLS:
  39. ctx.register_tool(name=name, toolset="google_meet", schema=schema, handler=handler,
  40. check_fn=check_meet_requirements, emoji=emoji)
  41. ctx.register_cli_command(
  42. name="meet", help="Google Meet bot (join, transcribe, follow up)",
  43. setup_fn=_register_meet_cli, handler_fn=_meet_command,
  44. description=("Let the hermes agent join a Google Meet call and scrape live "
  45. "captions into a transcript. See: hermes meet setup"))
  46. ctx.register_hook("on_session_end", _on_session_end)