diff --git a/lib/container.sh b/lib/container.sh index 11072fb..a5b2a86 100644 --- a/lib/container.sh +++ b/lib/container.sh @@ -115,14 +115,37 @@ fi # ── Put claude wrapper first on PATH ──────────────────────────────────── export PATH="\$PROJECT_DIR/bin:\$PATH" -# ── Launch CS Core on the host ─────────────────────────────────────────── -echo "→ Starting Context Studio Core..." +# ── Launch CS Core A2A servers in background ───────────────────────────── +echo "→ Starting Context Studio Core (A2A servers)..." CS_CORE_DIR="\$CS_CORE" \\ CS_WORKFLOW_DIR="\$PROJECT_DIR/workflow" \\ PROJECT_ROOT_DIR="\$PROJECT_DIR" \\ -node "\$CS_CORE/core/start.js" +node "\$CS_CORE/core/start.js" --ui-mode=headless & +CS_CORE_PID=\$! -# ── CS Core exited — stop container ───────────────────────────────────── +# ── Wait for registry to be ready (port 8000) ─────────────────────────── +echo -n "→ Waiting for A2A registry..." +for _i in \$(seq 1 30); do + if curl -sf http://localhost:8000/health >/dev/null 2>&1; then + echo " ready." + break + fi + echo -n "." + sleep 0.5 +done +echo "" + +# ── Launch Electron UI ─────────────────────────────────────────────────── +echo "→ Launching Context Studio UI..." +CS_CORE_DIR="\$CS_CORE" \\ +CS_WORKFLOW_DIR="\$PROJECT_DIR/workflow" \\ +PROJECT_ROOT_DIR="\$PROJECT_DIR" \\ +"\$CS_CORE/app/node_modules/.bin/electron" "\$CS_CORE/app" + +# ── Electron closed — stop A2A servers and container ───────────────────── +echo "→ UI closed. Stopping A2A servers..." +kill "\$CS_CORE_PID" 2>/dev/null || true +wait "\$CS_CORE_PID" 2>/dev/null || true echo "→ Stopping agents container..." "\$RUNTIME" rm -f "\$CONTAINER_NAME" 2>/dev/null || true START