Add Perplexity cookie-auth fallback + Cloudflare retry path#7
Add Perplexity cookie-auth fallback + Cloudflare retry path#7damianpdr wants to merge 3 commits intonicobailon:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0fab415b4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| try { | ||
| const { answer, results } = await search(queryList[qi], { | ||
| provider: defaultProvider as SearchProvider | undefined, | ||
| provider: initialSearchProvider, |
There was a problem hiding this comment.
Keep provider mode consistent across curator searches
When requestedProvider is "auto", the initial query loop now calls search() with provider: undefined, so it can fall back from Perplexity to Gemini, but onAddSearch in the curator path still calls search() with a pinned provider (pc.defaultProvider/currentProvider). In environments where Perplexity is detected but unusable at runtime (e.g., Chrome installed but no active Perplexity session), initial queries can succeed via Gemini while added queries fail with Perplexity auth errors, which makes the same curator session behave inconsistently.
Useful? React with 👍 / 👎.
|
Thanks, this is valid and fixed in d284554.\n\nI introduced a small helper and now use it consistently in both curator paths:\n- initial query batch\n- callbacks\n\nBehavior now stays consistent when the requested provider is (it passes so runtime fallback can still occur), while explicit provider selections in the curator continue to pin to the chosen provider. |
|
Follow-up with exact details: ✅ Fixed in commit I added a helper:
and use it consistently in both curator paths for:
Result:
|
Summary
This PR makes
web_searchmore resilient when Perplexity API keys are missing/invalid and when Perplexity web requests are blocked by Cloudflare in Node fetch.What changed
chrome-cookies.tsnow supports Perplexity origins and relevant cookie names.isPerplexityAvailable()now considers local Chrome cookie availability.perplexity.ts:Just a moment..., cf challenge markers).curl_cffiChrome impersonation.~/.pi/cache/pi-web-access/curl-cffi-venvon first use.Why
In some environments, Perplexity web endpoint calls from Node fetch get blocked by Cloudflare (
403 Just a moment...) even with valid logged-in Chrome cookies. Usingcurl_cffiwith browser impersonation resolves this and restores working Perplexity search.Validation
Manual validation in local environment:
https://www.perplexity.ai/rest/sse/perplexity_askreturned Cloudflare 403.curl_cffi+ same cookies to same endpoint returned HTTP 200 SSE stream./api/auth/session) confirmed valid logged-in session.Notes
curl_cffifallback requirespython3withvenvsupport on macOS.