feat(tools): add Defuddle extractor chain for web_fetch#296
Closed
feat(tools): add Defuddle extractor chain for web_fetch#296
Conversation
…action Integrate fetch.goclaw.sh Cloudflare Worker as primary content extractor using Defuddle library. Implements ContentExtractor interface with waterfall fallback: Defuddle CF Worker (10s timeout) → in-process htmlToMarkdown() converter. - Add ExtractorChain pattern with quality gate (min 100 chars, 10 words) - Add DefuddleExtractor calling GET https://fetch.goclaw.sh/<domain>/<path> - Add InProcessExtractor wrapping existing HTML→markdown converter - Add defuddle_enabled config toggle with runtime pub/sub reload - Add Switch toggle in Web UI settings (en/vi/zh i18n) - 23 new tests with race detector coverage
…attern Move extractor chain settings from config.json5 to builtin_tools DB table, aligning with the media_provider_chain pattern. Key changes: Backend: - Extract fetchRawContent() from doDirectFetch() for code reuse - Rewrite InProcessExtractor to delegate (93 → 28 lines), fixing missing domain policy checks on redirects (security fix) - Add ResolveExtractorChain() parsing settings from builtin_tools context - DefuddleExtractor now configurable via base_url + timeout from settings - Seed default chain [defuddle, html-to-markdown] for new deployments - Add backfillWebFetchSettings() for existing deployments - Remove defuddle_enabled from config struct, pub/sub, gateway_setup Frontend: - Add DnD extractor chain form on builtin tools page - Route web_fetch → dedicated form in settings dialog - Remove defuddle toggle from config page - Dedicated i18n keys (en/vi/zh), no cross-form coupling
viettranx
added a commit
that referenced
this pull request
Mar 20, 2026
Add Cloudflare Worker (fetch.goclaw.sh) as primary markdown extractor with waterfall fallback to built-in HTML→Markdown converter. Architecture: - ExtractorChain pattern with quality gate (min 100 chars, 10 words) - Settings stored in builtin_tools DB table (not config.json5) - ResolveExtractorChain reads chain from context per-request - InProcessExtractor delegates to fetchRawContent (full SSRF + domain policy checks on redirects) - DefuddleExtractor with configurable base_url + timeout - Seed default chain [defuddle, html-to-markdown] for new deployments - Backfill migration for existing deployments Web UI: - Dedicated DnD extractor chain form on builtin tools page - Drag-and-drop ordering, enable/disable per extractor - Timeout + base URL config for Defuddle - i18n support (en/vi/zh)
Contributor
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
web_fetchmarkdown extraction with waterfall fallbackfetch.goclaw.shextracts clean markdown (10s timeout)htmlToMarkdown()converter (existing, battle-tested)defuddle_enabledin config.json5 with runtime pub/sub reloadGoClaw Fetch Solution (Defuddle wrapper)
🤌 https://fetch.goclaw.sh/
Architecture
Changes
New files (4):
internal/tools/web_fetch_extractor.go— ContentExtractor interface, ExtractorChain, quality gateinternal/tools/web_fetch_extractor_defuddle.go— DefuddleExtractor (CF Worker client)internal/tools/web_fetch_extractor_inprocess.go— InProcessExtractor (wraps existing converter)internal/tools/web_fetch_extractor_test.go— 23 tests with race detector coverageModified files (8):
internal/tools/web_fetch.go— chain integration, doFetch refactorinternal/config/config_channels.go—DefuddleEnabled *boolfieldcmd/gateway_setup.go— wire config to WebFetchToolcmd/gateway.go— pub/sub handler for runtime toggleui/web/src/pages/config/sections/tools-web-section.tsx— Switch toggleui/web/src/i18n/locales/{en,vi,zh}/config.json— i18n keysTest plan
go build ./...— compile cleango vet ./...— no issuesgo test -race ./internal/tools/— 119 tests pass (23 new + 96 existing)web_fetch_convert_test.gofetch.goclaw.shreturns clean markdown (requires CF Worker deployed)