Add support for Anthropic's server-side tool types (web_search) that are
used by Claude Code and other Anthropic API clients.
Changes:
- anthropic-types.ts: Add AnthropicServerTool, AnthropicServerToolUseBlock,
AnthropicServerToolResultBlock, AnthropicWebSearchToolResultBlock types
- non-stream-translation.ts: Filter server tools from OpenAI tool translation,
handle server_tool_use/result blocks in message conversion, export
hasWebSearchTool helper
- handler.ts: Add web search proxy logic — when Anthropic client requests
web_search server tool, detect search intent and perform proxy search
via gpt-4o, returning synthetic server_tool_use/web_search_tool_result
blocks
This fixes compatibility with Claude Code's WebSearch feature when using
copilot-api as the API backend. The proxy approach works in non-streaming
mode by delegating actual web search to a web-capable Copilot model.
Closes ericc-ch#241
Problem
When using copilot-api with Claude Code or other Anthropic API clients that enable web search, the server-side tool types (server_tool_use, server_tool_result, web_search_tool_result) are not recognized. This causes:
Solution
Type definitions (anthropic-types.ts)
Message translation (non-stream-translation.ts)
Web search proxy (handler.ts)
Limitations
Testing
Tested with Claude Code + copilot-api v0.7.0: