name: notebooklm-research
version: 2.0.0
description: >
Use NotebookLM CLI (nlm) as the primary tool for academic/policy research.
Summarise sources, query with RAG, cross-query notebooks, and generate
reports using Google's NotebookLM AI — no external LLM tokens wasted.
Replaces the deprecated notebook-master-sync (absorbed).
trigger:
- "User says 'sync notebook' / 'notebooklm sync' / 'đồng bộ notebook'"
- "User asks to summarise / compare / research sources"
- "Need to extract structured info (chapter-by-chapter) from a document"
- "Pipeline task involving source ingestion, analysis, or reporting"
notebooklm sync — Chạy đồng bộ tự động giữa NotebookLM và master file researchpython3 scripts/notebooklm_sync.pyNotebookLM-First. Before calling any external LLM (9router, etc.) for summarisation or extraction, use NotebookLM CLI — it's free, RAG-native, and produces citations.
notebooklm sync)When triggered, the agent runs python3 scripts/notebooklm_sync.py which executes 4 steps:
nlm doctor; auto-refresh if expirednlm source list <notebook> --jsonSee references/sync-debug-notes.md for a real auth-refresh and ID-drift example.
See references/legal-doc-analysis-pattern.md for the correct sequence when analysing legal/regulatory documents (Luật, Thông tư) against an external framework (ILO, OECD, etc.).
See references/ilo-lmis-vietnam-domain.md for condensed ILO LMIS framework knowledge and Vietnam-specific labour market context (informal economy stats, ASEAN gap analysis, proxy indicators).
Tóm tắt (VN) or body < 1200 chars → flag for updateFor each flagged source:
1. nlm notebook query --source-ids "<id>" "<notebook>" "<prompt>" → 5,000+ char VN summary with citations
2. nlm source describe --json <id> → EN summary + keywords (0 token cost)
3. 3-second delay between calls to avoid rate limiting
- found in VN proseWhen building recurring deep-research loops (e.g. 7-pillar institutional benchmarking), construct multi-task pipelines programmatically:
- Task 1 (r-and-d): Scoping & Data Sync (Process batch of 10 sources, run up to 10 nested search/explorations using Vision/OCR if external files are found).
- Task 2 (r-and-d): RAG Analysis & Deep Finding (Extract details to policy documents).
- Task 3 (grill-qa): Critique (Review findings, check for dashes, enforce logic & 7 pillars).
- Task 4 (r-and-d): Synthesis & Reporting.
- Task 5 (grill-qa): Master Update & QA Gate.
Chain these tasks with --parent dependencies on creation so they execute sequentially. Each cron/orchestrator run must dispatch a dedicated chain per target.
• Phase 2 Policy Coherence Test: Bổ sung bước kiểm định định lượng và định tính về tính tương thích chính sách và agenda overload trong các văn bản chiến lược.
• Anti-Dash Enforcement: Trong mọi query prompt tiếng Việt, bắt buộc chèn đoạn: "Tuyệt đối không dùng dấu gạch nối trong văn xuôi tiếng Việt."
• Batching Strategy: Thực hiện batch 10 nguồn mỗi loop, lưu trạng thái processed_ids và last_batch vào processed_sources_vn.json.
• QA Integration: Tích hợp kiểm tra tính nhất quán dữ liệu (Glossary, citations, APA 7) vào Phase 5.
• Handoff Logic: Mỗi phase phải tự chủ động cập nhật trạng thái task và đẩy sang Phase kế tiếp trong Kanban.
done, and push Phase 4 to ready. The CEO reads comments and decides whether to revisit.done = signal for the next loop. When all 5 tasks are done (not just archived), the next cron run must detect this and initiate a new 5-task cycle (Loop N+1). Treat done as "pipeline complete" even if not archived.todo → ready and write a transfer comment with findings, file paths, and critique context.master_reports/ directory:
bash
cp {workspace_path}/{filename} {project_base}/master_reports/{filename}[SILENT] when a pipeline exists — each run must either create a pipeline or report current status.Quality Standard for Government/Policy Sources:
- Summaries must be highly detailed, structured chapter-by-chapter or section-by-section as the original document is organized.
- If the document explicitly identifies bottlenecks/challenges, faithfully report what it says. If it does NOT mention them, explicitly note their absence in the summary — never fabricate or invent.
- Automated background batching (multiple calls via LLM loop) of critical policy documents consistently produces generic, shallow summaries that violate quality standards. Foreground or batch-with-notify supervision is preferred for high-stakes deliverables.
- Zero-Token Summarization (NotebookLM-First): Instead of fetching raw content and summarising via external LLM (9router), use NotebookLM's own AI:
1. nlm source describe <source-id> --json for EN summary + keywords (free).
2. nlm notebook query --source-ids <id> <notebook> "VN prompt" for chapter-level VN summary.
- NEVER fabricate bottlenecks, targets, or recommendations. If absent from source, say so.
"model": "default"."stream": false in urllib payloads to avoid JSONDecodeError.nlm login # Browser-based login
nlm login --check # Check auth status
nlm login switch <profile> # Switch profile
nlm doctor # Run diagnostics
nlm source list <notebook> --json # List all sources with real UUIDs
nlm source describe <source-id> # AI summary + keywords (0 token cost)
nlm source describe <source-id> --json # JSON output
nlm source get <source-id> # Raw content
# Single source (targeted)
nlm notebook query --source-ids "<id>" "<notebook>" "Your question"
# Multi-source
nlm notebook query --source-ids "id1,id2" "<notebook>" "Compare..."
# Cross-notebook
nlm cross query "Question" --notebooks "id1,id2"
nlm cross query "Question" --all
nlm research start "query" --notebook-id <id> --mode deep --auto-import
nlm research status <notebook> --max-wait 300
nlm research import <notebook> <task-id> --cited-only
nlm report create <notebook> --format "Briefing Doc" --confirm
nlm audio create <notebook> --format deep_dive --confirm
nlm slides create <notebook> --confirm
nlm download report <notebook> <artifact> --output report.md
nlm batch query "Question" --notebooks "id1,id2"
nlm batch query "Question" --all
nlm pipeline run research-and-report --notebook <id>
nlm tag add <notebook> --tags "tag1,tag2"
nlm source describe for quick summaries firstnlm notebook query --source-ids for structured extractionnlm source list <notebook> --jsonTuyệt đối không dùng dấu gạch nối trong văn xuôi tiếng ViệtAuthentication expired or connection refused to Chrome debugger:pkill -f chrometerminal(background=true, notify_on_complete=false) — do NOT use shell & in a foreground call (that syntax is rejected):
google-chrome --headless=new --no-sandbox --disable-gpu --disable-dev-shm-usage --disable-extensions --no-first-run --no-default-browser-check --remote-debugging-port=9223 --remote-debugging-address=127.0.0.1 --remote-allow-origins=* --user-data-dir=/root/.notebooklm-mcp-cli/chrome-profiles/defaultpython3 /opt/ai-os/products/ceo/scripts/notebooklm_refresh.py✅ Auth tokens saved to profile 'default'!
The subsequent ⚠️ API test failed (may need CSRF refresh): list_notebooks()... from the same script is a FALSE POSITIVE — it does NOT block actual nlm commands.timeout 60 nlm source list <notebook-id> --json (if it returns JSON, you're good)./tmp/nlm_batch_*.log and set notify_on_complete=true1. INGEST → nlm source add <notebook> --url/file/youtube (--wait)
2. AUTH → nlm doctor (verify before batch)
3. FETCH UUIDs → nlm source list <notebook> --json
4. SURVEY → nlm source describe <id> --json (ALL sources, batches of 3)
5. TARGETED QUERY → nlm notebook query --source-ids <1-3 IDs> "VN question"
6. MERGE → write combined EN+VN summary to research file
7. VERIFY → scan for dashes in VN prose
8. REPORT → nlm report create <notebook> --format "Briefing Doc"
9. ARCHIVE → nlm download report <notebook> <artifact> --output report.md
When user shares a notebook for the first time and asks to "understand the sources" or build a knowledge base:
nlm source list <notebook-id> --json → inventory all sources with IDsnlm source describe <id> --json for EVERY source (3 per terminal call, sleep 3s between)context_map.md in the project folder: source inventory table, each source's role, key themesnotebook query per analytical cluster (≤3 IDs per call)kb_strategy.md: knowledge domain map, tiered source list to acquire, research argument, roadmapPitfall: Do NOT skip straight to multi-source cross-query after listing sources. source describe is free and gives enough signal to cluster sources intelligently before spending query budget.
An automated sync script is bundled at scripts/notebooklm_sync.py (resolves to ~/.hermes/skills/research/notebooklm-research/scripts/notebooklm_sync.py). It orchestrates a 4-phase sync:
Note: copy is also at /opt/ai-os/products/ceo/scripts/notebooklm_sync.py for direct invocations from the CEO project directory.
nlm doctor to verify auth; auto-refresh via notebooklm_refresh.py if expired.nlm source list <notebook> --json.master_tourism_vn.md to build a local index of (title, ID, body).src_norm in master_norm or master_norm in src_norm to handle minor name drift.Tóm tắt (VN) or with bodies under 1200 chars:nlm notebook query --source-ids <id> with the standard VN prompt (no dashes).nlm source describe <id> --json for EN summary + keywords.Caution: The script modifies the master file directly. Always run from a terminal background session with --notify-on-complete for batches over 10 sources, and review the diff before pushing to git.
nlm notebook query timeout: Terminal tool mặc định timeout 60s. NLM query có thể mất 120 đến 180s. Luôn truyền timeout=240 vào terminal tool (không phải timeout shell wrapper). Dùng > /tmp/nlm_out.json 2>&1 rồi đọc file sau — không pipe trực tiếp.--source-ids format: Nhận comma-separated, KHÔNG phải space-separated. Sai format → query trả về kết quả không lọc.nlm auth hết hạn sau vài giờ idle. Chạy python3 /opt/ai-os/products/ceo/scripts/notebooklm_refresh.py trước mỗi session mới. "API test failed" trong output là false positive — không phải lỗi thật.nlm: command not found due to missing binary or virtual environment activation): If the nlm tool is missing or fails to execute, do not guess or write off the tool as broken. Ensure you check for the correct python environment/venv or the path where nlm is installed (e.g., look for .venv/bin/nlm in the project integrations folder). If needed, symlink it to /usr/local/bin/nlm or append its directory to PATH.notebooklm_sync.py) updating the SQLite local Kanban database must import sqlite3 at the top of the file to avoid NameError failures.nlm doctor before batch work.nlm notebook query with no --source-ids mixes all sources — always scope to IDs.source describe returns ~500-1000 chars EN — use notebook query for VN deep summaries.| jq — Python json module is safer.a.txt, b.txt, c.txt), always perform an atomic write (e.g., using write_file) rather than sequential shell commands, and verify existence before proceeding.nlm source list "<name>" with the text title of a notebook will return a NOT_FOUND error. You must first fetch the notebook UUID using nlm notebook list and then use that exact UUID for source lists or target queries (e.g. nlm source list "c73f7763-e6a6-423f-bb64-f751968eab92").nlm source list <notebook> --json. If the master file has an ID that doesn't match NotebookLM's output, run notebooklm_sync.py to auto-repair via fuzzy matching.nlm notebook query with --source-ids supports --timeout 300: For multi-source RAG queries spanning 10+ IDs with deep prompt analysis, pass --timeout 600 to avoid premature timeouts.notebook query call. Use source describe (free, fast) first to survey all sources, then follow up with targeted notebook query --source-ids <1-3 IDs> for depth. Never attempt all 7–8 sources in one query call.nlm source list <notebook> --json to get all IDs and titles; (2) nlm source describe <id> --json for every source in parallel batches of 3; (3) only then run targeted notebook query per topic/cluster. This respects rate limits and avoids timeouts.timeout 90 wrapper on terminal commands is more reliable than --timeout flag for catching hung queries; pair with 2>&1 | head -200 to capture partial JSON output on timeout.nlm doctor "API test failed" is NOT blocking: After an auth refresh cycle, nlm doctor may report "API test failed (may need CSRF refresh): list_notebooks() missing 1 required positional argument: 'client'". This is a false positive in the diagnostic tool that does not affect actual operations. nlm notebook list, nlm source list, and nlm notebook query all still function correctly.pkill -f chrome if port 9223 is already bound (ss -tlnp | grep 9223), as killing Chrome mid-session terminates browser state for all active subagents. Only restart Chrome if auth fails and port 9223 is unresponsive.delegate_task has a strict concurrency limit (max_concurrent_children, default 3). Attempting to dispatch 4+ tasks in a single call fails immediately. Batch tasks into groups of ≤3 per delegate_task call and dispatch remaining tasks in subsequent calls or wait-for-completion cycles.nlm notebook query terminal calls IN PARALLEL — one per topic cluster, each scoped to ≤3 source IDs. This halves wall-clock time versus sequential querying without increasing timeout risk. Combine with parallel web_search calls for supplementary context to fill while NLM queries run.notebooklm_refresh.py absolute path: Always use /opt/ai-os/products/ceo/scripts/notebooklm_refresh.py. Do NOT use relative paths (scripts/notebooklm_refresh.py) as the script must be invoked from a shell whose cwd may vary.& backgrounding. Using command1 & sleep 5; command2 in a foreground terminal() call is rejected with an error. To start a long-lived process (like Chrome headless) before running a follow-up script, use two separate calls: terminal(background=true) for the server, then terminal() (foreground) for the script.