@roomi-fields/notebooklm-mcp 1.3.5 → 1.5.0
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.
- package/README.md +93 -658
- package/dist/accounts/account-manager.d.ts +163 -0
- package/dist/accounts/account-manager.d.ts.map +1 -0
- package/dist/accounts/account-manager.js +614 -0
- package/dist/accounts/account-manager.js.map +1 -0
- package/dist/accounts/auto-login-manager.d.ts +62 -0
- package/dist/accounts/auto-login-manager.d.ts.map +1 -0
- package/dist/accounts/auto-login-manager.js +537 -0
- package/dist/accounts/auto-login-manager.js.map +1 -0
- package/dist/accounts/crypto.d.ts +45 -0
- package/dist/accounts/crypto.d.ts.map +1 -0
- package/dist/accounts/crypto.js +138 -0
- package/dist/accounts/crypto.js.map +1 -0
- package/dist/accounts/index.d.ts +14 -0
- package/dist/accounts/index.d.ts.map +1 -0
- package/dist/accounts/index.js +14 -0
- package/dist/accounts/index.js.map +1 -0
- package/dist/accounts/types.d.ts +103 -0
- package/dist/accounts/types.d.ts.map +1 -0
- package/dist/accounts/types.js +7 -0
- package/dist/accounts/types.js.map +1 -0
- package/dist/auth/auth-manager.d.ts +9 -2
- package/dist/auth/auth-manager.d.ts.map +1 -1
- package/dist/auth/auth-manager.js +60 -6
- package/dist/auth/auth-manager.js.map +1 -1
- package/dist/auto-discovery/auto-discovery.d.ts.map +1 -1
- package/dist/auto-discovery/auto-discovery.js +2 -1
- package/dist/auto-discovery/auto-discovery.js.map +1 -1
- package/dist/cli/accounts.d.ts +13 -0
- package/dist/cli/accounts.d.ts.map +1 -0
- package/dist/cli/accounts.js +195 -0
- package/dist/cli/accounts.js.map +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -0
- package/dist/config.js.map +1 -1
- package/dist/content/content-generator.d.ts +153 -0
- package/dist/content/content-generator.d.ts.map +1 -0
- package/dist/content/content-generator.js +637 -0
- package/dist/content/content-generator.js.map +1 -0
- package/dist/content/content-manager.d.ts +364 -0
- package/dist/content/content-manager.d.ts.map +1 -0
- package/dist/content/content-manager.js +3846 -0
- package/dist/content/content-manager.js.map +1 -0
- package/dist/content/content-templates.d.ts +183 -0
- package/dist/content/content-templates.d.ts.map +1 -0
- package/dist/content/content-templates.js +719 -0
- package/dist/content/content-templates.js.map +1 -0
- package/dist/content/index.d.ts +14 -0
- package/dist/content/index.d.ts.map +1 -0
- package/dist/content/index.js +14 -0
- package/dist/content/index.js.map +1 -0
- package/dist/content/types.d.ts +285 -0
- package/dist/content/types.d.ts.map +1 -0
- package/dist/content/types.js +10 -0
- package/dist/content/types.js.map +1 -0
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/http-wrapper.d.ts +7 -0
- package/dist/http-wrapper.d.ts.map +1 -1
- package/dist/http-wrapper.js +449 -29
- package/dist/http-wrapper.js.map +1 -1
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/dist/library/notebook-library.d.ts +4 -0
- package/dist/library/notebook-library.d.ts.map +1 -1
- package/dist/library/notebook-library.js +20 -3
- package/dist/library/notebook-library.js.map +1 -1
- package/dist/session/browser-session.d.ts +35 -8
- package/dist/session/browser-session.d.ts.map +1 -1
- package/dist/session/browser-session.js +242 -28
- package/dist/session/browser-session.js.map +1 -1
- package/dist/session/session-manager.d.ts +6 -0
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +46 -14
- package/dist/session/session-manager.js.map +1 -1
- package/dist/session/shared-context-manager.d.ts +3 -3
- package/dist/session/shared-context-manager.d.ts.map +1 -1
- package/dist/session/shared-context-manager.js +8 -7
- package/dist/session/shared-context-manager.js.map +1 -1
- package/dist/stdio-http-proxy.d.ts +24 -0
- package/dist/stdio-http-proxy.d.ts.map +1 -0
- package/dist/stdio-http-proxy.js +592 -0
- package/dist/stdio-http-proxy.js.map +1 -0
- package/dist/tools/index.d.ts +106 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1028 -7
- package/dist/tools/index.js.map +1 -1
- package/dist/types.d.ts +81 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/citation-extractor.d.ts +66 -0
- package/dist/utils/citation-extractor.d.ts.map +1 -0
- package/dist/utils/citation-extractor.js +492 -0
- package/dist/utils/citation-extractor.js.map +1 -0
- package/dist/utils/page-utils.d.ts +8 -0
- package/dist/utils/page-utils.d.ts.map +1 -1
- package/dist/utils/page-utils.js +112 -8
- package/dist/utils/page-utils.js.map +1 -1
- package/docs/ARCHITECTURE_MIGRATION_STUDY.md +894 -0
- package/docs/CHROME_PROFILE_LIMITATION.md +15 -1
- package/docs/MULTI_ACCOUNT_SYSTEM.md +304 -0
- package/package.json +10 -10
- package/dist/__tests__/cleanup-manager.test.d.ts +0 -2
- package/dist/__tests__/cleanup-manager.test.d.ts.map +0 -1
- package/dist/__tests__/cleanup-manager.test.js +0 -341
- package/dist/__tests__/cleanup-manager.test.js.map +0 -1
- package/dist/__tests__/config-parsing.test.d.ts +0 -2
- package/dist/__tests__/config-parsing.test.d.ts.map +0 -1
- package/dist/__tests__/config-parsing.test.js +0 -338
- package/dist/__tests__/config-parsing.test.js.map +0 -1
- package/dist/__tests__/config.test.d.ts +0 -2
- package/dist/__tests__/config.test.d.ts.map +0 -1
- package/dist/__tests__/config.test.js +0 -267
- package/dist/__tests__/config.test.js.map +0 -1
- package/dist/__tests__/errors.test.d.ts +0 -2
- package/dist/__tests__/errors.test.d.ts.map +0 -1
- package/dist/__tests__/errors.test.js +0 -166
- package/dist/__tests__/errors.test.js.map +0 -1
- package/dist/__tests__/logger.test.d.ts +0 -2
- package/dist/__tests__/logger.test.d.ts.map +0 -1
- package/dist/__tests__/logger.test.js +0 -324
- package/dist/__tests__/logger.test.js.map +0 -1
- package/dist/__tests__/page-utils.test.d.ts +0 -2
- package/dist/__tests__/page-utils.test.d.ts.map +0 -1
- package/dist/__tests__/page-utils.test.js +0 -349
- package/dist/__tests__/page-utils.test.js.map +0 -1
- package/dist/__tests__/setup-verification.test.d.ts +0 -2
- package/dist/__tests__/setup-verification.test.d.ts.map +0 -1
- package/dist/__tests__/setup-verification.test.js +0 -15
- package/dist/__tests__/setup-verification.test.js.map +0 -1
- package/dist/__tests__/stealth-utils.test.d.ts +0 -2
- package/dist/__tests__/stealth-utils.test.d.ts.map +0 -1
- package/dist/__tests__/stealth-utils.test.js +0 -413
- package/dist/__tests__/stealth-utils.test.js.map +0 -1
- package/dist/__tests__/types.test.d.ts +0 -2
- package/dist/__tests__/types.test.d.ts.map +0 -1
- package/dist/__tests__/types.test.js +0 -461
- package/dist/__tests__/types.test.js.map +0 -1
|
@@ -0,0 +1,894 @@
|
|
|
1
|
+
# NotebookLM MCP - Étude de Migration d'Architecture
|
|
2
|
+
|
|
3
|
+
> **Date**: Décembre 2024
|
|
4
|
+
> **Statut**: Étude préliminaire
|
|
5
|
+
> **Conclusion**: Migration non recommandée actuellement (API incomplète)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Résumé Exécutif
|
|
10
|
+
|
|
11
|
+
Cette étude analyse les options pour industrialiser l'authentification et migrer vers l'API officielle NotebookLM Enterprise.
|
|
12
|
+
|
|
13
|
+
**Conclusion principale**: L'API Enterprise ne couvre pas les fonctionnalités essentielles (interrogation du notebook, génération de contenus). La migration n'est pas justifiée actuellement mais devra être réévaluée quand Google étendra l'API.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Table des Matières
|
|
18
|
+
|
|
19
|
+
1. [Contexte et Objectifs](#1-contexte-et-objectifs)
|
|
20
|
+
2. [Architecture Actuelle](#2-architecture-actuelle)
|
|
21
|
+
3. [Options d'Architecture](#3-options-darchitecture)
|
|
22
|
+
4. [Comparaison des Fonctionnalités](#4-comparaison-des-fonctionnalités)
|
|
23
|
+
5. [Analyse des Coûts](#5-analyse-des-coûts)
|
|
24
|
+
6. [Matrice Avantages/Limites](#6-matrice-avantageslimites)
|
|
25
|
+
7. [Recommandations](#7-recommandations)
|
|
26
|
+
8. [Roadmap et Points de Réévaluation](#8-roadmap-et-points-de-réévaluation)
|
|
27
|
+
9. [Industrialisation de l'Authentification](#9-industrialisation-de-lauthentification-sans-api-enterprise)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 1. Contexte et Objectifs
|
|
32
|
+
|
|
33
|
+
### 1.1 Situation Actuelle
|
|
34
|
+
|
|
35
|
+
Le MCP NotebookLM utilise **Playwright (browser automation)** pour interagir avec NotebookLM car aucune API officielle n'existait au moment du développement.
|
|
36
|
+
|
|
37
|
+
### 1.2 Objectif Principal
|
|
38
|
+
|
|
39
|
+
**Industrialiser l'authentification** pour:
|
|
40
|
+
|
|
41
|
+
- Éliminer la dépendance aux cookies browser
|
|
42
|
+
- Permettre l'authentification M2M (Machine-to-Machine)
|
|
43
|
+
- Augmenter la fiabilité et réduire les interventions manuelles
|
|
44
|
+
- Supporter plusieurs comptes avec rotation
|
|
45
|
+
|
|
46
|
+
### 1.3 Découverte
|
|
47
|
+
|
|
48
|
+
Google a lancé une **API NotebookLM Enterprise** (Discovery Engine API) mais celle-ci est **incomplète** pour nos besoins.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 2. Architecture Actuelle
|
|
53
|
+
|
|
54
|
+
### 2.1 Diagramme
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
58
|
+
│ ARCHITECTURE ACTUELLE (Playwright) │
|
|
59
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
60
|
+
│ │
|
|
61
|
+
│ ┌──────────┐ ┌──────────────┐ ┌─────────────────────────────┐ │
|
|
62
|
+
│ │ Client │────▶│ HTTP Server │────▶│ Playwright/Patchright │ │
|
|
63
|
+
│ │ (MCP) │ │ (Express) │ │ (Browser Automation) │ │
|
|
64
|
+
│ └──────────┘ └──────────────┘ └──────────────┬───────────────┘ │
|
|
65
|
+
│ │ │
|
|
66
|
+
│ ▼ │
|
|
67
|
+
│ ┌─────────────────────────────┐ │
|
|
68
|
+
│ │ NotebookLM Web UI │ │
|
|
69
|
+
│ │ (notebooklm.google.com) │ │
|
|
70
|
+
│ └─────────────────────────────┘ │
|
|
71
|
+
│ │
|
|
72
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
73
|
+
│ AUTHENTIFICATION: │
|
|
74
|
+
│ ├── Login manuel initial (setup_auth) │
|
|
75
|
+
│ ├── Cookies sauvegardés (~/.notebooklm-mcp/auth-state.json) │
|
|
76
|
+
│ ├── SessionStorage persisté │
|
|
77
|
+
│ └── Auto-refresh si cookies expirés │
|
|
78
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
79
|
+
│ LIMITATIONS: │
|
|
80
|
+
│ ├── Compte unique = point de défaillance unique │
|
|
81
|
+
│ ├── Rate limit 50 queries/jour (compte gratuit) │
|
|
82
|
+
│ ├── Expiration cookies (~2 semaines) │
|
|
83
|
+
│ ├── Détection activité suspecte par Google │
|
|
84
|
+
│ └── Fragilité si l'UI NotebookLM change │
|
|
85
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 2.2 Stack Technique
|
|
89
|
+
|
|
90
|
+
| Composant | Technologie | Rôle |
|
|
91
|
+
| -------------- | ---------------------------- | ----------------------------- |
|
|
92
|
+
| Runtime | Node.js 18+ | Exécution |
|
|
93
|
+
| Browser Engine | Patchright (Playwright fork) | Automation avec stealth |
|
|
94
|
+
| HTTP Server | Express.js | API REST pour les clients MCP |
|
|
95
|
+
| Auth Storage | JSON files | Persistance cookies/session |
|
|
96
|
+
| Stealth | Custom utils | Comportement humain simulé |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 3. Options d'Architecture
|
|
101
|
+
|
|
102
|
+
### 3.1 Option A: Statu Quo (Playwright seul)
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
106
|
+
│ OPTION A: PLAYWRIGHT SEUL (actuel) │
|
|
107
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
108
|
+
│ │
|
|
109
|
+
│ Client ──▶ HTTP Server ──▶ Playwright ──▶ NotebookLM Web UI │
|
|
110
|
+
│ │
|
|
111
|
+
│ Améliorations possibles: │
|
|
112
|
+
│ ├── Pool de comptes avec rotation │
|
|
113
|
+
│ ├── Browser profiles persistants │
|
|
114
|
+
│ ├── Quota tracking par compte │
|
|
115
|
+
│ └── Failover automatique │
|
|
116
|
+
│ │
|
|
117
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 3.2 Option B: API Enterprise (complète)
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
124
|
+
│ OPTION B: API ENTERPRISE SEULE (hypothétique - API incomplète) │
|
|
125
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
126
|
+
│ │
|
|
127
|
+
│ Client ──▶ HTTP Server ──▶ Google Cloud API ──▶ NotebookLM Backend │
|
|
128
|
+
│ │ │
|
|
129
|
+
│ ▼ │
|
|
130
|
+
│ Service Account / OAuth 2.0 │
|
|
131
|
+
│ │
|
|
132
|
+
│ ❌ NON VIABLE: L'API ne supporte pas l'interrogation (chat/query) │
|
|
133
|
+
│ │
|
|
134
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 3.3 Option C: Architecture Hybride
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
141
|
+
│ OPTION C: HYBRIDE (API + Playwright) │
|
|
142
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
143
|
+
│ │
|
|
144
|
+
│ ┌──────────────────────────────────────────────────────────────────┐ │
|
|
145
|
+
│ │ MCP NotebookLM v2 │ │
|
|
146
|
+
│ └──────────────────────────────────────────────────────────────────┘ │
|
|
147
|
+
│ │ │
|
|
148
|
+
│ ┌───────────────────────┴───────────────────────┐ │
|
|
149
|
+
│ ▼ ▼ │
|
|
150
|
+
│ ┌─────────────────────┐ ┌─────────────────────────┐ │
|
|
151
|
+
│ │ API Enterprise │ │ Playwright │ │
|
|
152
|
+
│ │ (Google Cloud) │ │ (Browser Automation) │ │
|
|
153
|
+
│ ├─────────────────────┤ ├─────────────────────────┤ │
|
|
154
|
+
│ │ • Create notebook │ │ • Ask questions │ │
|
|
155
|
+
│ │ • Add/manage sources│ │ • Generate guides │ │
|
|
156
|
+
│ │ • Generate audio │ │ • Extract responses │ │
|
|
157
|
+
│ │ • Share notebook │ │ • Download content │ │
|
|
158
|
+
│ │ • M2M Auth (OAuth) │ │ • Web search sources │ │
|
|
159
|
+
│ └─────────────────────┘ └─────────────────────────┘ │
|
|
160
|
+
│ │ │ │
|
|
161
|
+
│ ▼ ▼ │
|
|
162
|
+
│ Service Account Cookies/Session │
|
|
163
|
+
│ (pas d'intervention humaine) (login manuel requis) │
|
|
164
|
+
│ │
|
|
165
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## 4. Comparaison des Fonctionnalités
|
|
171
|
+
|
|
172
|
+
### 4.1 Fonctionnalités par Mode d'Accès
|
|
173
|
+
|
|
174
|
+
| Fonctionnalité | API Enterprise | Playwright | Notes |
|
|
175
|
+
| ------------------------------ | :------------: | :--------: | ----------------------------- |
|
|
176
|
+
| **Gestion Notebooks** | | | |
|
|
177
|
+
| Créer notebook | ✅ | ✅ | API préférable |
|
|
178
|
+
| Lister notebooks | ✅ | ⚠️ | API plus fiable |
|
|
179
|
+
| Supprimer notebook | ✅ | ⚠️ | API préférable |
|
|
180
|
+
| Partager notebook | ✅ | ⚠️ | API avec rôles IAM |
|
|
181
|
+
| **Gestion Sources** | | | |
|
|
182
|
+
| Ajouter source (fichier) | ✅ | ✅ | API plus simple |
|
|
183
|
+
| Ajouter source (URL) | ✅ | ✅ | API plus simple |
|
|
184
|
+
| Ajouter source (texte) | ✅ | ✅ | API plus simple |
|
|
185
|
+
| Ajouter source (Google Drive) | ✅ | ⚠️ | API native |
|
|
186
|
+
| Ajouter source (YouTube) | ✅ | ✅ | Équivalent |
|
|
187
|
+
| Lister sources | ✅ | ⚠️ | API plus fiable |
|
|
188
|
+
| Supprimer sources | ✅ | ⚠️ | API préférable |
|
|
189
|
+
| Discover sources (web search) | ❌ | ✅ | Playwright seul |
|
|
190
|
+
| **Génération Contenu** | | | |
|
|
191
|
+
| Audio Overview | ✅ | ✅ | API préférable |
|
|
192
|
+
| Podcast (standalone) | ✅ | ❌ | API exclusive |
|
|
193
|
+
| Study Guide | ❌ | ✅ | Playwright seul |
|
|
194
|
+
| Briefing Doc | ❌ | ✅ | Playwright seul |
|
|
195
|
+
| Timeline | ❌ | ✅ | Playwright seul |
|
|
196
|
+
| FAQ | ❌ | ✅ | Playwright seul |
|
|
197
|
+
| Table of Contents | ❌ | ✅ | Playwright seul |
|
|
198
|
+
| Mind Map | ❌ | ✅ | Playwright seul |
|
|
199
|
+
| **Interaction** | | | |
|
|
200
|
+
| **Poser des questions (chat)** | ❌ | ✅ | **CRITIQUE: Playwright seul** |
|
|
201
|
+
| Extraire réponses | ❌ | ✅ | Playwright seul |
|
|
202
|
+
| Historique conversation | ❌ | ✅ | Playwright seul |
|
|
203
|
+
| **Export** | | | |
|
|
204
|
+
| Télécharger audio (WAV) | ⚠️ | ✅ | Via UI |
|
|
205
|
+
| Télécharger mind map (image) | ❌ | ✅ | Playwright seul |
|
|
206
|
+
| Exporter texte généré | ❌ | ✅ | Playwright seul |
|
|
207
|
+
|
|
208
|
+
### 4.2 Résumé Couverture
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
212
|
+
│ COUVERTURE FONCTIONNELLE │
|
|
213
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
214
|
+
│ │
|
|
215
|
+
│ API Enterprise: ████████░░░░░░░░░░░░ ~40% des fonctionnalités │
|
|
216
|
+
│ Playwright: ████████████████████ ~100% des fonctionnalités │
|
|
217
|
+
│ │
|
|
218
|
+
│ ⚠️ LA FONCTION LA PLUS IMPORTANTE (chat/query) N'EST PAS DANS L'API │
|
|
219
|
+
│ │
|
|
220
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 5. Analyse des Coûts
|
|
226
|
+
|
|
227
|
+
### 5.1 Coûts Directs
|
|
228
|
+
|
|
229
|
+
| Option | Coût Mensuel | Coût Annuel | Notes |
|
|
230
|
+
| ------------------------ | ------------ | ------------ | ------------------------------ |
|
|
231
|
+
| **Gratuit (Playwright)** | $0 | $0 | 50 queries/jour, 100 notebooks |
|
|
232
|
+
| **NotebookLM Plus** | ~$10/user | ~$120/user | Via Workspace, 5x limites |
|
|
233
|
+
| **Enterprise** | $9/licence | $108/licence | API access, M2M auth |
|
|
234
|
+
| **Gemini Enterprise** | $30/user | $360/user | Inclut NotebookLM Enterprise |
|
|
235
|
+
|
|
236
|
+
### 5.2 Coûts API (estimés)
|
|
237
|
+
|
|
238
|
+
| Opération | Pricing | Notes |
|
|
239
|
+
| ---------------- | ------------------ | -------------------------------- |
|
|
240
|
+
| API Calls | Non documenté | Probablement inclus dans licence |
|
|
241
|
+
| Storage | Standard GCP rates | Si data stores utilisés |
|
|
242
|
+
| Audio Generation | Non documenté | Potentiellement pay-as-you-go |
|
|
243
|
+
|
|
244
|
+
### 5.3 Coûts Cachés
|
|
245
|
+
|
|
246
|
+
| Élément | Option Gratuite | Option Enterprise |
|
|
247
|
+
| --------------------- | --------------- | ------------------- |
|
|
248
|
+
| Maintenance cookies | ~1h/mois | $0 (M2M) |
|
|
249
|
+
| Gestion multi-comptes | Complexe | Native (IAM) |
|
|
250
|
+
| Debugging UI changes | Variable | Réduit (API stable) |
|
|
251
|
+
| Support Google | Aucun | Inclus |
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## 6. Matrice Avantages/Limites
|
|
256
|
+
|
|
257
|
+
### 6.1 Option A: Playwright Seul (Statu Quo)
|
|
258
|
+
|
|
259
|
+
| Avantages | Limites |
|
|
260
|
+
| --------------------------- | -------------------------------- |
|
|
261
|
+
| ✅ Gratuit | ❌ Auth fragile (cookies) |
|
|
262
|
+
| ✅ 100% des fonctionnalités | ❌ Rate limit 50/jour |
|
|
263
|
+
| ✅ Pas de dépendance GCP | ❌ Maintenance si UI change |
|
|
264
|
+
| ✅ Fonctionne maintenant | ❌ Pas de M2M natif |
|
|
265
|
+
| ✅ Contrôle total | ❌ Détection possible par Google |
|
|
266
|
+
|
|
267
|
+
### 6.2 Option B: API Enterprise Seule
|
|
268
|
+
|
|
269
|
+
| Avantages | Limites |
|
|
270
|
+
| ------------------------------- | ---------------------------------- |
|
|
271
|
+
| ✅ Auth M2M (Service Account) | ❌ **Pas de chat/query API** |
|
|
272
|
+
| ✅ API stable et versionnée | ❌ **Pas de génération guides** |
|
|
273
|
+
| ✅ Quotas plus élevés | ❌ Coût $9/mois minimum |
|
|
274
|
+
| ✅ Support Google | ❌ Fonctionnalités limitées (~40%) |
|
|
275
|
+
| ✅ Sécurité enterprise (VPC-SC) | ❌ Lock-in Google Cloud |
|
|
276
|
+
|
|
277
|
+
### 6.3 Option C: Hybride (API + Playwright)
|
|
278
|
+
|
|
279
|
+
| Avantages | Limites |
|
|
280
|
+
| --------------------------------- | --------------------------------------- |
|
|
281
|
+
| ✅ Meilleur des deux mondes | ❌ Complexité accrue |
|
|
282
|
+
| ✅ M2M pour sources/audio | ❌ Toujours besoin de cookies pour chat |
|
|
283
|
+
| ✅ 100% fonctionnalités | ❌ Coût $9/mois + maintenance |
|
|
284
|
+
| ✅ Migration progressive possible | ❌ Deux systèmes à maintenir |
|
|
285
|
+
| ✅ Fallback si API évolue | ❌ Overhead développement |
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## 7. Recommandations
|
|
290
|
+
|
|
291
|
+
### 7.1 Décision: NE PAS MIGRER (pour l'instant)
|
|
292
|
+
|
|
293
|
+
```
|
|
294
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
295
|
+
│ RECOMMANDATION FINALE │
|
|
296
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
297
|
+
│ │
|
|
298
|
+
│ ❌ MIGRATION NON RECOMMANDÉE ACTUELLEMENT │
|
|
299
|
+
│ │
|
|
300
|
+
│ Raison principale: │
|
|
301
|
+
│ L'API Enterprise ne supporte pas la fonctionnalité critique: │
|
|
302
|
+
│ → Interrogation du notebook (chat/query) │
|
|
303
|
+
│ │
|
|
304
|
+
│ Sans cette fonctionnalité, l'API n'apporte pas de valeur │
|
|
305
|
+
│ suffisante pour justifier le coût de $9/mois/licence. │
|
|
306
|
+
│ │
|
|
307
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### 7.2 Actions Court Terme (0-3 mois)
|
|
311
|
+
|
|
312
|
+
| Action | Priorité | Effort | Impact |
|
|
313
|
+
| ------------------------------ | -------- | --------- | ----------------- |
|
|
314
|
+
| Pool de comptes gratuits (3-5) | Haute | 2-3 jours | Résilience auth |
|
|
315
|
+
| Quota tracking par compte | Haute | 1 jour | Évite rate limits |
|
|
316
|
+
| Browser profiles persistants | Moyenne | 2 jours | Stabilité auth |
|
|
317
|
+
| Failover automatique | Moyenne | 1 jour | Disponibilité |
|
|
318
|
+
|
|
319
|
+
### 7.3 Actions si API Évolue
|
|
320
|
+
|
|
321
|
+
Quand Google ajoutera l'endpoint `notebooks.query` ou équivalent:
|
|
322
|
+
|
|
323
|
+
1. Réévaluer la migration hybride
|
|
324
|
+
2. Implémenter d'abord pour sources/audio (M2M)
|
|
325
|
+
3. Migrer progressivement les fonctionnalités supportées
|
|
326
|
+
4. Conserver Playwright comme fallback
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## 8. Roadmap et Points de Réévaluation
|
|
331
|
+
|
|
332
|
+
### 8.1 Timeline
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
336
|
+
│ ROADMAP │
|
|
337
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
338
|
+
│ │
|
|
339
|
+
│ Q1 2025: Améliorer architecture actuelle │
|
|
340
|
+
│ ├── Pool multi-comptes │
|
|
341
|
+
│ ├── Quota tracking │
|
|
342
|
+
│ └── Monitoring/alerting │
|
|
343
|
+
│ │
|
|
344
|
+
│ Q2 2025: Surveiller évolution API Google │
|
|
345
|
+
│ ├── Veille sur notebooks.query/chat endpoint │
|
|
346
|
+
│ ├── Réévaluer si >60% couverture fonctionnelle │
|
|
347
|
+
│ └── POC hybride si pertinent │
|
|
348
|
+
│ │
|
|
349
|
+
│ Q3-Q4 2025: Migration potentielle │
|
|
350
|
+
│ ├── Si API complète: migration progressive │
|
|
351
|
+
│ └── Si API incomplète: continuer Playwright │
|
|
352
|
+
│ │
|
|
353
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### 8.2 Critères de Réévaluation
|
|
357
|
+
|
|
358
|
+
Réévaluer la migration si l'API ajoute:
|
|
359
|
+
|
|
360
|
+
- [ ] `notebooks.query` ou `notebooks.chat` - Interrogation du notebook
|
|
361
|
+
- [ ] `notebooks.generate` - Génération de Study Guide, Timeline, etc.
|
|
362
|
+
- [ ] `notebooks.export` - Export des contenus générés
|
|
363
|
+
- [ ] Pricing transparent pour les API calls
|
|
364
|
+
|
|
365
|
+
### 8.3 Sources de Veille
|
|
366
|
+
|
|
367
|
+
| Source | URL | Fréquence |
|
|
368
|
+
| ------------------------ | ----------------------------------------------- | ------------ |
|
|
369
|
+
| Google Cloud Blog | cloud.google.com/blog | Mensuelle |
|
|
370
|
+
| NotebookLM Release Notes | support.google.com/notebooklm | Bi-mensuelle |
|
|
371
|
+
| API Documentation | docs.cloud.google.com/.../notebooklm-enterprise | Mensuelle |
|
|
372
|
+
| Google AI Forum | discuss.ai.google.dev | Hebdomadaire |
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## Annexes
|
|
377
|
+
|
|
378
|
+
### A. Endpoints API Enterprise (Décembre 2024)
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
Base URL: https://{LOCATION}-discoveryengine.googleapis.com/v1alpha
|
|
382
|
+
|
|
383
|
+
Notebooks:
|
|
384
|
+
POST /projects/{project}/locations/{location}/notebooks # Create
|
|
385
|
+
GET /projects/{project}/locations/{location}/notebooks/{id} # Get
|
|
386
|
+
GET /projects/{project}/locations/{location}/notebooks:listRecentlyViewed # List
|
|
387
|
+
POST /projects/{project}/locations/{location}/notebooks:batchDelete # Delete
|
|
388
|
+
POST /projects/{project}/locations/{location}/notebooks/{id}:share # Share
|
|
389
|
+
|
|
390
|
+
Sources:
|
|
391
|
+
POST /projects/{project}/locations/{location}/notebooks/{id}/sources:batchCreate # Add
|
|
392
|
+
POST /projects/{project}/locations/{location}/notebooks/{id}/sources:uploadFile # Upload
|
|
393
|
+
GET /projects/{project}/locations/{location}/notebooks/{id}/sources/{sourceId} # Get
|
|
394
|
+
POST /projects/{project}/locations/{location}/notebooks/{id}/sources:batchDelete # Delete
|
|
395
|
+
|
|
396
|
+
Audio:
|
|
397
|
+
POST /projects/{project}/locations/{location}/notebooks/{id}/audioOverviews # Create
|
|
398
|
+
DELETE /projects/{project}/locations/{location}/notebooks/{id}/audioOverviews/{aoId} # Delete
|
|
399
|
+
|
|
400
|
+
Podcasts (standalone):
|
|
401
|
+
POST /projects/{project}/locations/{location}/podcasts # Create
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### B. Authentification API Enterprise
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
# Option 1: Service Account (M2M - recommandé pour production)
|
|
408
|
+
gcloud auth activate-service-account \
|
|
409
|
+
--key-file=/path/to/service-account-key.json
|
|
410
|
+
|
|
411
|
+
# Option 2: User Account (interactif)
|
|
412
|
+
gcloud auth login --enable-gdrive-access
|
|
413
|
+
|
|
414
|
+
# Obtenir token
|
|
415
|
+
TOKEN=$(gcloud auth print-access-token)
|
|
416
|
+
|
|
417
|
+
# Exemple d'appel API
|
|
418
|
+
curl -X POST \
|
|
419
|
+
"https://us-discoveryengine.googleapis.com/v1alpha/projects/123/locations/us/notebooks" \
|
|
420
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
421
|
+
-H "Content-Type: application/json" \
|
|
422
|
+
-d '{"displayName": "Mon Notebook"}'
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### C. Références
|
|
426
|
+
|
|
427
|
+
- [NotebookLM Enterprise Documentation](https://docs.cloud.google.com/gemini/enterprise/notebooklm-enterprise/docs/overview)
|
|
428
|
+
- [API Notebooks](https://docs.cloud.google.com/gemini/enterprise/notebooklm-enterprise/docs/api-notebooks)
|
|
429
|
+
- [API Sources](https://docs.cloud.google.com/gemini/enterprise/notebooklm-enterprise/docs/api-notebooks-sources)
|
|
430
|
+
- [API Audio Overview](https://docs.cloud.google.com/gemini/enterprise/notebooklm-enterprise/docs/api-audio-overview)
|
|
431
|
+
- [NotebookLM Pricing](https://www.elite.cloud/post/notebooklm-pricing-2025-free-plan-vs-paid-plan-which-one-actually-saves-you-time/)
|
|
432
|
+
- [NotebookLM for Enterprise](https://cloud.google.com/resources/notebooklm-enterprise)
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## 9. Industrialisation de l'Authentification (sans API Enterprise)
|
|
437
|
+
|
|
438
|
+
Cette section détaille les options pour robustifier l'authentification Playwright sans migrer vers l'API Enterprise.
|
|
439
|
+
|
|
440
|
+
### 9.1 Problématique OAuth vs Session Cookies
|
|
441
|
+
|
|
442
|
+
```
|
|
443
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
444
|
+
│ POURQUOI OAUTH NE RÉSOUT PAS LE PROBLÈME DIRECTEMENT │
|
|
445
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
446
|
+
│ │
|
|
447
|
+
│ NotebookLM Web UI utilise: │
|
|
448
|
+
│ └── Session cookies Google (SID, HSID, SSID, APISID, SAPISID) │
|
|
449
|
+
│ ├── Durée: ~2 semaines │
|
|
450
|
+
│ └── Générés lors du login web │
|
|
451
|
+
│ │
|
|
452
|
+
│ OAuth 2.0 produit: │
|
|
453
|
+
│ └── Access tokens + Refresh tokens │
|
|
454
|
+
│ ├── Pour APIs Google (Drive, Cloud, etc.) │
|
|
455
|
+
│ └── NON convertibles en session cookies web ❌ │
|
|
456
|
+
│ │
|
|
457
|
+
│ Résultat: │
|
|
458
|
+
│ ├── OAuth fonctionne pour l'API Enterprise (si on l'utilisait) │
|
|
459
|
+
│ ├── OAuth NE fonctionne PAS pour l'UI web NotebookLM │
|
|
460
|
+
│ └── On doit maintenir des sessions web via Playwright │
|
|
461
|
+
│ │
|
|
462
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### 9.2 Options d'Industrialisation
|
|
466
|
+
|
|
467
|
+
#### Option 1: Comptes Dédiés + Credentials Stockés (Sans 2FA)
|
|
468
|
+
|
|
469
|
+
```
|
|
470
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
471
|
+
│ OPTION 1: CREDENTIALS STOCKÉS (comptes sans 2FA) │
|
|
472
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
473
|
+
│ │
|
|
474
|
+
│ Setup: │
|
|
475
|
+
│ 1. Créer 3-5 comptes Gmail DÉDIÉS (pas comptes personnels) │
|
|
476
|
+
│ 2. Désactiver 2FA sur ces comptes │
|
|
477
|
+
│ 3. Stocker email/password chiffrés (AES-256) │
|
|
478
|
+
│ 4. Auto-login automatique quand session expire │
|
|
479
|
+
│ │
|
|
480
|
+
│ Flow: │
|
|
481
|
+
│ ┌─────────┐ ┌──────────────┐ ┌─────────────────┐ │
|
|
482
|
+
│ │ Request │────▶│ Check Session│────▶│ Session Valid? │ │
|
|
483
|
+
│ └─────────┘ └──────────────┘ └────────┬────────┘ │
|
|
484
|
+
│ │ │
|
|
485
|
+
│ ┌──────────────────────┴──────────────────┐ │
|
|
486
|
+
│ ▼ ▼ │
|
|
487
|
+
│ ┌──────────────┐ ┌───────────┐ │
|
|
488
|
+
│ │ YES: Use it │ │ NO: Login │ │
|
|
489
|
+
│ └──────────────┘ └─────┬─────┘ │
|
|
490
|
+
│ │ │
|
|
491
|
+
│ ▼ │
|
|
492
|
+
│ ┌──────────────────────────┐│
|
|
493
|
+
│ │ 1. Decrypt credentials ││
|
|
494
|
+
│ │ 2. Navigate to login ││
|
|
495
|
+
│ │ 3. Fill email, Next ││
|
|
496
|
+
│ │ 4. Fill password, Next ││
|
|
497
|
+
│ │ 5. Save session cookies ││
|
|
498
|
+
│ └──────────────────────────┘│
|
|
499
|
+
│ │
|
|
500
|
+
│ Avantages: Limites: │
|
|
501
|
+
│ ✅ Zero intervention humaine ⚠️ Comptes moins sécurisés (no 2FA)│
|
|
502
|
+
│ ✅ Simple à implémenter ⚠️ Google peut bloquer si suspect │
|
|
503
|
+
│ ✅ Fonctionne 24/7 ⚠️ Credentials stockés = risque │
|
|
504
|
+
│ │
|
|
505
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
#### Option 2: Comptes avec TOTP + Auto-2FA
|
|
509
|
+
|
|
510
|
+
````
|
|
511
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
512
|
+
│ OPTION 2: CREDENTIALS + TOTP SECRET (comptes avec 2FA) │
|
|
513
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
514
|
+
│ │
|
|
515
|
+
│ Setup: │
|
|
516
|
+
│ 1. Créer comptes Gmail avec 2FA TOTP (PAS SMS) │
|
|
517
|
+
│ 2. Lors du setup 2FA, sauvegarder le SECRET (code QR) │
|
|
518
|
+
│ 3. Stocker email + password + TOTP secret (chiffrés) │
|
|
519
|
+
│ 4. Générer les codes 2FA programmatiquement │
|
|
520
|
+
│ │
|
|
521
|
+
│ Génération TOTP: │
|
|
522
|
+
│ ```typescript │
|
|
523
|
+
│ import { authenticator } from 'otplib'; │
|
|
524
|
+
│ │
|
|
525
|
+
│ const secret = decrypt(account.totpSecretEncrypted); │
|
|
526
|
+
│ const code = authenticator.generate(secret); │
|
|
527
|
+
│ // → "123456" (code 2FA valide 30 secondes) │
|
|
528
|
+
│ ``` │
|
|
529
|
+
│ │
|
|
530
|
+
│ Flow 2FA: │
|
|
531
|
+
│ ┌─────────────────┐ │
|
|
532
|
+
│ │ After password │ │
|
|
533
|
+
│ └────────┬────────┘ │
|
|
534
|
+
│ ▼ │
|
|
535
|
+
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
|
|
536
|
+
│ │ Detect 2FA page │────▶│ Generate TOTP │────▶│ Fill & Submit │ │
|
|
537
|
+
│ └─────────────────┘ │ from secret │ └─────────────────┘ │
|
|
538
|
+
│ └─────────────────┘ │
|
|
539
|
+
│ │
|
|
540
|
+
│ Avantages: Limites: │
|
|
541
|
+
│ ✅ 2FA activé (plus sécurisé) ⚠️ TOTP secret à stocker │
|
|
542
|
+
│ ✅ Zero intervention humaine ⚠️ Plus complexe à setup │
|
|
543
|
+
│ ✅ Meilleure protection compte ⚠️ Google peut quand même bloquer │
|
|
544
|
+
│ │
|
|
545
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
546
|
+
````
|
|
547
|
+
|
|
548
|
+
#### Option 3: Session Keep-Alive Proactif
|
|
549
|
+
|
|
550
|
+
````
|
|
551
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
552
|
+
│ OPTION 3: SESSION KEEP-ALIVE (prévention vs guérison) │
|
|
553
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
554
|
+
│ │
|
|
555
|
+
│ Principe: Utiliser la session AVANT qu'elle expire │
|
|
556
|
+
│ Les cookies Google durent ~2 semaines mais se "refresh" à l'usage │
|
|
557
|
+
│ │
|
|
558
|
+
│ Implementation: │
|
|
559
|
+
│ ├── Cron job toutes les 12h │
|
|
560
|
+
│ ├── Pour chaque compte: charger NotebookLM (pas besoin de query) │
|
|
561
|
+
│ └── Ça "refresh" implicitement les cookies de session │
|
|
562
|
+
│ │
|
|
563
|
+
│ ```typescript │
|
|
564
|
+
│ // Cron: 0 */12 * * * (toutes les 12 heures) │
|
|
565
|
+
│ async function keepSessionsAlive() { │
|
|
566
|
+
│ for (const account of accounts) { │
|
|
567
|
+
│ const context = await loadBrowserProfile(account); │
|
|
568
|
+
│ const page = await context.newPage(); │
|
|
569
|
+
│ await page.goto('https://notebooklm.google.com'); │
|
|
570
|
+
│ await page.waitForLoadState('networkidle'); │
|
|
571
|
+
│ // Session cookies auto-refreshed! │
|
|
572
|
+
│ await page.close(); │
|
|
573
|
+
│ } │
|
|
574
|
+
│ } │
|
|
575
|
+
│ ``` │
|
|
576
|
+
│ │
|
|
577
|
+
│ Avantages: Limites: │
|
|
578
|
+
│ ✅ Pas de login = moins de risque ⚠️ Retarde le problème seulement │
|
|
579
|
+
│ ✅ Très simple ⚠️ Si rate un refresh = problème │
|
|
580
|
+
│ ✅ Pas de credentials stockés ⚠️ Nécessite login initial manuel │
|
|
581
|
+
│ │
|
|
582
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
583
|
+
````
|
|
584
|
+
|
|
585
|
+
### 9.3 Architecture Multi-Comptes Recommandée
|
|
586
|
+
|
|
587
|
+
```
|
|
588
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
589
|
+
│ ARCHITECTURE PRODUCTION RECOMMANDÉE │
|
|
590
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
591
|
+
│ │
|
|
592
|
+
│ ~/.notebooklm-mcp/ │
|
|
593
|
+
│ ├── accounts.json ← Configuration des comptes │
|
|
594
|
+
│ ├── accounts/ │
|
|
595
|
+
│ │ ├── account-1/ │
|
|
596
|
+
│ │ │ ├── profile/ ← Chrome profile complet persistant │
|
|
597
|
+
│ │ │ ├── auth-state.json ← Cookies/session exportés │
|
|
598
|
+
│ │ │ ├── quota.json ← { used: 45, limit: 50, resetAt: "." } │
|
|
599
|
+
│ │ │ └── credentials.enc ← Email/password/TOTP chiffré (opt.) │
|
|
600
|
+
│ │ ├── account-2/ │
|
|
601
|
+
│ │ │ └── ... │
|
|
602
|
+
│ │ └── account-3/ │
|
|
603
|
+
│ │ └── ... │
|
|
604
|
+
│ └── active-account.json ← Compte actuellement sélectionné │
|
|
605
|
+
│ │
|
|
606
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
607
|
+
│ │
|
|
608
|
+
│ ┌─────────────────────────────────────────────────────────────────┐ │
|
|
609
|
+
│ │ Account Pool Manager │ │
|
|
610
|
+
│ └─────────────────────────────────────────────────────────────────┘ │
|
|
611
|
+
│ │ │
|
|
612
|
+
│ ┌────────────────────┼────────────────────┐ │
|
|
613
|
+
│ ▼ ▼ ▼ │
|
|
614
|
+
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
|
|
615
|
+
│ │ Account 1 │ │ Account 2 │ │ Account 3 │ │
|
|
616
|
+
│ │ (primary) │ │ (backup) │ │ (backup) │ │
|
|
617
|
+
│ ├───────────────┤ ├───────────────┤ ├───────────────┤ │
|
|
618
|
+
│ │ Email: bot1@ │ │ Email: bot2@ │ │ Email: bot3@ │ │
|
|
619
|
+
│ │ TOTP: ✓ │ │ TOTP: ✓ │ │ TOTP: ✓ │ │
|
|
620
|
+
│ │ Profile: ✓ │ │ Profile: ✓ │ │ Profile: ✓ │ │
|
|
621
|
+
│ │ Quota: 45/50 │ │ Quota: 50/50 │ │ Quota: 23/50 │ │
|
|
622
|
+
│ │ Session: OK │ │ Session: OK │ │ Session: EXP │◄─┐ │
|
|
623
|
+
│ └───────────────┘ └───────────────┘ └───────────────┘ │ │
|
|
624
|
+
│ │ │
|
|
625
|
+
│ Auto-Login ────────┘ │
|
|
626
|
+
│ │
|
|
627
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
628
|
+
│ STRATÉGIES DE SÉLECTION │
|
|
629
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
630
|
+
│ │
|
|
631
|
+
│ LEAST_USED: Utiliser le compte avec le plus de quota restant │
|
|
632
|
+
│ ROUND_ROBIN: Alterner entre les comptes à chaque requête │
|
|
633
|
+
│ FAILOVER: Compte principal, switch si problème │
|
|
634
|
+
│ │
|
|
635
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
636
|
+
│ COMPOSANTS │
|
|
637
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
638
|
+
│ │
|
|
639
|
+
│ SessionKeepAlive → Cron 12h, maintient sessions actives │
|
|
640
|
+
│ HealthMonitor → Vérifie état sessions, détecte expirations │
|
|
641
|
+
│ AutoLoginModule → Re-login automatique si credentials stockés │
|
|
642
|
+
│ QuotaTracker → Compte requêtes, évite rate limits │
|
|
643
|
+
│ AlertingService → Notifie si tous comptes KO │
|
|
644
|
+
│ │
|
|
645
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
### 9.4 Implémentation Technique
|
|
649
|
+
|
|
650
|
+
#### Configuration accounts.json
|
|
651
|
+
|
|
652
|
+
```json
|
|
653
|
+
{
|
|
654
|
+
"accounts": [
|
|
655
|
+
{
|
|
656
|
+
"id": "account-1",
|
|
657
|
+
"email": "notebooklm.bot1@gmail.com",
|
|
658
|
+
"enabled": true,
|
|
659
|
+
"priority": 1,
|
|
660
|
+
"has_credentials": true,
|
|
661
|
+
"has_totp": true
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
"id": "account-2",
|
|
665
|
+
"email": "notebooklm.bot2@gmail.com",
|
|
666
|
+
"enabled": true,
|
|
667
|
+
"priority": 2,
|
|
668
|
+
"has_credentials": true,
|
|
669
|
+
"has_totp": true
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
"id": "account-3",
|
|
673
|
+
"email": "notebooklm.bot3@gmail.com",
|
|
674
|
+
"enabled": true,
|
|
675
|
+
"priority": 3,
|
|
676
|
+
"has_credentials": false,
|
|
677
|
+
"has_totp": false
|
|
678
|
+
}
|
|
679
|
+
],
|
|
680
|
+
"rotation_strategy": "least_used",
|
|
681
|
+
"keep_alive_interval_hours": 12,
|
|
682
|
+
"auto_login_enabled": true,
|
|
683
|
+
"alert_webhook": "https://hooks.slack.com/..."
|
|
684
|
+
}
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
#### Interface AccountManager
|
|
688
|
+
|
|
689
|
+
```typescript
|
|
690
|
+
interface Account {
|
|
691
|
+
id: string;
|
|
692
|
+
email: string;
|
|
693
|
+
profileDir: string;
|
|
694
|
+
quota: { used: number; limit: number; resetAt: Date };
|
|
695
|
+
sessionStatus: 'valid' | 'expiring' | 'expired';
|
|
696
|
+
lastActivity: Date;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
interface AccountManager {
|
|
700
|
+
// Sélectionner le meilleur compte disponible
|
|
701
|
+
getBestAccount(): Promise<Account>;
|
|
702
|
+
|
|
703
|
+
// Incrémenter le quota après une requête
|
|
704
|
+
recordUsage(accountId: string): Promise<void>;
|
|
705
|
+
|
|
706
|
+
// Vérifier la santé de tous les comptes
|
|
707
|
+
healthCheck(): Promise<AccountHealth[]>;
|
|
708
|
+
|
|
709
|
+
// Auto-refresh si credentials stockés
|
|
710
|
+
refreshAccount(accountId: string): Promise<boolean>;
|
|
711
|
+
|
|
712
|
+
// Keep-alive pour maintenir les sessions
|
|
713
|
+
keepAlive(): Promise<void>;
|
|
714
|
+
}
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
#### Auto-Login avec TOTP
|
|
718
|
+
|
|
719
|
+
```typescript
|
|
720
|
+
import { authenticator } from 'otplib';
|
|
721
|
+
import { decrypt } from './crypto';
|
|
722
|
+
|
|
723
|
+
class AutoLoginManager {
|
|
724
|
+
async performAutoLogin(account: AccountConfig): Promise<boolean> {
|
|
725
|
+
const page = await this.browser.newPage();
|
|
726
|
+
|
|
727
|
+
try {
|
|
728
|
+
// 1. Navigate to Google login
|
|
729
|
+
await page.goto('https://accounts.google.com/signin');
|
|
730
|
+
await page.waitForLoadState('networkidle');
|
|
731
|
+
|
|
732
|
+
// 2. Enter email
|
|
733
|
+
const email = decrypt(account.emailEncrypted);
|
|
734
|
+
await page.fill('input[type="email"]', email);
|
|
735
|
+
await page.click('#identifierNext');
|
|
736
|
+
await page.waitForNavigation();
|
|
737
|
+
|
|
738
|
+
// 3. Enter password
|
|
739
|
+
const password = decrypt(account.passwordEncrypted);
|
|
740
|
+
await page.fill('input[type="password"]', password);
|
|
741
|
+
await page.click('#passwordNext');
|
|
742
|
+
await page.waitForNavigation();
|
|
743
|
+
|
|
744
|
+
// 4. Handle 2FA if configured
|
|
745
|
+
if (account.totpSecretEncrypted) {
|
|
746
|
+
await this.handle2FA(page, account.totpSecretEncrypted);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// 5. Wait for successful login
|
|
750
|
+
await page.waitForURL('**/myaccount.google.com/**', { timeout: 30000 });
|
|
751
|
+
|
|
752
|
+
// 6. Navigate to NotebookLM to establish session
|
|
753
|
+
await page.goto('https://notebooklm.google.com');
|
|
754
|
+
await page.waitForLoadState('networkidle');
|
|
755
|
+
|
|
756
|
+
// 7. Save session state
|
|
757
|
+
const state = await page.context().storageState();
|
|
758
|
+
await this.saveSessionState(account.id, state);
|
|
759
|
+
|
|
760
|
+
log.success(`✅ Auto-login successful for ${account.email}`);
|
|
761
|
+
return true;
|
|
762
|
+
} catch (error) {
|
|
763
|
+
log.error(`❌ Auto-login failed for ${account.email}: ${error}`);
|
|
764
|
+
return false;
|
|
765
|
+
} finally {
|
|
766
|
+
await page.close();
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
private async handle2FA(page: Page, totpSecretEncrypted: string): Promise<void> {
|
|
771
|
+
// Wait for 2FA page
|
|
772
|
+
await page.waitForSelector('input[name="totpPin"]', { timeout: 10000 });
|
|
773
|
+
|
|
774
|
+
// Generate TOTP code
|
|
775
|
+
const secret = decrypt(totpSecretEncrypted);
|
|
776
|
+
const code = authenticator.generate(secret);
|
|
777
|
+
|
|
778
|
+
log.info(` 🔐 Entering 2FA code...`);
|
|
779
|
+
await page.fill('input[name="totpPin"]', code);
|
|
780
|
+
await page.click('#totpNext');
|
|
781
|
+
await page.waitForNavigation();
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
### 9.5 Setup des Comptes Dédiés
|
|
787
|
+
|
|
788
|
+
| Étape | Action | Notes |
|
|
789
|
+
| ----- | ---------------------------------- | ------------------------------------------ |
|
|
790
|
+
| 1 | Créer 3-5 comptes Gmail dédiés | Noms: `nblm.bot1@gmail.com`, etc. |
|
|
791
|
+
| 2 | Activer 2FA TOTP (recommandé) | Utiliser Google Authenticator ou similaire |
|
|
792
|
+
| 3 | Sauvegarder le secret TOTP | Code affiché lors du setup (ou QR décodé) |
|
|
793
|
+
| 4 | Créer le fichier `credentials.enc` | Chiffrer avec clé AES-256 |
|
|
794
|
+
| 5 | Login initial manuel (1 fois) | Pour établir le profil browser |
|
|
795
|
+
| 6 | Vérifier quota disponible | 50 queries/jour par compte gratuit |
|
|
796
|
+
|
|
797
|
+
### 9.6 Risques et Mitigations
|
|
798
|
+
|
|
799
|
+
| Risque | Probabilité | Impact | Mitigation |
|
|
800
|
+
| --------------------------------- | ----------- | -------- | --------------------------------------------------- |
|
|
801
|
+
| Google bloque "activité suspecte" | Moyenne | Haut | Profils persistants, comportement humain, IP stable |
|
|
802
|
+
| CAPTCHA au login | Faible | Moyen | Retry avec délai, fallback autre compte |
|
|
803
|
+
| Credentials compromis | Faible | Critique | Chiffrement AES-256, comptes dédiés isolés |
|
|
804
|
+
| Tous comptes bloqués | Très faible | Critique | Alerting immédiat, intervention manuelle |
|
|
805
|
+
| Changement UI Google login | Faible | Moyen | Monitoring, mise à jour sélecteurs |
|
|
806
|
+
|
|
807
|
+
### 9.7 Comparatif des Options
|
|
808
|
+
|
|
809
|
+
| Critère | Option 1 (No 2FA) | Option 2 (TOTP) | Option 3 (Keep-Alive) |
|
|
810
|
+
| -------------------- | ----------------- | --------------- | --------------------- |
|
|
811
|
+
| **Sécurité** | ⚠️ Faible | ✅ Bonne | ✅ Bonne |
|
|
812
|
+
| **Complexité setup** | ✅ Simple | ⚠️ Moyenne | ✅ Simple |
|
|
813
|
+
| **Maintenance** | ✅ Faible | ✅ Faible | ⚠️ Moyenne |
|
|
814
|
+
| **Fiabilité** | ⚠️ Moyenne | ✅ Bonne | ⚠️ Moyenne |
|
|
815
|
+
| **Zero-touch** | ✅ Oui | ✅ Oui | ⚠️ Partiel |
|
|
816
|
+
| **Recommandé** | Dev/test | **Production** | Complément |
|
|
817
|
+
|
|
818
|
+
### 9.8 Recommandation Finale
|
|
819
|
+
|
|
820
|
+
```
|
|
821
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
822
|
+
│ RECOMMANDATION POUR PRODUCTION │
|
|
823
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
824
|
+
│ │
|
|
825
|
+
│ Combiner Option 2 (TOTP) + Option 3 (Keep-Alive): │
|
|
826
|
+
│ │
|
|
827
|
+
│ 1. Pool de 3-5 comptes dédiés avec 2FA TOTP │
|
|
828
|
+
│ 2. Credentials + TOTP secrets chiffrés (AES-256) │
|
|
829
|
+
│ 3. Keep-alive cron toutes les 12h (prévention) │
|
|
830
|
+
│ 4. Auto-login avec TOTP si session expire (guérison) │
|
|
831
|
+
│ 5. Rotation LEAST_USED pour répartir la charge │
|
|
832
|
+
│ 6. Alerting si >50% des comptes en erreur │
|
|
833
|
+
│ │
|
|
834
|
+
│ Effort estimé: 3-5 jours de développement │
|
|
835
|
+
│ Résultat: Système autonome 24/7 sans intervention humaine │
|
|
836
|
+
│ │
|
|
837
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
838
|
+
```
|
|
839
|
+
|
|
840
|
+
---
|
|
841
|
+
|
|
842
|
+
## Annexes
|
|
843
|
+
|
|
844
|
+
### D. Dépendances pour Auto-Login TOTP
|
|
845
|
+
|
|
846
|
+
```json
|
|
847
|
+
{
|
|
848
|
+
"dependencies": {
|
|
849
|
+
"otplib": "^12.0.1"
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
### E. Exemple de Chiffrement Credentials
|
|
855
|
+
|
|
856
|
+
```typescript
|
|
857
|
+
import crypto from 'crypto';
|
|
858
|
+
|
|
859
|
+
const ALGORITHM = 'aes-256-gcm';
|
|
860
|
+
const KEY = process.env.CREDENTIALS_ENCRYPTION_KEY; // 32 bytes
|
|
861
|
+
|
|
862
|
+
export function encrypt(text: string): string {
|
|
863
|
+
const iv = crypto.randomBytes(16);
|
|
864
|
+
const cipher = crypto.createCipheriv(ALGORITHM, Buffer.from(KEY, 'hex'), iv);
|
|
865
|
+
let encrypted = cipher.update(text, 'utf8', 'hex');
|
|
866
|
+
encrypted += cipher.final('hex');
|
|
867
|
+
const authTag = cipher.getAuthTag();
|
|
868
|
+
return `${iv.toString('hex')}:${authTag.toString('hex')}:${encrypted}`;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
export function decrypt(encryptedData: string): string {
|
|
872
|
+
const [ivHex, authTagHex, encrypted] = encryptedData.split(':');
|
|
873
|
+
const iv = Buffer.from(ivHex, 'hex');
|
|
874
|
+
const authTag = Buffer.from(authTagHex, 'hex');
|
|
875
|
+
const decipher = crypto.createDecipheriv(ALGORITHM, Buffer.from(KEY, 'hex'), iv);
|
|
876
|
+
decipher.setAuthTag(authTag);
|
|
877
|
+
let decrypted = decipher.update(encrypted, 'hex', 'utf8');
|
|
878
|
+
decrypted += decipher.final('utf8');
|
|
879
|
+
return decrypted;
|
|
880
|
+
}
|
|
881
|
+
```
|
|
882
|
+
|
|
883
|
+
### F. Références Authentification
|
|
884
|
+
|
|
885
|
+
- [Playwright Authentication](https://playwright.dev/docs/auth)
|
|
886
|
+
- [Google OAuth Refresh Tokens](https://developers.google.com/identity/protocols/oauth2)
|
|
887
|
+
- [Puppeteer Session Cookie Management](https://www.webshare.io/academy-article/puppeteer-login)
|
|
888
|
+
- [OAuth Tokens vs Cookies Discussion](https://github.com/puppeteer/puppeteer/issues/6615)
|
|
889
|
+
- [otplib - TOTP Library](https://www.npmjs.com/package/otplib)
|
|
890
|
+
|
|
891
|
+
---
|
|
892
|
+
|
|
893
|
+
_Document généré le 23 décembre 2024_
|
|
894
|
+
_Prochaine réévaluation recommandée: Mars 2025_
|