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
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
import { EmptyResultError } from '@jackwener/opencli/errors';
|
|
import {
|
|
CHATGPT_DOMAIN,
|
|
ensureChatGPTLogin,
|
|
ensureOnChatGPT,
|
|
getConversationList,
|
|
requirePositiveInt,
|
|
} from './utils.js';
|
|
|
|
export const historyCommand = cli({
|
|
site: 'chatgpt',
|
|
name: 'history',
|
|
access: 'read',
|
|
description: 'List visible ChatGPT web conversation history from the sidebar',
|
|
domain: CHATGPT_DOMAIN,
|
|
strategy: Strategy.COOKIE,
|
|
browser: true,
|
|
siteSession: 'persistent',
|
|
navigateBefore: false,
|
|
args: [
|
|
{ name: 'limit', type: 'int', default: 20, help: 'Max conversations to show' },
|
|
],
|
|
columns: ['Index', 'Id', 'Title', 'Url'],
|
|
func: async (page, kwargs) => {
|
|
const limit = requirePositiveInt(
|
|
Number(kwargs.limit ?? 20),
|
|
'chatgpt history --limit',
|
|
'Example: opencli chatgpt history --limit 20',
|
|
);
|
|
await ensureOnChatGPT(page);
|
|
await ensureChatGPTLogin(page, 'ChatGPT history requires a logged-in ChatGPT session.');
|
|
const conversations = await getConversationList(page);
|
|
if (!conversations.length) {
|
|
throw new EmptyResultError('chatgpt history', 'No ChatGPT conversation links were visible in the sidebar.');
|
|
}
|
|
return conversations.slice(0, limit);
|
|
},
|
|
});
|