A2A wiring up

This commit is contained in:
Renn F
2026-01-06 00:59:09 +01:00
parent aeb3aea55e
commit c621710ae6
63 changed files with 2327 additions and 451 deletions
+13 -1
View File
@@ -6,12 +6,13 @@
FROM python:3.13-bookworm
# Install Node.js 22 (required for Claude Code CLI)
# Install Node.js 22 (required for Claude Code CLI) and jq (for hooks)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
git \
gnupg \
jq \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
@@ -45,4 +46,15 @@ RUN uv python install 3.13 && uv sync --frozen --python 3.13
# System prompt mounted at /app/system-prompt.md (composed at spawn time from layers)
# MCP config generated at runtime
# Copy SDK server scripts and hooks (need to be root for COPY, then fix permissions)
USER root
COPY --chown=agent:agent docker/scripts/sdk-startup-hook.sh /app/scripts/sdk-startup-hook.sh
COPY --chown=agent:agent docker/scripts/a2a-check-hook.sh /app/scripts/a2a-check-hook.sh
RUN chmod +x /app/scripts/*.sh
USER agent
# Expose SDK server port
EXPOSE 9000
# Claude runs directly - SDK server started via SessionStart hook
ENTRYPOINT ["claude"]
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
# A2A Check Hook
#
# Claude Code hook that runs after each tool call to check for
# incoming A2A messages. Notifies Claude if messages are pending.
#
# This hook is non-blocking and always succeeds to avoid
# interrupting Claude's workflow.
SDK_URL="${ROBOCO_SDK_URL:-http://localhost:9000}"
# Check inbox count (non-consuming endpoint)
response=$(curl -sf "$SDK_URL/inbox/count" 2>/dev/null)
if [ $? -eq 0 ]; then
total=$(echo "$response" | jq -r '.total // 0')
urgent=$(echo "$response" | jq -r '.urgent // 0')
if [ "$total" -gt 0 ]; then
if [ "$urgent" -gt 0 ]; then
echo "[A2A] URGENT: You have $urgent urgent message(s). Use roboco_a2a_check() to read them."
else
echo "[A2A] You have $total pending message(s). Use roboco_a2a_check() to read them."
fi
fi
fi
# Always exit 0 - don't block Claude
exit 0
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
# SDK Server Startup Hook
#
# Called by Claude Code on SessionStart to start the SDK server.
# Runs in background, Claude continues immediately.
SDK_PORT="${ROBOCO_SDK_PORT:-9000}"
AGENT_ID="${ROBOCO_AGENT_ID:-unknown}"
LOG_FILE="/tmp/sdk-server.log"
# Check if SDK is already running
if curl -sf "http://localhost:${SDK_PORT}/health" >/dev/null 2>&1; then
echo "[SDK] Already running on port ${SDK_PORT}"
exit 0
fi
# Start SDK server in background (nohup to survive hook completion)
echo "[SDK] Starting for agent ${AGENT_ID} on port ${SDK_PORT}..."
nohup uv run python -m roboco.agent_sdk.server > "$LOG_FILE" 2>&1 &
SDK_PID=$!
# Brief wait for startup (non-blocking - don't hold up Claude)
sleep 2
# Check if it started
if curl -sf "http://localhost:${SDK_PORT}/health" >/dev/null 2>&1; then
echo "[SDK] Ready (PID: ${SDK_PID})"
else
echo "[SDK] Starting in background (PID: ${SDK_PID}, check ${LOG_FILE} for status)"
fi
exit 0