Skip to content
2 min read · 313 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 a factory, createSearxngSearchTool. 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 a factory rather than a Tool instance, it MUST NOT be bulk-registered via Object.values(batteries). Call the factory first, then register the returned tool: new ToolRegistry([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.

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.

References

E_INVALID_SEARXNG_CONFIG

Re-exports E_INVALID_SEARXNG_CONFIG