@roomi-fields/notebooklm-mcp 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +548 -0
  3. package/dist/auth/auth-manager.d.ts +139 -0
  4. package/dist/auth/auth-manager.d.ts.map +1 -0
  5. package/dist/auth/auth-manager.js +981 -0
  6. package/dist/auth/auth-manager.js.map +1 -0
  7. package/dist/config.d.ts +89 -0
  8. package/dist/config.d.ts.map +1 -0
  9. package/dist/config.js +216 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/errors.d.ts +26 -0
  12. package/dist/errors.d.ts.map +1 -0
  13. package/dist/errors.js +41 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/http-wrapper.d.ts +8 -0
  16. package/dist/http-wrapper.d.ts.map +1 -0
  17. package/dist/http-wrapper.js +221 -0
  18. package/dist/http-wrapper.js.map +1 -0
  19. package/dist/index.d.ts +32 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +499 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/library/notebook-library.d.ts +81 -0
  24. package/dist/library/notebook-library.d.ts.map +1 -0
  25. package/dist/library/notebook-library.js +362 -0
  26. package/dist/library/notebook-library.js.map +1 -0
  27. package/dist/library/types.d.ts +67 -0
  28. package/dist/library/types.d.ts.map +1 -0
  29. package/dist/library/types.js +8 -0
  30. package/dist/library/types.js.map +1 -0
  31. package/dist/session/browser-session.d.ts +108 -0
  32. package/dist/session/browser-session.d.ts.map +1 -0
  33. package/dist/session/browser-session.js +630 -0
  34. package/dist/session/browser-session.js.map +1 -0
  35. package/dist/session/session-manager.d.ts +76 -0
  36. package/dist/session/session-manager.d.ts.map +1 -0
  37. package/dist/session/session-manager.js +273 -0
  38. package/dist/session/session-manager.js.map +1 -0
  39. package/dist/session/shared-context-manager.d.ts +107 -0
  40. package/dist/session/shared-context-manager.d.ts.map +1 -0
  41. package/dist/session/shared-context-manager.js +447 -0
  42. package/dist/session/shared-context-manager.js.map +1 -0
  43. package/dist/tools/index.d.ts +225 -0
  44. package/dist/tools/index.d.ts.map +1 -0
  45. package/dist/tools/index.js +1396 -0
  46. package/dist/tools/index.js.map +1 -0
  47. package/dist/types.d.ts +82 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +5 -0
  50. package/dist/types.js.map +1 -0
  51. package/dist/utils/cleanup-manager.d.ts +133 -0
  52. package/dist/utils/cleanup-manager.d.ts.map +1 -0
  53. package/dist/utils/cleanup-manager.js +673 -0
  54. package/dist/utils/cleanup-manager.js.map +1 -0
  55. package/dist/utils/logger.d.ts +61 -0
  56. package/dist/utils/logger.d.ts.map +1 -0
  57. package/dist/utils/logger.js +92 -0
  58. package/dist/utils/logger.js.map +1 -0
  59. package/dist/utils/page-utils.d.ts +54 -0
  60. package/dist/utils/page-utils.d.ts.map +1 -0
  61. package/dist/utils/page-utils.js +422 -0
  62. package/dist/utils/page-utils.js.map +1 -0
  63. package/dist/utils/stealth-utils.d.ts +135 -0
  64. package/dist/utils/stealth-utils.d.ts.map +1 -0
  65. package/dist/utils/stealth-utils.js +398 -0
  66. package/dist/utils/stealth-utils.js.map +1 -0
  67. package/package.json +71 -0
@@ -0,0 +1,447 @@
1
+ /**
2
+ * Shared Context Manager with Persistent Chrome Profile
3
+ *
4
+ * Manages ONE global persistent BrowserContext for ALL sessions.
5
+ * This is critical for avoiding bot detection:
6
+ *
7
+ * - Google tracks browser fingerprints (Canvas, WebGL, Audio, Fonts, etc.)
8
+ * - Multiple contexts = Multiple fingerprints = Suspicious!
9
+ * - ONE persistent context = ONE consistent fingerprint = Normal user
10
+ * - Persistent user_data_dir = SAME fingerprint across all app restarts!
11
+ *
12
+ * Based on the Python implementation from shared_context_manager.py
13
+ */
14
+ import { chromium } from "patchright";
15
+ import { CONFIG } from "../config.js";
16
+ import { log } from "../utils/logger.js";
17
+ import fs from "fs";
18
+ import path from "path";
19
+ /**
20
+ * Shared Context Manager
21
+ *
22
+ * Benefits:
23
+ * 1. ONE consistent browser fingerprint for all sessions
24
+ * 2. Fingerprint persists across app restarts (user_data_dir)
25
+ * 3. Mimics real user behavior (one browser, multiple tabs)
26
+ * 4. Google sees: "Same browser since day 1"
27
+ */
28
+ export class SharedContextManager {
29
+ authManager;
30
+ globalContext = null;
31
+ contextCreatedAt = null;
32
+ currentProfileDir = null;
33
+ isIsolatedProfile = false;
34
+ currentHeadlessMode = null;
35
+ constructor(authManager) {
36
+ this.authManager = authManager;
37
+ log.info("🌐 SharedContextManager initialized (PERSISTENT MODE)");
38
+ log.info(` Chrome Profile: ${CONFIG.chromeProfileDir}`);
39
+ log.success(" Fingerprint: PERSISTENT across restarts! 🎯");
40
+ // Cleanup old isolated profiles at startup (best-effort)
41
+ if (CONFIG.cleanupInstancesOnStartup) {
42
+ void this.pruneIsolatedProfiles("startup");
43
+ }
44
+ }
45
+ /**
46
+ * Get the global shared persistent context, or create new if needed
47
+ *
48
+ * Context is recreated only when:
49
+ * - First time (no context exists in this app instance)
50
+ * - Context was closed/invalid
51
+ *
52
+ * Note: Auth expiry does NOT recreate context - we reuse the SAME
53
+ * fingerprint and just re-login!
54
+ *
55
+ * @param overrideHeadless Optional override for headless mode (true = show browser)
56
+ */
57
+ async getOrCreateContext(overrideHeadless) {
58
+ // Check if headless mode needs to be changed (e.g., show_browser=true)
59
+ // If yes, close the browser so it gets recreated with the new mode
60
+ if (this.needsHeadlessModeChange(overrideHeadless)) {
61
+ log.warning("🔄 Headless mode change detected - recreating browser context...");
62
+ await this.closeContext();
63
+ }
64
+ if (await this.needsRecreation()) {
65
+ log.warning("🔄 Creating/Loading persistent context...");
66
+ await this.recreateContext(overrideHeadless);
67
+ }
68
+ else {
69
+ log.success("♻️ Reusing existing persistent context");
70
+ }
71
+ return this.globalContext;
72
+ }
73
+ /**
74
+ * Check if global context needs to be recreated
75
+ */
76
+ async needsRecreation() {
77
+ // No context exists yet (first time or after manual close)
78
+ if (!this.globalContext) {
79
+ log.info(" ℹ️ No context exists yet");
80
+ return true;
81
+ }
82
+ // Async validity check (will throw if closed)
83
+ try {
84
+ await this.globalContext.cookies();
85
+ log.dim(" ✅ Context still valid (browser open)");
86
+ return false;
87
+ }
88
+ catch (error) {
89
+ log.warning(" ⚠️ Context appears closed - will recreate");
90
+ this.globalContext = null;
91
+ this.contextCreatedAt = null;
92
+ this.currentHeadlessMode = null;
93
+ return true;
94
+ }
95
+ }
96
+ /**
97
+ * Create/Load the global PERSISTENT context with Chrome user_data_dir
98
+ *
99
+ * This is THE KEY to fingerprint persistence!
100
+ *
101
+ * First time:
102
+ * - Chrome creates new profile in user_data_dir
103
+ * - Generates fingerprint (Canvas, WebGL, Audio, etc.)
104
+ * - Saves everything to disk
105
+ *
106
+ * Subsequent starts:
107
+ * - Chrome loads profile from user_data_dir
108
+ * - SAME fingerprint as before! ✅
109
+ * - Google sees: "Same browser since day 1"
110
+ *
111
+ * @param overrideHeadless Optional override for headless mode (true = show browser)
112
+ */
113
+ async recreateContext(overrideHeadless) {
114
+ // Close old context if exists
115
+ if (this.globalContext) {
116
+ try {
117
+ log.info(" 🗑️ Closing old context...");
118
+ await this.globalContext.close();
119
+ }
120
+ catch (error) {
121
+ log.warning(` ⚠️ Error closing old context: ${error}`);
122
+ }
123
+ }
124
+ // Check for saved auth
125
+ const statePath = await this.authManager.getValidStatePath();
126
+ if (statePath) {
127
+ log.success(` 📂 Found auth state: ${statePath}`);
128
+ log.info(" 💡 Will load cookies into persistent profile");
129
+ }
130
+ else {
131
+ log.warning(" 🆕 No saved auth - fresh persistent profile");
132
+ log.info(" 💡 First login will save auth to persistent profile");
133
+ }
134
+ // Determine headless mode: use override if provided, otherwise use CONFIG
135
+ const shouldBeHeadless = overrideHeadless !== undefined ? !overrideHeadless : CONFIG.headless;
136
+ if (overrideHeadless !== undefined) {
137
+ log.info(` Browser visibility override: ${overrideHeadless ? 'VISIBLE' : 'HEADLESS'}`);
138
+ }
139
+ // Build launch options for persistent context
140
+ // NOTE: userDataDir is passed as first parameter, NOT in options!
141
+ const launchOptions = {
142
+ headless: shouldBeHeadless,
143
+ channel: "chrome",
144
+ viewport: CONFIG.viewport,
145
+ locale: "en-US",
146
+ timezoneId: "Europe/Berlin",
147
+ // ✅ CRITICAL FIX: Pass storageState directly at launch!
148
+ // This is the PROPER way to handle session cookies (Playwright bug workaround)
149
+ // Benefits:
150
+ // - Session cookies persist correctly
151
+ // - No need for addCookies() workarounds
152
+ // - Chrome loads everything automatically
153
+ ...(statePath && { storageState: statePath }),
154
+ args: [
155
+ "--disable-blink-features=AutomationControlled",
156
+ "--disable-dev-shm-usage",
157
+ "--no-first-run",
158
+ "--no-default-browser-check",
159
+ ],
160
+ };
161
+ // 🔥 CRITICAL: launchPersistentContext creates/loads Chrome profile
162
+ // Strategy handling for concurrent instances
163
+ const baseProfile = CONFIG.chromeProfileDir;
164
+ const strategy = CONFIG.profileStrategy;
165
+ const tryLaunch = async (userDataDir) => {
166
+ log.info(" 🚀 Launching persistent Chrome context...");
167
+ log.dim(` 📍 Profile location: ${userDataDir}`);
168
+ if (statePath) {
169
+ log.info(` 📄 Loading auth state: ${statePath}`);
170
+ }
171
+ return chromium.launchPersistentContext(userDataDir, launchOptions);
172
+ };
173
+ try {
174
+ if (strategy === "isolated") {
175
+ const isolatedDir = await this.prepareIsolatedProfileDir(baseProfile);
176
+ this.globalContext = await tryLaunch(isolatedDir);
177
+ this.currentProfileDir = isolatedDir;
178
+ this.isIsolatedProfile = true;
179
+ }
180
+ else {
181
+ // single or auto → first try base
182
+ this.globalContext = await tryLaunch(baseProfile);
183
+ this.currentProfileDir = baseProfile;
184
+ this.isIsolatedProfile = false;
185
+ }
186
+ }
187
+ catch (e) {
188
+ const msg = String(e?.message || e);
189
+ const isSingleton = /ProcessSingleton|SingletonLock|profile is already in use/i.test(msg);
190
+ if (strategy === "single" || !isSingleton) {
191
+ // hard fail
192
+ if (isSingleton && strategy === "single") {
193
+ log.error("❌ Chrome profile already in use and strategy=single. Close other instance or set NOTEBOOK_PROFILE_STRATEGY=auto/isolated.");
194
+ }
195
+ throw e;
196
+ }
197
+ // auto strategy with lock → fall back to isolated instance dir
198
+ log.warning("⚠️ Base Chrome profile in use by another process. Falling back to isolated per-instance profile...");
199
+ const isolatedDir = await this.prepareIsolatedProfileDir(baseProfile);
200
+ this.globalContext = await tryLaunch(isolatedDir);
201
+ this.currentProfileDir = isolatedDir;
202
+ this.isIsolatedProfile = true;
203
+ }
204
+ this.contextCreatedAt = Date.now();
205
+ this.currentHeadlessMode = shouldBeHeadless;
206
+ // Track close event to force recreation next time
207
+ try {
208
+ this.globalContext.on("close", () => {
209
+ log.warning(" 🛑 Persistent context was closed externally");
210
+ this.globalContext = null;
211
+ this.contextCreatedAt = null;
212
+ this.currentHeadlessMode = null;
213
+ });
214
+ }
215
+ catch { }
216
+ // Validate cookies if we loaded state
217
+ if (statePath) {
218
+ try {
219
+ if (await this.authManager.validateCookiesExpiry(this.globalContext)) {
220
+ log.success(" ✅ Authentication state loaded successfully");
221
+ log.success(" 🎯 Session cookies persisted correctly!");
222
+ }
223
+ else {
224
+ log.warning(" ⚠️ Cookies expired - will need re-login");
225
+ }
226
+ }
227
+ catch (error) {
228
+ log.warning(` ⚠️ Could not validate auth state: ${error}`);
229
+ }
230
+ }
231
+ log.success("✅ Persistent context ready!");
232
+ log.dim(` Context ID: ${this.getContextId()}`);
233
+ log.dim(` Chrome Profile: ${CONFIG.chromeProfileDir}`);
234
+ log.success(" 🎯 Fingerprint: PERSISTENT (same across restarts!)");
235
+ }
236
+ /**
237
+ * Manually close the global context (e.g., on shutdown)
238
+ *
239
+ * Note: This closes the context for ALL sessions!
240
+ * Chrome will save everything to user_data_dir automatically.
241
+ */
242
+ async closeContext() {
243
+ if (this.globalContext) {
244
+ log.warning("🛑 Closing persistent context...");
245
+ log.info(" 💾 Chrome is saving profile to disk...");
246
+ try {
247
+ await this.globalContext.close();
248
+ this.globalContext = null;
249
+ this.contextCreatedAt = null;
250
+ this.currentHeadlessMode = null;
251
+ log.success("✅ Persistent context closed");
252
+ log.success(` 💾 Profile saved: ${this.currentProfileDir || CONFIG.chromeProfileDir}`);
253
+ }
254
+ catch (error) {
255
+ log.error(`❌ Error closing context: ${error}`);
256
+ }
257
+ }
258
+ // Best-effort cleanup on shutdown
259
+ if (CONFIG.cleanupInstancesOnShutdown) {
260
+ try {
261
+ // If this process used an isolated profile, remove it now
262
+ if (this.isIsolatedProfile && this.currentProfileDir) {
263
+ await this.safeRemoveIsolatedProfile(this.currentProfileDir);
264
+ }
265
+ }
266
+ catch (err) {
267
+ log.warning(` ⚠️ Cleanup (self) failed: ${err}`);
268
+ }
269
+ try {
270
+ await this.pruneIsolatedProfiles("shutdown");
271
+ }
272
+ catch (err) {
273
+ log.warning(` ⚠️ Cleanup (prune) failed: ${err}`);
274
+ }
275
+ }
276
+ }
277
+ async prepareIsolatedProfileDir(baseProfile) {
278
+ const stamp = `${process.pid}-${Date.now()}`;
279
+ const dir = path.join(CONFIG.chromeInstancesDir, `instance-${stamp}`);
280
+ try {
281
+ fs.mkdirSync(dir, { recursive: true });
282
+ if (CONFIG.cloneProfileOnIsolated && fs.existsSync(baseProfile)) {
283
+ log.info(" 🧬 Cloning base Chrome profile into isolated instance (may take time)...");
284
+ // Best-effort clone without locks
285
+ await fs.promises.cp(baseProfile, dir, {
286
+ recursive: true,
287
+ errorOnExist: false,
288
+ force: true,
289
+ filter: (src) => {
290
+ const bn = path.basename(src);
291
+ return !/^Singleton/i.test(bn) && !bn.endsWith(".lock") && !bn.endsWith(".tmp");
292
+ },
293
+ });
294
+ log.success(" ✅ Clone complete");
295
+ }
296
+ else {
297
+ log.info(" 🧪 Using fresh isolated Chrome profile (no clone)");
298
+ }
299
+ }
300
+ catch (err) {
301
+ log.warning(` ⚠️ Could not prepare isolated profile: ${err}`);
302
+ }
303
+ return dir;
304
+ }
305
+ async pruneIsolatedProfiles(phase) {
306
+ const root = CONFIG.chromeInstancesDir;
307
+ let entries;
308
+ try {
309
+ const names = await fs.promises.readdir(root, { withFileTypes: true });
310
+ entries = [];
311
+ for (const d of names) {
312
+ if (!d.isDirectory())
313
+ continue;
314
+ const p = path.join(root, d.name);
315
+ try {
316
+ const st = await fs.promises.stat(p);
317
+ entries.push({ path: p, mtimeMs: st.mtimeMs });
318
+ }
319
+ catch { }
320
+ }
321
+ }
322
+ catch {
323
+ return; // directory absent is fine
324
+ }
325
+ if (entries.length === 0)
326
+ return;
327
+ const now = Date.now();
328
+ const ttlMs = CONFIG.instanceProfileTtlHours * 3600 * 1000;
329
+ const maxCount = Math.max(0, CONFIG.instanceProfileMaxCount);
330
+ // Sort newest first
331
+ entries.sort((a, b) => b.mtimeMs - a.mtimeMs);
332
+ const keep = new Set();
333
+ const toDelete = new Set();
334
+ // Keep newest up to maxCount
335
+ for (let i = 0; i < entries.length; i++) {
336
+ const e = entries[i];
337
+ const ageMs = now - e.mtimeMs;
338
+ const overTtl = ttlMs > 0 && ageMs > ttlMs;
339
+ const overCount = i >= maxCount;
340
+ const isCurrent = this.currentProfileDir && path.resolve(e.path) === path.resolve(this.currentProfileDir);
341
+ if (!isCurrent && (overTtl || overCount)) {
342
+ toDelete.add(e.path);
343
+ }
344
+ else {
345
+ keep.add(e.path);
346
+ }
347
+ }
348
+ if (toDelete.size === 0)
349
+ return;
350
+ log.info(`🧹 Pruning isolated profiles (${phase})...`);
351
+ for (const p of toDelete) {
352
+ try {
353
+ await this.safeRemoveIsolatedProfile(p);
354
+ log.dim(` 🗑️ removed ${p}`);
355
+ }
356
+ catch (err) {
357
+ log.warning(` ⚠️ Failed to remove ${p}: ${err}`);
358
+ }
359
+ }
360
+ }
361
+ async safeRemoveIsolatedProfile(dir) {
362
+ // Never remove the base profile
363
+ if (path.resolve(dir) === path.resolve(CONFIG.chromeProfileDir))
364
+ return;
365
+ // Only remove within instances root
366
+ if (!path.resolve(dir).startsWith(path.resolve(CONFIG.chromeInstancesDir)))
367
+ return;
368
+ // Best-effort: try removing typical lock files first, then the directory
369
+ try {
370
+ await fs.promises.rm(dir, { recursive: true, force: true });
371
+ }
372
+ catch (err) {
373
+ // If rm is not available in older node, fallback to rmdir
374
+ try {
375
+ await fs.promises.rmdir(dir, { recursive: true });
376
+ }
377
+ catch { }
378
+ }
379
+ }
380
+ /**
381
+ * Get information about the global persistent context
382
+ */
383
+ getContextInfo() {
384
+ if (!this.globalContext) {
385
+ return {
386
+ exists: false,
387
+ user_data_dir: CONFIG.chromeProfileDir,
388
+ persistent: true,
389
+ };
390
+ }
391
+ const ageSeconds = this.contextCreatedAt
392
+ ? (Date.now() - this.contextCreatedAt) / 1000
393
+ : undefined;
394
+ const ageHours = ageSeconds ? ageSeconds / 3600 : undefined;
395
+ return {
396
+ exists: true,
397
+ age_seconds: ageSeconds,
398
+ age_hours: ageHours,
399
+ fingerprint_id: this.getContextId(),
400
+ user_data_dir: CONFIG.chromeProfileDir,
401
+ persistent: true,
402
+ };
403
+ }
404
+ /**
405
+ * Get the current headless mode of the browser context
406
+ *
407
+ * @returns boolean | null - true if headless, false if visible, null if no context exists
408
+ */
409
+ getCurrentHeadlessMode() {
410
+ return this.currentHeadlessMode;
411
+ }
412
+ /**
413
+ * Check if the browser context needs to be recreated due to headless mode change
414
+ *
415
+ * @param overrideHeadless - Optional override for headless mode (true = show browser)
416
+ * @returns boolean - true if context needs to be recreated with new mode
417
+ */
418
+ needsHeadlessModeChange(overrideHeadless) {
419
+ // No context exists yet = will be created with correct mode anyway
420
+ if (this.currentHeadlessMode === null) {
421
+ return false;
422
+ }
423
+ // Calculate target headless mode
424
+ // If override is specified, use it (!overrideHeadless because true = show browser = headless false)
425
+ // Otherwise, use CONFIG.headless (which may have been temporarily modified by browser_options)
426
+ const targetHeadless = overrideHeadless !== undefined
427
+ ? !overrideHeadless
428
+ : CONFIG.headless;
429
+ // Compare with current mode
430
+ const needsChange = this.currentHeadlessMode !== targetHeadless;
431
+ if (needsChange) {
432
+ log.info(` Browser mode change detected: ${this.currentHeadlessMode ? 'HEADLESS' : 'VISIBLE'} → ${targetHeadless ? 'HEADLESS' : 'VISIBLE'}`);
433
+ }
434
+ return needsChange;
435
+ }
436
+ /**
437
+ * Get context ID for logging
438
+ */
439
+ getContextId() {
440
+ if (!this.globalContext) {
441
+ return "none";
442
+ }
443
+ // Use object hash as ID
444
+ return `ctx-${this.globalContext._guid || "unknown"}`;
445
+ }
446
+ }
447
+ //# sourceMappingURL=shared-context-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-context-manager.js","sourceRoot":"","sources":["../../src/session/shared-context-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,OAAO,oBAAoB;IACvB,WAAW,CAAc;IACzB,aAAa,GAA0B,IAAI,CAAC;IAC5C,gBAAgB,GAAkB,IAAI,CAAC;IACvC,iBAAiB,GAAkB,IAAI,CAAC;IACxC,iBAAiB,GAAY,KAAK,CAAC;IACnC,mBAAmB,GAAmB,IAAI,CAAC;IAEnD,YAAY,WAAwB;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,GAAG,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;QAClE,GAAG,CAAC,IAAI,CAAC,qBAAqB,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC;QACzD,GAAG,CAAC,OAAO,CAAC,+CAA+C,CAAC,CAAC;QAE7D,yDAAyD;QACzD,IAAI,MAAM,CAAC,yBAAyB,EAAE,CAAC;YACrC,KAAK,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;QAC7C,CAAC;IACH,CA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G;QACpG,+FAA+F;QAC/F,MAAM,cAAc,GAAG,gBAAgB,KAAK,SAAS;YACnD,CAAC,CAAC,CAAC,gBAAgB;YACnB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QAEpB,4BAA4B;QAC5B,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,KAAK,cAAc,CAAC;QAEhE,IAAI,WAAW,EAAE,CAAC;YAChB,GAAG,CAAC,IAAI,CAAC,mCAAmC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QAChJ,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;OAEG;IACK,YAAY;QAClB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,wBAAwB;QACxB,OAAO,OAAQ,IAAI,CAAC,aAAqB,CAAC,KAAK,IAAI,SAAS,EAAE,CAAC;IACjE,CAAC;CACF"}
@@ -0,0 +1,225 @@
1
+ /**
2
+ * MCP Tool Implementations
3
+ *
4
+ * Implements all MCP tools for NotebookLM integration:
5
+ * - ask_question: Ask NotebookLM with session support
6
+ * - list_sessions: List all active sessions
7
+ * - close_session: Close a specific session
8
+ * - reset_session: Reset session chat history
9
+ * - get_health: Server health check
10
+ * - setup_auth: Interactive authentication setup
11
+ *
12
+ * Based on the Python implementation from tools/*.py
13
+ */
14
+ import { SessionManager } from "../session/session-manager.js";
15
+ import { AuthManager } from "../auth/auth-manager.js";
16
+ import { NotebookLibrary } from "../library/notebook-library.js";
17
+ import type { AddNotebookInput, UpdateNotebookInput } from "../library/types.js";
18
+ import { type BrowserOptions } from "../config.js";
19
+ import type { AskQuestionResult, ToolResult, Tool, ProgressCallback } from "../types.js";
20
+ /**
21
+ * Build Tool Definitions with NotebookLibrary context
22
+ */
23
+ export declare function buildToolDefinitions(library: NotebookLibrary): Tool[];
24
+ /**
25
+ * MCP Tool Handlers
26
+ */
27
+ export declare class ToolHandlers {
28
+ private sessionManager;
29
+ private authManager;
30
+ private library;
31
+ constructor(sessionManager: SessionManager, authManager: AuthManager, library: NotebookLibrary);
32
+ /**
33
+ * Handle ask_question tool
34
+ */
35
+ handleAskQuestion(args: {
36
+ question: string;
37
+ session_id?: string;
38
+ notebook_id?: string;
39
+ notebook_url?: string;
40
+ show_browser?: boolean;
41
+ browser_options?: BrowserOptions;
42
+ }, sendProgress?: ProgressCallback): Promise<ToolResult<AskQuestionResult>>;
43
+ /**
44
+ * Handle list_sessions tool
45
+ */
46
+ handleListSessions(): Promise<ToolResult<{
47
+ active_sessions: number;
48
+ max_sessions: number;
49
+ session_timeout: number;
50
+ oldest_session_seconds: number;
51
+ total_messages: number;
52
+ sessions: Array<{
53
+ id: string;
54
+ created_at: number;
55
+ last_activity: number;
56
+ age_seconds: number;
57
+ inactive_seconds: number;
58
+ message_count: number;
59
+ notebook_url: string;
60
+ }>;
61
+ }>>;
62
+ /**
63
+ * Handle close_session tool
64
+ */
65
+ handleCloseSession(args: {
66
+ session_id: string;
67
+ }): Promise<ToolResult<{
68
+ status: string;
69
+ message: string;
70
+ session_id: string;
71
+ }>>;
72
+ /**
73
+ * Handle reset_session tool
74
+ */
75
+ handleResetSession(args: {
76
+ session_id: string;
77
+ }): Promise<ToolResult<{
78
+ status: string;
79
+ message: string;
80
+ session_id: string;
81
+ }>>;
82
+ /**
83
+ * Handle get_health tool
84
+ */
85
+ handleGetHealth(): Promise<ToolResult<{
86
+ status: string;
87
+ authenticated: boolean;
88
+ notebook_url: string;
89
+ active_sessions: number;
90
+ max_sessions: number;
91
+ session_timeout: number;
92
+ total_messages: number;
93
+ headless: boolean;
94
+ auto_login_enabled: boolean;
95
+ stealth_enabled: boolean;
96
+ troubleshooting_tip?: string;
97
+ }>>;
98
+ /**
99
+ * Handle setup_auth tool
100
+ *
101
+ * Opens a browser window for manual login with live progress updates.
102
+ * The operation waits synchronously for login completion (up to 10 minutes).
103
+ */
104
+ handleSetupAuth(args: {
105
+ show_browser?: boolean;
106
+ browser_options?: BrowserOptions;
107
+ }, sendProgress?: ProgressCallback): Promise<ToolResult<{
108
+ status: string;
109
+ message: string;
110
+ authenticated: boolean;
111
+ duration_seconds?: number;
112
+ }>>;
113
+ /**
114
+ * Handle re_auth tool
115
+ *
116
+ * Performs a complete re-authentication:
117
+ * 1. Closes all active browser sessions
118
+ * 2. Deletes all saved authentication data (cookies, Chrome profile)
119
+ * 3. Opens browser for fresh Google login
120
+ *
121
+ * Use for switching Google accounts or recovering from rate limits.
122
+ */
123
+ handleReAuth(args: {
124
+ show_browser?: boolean;
125
+ browser_options?: BrowserOptions;
126
+ }, sendProgress?: ProgressCallback): Promise<ToolResult<{
127
+ status: string;
128
+ message: string;
129
+ authenticated: boolean;
130
+ duration_seconds?: number;
131
+ }>>;
132
+ /**
133
+ * Handle add_notebook tool
134
+ */
135
+ handleAddNotebook(args: AddNotebookInput): Promise<ToolResult<{
136
+ notebook: any;
137
+ }>>;
138
+ /**
139
+ * Handle list_notebooks tool
140
+ */
141
+ handleListNotebooks(): Promise<ToolResult<{
142
+ notebooks: any[];
143
+ active_notebook_id: string | null;
144
+ }>>;
145
+ /**
146
+ * Handle get_notebook tool
147
+ */
148
+ handleGetNotebook(args: {
149
+ id: string;
150
+ }): Promise<ToolResult<{
151
+ notebook: any;
152
+ }>>;
153
+ /**
154
+ * Handle select_notebook tool
155
+ */
156
+ handleSelectNotebook(args: {
157
+ id: string;
158
+ }): Promise<ToolResult<{
159
+ notebook: any;
160
+ }>>;
161
+ /**
162
+ * Handle update_notebook tool
163
+ */
164
+ handleUpdateNotebook(args: UpdateNotebookInput): Promise<ToolResult<{
165
+ notebook: any;
166
+ }>>;
167
+ /**
168
+ * Handle remove_notebook tool
169
+ */
170
+ handleRemoveNotebook(args: {
171
+ id: string;
172
+ }): Promise<ToolResult<{
173
+ removed: boolean;
174
+ closed_sessions: number;
175
+ }>>;
176
+ /**
177
+ * Handle search_notebooks tool
178
+ */
179
+ handleSearchNotebooks(args: {
180
+ query: string;
181
+ }): Promise<ToolResult<{
182
+ notebooks: any[];
183
+ }>>;
184
+ /**
185
+ * Handle get_library_stats tool
186
+ */
187
+ handleGetLibraryStats(): Promise<ToolResult<any>>;
188
+ /**
189
+ * Handle cleanup_data tool
190
+ *
191
+ * ULTRATHINK Deep Cleanup - scans entire system for ALL NotebookLM MCP files
192
+ */
193
+ handleCleanupData(args: {
194
+ confirm: boolean;
195
+ preserve_library?: boolean;
196
+ }): Promise<ToolResult<{
197
+ status: string;
198
+ mode: string;
199
+ preview?: {
200
+ categories: Array<{
201
+ name: string;
202
+ description: string;
203
+ paths: string[];
204
+ totalBytes: number;
205
+ optional: boolean;
206
+ }>;
207
+ totalPaths: number;
208
+ totalSizeBytes: number;
209
+ };
210
+ result?: {
211
+ deletedPaths: string[];
212
+ failedPaths: string[];
213
+ totalSizeBytes: number;
214
+ categorySummary: Record<string, {
215
+ count: number;
216
+ bytes: number;
217
+ }>;
218
+ };
219
+ }>>;
220
+ /**
221
+ * Cleanup all resources (called on server shutdown)
222
+ */
223
+ cleanup(): Promise<void>;
224
+ }
225
+ //# sourceMappingURL=index.d.ts.map