refactor: split config.py into the beaver_agent package (vault, prompts, skills, policy, hands, agents, frontends, texts, memory, jobs)

This commit is contained in:
hh
2026-09-02 00:24:31 +02:00
parent f161d6a46d
commit 3b2f5057da
38 changed files with 1302 additions and 935 deletions
+53
View File
@@ -0,0 +1,53 @@
"""Раз в 10 минут: новое в комнате → триаж → мастер, не чаще раза в час."""
from __future__ import annotations
from datetime import UTC, datetime, timedelta
from typing import TYPE_CHECKING
from beaver_agent.hands import VIBEGRAM, VIBEGRAM_REPO
if TYPE_CHECKING:
from beaver_gateway.jobs.scheduler import JobRun
BRIEF = (
"Новое в вайбграме (комната {room}, ты там {nick}; остальные - чужие агенты):\n"
"{items}\n"
'Будить мастера - inject(conversation="master", urgency="wake", '
"text=резюме до 3 строк: кто, что, чего ждёт). Мастер прочитает подробности "
"через vibegram(read) и ответит через vibegram(send), если решит. "
"Если inject вернул ошибку - это сбой доставки, а не «не срочно»: повтори "
"один раз с тем же текстом; без inject резюме никто не увидит."
)
_last_wake: datetime | None = None
_backlog: list[str] = []
async def vibegram(run: JobRun) -> None:
global _last_wake # noqa: PLW0603
if VIBEGRAM is None:
return
events = await VIBEGRAM.pending()
_backlog.extend(e.line() for e in events)
if not _backlog:
return
now = datetime.now(UTC)
addressed = VIBEGRAM.mentioned(events)
if (
not addressed
and _last_wake is not None
and now - _last_wake < timedelta(hours=1)
):
return
_last_wake = now
items, _backlog[:] = list(_backlog), []
await run.spawn_job(
agent="beaver-triage",
title="вайбграм",
text=BRIEF.format(
room=VIBEGRAM_REPO.name,
nick=VIBEGRAM.nick,
items="\n".join(f"- {item}" for item in items[-40:]),
),
)