current.js
1 import { cli, Strategy } from '@jackwener/opencli/registry'; 2 import { EmptyResultError } from '@jackwener/opencli/errors'; 3 import { NOTEBOOKLM_DOMAIN, NOTEBOOKLM_SITE } from './shared.js'; 4 import { getNotebooklmPageState, readCurrentNotebooklm, requireNotebooklmSession } from './utils.js'; 5 cli({ 6 site: NOTEBOOKLM_SITE, 7 name: 'current', 8 description: 'Show metadata for the currently opened NotebookLM notebook tab', 9 domain: NOTEBOOKLM_DOMAIN, 10 strategy: Strategy.COOKIE, 11 browser: true, 12 navigateBefore: false, 13 args: [], 14 columns: ['id', 'title', 'url', 'source'], 15 func: async (page) => { 16 await requireNotebooklmSession(page); 17 const state = await getNotebooklmPageState(page); 18 if (state.kind !== 'notebook') { 19 throw new EmptyResultError('opencli notebooklm current', 'No NotebookLM notebook is open in the automation workspace. Run `opencli notebooklm open <notebook>` first.'); 20 } 21 const current = await readCurrentNotebooklm(page); 22 if (!current) { 23 throw new EmptyResultError('opencli notebooklm current', 'NotebookLM notebook metadata was not found on the current page.'); 24 } 25 return [current]; 26 }, 27 });