fix: limit no-reply keywords and log
This commit is contained in:
@@ -115,16 +115,12 @@ export function registerBeforeMessageWriteHook(deps: BeforeMessageWriteDeps): vo
|
||||
const policy = resolvePolicy(live, channelId, policyState.channelPolicies as Record<string, any>);
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -74,16 +74,12 @@ export function registerMessageSentHook(deps: MessageSentDeps): void {
|
||||
const policy = resolvePolicy(live, channelId, policyState.channelPolicies as Record<string, any>);
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user