@@ -9,6 +9,24 @@ import {
99} from '@/tools/exa/utils'
1010import type { ToolConfig } from '@/tools/types'
1111
12+ /** Content options every search type except Lite accepts: summaries, subpages, extras, and freshness. */
13+ function addNonLiteContents ( contents : Record < string , unknown > , params : ExaSearchParams ) : void {
14+ if ( params . summaryQuery ) {
15+ contents . summary = { query : params . summaryQuery }
16+ } else if ( String ( params . summary ) === 'true' ) {
17+ contents . summary = true
18+ }
19+
20+ if ( params . subpages ) contents . subpages = Number ( params . subpages )
21+ const subpageTarget = parseCommaList ( params . subpageTarget )
22+ if ( subpageTarget ) contents . subpageTarget = subpageTarget
23+
24+ const extras = buildExtras ( params )
25+ if ( extras ) contents . extras = extras
26+
27+ applyFreshness ( contents , params )
28+ }
29+
1230export const searchTool : ToolConfig < ExaSearchParams , ExaSearchResponse > = {
1331 id : 'exa_search' ,
1432 name : 'Exa Search' ,
@@ -231,36 +249,30 @@ export const searchTool: ToolConfig<ExaSearchParams, ExaSearchResponse> = {
231249
232250 if ( params . startPublishedDate ) body . startPublishedDate = params . startPublishedDate
233251 if ( params . endPublishedDate ) body . endPublishedDate = params . endPublishedDate
234- if ( params . startCrawlDate ) body . startCrawlDate = params . startCrawlDate
235- if ( params . endCrawlDate ) body . endCrawlDate = params . endCrawlDate
236-
237- const outputSchema = parseJsonSchema ( params . outputSchema , 'outputSchema' )
238- if ( outputSchema ) body . outputSchema = outputSchema
239- if ( params . systemPrompt ) body . systemPrompt = params . systemPrompt
240252
241253 /**
242254 * On `/search` the content options are nested under `contents` — unlike
243255 * `/contents`, where the same fields sit at the top level.
244256 */
245257 const contents : Record < string , any > = { }
246258
247- if ( params . text !== undefined ) contents . text = params . text
248- if ( params . highlights !== undefined ) contents . highlights = params . highlights
259+ if ( params . text != null ) contents . text = params . text
260+ if ( params . highlights != null ) contents . highlights = params . highlights
249261
250- if ( params . summaryQuery ) {
251- contents . summary = { query : params . summaryQuery }
252- } else if ( params . summary !== undefined ) {
253- contents . summary = params . summary
254- }
255-
256- if ( params . subpages ) contents . subpages = Number ( params . subpages )
257- const subpageTarget = parseCommaList ( params . subpageTarget )
258- if ( subpageTarget ) contents . subpageTarget = subpageTarget
262+ /**
263+ * Lite rejects every parameter outside query, filters, and text/highlights contents,
264+ * so the options other search types accept are only added for them.
265+ */
266+ if ( params . type !== 'lite' ) {
267+ if ( params . startCrawlDate ) body . startCrawlDate = params . startCrawlDate
268+ if ( params . endCrawlDate ) body . endCrawlDate = params . endCrawlDate
259269
260- const extras = buildExtras ( params )
261- if ( extras ) contents . extras = extras
270+ const outputSchema = parseJsonSchema ( params . outputSchema , 'outputSchema' )
271+ if ( outputSchema ) body . outputSchema = outputSchema
272+ if ( params . systemPrompt ) body . systemPrompt = params . systemPrompt
262273
263- applyFreshness ( contents , params )
274+ addNonLiteContents ( contents , params )
275+ }
264276
265277 if ( Object . keys ( contents ) . length > 0 ) {
266278 body . contents = contents
0 commit comments