Everything that was uncommitted in the shared tree, in one commit because the changes are interleaved across the same files (lcm, engine, frontend, locales). lcm: a continuation prompt is not the task. After /resume the newest user message is "Continue with the task ...", and pinning it kept the keystroke while the question it continues was cut away -- measured: a resumed session woke up with the prompt, one tool call and its error, and no task at all. The pin now skips the harness's own continuation prompts, so the real question is pinned again. test_compactor drives it: with the skip disabled the task is lost (red), with it the task comes back after the summary (green). engine: /self-check and the exact tool-argument parse are in a1794fb; this commit carries the tests for them (a failed tool observation must appear in the self-check prompt; mcp_parse_exact rejects two objects in one string) and the i18n keys the new code uses: cmd.script.*, main.no_profile, tg.busy, tg.interview.running, ui.agent_busy in all three catalogues. The rest is the in-flight work from the shared session: engine/frontend, plugins, telegram/a2a, and their tests. make check: all tests passed; check_i18n ok, 204 keys in 3 catalogues.
211 lines
7.7 KiB
Bash
Executable File
211 lines
7.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# splinter -- the A2A client transport, against a fake A2A agent.
|
|
#
|
|
# What it guards: SendMessage as JSON-RPC (--no-stream), SendStreamingMessage
|
|
# with SSE (the default one-shot path), the message shape, a Task result
|
|
# (status message plus artifact text), a direct Message, the bearer token, and
|
|
# a JSON-RPC error that must fail the turn instead of becoming an empty answer.
|
|
set -u
|
|
cd "$(dirname "$0")/.." || exit 1
|
|
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-a2a-XXXXXX") || exit 1
|
|
SPLINTER_SESSION_DIR="$D/home/.splinter"; export SPLINTER_SESSION_DIR
|
|
P=$((20000 + ($$ % 20000)))
|
|
F=
|
|
cleanup() { [ -n "$F" ] && kill "$F" 2>/dev/null; rm -rf "$D"; }
|
|
trap cleanup EXIT
|
|
export SPLINTER_A2A_INBOX="$D/inbox"
|
|
python3 -I tests/fake_a2a.py "$P" "$D/req.log" &
|
|
F=$!
|
|
for i in $(seq 1 50); do
|
|
curl -s -o /dev/null "http://127.0.0.1:$P/x" && break
|
|
sleep 0.2
|
|
done
|
|
|
|
fails=0
|
|
check() { if "$@"; then :; else echo "FAIL $*"; fails=$((fails + 1)); fi; }
|
|
blocking() { # the plain send path
|
|
SPLINTER_A2A_URL="http://127.0.0.1:$P/rpc" SPLINTER_A2A_TIMEOUT=20 \
|
|
./splinter --no-config --plugin plugins/a2a/a2a.so \
|
|
--transport a2a --no-stream -p "$1"
|
|
}
|
|
streaming() { # the one-shot default: stream when the transport can
|
|
SPLINTER_A2A_URL="http://127.0.0.1:$P/rpc" SPLINTER_A2A_TIMEOUT=20 \
|
|
./splinter --no-config --plugin plugins/a2a/a2a.so \
|
|
--transport a2a -p "$1"
|
|
}
|
|
discovered() { # <card-path> <text>: no URL, only the agent card
|
|
SPLINTER_A2A_CARD="http://127.0.0.1:$P/$1" SPLINTER_A2A_TIMEOUT=20 \
|
|
./splinter --no-config --plugin plugins/a2a/a2a.so \
|
|
--transport a2a --no-stream -p "$2"
|
|
}
|
|
|
|
# ---- blocking: a Task, status message and artifact text ----
|
|
out=$(blocking "hallo" 2>&1)
|
|
echo "$out" | grep -q 'a2a sagt hallo'
|
|
check test $? -eq 0
|
|
echo "$out" | grep -q 'und tschuess'
|
|
check test $? -eq 0
|
|
|
|
# the wire shape of the blocking call
|
|
grep -q '"method":"SendMessage"' "$D/req.log"
|
|
check test $? -eq 0
|
|
grep -q '"role":"ROLE_USER"' "$D/req.log"
|
|
check test $? -eq 0
|
|
grep -q '"parts":\[{"text":"hallo"}\]' "$D/req.log"
|
|
check test $? -eq 0
|
|
|
|
# a direct Message is an answer, not a task
|
|
out=$(blocking "direkt" 2>&1)
|
|
echo "$out" | grep -q 'direkt vom agenten'
|
|
check test $? -eq 0
|
|
|
|
# a binary part is not dropped: it is saved and the path is in the answer
|
|
out=$(blocking "schick eine datei" 2>&1)
|
|
echo "$out" | grep -q 'hier ist die datei'
|
|
check test $? -eq 0
|
|
echo "$out" | grep -q '\[file bild.png at'
|
|
check test $? -eq 0
|
|
found=$(ls "$SPLINTER_A2A_INBOX"/*bild.png 2>/dev/null | head -1)
|
|
check test -n "$found"
|
|
check sh -c "printf PNGDATA | cmp - '$found'"
|
|
|
|
# raw (text/plain base64) and string data parts are read
|
|
out=$(blocking "raw" 2>&1)
|
|
echo "$out" | grep -q 'hallo'
|
|
check test $? -eq 0
|
|
echo "$out" | grep -q 'struktur'
|
|
check test $? -eq 0
|
|
|
|
# the token goes out as a bearer header, and is required when the agent asks
|
|
out=$(SPLINTER_A2A_TOKEN=tok blocking "auth bitte" 2>&1)
|
|
echo "$out" | grep -q 'a2a sagt hallo'
|
|
check test $? -eq 0
|
|
out=$(blocking "auth ohne token" 2>&1)
|
|
echo "$out" | grep -q 'unauthorized'
|
|
check test $? -eq 0
|
|
|
|
# a JSON-RPC error fails the turn with the agent's message
|
|
blocking "fehler" >/dev/null 2>"$D/err"
|
|
check test $? -ne 0
|
|
grep -q 'boom from a2a' "$D/err"
|
|
check test $? -eq 0
|
|
|
|
# ---- streaming: artifact chunks arrive as the answer ----
|
|
out=$(streaming "stream bitte" 2>&1)
|
|
echo "$out" | grep -q 'teil eins teil zwei'
|
|
check test $? -eq 0
|
|
if echo "$out" | grep -q 'fertig'; then
|
|
echo "FAIL the final status note leaked into the streamed answer"
|
|
fails=$((fails + 1))
|
|
fi
|
|
|
|
# no artifact: the final status message is the answer
|
|
out=$(streaming "streamstatus" 2>&1)
|
|
echo "$out" | grep -q 'nur status'
|
|
check test $? -eq 0
|
|
|
|
# a direct Message also streams
|
|
out=$(streaming "direkt" 2>&1)
|
|
echo "$out" | grep -q 'direkt vom agenten'
|
|
check test $? -eq 0
|
|
|
|
# the wire method, not the blocking one
|
|
grep -q '"method":"SendStreamingMessage"' "$D/req.log"
|
|
check test $? -eq 0
|
|
|
|
# a plain JSON-RPC error instead of a stream: the server's message, and the
|
|
# request file (the whole conversation) is not left behind
|
|
tmpd="$D/tmp"
|
|
mkdir -p "$tmpd"
|
|
out=$(TMPDIR="$tmpd" streaming "plainerr" 2>&1)
|
|
echo "$out" | grep -q 'plain boom'
|
|
check test $? -eq 0
|
|
check test -z "$(ls "$tmpd" | grep splinter-a2a-)"
|
|
|
|
# ---- discovery: the card names the JSON-RPC endpoint ----
|
|
out=$(discovered ".well-known/agent-card.json" "hallo" 2>&1)
|
|
echo "$out" | grep -q 'a2a sagt hallo'
|
|
check test $? -eq 0
|
|
out=$(discovered "old-card.json" "hallo" 2>&1)
|
|
echo "$out" | grep -q 'a2a sagt hallo'
|
|
check test $? -eq 0
|
|
|
|
# ---- the plugin's GetTask/CancelTask tools against the same agent ----
|
|
mkdir -p "$D/home"
|
|
printf 'tool a2a_get_task {"id":"task-1"}\nanswer done\n' > "$D/tool-get.txt"
|
|
out=$(HOME="$D/home" SPLINTER_A2A_URL="http://127.0.0.1:$P/rpc" \
|
|
SPLINTER_A2A_TIMEOUT=20 ./splinter --no-config \
|
|
--plugin plugins/a2a/a2a.so --script "$D/tool-get.txt" \
|
|
-p "tool" --autonomous 2>&1)
|
|
echo "$out" | grep -q '^done'
|
|
check test $? -eq 0
|
|
sess=$(ls -t "$D/home/.splinter"/sess-*.jsonl 2>/dev/null | head -1)
|
|
check test -n "$sess"
|
|
check grep -q 'TASK_STATE_COMPLETED' "$sess"
|
|
|
|
printf 'tool a2a_cancel_task {"id":"task-1"}\nanswer done\n' \
|
|
> "$D/tool-cancel.txt"
|
|
out=$(HOME="$D/home" SPLINTER_A2A_URL="http://127.0.0.1:$P/rpc" \
|
|
SPLINTER_A2A_TIMEOUT=20 ./splinter --no-config \
|
|
--plugin plugins/a2a/a2a.so --script "$D/tool-cancel.txt" \
|
|
-p "tool" --autonomous 2>&1)
|
|
echo "$out" | grep -q '^done'
|
|
check test $? -eq 0
|
|
sess=$(ls -t "$D/home/.splinter"/sess-*.jsonl 2>/dev/null | head -1)
|
|
check grep -q -- '-32002' "$sess"
|
|
|
|
# ---- SubscribeToTask: the events of a subscription as one observation ----
|
|
printf 'tool a2a_subscribe {"id":"task-1"}\nanswer done\n' \
|
|
> "$D/tool-sub.txt"
|
|
out=$(HOME="$D/home" SPLINTER_A2A_URL="http://127.0.0.1:$P/rpc" \
|
|
SPLINTER_A2A_TIMEOUT=20 ./splinter --no-config \
|
|
--plugin plugins/a2a/a2a.so --script "$D/tool-sub.txt" \
|
|
-p "tool" --autonomous 2>&1)
|
|
echo "$out" | grep -q '^done'
|
|
check test $? -eq 0
|
|
sess=$(ls -t "$D/home/.splinter"/sess-*.jsonl 2>/dev/null | head -1)
|
|
check test -n "$sess"
|
|
check grep -q 'TASK_STATE_COMPLETED' "$sess"
|
|
check grep -q 'abo text' "$sess"
|
|
check grep -q 'abo teil' "$sess"
|
|
|
|
printf 'tool a2a_subscribe {"id":"nope"}\nanswer done\n' \
|
|
> "$D/tool-sub2.txt"
|
|
out=$(HOME="$D/home" SPLINTER_A2A_URL="http://127.0.0.1:$P/rpc" \
|
|
SPLINTER_A2A_TIMEOUT=20 ./splinter --no-config \
|
|
--plugin plugins/a2a/a2a.so --script "$D/tool-sub2.txt" \
|
|
-p "tool" --autonomous 2>&1)
|
|
echo "$out" | grep -q '^done'
|
|
check test $? -eq 0
|
|
sess=$(ls -t "$D/home/.splinter"/sess-*.jsonl 2>/dev/null | head -1)
|
|
check grep -q -- '-32001' "$sess"
|
|
|
|
# ---- a2a_send: a message with a file attached ----
|
|
printf 'PNGDATA' > "$D/att.png"
|
|
printf 'tool a2a_send {"text":"hier ist eine datei","file":"%s"}\nanswer done\n' \
|
|
"$D/att.png" > "$D/tool-send.txt"
|
|
out=$(HOME="$D/home" SPLINTER_A2A_URL="http://127.0.0.1:$P/rpc" \
|
|
SPLINTER_A2A_TIMEOUT=20 ./splinter --no-config \
|
|
--plugin plugins/a2a/a2a.so --script "$D/tool-send.txt" \
|
|
-p "tool" --autonomous 2>&1)
|
|
echo "$out" | grep -q '^done'
|
|
check test $? -eq 0
|
|
sess=$(ls -t "$D/home/.splinter"/sess-*.jsonl 2>/dev/null | head -1)
|
|
check grep -q 'datei empfangen: att.png 7' "$sess"
|
|
check grep -q '"file":{"name":"att.png","mimeType":"image/png"' "$D/req.log"
|
|
check grep -q '"bytes":"UE5HREFUQQ=="' "$D/req.log"
|
|
|
|
printf 'tool a2a_send {"text":"x","file":"%s/%s"}\nanswer done\n' \
|
|
"$D" "gibtsnicht.png" > "$D/tool-send2.txt"
|
|
out=$(HOME="$D/home" SPLINTER_A2A_URL="http://127.0.0.1:$P/rpc" \
|
|
SPLINTER_A2A_TIMEOUT=20 ./splinter --no-config \
|
|
--plugin plugins/a2a/a2a.so --script "$D/tool-send2.txt" \
|
|
-p "tool" --autonomous 2>&1)
|
|
echo "$out" | grep -q '^done'
|
|
check test $? -eq 0
|
|
sess=$(ls -t "$D/home/.splinter"/sess-*.jsonl 2>/dev/null | head -1)
|
|
check grep -q 'cannot read' "$sess"
|
|
|
|
if [ "$fails" -eq 0 ]; then echo "test_a2a: ok"; exit 0; fi
|
|
exit 1
|