jackwener/OpenCLI · error · AuthRequiredError

AUTH_REQUIRED

AUTH_REQUIRED

Error message

Yuanbao opened a login gate when reading the sidebar.

What it means

The Yuanbao CLI history command detected Tencent Yuanbao's login gate (login wall / not-authenticated overlay) on the automation page before reading the sidebar session list. The library throws AUTH_REQUIRED because the operation cannot proceed without an authenticated Yuanbao session. It is raised in the command function for `yuanbao history` after ensureYuanbaoPage and hasLoginGate detection.

Source

Thrown at clis/yuanbao/history.js:33

    access: 'read',
    description: 'List recent Yuanbao conversations from the sidebar (requires login)',
    domain: YUANBAO_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    args: [
        { name: 'limit', type: 'int', default: 20, help: 'Max conversations to list (sidebar virtual scroll caps actual count)' },
    ],
    columns: ['Index', 'Title', 'AgentId', 'SessionId', 'Url'],
    func: async (page, kwargs) => {
        const limit = Number(kwargs.limit ?? 20);
        if (!Number.isInteger(limit) || limit <= 0) {
            throw new ArgumentError('limit', 'must be a positive integer');
        }
        await ensureYuanbaoPage(page);
        if (await hasLoginGate(page)) {
            throw authRequired('Yuanbao opened a login gate when reading the sidebar.');
        }
        await page.wait(1.5);
        const sessions = await getYuanbaoSessionList(page, limit);
        if (!sessions.length) {
            throw new EmptyResultError(
                'yuanbao history',
                'No Yuanbao conversations found in the sidebar. Either the account is logged out, the sidebar is collapsed, or the user truly has no chat history yet.',
            );
        }
        return sessions.map((s, i) => ({
            Index: i + 1,
            Title: s.title || '(untitled)',
            AgentId: s.agentId,
            SessionId: s.cid,
            Url: `${YUANBAO_URL}chat/${s.agentId}/${s.cid}`,
        }));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open the automation browser profile and log in to yuanbao.tencent.com manually, then rerun the command.
  2. Persist the logged-in browser profile (user data dir) so cookies survive across CLI runs.
  3. Re-check with a short retry in case the gate was a transient redirect before authentication state settled.
  4. Verify the browser profile/daemon is attached to the account you expect, not a fresh or incognito profile.

Example fix

// before: headless run with fresh profile
await cli.run(['yuanbao', 'history']);
// after: reuse persisted profile and log in once
const browser = await launch({ userDataDir: '~/.opencli/profiles/yuanbao' });
await loginToYuanbao(browser); // one-time interactive login
await cli.run(['yuanbao', 'history']);
Defensive patterns

Strategy: try-catch

Validate before calling

if (await hasLoginGate(page)) {
  await interactiveLogin(page); // log in before invoking history
}
await cli.run(['yuanbao', 'history']);

Try / catch

try {
  await cli.run(['yuanbao', 'history']);
} catch (e) {
  if (e.code === 'AUTH_REQUIRED') { await interactiveLogin(page); return cli.run(['yuanbao', 'history']); }
  throw e;
}

Prevention

When it happens

Trigger: Running the `yuanbao history` command when hasLoginGate(page) returns true — i.e., the browser page redirected to or displays Yuanbao's login gate instead of the authenticated sidebar with the session list.

Common situations: Expired Yuanbao session cookies, running the CLI with a fresh browser profile that was never logged in, being logged out remotely, or cookies cleared by browser cleanup tools.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/943adff954f6c225. Report an issue: GitHub.