#!/usr/bin/env bash # tests/fixtures/phase-lib/progress.sh -- the fixture's stand-in for progress.mjs. # # Same job and same contract: read the child's JSON stream on stdin, write the final # assistant text to $1, exit non-zero when the stream produced no report. set -uo pipefail out="$1"; shift text="" while IFS= read -r line; do case "$line" in *'"type": "message_end"'* | *'"type":"message_end"'*) t="$(printf '%s' "$line" | sed -n 's/.*"text": *"\([^"]*\)".*/\1/p')" [[ -n "$t" ]] && text="$t" ;; esac done if [[ -z "$text" ]]; then printf '(no final assistant message)\n' > "$out" exit 1 fi printf '%s\n' "$text" > "$out"