auto-sync: 2026-05-19 23:09:22

This commit is contained in:
cfdaily
2026-05-19 23:09:22 +08:00
parent 04e17cb0ed
commit 6bf0e4d39a
+37
View File
@@ -18,6 +18,10 @@ from src.daemon.spawner import AgentSpawner
from src.daemon.dispatcher import Dispatcher
from src.daemon.counter import ActiveAgentCounter
from src.daemon.router import AgentRouter, AgentProfile, LLMDriver
from src.daemon.health import HealthChecker
from src.daemon.inbox import InboxWatcher
from src.daemon.experience import ExperienceDistiller, ExperienceStore
from src.daemon.bootstrap import BootstrapBuilder
from src.utils import get_data_root
logger = logging.getLogger("moziplus-v2")
@@ -122,6 +126,10 @@ async def lifespan(app: FastAPI):
agent_timeout=daemon_config.get("agent_timeout", 600),
api_host=api_host,
api_port=api_port,
bootstrap_builder=BootstrapBuilder(
template_dir=Path(__file__).parent / "daemon" / "prompt_templates",
max_tokens=4096,
),
)
counter = ActiveAgentCounter(
max_global=daemon_config.get("max_global_agents", 5),
@@ -172,6 +180,28 @@ async def lifespan(app: FastAPI):
db_path=default_db_path,
)
# 创建集成模块
# HealthChecker
health_checker = HealthChecker(
zombie_threshold=daemon_config.get("zombie_threshold", 20),
)
# ExperienceDistiller
experience_config = config.get("experience", {})
experience_store_path = DATA_ROOT / "experiences.jsonl"
experience_distiller = ExperienceDistiller(
store=ExperienceStore(store_path=experience_store_path),
)
# InboxWatcher
inbox_config = config.get("inbox", {})
inbox_path = DATA_ROOT / inbox_config.get("path", "inbox/daemon.jsonl")
inbox_watcher = InboxWatcher(
inbox_path=inbox_path,
watch_interval=inbox_config.get("watch_interval", 1.0),
# process_callback 在 Ticker.start() 后设置(需要 ticker 引用)
)
ticker = Ticker(
registry=registry,
tick_interval=tick_interval,
@@ -180,7 +210,14 @@ async def lifespan(app: FastAPI):
max_dispatch_per_tick=max_dispatch,
claim_timeout_minutes=claim_timeout,
default_task_timeout_minutes=task_timeout,
health_checker=health_checker,
inbox_watcher=inbox_watcher,
experience_distiller=experience_distiller,
)
# 绑定 InboxWatcher 回调(需要 ticker 引用)
inbox_watcher.process_callback = ticker._on_inbox_event
await ticker.start()
agent_ids = list(agent_profiles.keys())
logger.info("Ticker started (interval=%ss, dispatch=%d/tick, agents=%s, llm=%s)",