Newer
Older
cortex-hub / curl_setup_agent_fix.sh
#!/bin/bash
USER_ID="9a333ccd-9c3f-432f-a030-7b1e1284a436"
API="https://ai.jerxie.com/api/v1"

echo "Creating template..."
curl -s -X POST "$API/agents/templates" \
  -H "X-User-ID: $USER_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "demo-telemetry-agent",
    "name": "Live Telemetry Demo",
    "system_prompt_template": "Just a test.",
    "allowed_skills": [],
    "resource_limits": {"max_memory_mb": 512, "max_cpu_percent": 80}
  }'

echo -e "\nCreating session..."
RESP=$(curl -s -X POST "$API/sessions/" \
  -H "X-User-ID: $USER_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "'"$USER_ID"'",
    "feature_name": "agent_dashboard"
  }')
echo "$RESP"

SESSION_ID=$(echo "$RESP" | grep -o '"id":[0-9]*' | cut -d':' -f2 | head -n 1)

if [ -z "$SESSION_ID" ]; then
   echo "Failed to extract session ID."
   exit 1
fi

echo -e "\nCreating instance..."
curl -s -X POST "$API/agents/instances" \
  -H "X-User-ID: $USER_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "template_id": "demo-telemetry-agent",
    "session_id": '"$SESSION_ID"',
    "mesh_node_id": "test-node-1",
    "status": "active",
    "current_workspace_jail": "/tmp/cortex-sync"
  }'