/** * Command Recorder for capturing and replaying tool invocations * * Records all tool calls automatically and allows creating named sequences * by selecting specific command indices from the history. */ export interface RecordedCommand { tool: string; params: Record; delay?: number; comment?: string; } export interface CommandSequence { id: string; name: string; description?: string; expectedOutcome?: string; startUrl?: string; commands: RecordedCommand[]; createdAt: number; } interface HistoryCommand extends RecordedCommand { index: number; timestamp: number; } export interface ActiveSequenceState { sequenceId: string; sequenceName: string; connectionReason: string; currentStep: number; totalSteps: number; pausedAt: number; historyIndexAtPause: number; } export declare class CommandRecorder { private history; private sequences; private commandCounter; private maxHistorySize; private sequencesDir; private activeSequence; private historyViewedWhilePaused; constructor(); /** * Get the sequences directory for a specific scope */ getSequencesDir(global?: boolean): string; /** * Set active sequence state (for step-through) */ setActiveSequence(state: ActiveSequenceState | null): void; /** * Mark that history was viewed while paused (enables insert) */ markHistoryViewed(): void; /** * Reset history viewed flag (called when other actions are taken) */ resetHistoryViewed(): void; /** * Check if history was viewed while paused */ wasHistoryViewed(): boolean; /** * Get active sequence state */ getActiveSequence(): ActiveSequenceState | null; /** * Update current step in active sequence */ updateActiveSequenceStep(step: number): void; /** * Get commands recorded since sequence was paused */ getCommandsSincePause(): HistoryCommand[]; /** * Get current history index (for tracking pause point) */ getCurrentHistoryIndex(): number; /** * Record a command (always-on, automatic) */ recordCommand(tool: string, params: Record, options?: { delay?: number; comment?: string; }): Promise; /** * Get command history (most recent first) */ getHistory(limit?: number): HistoryCommand[]; /** * Get a specific command by index */ getCommand(index: number): HistoryCommand | undefined; /** * Create a sequence from command indices */ createSequence(name: string, commandIndices: number[], options?: { description?: string; expectedOutcome?: string; startUrl?: string; }): Promise; /** * Create a sequence directly from commands (not from history) */ createSequenceFromCommands(name: string, commands: RecordedCommand[], options?: { description?: string; expectedOutcome?: string; startUrl?: string; }): Promise; /** * Check if a sequence with the given name exists */ sequenceNameExists(name: string): boolean; /** * List all saved sequences */ listSequences(): CommandSequence[]; /** * Get a specific sequence by ID */ getSequence(sequenceId: string): CommandSequence | undefined; /** * Delete a sequence */ deleteSequence(sequenceId: string): boolean; /** * Remove a sequence by name (used when reloading to avoid duplicates with different IDs) */ private removeSequenceByName; /** * Clear all sequences */ clearAllSequences(): Promise; /** * Clear command history */ clearHistory(): Promise; /** * Get statistics */ getStats(): { historyCount: number; sequenceCount: number; oldestCommandIndex: number | null; newestCommandIndex: number | null; }; /** * Save a sequence to disk * @param sequenceId - ID of the sequence to save * @param global - If true, save to global ~/.cdp-tools/sequences/, otherwise working directory */ saveSequenceToDisk(sequenceId: string, global?: boolean, overwrite?: boolean): Promise<{ success: true; filepath: string; } | { success: false; error: string; conflict?: boolean; filepath?: string; } | null>; /** * Find best matching filename from saved sequences (searches both working dir and global) * Supports: exact match, with/without .json, name prefix (returns latest by timestamp) * Returns the full path to the matched file */ findMatchingFilename(searchTerm: string): Promise<{ filename: string; fullPath: string; matchType: string; location: string; } | null>; /** * Load a sequence from disk (supports fuzzy filename matching) */ loadSequenceFromDisk(filename: string): Promise; /** * List saved sequences on disk from a specific directory */ private listSequencesFromDir; /** * List saved sequences on disk (checks both working directory and global) */ listSavedSequencesOnDisk(): Promise>; /** * Delete a sequence from disk (supports fuzzy filename matching) */ deleteSequenceFromDisk(filename: string): Promise; } export {}; //# sourceMappingURL=command-recorder.d.ts.map