swadhinbiswas πŸš€ release: 2.0.8 β€” write-path fix (ADR-080), fork-safe GIL pool (ADR-081), HTTP/3 (ADR-082), Security DI fix, docs honesty pass Β· 8/6/2026
731fffe
84 lines Β· 2.7 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
# examples/agent_demo/run_demo.sh β€” one-command agent-native demo.
#
# Starts the JustAPI agent demo, exercises all three differentiators
# (native MCP tools, durable sessions, Rust-validated streaming), shows the
# output, then stops the server. No manual steps.
#
# Usage:
#   bash examples/agent_demo/run_demo.sh [port]
#
# Prereqs: the justapi package must be importable (e.g. a venv with
# `pip install justapi` or the repo's `.venv`).

set -euo pipefail

PORT="${1:-8051}"
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT="$(dirname "$(dirname "$HERE")")"

# Pick a python that can import justapi.
if python -c "import justapi" 2>/dev/null; then
    PY=python
elif "$ROOT/crates/justapi-py/.venv/bin/python" -c "import justapi" 2>/dev/null; then
    PY="$ROOT/crates/justapi-py/.venv/bin/python"
elif "$ROOT/.venv/bin/python" -c "import justapi" 2>/dev/null; then
    PY="$ROOT/.venv/bin/python"
else
    echo "[demo] no python with 'justapi' importable found." >&2
    echo "[demo] install it first: pip install justapi   (or rebuild the wheel)" >&2
    exit 1
fi

BASE="http://127.0.0.1:$PORT"
LOG="$(mktemp /tmp/justapi_agent_demo.XXXXXX.log)"

echo "[demo] starting JustAPI agent demo on $BASE (python: $PY)"
"$PY" "$HERE/app.py" "$PORT" >"$LOG" 2>&1 &
SERVER_PID=$!
trap 'kill "$SERVER_PID" 2>/dev/null || true' EXIT

# Wait for the server to come up.
for _ in $(seq 1 30); do
    if curl -sf "$BASE/" >/dev/null 2>&1; then break; fi
    if ! kill -0 "$SERVER_PID" 2>/dev/null; then
        echo "[demo] server exited early; log tail:" >&2
        tail -20 "$LOG" >&2
        exit 1
    fi
    sleep 0.5
done

sep() { printf '\n────────────────────────────────────────────────────────\n'; }

echo ""
echo "=== 1. Native MCP tools (schemas inferred in Rust) ==="
curl -s "$BASE/_system/tools" | "$PY" -m json.tool | head -20
sep

echo "=== 2. Call a tool through the native call path ==="
curl -s -X POST "$BASE/_system/tools/call" \
    -H 'content-type: application/json' \
    -d '{"name":"add","arguments":{"a":5,"b":7}}'
echo ""
sep

echo "=== 3. Streaming agent run (NDJSON, validated item-by-item in Rust) ==="
curl -sN "$BASE/agent/run?session=demo&query=streaming"
echo ""
sep

echo "=== 4. Durable session state (persisted across requests) ==="
curl -s "$BASE/agent/state?session=demo"
echo ""
echo ""
echo "=== 5. Same session again β†’ run counter incremented ==="
curl -sN "$BASE/agent/run?session=demo&query=streaming" >/dev/null
curl -s "$BASE/agent/state?session=demo"
echo ""
sep

echo ""
echo "[demo] done. Server log: $LOG"
echo "[demo] rerun:  bash examples/agent_demo/run_demo.sh"