Commit Graph
22 Commits
Author SHA1 Message Date
Ivan Pereira 838644734f fix: address auth and source handling review findings 2026-07-14 12:06:33 +01:00
Ivan Pereira 5b6bb41c3f refactor: drop dead model/limit plumbing and unused render helper
resolveSearchDefaults no longer accepts a per-call model override and
SearchParams no longer carries limit; neither was reachable from the
tool schema (limit is applied client-side in formatForLLM). Also fold
asPositiveNumber into asPositiveInteger and simplify recency matching.
2026-07-14 03:26:27 +01:00
Ivan Pereira 39d977c403 refactor(auth): route browser paste login through /perplexity-login
The perplexity_search tool no longer prompts for pasted browser
credentials mid-search; /perplexity-login --browser is the single
entry point for that flow. Drop the now-unused promptForBrowserAuth
option and its Cloudflare-challenge fallback from authenticate().
2026-07-14 03:26:00 +01:00
Ivan Pereira f8919e254c refactor(auth): separate browser credential parsing 2026-06-24 17:51:37 +01:00
Ivan Pereira 8d889add43 fix(auth): address browser cookie review comments 2026-06-24 17:31:53 +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 142640d96c fix(auth): avoid CSRF challenges during OTP login 2026-06-22 11:33:40 +01:00
Ivan Pereira 4e77f38d5d fix(config): respect configured model 2026-05-11 15:16:42 +01:00
Ivan Pereira 96a3246d1e fix(search): restore error rendering and safe error handling
- Re-add isError flag to error details so renderPerplexityResult
  shows error styling instead of green success rows
- Use errorMessage() for unknown errors instead of unsafe cast
- Trim whitespace-only PI_PERPLEXITY_MODEL env var values
- Add comment explaining clearToken() on AUTH rejection
2026-03-21 21:28:51 +00:00
Ivan Pereira fcc7613edc fix(config): simplify current model label 2026-03-21 21:02:44 +00:00
Ivan Pereira 041d30651a fix(config): apply defaults to perplexity UI 2026-03-21 20:54:41 +00:00
Ivan Pereira 431a814e9a Add asPositiveInteger helper, use for limit display 2026-02-23 10:49:46 +00:00
Ivan Pereira 56ef5533a3 Standardize ellipsis to … in snippet truncation 2026-02-23 10:49:43 +00:00
Ivan Pereira 909145de94 Remove closure cancel flags from login command
canceledAtEmailPrompt and canceledAtOtpPrompt were closure booleans
set inside prompt callbacks to detect user cancellation after the
fact. Fragile if authenticate ever retries prompts or changes order.

In the command context both prompt functions are always provided, so
AuthError(NO_TOKEN) unambiguously means the user declined to enter
required input. Check the error code directly instead.
2026-02-23 10:49:39 +00:00
Ivan Pereira 63eb22316a Replace brittle error text detection with isError flag
renderPerplexityResult was pattern-matching content text prefixes
to decide whether to render in error style. This was tightly coupled
to exact message strings in index.ts — a wording change would
silently break the error styling.

Set isError: true in details on every error return path in execute,
and check details.isError in the renderer instead.
2026-02-23 10:49:33 +00:00
Ivan Pereira 2c5b558271 Extract shared Perplexity API constants to src/constants.ts
PERPLEXITY_USER_AGENT and PERPLEXITY_API_VERSION were duplicated
in auth/login.ts and search/client.ts. Centralise both so updates
only need to happen in one place.
2026-02-23 10:49:23 +00:00
Ivan Pereira 76dbc20064 Harden token storage and declare Bun runtime
Enforce 0600 permissions after every auth token write so existing files
with broader modes are corrected.

Add a regression test for the permission hardening path and document the
Bun runtime dependency used by the Node/jiti search subprocess path.
Also declare bun in package dependencies and engines.
2026-02-23 10:47:05 +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 f42531b07c Implement perplexity login/render modules and harden OAuth search flow 2026-02-17 08:25:56 +00:00
Ivan Pereira 39b8ee6b57 Add OTP fallback auth and progress handoff log 2026-02-16 18:51:09 +00:00
Ivan Pereira 47878d9962 Initial commit 2026-02-16 18:42:03 +00:00