test-api.sh
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# 验证 API 是否返回 input/output
TASK_ID=$(curl -s http://localhost:3000/api/tasks | python3 -c "
import sys, json
data = json.load(sys.stdin)
tasks = data.get('tasks', [])
if tasks:
print(tasks[0]['id'])
else:
print('NO_TASKS')
" 2>/dev/null)
echo "Task ID: $TASK_ID"
if [ "$TASK_ID" = "NO_TASKS" ]; then
echo "No tasks found"
exit 0
fi
curl -s "http://localhost:3000/api/tasks/$TASK_ID/executions" | python3 -c "
import sys, json
data = json.load(sys.stdin)
if isinstance(data, dict) and 'error' in data:
print('API ERROR:', data['error'])
sys.exit(1)
print(f'Executions count: {len(data)}')
for i, ex in enumerate(data):
print(f'--- execution {i} ---')
print(f' id: {ex.get(\"id\")}')
print(f' agent: {ex.get(\"agent_name\")}')
print(f' status: {ex.get(\"status\")}')
has_input = bool(ex.get('input'))
has_output = bool(ex.get('output'))
print(f' has input: {has_input} ({len(ex.get(\"input\", \"\"))} chars)')
print(f' has output: {has_output} ({len(ex.get(\"output\", \"\"))} chars)')
print(f' acpEvents: {len(ex.get(\"acpEvents\", []))}')
print(f' keys: {list(ex.keys())}')
"