Skip to content

Syclus123/agent_web_compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

agent-web-compiler

Compile the Human Web into the Agent Web. Search it. Prove it. Act on it. Publish it.

Turn webpages, PDFs, and documents into agent-native objects β€” then index, search, answer with verifiable citations, synthesize callable APIs from UI actions, and help websites publish agent-friendly content.

                        agent-web-compiler

  Compile ──► Index ──► Search ──► Prove ──► Act ──► Publish
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚8-stage β”‚ β”‚BM25 + β”‚ β”‚Query   β”‚ β”‚Block  β”‚ β”‚Stateβ”‚ β”‚llms.txtβ”‚
  β”‚pipelineβ”‚ β”‚dense  β”‚ β”‚planningβ”‚ β”‚level  β”‚ β”‚graphβ”‚ β”‚agent   β”‚
  β”‚14 blockβ”‚ β”‚hybrid β”‚ β”‚Groundedβ”‚ β”‚cites +β”‚ β”‚API  β”‚ β”‚content β”‚
  β”‚8 actionβ”‚ β”‚4-levelβ”‚ β”‚answers β”‚ β”‚traces β”‚ β”‚synthβ”‚ β”‚actions β”‚
  β”‚types   β”‚ β”‚index  β”‚ β”‚Exec    β”‚ β”‚snaps  β”‚ β”‚exec β”‚ β”‚sitemap β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚plans   β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜

1,279 tests Β· 77 modules Β· 40K LOC Β· Across 15 webpages: 27% fewer tokens, 377 actions discovered, block-level citations β€” no LLM needed.

Quick Start

pip install agent-web-compiler

Search with grounded answers

from agent_web_compiler import AgentSearch

search = AgentSearch()
search.ingest_url("https://docs.example.com/api")

answer = search.answer("What authentication methods are supported?")
print(answer.to_markdown())
#   **Answer**: Bearer token and OAuth 2.0. [1][2]
#   [1] "Include your API key in the Authorization header..."
#   [2] "OAuth 2.0 flow requires client_id and client_secret..."

Verifiable provenance

from agent_web_compiler import ProvenanceEngine

provenance = ProvenanceEngine()
result = provenance.answer_with_provenance(search, "What is the rate limit?")
# β†’ answer + citations (block + DOM + bbox) + evidence + decision trace + snapshots

Action graph & API synthesis

from agent_web_compiler.actiongraph import ActionGraphBuilder, APISynthesizer, HybridExecutor

doc = search.ingest_url("https://example.com/products")
graph = ActionGraphBuilder().build_from_document(doc)      # page state machine
apis = APISynthesizer().synthesize_from_document(doc)      # pseudo-API candidates
decisions = HybridExecutor().decide_all(doc, apis)         # API-first, browser-fallback

Site memory

from agent_web_compiler import SiteMemory

memory = SiteMemory()
memory.observe(doc1); memory.observe(doc2); memory.observe(doc3)
insight = memory.get_insight("example.com")
# β†’ templates, noise selectors, entry points, common actions, nav patterns

Publish for agents

from agent_web_compiler import SitePublisher

publisher = SitePublisher(site_name="My Docs", site_url="https://docs.example.com")
publisher.crawl_site("https://docs.example.com/", max_pages=50)
publisher.generate_all("output/")
# β†’ llms.txt, agent.json, content.json, actions.json, agent-sitemap.xml, agent-feed.json

Drive a real browser with browser-harness (new)

AWC ships a bridge to browser-harness β€” a minimal CDP helper that attaches to the user's already-running Chrome. This unlocks three things the default pipeline can't do alone:

  1. Fetch pages from your logged-in session β€” SaaS, LinkedIn, Gmail all Just Work; no stale-cookie dance.
  2. Close the loop from compile β†’ plan β†’ act β€” LiveRuntime turns a URL + a natural-language task into real clicks, with every step producing an Evidence record.
  3. Auto-generate BH domain-skills β€” compile a site once, emit a PR-ready agent-workspace/domain-skills/<site>/<task>.md.
pip install "agent-web-compiler[harness]"
# and follow the BH setup prompt:
#   https://github.com/browser-use/browser-harness#setup-prompt
# Fetch using your real Chrome
from agent_web_compiler import compile_url
doc = compile_url("https://app.linkedin.com/in/me", fetcher="browser_harness")

# Compile β†’ plan β†’ act, all in one shot
from agent_web_compiler import LiveRuntime
rt = LiveRuntime.from_url("https://github.com/browser-use/browser-harness")
outcome = rt.run("star the repository", max_actions=1)
#   β†’ outcome.evidence is an Evidence record with screenshot + transition

# Contribute a BH skill back upstream
from agent_web_compiler import DomainSkillPublisher
skill = DomainSkillPublisher().generate_from_document(doc, task="scraping")
skill.write_to_repo("~/code/browser-harness")
# β†’ agent-workspace/domain-skills/linkedin/scraping.md, ready for a PR
# CLI equivalents
awc compile https://app.linkedin.com/in/me --fetcher browser_harness
awc live "reply to Alice" --on https://app.linkedin.com/messaging
awc publish bh-skill https://docs.stripe.com/api --out ~/code/browser-harness

See docs/integration-with-browser-harness.md for the full design doc and docs/fetchers/browser-harness.md for the fetcher reference.

Compile only

from agent_web_compiler import compile_url
doc = compile_url("https://example.com")

Custom pipeline

from agent_web_compiler import PipelineBuilder
pipeline = PipelineBuilder().skip_actions().skip_salience().build()
doc = pipeline.compile(html)  # 0.45ms β€” 93x faster

CLI

# Compile
awc compile https://example.com -o output/

# Index + Search
awc index crawl https://docs.example.com/ --max-pages 50
awc search "rate limit" && awc answer "How to auth?" && awc plan "download PDF"

# Provenance
awc provenance cite "What is the refund policy?"

# Publish
awc publish site https://docs.example.com/ -o output/

# Memory
awc memory show example.com

# Interactive
awc interactive

# Serve
awc serve --transport mcp     # 10 MCP tools
awc serve --transport rest    # 7 REST endpoints

Seven Capabilities

1. Compile

14 block types Β· 8 action types Β· provenance Β· entities Β· nav graph Β· 17 extension points via PipelineBuilder Β· HTML/PDF/DOCX/JSON/Playwright

2. Index & Search

BM25 + dense hybrid Β· pluggable embeddings (TF-IDF built-in, OpenAI optional) Β· 4-level indexing Β· query planning (fact/evidence/navigation/task) Β· grounded answering Β· execution planning Β· site crawling

3. Prove

Evidence objects (block/action/DOM/bbox/screenshot) · citations with answer-span alignment · page snapshots (version-bound) · decision traces (query→retrieve→rerank→answer) · reproducibility

4. Act β€” Action Graph & API Synthesis ← NEW

Page state machine — model pages as states with typed transitions (navigate/expand/filter/submit/download) API candidate synthesis — find machine-callable endpoints behind UI actions (search forms→GET API, pagination→parameterized URLs) Hybrid execution — API-first when safe and confident, browser-fallback otherwise Risk assessment — read_only/write/auth_required safety levels

5. Remember β€” Site Memory ← NEW

Cross-page learning β€” templates, noise selectors, entry points, hub pages, action habits Navigation patterns β€” frequently-traversed URL sequences Persistent β€” save/load site insights across sessions Improves over time β€” 3+ pages triggers pattern detection

6. Publish

llms.txt Β· agent.json Β· content.json Β· actions.json Β· agent-sitemap.xml Β· agent-feed.json (delta) Β· auto-generated from existing content

7. Integrate

OpenAI CUA Β· Claude Computer Use Β· Browser Use Β· LangChain Β· 5 LLM formatters Β· MCP (10 tools) Β· REST (7 endpoints) Β· REPL Β· browser middleware

Framework Integration

from agent_web_compiler.adapters.openai_adapter import OpenAIAdapter     # CUA
from agent_web_compiler.adapters.anthropic_adapter import AnthropicAdapter # Claude
from agent_web_compiler.middleware.browser_middleware import BrowserMiddleware
from agent_web_compiler.exporters.llm_formatters import format_for_llm    # 5 formats

MCP: compile_url compile_html compile_file get_blocks get_actions get_markdown ingest_url search answer plan

Comparison

Capability Raw HTML MD Scraper agent-web-compiler
Tokens Baseline -27% -27% + structured
Semantic blocks βœ— βœ— 14 types
Actions 0 0 377 across 15 pages
Grounded answers βœ— βœ— Block-level citations
Evidence chain βœ— βœ— DOM + bbox + snapshot + trace
API synthesis βœ— βœ— Pseudo-API from UI actions
Site memory βœ— βœ— Cross-page pattern learning
Publish for agents βœ— βœ— 6 standardized files

Architecture

24 packages Β· 78+ modules:

agent_web_compiler/
β”œβ”€β”€ core/           Schemas, interfaces, errors (7)
β”œβ”€β”€ pipeline/       Compilers + cache + extensible builder (8)
β”œβ”€β”€ sources/        HTTP, Playwright, browser-harness, file reader, crawler (5)
β”œβ”€β”€ normalizers/    Boilerplate removal, site profiles (2)
β”œβ”€β”€ segmenters/     Blocking, salience, query filter (3)
β”œβ”€β”€ extractors/     Actions, entities, assets, nav graph (4)
β”œβ”€β”€ aligners/       DOM + screenshot provenance (2)
β”œβ”€β”€ exporters/      JSON, markdown, token budget, LLM formatters (5)
β”œβ”€β”€ index/          BM25 + dense engine, embeddings (4)
β”œβ”€β”€ search/         Planner, retriever, answerer, runtime, SDK (5)
β”œβ”€β”€ provenance/     Evidence, citations, snapshots, traces, engine (5)
β”œβ”€β”€ actiongraph/    State machine, API synthesis, hybrid executor (4)
β”œβ”€β”€ memory/         Site-level learning across visits (1)
β”œβ”€β”€ publisher/      llms.txt, agent/content/actions.json, sitemap, feed,
β”‚                   bh-skill markdown (7)
β”œβ”€β”€ runtime/        Live execution backends (optional extras)
β”‚   └── browser_harness/   LiveActionExecutor, LiveRuntime, evidence_adapter
β”œβ”€β”€ adapters/       OpenAI, Anthropic, Browser Use, LangChain (4)
β”œβ”€β”€ middleware/     Browser agent middleware (1)
β”œβ”€β”€ plugins/        Registry + protocols (2)
β”œβ”€β”€ standards/      agent.json spec (1)
β”œβ”€β”€ serving/        MCP server, REST API (2)
β”œβ”€β”€ cli/            CLI + REPL (2)
└── utils/          Text, DOM, doc diff (3)

Installation

pip install agent-web-compiler                 # Core
pip install "agent-web-compiler[pdf]"          # + PDF
pip install "agent-web-compiler[browser]"      # + Playwright (isolated Chromium)
pip install "agent-web-compiler[harness]"      # + browser-harness (your real Chrome)
pip install "agent-web-compiler[serve]"        # + MCP + REST
pip install "agent-web-compiler[all]"          # Everything

Python 3.9+ Β· From source: pip install -e ".[dev]" && pytest (1,279 tests, ~4s, offline)

Documentation

Architecture Β· Schema Β· Provenance Β· Publisher Β· Contributing Β· Roadmap Β· Changelog

License

MIT

Related Projects

Project AWC adds / integration
Firecrawl Search, provenance, API synthesis, publish
Jina Reader Typed blocks, action graph, evidence chains
Docling Web + search + provenance + publish in one stack
Browser Use Pre-compiled affordances, API-first execution, site memory
browser-harness First-class bridge: fetch via real Chrome, LiveRuntime execution, auto-generated domain-skills
llms.txt Full agent manifest + actions + delta feeds

agent-web-compiler β€” compile β†’ index β†’ search β†’ prove β†’ act β†’ publish β€” for the Agent Web.

About

🌐 Compile the Human Web into the Agent Web.

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages