Skip to content
3 min read · 522 words

@nhtio/adk/batteries/tools/web_retrieval

RAG glue: turn web-search and web-scrape results into Retrievable records for a turn.

Remarks

The seam from "I searched / scraped something" to "it is in the turn as a Retrievable", shared by the SearXNG and Scrapper batteries. It is deliberately decoupled from the ADK core at runtime:

  • The converters are pure (payload) => RawRetrievable[] — they build plain data objects and never instantiate a core class, so the module's only core coupling is erased import type.
  • The recommended spool-artifact type travels as an open resolver (@nhtio/adk/forge!ArtifactConstructorResolver), never a closed string enum — a consumer's future YAML/HTML SpooledArtifact subclass works with no change here. The converter hands the recommendation to the caller's spool hook; the caller owns the actual class import.
  • The one helper that must construct a Retrievable (storeRetrievables) takes the constructor via a resolver (constructor / sync / async / dynamic-import), exactly like the vector battery's createVectorStore client.

Web content is 'third-party-public' by default — a definitional constant for open-web data (NOT inferred from the URL, which CONTRIBUTING Design Decision #12 forbids); override via trustTier when you know better.

Interfaces

InterfaceDescription
ArticleToRetrievableOptionsOptions for scrapperArticleToRetrievable.
ArtifactRecommendationsThe artifact-resolver recommendations a caller may supply so the glue names no concrete class itself. Each converter asks for the relevant key; if the caller omits it, content stays inline.
RetrievableStoreCtxThe minimal context surface storeRetrievables needs.
ScrapperArticleLikeMinimal structural shape of a Scrapper normalised article.
ScrapperLinkLikeMinimal structural shape of a Scrapper normalised link.
ScrapperLinksLikeMinimal structural shape of a Scrapper normalised links payload.
SearxngPayloadLikeMinimal structural shape of a SearXNG normalised payload.
SearxngResultLikeMinimal structural shape of a SearXNG normalised result the converter reads.
ToRetrievableOptionsOptions common to every converter.

Type Aliases

Type AliasDescription
ArticleContentSourceWhich article text field to use as the record content.
ResolverA resolver of T: the value itself, or a (sync/async) thunk, optionally a module { default }.
RetrievableCtorA constructor that builds a @nhtio/adk!Retrievable from a @nhtio/adk!RawRetrievable.
SpoolHookA reader-backed-artifact hook. Called by a converter for content that may be large; the converter passes the artifact constructor it recommends for this content (an open @nhtio/adk/forge!ArtifactConstructorResolver) so the caller can wrap with the right subclass — preserving its forged query tools — using the caller's own core import. Return a @nhtio/adk!SpooledArtifact to store the content reader-backed, or undefined to keep it inline as a string.

Functions

FunctionDescription
scrapperArticleToRetrievableConvert a Scrapper normalised article into a single @nhtio/adk!RawRetrievable.
scrapperLinksToRetrievablesConvert a Scrapper normalised links payload into one @nhtio/adk!RawRetrievable per link.
searxngResultsToRetrievablesConvert a SearXNG normalised payload into one @nhtio/adk!RawRetrievable per result.
storeRetrievablesConstruct @nhtio/adk!Retrievables from RawRetrievables and store each via ctx.