/** * Thread Lifecycle Manager () * * Core logic for thread lifecycle management: * - ID generation, migration from plain strings to ThreadObject * - Aggregation across sessions (replaces aggregateOpenThreads) * - Resolution by ID or text match * - Local file persistence (.gitmem/threads.json) */ import type { ThreadObject } from "../types/index.js"; /** * Generate a thread ID: "t-" + 8 hex chars */ export declare function generateThreadId(): string; /** * Migrate a plain string thread to a ThreadObject. */ export declare function migrateStringThread(text: string, sourceSession?: string): ThreadObject; /** * Normalize a mixed array of strings and ThreadObjects into ThreadObject[]. * Handles backward compatibility with existing plain string threads. */ export declare function normalizeThreads(raw: (string | ThreadObject)[], sourceSession?: string): ThreadObject[]; interface SessionRecord { id: string; session_date: string; open_threads?: (string | ThreadObject)[]; close_compliance?: Record | null; } interface AggregateResult { open: ThreadObject[]; recently_resolved: ThreadObject[]; } /** * Aggregate threads across recent closed sessions. * Replaces the old aggregateOpenThreads() function. * * Returns: * - open: deduplicated open threads * - recently_resolved: threads resolved in the most recent session */ export declare function aggregateThreads(sessions: SessionRecord[], maxSessions?: number, maxAgeDays?: number): AggregateResult; /** * Find a thread by exact ID. */ export declare function findThreadById(threads: ThreadObject[], id: string): ThreadObject | null; /** * Find a thread by case-insensitive substring match on text. * Returns the first match. */ export declare function findThreadByText(threads: ThreadObject[], query: string): ThreadObject | null; /** * Resolve a thread in a list. Returns the resolved thread or null if not found. * Mutates the thread object in place. */ export declare function resolveThread(threads: ThreadObject[], options: { threadId?: string; textMatch?: string; sessionId?: string; resolutionNote?: string; }): ThreadObject | null; /** * Load threads from .gitmem/threads.json. * Returns empty array if file doesn't exist or is invalid. */ export declare function loadThreadsFile(): ThreadObject[]; /** * Save threads to .gitmem/threads.json. */ export declare function saveThreadsFile(threads: ThreadObject[]): void; /** * Merge two thread lists, preferring resolved state. * Used to merge session-close payload with mid-session resolutions. */ export declare function mergeThreadStates(incoming: ThreadObject[], current: ThreadObject[]): ThreadObject[]; export {}; //# sourceMappingURL=thread-manager.d.ts.map