refactor: consolidate runtime helpers

This commit is contained in:
Eyejoker
2026-03-23 06:39:26 +09:00
parent c733217074
commit 898c77fcfc
15 changed files with 808 additions and 608 deletions

View File

@@ -1,9 +1,9 @@
import {
getLatestMessageSeqAtOrBefore,
getLastHumanMessageTimestamp,
isPairedRoomJid,
} from './db.js';
import { filterProcessableMessages } from './bot-message-filter.js';
import { normalizeStoredSeqCursor } from './message-cursor.js';
import { isTriggerAllowed, loadSenderAllowlist } from './sender-allowlist.js';
import {
type Channel,
@@ -13,15 +13,6 @@ import {
const BOT_COLLABORATION_WINDOW_MS = 12 * 60 * 60 * 1000;
export function normalizeStoredSeqCursor(
cursor: string | undefined,
chatJid?: string,
): string {
if (!cursor) return '0';
if (/^\d+$/.test(cursor.trim())) return cursor.trim();
return String(getLatestMessageSeqAtOrBefore(cursor, chatJid));
}
export function advanceLastAgentCursor(
lastAgentTimestamps: Record<string, string>,
saveState: () => void,