feat: add optional you.com search provider for web_search - #55
Open
mouse-value-add wants to merge 1 commit into
Open
mouse-value-add wants to merge 1 commit into
mouse-value-add wants to merge 1 commit into
Conversation
Add a 'youcom' engine to the existing SearchProvider fallback chain in src/utils/web.ts. It is only tried first when YDC_API_KEY is set; DuckDuckGo Lite and Sogou remain the defaults, and requests fall back to them on failure, so default behavior is unchanged. - opt-in via YDC_API_KEY (whitespace-only treated as unset) - no new dependencies (global fetch, X-API-Key header) - JSON response parsed into the existing SearchResult shape - docs in USAGE.md; tests in test/web-search-provider.test.ts
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.
What this adds
An optional You.com engine for the built-in
web_searchtool.src/utils/web.tsalready has aSearchProviderfallback chain (duckduckgo-lite→sogou), so this adds a third provider that reuses the same loop, retry helper, andSearchResultshape:youcomis only tried first whenYDC_API_KEYis set in the environmentSo with no key configured, nothing changes for existing users.
Setup
That's it — no config file changes, no new dependencies (plain
fetchwith anX-API-Keyheader againsthttps://api.ydc-index.io/search), keeping with the lightweight principle in CONTRIBUTING.md.What changed
src/utils/web.ts: newyoucommember ofSearchProvider,getSearchProviders()builds the chain (youcom first only when the key is set), a JSON fetch branch, andparseYoucomResults()mappinghits[]to the existingSearchResulttypeUSAGE.md: short "Web search backends" subsection under Configuration documenting the chain and the opt-intest/web-search-provider.test.ts: new suite (node:test, same style as the rest oftest/) covering:Validation
npm run check(tsc --noEmit) — cleannpm run lint— cleannpm test— 278 passing, 0 failing (274 baseline + 4 new)YDC_API_KEY=*** npx tsx -e "import('./src/utils/web.js').then(m => m.searchDuckDuckGoLite({ query: 'mcp spec' })).then(r => console.log(r.base_resp.source, r.organic.length))"— expectedyoucom 5Happy to adjust the shape if you'd rather have the provider list configurable via
settings.jsoninstead of env-only, or drop the docs change.