notebooklm-kit 0.0.1 → 2.1.1

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 (100) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +4102 -0
  3. package/dist/src/auth/auth.d.ts +46 -0
  4. package/dist/src/auth/auth.d.ts.map +1 -0
  5. package/dist/src/auth/auth.js +323 -0
  6. package/dist/src/auth/auth.js.map +1 -0
  7. package/dist/src/auth/refresh.d.ts +150 -0
  8. package/dist/src/auth/refresh.d.ts.map +1 -0
  9. package/dist/src/auth/refresh.js +433 -0
  10. package/dist/src/auth/refresh.js.map +1 -0
  11. package/dist/src/client/notebooklm-client.d.ts +372 -0
  12. package/dist/src/client/notebooklm-client.d.ts.map +1 -0
  13. package/dist/src/client/notebooklm-client.js +550 -0
  14. package/dist/src/client/notebooklm-client.js.map +1 -0
  15. package/dist/src/index.d.ts +50 -0
  16. package/dist/src/index.d.ts.map +1 -0
  17. package/dist/src/index.js +45 -0
  18. package/dist/src/index.js.map +1 -0
  19. package/dist/src/rpc/rpc-client.d.ts +48 -0
  20. package/dist/src/rpc/rpc-client.d.ts.map +1 -0
  21. package/dist/src/rpc/rpc-client.js +94 -0
  22. package/dist/src/rpc/rpc-client.js.map +1 -0
  23. package/dist/src/rpc/rpc-methods.d.ts +127 -0
  24. package/dist/src/rpc/rpc-methods.d.ts.map +1 -0
  25. package/dist/src/rpc/rpc-methods.js +169 -0
  26. package/dist/src/rpc/rpc-methods.js.map +1 -0
  27. package/dist/src/services/artifacts.d.ts +1017 -0
  28. package/dist/src/services/artifacts.d.ts.map +1 -0
  29. package/dist/src/services/artifacts.js +5413 -0
  30. package/dist/src/services/artifacts.js.map +1 -0
  31. package/dist/src/services/generation.d.ts +147 -0
  32. package/dist/src/services/generation.d.ts.map +1 -0
  33. package/dist/src/services/generation.js +479 -0
  34. package/dist/src/services/generation.js.map +1 -0
  35. package/dist/src/services/notebook-language.d.ts +109 -0
  36. package/dist/src/services/notebook-language.d.ts.map +1 -0
  37. package/dist/src/services/notebook-language.js +204 -0
  38. package/dist/src/services/notebook-language.js.map +1 -0
  39. package/dist/src/services/notebooks.d.ts +26 -0
  40. package/dist/src/services/notebooks.d.ts.map +1 -0
  41. package/dist/src/services/notebooks.js +539 -0
  42. package/dist/src/services/notebooks.js.map +1 -0
  43. package/dist/src/services/notes.d.ts +72 -0
  44. package/dist/src/services/notes.d.ts.map +1 -0
  45. package/dist/src/services/notes.js +340 -0
  46. package/dist/src/services/notes.js.map +1 -0
  47. package/dist/src/services/sources.d.ts +1085 -0
  48. package/dist/src/services/sources.d.ts.map +1 -0
  49. package/dist/src/services/sources.js +2675 -0
  50. package/dist/src/services/sources.js.map +1 -0
  51. package/dist/src/types/artifact.d.ts +258 -0
  52. package/dist/src/types/artifact.d.ts.map +1 -0
  53. package/dist/src/types/artifact.js +42 -0
  54. package/dist/src/types/artifact.js.map +1 -0
  55. package/dist/src/types/common.d.ts +226 -0
  56. package/dist/src/types/common.d.ts.map +1 -0
  57. package/dist/src/types/common.js +80 -0
  58. package/dist/src/types/common.js.map +1 -0
  59. package/dist/src/types/languages.d.ts +179 -0
  60. package/dist/src/types/languages.d.ts.map +1 -0
  61. package/dist/src/types/languages.js +254 -0
  62. package/dist/src/types/languages.js.map +1 -0
  63. package/dist/src/types/note.d.ts +41 -0
  64. package/dist/src/types/note.d.ts.map +1 -0
  65. package/dist/src/types/note.js +12 -0
  66. package/dist/src/types/note.js.map +1 -0
  67. package/dist/src/types/notebook.d.ts +81 -0
  68. package/dist/src/types/notebook.d.ts.map +1 -0
  69. package/dist/src/types/notebook.js +5 -0
  70. package/dist/src/types/notebook.js.map +1 -0
  71. package/dist/src/types/source.d.ts +241 -0
  72. package/dist/src/types/source.d.ts.map +1 -0
  73. package/dist/src/types/source.js +60 -0
  74. package/dist/src/types/source.js.map +1 -0
  75. package/dist/src/utils/batch-execute.d.ts +58 -0
  76. package/dist/src/utils/batch-execute.d.ts.map +1 -0
  77. package/dist/src/utils/batch-execute.js +398 -0
  78. package/dist/src/utils/batch-execute.js.map +1 -0
  79. package/dist/src/utils/chunked-decoder.d.ts +11 -0
  80. package/dist/src/utils/chunked-decoder.d.ts.map +1 -0
  81. package/dist/src/utils/chunked-decoder.js +326 -0
  82. package/dist/src/utils/chunked-decoder.js.map +1 -0
  83. package/dist/src/utils/chunked-parser.d.ts +61 -0
  84. package/dist/src/utils/chunked-parser.d.ts.map +1 -0
  85. package/dist/src/utils/chunked-parser.js +609 -0
  86. package/dist/src/utils/chunked-parser.js.map +1 -0
  87. package/dist/src/utils/errors.d.ts +58 -0
  88. package/dist/src/utils/errors.d.ts.map +1 -0
  89. package/dist/src/utils/errors.js +357 -0
  90. package/dist/src/utils/errors.js.map +1 -0
  91. package/dist/src/utils/quota.d.ts +213 -0
  92. package/dist/src/utils/quota.d.ts.map +1 -0
  93. package/dist/src/utils/quota.js +518 -0
  94. package/dist/src/utils/quota.js.map +1 -0
  95. package/dist/src/utils/streaming-client.d.ts +129 -0
  96. package/dist/src/utils/streaming-client.d.ts.map +1 -0
  97. package/dist/src/utils/streaming-client.js +559 -0
  98. package/dist/src/utils/streaming-client.js.map +1 -0
  99. package/package.json +85 -7
  100. package/index.js +0 -2
@@ -0,0 +1,1085 @@
1
+ /**
2
+ * Sources service
3
+ * Handles source operations (add URLs, files, text, Google Drive, YouTube, etc.)
4
+ *
5
+ * WORKFLOW USAGE NOTES:
6
+ * - Individual add methods (addFromURL, addFromText, etc.) return immediately after source is queued
7
+ * - Use pollProcessing() to check if sources are ready, or use workflow functions that handle waiting
8
+ * - For web search: Use searchWebAndWait() to get results, then addDiscovered() to add them
9
+ * - For batch operations: Use addBatch() to add multiple sources efficiently
10
+ * - All add methods check quota before adding and record usage after success
11
+ */
12
+ import { RPCClient } from '../rpc/rpc-client.js';
13
+ import type { Source, AddSourceFromURLOptions, AddSourceFromTextOptions, AddSourceFromFileOptions, SourceProcessingStatus, SourceContent, SourceFreshness, DiscoveredWebSource, DiscoveredDriveSource, SearchWebSourcesOptions, AddDiscoveredSourcesOptions, AddGoogleDriveSourceOptions, AddYouTubeSourceOptions, BatchAddSourcesOptions, SearchWebAndWaitOptions, WebSearchResult } from '../types/source.js';
14
+ /**
15
+ * Web search sub-service for sources
16
+ * Handles web search operations (search, wait, get results, add discovered)
17
+ */
18
+ export declare class WebSearchService {
19
+ private rpc;
20
+ private quota?;
21
+ constructor(rpc: RPCClient, quota?: import("../utils/quota.js").QuotaManager | undefined);
22
+ /**
23
+ * Search web sources (STEP 1 of multi-step workflow)
24
+ *
25
+ * **Use this for multi-step workflows where you want to see results before deciding next steps.**
26
+ *
27
+ * **Multi-Step Workflow (for user decision-making):**
28
+ * 1. `search()` → Returns `sessionId` (start here - this method)
29
+ * - Shows you the search has started
30
+ * - Returns immediately with sessionId
31
+ * 2. `getResults(sessionId)` → Returns discovered sources (you can validate/filter)
32
+ * - Shows you what was found
33
+ * - You can inspect, filter, or select which sources to add
34
+ * 3. `addDiscovered(sessionId, selectedSources)` → Adds your selected sources
35
+ * - You decide which sources from step 2 to actually add
36
+ *
37
+ * **Simple Alternative (RECOMMENDED for automated workflows):**
38
+ * - Use `searchAndWait()` instead - one call, returns all results for validation
39
+ * - Then use `addDiscovered()` to add selected sources
40
+ *
41
+ * **Customization Options:**
42
+ * - `mode: ResearchMode.FAST` - Quick search (default)
43
+ * - `mode: ResearchMode.DEEP` - Comprehensive research (web only)
44
+ * - `sourceType: SearchSourceType.WEB` - Search web (default)
45
+ * - `sourceType: SearchSourceType.GOOGLE_DRIVE` - Search Google Drive (FAST mode only)
46
+ *
47
+ * @param notebookId - The notebook ID
48
+ * @param options - Search options (query, mode, sourceType)
49
+ * @returns sessionId - Required for steps 2 and 3
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Multi-step: Start search, then check results later
54
+ * const sessionId = await client.sources.add.web.search('notebook-id', {
55
+ * query: 'AI research',
56
+ * mode: ResearchMode.DEEP,
57
+ * });
58
+ *
59
+ * // Later... check what was found
60
+ * const results = await client.sources.add.web.getResults('notebook-id', sessionId);
61
+ * console.log(`Found ${results.web.length} sources`);
62
+ *
63
+ * // User decides which ones to add
64
+ * const selected = results.web.filter(s => s.url.includes('arxiv.org'));
65
+ * await client.sources.add.web.addDiscovered('notebook-id', {
66
+ * sessionId,
67
+ * webSources: selected,
68
+ * });
69
+ * ```
70
+ */
71
+ search(notebookId: string, options: SearchWebSourcesOptions): Promise<string>;
72
+ /**
73
+ * Search web sources and wait for results (SIMPLE - one call, returns results for validation)
74
+ *
75
+ * **RECOMMENDED FOR SIMPLE WORKFLOWS** - One call, returns all results you can validate.
76
+ *
77
+ * **What it does:**
78
+ * - Starts search, waits for results automatically
79
+ * - Returns all discovered sources once available (or timeout)
80
+ * - Returns results + sessionId for validation
81
+ * - No user decision needed during search - just wait and get results
82
+ *
83
+ * **Simple Workflow:**
84
+ * 1. `searchAndWait()` → Returns results + sessionId (this method - validates results)
85
+ * 2. `addDiscovered(sessionId, selectedSources)` → Add your selected sources
86
+ *
87
+ * **Customization Options:**
88
+ * - `mode: ResearchMode.FAST` - Quick search (default, ~10-30 seconds)
89
+ * - `mode: ResearchMode.DEEP` - Comprehensive research (web only, ~60-120 seconds)
90
+ * - `sourceType: SearchSourceType.WEB` - Search web (default)
91
+ * - `sourceType: SearchSourceType.GOOGLE_DRIVE` - Search Google Drive (FAST mode only)
92
+ * - `timeout` - Max wait time (default: 60000ms = 60 seconds)
93
+ * - `pollInterval` - How often to check for results (default: 2000ms = 2 seconds)
94
+ * - `onProgress` - Callback to track progress
95
+ *
96
+ * **When to use:**
97
+ * - Automated workflows where you don't need to see intermediate steps
98
+ * - Simple cases where you just want to search and get results
99
+ * - When you want to validate all results before deciding which to add
100
+ *
101
+ * **When NOT to use:**
102
+ * - If you need to see results as they come in (use `search()` + `getResults()` instead)
103
+ * - If you want to make decisions during the search process
104
+ *
105
+ * @param notebookId - The notebook ID
106
+ * @param options - Search options with waiting configuration
107
+ * @returns WebSearchResult with sessionId, web sources, and drive sources
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * // Simple: Search and get all results for validation
112
+ * const result = await client.sources.add.web.searchAndWait('notebook-id', {
113
+ * query: 'quantum computing research',
114
+ * mode: ResearchMode.DEEP, // Comprehensive search
115
+ * timeout: 120000, // Wait up to 2 minutes
116
+ * onProgress: (status) => {
117
+ * console.log(`Found ${status.resultCount} results so far...`);
118
+ * },
119
+ * });
120
+ *
121
+ * // Validate results
122
+ * console.log(`Found ${result.web.length} web sources`);
123
+ * console.log(`Found ${result.drive.length} drive sources`);
124
+ *
125
+ * // User decides which to add (or add all)
126
+ * const topSources = result.web.slice(0, 10); // Top 10
127
+ * await client.sources.add.web.addDiscovered('notebook-id', {
128
+ * sessionId: result.sessionId, // Required!
129
+ * webSources: topSources,
130
+ * });
131
+ * ```
132
+ */
133
+ searchAndWait(notebookId: string, options: SearchWebAndWaitOptions): Promise<WebSearchResult>;
134
+ /**
135
+ * Get search results (STEP 2 of multi-step workflow - returns results for validation)
136
+ *
137
+ * **REQUIRES:** You must have a `sessionId` from `search()` (step 1) to use this method.
138
+ *
139
+ * **What it does:**
140
+ * - Returns discovered sources from a search session
141
+ * - Shows you what was found so you can validate/filter/select
142
+ * - Returns results immediately (doesn't wait - call multiple times to poll)
143
+ *
144
+ * **Multi-Step Workflow:**
145
+ * 1. `search()` → Returns `sessionId` (step 1)
146
+ * 2. `getResults(sessionId)` → Returns discovered sources (this method - step 2)
147
+ * - **You can validate results here** - see what was found
148
+ * - **You can filter/select** - decide which sources to add
149
+ * - **You can call multiple times** - to poll for more results
150
+ * 3. `addDiscovered(sessionId, selectedSources)` → Add your selected sources (step 3)
151
+ *
152
+ * **Simple Alternative:**
153
+ * - Use `searchAndWait()` to combine steps 1-2 automatically
154
+ *
155
+ * **Usage Patterns:**
156
+ * - Call once after `search()` to get initial results
157
+ * - Call multiple times to poll for more results (results accumulate)
158
+ * - Filter results before passing to `addDiscovered()`
159
+ *
160
+ * @param notebookId - The notebook ID
161
+ * @param sessionId - Session ID from `search()` to filter results (optional - if omitted, returns all results)
162
+ * @returns Discovered sources (web and drive) for validation
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * // Step 1: Start search
167
+ * const sessionId = await client.sources.add.web.search('notebook-id', {
168
+ * query: 'AI research',
169
+ * });
170
+ *
171
+ * // Step 2: Get results (can call multiple times to poll)
172
+ * let results;
173
+ * do {
174
+ * await new Promise(r => setTimeout(r, 2000)); // Wait 2 seconds
175
+ * results = await client.sources.add.web.getResults('notebook-id', sessionId);
176
+ * console.log(`Found ${results.web.length} sources so far...`);
177
+ * } while (results.web.length === 0);
178
+ *
179
+ * // Validate and filter results
180
+ * const relevant = results.web.filter(s =>
181
+ * s.title.includes('machine learning') ||
182
+ * s.url.includes('arxiv.org')
183
+ * );
184
+ *
185
+ * // Step 3: Add selected sources
186
+ * await client.sources.add.web.addDiscovered('notebook-id', {
187
+ * sessionId,
188
+ * webSources: relevant,
189
+ * });
190
+ * ```
191
+ */
192
+ getResults(notebookId: string, sessionId?: string): Promise<{
193
+ web: DiscoveredWebSource[];
194
+ drive: DiscoveredDriveSource[];
195
+ }>;
196
+ /**
197
+ * Add discovered sources from search results (final step - adds your selected sources)
198
+ *
199
+ * **REQUIRES:** You must have a `sessionId` from `search()` or `searchAndWait()`.
200
+ *
201
+ * **What it does:**
202
+ * - Adds the sources you selected from search results
203
+ * - You decide which sources to add (from `getResults()` or `searchAndWait()`)
204
+ * - Returns array of added source IDs for validation
205
+ *
206
+ * **Workflow Patterns:**
207
+ *
208
+ * **Simple Pattern:**
209
+ * ```typescript
210
+ * const result = await client.sources.add.web.searchAndWait(...);
211
+ * const addedIds = await client.sources.add.web.addDiscovered('notebook-id', {
212
+ * sessionId: result.sessionId,
213
+ * webSources: result.web, // Add all, or filter first
214
+ * });
215
+ * ```
216
+ *
217
+ * **Multi-Step Pattern:**
218
+ * ```typescript
219
+ * const sessionId = await client.sources.add.web.search(...);
220
+ * const results = await client.sources.add.web.getResults(..., sessionId);
221
+ * const selected = results.web.filter(...); // Your selection logic
222
+ * const addedIds = await client.sources.add.web.addDiscovered('notebook-id', {
223
+ * sessionId,
224
+ * webSources: selected,
225
+ * });
226
+ * ```
227
+ *
228
+ * **Important:**
229
+ * - `sessionId` must match the one from your search (from `search()` or `searchAndWait()`)
230
+ * - You can add web sources, drive sources, or both
231
+ * - Returns source IDs so you can validate what was added
232
+ *
233
+ * @param notebookId - The notebook ID
234
+ * @param options - Session ID and sources to add (web and/or drive)
235
+ * @returns Array of added source IDs (for validation)
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * // After searchAndWait() - add selected sources
240
+ * const result = await client.sources.add.web.searchAndWait('notebook-id', {
241
+ * query: 'research papers',
242
+ * });
243
+ *
244
+ * // Validate results, then add top 5
245
+ * const top5 = result.web.slice(0, 5);
246
+ * const addedIds = await client.sources.add.web.addDiscovered('notebook-id', {
247
+ * sessionId: result.sessionId,
248
+ * webSources: top5,
249
+ * });
250
+ *
251
+ * console.log(`Added ${addedIds.length} sources:`, addedIds);
252
+ * ```
253
+ */
254
+ addDiscovered(notebookId: string, options: AddDiscoveredSourcesOptions): Promise<string[]>;
255
+ }
256
+ /**
257
+ * Add sources sub-service
258
+ * Handles adding sources of various types (URL, text, file, YouTube, Google Drive, batch)
259
+ */
260
+ export declare class AddSourcesService {
261
+ private rpc;
262
+ private quota?;
263
+ readonly web: WebSearchService;
264
+ constructor(rpc: RPCClient, quota?: import("../utils/quota.js").QuotaManager | undefined);
265
+ private extractSourceId;
266
+ /**
267
+ * Add a URL source
268
+ */
269
+ url(notebookId: string, options: AddSourceFromURLOptions): Promise<string>;
270
+ /**
271
+ * Add a text source
272
+ */
273
+ text(notebookId: string, options: AddSourceFromTextOptions): Promise<string>;
274
+ /**
275
+ * Add a file source
276
+ */
277
+ file(notebookId: string, options: AddSourceFromFileOptions): Promise<string>;
278
+ /**
279
+ * Add a YouTube video source
280
+ */
281
+ youtube(notebookId: string, options: AddYouTubeSourceOptions): Promise<string>;
282
+ /**
283
+ * Add a Google Drive source
284
+ *
285
+ * @deprecated This method is deprecated. Use `batch()` with `type: 'gdrive'` instead.
286
+ */
287
+ drive(notebookId: string, options: AddGoogleDriveSourceOptions): Promise<string>;
288
+ /**
289
+ * Add multiple sources in a batch
290
+ */
291
+ batch(notebookId: string, options: BatchAddSourcesOptions): Promise<string[]>;
292
+ private isYouTubeURL;
293
+ }
294
+ /**
295
+ * Service for source operations
296
+ */
297
+ export declare class SourcesService {
298
+ private rpc;
299
+ private quota?;
300
+ readonly add: AddSourcesService;
301
+ constructor(rpc: RPCClient, quota?: import("../utils/quota.js").QuotaManager | undefined);
302
+ /**
303
+ * List all sources in a notebook
304
+ *
305
+ * **What it does:** Retrieves a list of all sources (URLs, text, files, YouTube videos,
306
+ * Google Drive files, etc.) associated with a notebook.
307
+ *
308
+ * **Input:**
309
+ * - `notebookId` (string, required): The ID of the notebook to list sources from
310
+ *
311
+ * **Output:** Returns an array of `Source` objects, each containing:
312
+ * - `sourceId`: Unique identifier for the source
313
+ * - `title`: Source title/name
314
+ * - `type`: Source type (URL, TEXT, FILE, YOUTUBE_VIDEO, GOOGLE_DRIVE, etc.)
315
+ * - `url`: Source URL (for URL/YouTube sources)
316
+ * - `createdAt`: Creation timestamp
317
+ * - `updatedAt`: Last modified timestamp
318
+ * - `status`: Processing status (PROCESSING, READY, FAILED)
319
+ * - `metadata`: Additional metadata (file size, MIME type, etc.)
320
+ *
321
+ * **Note:**
322
+ * - Sources are extracted from the notebook response (same RPC as `notebooks.get()`)
323
+ * - This method efficiently reuses the notebook data without requiring a separate RPC call
324
+ * - Processing status is inferred from the source metadata
325
+ *
326
+ * @param notebookId - The notebook ID
327
+ *
328
+ * @example
329
+ * ```typescript
330
+ * // List all sources
331
+ * const sources = await client.sources.list('notebook-id');
332
+ * console.log(`Found ${sources.length} sources`);
333
+ *
334
+ * // Filter by type
335
+ * const pdfs = sources.filter(s => s.type === SourceType.FILE);
336
+ * const urls = sources.filter(s => s.type === SourceType.URL);
337
+ *
338
+ * // Check processing status
339
+ * const ready = sources.filter(s => s.status === SourceStatus.READY);
340
+ * const processing = sources.filter(s => s.status === SourceStatus.PROCESSING);
341
+ *
342
+ * // Get source details
343
+ * sources.forEach(source => {
344
+ * console.log(`${source.title} (${source.type}) - ${source.status}`);
345
+ * });
346
+ * ```
347
+ */
348
+ list(notebookId: string): Promise<Source[]>;
349
+ /**
350
+ * Parse sources from notebook response
351
+ *
352
+ * Source structure in response:
353
+ * [
354
+ * ["source-id"],
355
+ * "filename.pdf",
356
+ * [null, fileSize, [timestamp], ["processed-id", timestamp], type_code, null, 1],
357
+ * [null, 2]
358
+ * ]
359
+ *
360
+ * Type codes:
361
+ * - 1 = Google Drive
362
+ * - 2 = Text
363
+ * - 3 = File/PDF
364
+ * - 4 = Text note
365
+ * - 5 = URL
366
+ * - 8 = Mind map note
367
+ * - 9 = YouTube
368
+ * - 10 = Video file
369
+ * - 13 = Image
370
+ * - 14 = PDF from Drive
371
+ */
372
+ private parseSourcesFromResponse;
373
+ /**
374
+ * Map type code from API response to SourceType enum
375
+ *
376
+ * **What this does:**
377
+ * The NotebookLM API returns sources with numeric type codes in the metadata array.
378
+ * This function converts those internal API codes to our public SourceType enum.
379
+ *
380
+ * **Where the type code comes from:**
381
+ * In the API response, each source has this structure:
382
+ * ```
383
+ * [
384
+ * ["source-id"], // [0] = source ID
385
+ * "filename.pdf", // [1] = title
386
+ * [null, 602, [...], [...], 3, ...], // [2] = metadata array
387
+ * // [2][4] = type code (the number we map)
388
+ * ]
389
+ * ```
390
+ *
391
+ * **Type Code Examples from Real API Responses:**
392
+ * - `3` = PDF file: `["fnz offer.pdf", [null, 602, [...], [...], 3, ...]`
393
+ * - `5` = URL: `["AI SDK", [null, 571, [...], [...], 5, ..., ["https://ai-sdk.dev/"]]`
394
+ * - `9` = YouTube: `["Building an iMessage AI Chatbot", [null, 793, [...], [...], 9, [...]]`
395
+ * - `4` = Text note: `["A Pussycat's Discourse", [null, 1, [...], [...], 4, ...]`
396
+ * - `1` = Google Drive: `["offer_letter_photon", [[...], 492, [...], [...], 1, ...]`
397
+ * - `13` = Image: `["Screenshot 2025-12-28.png", [null, 0, [...], [...], 13, ...]`
398
+ *
399
+ * **Mapping:**
400
+ * Each API type code maps to a specific SourceType enum value to preserve the distinction
401
+ * between different file types (PDF, video, image, etc.).
402
+ *
403
+ * @param typeCode - The numeric type code from API response metadata[4]
404
+ * @returns The corresponding SourceType enum value
405
+ */
406
+ private mapTypeCodeToSourceType;
407
+ /**
408
+ * Get source(s) from a notebook
409
+ *
410
+ * **What it does:**
411
+ * - If `sourceId` is provided: Returns a single source by ID
412
+ * - If `sourceId` is not provided: Returns all sources (same as `list()`)
413
+ *
414
+ * **Input:**
415
+ * - `notebookId` (string, required): The notebook ID
416
+ * - `sourceId` (string, optional): The source ID to get. If omitted, returns all sources.
417
+ *
418
+ * **Output:**
419
+ * - If `sourceId` provided: Returns a single `Source` object
420
+ * - If `sourceId` omitted: Returns an array of `Source` objects
421
+ *
422
+ * @param notebookId - The notebook ID
423
+ * @param sourceId - Optional source ID to get a single source
424
+ *
425
+ * @example
426
+ * ```typescript
427
+ * // Get all sources
428
+ * const allSources = await client.sources.get('notebook-id');
429
+ *
430
+ * // Get a specific source
431
+ * const source = await client.sources.get('notebook-id', 'source-id');
432
+ * console.log(source.title);
433
+ * ```
434
+ */
435
+ get(notebookId: string, sourceId?: string): Promise<Source | Source[]>;
436
+ /**
437
+ * Add a source from URL
438
+ *
439
+ * WORKFLOW USAGE:
440
+ * - Returns immediately after source is queued (does not wait for processing)
441
+ * - Use pollProcessing() to check if source is ready
442
+ * - Or use workflow functions like addSourceAndWait() that handle waiting automatically
443
+ * - Automatically detects YouTube URLs and routes to addYouTube()
444
+ *
445
+ * @param notebookId - The notebook ID
446
+ * @param options - URL and optional title
447
+ *
448
+ * @example
449
+ * ```typescript
450
+ * // Add a regular URL
451
+ * const sourceId = await client.sources.addFromURL('notebook-id', {
452
+ * url: 'https://example.com/article',
453
+ * });
454
+ *
455
+ * // Check if ready (manual polling)
456
+ * let status;
457
+ * do {
458
+ * status = await client.sources.pollProcessing('notebook-id');
459
+ * await new Promise(r => setTimeout(r, 2000));
460
+ * } while (!status.allReady);
461
+ * ```
462
+ */
463
+ addFromURL(notebookId: string, options: AddSourceFromURLOptions): Promise<string>;
464
+ /**
465
+ * Add a source from text (copied text)
466
+ *
467
+ * WORKFLOW USAGE:
468
+ * - Returns immediately after source is queued
469
+ * - Use pollProcessing() to check if source is ready
470
+ * - Or use workflow functions that handle waiting automatically
471
+ *
472
+ * @param notebookId - The notebook ID
473
+ * @param options - Text content and title
474
+ *
475
+ * @example
476
+ * ```typescript
477
+ * const sourceId = await client.sources.addFromText('notebook-id', {
478
+ * title: 'My Notes',
479
+ * content: 'This is my research content...',
480
+ * });
481
+ * ```
482
+ */
483
+ addFromText(notebookId: string, options: AddSourceFromTextOptions): Promise<string>;
484
+ /**
485
+ * Add a source from uploaded file
486
+ *
487
+ * WORKFLOW USAGE:
488
+ * - Returns immediately after file is uploaded and queued
489
+ * - File processing may take longer than URLs/text
490
+ * - Use pollProcessing() to check if source is ready
491
+ * - Or use workflow functions that handle waiting automatically
492
+ *
493
+ * @param notebookId - The notebook ID
494
+ * @param options - File content, name, and MIME type
495
+ *
496
+ * @example
497
+ * ```typescript
498
+ * // From Buffer (Node.js)
499
+ * const fileBuffer = await fs.readFile('document.pdf');
500
+ * const sourceId = await client.sources.addFromFile('notebook-id', {
501
+ * content: fileBuffer,
502
+ * fileName: 'document.pdf',
503
+ * mimeType: 'application/pdf',
504
+ * });
505
+ *
506
+ * // From base64 string
507
+ * const sourceId = await client.sources.addFromFile('notebook-id', {
508
+ * content: base64String,
509
+ * fileName: 'document.pdf',
510
+ * });
511
+ * ```
512
+ */
513
+ addFromFile(notebookId: string, options: AddSourceFromFileOptions): Promise<string>;
514
+ /**
515
+ * Add a YouTube video source
516
+ *
517
+ * WORKFLOW USAGE:
518
+ * - Returns immediately after source is queued
519
+ * - YouTube videos may take longer to process than URLs/text
520
+ * - Use pollProcessing() to check if source is ready
521
+ * - Or use workflow functions that handle waiting automatically
522
+ *
523
+ * @param notebookId - The notebook ID
524
+ * @param options - YouTube URL or video ID
525
+ *
526
+ * @example
527
+ * ```typescript
528
+ * // From YouTube URL
529
+ * const sourceId = await client.sources.addYouTube('notebook-id', {
530
+ * urlOrId: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
531
+ * });
532
+ *
533
+ * // From video ID
534
+ * const sourceId = await client.sources.addYouTube('notebook-id', {
535
+ * urlOrId: 'dQw4w9WgXcQ',
536
+ * });
537
+ * ```
538
+ */
539
+ addYouTube(notebookId: string, options: AddYouTubeSourceOptions): Promise<string>;
540
+ /**
541
+ * Add a Google Drive source directly (by file ID)
542
+ *
543
+ * @deprecated This method is deprecated. Use `addBatch()` with `type: 'gdrive'` instead.
544
+ *
545
+ * WORKFLOW USAGE:
546
+ * - Returns immediately after source is queued
547
+ * - Use pollProcessing() to check if source is ready
548
+ * - Or use workflow functions that handle waiting automatically
549
+ * - For searching Drive files first, use searchWeb() with sourceType: GOOGLE_DRIVE
550
+ *
551
+ * **Note:** This method is deprecated. Use `addBatch()` with `type: 'gdrive'` instead.
552
+ *
553
+ * @param notebookId - The notebook ID
554
+ * @param options - Google Drive file ID and optional metadata
555
+ *
556
+ * @example
557
+ * ```typescript
558
+ * // DEPRECATED: Use addBatch() instead
559
+ * const sourceId = await client.sources.addGoogleDrive('notebook-id', {
560
+ * fileId: '1a2b3c4d5e6f7g8h9i0j',
561
+ * mimeType: 'application/vnd.google-apps.document',
562
+ * title: 'My Document',
563
+ * });
564
+ *
565
+ * // RECOMMENDED: Use addBatch() instead
566
+ * const sourceIds = await client.sources.addBatch('notebook-id', {
567
+ * sources: [{
568
+ * type: 'gdrive',
569
+ * fileId: '1a2b3c4d5e6f7g8h9i0j',
570
+ * mimeType: 'application/vnd.google-apps.document',
571
+ * title: 'My Document',
572
+ * }],
573
+ * });
574
+ * ```
575
+ *
576
+ * **Note:** For finding Drive files, use `searchWeb()` with `sourceType: SearchSourceType.GOOGLE_DRIVE`
577
+ * to search your Drive, then use `addDiscovered()` to add the found files.
578
+ */
579
+ addGoogleDrive(notebookId: string, options: AddGoogleDriveSourceOptions): Promise<string>;
580
+ /**
581
+ * Search web sources (initiate search, returns sessionId)
582
+ *
583
+ * **NOTE: For most use cases, use `searchWebAndWait()` instead, which handles the complete workflow automatically.**
584
+ *
585
+ * **IMPORTANT: This is STEP 1 of a 3-step sequential workflow.**
586
+ *
587
+ * You must complete the steps in order - you cannot skip to step 2 or 3 without completing step 1 first.
588
+ *
589
+ * **Complete Workflow (3 steps):**
590
+ * 1. `searchWeb()` → Returns `sessionId` (start here - this method)
591
+ * 2. `getSearchResults()` → Returns discovered sources (requires step 1)
592
+ * 3. `addDiscovered()` → Adds selected sources (requires sessionId from step 1)
593
+ *
594
+ * **Simplified Alternative (RECOMMENDED):**
595
+ * - Use `searchWebAndWait()` instead - it combines steps 1-2 with automatic polling
596
+ * - Then use `addDiscovered()` to add sources (step 3)
597
+ *
598
+ * @param notebookId - The notebook ID
599
+ * @param options - Search options
600
+ * @returns sessionId - Required for steps 2 and 3
601
+ *
602
+ * @example
603
+ * ```typescript
604
+ * // STEP 1: Initiate search (you must start here)
605
+ * const sessionId = await client.sources.searchWeb('notebook-id', {
606
+ * query: 'AI research',
607
+ * sourceType: SearchSourceType.WEB,
608
+ * mode: ResearchMode.FAST,
609
+ * });
610
+ *
611
+ * // STEP 2: Get results (requires sessionId from step 1)
612
+ * const results = await client.sources.getSearchResults('notebook-id');
613
+ *
614
+ * // STEP 3: Add selected sources (requires sessionId from step 1)
615
+ * const addedIds = await client.sources.addDiscovered('notebook-id', {
616
+ * sessionId: sessionId,
617
+ * webSources: results.web.slice(0, 5),
618
+ * });
619
+ * ```
620
+ *
621
+ * @example
622
+ * ```typescript
623
+ * // Deep research (web sources only - DEEP mode not available for Drive)
624
+ * const sessionId = await client.sources.searchWeb('notebook-id', {
625
+ * query: 'Machine learning',
626
+ * mode: ResearchMode.DEEP, // Only for WEB sources
627
+ * });
628
+ *
629
+ * // Google Drive search (FAST mode only)
630
+ * const sessionId = await client.sources.searchWeb('notebook-id', {
631
+ * query: 'presentation',
632
+ * sourceType: SearchSourceType.GOOGLE_DRIVE, // FAST mode only
633
+ * });
634
+ * ```
635
+ */
636
+ searchWeb(notebookId: string, options: SearchWebSourcesOptions): Promise<string>;
637
+ /**
638
+ * Search web sources and wait for results (complete workflow)
639
+ *
640
+ * **RECOMMENDED METHOD** - Use this instead of `searchWeb()` + `getSearchResults()` manually.
641
+ *
642
+ * WORKFLOW USAGE:
643
+ * - This is a complete workflow that combines searchWeb() + getSearchResults() with polling
644
+ * - Returns results once they're available (or timeout)
645
+ * - Use the returned sessionId with addDiscovered() to add sources
646
+ * - This is the recommended method for web search workflows
647
+ * - Automatically filters results by sessionId to avoid mixing with previous searches
648
+ *
649
+ * @param notebookId - The notebook ID
650
+ * @param options - Search options with waiting configuration
651
+ *
652
+ * @example
653
+ * ```typescript
654
+ * // Search and wait for results
655
+ * const result = await client.sources.searchWebAndWait('notebook-id', {
656
+ * query: 'AI research',
657
+ * mode: ResearchMode.DEEP,
658
+ * timeout: 60000, // Wait up to 60 seconds
659
+ * onProgress: (status) => {
660
+ * console.log(`Has results: ${status.hasResults}, Count: ${status.resultCount}`);
661
+ * },
662
+ * });
663
+ *
664
+ * // Then add selected sources
665
+ * const addedIds = await client.sources.addDiscovered('notebook-id', {
666
+ * sessionId: result.sessionId,
667
+ * webSources: result.web.slice(0, 5), // Add first 5
668
+ * });
669
+ * ```
670
+ */
671
+ searchWebAndWait(notebookId: string, options: SearchWebAndWaitOptions): Promise<WebSearchResult>;
672
+ /**
673
+ * Get search results (STEP 2 of 3-step workflow)
674
+ *
675
+ * **REQUIRES:** You must call `searchWeb()` first (step 1) before calling this method.
676
+ *
677
+ * This method retrieves the search results from a previously initiated search.
678
+ * The search was started by `searchWeb()` in step 1.
679
+ *
680
+ * **Complete Workflow (3 steps):**
681
+ * 1. `searchWeb()` → Returns `sessionId` (required first step)
682
+ * 2. `getSearchResults()` → Returns discovered sources (this method - step 2)
683
+ * 3. `addDiscovered()` → Adds selected sources (requires sessionId from step 1)
684
+ *
685
+ * **Note:** If you haven't called `searchWeb()` yet, you'll get empty results.
686
+ * Use `searchWebAndWait()` if you want to combine steps 1-2 automatically.
687
+ *
688
+ * **Filtering:** If `sessionId` is provided, only results from that session will be returned.
689
+ * Otherwise, results from all sessions will be returned (may include previous searches).
690
+ *
691
+ * @param notebookId - The notebook ID (must match the notebookId used in step 1)
692
+ * @param sessionId - Optional session ID to filter results to only this search session
693
+ * @returns Discovered sources (web and/or drive)
694
+ *
695
+ * @example
696
+ * ```typescript
697
+ * // STEP 1: Initiate search first
698
+ * const sessionId = await client.sources.searchWeb('notebook-id', { query: 'AI' });
699
+ *
700
+ * // STEP 2: Get results (only works after step 1)
701
+ * // Option 1: Get all results (may include previous searches)
702
+ * const results = await client.sources.getSearchResults('notebook-id');
703
+ *
704
+ * // Option 2: Get results only from current search (recommended)
705
+ * const results = await client.sources.getSearchResults('notebook-id', sessionId);
706
+ * console.log(`Found ${results.web.length} web sources and ${results.drive.length} drive sources`);
707
+ *
708
+ * // STEP 3: Add selected sources
709
+ * const addedIds = await client.sources.addDiscovered('notebook-id', {
710
+ * sessionId: sessionId,
711
+ * webSources: results.web,
712
+ * });
713
+ * ```
714
+ */
715
+ getSearchResults(notebookId: string, sessionId?: string): Promise<{
716
+ web: DiscoveredWebSource[];
717
+ drive: DiscoveredDriveSource[];
718
+ }>;
719
+ /**
720
+ * Add discovered sources from search results (STEP 3 of 3-step workflow)
721
+ *
722
+ * **REQUIRES:** You must have a `sessionId` from `searchWeb()` (step 1) to use this method.
723
+ *
724
+ * This is the final step - it adds the selected discovered sources to your notebook.
725
+ *
726
+ * **Complete Workflow (3 steps):**
727
+ * 1. `searchWeb()` → Returns `sessionId` (required first step)
728
+ * 2. `getSearchResults()` → Returns discovered sources (optional - if you need to filter/select)
729
+ * 3. `addDiscovered()` → Adds selected sources (this method - final step)
730
+ *
731
+ * **Simplified Alternative:**
732
+ * - Use `searchWebAndWait()` to combine steps 1-2, then use this method for step 3
733
+ *
734
+ * @param notebookId - The notebook ID
735
+ * @param options - Session ID (from step 1) and sources to add
736
+ * @returns Array of added source IDs
737
+ *
738
+ * @example
739
+ * ```typescript
740
+ * // Option 1: Complete 3-step workflow
741
+ * const sessionId = await client.sources.searchWeb('notebook-id', {
742
+ * query: 'AI research',
743
+ * mode: ResearchMode.DEEP,
744
+ * });
745
+ * const results = await client.sources.getSearchResults('notebook-id');
746
+ * const addedIds = await client.sources.addDiscovered('notebook-id', {
747
+ * sessionId: sessionId, // Required: from step 1
748
+ * webSources: results.web.slice(0, 5), // Add first 5 web sources
749
+ * });
750
+ *
751
+ * // Option 2: Simplified workflow (recommended)
752
+ * const result = await client.sources.searchWebAndWait('notebook-id', {
753
+ * query: 'AI research',
754
+ * mode: ResearchMode.DEEP,
755
+ * });
756
+ * const addedIds = await client.sources.addDiscovered('notebook-id', {
757
+ * sessionId: result.sessionId, // From searchWebAndWait
758
+ * webSources: result.web.slice(0, 5),
759
+ * driveSources: result.drive.slice(0, 2), // Can also add Drive sources
760
+ * });
761
+ * ```
762
+ */
763
+ addDiscovered(notebookId: string, options: AddDiscoveredSourcesOptions): Promise<string[]>;
764
+ /**
765
+ * Add multiple sources in batch
766
+ *
767
+ * WORKFLOW USAGE:
768
+ * - Efficiently adds multiple sources of different types in one call
769
+ * - All source types are supported EXCEPT web sources (which come from search)
770
+ * - Optionally waits for all sources to be processed
771
+ * - Use this for adding multiple sources at once instead of individual calls
772
+ * - All sources are added in parallel (server-side)
773
+ *
774
+ * **Supported Source Types:**
775
+ * - `url` - Regular URLs (via `addFromURL()`)
776
+ * - `text` - Text content (via `addFromText()`)
777
+ * - `file` - File uploads (via `addFromFile()`)
778
+ * - `youtube` - YouTube videos (via `addYouTube()`)
779
+ * - `gdrive` - Google Drive files (via `addGoogleDrive()`)
780
+ *
781
+ * **NOT Supported:**
782
+ * - Web sources from search - Use `searchWebAndWait()` + `addDiscovered()` instead
783
+ *
784
+ * @param notebookId - The notebook ID
785
+ * @param options - Batch addition options
786
+ * @returns Array of source IDs for all added sources
787
+ *
788
+ * @example
789
+ * ```typescript
790
+ * // Add multiple sources without waiting
791
+ * const sourceIds = await client.sources.addBatch('notebook-id', {
792
+ * sources: [
793
+ * { type: 'url', url: 'https://example.com/article1' },
794
+ * { type: 'url', url: 'https://example.com/article2' },
795
+ * { type: 'text', title: 'Notes', content: 'My research notes...' },
796
+ * { type: 'youtube', urlOrId: 'https://youtube.com/watch?v=...' },
797
+ * { type: 'gdrive', fileId: '1a2b3c4d5e6f7g8h9i0j', mimeType: 'application/pdf' },
798
+ * ],
799
+ * });
800
+ *
801
+ * // Add and wait for processing
802
+ * const sourceIds = await client.sources.addBatch('notebook-id', {
803
+ * sources: [
804
+ * { type: 'url', url: 'https://example.com/article' },
805
+ * { type: 'text', title: 'Notes', content: 'Content...' },
806
+ * ],
807
+ * waitForProcessing: true,
808
+ * timeout: 300000, // 5 minutes
809
+ * onProgress: (ready, total) => {
810
+ * console.log(`${ready}/${total} sources ready`);
811
+ * },
812
+ * });
813
+ * ```
814
+ */
815
+ addBatch(notebookId: string, options: BatchAddSourcesOptions): Promise<string[]>;
816
+ /**
817
+ * Delete a source from a notebook
818
+ *
819
+ * WORKFLOW USAGE:
820
+ * - Permanently removes a source from the notebook
821
+ * - This action cannot be undone
822
+ * - To delete multiple sources, call this method multiple times
823
+ *
824
+ * @param notebookId - The notebook ID
825
+ * @param sourceId - The source ID to delete
826
+ *
827
+ * @example
828
+ * ```typescript
829
+ * // Delete a single source
830
+ * await client.sources.delete('notebook-id', 'source-id-123');
831
+ *
832
+ * // Delete multiple sources (call multiple times)
833
+ * await client.sources.delete('notebook-id', 'source-id-1');
834
+ * await client.sources.delete('notebook-id', 'source-id-2');
835
+ * await client.sources.delete('notebook-id', 'source-id-3');
836
+ * ```
837
+ */
838
+ delete(notebookId: string, sourceId: string): Promise<void>;
839
+ /**
840
+ * Update source metadata
841
+ *
842
+ * WORKFLOW USAGE:
843
+ * - Updates source properties like title, metadata, etc.
844
+ * - This updates the source information, not the content itself
845
+ * - Returns immediately (no waiting required)
846
+ *
847
+ * **Common Updates:**
848
+ * - `title` - Change the source title/name
849
+ * - `metadata` - Update custom metadata
850
+ * - Other source properties as defined in the Source interface
851
+ *
852
+ * @param notebookId - The notebook ID
853
+ * @param sourceId - The source ID to update
854
+ * @param updates - Partial Source object with fields to update
855
+ *
856
+ * @example
857
+ * ```typescript
858
+ * // Update source title
859
+ * await client.sources.update('notebook-id', 'source-id', {
860
+ * title: 'Updated Source Title',
861
+ * });
862
+ *
863
+ * // Update metadata
864
+ * await client.sources.update('notebook-id', 'source-id', {
865
+ * metadata: {
866
+ * category: 'research',
867
+ * priority: 'high',
868
+ * },
869
+ * });
870
+ * ```
871
+ */
872
+ update(notebookId: string, sourceId: string, updates: Partial<Source>): Promise<void>;
873
+ /**
874
+ * Poll source processing status
875
+ *
876
+ * WORKFLOW USAGE:
877
+ * - Call this repeatedly to check if sources are ready
878
+ * - Use in loops with setTimeout for manual polling
879
+ * - Or use workflow functions that handle polling automatically
880
+ * - This is a single check - does not wait or retry
881
+ *
882
+ * @param notebookId - The notebook ID
883
+ *
884
+ * @example
885
+ * ```typescript
886
+ * // Manual polling
887
+ * let status;
888
+ * do {
889
+ * status = await client.sources.pollProcessing('notebook-id');
890
+ * if (!status.allReady) {
891
+ * await new Promise(r => setTimeout(r, 2000)); // Wait 2s
892
+ * }
893
+ * } while (!status.allReady);
894
+ * ```
895
+ */
896
+ /**
897
+ * Get source processing status
898
+ *
899
+ * **What it does:** Checks the processing status of all sources in a notebook.
900
+ * Returns information about which sources are still processing and whether all sources are ready.
901
+ *
902
+ * **Input:**
903
+ * - `notebookId` (string, required): The notebook ID
904
+ *
905
+ * **Output:** Returns a `SourceProcessingStatus` object containing:
906
+ * - `allReady` (boolean): Whether all sources are ready
907
+ * - `processing` (string[]): Array of source IDs that are still processing
908
+ *
909
+ * @param notebookId - The notebook ID
910
+ *
911
+ * @example
912
+ * ```typescript
913
+ * // Check processing status
914
+ * const status = await client.sources.status('notebook-id');
915
+ *
916
+ * if (status.allReady) {
917
+ * console.log('All sources are ready!');
918
+ * } else {
919
+ * console.log(`Still processing: ${status.processing.length} sources`);
920
+ * console.log('Processing IDs:', status.processing);
921
+ * }
922
+ * ```
923
+ */
924
+ status(notebookId: string): Promise<SourceProcessingStatus>;
925
+ /**
926
+ * Select/prepare source for viewing
927
+ *
928
+ * @deprecated This method is deprecated. It's only used with loadContent(),
929
+ * which is also deprecated due to "Service unavailable" errors.
930
+ *
931
+ * WORKFLOW USAGE:
932
+ * - REQUIRED: Must call this before loadContent() for reliable content loading
933
+ * - NotebookLM requires sources to be selected before they can be loaded
934
+ * - Use in sequence: selectSource() → loadContent()
935
+ *
936
+ * @param sourceId - The source ID
937
+ *
938
+ * @example
939
+ * ```typescript
940
+ * // REQUIRED: select first, then load
941
+ * await client.sources.selectSource('source-id');
942
+ * const content = await client.sources.loadContent('source-id');
943
+ * console.log(content.text);
944
+ * ```
945
+ */
946
+ selectSource(sourceId: string): Promise<void>;
947
+ /**
948
+ * Load source content
949
+ *
950
+ * @deprecated This method is deprecated and may not work reliably.
951
+ * The API endpoint returns "Service unavailable" errors.
952
+ *
953
+ * WORKFLOW USAGE:
954
+ * - REQUIRED: Must call selectSource() first before calling this method
955
+ * - Returns full text content of the source
956
+ * - Use this to read source content after it's ready
957
+ *
958
+ * @param sourceId - The source ID
959
+ *
960
+ * @example
961
+ * ```typescript
962
+ * // REQUIRED: select first, then load
963
+ * await client.sources.selectSource('source-id');
964
+ * const content = await client.sources.loadContent('source-id');
965
+ * console.log(content.text);
966
+ * ```
967
+ */
968
+ loadContent(sourceId: string): Promise<SourceContent>;
969
+ /**
970
+ * Check source freshness
971
+ *
972
+ * @deprecated This method is deprecated and may not work reliably.
973
+ * The API endpoint returns "Service unavailable" errors.
974
+ *
975
+ * WORKFLOW USAGE:
976
+ * - Use this to check if source content is up-to-date
977
+ * - Can be used before refresh() to determine if refresh is needed
978
+ *
979
+ * @param sourceId - The source ID
980
+ */
981
+ checkFreshness(sourceId: string): Promise<SourceFreshness>;
982
+ /**
983
+ * Add deep research report as a source
984
+ *
985
+ * @deprecated This method is deprecated and may not work reliably.
986
+ * The API endpoint may return "Service unavailable" errors.
987
+ *
988
+ * WORKFLOW USAGE:
989
+ * - Creates an AI-generated deep research report on a topic and adds it as a source
990
+ * - Monthly quota limit: 10 reports per month
991
+ * - Returns immediately after research is queued
992
+ * - Use `pollProcessing()` to check when the research report is ready
993
+ * - Once ready, the report appears as a source in your notebook
994
+ *
995
+ * **Important Notes:**
996
+ * - This is DIFFERENT from `searchWeb()` with `ResearchMode.DEEP`
997
+ * - `searchWeb(..., mode: ResearchMode.DEEP)` - Searches web and finds relevant sources
998
+ * - `addDeepResearch()` - Creates a complete research report as a source itself
999
+ * - Monthly limit: 10 reports per month (enforced by quota system)
1000
+ * - The generated report becomes a source that can be used for chat, artifacts, etc.
1001
+ * - Processing can take several minutes for comprehensive research
1002
+ *
1003
+ * **Use Cases:**
1004
+ * - Need a comprehensive research report on a complex topic
1005
+ * - Want AI-generated analysis compiled into a single source
1006
+ * - Starting research on a new domain and need foundational content
1007
+ *
1008
+ * @param notebookId - The notebook ID
1009
+ * @param query - Research query/question (what you want researched)
1010
+ * @returns Source ID of the generated research report
1011
+ *
1012
+ * @example
1013
+ * ```typescript
1014
+ * // Create a deep research report
1015
+ * const sourceId = await client.sources.addDeepResearch('notebook-id',
1016
+ * 'Latest developments in quantum computing and their applications'
1017
+ * );
1018
+ *
1019
+ * // Wait for research report to be ready
1020
+ * let status;
1021
+ * do {
1022
+ * status = await client.sources.pollProcessing('notebook-id');
1023
+ * if (!status.allReady) {
1024
+ * console.log('Research report still being generated...');
1025
+ * await new Promise(r => setTimeout(r, 5000)); // Wait 5s between checks
1026
+ * }
1027
+ * } while (!status.allReady);
1028
+ *
1029
+ * console.log(`Research report ready! Source ID: ${sourceId}`);
1030
+ * ```
1031
+ */
1032
+ addDeepResearch(notebookId: string, query: string): Promise<string>;
1033
+ /**
1034
+ * Act on multiple sources (bulk action)
1035
+ *
1036
+ * @deprecated This method is deprecated and may not work reliably.
1037
+ * The RPC endpoint returns "Service unavailable" errors.
1038
+ *
1039
+ * WORKFLOW USAGE:
1040
+ * - Use this for bulk operations on multiple sources
1041
+ * - Different from update() which works on a single source
1042
+ * - Supports various AI-powered content transformation actions
1043
+ *
1044
+ * **Note:** This method is deprecated due to API reliability issues.
1045
+ * Consider using artifact creation methods (e.g., `sdk.artifacts.create()`)
1046
+ * for similar functionality.
1047
+ *
1048
+ * @param notebookId - The notebook ID
1049
+ * @param action - Action to perform (see supported actions below)
1050
+ * @param sourceIds - Array of source IDs to act on
1051
+ *
1052
+ * @example
1053
+ * ```typescript
1054
+ * // Rephrase content from multiple sources
1055
+ * await client.sources.actOn('notebook-id', 'rephrase', ['source-1', 'source-2']);
1056
+ *
1057
+ * // Generate study guide from sources
1058
+ * await client.sources.actOn('notebook-id', 'study_guide', ['source-1']);
1059
+ *
1060
+ * // Create interactive mindmap
1061
+ * await client.sources.actOn('notebook-id', 'interactive_mindmap', ['source-1', 'source-2']);
1062
+ * ```
1063
+ *
1064
+ * **Supported Actions:**
1065
+ * - `rephrase` - Rephrase content from sources
1066
+ * - `expand` - Expand content from sources
1067
+ * - `summarize` - Summarize content from sources
1068
+ * - `critique` - Critique content from sources
1069
+ * - `brainstorm` - Brainstorm ideas from sources
1070
+ * - `verify` - Verify information from sources
1071
+ * - `explain` - Explain concepts from sources
1072
+ * - `outline` - Create outline from sources
1073
+ * - `study_guide` - Generate study guide from sources
1074
+ * - `faq` - Generate FAQ from sources
1075
+ * - `briefing_doc` - Create briefing document from sources
1076
+ * - `interactive_mindmap` - Generate interactive mindmap from sources
1077
+ * - `timeline` - Create timeline from sources
1078
+ * - `table_of_contents` - Generate table of contents from sources
1079
+ */
1080
+ actOn(notebookId: string, action: string, sourceIds: string[]): Promise<void>;
1081
+ private isYouTubeURL;
1082
+ private extractYouTubeVideoId;
1083
+ private extractSourceId;
1084
+ }
1085
+ //# sourceMappingURL=sources.d.ts.map