# @leumas/research

Deep-research engine — iterative query -> web-search -> summarize -> reflect loop over @leumas/providers + the websearch/scraping adapters. Exposed as /api/research (JSON + SSE), the deep-research...


The deep-research engine: an iterative **query → web-search → summarize → reflect** loop
(ported from the legacy `ollama-research` tool, LangGraph dropped) that any Leumas surface can call.

- **Engine** — `runDeepResearch({ topic, loops, searchApi, provider, onEvent, signal, providerRegistry, adapters, connector })`.
  LLM calls ride the injected `@leumas/providers` registry; search rides the `websearch` adapter
  (DuckDuckGo/Wikipedia keyless, Tavily/Perplexity via env keys); full-page enrichment rides the
  `scraping` adapter. Runs persist to the `research_runs` dynamic collection when a connector is given.
- **HTTP** — `createResearchRouter(...)` mounted at `/api/research`: `POST /run` (JSON) and
  `POST /run/stream` (SSE: `start · loop · query · sources · page · summary · reflection · final · done · error`).
- **Action** — `deepResearchAction(...)` registers the `deep-research` action: rule-callable, and the
  seeded `research.deep` functioncall (executor kind `action`) makes it a chatbot tool + MCP tool.
- **Gating** — logged-in + `intelligence` membership (admins bypass) + PassNode `feature:research.run`.

Studio UI: the **Intelligence** domain's Research Lab. Smoke: `pnpm smoke:research` (network-free fakes).


---
Source: shared/engines/research/README.md
Canonical: https://docs.leumas.tech/p/engines/research
