Skip to content
2 min read · 342 words

@nhtio/adk/batteries/tools/searxng

Factory for a configured SearXNG metasearch tool.

Remarks

Unlike the other bundled tool categories — every one of which exports a ready-made, stateless Tool constant — the SearXNG battery exports factories, createSearxngSearchTool (async) and createSearxngSearchToolSync. A search tool has to talk to a specific SearXNG instance, usually behind custom authentication, so it needs per-deployment configuration (a base URL and headers) that cannot be baked in at module load.

Because this module exports factories rather than Tool instances, they MUST NOT be bulk-registered via Object.values(batteries). Call a factory first, then register the returned tool: new ToolRegistry([await createSearxngSearchTool({ instanceUrl })]).

See

https://docs.searxng.org/dev/search_api.html

Interfaces

InterfaceDescription
SearxngRequestContextMutable context handed to each input-pipeline stage before the HTTP request is sent.
SearxngResponseContextMutable context handed to each output-pipeline stage after the response JSON is parsed.
SearxngResultA single normalised SearXNG result. SearXNG result items are deliberately untyped upstream, so every field except a best-effort title/url is optional.
SearxngToolConfigConfiguration for createSearxngSearchTool (async) and createSearxngSearchToolSync (sync — artifact narrowed to the sync subset).

Type Aliases

Type AliasDescription
SearxngHeadersA static set of request headers (used for custom authentication).
SearxngHeadersResolverA resolver returning request headers, sync or async. Use this form when the auth token is refreshable — the resolver runs on every search, so a fresh token can be minted per call.
SearxngInputMiddlewareFnAn input-pipeline stage. Onion middleware over SearxngRequestContext.
SearxngOutputMiddlewareFnAn output-pipeline stage. Onion middleware over SearxngResponseContext.
SearxngResultFormatThe output shape the tool serialises. either lets the model pick per call.

Functions

FunctionDescription
createSearxngSearchToolCreate a configured SearXNG search Tool (async — accepts a dynamic-import artifact).
createSearxngSearchToolSyncSynchronous createSearxngSearchTool — the ergonomic common path.

References

E_INVALID_SEARXNG_CONFIG

Re-exports E_INVALID_SEARXNG_CONFIG