mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
A2A wiring up
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user