export type TrailEntry = { sessionId: string; timestamp: string; tool: string; url?: string; tabId?: string; input: Record; result: Record; }; export declare function recordAction(entry: Omit): void; export declare function getLastAction(): TrailEntry | null; export declare function getTrail(): TrailEntry[]; export declare function clearTrail(): void; export interface LoopDiagnostics { looped: boolean; strikes: number; severity: "none" | "warning" | "critical"; } export declare function detectLoop(tool: string, ref: string): boolean; export declare function getLoopDiagnostics(tool: string, ref: string): LoopDiagnostics; export declare function resetLoopCounter(reason?: string): void; /** * Reset loop detection for a single tool+ref pair only. * Does not affect other refs or the trail history. */ export declare function resetLoopCounterForRef(tool: string, ref: string): void; export interface ToolCallTracking { tool: string; target: string; timestamp: string; result: Record; } /** * Track a tool call for loop detection * Maintains a rolling window of the last 5 tool calls */ export declare function trackToolCall(tool: string, target: string, result: Record): void; /** * Check if the agent is stuck in a loop using rolling window detection * Returns STUCK signal with diagnosis if loop detected */ export declare function detectStuckLoop(): { stuck: boolean; diagnosis?: string; }; /** * Clear the tool call window (useful when starting a new task). * Also called by navigate.ts on every navigation to prevent cross-page STUCK_LOOP. */ export declare function clearToolCallWindow(): void; /** * Get the current tool call window (for debugging) */ export declare function getToolCallWindow(): ToolCallTracking[]; /** * Detect cross-tool loops — e.g. click→fill→click→fill repeating with no success. * Catches cases where the agent alternates between tools on the same target * without making progress, which single-tool detection misses entirely. */ export declare function detectCrossToolLoop(): { stuck: boolean; pattern?: string; diagnosis?: string; };