Files
copilotkit__copilotkit/showcase/starters/claude-sdk-python/entrypoint.sh
Jordan Ritter 59c073c610 fix: add agent_server.py to all Python starters, matching demo packages
Python starters were trying to run uvicorn with agent.<module>:app but
those modules don't export a FastAPI app. The demo packages use
agent_server.py as the FastAPI wrapper, so starters need it too.

Changes:
- Copy agent_server.py from each demo package into starter root,
  rewriting "from agents." to "from agent." for the starter layout
- Update all non-langgraph Python devScripts to use agent_server:app
- Update Dockerfile.python to COPY agent_server.py for non-langgraph
- Update getEntrypointBlock() generic Python to use agent_server:app
- Make langgraph-fastapi use langgraph_cli dev like langgraph-python
  (it was incorrectly configured as a uvicorn-based starter)
- Regenerate all starters
2026-04-14 15:41:34 -07:00

61 lines
1.9 KiB
Bash
Executable File
Generated

#!/bin/bash
# Template variables (substituted by generate-starters.ts):
# SLUG — framework slug (e.g. "langgraph-python")
# DEV_SCRIPT_BLOCK — language-specific agent startup block
set -e
cleanup() {
kill $AGENT_PID $NEXTJS_PID 2>/dev/null
}
trap cleanup EXIT
echo "========================================="
echo "[entrypoint] Starting showcase: claude-sdk-python"
echo "[entrypoint] Time: $(date -u)"
echo "[entrypoint] PORT=${PORT:-not set}"
echo "[entrypoint] NODE_ENV=${NODE_ENV:-not set}"
echo "========================================="
# Check critical env vars
if [ -z "$OPENAI_API_KEY" ]; then
echo "[entrypoint] WARNING: OPENAI_API_KEY is not set! Agent will fail."
else
echo "[entrypoint] OPENAI_API_KEY: set (${#OPENAI_API_KEY} chars)"
fi
echo "[entrypoint] Starting Python agent server on port 8123..."
cd /app && python -m uvicorn agent_server:app --host 0.0.0.0 --port 8123 2>&1 | sed 's/^/[agent] /' &
AGENT_PID=$!
sleep 2
if kill -0 $AGENT_PID 2>/dev/null; then
echo "[entrypoint] Agent server started (PID: $AGENT_PID)"
else
echo "[entrypoint] ERROR: Agent server failed to start — exiting"
exit 1
fi
echo "========================================="
echo "[entrypoint] Starting Next.js frontend on port ${PORT:-10000}..."
echo "========================================="
PORT=${PORT:-10000}
npx next start --port $PORT 2>&1 | sed 's/^/[nextjs] /' &
NEXTJS_PID=$!
echo "[entrypoint] Next.js started (PID: $NEXTJS_PID)"
echo "[entrypoint] Both processes running. Waiting..."
wait -n $AGENT_PID $NEXTJS_PID
EXIT_CODE=$?
if ! kill -0 $AGENT_PID 2>/dev/null; then
echo "[entrypoint] Agent process (PID: $AGENT_PID) exited with code $EXIT_CODE"
elif ! kill -0 $NEXTJS_PID 2>/dev/null; then
echo "[entrypoint] Next.js process (PID: $NEXTJS_PID) exited with code $EXIT_CODE"
else
echo "[entrypoint] A process exited with code $EXIT_CODE"
fi
# Clean up surviving process
kill $AGENT_PID $NEXTJS_PID 2>/dev/null
exit $EXIT_CODE