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.5 KB
Raw Blame
import { cli, Strategy } from '@jackwener/opencli/registry';
import {
    YUANBAO_DOMAIN,
    ensureYuanbaoPage,
    isLoggedIn,
    getCurrentYuanbaoSessionId,
    getYuanbaoModelLabel,
} from './shared.js';

cli({
    site: 'yuanbao',
    name: 'status',
    access: 'read',
    description: 'Check Yuanbao page availability, login state, current session and model',
    domain: YUANBAO_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    args: [],
    columns: ['Status', 'Login', 'Model', 'ModelId', 'AgentId', 'SessionId', 'Url'],
    func: async (page) => {
        await ensureYuanbaoPage(page);
        await page.wait(1.5);
        const [loggedIn, session, model, url] = await Promise.all([
            isLoggedIn(page),
            getCurrentYuanbaoSessionId(page),
            getYuanbaoModelLabel(page),
            page.evaluate('window.location.href').catch(() => ''),
        ]);
        // Surface unknown values as `null` (typed unknown) rather than '-' / ''
        // sentinels — sentinels look like real labels and silently break filters
        // built on these columns.
        return [{
            Status: 'Connected',
            Login: loggedIn ? 'Yes' : 'No (login gate)',
            Model: model.label,
            ModelId: model.modelId,
            AgentId: session?.agentId ?? null,
            SessionId: session?.convId ?? null,
            Url: typeof url === 'string' ? url : '',
        }];
    },
});