import type { PainConfig } from './config.js'; export interface TokenUsage { input?: number; output?: number; cacheRead?: number; cacheWrite?: number; total?: number; } export interface SessionState { sessionId: string; sessionKey?: string; trigger?: string; workspaceDir?: string; toolReadsByFile: Record; llmTurns: number; blockedAttempts: number; lastActivityAt: number; lastControlActivityAt: number; totalInputTokens: number; totalOutputTokens: number; cacheHits: number; stuckLoops: number; currentGfi: number; gfiBySource?: Record; lastErrorSource?: string; lastErrorHash: string; consecutiveErrors: number; lastGfiDecayAt?: number; dailyToolCalls: number; dailyToolFailures: number; dailyPainSignals: number; dailyGfiPeak: number; injectedProbationIds?: string[]; injectedPrincipleIds?: string[]; receiptAutoCorrects?: number; } /** * Initialize persistence for session state. * Call this once during plugin startup. */ export declare function initPersistence(stateDir: string): void; /** * Force persist all sessions immediately. */ export declare function flushAllSessions(): void; export declare function trackToolRead(sessionId: string, filePath: string, workspaceDir?: string): SessionState; export declare function trackLlmOutput(sessionId: string, usage: TokenUsage | undefined, config?: PainConfig, workspaceDir?: string, sessionKey?: string, trigger?: string): SessionState; /** * Tracks physical friction based on tool execution failures. * Delegates to core GFI kernel for scoring. */ export declare function trackFriction(sessionId: string, deltaF: number, hash: string, workspaceDir?: string, options?: { source?: string; }): SessionState; /** * Resets the friction index upon successful action. * Delegates to core GFI kernel for relief computation. */ export declare function resetFriction(sessionId: string, workspaceDir?: string, options?: { source?: string; amount?: number; }): SessionState; export declare function trackBlock(sessionId: string): SessionState; export declare function setInjectedProbationIds(sessionId: string, ids: string[], workspaceDir?: string): SessionState; /** * PRI-534: record the principle ids injected into this session's prompt context. * PRI-755 (review fix): call this on EVERY prompt build with the CURRENT set — * including an empty one. An empty array is a known-empty round and overwrites * a stale non-empty set from an earlier turn; the self-report capture validates * against this set, so keeping a stale set would re-admit markers for * principles no longer injected. */ export declare function setInjectedPrincipleIds(sessionId: string | undefined, ids: readonly string[], workspaceDir?: string): void; /** PRI-534: count one applied live auto-correction in this session. */ export declare function trackReceiptAutoCorrect(sessionId: string | undefined, workspaceDir?: string): void; export declare function getInjectedProbationIds(sessionId: string, workspaceDir?: string): string[]; /** * PRI-755: read-only view of the principle ids injected into this session's * prompt context. Tri-state: an array (possibly empty) means the injection set * is KNOWN; undefined means UNKNOWN (session never built a prompt in this * process, tracker restarted, or session expired). Receipt capture may only * treat verified membership as evidence — unknown must not imply empty. */ export declare function getInjectedPrincipleIds(sessionId: string): readonly string[] | undefined; export declare function clearInjectedProbationIds(sessionId: string, workspaceDir?: string): SessionState; export declare function getSession(sessionId: string): SessionState | undefined; export declare function listSessions(workspaceDir?: string): SessionState[]; export declare function clearSession(sessionId: string): void; /** * Seed a session directly into SessionTracker.sessions for testing. * This bypasses the normal tool-call flow to set up test data for * checkWorkspaceIdle without requiring full integration test setup. * * @param sessionId - Session ID * @param workspaceDir - Workspace directory (optional, for filtering) * @param lastActivityAt - Unix timestamp in ms (default: now) */ export declare function seedSessionForTest(sessionId: string, workspaceDir?: string, lastActivityAt?: number): void; export declare function garbageCollectSessions(): void; /** * Get daily statistics summary for a session. */ export declare function getDailySummary(sessionId: string): { toolCalls: number; toolFailures: number; painSignals: number; gfiPeak: number; } | null; /** * Reset daily statistics (call at midnight or on new day). */ export declare function resetDailyStats(sessionId: string): void; /** * Apply time-based decay to GFI using stage-aware linear decay. * Delegates to core GFI kernel. * * @param sessionId - The session to decay * @param elapsedMinutes - Minutes since last decay * @returns Updated session state, or undefined if session not found or GFI is 0 */ export declare function decayGfi(sessionId: string, elapsedMinutes: number): SessionState | undefined; /** * Check if GFI decay should be applied and return elapsed minutes since last decay. * @param sessionId - The session to check * @returns Elapsed minutes since last decay, or 0 if no decay needed */ export declare function getGfiDecayElapsed(sessionId: string): number;