From 4905f37c1a03917b941265dbbf1fc2f4634908e8 Mon Sep 17 00:00:00 2001 From: nav Date: Tue, 10 Mar 2026 13:53:32 +0000 Subject: [PATCH] fix: limit no-reply keywords and log --- plugin/hooks/before-message-write.ts | 13 ++++++------- plugin/hooks/message-sent.ts | 12 +++++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/plugin/hooks/before-message-write.ts b/plugin/hooks/before-message-write.ts index 33727c6..6cc93c0 100644 --- a/plugin/hooks/before-message-write.ts +++ b/plugin/hooks/before-message-write.ts @@ -115,16 +115,12 @@ export function registerBeforeMessageWriteHook(deps: BeforeMessageWriteDeps): vo const policy = resolvePolicy(live, channelId, policyState.channelPolicies as Record); const trimmed = content.trim(); - const isNoReply = - trimmed.length === 0 || - /^NO$/i.test(trimmed) || - /^NO_REPLY$/i.test(trimmed) || - /^HEARTBEAT_OK$/i.test(trimmed); + const isNoReply = /^NO$/i.test(trimmed) || /^NO_REPLY$/i.test(trimmed); const lastChar = trimmed.length > 0 ? Array.from(trimmed).pop() || "" : ""; const hasEndSymbol = !!lastChar && policy.endSymbols.includes(lastChar); const waitId = live.waitIdentifier || "👤"; const hasWaitIdentifier = !!lastChar && lastChar === waitId; - // Treat explicit NO_REPLY/HEARTBEAT_OK/NO and empty responses as no-reply. + // Treat explicit NO/NO_REPLY keywords as no-reply. const wasNoReply = isNoReply; const turnDebug = getTurnDebugInfo(channelId); @@ -145,7 +141,10 @@ export function registerBeforeMessageWriteHook(deps: BeforeMessageWriteDeps): vo const wasAllowed = sessionAllowed.get(key); if (wasNoReply) { - api.logger.info(`dirigent: DEBUG NO_REPLY detected session=${key} wasAllowed=${wasAllowed}`); + const noReplyKeyword = /^NO$/i.test(trimmed) ? "NO" : "NO_REPLY"; + api.logger.info( + `dirigent: DEBUG NO_REPLY detected session=${key} wasAllowed=${wasAllowed} keyword=${noReplyKeyword}`, + ); if (wasAllowed === undefined) return; diff --git a/plugin/hooks/message-sent.ts b/plugin/hooks/message-sent.ts index 9c5d594..b9703bc 100644 --- a/plugin/hooks/message-sent.ts +++ b/plugin/hooks/message-sent.ts @@ -74,16 +74,12 @@ export function registerMessageSentHook(deps: MessageSentDeps): void { const policy = resolvePolicy(live, channelId, policyState.channelPolicies as Record); const trimmed = content.trim(); - const isNoReply = - trimmed.length === 0 || - /^NO$/i.test(trimmed) || - /^NO_REPLY$/i.test(trimmed) || - /^HEARTBEAT_OK$/i.test(trimmed); + const isNoReply = /^NO$/i.test(trimmed) || /^NO_REPLY$/i.test(trimmed); const lastChar = trimmed.length > 0 ? Array.from(trimmed).pop() || "" : ""; const hasEndSymbol = !!lastChar && policy.endSymbols.includes(lastChar); const waitId = live.waitIdentifier || "👤"; const hasWaitIdentifier = !!lastChar && lastChar === waitId; - // Treat explicit NO_REPLY/HEARTBEAT_OK/NO and empty responses as no-reply. + // Treat explicit NO/NO_REPLY keywords as no-reply. const wasNoReply = isNoReply; if (key && sessionTurnHandled.has(key)) { @@ -105,8 +101,10 @@ export function registerMessageSentHook(deps: MessageSentDeps): void { if (wasNoReply || hasEndSymbol) { const nextSpeaker = onSpeakerDone(channelId, accountId, wasNoReply); const trigger = wasNoReply ? "no_reply_keyword" : "end_symbol"; + const noReplyKeyword = wasNoReply ? (/^NO$/i.test(trimmed) ? "NO" : "NO_REPLY") : ""; + const keywordNote = wasNoReply ? ` keyword=${noReplyKeyword}` : ""; api.logger.info( - `dirigent: turn onSpeakerDone channel=${channelId} from=${accountId} next=${nextSpeaker ?? "dormant"} trigger=${trigger}`, + `dirigent: turn onSpeakerDone channel=${channelId} from=${accountId} next=${nextSpeaker ?? "dormant"} trigger=${trigger}${keywordNote}`, ); if (wasNoReply && nextSpeaker && live.moderatorBotToken) {