How demigodmode/pi-web-agent works
pi-web-agent is a Pi extension for bounded web research, centered on the web_explore tool: a user asks a question or supplies a URL, research orchestration discovers and fetches sources, evaluates evidence, then returns a bounded answer with caveats. The architecture also exposes standalone search and fetch tools, configurable providers and fallback, specialized content readers, guarded network access, and configurable presentation. Connections reflect excerpted calls, indexed imports, or README-documented capabilities; several provider and reader implementations were not sampled, so their internal dispatch details are not expanded.
Main entry points: web-explore.ts Web explore · factory.ts Backend factory · fetch Fetch backends · research-orchestrator.ts Research orchestrator
Components 22
Pi entrypoints
- Extension setup
src/extension.ts - Web explore
src/tools/web-explore.ts - Web search
src/tools/web-search.ts
Research workflow
- Research API
src/orchestration/index.ts - Research orchestrator
src/orchestration/research-orchestrator.ts - Research worker
src/orchestration/research-worker.ts - Evidence quality
src/orchestration/evidence-quality.ts - Answer synthesis
src/orchestration/answer-synthesizer.ts
Search and backends
- Backend factory
src/backends/factory.ts - Search providers
src/search - Search fanout
src/search/fanout.ts - Fallback policy
src/backends/fallback-policy.ts
Fetch and content
- Fetch backends
src/fetch - Content readers
src/readers - Content extraction
src/extract/readability.ts - Section selection
src/extract/section-selector.ts
Safety and settings
- Network guard
src/fetch/network-guard.ts - Guard proxy
src/fetch/guard-proxy.ts - Backend settings
src/backends/config.ts - Result presentation
src/presentation/explore-presentation.ts - Settings command
src/commands/web-agent-config.ts
Other components
- Pi user
Connections 28
- Pi user → Web explore: asks research
- Extension setup → Web explore: registers tool
src/extension.ts - Web explore → Research API: starts research
src/tools/web-explore.ts - Web explore → Answer synthesis: synthesizes answer
src/tools/web-explore.ts - Web explore → Evidence quality: checks evidence
src/tools/web-explore.ts - Web explore → Result presentation: formats result
src/tools/web-explore.ts - Research API → Research orchestrator: runs research
src/orchestration/index.ts - Research API → Backend factory: builds backends
src/orchestration/index.ts - Research orchestrator → Research worker: coordinates passes
- Research orchestrator → Evidence quality: assesses evidence
src/orchestration/research-orchestrator.ts - Research orchestrator → Section selection: selects excerpts
src/orchestration/research-orchestrator.ts - Research worker → Section selection: selects excerpts
src/orchestration/research-worker.ts - Backend factory → Search providers: builds providers
src/backends/factory.ts - Backend factory → Fetch backends: builds fetchers
src/backends/factory.ts - Backend factory → Network guard: configures guard
src/backends/factory.ts - Backend factory → Search fanout: configures fanout
src/backends/factory.ts - Web search → Search providers: queries DuckDuckGo
src/tools/web-search.ts - Web search → Result presentation: formats results
src/tools/web-search.ts - Search providers → Fallback policy: uses fallback
src/search/fanout.ts - Search fanout → Fallback policy: applies policy
src/search/fanout.ts - Fetch backends → Content readers: reads source formats
- Fetch backends → Network guard: checks destinations
src/fetch/guard-proxy.ts - Fetch backends → Guard proxy: uses guarded proxy
src/fetch/headless-fetch.ts - Fetch backends → Content extraction: extracts page text
src/fetch/headless-fetch.ts - Content extraction → Section selection: narrows content
src/extract/readability.ts - Extension setup → Settings command: registers settings
src/extension.ts - Settings command → Backend settings: reads settings
src/commands/web-agent-config.ts - Backend settings → Network guard: sets allow ranges
src/backends/config.ts