Skip to content

feat: rewrite check-research for Gemini Deep Research (Task 5)#628

Merged
codercatdev merged 1 commit intodevfrom
feat/check-research-gemini
Mar 5, 2026
Merged

feat: rewrite check-research for Gemini Deep Research (Task 5)#628
codercatdev merged 1 commit intodevfrom
feat/check-research-gemini

Conversation

@codercatdev
Copy link
Contributor

Summary

Rewrites app/api/cron/check-research/route.ts to replace all NotebookLM calls with Gemini Deep Research API + Gemini Infographics (Imagen 4 Fast).

What Changed

Removed

  • All NotebookLM imports (NotebookLMClient, initAuth, ArtifactTypeCode, ArtifactStatus)
  • initAuth() call and NotebookLMClient instantiation
  • nbClient parameter from all step functions
  • DEFAULT_INFOGRAPHIC_INSTRUCTIONS constant (now lives in gemini-infographics.ts)
  • Auth-gated infographic download logic (Imagen returns base64 directly)
  • All nbClient.* method calls (pollResearch, importResearchSources, getSummary, getSourceIds, generateInfographic, listArtifacts, getInfographicUrl, getCookieHeader)

Added

  • pollResearch(interactionId) from @/lib/services/gemini-research — replaces NotebookLM polling
  • parseResearchReport(topic, report) from @/lib/services/gemini-research — replaces manual briefing/summary extraction
  • generateInfographicsForTopic(topic, briefing) from @/lib/services/gemini-infographics — replaces NotebookLM infographic generation + download
  • researchInteractionId field in PipelineDoc (new Gemini field, with researchNotebookId kept for backward compat)
  • enableDeepResearch toggle — when disabled, researching docs skip directly to enriching

Step Changes

Step Before After
stepResearching Polls NotebookLM, imports sources, gets summary Polls Gemini interaction, parses report with parseResearchReport
stepResearchComplete Starts async NotebookLM infographic generation → infographics_generating Generates infographics synchronously via Imagen, uploads to Sanity → enriching
stepInfographicsGenerating Polls NotebookLM artifacts, downloads auth-gated PNGs Legacy migration handler only — advances stuck docs to enriching
stepEnriching Unchanged Updated buildResearchPayload to handle both new (full ResearchPayload) and legacy (briefing + sources) formats

Kept Unchanged

  • fetchCache = 'force-no-store' and maxDuration = 60
  • Fail-closed CRON_SECRET auth
  • flagStuckDocs() and buildStuckThresholds()
  • MAX_DOCS_PER_STATUS = 2
  • All helper functions: extractTalkingPoints, extractCodeExamples, classifyScene, classifySourceType
  • buildEnrichmentPrompt, claudeCritic, SYSTEM_INSTRUCTION_FALLBACK
  • Error handling pattern (try/catch per doc, collect results)

Verification

  • npx tsc --noEmit — zero errors
  • ✅ No NotebookLM imports remain (only a comment in legacy migration handler)
  • ✅ New Gemini imports present
  • ✅ Fail-closed auth verified
  • ✅ File reduced from 1006 → 881 lines

Dependencies

  • @/lib/services/gemini-research (Task 3 — merged)
  • @/lib/services/gemini-infographics (Task 4 — merged)

Replace all NotebookLM calls with Gemini Deep Research API
(pollResearch, parseResearchReport) and Gemini Infographics
(generateInfographicsForTopic with Imagen 4 Fast).

Changes:
- stepResearching: polls Gemini interaction instead of NotebookLM
- stepResearchComplete: generates infographics via Imagen (sync, no polling)
- stepInfographicsGenerating: legacy migration handler only
- Remove all NotebookLM imports and client initialization
- Add enableDeepResearch toggle (skip when disabled)
- Keep: fail-closed auth, stuck detection, enrichment, Claude critic

Co-authored-by: research <research@miriad.systems>
@vercel
Copy link

vercel bot commented Mar 5, 2026

Deployment failed with the following error:

Resource is limited - try again in 8 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/alex-pattersons-projects?upgradeToPro=build-rate-limit

@codercatdev codercatdev merged commit 5cb64b6 into dev Mar 5, 2026
0 of 2 checks passed
@codercatdev codercatdev deleted the feat/check-research-gemini branch March 5, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant