mvp-factory-openhands/test-scripts/openhands-sdk-wrapper-sh.sh

48 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# OpenHands SDK Wrapper for n8n (sh-compatible)
# Usage: sh /home/bam/openhands-sdk-wrapper-sh.sh "task description"
SDK_PATH="/tmp/software-agent-sdk"
VENV_PATH="$SDK_PATH/.venv/bin"
ENV_FILE="/home/bam/openhands/.env"
WRAPPER_PATH="/home/bam/openhands-sdk-wrapper-fixed.py"
# Check if task argument provided
if [ -z "$1" ]; then
echo "ERROR: No task provided"
echo "Usage: $0 \"task description\""
exit 1
fi
TASK="$1"
# Change to SDK directory
cd "$SDK_PATH" || exit 1
# Activate virtual environment (sh compatible)
if [ -f "$VENV_PATH/activate" ]; then
. "$VENV_PATH/activate"
else
echo "ERROR: Virtual environment not found at $VENV_PATH"
exit 1
fi
# Load environment variables
if [ -f "$ENV_FILE" ]; then
while IFS= read -r line; do
# Skip comments and empty lines
case "$line" in
\#*|"") continue ;;
esac
# Export variable
export "$line" 2>/dev/null || true
done < "$ENV_FILE"
else
echo "ERROR: Environment file not found at $ENV_FILE"
exit 1
fi
# Execute the SDK wrapper
python3 "$WRAPPER_PATH" "$TASK"
exit $?