{"record":{"id":"944bfcc538c053fb","repo":"jackwener/OpenCLI","slug":"manus-session-cookies-missing-anonymous","errorCode":null,"errorMessage":"Manus session cookies missing — anonymous","messagePattern":"Manus session cookies missing — anonymous","errorType":"validation","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/manus/auth.js","lineNumber":11,"sourceCode":"import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';\nimport { registerSiteAuthCommands } from '../_shared/site-auth.js';\n\nasync function hasManusSessionCookie(page) {\n  const cookies = await page.getCookies({ url: 'https://manus.im' });\n  return cookies.some(c => /^(auth_session|manus_token|_session|session)$/.test(c.name) && c.value);\n}\n\nasync function verifyManusIdentity(page) {\n  if (!await hasManusSessionCookie(page)) {\n    throw new AuthRequiredError('manus.im', 'Manus session cookies missing — anonymous');\n  }\n  await page.goto('https://manus.im/');\n  await page.wait(3);\n  const probe = await page.evaluate(`(async () => {\n    try {\n      const r = await fetch('/api/auth/session', { credentials: 'include', headers: { Accept: 'application/json' } });\n      if (r.status === 401 || r.status === 403) {\n        return { kind: 'auth', detail: 'Manus /api/auth/session HTTP ' + r.status };\n      }\n      if (r.status === 503) {\n        return { kind: 'http', httpStatus: 503 };\n      }\n      if (!r.ok) return { kind: 'http', httpStatus: r.status };\n      const d = await r.json();\n      const u = d?.user || d;\n      if (!u || !(u.id || u.userId)) {\n        return { kind: 'auth', detail: 'Manus /api/auth/session 200 but no user' };\n      }","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/manus/auth.js#L1-L29","documentation":"verifyManusIdentity first checks the browser context for a Manus session cookie (auth_session, manus_token, _session, or session with a non-empty value) for https://manus.im. If none is present it throws AuthRequiredError because the CLI is operating anonymously and cannot prove the logged-in identity.","triggerScenarios":"Running any manus auth command (login/whoami/list) when the automation browser profile has no Manus session cookie — e.g. never logged in, cookies cleared, fresh/ephemeral browser profile, cookies expired and purged, or page.getCookies filtered to a different URL/domain than where the cookie was set.","commonSituations":"Running the CLI in CI or a container with a throwaway browser profile; clearing browser cookies or switching profiles; running before ever completing the interactive manus login; system clock issues causing cookie expiry and cleanup; a proxy or domain mismatch so cookies stored under another URL are not returned for manus.im.","solutions":["Run the manus login command and complete the interactive login at https://manus.im/login so session cookies are stored in the browser profile.","Use a persistent browser user-data directory so cookies survive between CLI runs.","Verify in the Manus web UI that you are actually logged in and the session has not been revoked.","If cookies exist but aren't seen, check the cookie's domain matches https://manus.im (e.g. cookie set for a subdomain or different path won't match).","Re-login if the session was invalidated server-side (password change, logout-everywhere, expired token)."],"exampleFix":"// before (fresh profile, no cookies)\nopencli manus whoami   // AuthRequiredError: Manus session cookies missing — anonymous\n// after\nopencli manus login    // complete browser login first\nopencli manus whoami   // succeeds","handlingStrategy":"try-catch","validationCode":"const cookies = await page.getCookies({ url: 'https://manus.im' });\nconst hasSession = cookies.some(c => /^(auth_session|manus_token|_session|session)$/.test(c.name) && c.value);\nif (!hasSession) { await runManusLogin(); }","typeGuard":"function hasManusSession(cookies) {\n  return cookies.some(c => /^(auth_session|manus_token|_session|session)$/.test(c.name) && !!c.value);\n}","tryCatchPattern":"try {\n  await manusWhoami();\n} catch (e) {\n  if (e.name === 'AuthRequiredError' && /cookies missing/.test(e.message)) {\n    await manusLogin(); // interactive login, then retry once\n  } else throw e;\n}","preventionTips":["Use a persistent browser user-data dir so session cookies survive runs.","Run manus login before scripted commands in fresh CI environments.","Detect AuthRequiredError early and trigger re-login instead of failing the whole job.","Periodically re-validate the session and refresh cookies before expiry."],"tags":["authentication","session-cookie","manus","auth-required"],"backgroundTag":"session-cookie-missing","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}