#!/bin/bash
USER_ID="9a333ccd-9c3f-432f-a030-7b1e1284a436"
API="https://ai.jerxie.com/api/v1"
echo "Creating template..."
TPL_RESP=$(curl -s -X POST "$API/agents/templates" \
-H "X-User-ID: $USER_ID" \
-H "Content-Type: application/json" \
-d '{
"name": "Live Telemetry Demo"
}')
echo "$TPL_RESP"
TPL_ID=$(echo "$TPL_RESP" | grep -o '"id":"[^"]*' | cut -d'"' -f4 | head -n 1)
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)
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": "'"$TPL_ID"'",
"session_id": '"$SESSION_ID"',
"mesh_node_id": "test-node-1",
"status": "active",
"current_workspace_jail": "/tmp/cortex-sync"
}'