Created
January 21, 2026 18:51
-
-
Save adrianbrowning/b8bd51f44cba22d5c81e09b6c1b38bcf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| in_thinking=false | |
| while read -r line; do | |
| thinking=$(echo "$line" | jq -r '.message.content[]? | select(.type == "thinking") | .thinking // empty' 2>/dev/null) | |
| text=$(echo "$line" | jq -rj '.message.content[]? | select(.type == "text") | .text // empty' 2>/dev/null) | |
| if [ -n "$thinking" ]; then | |
| if [ "$in_thinking" = false ]; then | |
| printf '\r\n───────────────\r\n💭 ' | |
| in_thinking=true | |
| fi | |
| printf '%s' "${thinking//$'\n'/$'\r\n'}" | |
| fi | |
| if [ -n "$text" ]; then | |
| if [ "$in_thinking" = true ]; then | |
| printf '\r\n───────────────\r\n' | |
| in_thinking=false | |
| fi | |
| printf '%s' "$text" | |
| fi | |
| done < <(docker sandbox run claude -p "Hello World, wait 5 seconds then reply" --output-format stream-json --verbose ) | |
| # Handle response ending in thinking | |
| if [ "$in_thinking" = true ]; then | |
| printf '\r\n───────────────\r\n' | |
| fi | |
| echo # final newline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment