Ассистент: мягкий отбор сообщений Daily Log/проектов в общем канале, повтор сводки по реальному ts
Some checks failed
ci / test (push) Failing after 38s
ci / deploy (push) Has been skipped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-29 08:52:57 +03:00
parent 24fed3d5a1
commit 1b12fbf538
7 changed files with 63 additions and 13 deletions

View File

@@ -4,7 +4,7 @@ import { loadFragment } from "../agents/prompts.js";
import { pauseState } from "../pause.js";
import { promptSideFor } from "../agents/session.js";
import { getRecapState, recapDelayMs } from "./recap.js";
import { isDailySummary, summaryContextFor } from "./daily-summary.js";
import { summaryContextFor } from "./daily-summary.js";
import { handleManagerMessages, type ChatDeps, type IncomingMessage, type ManagerInfo, type ProjectContext } from "./chat.js";
interface Pending {
@@ -118,19 +118,21 @@ export class SlackIntake {
const user = String(ev.user ?? "");
if (ev.bot_id || !user || user === "USLACKBOT" || !ACCEPTED_SUBTYPES.has(ev.subtype as string | undefined)) return;
const text = String(ev.text ?? "");
if (!isDailySummary(text)) return;
if (text.trim().length < 15) return;
const manager = await this.findManagerBySlackUser(user);
if (!manager || manager.chatKind === "accounting") {
this.deps.ctx.log.warn({ channel, user }, "сводка Daily Log от человека без чата ассистента - пропущена");
return;
}
if (await this.isOff(manager.personId)) return;
// мягкий фильтр: по смыслу сообщение про Daily Log или проекты (грубо, окончательно решает агент)
const summary = await summaryContextFor(this.pool, this.deps.timezone, { channel, ts, text, senderName: manager.name });
if (!summary.relevant) return;
const ins = await this.pool.query(
"insert into slack_message_log (channel_id, message_ts, manager_person_id, has_files, status, sender_slack_user_id) values ($1,$2,$3,false,'received',$4) on conflict do nothing returning message_ts",
[channel, ts, manager.personId, user],
);
if (!ins.rowCount) return; // дубль
const summary = await summaryContextFor(this.pool, this.deps.timezone, { channel, ts, text, senderName: manager.name });
const setStatus = (status: string) => this.pool.query("update slack_message_log set status = $3, processed_at = case when $3 in ('done','failed') then now() else null end where channel_id = $1 and message_ts = $2", [channel, ts, status]);
this.track(
(async () => {