#!/usr/bin/env bash
# 光湖服务器入口地图 Agent v2 · interactive shell hook

case "$-" in
  *i*) ;;
  *) return 0 2>/dev/null || exit 0 ;;
esac

if [ "${GUANGHU_MAP_AGENT_SEEN:-}" = "1" ]; then
  return 0 2>/dev/null || exit 0
fi

GUANGHU_MAP_AGENT_BIN="${GUANGHU_MAP_AGENT_BIN:-/opt/guanghu/map-agent/pre-op-map-agent-v2.py}"
GUANGHU_NODE_ID="${GUANGHU_NODE_ID:-BS-SG-003}"
export GUANGHU_NODE_ID

if python3 "$GUANGHU_MAP_AGENT_BIN" --persona "${GUANGHU_PERSONA:-${USER:-unknown}}"; then
  GUANGHU_MAP_AGENT_STATUS="MAP_VERIFIED"
else
  GUANGHU_MAP_AGENT_STATUS="MAP_MISSING"
  printf '%s\n' "警告: 当前 shell 未恢复节点地图。仅允许执行地图恢复或已授权的恢复动作。" >&2
fi

GUANGHU_MAP_AGENT_SEEN=1
export GUANGHU_MAP_AGENT_SEEN GUANGHU_MAP_AGENT_STATUS
