Tool Interface
Every tool in Weaver implements theTool interface:
Tool Result Types
Tools return structuredToolResult objects with different semantics:
- NewToolResult(forLLM) - Basic result sent to LLM
- SilentResult(forLLM) - Sent to LLM only, no user notification
- AsyncResult(forLLM) - Long-running background operation
- ErrorResult(message) - Error condition
- UserResult(content) - Sent to both LLM and user
Built-in Tools
File System Tools
read_file
Read file contents with workspace security. Parameters:path(string, required) - File path to read
write_file
Write content to a file, creating directories as needed. Parameters:path(string, required) - File pathcontent(string, required) - Content to write
edit_file
Edit files by replacing exact text matches. Parameters:path(string, required) - File pathold_text(string, required) - Exact text to findnew_text(string, required) - Replacement text
old_text appears multiple times or not at all.
append_file
Append content to the end of a file. Parameters:path(string, required) - File pathcontent(string, required) - Content to append
list_dir
List files and directories. Parameters:path(string, required) - Directory path
Shell Execution
exec
Execute shell commands with safety guards. Parameters:command(string, required) - Shell commandworking_dir(string, optional) - Working directory
- Blocks dangerous patterns (rm -rf, format, dd, etc.)
- 60-second timeout
- Optional workspace restriction
- Path traversal protection
Web Tools
web_search
Search the web using Brave API or DuckDuckGo. Parameters:query(string, required) - Search querycount(integer, optional) - Number of results (1-10)
- Brave Search - Requires API key, better results
- DuckDuckGo - No API key, HTML scraping fallback
web_fetch
Fetch and extract readable content from URLs. Parameters:url(string, required) - URL to fetchmaxChars(integer, optional) - Maximum characters (default: 50000)
- HTML to text extraction
- JSON formatting
- Automatic content type detection
- Truncation handling
Communication Tools
message
Send messages to users on chat channels. Parameters:content(string, required) - Message contentchannel(string, optional) - Target channelchat_id(string, optional) - Target chat ID
UI Control
canvas
Control the Nest UI interface for visual organization and node manipulation. Parameters:action(string, required) - Action to perform: “create_node”, “update_node”, “delete_node”, “clear”type(string) - Node type: “text”, “code”, “image”, “video”title(string) - Node titlecontent(string) - Node contentnode_id(string) - Target node ID (for update/delete)x,y(number) - Canvas positionwidth,height(number) - Node dimensions
- Creating visual knowledge graphs
- Organizing conversation artifacts
- Building interactive canvases
- Documenting complex workflows
Agent Orchestration
subagent
Execute tasks synchronously with an independent agent instance. Parameters:task(string, required) - Task descriptionlabel(string, optional) - Display label
- Delegating specific subtasks
- Isolating tool access
- Parallel task execution
spawn
Spawn background subagent tasks asynchronously. Parameters:task(string, required) - Task descriptionlabel(string, optional) - Display label
- Long-running operations
- Fire-and-forget tasks
- Background monitoring
Scheduling
cron
Schedule reminders, tasks, or commands. Actions:add- Create new scheduled joblist- List all jobsremove- Delete job by IDenable/disable- Toggle job
at_seconds- One-time reminder (seconds from now)every_seconds- Recurring intervalcron_expr- Cron expression (e.g., “0 9 * * *”)
message(string) - Reminder/task messagecommand(string, optional) - Shell command to executedeliver(boolean) - Direct delivery vs agent processing
Hardware Tools (Linux Only)
i2c
Interact with I2C bus devices for sensors and peripherals. Actions:detect- List available I2C busesscan- Find devices on a busread- Read bytes from devicewrite- Send bytes to device
bus(string) - Bus number (e.g., “1” for /dev/i2c-1)address(integer) - 7-bit device address (0x03-0x77)register(integer, optional) - Register addressdata(array, optional) - Bytes to writelength(integer, optional) - Bytes to readconfirm(boolean) - Required for write operations
spi
High-speed SPI bus communication. Actions:list- Find available SPI devicestransfer- Full-duplex send/receiveread- Receive bytes
device(string) - Device ID (e.g., “2.0” for /dev/spidev2.0)speed(integer) - Clock speed in Hz (default: 1MHz)mode(integer) - SPI mode 0-3bits(integer) - Bits per word (default: 8)data(array) - Bytes to sendlength(integer) - Bytes to readconfirm(boolean) - Required for transfers
Image Generation
generate_image
Generate images using Gemini 3 Pro Image. Parameters:prompt(string, required) - Image descriptionresolution(string) - “1K”, “2K”, or “4K”aspect_ratio(string) - “1:1”, “3:4”, “4:3”, “9:16”, “16:9”
Tool Registry
TheToolRegistry manages all available tools:
Registry Methods
Register(tool Tool)- Add tool to registryGet(name string)- Retrieve tool by nameExecute(ctx, name, args)- Execute toolExecuteWithContext(ctx, name, args, channel, chatID, callback)- Execute with session contextGetDefinitions()- Get all tool schemasToProviderDefs()- Convert to LLM provider formatList()- Get all tool namesCount()- Get tool countGetSummaries()- Human-readable tool list
Advanced Interfaces
ContextualTool
Tools can implementContextualTool to receive session context:
AsyncTool
Tools can implementAsyncTool for background operations:
Creating Custom Tools
Security & Safety
Workspace Restriction
Most file and exec tools support workspace restriction to prevent access outside project boundaries.Command Guards
The exec tool blocks dangerous patterns:rm -rf,del /fformat,mkfs,diskpartdd if=- Writes to disk devices
shutdown,reboot- Fork bombs
Path Validation
All file operations validate paths and resolve symlinks to prevent escapes.Write Confirmations
Hardware tools (I2C, SPI) requireconfirm: true for write operations.
Best Practices
- Use SilentResult for operations users don’t need to see
- Use AsyncResult for long-running tasks
- Validate inputs before execution
- Return detailed errors with actionable messages
- Set context for tools that need session information
- Implement timeouts for network/external operations
- Log execution for debugging and monitoring
Tool Execution Flow
- LLM decides to use a tool
- Registry validates tool exists
- Context is set (if ContextualTool)
- Callback is set (if AsyncTool)
- Tool executes with args
- Result is logged and returned
- LLM receives result in next turn
Performance Considerations
- Tools execute sequentially in the agent loop
- Use
spawnfor parallel operations - Set appropriate timeouts
- Truncate large outputs
- Cache expensive operations when possible