Агенты: нет задач у менеджера - шаг 2 не запускается, напоминания и обращения в ИТ не пишутся (deviations п.75)
All checks were successful
ci / test (push) Successful in 30s
ci / deploy (push) Successful in 2m23s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-03 20:06:21 +03:00
parent 50985de683
commit 53027f75de
6 changed files with 61 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
import { basename, join } from "node:path";
import { createLogger, createPool, itNotify, loadServiceSettings } from "khb_common";
import { createLogger, createPool, itNotify, loadServiceSettings, localDate } from "khb_common";
import { managerHasTasks } from "./inputs/has-tasks.js";
import { createCliRunner } from "./agents/cli-runner.js";
import { summarizeIdle } from "./agents/idle-memory.js";
import { createLiveRunner } from "./agents/live-runner.js";
@@ -87,7 +88,13 @@ const chat = chatDeps
const title = EVENT_TITLE[kind];
if (!title) throw new Error(`неизвестное событие ${kind}`);
const out = [];
const today = localDate(new Date(), common.timezone);
for (const m of await managers(service.modes)) {
if (!(await managerHasTasks(pool, m.personId, today))) {
log.info({ manager: m.name, kind }, "у менеджера нет задач - напоминание не отправляется");
out.push({ manager: m.name, skipped: "no_tasks" });
continue;
}
const systemEvent = loadFragment("p-chat-events.md", title, {}, promptSideFor(ctx, m.personId));
out.push(await handleManagerMessages(chatDeps, m, [], { systemEvent }).catch((e) => ({ error: String(e) })));
}