Rebase onto upstream (a4d95fd) #12

Closed
wylab wants to merge 144 commits from rebase-onto-upstream into main
2 changed files with 25 additions and 20 deletions
Showing only changes of commit d5283e9b10 - Show all commits
+8 -3
View File
@@ -1,11 +1,16 @@
"""Heartbeat service - periodic agent wake-up to check for tasks."""
from __future__ import annotations
import asyncio
from pathlib import Path
from typing import Any, Callable, Coroutine
from typing import TYPE_CHECKING, Any, Callable, Coroutine
from loguru import logger
if TYPE_CHECKING:
from nanobot.session.manager import SessionManager
# Default interval: 30 minutes
DEFAULT_HEARTBEAT_INTERVAL_S = 30 * 60
@@ -49,7 +54,7 @@ class HeartbeatService:
on_heartbeat: Callable[[str, dict[str, Any] | None], Coroutine[Any, Any, str]] | None = None,
interval_s: int = DEFAULT_HEARTBEAT_INTERVAL_S,
enabled: bool = True,
session_manager: "SessionManager | None" = None,
session_manager: SessionManager | None = None,
target_session_key: str = "telegram:239824268",
idle_threshold_s: int = 30 * 60, # 30 minutes
):
@@ -145,7 +150,7 @@ class HeartbeatService:
if self.on_heartbeat:
try:
# Call with suppress_output metadata
response = await self.on_heartbeat(
await self.on_heartbeat(
HEARTBEAT_PROMPT,
metadata={"suppress_output": True}
)
+4 -4
View File
@@ -1,11 +1,11 @@
# tests/test_heartbeat_idle.py
import pytest
import asyncio
from pathlib import Path
from datetime import datetime, timedelta
from pathlib import Path
import pytest
from nanobot.heartbeat.service import HeartbeatService
from nanobot.session.manager import SessionManager
from unittest.mock import AsyncMock, MagicMock
@pytest.mark.asyncio