tool-compat-shared
Generated from plugins/tool-compat-shared/README.md.
Internal helper package for the vendor-style tool bundles.
This package is intentionally not a public plugin package and does not expose
agent_plugin.json entries. It exists only to share filesystem, decoding,
truncation, formatting, write, literal-replacement, and web search logic across
gemini-tools, qwen-tools, kimi-tools, and grok-tools.
Engine vs Shape Principle
This package follows the Engine vs Shape separation:
- Engine (this package): HTTP calls, API clients, data extraction, protocol definitions, data models
- Shape (vendor plugins): Tool name, parameters, descriptions, result formatting, error messages
The web_search_engine module returns structured data (SearchResponse, SearchResult) only.
It does NOT format results for LLM consumption. All formatting — citation markers, source footers,
truncation banners, result numbering — belongs in vendor tool plugins.
Note: The existing
reader_engine.pyandsearch_engine.pymodules export vendor-specific formatting functions (e.g.,format_gemini_*,format_qwen_*). These are precedent violations of the Engine vs Shape principle. New modules should not follow this pattern.
Modules
reader_engine.py
File reading, encoding detection, BOM handling, path resolution, and line truncation.
editor_engine.py
Literal text replacement, multi-edit application, and file writing.
search_engine.py
Filesystem search: directory listing, glob search, grep search. Includes vendor-specific formatting functions (precedent violations — see note above).
shell_engine.py
Shell command execution, background process support, output truncation.
web_search_engine.py
Web search infrastructure: data models, provider protocol, and reusable search provider implementations (Tavily, Gemini API).
Data Models
SearchResult— Frozen dataclass with fields:title,url,snippet,content,date,site_name,score. All optional fields have defaults.SearchResponse— Frozen dataclass wrappingList[SearchResult]plus optionalanswer(AI-generated, from Tavily or Gemini API),query,grounding_chunks, andgrounding_supports(Gemini API citation metadata for vendor-side formatting).
Provider Protocol
SearchProvider—Protocolwithname(str),is_available()(bool),async search(query, *, limit) -> SearchResponse.
Provider Implementations
TavilyProvider— POST toapi.tavily.com/search. Config:api_key,search_depth(default:"advanced"),include_answer(default:True).GeminiApiProvider— Usesgoogle-genaiSDK withweb-searchmodel alias for server-side Google Search grounding. Config:api_key,model(default:"web-search"). Returnsanswer(response text),results(from grounding chunks), and rawgrounding_chunks/grounding_supportsfor vendor-side citation formatting. Requiresgoogle-genai>=0.3.0(optional dependency:pip install tool-compat-shared[gemini]).
Error Handling
SearchProviderError— Exception withprovider_nameandoriginal_error. Message format:[ProviderName] message.
Dependencies
aiohttp>=3.8.0— For async HTTP inweb_search_engine.py(lazy-imported)google-genai>=0.3.0— Optional, forGeminiApiProvider(install with[gemini]extra)
License
Copyright 2026 Dynamic Programming Solutions Kft.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.