Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 12:39:48 +08:00

47 lines
1.6 KiB
JavaScript

import { cli, Strategy } from '@jackwener/opencli/registry';
import { EmptyResultError } from '@jackwener/opencli/errors';
import {
DEEPSEEK_DOMAIN,
MESSAGE_SELECTOR,
ensureOnDeepSeek,
getVisibleMessages,
parseDeepSeekConversationId,
} from './utils.js';
export const detailCommand = cli({
site: 'deepseek',
name: 'detail',
access: 'read',
description: 'Read a specific DeepSeek conversation by ID',
domain: DEEPSEEK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
navigateBefore: false,
args: [
{ name: 'id', required: true, positional: true, help: 'Conversation ID (UUID) or full /a/chat/s/<id> URL' },
],
columns: ['Role', 'Text'],
func: async (page, kwargs) => {
const id = parseDeepSeekConversationId(kwargs.id);
await ensureOnDeepSeek(page);
await page.goto(`https://chat.deepseek.com/a/chat/s/${id}`);
// Wait for at least one rendered bubble instead of a fixed 5 s sleep.
// Empty / invalid conversations fall through to the EmptyResultError
// below.
try {
await page.wait({ selector: MESSAGE_SELECTOR, timeout: 10 });
} catch {
// No bubble mounted within 10 s; treated as empty by the check below.
}
const messages = await getVisibleMessages(page);
if (messages.length === 0) {
throw new EmptyResultError(
'deepseek detail',
`No visible messages found for conversation ${id}. Verify the ID is correct and that you are logged in.`,
);
}
return messages;
},
});