picoclaw/pkg/tools
yinwm 0ac93d4429 feat: US-014 - Add WebTool tests
Added comprehensive test coverage for WebTool (WebSearchTool, WebFetchTool) with 9 test cases:
- TestWebTool_WebFetch_Success: Verifies successful URL fetching
- TestWebTool_WebFetch_JSON: Verifies JSON content handling
- TestWebTool_WebFetch_InvalidURL: Verifies error handling for invalid URLs
- TestWebTool_WebFetch_UnsupportedScheme: Verifies only http/https allowed
- TestWebTool_WebFetch_MissingURL: Verifies missing URL parameter handling
- TestWebTool_WebFetch_Truncation: Verifies content truncation at maxChars
- TestWebTool_WebSearch_NoApiKey: Verifies API key requirement
- TestWebTool_WebSearch_MissingQuery: Verifies missing query parameter
- TestWebTool_WebFetch_HTMLExtraction: Verifies HTML tag removal and text extraction
- TestWebTool_WebFetch_MissingDomain: Verifies domain validation

WebTool implementation already conforms to ToolResult specification:
- WebFetch returns ForUser=fetched content, ForLLM=summary with byte count
- WebSearch returns ForUser=search results, ForLLM=result count
- Errors return ErrorResult with IsError=true

Tests use httptest.NewServer for mock HTTP servers, avoiding external API dependencies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:54:44 +08:00
..
base.go feat: US-006 - Add AsyncCallback type and AsyncTool interface 2026-02-12 19:35:41 +08:00
cron.go feat: US-002 - Modify Tool interface to return *ToolResult 2026-02-12 19:28:56 +08:00
cron.go.bak2 feat: US-002 - Modify Tool interface to return *ToolResult 2026-02-12 19:28:56 +08:00
cron.go.broken feat: US-002 - Modify Tool interface to return *ToolResult 2026-02-12 19:28:56 +08:00
edit.go feat: US-002 - Modify Tool interface to return *ToolResult 2026-02-12 19:28:56 +08:00
filesystem.go feat: US-002 - Modify Tool interface to return *ToolResult 2026-02-12 19:28:56 +08:00
filesystem_test.go feat: US-013 - Add FilesystemTool tests 2026-02-12 19:53:00 +08:00
message.go feat: US-002 - Modify Tool interface to return *ToolResult 2026-02-12 19:28:56 +08:00
message_test.go feat: US-011 - Add MessageTool tests 2026-02-12 19:50:53 +08:00
registry.go feat: US-008 - Inject callback into async tools in AgentLoop 2026-02-12 19:42:24 +08:00
result.go feat: US-002 - Modify Tool interface to return *ToolResult 2026-02-12 19:28:56 +08:00
result_test.go feat: US-002 - Modify Tool interface to return *ToolResult 2026-02-12 19:28:56 +08:00
shell.go feat: US-002 - Modify Tool interface to return *ToolResult 2026-02-12 19:28:56 +08:00
shell_test.go feat: US-012 - Add ShellTool tests 2026-02-12 19:52:16 +08:00
spawn.go feat: US-002 - Modify Tool interface to return *ToolResult 2026-02-12 19:28:56 +08:00
subagent.go Add memory system, debug mode, and tools 2026-02-11 00:14:23 +08:00
types.go * First commit 2026-02-09 19:20:19 +08:00
web.go feat: US-002 - Modify Tool interface to return *ToolResult 2026-02-12 19:28:56 +08:00
web_test.go feat: US-014 - Add WebTool tests 2026-02-12 19:54:44 +08:00