/** * NotebookLM Library Manager * * Manages a persistent library of NotebookLM notebooks. * Allows Claude to autonomously add, remove, and switch between * multiple notebooks based on the task at hand. * * Supports per-project libraries based on current working directory. */ import type { NotebookEntry, AddNotebookInput, UpdateNotebookInput, LibraryStats, ProjectInfo } from "./types.js"; export declare class NotebookLibrary { private libraryPath; private library; private projectInfo; private useProjectLibrary; private saveTimer; /** Pending use-count deltas keyed by notebook id, flushed by the debounced save. (M25) */ private pendingUseCounts; constructor(options?: { projectId?: string; useProjectLibrary?: boolean; }); /** * Get current project info (if using per-project library) */ getProjectInfo(): ProjectInfo | null; /** * Check if using per-project library */ isProjectLibrary(): boolean; /** * Get library file path */ getLibraryPath(): string; /** * Static method to detect project from current directory */ static detectCurrentProject(): ProjectInfo | null; /** * Load library from disk, or create default if not exists */ private loadLibrary; /** * Create default library from current CONFIG */ private createDefaultLibrary; /** * Save library to disk */ private saveLibrary; /** * Read the library file from disk without mutating in-memory state. * Used inside the lock to pick up changes made by concurrent sessions. (M25) */ private readLibraryFromDisk; /** * Atomically apply a read-modify-write to the library file. * * Holds a cross-process lock, reloads the latest library from disk (so a * concurrent session's notebooks aren't clobbered), applies `mutate` to a * deep copy, persists it, and only then commits it to this.library. If the * write throws, this.library is left untouched. (M25) */ private mutateLibrary; /** * Generate a unique ID from a string (slug format). * Uniqueness is checked against the supplied library (defaults to the * in-memory one) so callers inside mutateLibrary can de-dupe against the * freshly-reloaded disk state. (M25) */ private generateId; /** * Add a new notebook to the library */ addNotebook(input: AddNotebookInput): NotebookEntry; /** * List all notebooks in library */ listNotebooks(): NotebookEntry[]; /** * Get a specific notebook by ID */ getNotebook(id: string): NotebookEntry | null; /** * Get the currently active notebook */ getActiveNotebook(): NotebookEntry | null; /** * Select a notebook as active */ selectNotebook(id: string): NotebookEntry; /** * Update notebook metadata */ updateNotebook(input: UpdateNotebookInput): NotebookEntry; /** * Remove notebook from library */ removeNotebook(id: string): boolean; /** * Increment use count for a notebook */ incrementUseCount(id: string): NotebookEntry | null; /** * Debounced save — avoids writing to disk on every single query */ private debouncedSave; /** * Synchronously flush any pending debounced use-count updates to disk under * the cross-process lock, re-applying the accumulated deltas to the latest * on-disk library so concurrent sessions' notebooks and counts survive. (M25) */ flushSave(): void; /** * Release resources: flush pending writes and detach shutdown handlers. (M25) */ close(): void; /** * Get library statistics */ getStats(): LibraryStats; /** * Search notebooks by query (searches name, description, topics) */ searchNotebooks(query: string): NotebookEntry[]; }