Проектные каналы: тихий режим, recap для Daily Log; Huddle через message_changed; короткие напоминания
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -601,4 +601,72 @@ d("консольные агенты (временная БД, фейковый
|
||||
expect(liveCalls[3]!.env).toBeUndefined();
|
||||
});
|
||||
|
||||
it("проектный канал (новая версия): молчание и накопление, реакция, recap по тишине, подтверждение «yes»; Huddle через message_changed", async () => {
|
||||
const nl = String.fromCharCode(10);
|
||||
const texts: string[] = [
|
||||
["## Ответ менеджеру", "(без ответа)", "## Накопить для Daily Log", "[Wed 12:00] UANY: tile was ordered", "## Реакции", "1791741700.000100 memo", "## Память", "м-тихо"].join(nl),
|
||||
["## Ответ менеджеру", "Recap: tile ordered. Should I add this to the Daily Log?", "## Статус recap", "asked", "## Память", "м-recap"].join(nl),
|
||||
["## Ответ менеджеру", "Done: saved to Daily Log.", "## Статус recap", "recorded", "## Память", "м-yes"].join(nl),
|
||||
["## Ответ менеджеру", "(без ответа)", "## Память", "м-huddle"].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 } } };
|
||||
await db.pool.query("insert into project_channel (channel_id, jt_job_id, channel_name, is_enabled) values ('CPROJ3','llmtest-job','proj-llmtest-3', true) on conflict do nothing");
|
||||
const posted: string[] = [];
|
||||
const reactions: string[] = [];
|
||||
const slack = {
|
||||
postMessage: async (_c: string, t: string) => { posted.push(t); return true; }, fileInfo: async () => null, download: async () => 0,
|
||||
history: async () => [{ ts: "1791741700.000100", userId: "UANY", botId: null, text: "tile was ordered", threadTs: null, fileNames: [] }],
|
||||
userName: async () => "Walter", botUserId: async () => "UBOT",
|
||||
addReaction: async (_c: string, ts: string, e: string) => { reactions.push(ts + " " + e); return true; },
|
||||
};
|
||||
const noon = new Date("2026-10-21T16:00:00Z");
|
||||
const deps = { ctx: live, timezone: "America/New_York", slack, now: () => noon };
|
||||
const intake = new SlackIntake(deps, { channelIds: [], debounceMs: 600_000, recapSilenceMs: 600_000 });
|
||||
// 1. люди общаются: агент молчит, копит, ставит реакцию; в промте - диалог за сутки с временем и именами
|
||||
await intake.onEvent({ type: "message", channel: "CPROJ3", user: "UANY", ts: "1791741700.000100", text: "tile was ordered" });
|
||||
await intake.flush(MGR);
|
||||
await intake.idle();
|
||||
expect(posted).toEqual([]);
|
||||
expect(reactions).toEqual(["1791741700.000100 memo"]);
|
||||
expect(liveCalls[0]!.prompt).toContain("# Диалог канала за последние сутки");
|
||||
expect(liveCalls[0]!.prompt).toContain("Walter: tile was ordered");
|
||||
expect(liveCalls[0]!.prompt).toContain("# Накопленное для Daily Log");
|
||||
let st = (await db.pool.query("select status, notes from channel_recap_state where channel_id = 'CPROJ3'")).rows[0];
|
||||
expect(st).toMatchObject({ status: "collecting" });
|
||||
expect(st.notes).toContain("tile was ordered");
|
||||
// 2. тишина: recap одним сообщением, статус asked
|
||||
intake.scheduleRecap("CPROJ3", { personId: MGR, name: "llmtest-Manager", slackUserId: "ULLMTEST", slackChannelId: "CPROJ3" }, { jobId: "llmtest-job", jobName: null, channel: "CPROJ3", senderName: null, isHuddle: false }, 1);
|
||||
await new Promise((r) => setTimeout(r, 300));
|
||||
await intake.idle();
|
||||
expect(liveCalls[1]!.prompt).toContain("Беседа в проектном канале затихла");
|
||||
expect(liveCalls[1]!.prompt).toContain("tile was ordered");
|
||||
expect(posted).toEqual(["Recap: tile ordered. Should I add this to the Daily Log?"]);
|
||||
st = (await db.pool.query("select status from channel_recap_state where channel_id = 'CPROJ3'")).rows[0];
|
||||
expect(st.status).toBe("asked");
|
||||
// 3. «yes» от любого участника: запись, состояние очищено
|
||||
await intake.onEvent({ type: "message", channel: "CPROJ3", user: "UOTHER", ts: "1791741800.000100", text: "yes" });
|
||||
await intake.flush(MGR);
|
||||
await intake.idle();
|
||||
expect(liveCalls[2]!.prompt).toContain("Вопрос про Daily Log уже задан");
|
||||
expect(posted[1]).toContain("saved to Daily Log");
|
||||
expect((await db.pool.query("select 1 from channel_recap_state where channel_id = 'CPROJ3'")).rowCount).toBe(0);
|
||||
// 4. заметки Huddle приходят правкой родителя (message_changed) и принимаются один раз; "AI huddle notes are ready" - игнорируется
|
||||
const files = [{ id: "FH1", name: "Huddle notes", mimetype: "application/vnd.slack-docs", filetype: "quip" }];
|
||||
await intake.onEvent({ type: "message", channel: "CPROJ3", user: "USLACKBOT", ts: "1791741900.000100", text: "AI huddle notes are ready" });
|
||||
await intake.onEvent({ type: "message", subtype: "message_changed", channel: "CPROJ3", message: { type: "message", subtype: "huddle_thread", user: "USLACKBOT", ts: "1791741900.000200", files } });
|
||||
await intake.onEvent({ type: "message", subtype: "message_changed", channel: "CPROJ3", message: { type: "message", subtype: "huddle_thread", user: "USLACKBOT", ts: "1791741900.000200", files } });
|
||||
await intake.flush(MGR);
|
||||
await intake.idle();
|
||||
intake.stop();
|
||||
expect(liveCalls).toHaveLength(4);
|
||||
expect(liveCalls[3]!.prompt).toContain("[Slack huddle");
|
||||
expect(liveCalls[3]!.prompt).not.toContain("AI huddle notes are ready");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user