9 Commits
Author SHA1 Message Date
Ivan Pereira f94c08072e feat(models): add GLM-5.2 and harden reported-model fallback
Perplexity's model fields are inconsistent per model: Claude Sonnet 5 reports the real slug in user_selected_model with display_model "turbo", while GLM-5.2 reports the inverse. Pick whichever field is present and not "turbo", and fall back to the requested model when both are missing or "turbo".

Also add glm_5_2 to KNOWN_MODELS.

Refs #7 (follow-up comment)
2026-07-16 15:59:30 +01:00
9f5c87c1c4 feat(models): add Claude Sonnet 5 models and honor user_selected_model (#8)
Perplexity's /rest/models/config now exposes claude50sonnet and
claude50sonnetthinking. Add both to KNOWN_MODELS with the official
labels from the config.

The stream's display_model can report "turbo" even when the requested
model was honored, so prefer user_selected_model when present and not
"turbo" so tool metadata reflects the model actually used.

Closes #7

Co-authored-by: Ivan Pereira <183991+ivanrvpereira@users.noreply.github.com>
2026-07-16 15:40:59 +01:00
97aab3e9b9 refactor(search): always send searches as incognito (#14)
Hardcode is_incognito: true in the Perplexity request and remove the
toggle surface: the incognito tool parameter, PI_PERPLEXITY_INCOGNITO
env var, config file field, /perplexity-config prompt, and TUI status
indicators. Config and resolveDefaultModel are now model-only.

Supersedes the incognito portion of PR #4.

Co-authored-by: Ivan Pereira <183991+ivanrvpereira@users.noreply.github.com>
2026-07-16 15:28:02 +01:00
Ivan Pereira d01cfc86bc feat(auth): add browser cookie login fallback 2026-06-24 17:19:38 +01:00
Ivan Pereira bbb5623f25 refactor(runtime): replace Bun dependency with Node fetch
Run Perplexity search and auth requests through pi's Node runtime instead of
shelling out to Bun. Move development and CI commands to npm, add a Node test
build path, and keep OTP auth fail-fast when Set-Cookie headers are not
available.
2026-06-23 15:51:16 +01:00
Ivan Pereira 0f301e7f47 fix(test): isolate tests from mock.module cache pollution
mock.module() in index-execute.test.ts permanently poisons Bun's
module cache — mock.restore() does not undo it in Bun 1.3.11.

Use cache-busted dynamic imports (../src/mod.ts?t=${Date.now()}) in
beforeEach for the three affected test files so each test gets a
fresh, unpoisoned module instance.
2026-03-21 21:29:00 +00:00
Ivan Pereira 041d30651a fix(config): apply defaults to perplexity UI 2026-03-21 20:54:41 +00:00
Ivan Pereira 501935fe1c Simplify auth and search client, drop local JWT expiry tracking
Auth:
- Remove jwt.ts — stop decoding JWT exp claims locally
- Simplify OTP login: direct token extraction from verify response,
  remove CookieJar, BFS token extraction, session fallback, CF bypass
- Storage: drop expires field, store token-only; clear on 401/403
- Single auth path: try stored token → macOS app → OTP fallback

Search client:
- Remove Cloudflare subprocess fallback (fetchViaBunRuntime)
- Remove streamFromText, isCloudflareChallenge, BunFetchResult
- Simplify SSE fetch to single fetch() call with abort signal
- Let server validate tokens; clear cache on auth errors

Render:
- Extract shared utilities (asString, truncate) to render/util.ts
- Simplify call.ts and result.ts to import from shared module

Tests:
- Remove jwt.test.ts (module deleted)
- Add otp-flow.test.ts for email OTP authentication
- Simplify login and client tests for reduced code paths

Add debug scripts and plan documents.
2026-02-18 08:03:39 +00:00
Ivan Pereira 47878d9962 Initial commit 2026-02-16 18:42:03 +00:00