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
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
import {
|
|
YUANBAO_DOMAIN,
|
|
ensureYuanbaoPage,
|
|
getYuanbaoMessageBubbles,
|
|
} from './shared.js';
|
|
import { convertYuanbaoHtmlToMarkdown } from './ask.js';
|
|
|
|
cli({
|
|
site: 'yuanbao',
|
|
name: 'read',
|
|
access: 'read',
|
|
description: 'Read messages in the current Yuanbao conversation',
|
|
domain: YUANBAO_DOMAIN,
|
|
strategy: Strategy.COOKIE,
|
|
browser: true,
|
|
siteSession: 'persistent',
|
|
navigateBefore: false,
|
|
args: [],
|
|
columns: ['Role', 'Text'],
|
|
func: async (page) => {
|
|
await ensureYuanbaoPage(page);
|
|
await page.wait(1.5);
|
|
const bubbles = await getYuanbaoMessageBubbles(page);
|
|
if (!bubbles.length) {
|
|
return [{ Role: 'system', Text: 'No visible messages in the current Yuanbao conversation.' }];
|
|
}
|
|
return bubbles.map((b) => ({
|
|
Role: b.role,
|
|
// Assistant turns render markdown HTML; convert to markdown so the
|
|
// text column carries usable structure (lists, code, tables) rather
|
|
// than collapsed innerText.
|
|
Text: b.role === 'Assistant' && b.html
|
|
? (convertYuanbaoHtmlToMarkdown(b.html).trim() || b.text)
|
|
: b.text,
|
|
}));
|
|
},
|
|
});
|