#!/bin/bash
# check-agent.sh - Check agent tables in NocoDB
# Uses vault cache for fast token retrieval

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/../vault-env.sh"

NOCODB_TOKEN=$(vaul…ken)

if [ -z "$NOCODB_TOKEN" ]; then
    echo "Error: Could not retrieve NocoDB token"
    exit 1
fi

echo "Token: ${NOCODB_TOKEN:***"

# Check tables in Agent base
echo "=== Tables in Agent base ==="
curl -s "http://192.168.25.5:8080/api/v2/meta/bases/pedwxnsn51vxdq2/tables" \
  -H "xc-token: $NOCODB_TOKEN" | jq '.list[] | "\(.id): \(.title)"'
