tools.py 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. """
  2. Chatto plugin tools, registered without the Chatto adapter.
  3. Hermes defers platform plugins: a CLI or TUI session never materializes a
  4. platform, so ``register()`` — where the adapter is registered — does not run
  5. there, and tools declared only inside it are simply absent from those sessions.
  6. The ``provides_tools`` declaration in plugin.yaml asks Hermes to import this
  7. module instead and call ``register_tools(ctx)``; without it, Hermes only logs
  8. that the declared tools will be missing.
  9. The tool list itself lives in the adapter module, because that is where the
  10. handlers live. Both entry points call the same registration, so the two doors
  11. into the list cannot drift apart.
  12. """
  13. try:
  14. from .adapter import register_plugin_tools
  15. except ImportError: # pragma: no cover - loaded outside a package (tests)
  16. from adapter import register_plugin_tools
  17. __all__ = ["register_tools"]
  18. def register_tools(ctx) -> None:
  19. """Register the ``chatto-platform`` toolset with the plugin context.
  20. Entry point for Hermes' deferred-platform loader, which calls this in a
  21. session that never loads the adapter. Importing the adapter module here is
  22. deliberate: the handlers need it, and the deferred loader already imported
  23. it as this package's ``__init__`` did, so no second copy is loaded.
  24. """
  25. register_plugin_tools(ctx)