Skip to content

feat: bind all tools to LLM with runtime options injection - #46

Merged
avoidwork merged 3 commits into
mainfrom
feat/bind-tools-to-llm
May 29, 2026
Merged

feat: bind all tools to LLM with runtime options injection#46
avoidwork merged 3 commits into
mainfrom
feat/bind-tools-to-llm

Conversation

@avoidwork

@avoidwork avoidwork commented May 29, 2026

Copy link
Copy Markdown
Owner

Description

Replaces the previous web search backends (Exa, Firecrawl, Tavily, Parallel) with a new set of free or low-cost search engines. This dramatically expands search capabilities without requiring paid API keys.

New built-in engines (priority order):

  1. Custom — User-provided URL with template variables ({{query}}, {{apiKey}}), optional request body/headers, configurable response parsing fields
  2. Bing — Requires BING_API_KEY environment variable (https://dev.bing.com)
  3. SearXNG — Requires SEARXNG_URL env var pointing to a self-hosted SearXNG instance
  4. DuckDuckGo — Always available, no key needed (HTML scrape fallback)

Environment variable configuration:

Variable Purpose Required For
CUSTOM_SEARCH_URL Custom search endpoint URL with {{query}} template Custom engine
CUSTOM_SEARCH_METHOD HTTP method (GET/POST, default POST) Custom engine body
CUSTOM_SEARCH_BODY JSON body with {{query}}/{{apiKey}} templates POST requests
CUSTOM_SEARCH_HEADERS JSON string of request headers Auth headers
CUSTOM_SEARCH_QUERY_KEY or CUSTOM_RESULT_KEY JSON field containing results array Custom engine
CUSTOM_TITLE_FIELD Field name for result title (default: title) Custom engine
CUSTOM_URL_FIELD Field name for result URL (default: url) Custom engine
CUSTOM_DESCRIPTION_FIELD Field name for result description (default: description) Custom engine
CUSTOM_API_KEY API key passed to URL/body headers Custom engine
BING_API_KEY Bing Search API subscription key Bing engine
SEARXNG_URL URL of self-hosted SearXNG instance (JSON API) SearXNG engine

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (no longer removes old tool APIs)

Testing

  • 732 tests pass (158 suites)
  • Rewrote tests/unit/tools_web.test.js to cover all new backends: Bing, SearXNG, Custom, DuckDuckGo
  • Removed outdated tests/unit/tools_web_full.test.js (309 tests for old engines)
  • Pre-commit hooks (oxlint, oxfmt, coverage) all pass

Coverage

  • 100% line coverage on tools/index.js
  • Full coverage on new search engine implementations

Checklist

  • npm run lint passes
  • Tests pass with 100% line coverage on changed files
  • No forbidden patterns used
  • Conventional Commit style applied

…y pattern

- Add factory function (createXxxTool) to every tool module that captures
  runtime options via closure before @tool decoration
- Refactor buildToolConfig to use TOOL_FACTORIES map, passing all runtime
  options: allowedPaths, maxReadSize, registry, conversationsDir, safety,
  timeout, memoryLimit
- Pass sandbox paths, safety config, and timeout from index.js to
  buildToolConfig
- Remove ALL_TOOLS backward-compatibility map and stub
  createToolWithRuntimeOptions
- 100% line coverage on tools/index.js, 751 tests passing
@avoidwork avoidwork self-assigned this May 29, 2026
avoidwork added 2 commits May 29, 2026 08:26
…Custom engines

- Removed Exa, Firecrawl, Tavily, and Parallel (DuckDuckGo HTML)
- Added DuckDuckGo (free, no key), Google (free, HTML scrape),
  Bing (BING_API_KEY), SearXNG (SEARXNG_URL), and Custom
- Custom engine supports: url, method, body, headers, result fields,
  api_key, queryKey, titleField, urlField, descriptionField
- Updated tests and coverage for new engines
@avoidwork
avoidwork merged commit 524328b into main May 29, 2026
@avoidwork
avoidwork deleted the feat/bind-tools-to-llm branch May 29, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant