feat: add Warp provider adapter#350
Conversation
Add Warp SQLite session discovery and parsing, wire provider registry/model aliases/cache env fingerprinting, and document/test provider behavior. Co-Authored-By: Oz <oz-agent@warp.dev>
iamtoruk
left a comment
There was a problem hiding this comment.
Code Review — Performance, Security & Compatibility Audit
Ran this against a real local Warp DB (macOS, 301MB warp.sqlite, 3 conversations). Provider discovers and parses correctly. No crashes. Full test suite passes (876/876).
Must Fix
1. Remove bare auto-efficient / auto-powerful from BUILTIN_ALIASES (src/models.ts:176-177)
These two generic keys create a global collision risk — any future provider emitting a model named auto-efficient would silently resolve to gpt-5.3-codex. They're also redundant: Warp's own normalizeModel() already maps auto-efficient → warp-auto-efficient before the name reaches BUILTIN_ALIASES, so the bare keys are dead code.
Remove these two lines:
- 'auto-efficient': 'gpt-5.3-codex',
- 'auto-powerful': 'claude-opus-4-6',The prefixed warp-auto-efficient and warp-auto-powerful (lines 174-175) are sufficient.
2. Remove unscoped README changes
The Node badge bump (20→22) and better-sqlite3 requirements rewrite are pre-existing doc debt, not Warp-specific. Please split these into a separate commit/PR so the changelog stays accurate.
Should Consider
3. outputTokens: 0 always
All tokens are attributed to inputTokens and cost is calculated at the input rate. For models where output costs 3-5x more than input (Opus), this significantly underestimates cost. The costIsEstimated: true flag helps, but consider a heuristic 60/40 split or at least a code comment explaining the trade-off.
4. Duplicate display-name aliases
'Claude Sonnet 4.6', 'Claude Haiku 4.5', etc. appear in both BUILTIN_ALIASES (models.ts) and modelAliases (warp.ts). These will drift. Consider removing the display-name entries from warp.ts since resolveAlias in models.ts already handles them globally.
5. toolSequence for retry detection
We just landed #353 which adds toolSequence to fix 100% one-shot rates for providers that aggregate tools per-session. Warp emits per-exchange so it's not technically broken, but if a single exchange involves multiple sequential tool invocations (Edit→Bash→Edit), those get flattened into one tools[]. Consider setting toolSequence: undefined explicitly or adding a comment noting the limitation.
Verified Safe
| Area | Finding |
|---|---|
| SQL injection | All 6 queries use parameterized ? placeholders. No string interpolation. |
| DB access | Opened readOnly: true (sqlite.ts:124). Malicious WARP_DB_PATH → failed open, caught by try/catch. |
decodeSourcePath colon split |
macOS paths can't contain :. Edge case with crafted DB → failed open, no harm. |
blobToText / XSS |
Data flows to JSON, no HTML rendering context. |
| Blocks query performance | Full table scan with json_extract on read-only DB (can't add index). Acceptable for typical Warp DBs (<50k blocks). ~50-200ms worst case. |
| Discovery N+1 | Correlated subquery per conversation. Fine for a few hundred conversations. |
assignCommandBlocksToExchanges |
O(blocks × exchanges) with early break. Both sets tiny per-conversation. |
Provider registry (index.ts) |
Lazy-load pattern matches Goose/Cursor/Crush exactly. |
Session cache (session-cache.ts) |
WARP_DB_PATH fingerprint isolated to Warp section. |
Overall well-structured contribution. Items 1 and 2 are the only blockers.
- remove unscoped README node/better-sqlite3 changes - drop bare auto aliases to avoid collisions - document output-token estimation tradeoff Co-Authored-By: Oz <oz-agent@warp.dev>
|
Implemented the requested review fixes on this branch:
Validation run:
Result: 90/90 tests passing. |
Summary
Validation
Artifacts
Co-Authored-By: Oz oz-agent@warp.dev