Промты согласованы и установлены всем менеджерам: recap, Control todo (миграция 023, ControlWatcher), fallback на английском; tasks.md очищен
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import { buildApi } from "./http-api.js";
|
||||
import { listManagers } from "./managers.js";
|
||||
import { pauseState } from "./pause.js";
|
||||
import { handleManagerMessages } from "./slack/chat.js";
|
||||
import { ControlWatcher } from "./slack/control.js";
|
||||
import type { DriveClient } from "./gdrive/client.js";
|
||||
import { DriveInbox } from "./slack/drive-inbox.js";
|
||||
import { SlackIntake } from "./slack/intake.js";
|
||||
@@ -670,4 +671,50 @@ d("консольные агенты (временная БД, фейковый
|
||||
expect(liveCalls[3]!.prompt).not.toContain("AI huddle notes are ready");
|
||||
});
|
||||
|
||||
it("Control todo: пара пишется из раздела вывода; исполнитель закрыл - «выполнено», после срока без действий - «просрочено»; статусы меняются", async () => {
|
||||
const nl = String.fromCharCode(10);
|
||||
const texts: string[] = [
|
||||
["## Ответ менеджеру", "(без ответа)", "## Control todo", "CTRLcccccc03 EXECcccccc03 2026-10-25", "## Память", "м-control-1"].join(nl),
|
||||
["## Ответ менеджеру", "Walter closed the tile todo - you can close your Control todo. No action on the plumber todo for 2 days - marked overdue.", "## Память", "м-control-2"].join(nl),
|
||||
];
|
||||
const liveCalls: ClaudeCall[] = [];
|
||||
const liveRunner = {
|
||||
run: async (c: ClaudeCall) => { liveCalls.push(c); return { text: texts.shift()!, sessionId: c.sessionId }; },
|
||||
isActive: () => false, activeSession: () => null, close: () => undefined, closeAll: () => undefined, activeCount: () => 0,
|
||||
};
|
||||
const base = ctx();
|
||||
const live = { ...base, liveRunner, settings: { ...base.settings, live: { managerIds: [MGR], idleMinutes: 10, warmupSeconds: 0 } } };
|
||||
const posted: string[] = [];
|
||||
const slack = { postMessage: async (_c: string, t: string) => { posted.push(t); return true; }, fileInfo: async () => null, download: async () => 0 };
|
||||
const mgr = { personId: MGR, name: "llmtest-Manager", slackUserId: "ULLMTEST", slackChannelId: "CLLMTEST" };
|
||||
const noon = new Date("2026-10-21T16:00:00Z");
|
||||
const deps = { ctx: live, timezone: "America/New_York", slack, now: () => noon };
|
||||
// 1. агент вывел пару - она записана
|
||||
await handleManagerMessages({ ...deps, dryPublish: true }, mgr, [{ channel: "CLLMTEST", ts: "1791741800.000001", text: "I noticed missing conduit", fileIds: [] }]);
|
||||
const saved = (await db.pool.query("select executor_task_id, to_char(control_due,'YYYY-MM-DD') d, status from control_todo where control_task_id = 'CTRLcccccc03'")).rows[0];
|
||||
expect(saved).toEqual({ executor_task_id: "EXECcccccc03", d: "2026-10-25", status: "active" });
|
||||
// 2. две другие пары: исполнитель закрыл todo (событие JobTread) и срок Control todo прошёл без действий
|
||||
await db.pool.query("insert into control_todo (controller_person_id, executor_task_id, control_task_id, executor_name, control_due) values ($1,'EXECaaaaaa01','CTRLaaaaaa01','Order tile','2026-10-30'), ($1,'EXECbbbbbb02','CTRLbbbbbb02','Call plumber','2026-10-20')", [MGR]);
|
||||
await db.pool.query("insert into jt_event (id, type, created_at, task_id, kind) values ('llmtest-ev-ctl-1', 'taskUpdated', now(), 'EXECaaaaaa01', 'todo_closed')");
|
||||
const watcher = new ControlWatcher(deps, { loadManager: async () => mgr, intervalMs: 0 });
|
||||
expect(await watcher.tick()).toBe(1);
|
||||
const prompt = liveCalls[1]!.prompt;
|
||||
expect(prompt).toContain("ВЫПОЛНЕНО: исполнитель закрыл todo EXECaaaaaa01 «Order tile». Control todo CTRLaaaaaa01");
|
||||
expect(prompt).toContain("ПРОСРОЧЕНО: по todo исполнителя EXECbbbbbb02 «Call plumber»");
|
||||
expect(prompt).not.toContain("EXECcccccc03"); // срок 10/25 ещё не наступил (сегодня 10/21)
|
||||
const st = (await db.pool.query("select control_task_id, status from control_todo order by control_task_id")).rows;
|
||||
expect(st).toEqual([{ control_task_id: "CTRLaaaaaa01", status: "done" }, { control_task_id: "CTRLbbbbbb02", status: "overdue" }, { control_task_id: "CTRLcccccc03", status: "active" }]);
|
||||
expect(posted).toHaveLength(1);
|
||||
// 3. повторная проверка ничего не шлёт; ночью (вне окна 7-19 по Тампе) тоже
|
||||
expect(await watcher.tick()).toBe(0);
|
||||
const night = new ControlWatcher({ ...deps, now: () => new Date("2026-10-21T05:00:00Z") }, { loadManager: async () => mgr, intervalMs: 0 });
|
||||
expect(await night.tick()).toBe(0);
|
||||
// 4. исполнитель после «просрочено» всё же закрыл todo - снова сообщение, статус done
|
||||
texts.push(["## Ответ менеджеру", "Plumber todo is done now.", "## Память", "м-control-3"].join(nl));
|
||||
await db.pool.query("insert into jt_event (id, type, created_at, task_id, kind) values ('llmtest-ev-ctl-2', 'taskUpdated', now(), 'EXECbbbbbb02', 'todo_closed')");
|
||||
expect(await watcher.tick()).toBe(1);
|
||||
expect(liveCalls[2]!.prompt).toContain("ВЫПОЛНЕНО: исполнитель закрыл todo EXECbbbbbb02");
|
||||
expect((await db.pool.query("select status from control_todo where control_task_id = 'CTRLbbbbbb02'")).rows[0].status).toBe("done");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -16,6 +16,7 @@ import { createTokenProvider, parseServiceAccountKey } from "./gdrive/service-ac
|
||||
import { createGoogleDrive } from "./slack/drive.js";
|
||||
import { DriveInbox } from "./slack/drive-inbox.js";
|
||||
import { SlackIntake, rowToManager } from "./slack/intake.js";
|
||||
import { ControlWatcher } from "./slack/control.js";
|
||||
import { createGoogleTts } from "./slack/tts.js";
|
||||
|
||||
const { common, service } = loadServiceSettings("khbuild_assistant_prep", assistantPrepSchema);
|
||||
@@ -107,6 +108,8 @@ log.info({ port: service.http.port }, "khbuild_assistant_prep запущен");
|
||||
|
||||
if (service.slack && chatDeps) {
|
||||
const intake = new SlackIntake(chatDeps, { channelIds: service.slack.channelIds, debounceMs: service.slack.debounceSeconds * 1000, followupMs: service.slack.followupMinutes * 60_000, recapSilenceMs: service.slack.recapSilenceMinutes * 60_000, recapFromHour: service.slack.recapFromHour, recapToHour: service.slack.recapToHour });
|
||||
if (service.slack.controlCheckMinutes > 0)
|
||||
new ControlWatcher(chatDeps, { loadManager: (id) => intake.findManagerByPerson(id), intervalMs: service.slack.controlCheckMinutes * 60_000, fromHour: service.slack.recapFromHour, toHour: service.slack.recapToHour }).start();
|
||||
void intake.restoreRecapTimers().catch((e) => log.error({ err: String(e) }, "восстановление таймеров recap не удалось"));
|
||||
startSocketMode({ appToken: service.slack.appToken, log, onEvent: (ev) => void intake.onEvent(ev).catch((e) => log.error({ err: String(e) }, "ошибка приёма события Slack")) });
|
||||
if (service.drive && driveClient && service.drive.inboxScanSeconds > 0) {
|
||||
|
||||
@@ -30,7 +30,7 @@ const FRAGMENTS: Record<string, Record<string, string[]>> = {
|
||||
/** Только новая версия агента (proposed). */
|
||||
const LIVE_FRAGMENTS: Record<string, Record<string, string[]>> = {
|
||||
"p-long-living-agents.md": { "Продолжение диалога": [], "Правила долгоживущего агента": [], "Todo менеджера": ["membership"] },
|
||||
"p-chat-events.md": { "Беседа в проектном канале затихла": [] },
|
||||
"p-chat-events.md": { "Беседа в проектном канале затихла": [], "Control: исполнитель закрыл или просрочил": ["changes"] },
|
||||
"p-chat-environment.md": { "Менеджер": ["name", "mention"], "Частота сообщений": ["last_assistant", "last_human", "unanswered", "assistant_today", "replied_today"] },
|
||||
};
|
||||
|
||||
@@ -123,7 +123,7 @@ describe("промты в docs модуля (p-*.md)", () => {
|
||||
});
|
||||
|
||||
it("todo-напоминание: на самого говорящего, срок 3 рабочих дня, без вопросов «кто и когда» (proposed)", () => {
|
||||
for (const name of ["p-manager-dialog.md", "p-project-channel.md", "p-ceo-assistant.md"]) {
|
||||
for (const name of ["p-manager-dialog.md", "p-project-channel.md"]) {
|
||||
const t = loadPrompt(name, { media_dir: "/m" }, "proposed");
|
||||
expect(t, name).toContain("через 3 рабочих дня");
|
||||
expect(t, name).toContain("Reminder: Did");
|
||||
@@ -141,6 +141,12 @@ describe("промты в docs модуля (p-*.md)", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("ассистент руководителя (proposed): замечание Arthur - todo менеджеру проекта и todo-напоминание Arthur на 2 дня позже", () => {
|
||||
const t = loadPrompt("p-ceo-assistant.md", { media_dir: "/m" }, "proposed");
|
||||
for (const part of ["## Замечания Arthur на объектах", "менеджер по стройке соответствующего проекта", "на 2 дня позже срока todo менеджера", "Control: Ask <менеджер> if", "`## Control todo`", "(выполнено)", "(просрочено)", "Reminder: Did", "через 3 рабочих дня", "More than 3 weeks ago", "Keep confirmed"])
|
||||
expect(t, part).toContain(part);
|
||||
});
|
||||
|
||||
it("Huddle: правило про заметки и расшифровку есть у менеджера и руководителя (proposed)", () => {
|
||||
for (const name of ["p-manager-dialog.md", "p-ceo-assistant.md"]) {
|
||||
const t = loadPrompt(name, { media_dir: "/m" }, "proposed");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { formatChannelDialog, loadChannelDialog, parseReactions, parseRecapStatus, recapBlock, recapDelayMs, sectionText, stampLocal } from "./slack/recap.js";
|
||||
import { normalizeHuddleEvent } from "./slack/intake.js";
|
||||
import { parseControlTodos } from "./slack/control.js";
|
||||
|
||||
const TZ = "America/New_York";
|
||||
|
||||
@@ -86,3 +87,14 @@ describe("Huddle в Slack", () => {
|
||||
expect(normalizeHuddleEvent(plain)).toBe(plain);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Control todo: раздел вывода агента", () => {
|
||||
it("строки «<id Control todo> <id todo исполнителя> [срок]»; пустое и мусор пропускаются", () => {
|
||||
expect(parseControlTodos("22PgkWLRQESe 22PgkWLc75kU 2026-10-29\n- 22Ph5jFdKVdE 22Ph5jFj9Ah5\nнет")).toEqual([
|
||||
{ controlTaskId: "22PgkWLRQESe", executorTaskId: "22PgkWLc75kU", controlDue: "2026-10-29" },
|
||||
{ controlTaskId: "22Ph5jFdKVdE", executorTaskId: "22Ph5jFj9Ah5", controlDue: null },
|
||||
]);
|
||||
expect(parseControlTodos("нет")).toEqual([]);
|
||||
expect(parseControlTodos(undefined)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,6 +50,8 @@ export const slackSchema = z.object({
|
||||
/** Часы по Тампе, когда можно задавать вопрос про Daily Log (остальное откладывается до начала окна). */
|
||||
recapFromHour: z.number().default(7),
|
||||
recapToHour: z.number().default(19),
|
||||
/** Как часто (минуты) проверять пары "todo исполнителя - Control todo"; 0 - не проверять. Сообщения контролёру - только в окне recapFromHour-recapToHour по Тампе. */
|
||||
controlCheckMinutes: z.number().default(30),
|
||||
});
|
||||
export type SlackSettings = z.infer<typeof slackSchema>;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { loadFragment, loadPrompt, type PromptSide } from "../agents/prompts.js"
|
||||
import { saveProblems } from "../agents/step2.js";
|
||||
import type { DriveSync } from "./drive.js";
|
||||
import type { SlackApi } from "./api.js";
|
||||
import { parseControlTodos, saveControlTodos } from "./control.js";
|
||||
import { applyRecapOutput, getRecapState, loadChannelDialog, parseReactions, recapBlock } from "./recap.js";
|
||||
import { saveChatTiming, type ChatTiming } from "./timing.js";
|
||||
import { normalizeVoice, speechText, type ReplyMode, type Tts } from "./tts.js";
|
||||
@@ -276,7 +277,7 @@ export async function handleManagerMessages(
|
||||
const listText = isCeo ? "" : await todayList(ctx, manager.personId, today);
|
||||
// проектный канал: диалог за сутки с временем (по Тампе) и накопленное для Daily Log
|
||||
const channelBlocks: string[] = [];
|
||||
const recapOn = !!proj && !!channel && live; // тихий режим и recap - только новая версия агента (промты proposed)
|
||||
const recapOn = !!proj && !!channel; // тихий режим и recap проектных каналов - у всех менеджеров (промты согласованы, approved = proposed)
|
||||
if (recapOn && proj && channel) {
|
||||
const dialogText = await loadChannelDialog(deps.slack, channel, now, deps.timezone);
|
||||
const st = await getRecapState(ctx.pool, channel);
|
||||
@@ -326,7 +327,7 @@ ${recapBlock(st, deps.timezone)}`);
|
||||
await saveChatTiming(ctx.pool, tm, ctx.log);
|
||||
ctx.log.error({ manager: manager.personId, err }, "шаг 4 не удался");
|
||||
await ctx.notifyIt(`:warning: khbuild_assistant_prep: шаг 4 (общение) для ${manager.name} не выполнен: ${err.slice(0, 500)}`);
|
||||
if (!deps.dryPublish && channel) await deps.slack.postMessage(channel, "Не смог обработать сообщение - уже сообщил ИТ-команде, скоро разберёмся.");
|
||||
if (!deps.dryPublish && channel) await deps.slack.postMessage(channel, "Sorry, I could not process your message. The IT team has been notified and will sort it out soon.");
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -338,6 +339,9 @@ ${recapBlock(st, deps.timezone)}`);
|
||||
if (!deps.dryPublish && deps.slack.addReaction)
|
||||
for (const r of parseReactions(out.sections.get("реакции"))) await deps.slack.addReaction(channel, r.ts, r.emoji).catch((e) => ctx.log.warn({ err: String(e) }, "реакция не поставлена"));
|
||||
}
|
||||
// "Control:" todo: агент записал пары (todo исполнителя - парное todo контролёра) - дальше за ними следит ControlWatcher
|
||||
const controlPairs = parseControlTodos(out.sections.get("control todo"));
|
||||
if (controlPairs.length) await saveControlTodos(ctx.pool, manager.personId, controlPairs);
|
||||
const replyRaw = out.sections.get(replyKey)!;
|
||||
const reply = /^\(без ответа\)\.?$/i.test(replyRaw) ? null : replyRaw;
|
||||
let published = false;
|
||||
|
||||
143
packages/khbuild_assistant_prep/src/slack/control.ts
Normal file
143
packages/khbuild_assistant_prep/src/slack/control.ts
Normal file
@@ -0,0 +1,143 @@
|
||||
import { localDate, type Pool } from "khb_common";
|
||||
import { loadFragment } from "../agents/prompts.js";
|
||||
import { promptSideFor } from "../agents/session.js";
|
||||
import { pauseState } from "../pause.js";
|
||||
import { handleManagerMessages, type ChatDeps, type ManagerInfo } from "./chat.js";
|
||||
import { recapDelayMs } from "./recap.js";
|
||||
|
||||
/**
|
||||
* "Control:" todo: исполнителю поставили задачу, контролёр (например CEO) получил парное todo "Control: ...".
|
||||
* Агент записывает пару в раздел вывода `## Control todo`; сервис следит за исполнителем и будит агента контролёра, когда
|
||||
* исполнитель закрыл todo ("(выполнено)") или после срока 2 дня не было действий ("(просрочено)").
|
||||
*/
|
||||
|
||||
export interface ControlPair {
|
||||
controlTaskId: string;
|
||||
executorTaskId: string;
|
||||
/** Срок Control todo (YYYY-MM-DD); null - срок не указан, "просрочено" не ставится. */
|
||||
controlDue: string | null;
|
||||
}
|
||||
|
||||
const ID = "[A-Za-z0-9]{8,16}";
|
||||
|
||||
/** Раздел `## Control todo`: строки `<id Control todo> <id todo исполнителя> [YYYY-MM-DD]`; прочее пропускается. */
|
||||
export function parseControlTodos(v: string | undefined): ControlPair[] {
|
||||
const out: ControlPair[] = [];
|
||||
for (const line of (v ?? "").split(/\r?\n/)) {
|
||||
const m = line.match(new RegExp(`(${ID})\\s+(${ID})(?:\\s+(\\d{4}-\\d{2}-\\d{2}))?`));
|
||||
if (m && m[1] !== m[2]) out.push({ controlTaskId: m[1]!, executorTaskId: m[2]!, controlDue: m[3] ?? null });
|
||||
}
|
||||
return out.slice(0, 20);
|
||||
}
|
||||
|
||||
export async function saveControlTodos(pool: Pool, controllerId: string, pairs: ControlPair[]): Promise<void> {
|
||||
for (const p of pairs)
|
||||
await pool.query(
|
||||
`insert into control_todo (controller_person_id, executor_task_id, control_task_id, control_due)
|
||||
values ($1,$2,$3,$4)
|
||||
on conflict (control_task_id) do update set executor_task_id = $2, control_due = coalesce($4, control_todo.control_due),
|
||||
controller_person_id = $1, updated_at = now()`,
|
||||
[controllerId, p.executorTaskId, p.controlTaskId, p.controlDue],
|
||||
);
|
||||
}
|
||||
|
||||
export interface ControlChange {
|
||||
id: string;
|
||||
controllerId: string;
|
||||
kind: "done" | "overdue";
|
||||
executorTaskId: string;
|
||||
executorName: string | null;
|
||||
controlTaskId: string;
|
||||
controlDue: string | null;
|
||||
}
|
||||
|
||||
/** Что изменилось у открытых пар. Пары, чей Control todo закрыл сам контролёр, молча переводятся в `closed`. */
|
||||
export async function findControlChanges(pool: Pool, now: Date, tz: string): Promise<ControlChange[]> {
|
||||
const { rows } = await pool.query(
|
||||
`select ct.id, ct.controller_person_id, ct.executor_task_id, ct.control_task_id, to_char(ct.control_due, 'YYYY-MM-DD') as control_due, ct.status,
|
||||
coalesce(et.name, ct.executor_name) as executor_name,
|
||||
(coalesce(et.progress, 0) >= 1 or exists (select 1 from jt_event e where e.task_id = ct.executor_task_id and e.kind = 'todo_closed' and e.created_at >= ct.created_at - interval '1 minute')) as exec_done,
|
||||
(coalesce(cc.progress, 0) >= 1 or exists (select 1 from jt_event e where e.task_id = ct.control_task_id and e.kind = 'todo_closed' and e.created_at >= ct.created_at - interval '1 minute')) as control_closed,
|
||||
exists (select 1 from jt_event e where e.task_id = ct.executor_task_id and e.created_at > $1::timestamptz - interval '2 days') as recent_activity
|
||||
from control_todo ct
|
||||
left join jt_task et on et.id = ct.executor_task_id
|
||||
left join jt_task cc on cc.id = ct.control_task_id
|
||||
where ct.status in ('active', 'overdue')
|
||||
order by ct.created_at`,
|
||||
[now],
|
||||
);
|
||||
const today = localDate(now, tz);
|
||||
const changes: ControlChange[] = [];
|
||||
const closed: string[] = [];
|
||||
for (const r of rows) {
|
||||
const base = {
|
||||
id: String(r.id), controllerId: String(r.controller_person_id), executorTaskId: String(r.executor_task_id),
|
||||
executorName: (r.executor_name as string | null) ?? null, controlTaskId: String(r.control_task_id), controlDue: (r.control_due as string | null) ?? null,
|
||||
};
|
||||
if (r.control_closed === true) closed.push(base.id);
|
||||
else if (r.exec_done === true) changes.push({ ...base, kind: "done" });
|
||||
else if (r.status === "active" && base.controlDue && base.controlDue <= today && r.recent_activity !== true) changes.push({ ...base, kind: "overdue" });
|
||||
}
|
||||
if (closed.length) await pool.query("update control_todo set status = 'closed', updated_at = now() where id = any($1::uuid[])", [closed]);
|
||||
return changes;
|
||||
}
|
||||
|
||||
const lineOf = (c: ControlChange): string =>
|
||||
c.kind === "done"
|
||||
? `- ВЫПОЛНЕНО: исполнитель закрыл todo ${c.executorTaskId}${c.executorName ? ` «${c.executorName}»` : ""}. Control todo ${c.controlTaskId}: допиши в конец названия «(выполнено)» (убери «(просрочено)», если есть).`
|
||||
: `- ПРОСРОЧЕНО: по todo исполнителя ${c.executorTaskId}${c.executorName ? ` «${c.executorName}»` : ""} 2 дня нет действий и срок Control todo (${c.controlDue}) наступил. Control todo ${c.controlTaskId}: допиши в конец названия «(просрочено)».`;
|
||||
|
||||
export interface ControlWatcherOpts {
|
||||
/** Менеджер-контролёр по person id (чат, в который агент напишет). */
|
||||
loadManager: (personId: string) => Promise<ManagerInfo | null>;
|
||||
intervalMs: number;
|
||||
fromHour?: number;
|
||||
toHour?: number;
|
||||
}
|
||||
|
||||
/** Периодическая проверка пар "todo исполнителя - Control todo"; при изменении будит агента контролёра. */
|
||||
export class ControlWatcher {
|
||||
private timer: NodeJS.Timeout | null = null;
|
||||
private running = false;
|
||||
|
||||
constructor(private deps: ChatDeps, private opts: ControlWatcherOpts) {}
|
||||
|
||||
start(): void {
|
||||
if (!this.opts.intervalMs || this.timer) return;
|
||||
this.timer = setInterval(() => void this.tick().catch((e) => this.deps.ctx.log.error({ err: String(e) }, "проверка Control todo не удалась")), this.opts.intervalMs);
|
||||
}
|
||||
|
||||
stop(): void {
|
||||
if (this.timer) clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
}
|
||||
|
||||
/** Одна проверка; возвращает число сообщений, отправленных контролёрам. Вне окна 7:00-19:00 по Тампе не пишет. */
|
||||
async tick(): Promise<number> {
|
||||
if (this.running) return 0;
|
||||
this.running = true;
|
||||
try {
|
||||
const now = (this.deps.now ?? (() => new Date()))();
|
||||
if (recapDelayMs(now, this.deps.timezone, this.opts.fromHour ?? 7, this.opts.toHour ?? 19) > 0) return 0;
|
||||
const changes = await findControlChanges(this.deps.ctx.pool, now, this.deps.timezone);
|
||||
const byController = new Map<string, ControlChange[]>();
|
||||
for (const c of changes) byController.set(c.controllerId, [...(byController.get(c.controllerId) ?? []), c]);
|
||||
let sent = 0;
|
||||
for (const [controllerId, list] of byController) {
|
||||
const manager = await this.opts.loadManager(controllerId);
|
||||
if (!manager) continue;
|
||||
const s = await pauseState(this.deps.ctx.pool, controllerId, now);
|
||||
if (s.paused && s.mode === "off") continue; // passive допустим: это не напоминание по инициативе, а сообщение о смене статуса
|
||||
await handleManagerMessages(this.deps, manager, [], {
|
||||
systemEvent: loadFragment("p-chat-events.md", "Control: исполнитель закрыл или просрочил", { changes: list.map(lineOf).join("\n") }, promptSideFor(this.deps.ctx, controllerId)),
|
||||
});
|
||||
for (const c of list)
|
||||
await this.deps.ctx.pool.query("update control_todo set status = $2, notified_at = now(), updated_at = now() where id = $1", [c.id, c.kind === "done" ? "done" : "overdue"]);
|
||||
sent++;
|
||||
}
|
||||
return sent;
|
||||
} finally {
|
||||
this.running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,6 @@ export class SlackIntake {
|
||||
const now = (this.deps.now ?? (() => new Date()))();
|
||||
const st = await getRecapState(this.pool, channel);
|
||||
if (!st || st.status === "asked" || !st.notes.trim()) return;
|
||||
if (promptSideFor(this.deps.ctx, manager.personId) !== "proposed") return; // recap - только у новой версии агента
|
||||
if (now.getTime() - st.lastHumanAt.getTime() > 36 * 3600_000) {
|
||||
await this.pool.query("delete from channel_recap_state where channel_id = $1", [channel]); // устарело: молча сбрасываем, не тревожим людей
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user