/** * Heartbeat Productivity Auditor * * A watchdog layer that runs independently of the koi. It tracks recent * heartbeat outcomes and detects when the koi is being unproductive ("lazy"). * * When laziness is detected, it injects a randomized user-style nudge message * into the next heartbeat prompt, tricking the koi into thinking the user * told it to be productive. * * This is a safety/redundancy layer on top of: * - Prompt-level enforcement (v2026.3.57) * - Logic-level tool-call retry (v2026.3.58) * - NO_REPLY token stripping (v2026.3.59) */ export type HeartbeatOutcome = { timestamp: number; /** Whether the heartbeat produced a visible response to the user */ delivered: boolean; /** Whether the koi used any tools during the run */ usedTools: boolean; /** Number of tool calls made */ toolCallCount: number; /** Short preview of the response text (for heuristic analysis) */ preview: string; /** Whether the heartbeat was skipped entirely */ skipped: boolean; /** Skip reason if skipped */ skipReason?: string; /** Whether the koi indicated it's mid-task (working on something across heartbeats) */ activeTask?: boolean; }; export declare function isActiveTask(preview: string): boolean; /** * Record a heartbeat outcome for auditing. */ export declare function recordHeartbeatOutcome(koiId: string, outcome: HeartbeatOutcome): void; /** * Check if the koi needs a productivity nudge and return one if so. * Called before each heartbeat run to potentially override/augment the prompt. * * Returns null if no nudge needed, or a nudge message string to inject. */ export declare function checkProductivityNudge(koiId: string): string | null; /** * Get current auditor stats for a koi (for diagnostics/logging). */ export declare function getAuditorStats(koiId: string): { consecutiveLazy: number; recentHistory: number; lastNudgeAt?: number; }; /** * Reset auditor state for a koi (e.g., on session reset). */ export declare function resetAuditorState(koiId: string): void;