/** * Cursor Output Normalization State * * Tracks state during JSONL parsing and output normalization, * including streaming message coalescing and session metadata. * * @module agents/cursor/normalizer/state */ import type { NormalizedEntry } from '../../types/agent-executor.js'; import type { CursorSystemMessage, CursorUserMessage, CursorAssistantMessage, CursorThinkingMessage, CursorResultMessage, CursorToolCallMessage } from '../types/messages.js'; /** * State tracker for Cursor output normalization. * * Manages streaming message coalescing, tool call tracking, * and session metadata reporting. */ export declare class CursorNormalizationState { /** Current entry index (incremented for each new entry) */ private entryIndex; /** Active assistant message being coalesced */ private assistantMessage?; /** Active thinking message being coalesced */ private thinkingMessage?; /** Map of call_id to tool use entry (for completion updates) */ private toolCalls; /** Whether model has been reported (report once) */ private modelReported; /** Whether session ID has been reported (report once) */ private sessionIdReported; /** Current session ID (captured from system message) */ private sessionId; /** Current model (captured from system message) */ private model; /** * Get next entry index and increment counter. * * @returns Next sequential entry index */ nextIndex(): number; /** * Get standardized metadata for entries. * * Returns metadata with sessionId and model if available. * * @returns Metadata object or undefined if no metadata available */ private getMetadata; /** * Handle system message. * * Extracts and reports session ID and model info (once each). * Subsequent system messages are skipped to avoid duplicate reporting. * * @param message - System message * @returns System message entry, or null if already reported */ handleSystemMessage(message: CursorSystemMessage): NormalizedEntry | null; /** * Handle user message. * * Creates entry with user prompt content. * * @param message - User message * @returns User message entry */ handleUserMessage(message: CursorUserMessage): NormalizedEntry; /** * Handle assistant message with streaming coalescing. * * Multiple assistant messages are coalesced into a single entry. * The first message creates a new entry, subsequent messages update * the same entry index with accumulated content. * * @param message - Assistant message * @returns Assistant message entry (coalesced) */ handleAssistantMessage(message: CursorAssistantMessage): NormalizedEntry; /** * Handle thinking message with streaming coalescing. * * Multiple thinking messages are coalesced into a single entry. * The first message creates a new entry, subsequent messages update * the same entry index with accumulated text. * * @param message - Thinking message * @returns Thinking message entry (coalesced), or null if no text */ handleThinkingMessage(message: CursorThinkingMessage): NormalizedEntry | null; /** * Handle result message. * * Creates error entry if result indicates failure, otherwise returns null * (success is implicit). * * @param message - Result message * @returns Error entry if failed, null otherwise */ handleResultMessage(message: CursorResultMessage): NormalizedEntry | null; /** * Handle tool call started event. * * Creates a new tool_use entry with 'running' status and tracks * the call_id for later completion updates. * * @param message - Tool call message with subtype 'started' * @param workDir - Working directory for path relativization * @returns Tool use entry */ handleToolCallStarted(message: CursorToolCallMessage, workDir: string): NormalizedEntry; /** * Handle tool call completed event. * * Updates the existing tool_use entry with 'success' or 'failed' status * and includes result data. Reuses the same entry index as the started event. * * @param message - Tool call message with subtype 'completed' * @param workDir - Working directory for path relativization * @returns Updated tool use entry, or null if no matching started event */ handleToolCallCompleted(message: CursorToolCallMessage, workDir: string): NormalizedEntry | null; /** * Check if tool call result indicates an error. * * @param toolCall - Tool call to check * @returns True if tool has error result * @private */ private toolHasError; /** * Get active tool call entry by call ID. * * @param callId - Tool call ID * @returns Tool call entry if found, undefined otherwise */ getToolCall(callId: string): { index: number; entry: NormalizedEntry; } | undefined; /** * Store tool call entry for later completion updates. * * @param callId - Tool call ID * @param index - Entry index * @param entry - Normalized entry */ setToolCall(callId: string, index: number, entry: NormalizedEntry): void; /** * Clear active assistant message (used when switching message types). */ clearAssistantMessage(): void; /** * Clear active thinking message (used when switching message types). */ clearThinkingMessage(): void; } //# sourceMappingURL=state.d.ts.map