#!/bin/sh
set -eu
payload=$(cat)
# This demo intentionally avoids jq so the stock Docker image can run it.
# Extract the input text for a very small, deterministic protocol example.
text=$(printf '%s' "$payload" | sed -n 's/.*"text"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p')
chars=$(printf '%s' "$text" | wc -c | tr -d ' ')
words=$(printf '%s' "$text" | awk '{print NF}')
printf '{"protocol":"jarvis.skill.v1","success":true,"data":{"characters":%s,"words":%s},"message":"Text analysiert: %s Wörter, %s Zeichen."}\n' "$chars" "$words" "$words" "$chars"
