Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

1.1 KB
Raw Blame
import { cli, Strategy } from '@jackwener/opencli/registry';
import { EmptyResultError } from '@jackwener/opencli/errors';
import { CLAUDE_DOMAIN, ensureOnClaude, getVisibleMessages, ensureClaudeLogin } from './utils.js';

export const readCommand = cli({
    site: 'claude',
    name: 'read',
    access: 'read',
    description: 'Read the current Claude conversation',
    domain: CLAUDE_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    args: [],
    columns: ['Index', 'Role', 'Text'],

    func: async (page) => {
        // ensureOnClaude now waits for the composer selector; the previous post-nav
        // 3 s settle is covered by that event-based wait.
        await ensureOnClaude(page);
        await ensureClaudeLogin(page, 'Claude read requires a logged-in Claude session.');
        const messages = await getVisibleMessages(page);
        if (messages.length > 0) return messages;
        throw new EmptyResultError('claude read', 'No visible Claude messages were found in the current conversation.');
    },
});