Skip to content

Commit 4c555e5

Browse files
committed
feat: add source URLs to notebook + increase research timeout to 10min
Before starting deep research, now adds up to 10 source URLs from trend discovery to the notebook. This gives NotebookLM real context (blog posts, HN links, etc.) to research from, matching the workflow shown in the video. Also increased research timeout from 5min to 10min since deep research can take 5-10 minutes to complete.
1 parent dea459a commit 4c555e5

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

lib/services/research.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ export interface SceneHint {
6161
}
6262

6363
export interface ResearchConfig {
64-
/** Timeout for research polling in ms (default: 300000 = 5 min) */
64+
/** Timeout for research polling in ms (default: 600000 = 10 min) */
6565
researchTimeout?: number;
6666
/** Timeout for artifact generation in ms (default: 300000 = 5 min) */
6767
artifactTimeout?: number;
68+
/** Source URLs to add to the notebook before research (from trend discovery) */
69+
sourceUrls?: string[];
6870
/** Polling interval for research status in ms (default: 15000 = 15s) */
6971
pollInterval?: number;
7072
}
@@ -263,7 +265,7 @@ export async function conductResearch(
263265
topic: string,
264266
configOverrides?: ResearchConfig
265267
): Promise<ResearchPayload> {
266-
const researchTimeout = configOverrides?.researchTimeout ?? 300_000;
268+
const researchTimeout = configOverrides?.researchTimeout ?? 600_000;
267269
const artifactTimeout = configOverrides?.artifactTimeout ?? 300_000;
268270
const pollInterval = configOverrides?.pollInterval ?? 15_000;
269271
const createdAt = new Date().toISOString();
@@ -291,6 +293,27 @@ export async function conductResearch(
291293

292294
console.log(`[research] Notebook created: ${notebookId}`);
293295

296+
// -----------------------------------------------------------------------
297+
// Step 2b: Add source URLs from trend discovery (if provided)
298+
// -----------------------------------------------------------------------
299+
const sourceUrls = configOverrides?.sourceUrls ?? [];
300+
if (sourceUrls.length > 0) {
301+
console.log(`[research] Adding ${sourceUrls.length} source URLs to notebook...`);
302+
const addResults = await Promise.allSettled(
303+
sourceUrls.slice(0, 10).map((url) =>
304+
safeStep(`add-source-${url.substring(0, 40)}`, () =>
305+
client.addSource(notebookId, url)
306+
)
307+
)
308+
);
309+
const added = addResults.filter((r) => r.status === 'fulfilled' && r.value).length;
310+
console.log(`[research] Added ${added}/${sourceUrls.length} sources to notebook`);
311+
// Give NotebookLM a moment to process the sources
312+
if (added > 0) {
313+
await sleep(5000);
314+
}
315+
}
316+
294317
// -----------------------------------------------------------------------
295318
// Step 3: Start deep web research
296319
// -----------------------------------------------------------------------

0 commit comments

Comments
 (0)