#!/bin/bash # Mock LLM engine for testing # This script simulates an LLM engine subprocess that responds to the three commands: # , ..., and ... # Function to read XML input until a complete closing tag is found read_xml_input() { local input="" local line local char_count=0 # Read until we get a complete XML command while IFS= read -r line; do input="${input}${line}" char_count=$((char_count + ${#line})) # Debug the actual content (first 30 chars) if [[ "$input" == *""* ]]; then printf "1024" printf "\\004" # EOT character (hex 04) return fi if [[ "$input" == *""*""* ]]; then printf "405" printf "\\004" # EOT character (hex 04) return fi if [[ "$input" == *""*""* ]]; then generate_response return fi done } # Function to generate a response token by token generate_response() { printf "<" sleep 0.3 printf "reason" sleep 0.3 printf "ing" sleep 0.3 printf ">" sleep 0.3 printf "This" sleep 0.3 printf " is" sleep 0.3 printf " a" sleep 0.3 printf " test" sleep 0.3 printf " response." sleep 0.3 printf "" sleep 0.3 printf "\\004" } # Main loop - keep reading input and responding iteration=0 while true; do iteration=$((iteration + 1)) read_xml_input done