feat(csm): bootstrap discussion callback flow

This commit is contained in:
zhi
2026-04-02 02:35:08 +00:00
parent 9fa71f37bf
commit 62cd2f20cf
9 changed files with 450 additions and 3 deletions

View File

@@ -25,6 +25,10 @@ type BeforeMessageWriteDeps = {
content: string,
logger: { info: (m: string) => void; warn: (m: string) => void },
) => Promise<void>;
discussionService?: {
maybeSendIdleReminder: (channelId: string) => Promise<void>;
getDiscussion: (channelId: string) => { status: string } | undefined;
};
};
export function registerBeforeMessageWriteHook(deps: BeforeMessageWriteDeps): void {
@@ -41,6 +45,7 @@ export function registerBeforeMessageWriteHook(deps: BeforeMessageWriteDeps): vo
ensureTurnOrder,
resolveDiscordUserId,
sendModeratorMessage,
discussionService,
} = deps;
api.on("before_message_write", (event, ctx) => {
@@ -164,6 +169,11 @@ export function registerBeforeMessageWriteHook(deps: BeforeMessageWriteDeps): vo
);
if (!nextSpeaker) {
if (discussionService?.getDiscussion(channelId)?.status === "active") {
void discussionService.maybeSendIdleReminder(channelId).catch((err) => {
api.logger.warn(`dirigent: idle reminder failed: ${String(err)}`);
});
}
if (shouldDebugLog(live, channelId)) {
api.logger.info(`dirigent: before_message_write all agents no-reply, going dormant - no handoff`);
}