Skip to main content

SearchProvider

@forge/monorepo


@forge/monorepo / backend/src / SearchProvider

Type Alias: SearchProvider

SearchProvider = object

Defined in: backend/src/toolkit/web.ts:115

A search provider, as configuration.

Deliberately not a hard-coded vendor. Every usable search API is a GET with a key and a JSON body of results, so the shape a deployment supplies is: where to send it, and how to read what comes back. apiKey is configuration and never appears in a tool's input schema — a model must not be able to name the credential it wants spent.

Properties

body?

readonly optional body?: (query, limit) => unknown

Defined in: backend/src/toolkit/web.ts:132

The request body for a POST provider. Ignored for GET.

Parameters

query

string

limit

number

Returns

unknown


endpoint

readonly endpoint: (query, limit) => string

Defined in: backend/src/toolkit/web.ts:118

Build the request URL for a query. The key belongs in headers, not here, wherever the provider allows it.

Parameters

query

string

limit

number

Returns

string


headers?

readonly optional headers?: Readonly<Record<string, string>>

Defined in: backend/src/toolkit/web.ts:119


method?

readonly optional method?: "GET" | "POST"

Defined in: backend/src/toolkit/web.ts:130

POST, for the providers that require it.

Added when the first real adapters were written (#214): this contract was GET-only, and three of the four most-used providers — Tavily, Serper, Exa — are POST with a JSON body. A GET-only seam would have limited the catalogue to Brave and self-hosted SearXNG, which is not a "one contract, several providers" rule so much as a rule with two providers.

Optional, so every existing GET provider is unchanged.


name

readonly name: string

Defined in: backend/src/toolkit/web.ts:116


parse

readonly parse: (payload) => readonly SearchHit[]

Defined in: backend/src/toolkit/web.ts:134

Read the provider's JSON into hits. Returning [] means "searched, found nothing".

Parameters

payload

unknown

Returns

readonly SearchHit[]