9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
48 lines
2.2 KiB
JavaScript
48 lines
2.2 KiB
JavaScript
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
import { EmptyResultError } from '@jackwener/opencli/errors';
|
|
import { NOTEBOOKLM_DOMAIN, NOTEBOOKLM_SITE } from './shared.js';
|
|
import { findNotebooklmNoteRow, getNotebooklmPageState, listNotebooklmNotesFromPage, readNotebooklmVisibleNoteFromPage, requireNotebooklmSession, } from './utils.js';
|
|
function matchesNoteTitle(title, query) {
|
|
const needle = query.trim().toLowerCase();
|
|
if (!needle)
|
|
return false;
|
|
const normalized = title.trim().toLowerCase();
|
|
return normalized === needle || normalized.includes(needle);
|
|
}
|
|
cli({
|
|
site: NOTEBOOKLM_SITE,
|
|
name: 'notes-get',
|
|
access: 'read',
|
|
description: 'Get one note from the current NotebookLM notebook by title from the visible note editor',
|
|
domain: NOTEBOOKLM_DOMAIN,
|
|
strategy: Strategy.COOKIE,
|
|
browser: true,
|
|
navigateBefore: false,
|
|
args: [
|
|
{
|
|
name: 'note',
|
|
positional: true,
|
|
required: true,
|
|
help: 'Note title or id from the current notebook',
|
|
},
|
|
],
|
|
columns: ['title', 'content', 'source', 'url'],
|
|
func: async (page, kwargs) => {
|
|
await requireNotebooklmSession(page);
|
|
const state = await getNotebooklmPageState(page);
|
|
if (state.kind !== 'notebook') {
|
|
throw new EmptyResultError('opencli notebooklm notes-get', 'No NotebookLM notebook is open in the adapter session. Run `opencli notebooklm open <notebook>` first.');
|
|
}
|
|
const query = typeof kwargs.note === 'string' ? kwargs.note : String(kwargs.note ?? '');
|
|
const visible = await readNotebooklmVisibleNoteFromPage(page);
|
|
if (visible && matchesNoteTitle(visible.title, query))
|
|
return [visible];
|
|
const rows = await listNotebooklmNotesFromPage(page);
|
|
const listed = findNotebooklmNoteRow(rows, query);
|
|
if (listed) {
|
|
throw new EmptyResultError('opencli notebooklm notes-get', `Note "${query}" is listed in Studio, but opencli currently reads note content only from the visible note editor. Open that note in NotebookLM, then retry.`);
|
|
}
|
|
throw new EmptyResultError('opencli notebooklm notes-get', `Note "${query}" was not found in the current notebook.`);
|
|
},
|
|
});
|