Konrad, 24.11.: "v1 geht durch ohne irgendwas. ich will auch keine approvals generell. ich will nur das der user mit ask nach sachen gefragt werden kann." Removed the whole approval apparatus, not just the prompt: - agent.c: the decision point (sp_host_gate/approve callbacks), the pause/resume path (has_pending, pending_from, sp_agent_resume), ack_approval, ask_operator and the ack stdin thread are gone. A tool runs; its exit status is the observation. sp_tool_policy (allow/deny per profile) stays - that is the operator's own configuration, not a question to the operator. - engine.c: SP_EV_APPROVAL, sp_engine_approve, the approve_pending condition variable and the `approval`/`approve` protocol commands are gone. - openai_server.c: the v1 endpoint runs gw_* tools without a gate; the autonomous flag is no longer part of sp_gateway_opts. - a2aserver.c: INPUT_REQUIRED and the resume-by-taskId path are gone; CancelTask stays. An A2A caller has no operator sitting in front of a prompt. - mcpserver.c: --autonomous no longer gates mutating tools; the flag and the config key are accepted for compatibility and documented as changing nothing. - telegram.c: tg_approve and the approval callback are gone; ask is the only dialog, and /cancel inside it still ends the turn. - front ends: protocol.c, curses.c, ui_local.c, ui_remote.c, client.c lose the approval event and the waiting flag. - ack.c stays: it is a plugin API (plugins/kids asks its parent through it), not splinter's own gate. --ack is documented as such. Tests: test_pause.c guarded the pause and now guards the opposite (a mutate and a destructive tool run, nothing is asked). test_a2a_input.sh, test_protocol.sh, test_ui.sh, test_agents_ui.sh, test_gateway.sh, test_gateway_openai.sh, test_agent.c and test_mcpsession.sh were rewritten the same way; splinter_approve must now be absent from the MCP tool list. Every rewritten test was run red against the old behaviour where that was possible. make check: all tests passed (428 s) make check-asan: all 47 test binaries clean make check-tsan: all 47 test binaries free of data races
118 lines
4.7 KiB
Bash
118 lines
4.7 KiB
Bash
#!/bin/sh
|
|
#
|
|
# splinter -- Tab switches the agent profile; plan cannot run commands, and
|
|
# build runs them without a question in front of the tool.
|
|
set -u
|
|
cd "$(dirname "$0")/.." || exit 1
|
|
. "$(dirname "$0")/sh/port.sh"
|
|
command -v tmux >/dev/null 2>&1 || { echo "test_agents_ui: skipped (no tmux)"; exit 0; }
|
|
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-ag-XXXXXX") || exit 1
|
|
SPLINTER_SESSION_DIR="$D/home/.splinter"; export SPLINTER_SESSION_DIR
|
|
# Our own socket, never the user's. $TMUX (set when this runs inside somebody's
|
|
# tmux) wins over TMUX_TMPDIR, so drop it and point the server at $D: a key
|
|
# this test sends can then not land in a real session, and the kill-session
|
|
# below cannot touch one.
|
|
unset TMUX TMUX_PANE
|
|
export TMUX_TMPDIR="$D"
|
|
own_server() {
|
|
if [ -n "${TMUX:-}" ] || [ "${TMUX_TMPDIR:-}" != "$D" ]; then
|
|
echo "test_agents_ui: refusing to touch a tmux server this test does not own" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
killserver() { own_server; tmux kill-server 2>/dev/null; }
|
|
P=$(free_port)
|
|
S=sp-agents-$$
|
|
F=
|
|
trap 'killserver; kill $F 2>/dev/null; rm -rf "$D"' EXIT
|
|
fails=0
|
|
check() { d=$1; shift; if "$@"; then :; else echo "FAIL $d"; fails=$((fails + 1)); fi; }
|
|
shows() {
|
|
for i in $(seq 1 40); do
|
|
tmux capture-pane -t $S -p | grep -q -- "$1" && return 0
|
|
sleep 0.25
|
|
done
|
|
return 1
|
|
}
|
|
# a condition that becomes true a moment later. A screen check is not enough
|
|
# here: the text of the refused turn is still on the pane, so "obs: " appears
|
|
# before the build turn has even started.
|
|
waitfor() {
|
|
for i in $(seq 1 40); do
|
|
"$@" && return 0
|
|
sleep 0.25
|
|
done
|
|
return 1
|
|
}
|
|
|
|
mkdir -p "$D/home/.splinter/agents" "$D/proj"
|
|
printf -- '---\ndescription: only reads\ntools: read\n---\nBe careful.\n' \
|
|
> "$D/home/.splinter/agents/careful.md"
|
|
python3 -I tests/fake_openai_tool.py "$P" "$D/made" &
|
|
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
|
|
|
|
# --agent-list names the profiles and where a file came from
|
|
HOME="$D/home" ./splinter --no-config --agent-list </dev/null > "$D/list.txt" 2>&1
|
|
check "build is listed" grep -q '^build ' "$D/list.txt"
|
|
check "plan is listed read-only" grep -q '^plan .*read-only' "$D/list.txt"
|
|
check "a file profile is listed" grep -q '^careful ' "$D/list.txt"
|
|
|
|
tmux new-session -d -s $S -x 120 -y 30 -c "$D/proj" \
|
|
"HOME=$D/home SPLINTER_LOCALE=en SPLINTER_USAGE_DIR=$D/u SPLINTER_COOLDOWN_DIR=$D/c \
|
|
$PWD/splinter --no-config --endpoint http://127.0.0.1:$P/v1/chat/completions \
|
|
--model m --chat 2>/dev/null"
|
|
check "starts as build" shows '^build>'
|
|
tmux send-keys -t $S Tab
|
|
check "Tab goes to plan" shows 'agent: plan'
|
|
tmux send-keys -t $S Tab
|
|
check "Tab goes on to a file profile" shows 'agent: careful'
|
|
tmux send-keys -t $S Tab
|
|
check "and wraps to build" shows '^build>'
|
|
tmux send-keys -t $S BTab
|
|
check "Shift-Tab goes back" shows 'agent: careful'
|
|
tmux send-keys -t $S BTab
|
|
check "back to plan" shows 'agent: plan'
|
|
|
|
# in plan, the command is refused with the reason; nothing is created
|
|
tmux send-keys -t $S -l 'mach etwas'
|
|
tmux send-keys -t $S Enter
|
|
check "plan refuses the command" shows "not available in the 'plan' agent"
|
|
check "nothing was created" test ! -e "$D/made"
|
|
|
|
# in build the same request goes through - no question in front of the tool,
|
|
# the profile's policy is the only thing that decides what the agent may reach
|
|
tmux send-keys -t $S Tab
|
|
tmux send-keys -t $S Tab
|
|
sleep 1
|
|
tmux send-keys -t $S -l 'nochmal'
|
|
tmux send-keys -t $S Enter
|
|
check "build runs the command" waitfor test -e "$D/made"
|
|
check "and the model read the observation" shows 'exit status 0'
|
|
|
|
# The language is English unless a config or SPLINTER_LOCALE says otherwise;
|
|
# the desktop's LANG must not change it behind the operator's back.
|
|
# A fresh session name: reusing one right after kill-session races, and a lost
|
|
# keystroke looked like a rendering bug.
|
|
tmux kill-session -t $S 2>/dev/null
|
|
S=sp-agents-de-$$
|
|
tmux new-session -d -s $S -x 120 -y 30 -c "$D/proj" \
|
|
"env -u SPLINTER_LOCALE LANG=de_DE.UTF-8 HOME=$D/home SPLINTER_USAGE_DIR=$D/u \
|
|
SPLINTER_COOLDOWN_DIR=$D/c $PWD/splinter --no-config \
|
|
--endpoint http://127.0.0.1:$P/v1/chat/completions --model m --chat 2>/dev/null"
|
|
check "English UI despite LANG=de_DE" shows 'ready'
|
|
# an asterisk in code is an asterisk; real emphasis loses its markers
|
|
tmux send-keys -t $S -l 'pointers bitte'
|
|
tmux send-keys -t $S Enter
|
|
check "pointers keep their asterisks" shows 'void \*ctx, const char \*name'
|
|
check "bold loses its markers" shows -- '-- bold and it'
|
|
check "no raw catalogue keys on the screen" sh -c \
|
|
"! tmux capture-pane -t $S -p | grep -Eq '(^|[ >])(ui|sidebar|status|widget|agent|usage|role)\.[a-z_]+'"
|
|
|
|
if [ "$fails" -eq 0 ]; then echo "test_agents_ui: ok"; exit 0; fi
|
|
tmux capture-pane -t $S -p | tail -15
|
|
exit 1
|