/** * NotebookLM Library Sync * * Syncs local library with actual NotebookLM notebooks. * Detects stale entries, extracts real URLs, and offers cleanup. */ import { AuthManager } from "../auth/auth-manager.js"; import { SharedContextManager } from "../session/shared-context-manager.js"; import type { NotebookLibrary } from "../library/notebook-library.js"; export interface ActualNotebook { title: string; url: string; sourceCount: number; createdDate: string; } export interface SyncResult { actualNotebooks: ActualNotebook[]; matched: Array<{ libraryId: string; libraryName: string; actualTitle: string; actualUrl: string; }>; staleEntries: Array<{ libraryId: string; libraryName: string; libraryUrl: string; reason: string; /** * Whether this entry is SAFE to auto-remove. Only true when we have an * exact, UUID-based confirmation that the notebook no longer exists. Entries * that merely failed a fuzzy title match are reported as stale (for the * human to review) but are NOT eligible for destructive auto-fix. */ autoFixSafe: boolean; }>; missingNotebooks: ActualNotebook[]; suggestions: string[]; } /** * Syncs library with actual NotebookLM notebooks */ export declare class NotebookSync { private authManager; private contextManager; private library; private page; constructor(authManager: AuthManager, contextManager: SharedContextManager, library: NotebookLibrary); /** * Sync library with actual NotebookLM notebooks */ syncLibrary(options?: { autoFix?: boolean; showBrowser?: boolean; }): Promise; /** * Extract all notebooks from NotebookLM homepage */ extractNotebooks(): Promise<{ notebooks: ActualNotebook[]; diagnostic: string[]; }>; /** * Switch to grid view — notebook UUIDs only appear in grid view DOM */ private switchToGridView; /** * Extract notebooks from grid view project-button elements. * UUIDs are embedded in child element IDs (e.g., id="project-UUID-title"). */ private extractFromGridView; /** * Extract notebooks from table view by clicking each row to capture the navigation URL. * Slower but works when grid view is unavailable. */ private extractFromTableViewWithNavigation; /** * Basic table row extraction without URLs (last resort fallback). */ private extractFromTableViewBasic; /** * Compare library entries with actual notebooks */ private compareLibraryWithActual; /** * Normalize a title for comparison */ private normalizeTitle; /** * Check if two titles match (fuzzy) */ private titlesMatch; /** * Extract a STABLE notebook UUID from a URL, or null if none can be derived. * * Returns null for "pending-*" placeholders and for any URL that does not * carry a real /notebook/UUID segment. A null id must NEVER be treated as a * match key (two unknowns are not "equal") and must NEVER feed a destructive * auto-fix decision — doing so previously let placeholder/garbage ids collide * or let a missing id be (mis)matched and removed. */ private extractNotebookId; /** * Auto-fix stale entries by removing them */ private autoFixStaleEntries; /** * Auto-add missing notebooks to library */ private autoAddMissingNotebooks; /** * Log sync summary */ private logSyncSummary; /** * Initialize browser and navigate to NotebookLM */ private initialize; /** * Cleanup resources */ private cleanup; } /** * Sync library with NotebookLM */ export declare function syncLibrary(authManager: AuthManager, contextManager: SharedContextManager, library: NotebookLibrary, options?: { autoFix?: boolean; showBrowser?: boolean; }): Promise;