File tree Expand file tree Collapse file tree 5 files changed +40
-60
lines changed
Expand file tree Collapse file tree 5 files changed +40
-60
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ function buildPrompt(trends: TrendResult[], research?: ResearchPayload): string
152152 }
153153 }
154154
155- if ( research . infographicPath ) {
155+ if ( research . infographicUrl ) {
156156 researchContext += `\n### Infographic Available\nAn infographic has been generated for this topic. Use sceneType "narration" with bRollUrl pointing to the infographic for at least one scene.\n` ;
157157 }
158158 }
Original file line number Diff line number Diff line change 99 */
1010
1111import type { AuthTokens , NotebookLMCookie } from './types' ;
12+ import { fetchWithTimeout } from './rpc' ;
1213
1314// ---------------------------------------------------------------------------
1415// Constants
@@ -107,28 +108,6 @@ function buildCookieHeader(cookies: Record<string, string>): string {
107108 . join ( '; ' ) ;
108109}
109110
110- /**
111- * Fetch with an AbortController timeout.
112- */
113- async function fetchWithTimeout (
114- url : string ,
115- init : RequestInit ,
116- timeoutMs : number
117- ) : Promise < Response > {
118- const controller = new AbortController ( ) ;
119- const timer = setTimeout ( ( ) => controller . abort ( ) , timeoutMs ) ;
120-
121- try {
122- const response = await fetch ( url , {
123- ...init ,
124- signal : controller . signal ,
125- } ) ;
126- return response ;
127- } finally {
128- clearTimeout ( timer ) ;
129- }
130- }
131-
132111// ---------------------------------------------------------------------------
133112// Main auth function
134113// ---------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ import {
2626 buildRpcUrl ,
2727 decodeResponse ,
2828 NotebookLMRPCError ,
29+ fetchWithTimeout ,
30+ sleep ,
2931} from './rpc' ;
3032import { initAuth } from './auth' ;
3133
@@ -46,28 +48,6 @@ const DEFAULT_SOURCE_PATH = '/';
4648// Helpers
4749// ---------------------------------------------------------------------------
4850
49- /**
50- * Fetch with AbortController timeout.
51- */
52- async function fetchWithTimeout (
53- url : string ,
54- init : RequestInit ,
55- timeoutMs : number
56- ) : Promise < Response > {
57- const controller = new AbortController ( ) ;
58- const timer = setTimeout ( ( ) => controller . abort ( ) , timeoutMs ) ;
59-
60- try {
61- const response = await fetch ( url , {
62- ...init ,
63- signal : controller . signal ,
64- } ) ;
65- return response ;
66- } finally {
67- clearTimeout ( timer ) ;
68- }
69- }
70-
7151/**
7252 * Check if a URL is a YouTube URL.
7353 */
@@ -76,13 +56,6 @@ function isYouTubeUrl(url: string): boolean {
7656 return lower . includes ( 'youtube.com' ) || lower . includes ( 'youtu.be' ) ;
7757}
7858
79- /**
80- * Sleep for a given number of milliseconds.
81- */
82- function sleep ( ms : number ) : Promise < void > {
83- return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
84- }
85-
8659/**
8760 * Safely access a deeply nested array value.
8861 * Returns undefined if any intermediate access fails.
Original file line number Diff line number Diff line change @@ -228,3 +228,36 @@ export function decodeResponse(
228228
229229 return extractRpcResult ( chunks , rpcId ) ;
230230}
231+
232+ // ---------------------------------------------------------------------------
233+ // Shared utilities (used by auth.ts, client.ts, research.ts)
234+ // ---------------------------------------------------------------------------
235+
236+ /**
237+ * Fetch with an AbortController timeout.
238+ */
239+ export async function fetchWithTimeout (
240+ url : string ,
241+ init : RequestInit ,
242+ timeoutMs : number
243+ ) : Promise < Response > {
244+ const controller = new AbortController ( ) ;
245+ const timer = setTimeout ( ( ) => controller . abort ( ) , timeoutMs ) ;
246+
247+ try {
248+ const response = await fetch ( url , {
249+ ...init ,
250+ signal : controller . signal ,
251+ } ) ;
252+ return response ;
253+ } finally {
254+ clearTimeout ( timer ) ;
255+ }
256+ }
257+
258+ /**
259+ * Sleep for a given number of milliseconds.
260+ */
261+ export function sleep ( ms : number ) : Promise < void > {
262+ return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
263+ }
Original file line number Diff line number Diff line change 1111 */
1212
1313import { NotebookLMClient } from './notebooklm/client' ;
14+ import { sleep } from './notebooklm/rpc' ;
1415
1516// ---------------------------------------------------------------------------
1617// Types (kept identical for backward compatibility with ingest route)
@@ -32,7 +33,7 @@ export interface ResearchPayload {
3233 prosCons ?: Record < string , string [ ] > ;
3334 commonMistakes ?: string [ ] ;
3435 sceneHints : SceneHint [ ] ;
35- infographicPath ?: string ; // URL to infographic (renamed semantically but kept for compat)
36+ infographicUrl ?: string ;
3637}
3738
3839export interface ResearchSource {
@@ -233,12 +234,6 @@ async function safeStep<T>(
233234
234235// ---------------------------------------------------------------------------
235236// Sleep helper
236- // ---------------------------------------------------------------------------
237-
238- function sleep ( ms : number ) : Promise < void > {
239- return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
240- }
241-
242237// ---------------------------------------------------------------------------
243238// Main pipeline
244239// ---------------------------------------------------------------------------
@@ -465,7 +460,7 @@ export async function conductResearch(
465460 talkingPoints,
466461 codeExamples,
467462 sceneHints,
468- infographicPath : infographicUrl ?? undefined ,
463+ infographicUrl : infographicUrl ?? undefined ,
469464 } ;
470465
471466 console . log (
You can’t perform that action at this time.
0 commit comments