Rebase onto upstream (a4d95fd) #12

Closed
wylab wants to merge 144 commits from rebase-onto-upstream into main
2 changed files with 31 additions and 1 deletions
Showing only changes of commit 41f8381138 - Show all commits
+5
View File
@@ -149,6 +149,11 @@ class ChannelManager:
except ImportError as e:
logger.warning("Matrix channel not available: {}", e)
def register_channel(self, name: str, channel: BaseChannel) -> None:
"""Register an external channel."""
self.channels[name] = channel
logger.info(f"{name} channel registered")
async def _start_channel(self, name: str, channel: BaseChannel) -> None:
"""Start a channel and log any exceptions."""
try:
+26 -1
View File
@@ -366,7 +366,28 @@ def gateway(
interval_s=hb_cfg.interval_s,
enabled=hb_cfg.enabled,
)
# Create hooks server
from nanobot.hooks.server import HooksServer
from nanobot.channels.hook import HookChannel
hooks_config = config.hooks if hasattr(config, 'hooks') else None
hooks_server = None
if hooks_config and hooks_config.enabled and hooks_config.has_tokens:
# Register hook channel
hook_channel = HookChannel(bus)
channels.register_channel("hook", hook_channel)
# Create hooks server
hooks_server = HooksServer(
host=config.gateway.host,
port=config.gateway.port,
config=hooks_config,
bus=bus,
)
console.print(f"[green]✓[/green] Hooks: {hooks_config.path} on port {config.gateway.port}")
if channels.enabled_channels:
console.print(f"[green]✓[/green] Channels enabled: {', '.join(channels.enabled_channels)}")
else:
@@ -382,6 +403,8 @@ def gateway(
try:
await cron.start()
await heartbeat.start()
if hooks_server:
await hooks_server.start()
await asyncio.gather(
agent.run(),
channels.start_all(),
@@ -389,6 +412,8 @@ def gateway(
except KeyboardInterrupt:
console.print("\nShutting down...")
finally:
if hooks_server:
await hooks_server.stop()
await agent.close_mcp()
heartbeat.stop()
cron.stop()