# knockoutez/wigolo architecture

> Architecture diagram of the GitHub repository knockoutez/wigolo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/knockoutez/wigolo
- Repository: https://github.com/knockoutez/wigolo

## Overview

#### Purpose and runtime surface
Wigolo is a local-first web-intelligence engine for AI agents: search, fetch, crawl, structured extraction, cache, similarity, research, autonomous gathering, diff, and watch. It runs primarily as a Node.js (Node ≥20) MCP stdio server, with CLI, local HTTP/REST/MCP daemon, REPL, and SDK-facing surfaces.
- `src/index.ts`
- `src/server.ts`
- `src/cli/index.ts`

#### Entry-point and transport boundary
The core server registers tool schemas and returns agent-oriented result contracts. MCP is the default in-process/stdin-out transport; `serve` adds HTTP REST (`/v1/{tool}`), OpenAPI, and remote MCP/SSE. The daemon layer owns binding, health checks, proxying, authentication, request limits, target validation, and loopback-safe defaults.
- `src/server/tool-schemas.ts`
- `src/daemon/http-server.ts`
- `src/daemon/rest/router.ts`

#### Tool orchestration layer
Thin tool handlers are the shared control boundary used by MCP, REST, CLI, and REPL. They dispatch into domain pipelines rather than duplicating behavior across transports. CLI commands handle setup, warmup, health/doctor, agent configuration, daemon lifecycle, and interactive operation; the REPL supports shell/NDJSON workflows.
- `src/tools/search.ts`
- `src/tools/fetch.ts`
- `src/tools/research.ts`
- `src/repl/shell.ts`

#### Retrieval and ranking pipeline
Search fans queries across direct public-engine adapters, optionally uses SearXNG/hybrid routing, then canonicalizes, filters, deduplicates, fuses, reranks, and builds evidence-bearing responses. Search output preserves citations, source spans, quality/freshness signals, engine health, and degradation warnings. Search providers and plugin-defined engines form an extension boundary.
- `src/search/core/orchestrator.ts`
- `src/search/hybrid/router.ts`
- `src/search/rerank.ts`
- `src/search/engines/`

#### Web acquisition, crawling, and extraction
Fetch routes URLs through escalating HTTP, TLS-hardened, and Playwright/browser paths based on observable challenge, hydration, and content signals. It handles sessions/actions, clearance reuse, politeness, and browser pooling before producing page content. Crawl builds on acquisition with sitemap/robots support, traversal, rate limiting, deduplication, and optional vector indexing. Extraction converts fetched HTML/PDF content into cleaned Markdown, metadata, structured data, site-specific outputs, and schema-constrained records.
- `src/fetch/router.ts`
- `src/crawl/crawler.ts`
- `src/extraction/pipeline.ts`
- `src/extraction/v1/routed.ts`

#### Local state and on-device intelligence
Persistent local storage under the user data directory supports fetched-content/query caching, domain routing knowledge, crawl ETags, diff/watch records, and vector search. SQLite migrations and sqlite-vec provide the storage boundary. Embeddings, reranking, and background indexing are local/lazy-loaded; semantic cache and find-similar combine vector, lexical, crawl, and live-web signals.
- `src/cache/db.ts`
- `src/cache/sqlite-vec-store.ts`
- `src/embedding/embed.ts`
- `src/search/find-similar.ts`

#### Higher-level agent workflows and optional services
Research decomposes questions, retrieves/fetches sources, validates citations, and renders a brief or synthesized report. The autonomous agent similarly plans, executes, ranks, and logs a bounded gather loop. LLM use is optional and isolated behind provider selection/adapters: Anthropic, Gemini, OpenAI, Groq, local Ollama, or custom OpenAI-compatible backends. Secrets are managed through key-store/keychain abstractions. Optional infrastructure includes locally bootstrapped SearXNG, Playwright/browser engines, Docker deployment, webhooks for watch, and external public search engines.
- `src/research/pipeline.ts`
- `src/agent/pipeline.ts`
- `src/integrations/cloud/llm/select.ts`
- `src/security/key-store.ts`

Main entry points: [`src/tools/search.ts`](https://github.com/knockoutez/wigolo/blob/main/src/tools/search.ts) (Tool handlers), [`src/research/pipeline.ts`](https://github.com/knockoutez/wigolo/blob/main/src/research/pipeline.ts) (Research pipeline), [`src/search/core/orchestrator.ts`](https://github.com/knockoutez/wigolo/blob/main/src/search/core/orchestrator.ts) (Search orchestration), [`src/fetch/router.ts`](https://github.com/knockoutez/wigolo/blob/main/src/fetch/router.ts) (Fetch router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_surfaces["Runtime surfaces"]
  node_mcp_server["MCP server<br/>Node.js entry point<br/>[index.ts]"]
  node_cli["CLI<br/>command surface<br/>[index.ts]"]
  node_daemon["HTTP daemon<br/>transport boundary<br/>[http-server.ts]"]
  node_rest_router["REST and remote MCP<br/>HTTP router<br/>[router.ts]"]
  node_repl["REPL<br/>interactive surface<br/>[shell.ts]"]
end

subgraph group_core["Core orchestration"]
  node_tool_schemas["Tool contracts<br/>MCP schemas<br/>[tool-schemas.ts]"]
  node_tool_handlers["Tool handlers<br/>orchestration boundary<br/>[search.ts]"]
end

subgraph group_retrieval["Retrieval and acquisition"]
  node_search_orchestrator["Search orchestration<br/>retrieval pipeline<br/>[orchestrator.ts]"]
  node_hybrid_router["Hybrid search routing<br/>search router<br/>[router.ts]"]
  node_search_engines{{"Search engines and plugins<br/>provider extension"}}
  node_reranking["Reranking<br/>ranking stage<br/>[rerank.ts]"]
  node_fetch_router["Fetch router<br/>web acquisition<br/>[router.ts]"]
  node_crawler["Crawler<br/>crawl pipeline<br/>[crawler.ts]"]
  node_extraction["Extraction pipeline<br/>content transformation<br/>[pipeline.ts]"]
end

subgraph group_local["Local intelligence"]
  node_local_store[("SQLite local store<br/>persistent state<br/>[db.ts]")]
  node_vector_store[("Vector store<br/>sqlite-vec index")]
  node_embeddings["Local embeddings<br/>on-device ML<br/>[embed.ts]"]
  node_similarity["Find similar<br/>semantic retrieval<br/>[find-similar.ts]"]
end

subgraph group_workflows["Agent workflows"]
  node_research["Research pipeline<br/>agent workflow<br/>[pipeline.ts]"]
  node_autonomous_agent["Autonomous gatherer<br/>agent workflow<br/>[pipeline.ts]"]
  node_llm_providers{{"Optional LLM providers<br/>provider selector<br/>[select.ts]"}}
  node_key_store["Secret store<br/>security boundary<br/>[key-store.ts]"]
end

node_mcp_server -->|"registers"| node_tool_schemas
node_tool_schemas -->|"invokes"| node_tool_handlers
node_cli -->|"uses"| node_tool_handlers
node_repl -->|"uses"| node_tool_handlers
node_daemon -->|"hosts"| node_rest_router
node_rest_router -->|"dispatches"| node_tool_handlers
node_tool_handlers -->|"search"| node_search_orchestrator
node_tool_handlers -->|"fetch"| node_fetch_router
node_tool_handlers -->|"research"| node_research
node_search_orchestrator -->|"routes queries"| node_hybrid_router
node_hybrid_router -->|"selects"| node_search_engines
node_search_orchestrator -->|"ranks results"| node_reranking
node_fetch_router -->|"supplies content"| node_extraction
node_crawler -->|"acquires pages"| node_fetch_router
node_crawler -.->|"indexes optionally"| node_vector_store
node_extraction -->|"caches content"| node_local_store
node_local_store -->|"stores vectors"| node_vector_store
node_embeddings -->|"indexes"| node_vector_store
node_similarity -->|"queries"| node_vector_store
node_research -->|"retrieves evidence"| node_search_orchestrator
node_research -->|"reads sources"| node_fetch_router
node_research -.->|"optionally synthesizes"| node_llm_providers
node_autonomous_agent -->|"uses retrieval loop"| node_research
node_llm_providers -->|"loads credentials"| node_key_store

click node_mcp_server "https://github.com/knockoutez/wigolo/blob/main/src/index.ts"
click node_cli "https://github.com/knockoutez/wigolo/blob/main/src/cli/index.ts"
click node_daemon "https://github.com/knockoutez/wigolo/blob/main/src/daemon/http-server.ts"
click node_rest_router "https://github.com/knockoutez/wigolo/blob/main/src/daemon/rest/router.ts"
click node_tool_schemas "https://github.com/knockoutez/wigolo/blob/main/src/server/tool-schemas.ts"
click node_tool_handlers "https://github.com/knockoutez/wigolo/blob/main/src/tools/search.ts"
click node_repl "https://github.com/knockoutez/wigolo/blob/main/src/repl/shell.ts"
click node_search_orchestrator "https://github.com/knockoutez/wigolo/blob/main/src/search/core/orchestrator.ts"
click node_hybrid_router "https://github.com/knockoutez/wigolo/blob/main/src/search/hybrid/router.ts"
click node_search_engines "https://github.com/knockoutez/wigolo/tree/main/src/search/engines"
click node_reranking "https://github.com/knockoutez/wigolo/blob/main/src/search/rerank.ts"
click node_fetch_router "https://github.com/knockoutez/wigolo/blob/main/src/fetch/router.ts"
click node_crawler "https://github.com/knockoutez/wigolo/blob/main/src/crawl/crawler.ts"
click node_extraction "https://github.com/knockoutez/wigolo/blob/main/src/extraction/pipeline.ts"
click node_local_store "https://github.com/knockoutez/wigolo/blob/main/src/cache/db.ts"
click node_vector_store "https://github.com/knockoutez/wigolo/blob/main/src/cache/sqlite-vec-store.ts"
click node_embeddings "https://github.com/knockoutez/wigolo/blob/main/src/embedding/embed.ts"
click node_similarity "https://github.com/knockoutez/wigolo/blob/main/src/search/find-similar.ts"
click node_research "https://github.com/knockoutez/wigolo/blob/main/src/research/pipeline.ts"
click node_autonomous_agent "https://github.com/knockoutez/wigolo/blob/main/src/agent/pipeline.ts"
click node_llm_providers "https://github.com/knockoutez/wigolo/blob/main/src/integrations/cloud/llm/select.ts"
click node_key_store "https://github.com/knockoutez/wigolo/blob/main/src/security/key-store.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mcp_server,node_cli,node_daemon,node_rest_router,node_repl toneBlue
class node_tool_schemas,node_tool_handlers toneAmber
class node_search_orchestrator,node_hybrid_router,node_search_engines,node_reranking,node_fetch_router,node_crawler,node_extraction toneMint
class node_local_store,node_vector_store,node_embeddings,node_similarity toneRose
class node_research,node_autonomous_agent,node_llm_providers,node_key_store toneIndigo
```

## Components

### Runtime surfaces

- [MCP server](https://github.com/knockoutez/wigolo/blob/main/src/index.ts): Node.js entry point · Default stdio server for agent tools. · `src/index.ts`
- [CLI](https://github.com/knockoutez/wigolo/blob/main/src/cli/index.ts): command surface · `src/cli/index.ts`
- [HTTP daemon](https://github.com/knockoutez/wigolo/blob/main/src/daemon/http-server.ts): transport boundary · Owns binding, auth, limits, proxying, and target safety. · `src/daemon/http-server.ts`
- [REST and remote MCP](https://github.com/knockoutez/wigolo/blob/main/src/daemon/rest/router.ts): HTTP router · Serves REST tools, OpenAPI, and MCP/SSE. · `src/daemon/rest/router.ts`
- [REPL](https://github.com/knockoutez/wigolo/blob/main/src/repl/shell.ts): interactive surface · Shell and NDJSON workflows. · `src/repl/shell.ts`

### Core orchestration

- [Tool contracts](https://github.com/knockoutez/wigolo/blob/main/src/server/tool-schemas.ts): MCP schemas · Registers agent-oriented tool schemas and result contracts. · `src/server/tool-schemas.ts`
- [Tool handlers](https://github.com/knockoutez/wigolo/blob/main/src/tools/search.ts): orchestration boundary · Shared dispatch layer across all transports. · `src/tools/search.ts`

### Retrieval and acquisition

- [Search orchestration](https://github.com/knockoutez/wigolo/blob/main/src/search/core/orchestrator.ts): retrieval pipeline · Fans out, canonicalizes, filters, deduplicates, fuses, and produces cited results. · `src/search/core/orchestrator.ts`
- [Hybrid search routing](https://github.com/knockoutez/wigolo/blob/main/src/search/hybrid/router.ts): search router · Optionally selects SearXNG or hybrid search paths. · `src/search/hybrid/router.ts`
- [Search engines and plugins](https://github.com/knockoutez/wigolo/tree/main/src/search/engines): provider extension · Public-engine adapters and plugin-defined engines. · `src/search/engines`
- [Reranking](https://github.com/knockoutez/wigolo/blob/main/src/search/rerank.ts): ranking stage · `src/search/rerank.ts`
- [Fetch router](https://github.com/knockoutez/wigolo/blob/main/src/fetch/router.ts): web acquisition · Escalates among HTTP, hardened TLS, and browser acquisition. · `src/fetch/router.ts`
- [Crawler](https://github.com/knockoutez/wigolo/blob/main/src/crawl/crawler.ts): crawl pipeline · Traverses with sitemap, robots, rate limiting, deduplication, and optional indexing. · `src/crawl/crawler.ts`
- [Extraction pipeline](https://github.com/knockoutez/wigolo/blob/main/src/extraction/pipeline.ts): content transformation · Converts HTML/PDF into Markdown, metadata, structured and schema-constrained records. · `src/extraction/pipeline.ts`

### Local intelligence

- [SQLite local store](https://github.com/knockoutez/wigolo/blob/main/src/cache/db.ts): persistent state · Caches content and queries; stores routing knowledge, ETags, diff/watch, and vectors. · `src/cache/db.ts`
- [Vector store](https://github.com/knockoutez/wigolo/blob/main/src/cache/sqlite-vec-store.ts): sqlite-vec index · `src/cache/sqlite-vec-store.ts`
- [Local embeddings](https://github.com/knockoutez/wigolo/blob/main/src/embedding/embed.ts): on-device ML · Lazy-loaded embeddings, reranking, and background indexing. · `src/embedding/embed.ts`
- [Find similar](https://github.com/knockoutez/wigolo/blob/main/src/search/find-similar.ts): semantic retrieval · Combines vector, lexical, crawl, and live-web signals. · `src/search/find-similar.ts`

### Agent workflows

- [Research pipeline](https://github.com/knockoutez/wigolo/blob/main/src/research/pipeline.ts): agent workflow · Decomposes questions, validates citations, and renders briefs or reports. · `src/research/pipeline.ts`
- [Autonomous gatherer](https://github.com/knockoutez/wigolo/blob/main/src/agent/pipeline.ts): agent workflow · Runs a bounded plan, execute, rank, and log loop. · `src/agent/pipeline.ts`
- [Optional LLM providers](https://github.com/knockoutez/wigolo/blob/main/src/integrations/cloud/llm/select.ts): provider selector · Isolated adapters for cloud, Ollama, and compatible backends. · `src/integrations/cloud/llm/select.ts`
- [Secret store](https://github.com/knockoutez/wigolo/blob/main/src/security/key-store.ts): security boundary · Key-store and keychain abstractions for provider credentials. · `src/security/key-store.ts`

## Connections

- MCP server → Tool contracts: registers
- Tool contracts → Tool handlers: invokes
- CLI → Tool handlers: uses
- REPL → Tool handlers: uses
- HTTP daemon → REST and remote MCP: hosts
- REST and remote MCP → Tool handlers: dispatches
- Tool handlers → Search orchestration: search
- Tool handlers → Fetch router: fetch
- Tool handlers → Research pipeline: research
- Search orchestration → Hybrid search routing: routes queries
- Hybrid search routing → Search engines and plugins: selects
- Search orchestration → Reranking: ranks results
- Fetch router → Extraction pipeline: supplies content
- Crawler → Fetch router: acquires pages
- Crawler → Vector store: indexes optionally
- Extraction pipeline → SQLite local store: caches content
- SQLite local store → Vector store: stores vectors
- Local embeddings → Vector store: indexes
- Find similar → Vector store: queries
- Research pipeline → Search orchestration: retrieves evidence
- Research pipeline → Fetch router: reads sources
- Research pipeline → Optional LLM providers: optionally synthesizes
- Autonomous gatherer → Research pipeline: uses retrieval loop
- Optional LLM providers → Secret store: loads credentials
