/** * Browser Session * * Represents a single browser session for NotebookLM interactions. * * Features: * - Human-like question typing * - Streaming response detection * - Auto-login on session expiry * - Session activity tracking * - Chat history reset * * Based on the Python implementation from browser_session.py */ import type { Page } from "patchright"; import type { SharedContextManager } from "./shared-context-manager.js"; import type { AuthManager } from "../auth/auth-manager.js"; import { type SourceFormat, type ExtractCitationsResult } from "../notebooklm/citations.js"; import { type AddSourceInput, type AddSourceResult } from "../notebooklm/sources.js"; import { type GenerateAudioOptions, type AudioGenerationResult, type DownloadAudioResult } from "../notebooklm/audio.js"; import type { SessionInfo, ProgressCallback } from "../types.js"; export declare class BrowserSession { readonly sessionId: string; readonly notebookUrl: string; readonly createdAt: number; lastActivity: number; messageCount: number; private context; private sharedContextManager; private authManager; private page; private initialized; constructor(sessionId: string, sharedContextManager: SharedContextManager, authManager: AuthManager, notebookUrl: string); /** * Initialize the session by creating a page and navigating to the notebook */ init(): Promise; /** * Wait for NotebookLM interface to be ready * * IMPORTANT: Matches Python implementation EXACTLY! * - Uses SPECIFIC selectors (textarea.query-box-input) * - Checks ONLY for "visible" state (NOT disabled!) * - NO placeholder checks (let NotebookLM handle that!) * * Based on Python _wait_for_ready() from browser_session.py:104-113 */ private waitForNotebookLMReady; private isPageClosedSafe; /** * Ensure the session is authenticated, perform auto-login if needed */ private ensureAuthenticated; private getOriginFromUrl; /** * Safely restore sessionStorage when the page is on the expected origin */ private restoreSessionStorage; /** * Ask a question to NotebookLM */ ask(question: string, sendProgress?: ProgressCallback): Promise; /** * Add a new source (URL or pasted text) to the active notebook page * (issue #25). Lazily initialises the session so the caller can use this * without first running `ask()`. */ addSource(input: AddSourceInput): Promise; /** * Generate an Audio Overview for the active notebook (issue #11). */ generateAudio(options?: GenerateAudioOptions): Promise; /** * Non-blocking probe for the current Audio Overview state (issue #11). */ getAudioStatus(): Promise; /** * Download the most recent Audio Overview (issue #11). */ downloadAudio(destinationDir: string): Promise; /** * Pull DOM-level citations from the most recent answer on this session's * page (issue #20). Must be called immediately after `ask()` — before any * follow-up question disturbs the source panel. */ extractCitations(answer: string, format: SourceFormat): Promise; /** * Find the chat input element * * IMPORTANT: Matches Python implementation EXACTLY! * - Uses SPECIFIC selectors from Python * - Checks ONLY visibility (NOT disabled state!) * * Based on Python ask() method from browser_session.py:166-171 */ private findChatInput; /** * Detect if a rate limit error occurred * * Searches the page for error messages indicating rate limit/quota exhaustion. * Free NotebookLM accounts have 50 queries/day limit. * * @returns true if rate limit error detected, false otherwise */ private detectRateLimitError; /** * Reset the chat history (start a new conversation) */ reset(): Promise; /** * Close the session */ close(): Promise; /** * Update last activity timestamp */ updateActivity(): void; /** * Check if session has expired (inactive for too long) */ isExpired(timeoutSeconds: number): boolean; /** * Get session information */ getInfo(): SessionInfo; /** * Get the underlying page (for advanced operations) */ getPage(): Page | null; /** * Check if session is initialized */ isInitialized(): boolean; } //# sourceMappingURL=browser-session.d.ts.map