Отключение агента менеджера: на время и до команды владельца (миграция 017, API pause/resume, события, шаг 2 и приём сообщений); тесты; docs
Some checks failed
ci / deploy (push) Has been cancelled
ci / test (push) Has been cancelled

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 19:56:51 +03:00
parent 3e696bb53f
commit f3e0b0618e
13 changed files with 273 additions and 22 deletions

View File

@@ -0,0 +1,19 @@
import type { Pool } from "khb_common";
import { NOT_PAUSED_SQL } from "./pause.js";
import { rowToManager } from "./slack/intake.js";
import type { ManagerInfo } from "./slack/chat.js";
/**
* Менеджеры с включённым проектом нужного режима. По умолчанию без отключённых (пауза на время или до команды): системные события им не идут.
* Для ручных запусков владельца (simulate/apply) отключённых можно включить в список (`includePaused`).
*/
export async function listManagers(pool: Pool, modes: string[], opts: { includePaused?: boolean } = {}): Promise<ManagerInfo[]> {
const { rows } = await pool.query(
`select distinct cm.person_id, p.display_name, cm.slack_user_id, cm.slack_channel_id, cm.reply_mode, cm.tts_voice
from construction_manager cm join person p on p.id = cm.person_id
join assistant_project ap on ap.manager_person_id = cm.person_id and ap.is_enabled and ap.mode = any($1)
where cm.is_active and p.is_active${opts.includePaused ? "" : ` and ${NOT_PAUSED_SQL("cm")}`}`,
[modes],
);
return rows.map(rowToManager);
}