#!/bin/sh
# The only authorized operation in this example is reading the bundled fixture.
set -eu
cd -P "$(dirname "$0")"
request=$(./model --demo)
case "$request" in
  '{"tool":"read_file","path":"jobs/item76666.om"}') ;;
  *) printf 'Unrecognized model request: %s\n' "$request" >&2; exit 1 ;;
esac
printf 'Model requested %s\n' "$request"
source_text=$(cat jobs/item76666.om)
reply=$(printf '%s\n' 'Task: Fix the error in this file and confirm its goal.' \
  'File: jobs/item76666.om' \
  'Goal: calc starts with x and adds 4 exactly 3 times in a for loop. main calls calc with 70.' \
  'State: read' 'Source:' "$source_text" 'Tool result: Read succeeded.' 'Answer:' | ./model)
printf 'Model replied %s\n' "$reply"
test "$reply" = '{"tool":"omega_check","path":"jobs/item76666.om"}'
