/** * Agent action history for undo/rollback functionality */ export interface ActionRecord { id: string; timestamp: number; type: 'write' | 'edit' | 'delete' | 'mkdir' | 'command'; path?: string; previousContent?: string; previousExisted?: boolean; wasDirectory?: boolean; deletedContent?: string; /** Hash of what the agent left in the file (write/edit). Undo only puts * the old content back while the file still holds exactly that. */ resultHash?: string; command?: string; args?: string[]; undone?: boolean; } export interface ActionSession { id: string; startTime: number; endTime?: number; prompt: string; actions: ActionRecord[]; projectRoot: string; } /** * Start a new action session */ export declare function startSession(prompt: string, projectRoot: string): string; /** * End current session and save to disk */ export declare function endSession(): void; /** * Record a file write action (before it happens) */ export declare function recordWrite(path: string): ActionRecord | null; /** * Record a file edit action (before it happens) */ export declare function recordEdit(path: string): ActionRecord | null; /** * Record a file/directory delete action (before it happens) */ export declare function recordDelete(path: string): ActionRecord | null; /** * Record a mkdir action */ export declare function recordMkdir(path: string): ActionRecord | null; /** * Record a command execution (can't be undone, but tracked) */ export declare function recordCommand(command: string, args: string[]): ActionRecord | null; /** * Note what a write or edit left in the file, once it happened. */ export declare function recordResult(record: ActionRecord | null | undefined, content: string): void; /** * Drop a record whose change never happened (the write failed or the * editor refused it). Left in place, undo would write its saved content * over whatever the file holds by then. */ export declare function discardAction(record: ActionRecord | null | undefined): void; /** * Get the run in progress, or else the last finished run that changed * something. Pass the workspace to leave out runs from another one. */ export declare function getCurrentSession(projectRoot?: string): ActionSession | null; /** * Undo the most recent file change of the run undo acts on. Pass the * workspace the user is in so a run in another one is left alone. */ export declare function undoLastAction(projectRoot?: string): { success: boolean; message: string; }; /** * Undo a specific action */ export declare function undoAction(action: ActionRecord): { success: boolean; message: string; }; /** * Undo every action of the run undo acts on. Pass the workspace the user is * in so a run in another one is left alone. */ export declare function undoAllActions(projectRoot?: string): { success: boolean; results: string[]; }; /** * Get list of recent sessions */ export declare function getRecentSessions(limit?: number): ActionSession[]; /** * Get a specific session by ID */ export declare function getSession(sessionId: string): ActionSession | null; /** * Format session for display */ export declare function formatSession(session: ActionSession): string; /** * Clear all history */ export declare function clearHistory(): void;