Commit graph

9 commits

Author SHA1 Message Date
Mario Zechner
9e3e319f1a Add session export to HTML, improve tool error handling, and enhance RPC mode documentation 2025-11-12 21:55:10 +01:00
Mario Zechner
2f0f0a913e Add proper truncation notices and comprehensive tests for read tool
**Improved output messages:**
1. File fits within limits: Just outputs content (no notices)
2. Lines get truncated: Shows "Some lines were truncated to 2000 characters for display"
3. File doesn't fit limit: Shows "N more lines not shown. Use offset=X to continue reading"
4. Offset beyond file: Shows "Error: Offset X is beyond end of file (N lines total)"
5. Both truncations: Combines both notices with ". " separator

**Comprehensive test coverage:**
- Files within limits (no notices)
- Large files (line truncation)
- Long lines (character truncation)
- Offset parameter
- Limit parameter
- Offset + limit together
- Invalid offset (out of bounds)
- Combined truncations (both notices)

All 17 tests passing ✓
2025-11-12 17:13:03 +01:00
Mario Zechner
c7a73d4f81 Add line limits and truncation to read tool
- Default limit of 2000 lines per read
- Maximum line length of 2000 characters (truncates longer lines)
- Add optional offset and limit parameters for pagination
- Show truncation notice with instruction to continue reading
- Plain text output (no line numbers)

Examples:
- `read path/to/file` - reads first 2000 lines
- `read path/to/file offset=2001` - continues from line 2001
- `read path/to/file limit=100` - reads only 100 lines

This prevents extremely large files from overwhelming context.
2025-11-12 16:53:05 +01:00
Mario Zechner
f147109da7 Fix coding agent tools to return error content instead of throwing
Tools now resolve with error messages in content blocks rather than
rejecting the promise. This matches the expected behavior where tools
always return a result, with errors indicated in the text content.

- read: Return error content for missing files
- edit: Return error content for missing files, text not found, multiple matches
- bash: Return error content for command failures, timeouts, and aborts
- All tools now include required details field in error results
2025-11-12 10:52:12 +01:00
Mario Zechner
84dcab219b Add image support in tool results across all providers
Tool results now use content blocks and can include both text and images.
All providers (Anthropic, Google, OpenAI Completions, OpenAI Responses)
correctly pass images from tool results to LLMs.

- Update ToolResultMessage type to use content blocks
- Add placeholder text for image-only tool results in Google/Anthropic
- OpenAI providers send tool result + follow-up user message with images
- Fix Anthropic JSON parsing for empty tool arguments
- Add comprehensive tests for image-only and text+image tool results
- Update README with tool result content blocks API
2025-11-12 10:45:56 +01:00
Mario Zechner
594edec31b Make file operations properly abortable with async operations
Replace synchronous file operations with async Promise-based operations
that listen to abort signals during execution:
- read, write, edit now use fs/promises async APIs
- Add abort event listeners that reject immediately on abort
- Check abort status before and after each async operation
- Clean up event listeners properly

This ensures pressing Esc during file operations shows red error state.
2025-11-11 23:33:16 +01:00
Mario Zechner
e6b47799a4 Add abort signal handling to read, write, and edit tools
All tools now check the abort signal before executing and throw
"Operation aborted" error if the signal is already aborted.
This ensures consistent abort behavior across all tools.
2025-11-11 23:28:39 +01:00
Mario Zechner
159075cad7 Improve tool execution rendering and error handling
- Show tool execution components immediately when tool calls appear in streaming
- Update components with streaming arguments as they come in
- Handle incomplete/partial arguments gracefully with optional chaining
- Fix error handling: tools now throw exceptions instead of returning error messages
- Fix bash abort handling to properly reject on abort/timeout
- Clean up error display
2025-11-11 23:05:58 +01:00
Mario Zechner
ffc9be8867 Agent package + coding agent WIP, refactored web-ui prompts 2025-10-17 11:47:01 +02:00