/** * Creation-time duplicate checks: the same creator making the same thing * (ticket, WorkItem, message) again within a short window gets the existing * one instead of a second copy. * * @module utils/duplicate-creation */ import { type WorkItem } from '../types/v2/work-item.types.js'; /** * Title / text key: lower-cased, punctuation and whitespace collapsed. * * @param text - Title or message * @returns Comparison key */ export declare function normalizeForDedupe(text: string): string; /** Why a WorkItem may be returned instead of creating another. */ export interface WorkItemDuplicateQuery { /** Who creates it (agent session; undefined = owner / unknown, never deduped) */ creator: string | undefined; /** Target session */ target: string | undefined; /** New title */ title: string; /** Clock (epoch ms) */ now: number; } /** * An open WorkItem the same creator already made for the same target with the * same title inside {@link D.WORK_ITEM_WINDOW_MS}. * * @param query - The would-be new item * @param items - Pool items * @returns The existing item, or null */ export declare function findDuplicateWorkItem(query: WorkItemDuplicateQuery, items: readonly WorkItem[]): WorkItem | null; /** * The harness's own "Follow through" WorkItem for the same target and title, * whatever its status, inside {@link D.FOLLOW_THROUGH_WINDOW_MS}: a promise is * parked once, not after every stop or restart. * * @param items - Pool items * @param target - Agent session * @param title - Title of the would-be item * @param harnessCreated - The harness origin tag (`stated-intent`, `owner-promise`) * @param now - Clock (epoch ms) * @returns The existing item, or null */ export declare function findExistingFollowThrough(items: readonly WorkItem[], target: string, title: string, harnessCreated: string, now: number): WorkItem | null; /** Forget every tracked message (tests). */ export declare function resetAgentMessageDedupeForTesting(): void; /** * Forget a recorded message, so a resend is not taken for a duplicate. Used * when the first send did not go through. * * @param sender - Sending agent session * @param target - Receiving session * @param text - Message text, as passed to {@link agentMessageRepeatOf} */ export declare function forgetAgentMessage(sender: string, target: string, text: string): void; /** * Whether an agent already sent this exact message to this target inside the * window. Records it otherwise. Short messages and exempt senders never match. * * @param sender - Sending agent session * @param target - Receiving session * @param text - Message text (trace markers should be stripped by the caller) * @param now - Clock (epoch ms) * @returns Seconds since the identical earlier message, or null when it is new */ export declare function agentMessageRepeatOf(sender: string, target: string, text: string, now?: number): number | null; //# sourceMappingURL=duplicate-creation.utils.d.ts.map