Шаг 4: история напоминаний, запрос "что-то ещё" по таймеру, язык ответа; тесты; docs/proposed
All checks were successful
ci / test (push) Successful in 14s
ci / deploy (push) Successful in 1m8s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 23:41:13 +03:00
parent 27b9842894
commit 8c2cd65498
23 changed files with 162 additions and 44 deletions

View File

@@ -61,6 +61,17 @@ export async function handleManagerMessages(
const mediaDir = join(managerWorkDir(ctx.settings, manager.personId), "media", sub);
mkdirSync(mediaDir, { recursive: true });
// история напоминаний (вход 7): ответ менеджера закрывает последнее неотвеченное напоминание
if (messages.length && !opts.systemEvent) {
await ctx.pool.query(
`update reminder_history set reply_at = now(), reply_summary = left($2, 500), reply_outcome = 'other'
where id = (select r.id from reminder_history r join assistant_project ap on ap.id = r.assistant_project_id
where ap.manager_person_id = $1 and r.reply_at is null and r.reminded_at > now() - interval '1 day'
order by r.reminded_at desc limit 1)`,
[manager.personId, messages.map((m) => m.text).join(" ").trim() || "(вложения)"],
);
}
// 1. вложения -> локальная папка
const attachments: ChatResult["attachments"] = [];
const perMessage = new Map<string, string[]>();
@@ -154,6 +165,14 @@ export async function handleManagerMessages(
const reply = /^\(без ответа\)\.?$/i.test(replyRaw) ? null : replyRaw;
let published = false;
if (reply && channel && !deps.dryPublish) published = await deps.slack.postMessage(channel, reply);
if (reply && opts.systemEvent) {
// напоминание ассистента по событию - в историю напоминаний (вход 7)
await ctx.pool.query(
`insert into reminder_history (assistant_project_id, reminded_at, reminder_text)
select ap.id, now(), left($2, 1000) from assistant_project ap where ap.manager_person_id = $1 and ap.is_enabled order by ap.created_at limit 1`,
[manager.personId, reply],
);
}
// 6. транскрипты и итоговые файлы -> Drive
if (deps.drive && attachments.length) await deps.drive.upload(mediaDir, sub).catch((e) => ctx.log.warn({ err: String(e) }, "повторная выгрузка в Drive не удалась"));