chat-parser: handle whitespace around JSON in tool call parsing
Models often output whitespace (newlines, spaces) between XML tags and
JSON content, e.g.:
<function=transfer_to_human>
{"reason": "..."}
</function>
This was causing parsing failures in Hermes 2 Pro and other formats
because try_consume_json() expected JSON to start immediately at the
current position.
Fix by modifying try_consume_json() to:
- Skip leading whitespace before attempting to parse JSON
- Consume trailing whitespace after successful JSON parse
- Restore position if JSON parsing fails (important for streaming)
This fix benefits all chat formats that use try_consume_json().
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>