spectrawl
spectrawl copied to clipboard
feat: add Exa AI-powered search tool
Summary
Adds Exa as an additional search provider in the cascade, alongside the existing nine engines. Exa is an AI-native search engine that returns clean, agent-ready results with built-in content retrieval (highlights, text, summaries), neural search, and rich filtering (category, domains, dates, user location).
- New
src/search/engines/exa.jsfollowing the samehttps-based pattern astavily.js,brave.js, andserper.js - Registered under the
exakey in theENGINEScascade registry - Reads
EXA_API_KEYfrom env (orconfig.exa.apiKey) - Defaults to
type: 'auto'withcontents: { highlights: true, text: { maxCharacters: 1000 } }so results land in the same snippet-sized shape the cascade already expects — configurable per-call - Forwards
category,includeDomains/excludeDomains,startPublishedDate/endPublishedDate,startCrawlDate/endCrawlDate, anduserLocation - Snippet extraction cascades through
highlights→summary→textso any combination ofcontentsoptions produces a usable result - TypeScript typings added for
config.search.exa - README updated: engines table row and env var reference
Usage
const { Spectrawl } = require('spectrawl')
const web = new Spectrawl({
search: {
cascade: ['gemini-grounded', 'exa', 'tavily'],
exa: { type: 'neural', category: 'research paper' }
}
})
const result = await web.deepSearch('transformer architectures for long context')
console.log(result.sources)
Set EXA_API_KEY in your environment (1,000 free searches/month, get a key at https://dashboard.exa.ai).
Files changed
src/search/engines/exa.js— new enginesrc/search/index.js— registerexain the cascadeindex.d.ts— addexaconfig typingsREADME.md— engines table + env vartest/exa.test.js— 10 unit tests covering the engine end-to-end
Test plan
- [x] Added unit tests for
exaSearchcovering:- Missing
EXA_API_KEY→ throws - API response → cascade result shape mapping
x-api-keyandx-exa-integrationheaders on the outgoing request- Default request body (
type: 'auto',numResults: 10,contentsshape) - Filter forwarding:
type,maxResults,category,includeDomains,excludeDomains,startPublishedDate,endPublishedDate,userLocation contents: falsedisables the contents object- Custom
contentsobject overrides the default - Snippet fallback:
highlights→summary→text→ empty string - Non-
resultspayload → descriptive error - Registry integration via
new SearchEngine({ cascade: ['exa'] })
- Missing
- [x]
node --test test/exa.test.js— 10 / 10 pass - [x]
node --test test/exa.test.js test/search.test.js test/config.test.js— 18 / 18 pass (no regressions in existing search tests) - [ ] Live end-to-end run against
api.exa.ai(requires anEXA_API_KEY; not run in this environment)