mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
Enforcements, hooks and code quality
This commit is contained in:
@@ -1,32 +1,43 @@
|
||||
#!/bin/bash
|
||||
# SDK Server Startup Hook
|
||||
# SessionStart hook — starts the SDK server and prints the pre-rendered
|
||||
# task briefing into the session so Claude doesn't burn its first turns
|
||||
# on tool discovery (roboco_task_scan → roboco_task_get → read files).
|
||||
#
|
||||
# Called by Claude Code on SessionStart to start the SDK server.
|
||||
# Runs in background, Claude continues immediately.
|
||||
# The briefing is written by the orchestrator before the container spawns
|
||||
# (_write_agent_briefing) and mounted read-only at /app/briefing.md.
|
||||
|
||||
SDK_PORT="${ROBOCO_SDK_PORT:-9000}"
|
||||
AGENT_ID="${ROBOCO_AGENT_ID:-unknown}"
|
||||
LOG_FILE="/tmp/sdk-server.log"
|
||||
BRIEFING_FILE="/app/briefing.md"
|
||||
PRECOMPACT_FILE="/tmp/roboco-precompact-${AGENT_ID}.md"
|
||||
|
||||
# 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
|
||||
# --- SDK bring-up ---------------------------------------------------------
|
||||
if ! curl -sf "http://localhost:${SDK_PORT}/health" >/dev/null 2>&1; then
|
||||
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=$!
|
||||
sleep 2
|
||||
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})"
|
||||
fi
|
||||
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=$!
|
||||
# Reset budget/terminal counters at the start of every session.
|
||||
curl -sf -m 2 -X POST "http://localhost:${SDK_PORT}/budget/reset" >/dev/null 2>&1 || true
|
||||
|
||||
# Brief wait for startup (non-blocking - don't hold up Claude)
|
||||
sleep 2
|
||||
# --- Briefing + PreCompact recovery --------------------------------------
|
||||
# Compact restore comes FIRST so it's clear what this session is resuming.
|
||||
if [[ -s "$PRECOMPACT_FILE" ]]; then
|
||||
echo "### Resumed from compact"
|
||||
cat "$PRECOMPACT_FILE"
|
||||
echo
|
||||
fi
|
||||
|
||||
# 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)"
|
||||
if [[ -s "$BRIEFING_FILE" ]]; then
|
||||
cat "$BRIEFING_FILE"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user