# Test Scripts - OpenHands SDK & Build Testing This directory contains test scripts for the OpenHands SDK integration and build testing workflow. ## 📁 Contents ### SDK Wrapper Scripts These scripts wrap the OpenHands CLI for various use cases: - **`openhands-sdk-wrapper-sh.sh`** (Primary) - Shell-compatible wrapper for n8n SSH execution - Usage: `sh openhands-sdk-wrapper-sh.sh "Your task here"` - Used in n8n workflows via SSH node - **`openhands-sdk-wrapper.py`** (Python) - Python wrapper for direct testing - Usage: `python3 openhands-sdk-wrapper.py "Task description"` - Requires OpenHands environment variables - **`openhands-sdk-wrapper-fixed.py`** (Enhanced Python) - Enhanced version with better error handling - Usage: `python3 openhands-sdk-wrapper-fixed.py "Task description"` - Includes environment validation ### Build & Test Scripts Scripts for testing build and test workflows: - **`build_test.sh`** - Basic build test script - Tests project build capabilities - Usage: `sh build_test.sh` - **`advanced_build_test.sh`** - Advanced build with detailed logging - Includes timeout handling - More comprehensive output - Usage: `sh advanced_build_test.sh` - **`build-test-complete.sh`** - Complete build test with verification - Checks build artifacts - Validates results - Usage: `sh build-test-complete.sh` ### Diagnostic Scripts Utility scripts for troubleshooting and environment checks: - **`check_environment.sh`** - Verifies system setup - Checks OpenHands installation - Validates environment variables - Usage: `sh check_environment.sh` - **`diagnose.sh`** - General troubleshooting script - Checks service status - Reviews logs - Usage: `sh diagnose.sh` - **`explore.sh`** - Explores project structure - Lists directories and files - Shows workspace contents - Usage: `sh explore.sh` ## 🚀 Quick Start ### Test SDK Wrapper ```bash # Test the main SDK wrapper sh openhands-sdk-wrapper-sh.sh "Create a file named test.txt with content: Hello from SDK test" # Test Python wrapper python3 openhands-sdk-wrapper.py "List files in /home/bam/workspace" ``` ### Run Build Tests ```bash # Basic build test sh build_test.sh # Advanced build test sh advanced_build_test.sh # Complete build test sh build-test-complete.sh ``` ### Check System ```bash # Verify environment sh check_environment.sh # Run diagnostics sh diagnose.sh # Explore workspace sh explore.sh ``` ## 📋 Integration with n8n These scripts are used in n8n workflows via the SSH node: ```javascript // In n8n SSH node: Command: sh /home/bam/claude/mvp-factory/test-scripts/openhands-sdk-wrapper-sh.sh "{{ $json.task }}" Authentication: privateKey Options: passThrough: true ``` ## 🔧 Environment Requirements ### OpenHands Environment Variables Required in `/home/bam/openhands/.env`: - `MINIMAX_API_KEY` - Primary LLM API key - `DEEPSEEK_API_KEY` - Backup LLM API key (optional) - `OPENAI_API_KEY` - Second backup (optional) ### SSH Access For n8n integration: - SSH key: `/home/bam/.ssh/n8n_key` - Permissions: `chmod 600 /home/bam/.ssh/n8n_key` ### Direct Testing For local testing: ```bash # Source OpenHands environment source /home/bam/openhands/.env # Test SDK directly /home/bam/.local/bin/openhands --version ``` ## 🎯 Usage Patterns ### 1. Testing from Command Line ```bash # Navigate to test-scripts cd /home/bam/claude/mvp-factory/test-scripts # Test SDK with simple task sh openhands-sdk-wrapper-sh.sh "Create and list a test file" # Verify the test ls -la /home/bam/workspace/ cat /home/bam/workspace/test_file.txt ``` ### 2. Integration Testing ```bash # Run full build test sh advanced_build_test.sh # Check results tail -f /tmp/openhands-test.log ``` ### 3. Troubleshooting ```bash # Check environment setup sh check_environment.sh # Diagnose issues sh diagnose.sh # Explore workspace sh explore.sh ``` ## 📊 Expected Outputs ### Successful SDK Execution ``` ✅ Task completed successfully 📁 Files created: test.txt 📝 Content: Hello from SDK test ``` ### Build Test Success ``` 🚀 Starting build test... ✅ Environment validated ✅ Dependencies installed ✅ Build completed ✅ Tests passed 🎉 Build test successful ``` ### Environment Check ``` ✅ OpenHands CLI: /home/bam/.local/bin/openhands (v1.3.0) ✅ API Keys: MiniMax configured ✅ Workspace: /home/bam/workspace accessible ✅ SSH Key: Present and readable ``` ## 🐛 Troubleshooting ### "Command not found" errors - Ensure OpenHands is installed: `/home/bam/.local/bin/openhands --version` - Source environment: `source /home/bam/openhands/.env` ### "Permission denied" errors - Check SSH key permissions: `chmod 600 /home/bam/.ssh/n8n_key` - Verify file permissions: `chmod +x *.sh` ### API key errors - Verify environment file: `cat /home/bam/openhands/.env` - Check API key format (should not have extra spaces or quotes) ### SSH authentication fails - Test SSH key: `ssh -i /home/bam/.ssh/n8n_key localhost` - Check n8n credentials in n8n UI ## 📚 Related Documentation - **Main Documentation:** `/home/bam/claude/mvp-factory/CLAUDE.md` - **n8n API Guide:** https://n8n.oky.sh/api/v1/ (requires API token) - **OpenHands CLI:** `/home/bam/.local/bin/openhands --help` ## 🔑 API Key Location **n8n API Token:** `/home/bam/.n8n_api_key` ```bash # View token (DO NOT commit this file) cat /home/bam/.n8n_api_key ``` **OpenHands API Keys:** `/home/bam/openhands/.env` ```bash # View OpenHands environment cat /home/bam/openhands/.env ``` ## ✅ Testing Checklist - [ ] SDK wrapper executes without errors - [ ] Tasks complete successfully - [ ] Build tests pass - [ ] Environment checks pass - [ ] n8n integration works via SSH - [ ] Webhook testing successful --- *Last Updated: 2025-12-02* *All scripts tested and working*