-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·171 lines (152 loc) · 5.33 KB
/
install.sh
File metadata and controls
executable file
·171 lines (152 loc) · 5.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
# Model Fallback Skill Installation Script
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Configuration
SKILL_NAME="model-fallback"
NANOBOT_HOME="${NANOBOT_HOME:-$HOME/.nanobot}"
SKILLS_DIR="$NANOBOT_HOME/workspace/skills"
SKILL_DIR="$SKILLS_DIR/$SKILL_NAME"
SCRIPT_DIR="$SKILL_DIR/scripts"
LOG_DIR="$NANOBOT_HOME/logs"
CONFIG_FILE="$NANOBOT_HOME/config.json"
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}Model Fallback Skill Installer${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
# Check if nanobot home exists
if [ ! -d "$NANOBOT_HOME" ]; then
echo -e "${RED}Error: Nanobot home directory not found at $NANOBOT_HOME${NC}"
echo "Please set NANOBOT_HOME environment variable or ensure nanobot is installed."
exit 1
fi
echo -e "${GREEN}✓${NC} Nanobot home: $NANOBOT_HOME"
# Create skills directory if it doesn't exist
if [ ! -d "$SKILLS_DIR" ]; then
echo -e "${YELLOW}Creating skills directory...${NC}"
mkdir -p "$SKILLS_DIR"
fi
# Check if skill is already installed
if [ -d "$SKILL_DIR" ]; then
echo -e "${YELLOW}⚠${NC} Skill already installed at $SKILL_DIR"
read -p "Do you want to reinstall? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Installation cancelled."
exit 0
fi
echo -e "${YELLOW}Removing existing installation...${NC}"
rm -rf "$SKILL_DIR"
fi
# Create skill directory structure
echo -e "${YELLOW}Creating skill directory structure...${NC}"
mkdir -p "$SCRIPT_DIR"
mkdir -p "$LOG_DIR"
# Copy skill files (assuming we're in the skill directory)
echo -e "${YELLOW}Copying skill files...${NC}"
if [ -f "SKILL.md" ]; then
cp SKILL.md "$SKILL_DIR/"
echo -e "${GREEN}✓${NC} Copied SKILL.md"
else
echo -e "${RED}Error: SKILL.md not found in current directory${NC}"
echo "Please run this script from the skill directory."
exit 1
fi
# Copy scripts
if [ -d "scripts" ]; then
cp scripts/*.py "$SCRIPT_DIR/"
chmod +x "$SCRIPT_DIR"/*.py
echo -e "${GREEN}✓${NC} Copied scripts"
else
echo -e "${RED}Error: scripts directory not found${NC}"
exit 1
fi
# Check Python 3 availability
echo ""
echo -e "${YELLOW}Checking Python 3...${NC}"
if ! command -v python3 &> /dev/null; then
echo -e "${RED}Error: Python 3 is required but not found${NC}"
exit 1
fi
echo -e "${GREEN}✓${NC} Python 3 found: $(python3 --version)"
# Check for required Python packages
echo -e "${YELLOW}Checking required packages...${NC}"
MISSING_PACKAGES=""
for package in requests; do
if ! python3 -c "import $package" 2>/dev/null; then
MISSING_PACKAGES="$MISSING_PACKAGES $package"
fi
done
if [ -n "$MISSING_PACKAGES" ]; then
echo -e "${YELLOW}⚠${NC} Missing packages:$MISSING_PACKAGES"
echo "Installing with pip3..."
pip3 install -q requests || {
echo -e "${RED}Error: Failed to install required packages${NC}"
echo "Please install manually: pip3 install requests"
exit 1
}
echo -e "${GREEN}✓${NC} Packages installed"
else
echo -e "${GREEN}✓${NC} All required packages available"
fi
# Check config file
echo ""
echo -e "${YELLOW}Checking nanobot configuration...${NC}"
if [ ! -f "$CONFIG_FILE" ]; then
echo -e "${YELLOW}⚠${NC} Config file not found at $CONFIG_FILE"
echo "You'll need to configure fallback settings manually."
else
echo -e "${GREEN}✓${NC} Config file found"
# Check if fallback is already configured
if python3 -c "import json; config = json.load(open('$CONFIG_FILE')); print('fallback' in str(config.get('agents', {}).get('defaults', {})))" 2>/dev/null | grep -q "True"; then
echo -e "${GREEN}✓${NC} Fallback already configured in config"
else
echo -e "${YELLOW}⚠${NC} Fallback not yet configured in config${NC}"
echo "See SKILL.md for configuration instructions."
fi
fi
# Check for wrapper script
echo ""
echo -e "${YELLOW}Checking for nanobot wrapper...${NC}"
if [ -f "$HOME/nanobot-wrapper.sh" ]; then
echo -e "${GREEN}✓${NC} Wrapper script found at $HOME/nanobot-wrapper.sh"
else
echo -e "${YELLOW}⚠${NC} Wrapper script not found${NC}"
echo "For automatic restarts, you should run nanobot with a wrapper script."
echo "See SKILL.md for wrapper script instructions."
fi
# Test scripts
echo ""
echo -e "${YELLOW}Testing scripts...${NC}"
if python3 "$SCRIPT_DIR/fallback-trigger.py" status &> /dev/null; then
echo -e "${GREEN}✓${NC} fallback-trigger.py is working"
else
echo -e "${YELLOW}⚠${NC} fallback-trigger.py test failed (may need config setup)"
fi
# Create log files
touch "$LOG_DIR/model-health.log"
touch "$LOG_DIR/model-fallback.log"
echo -e "${GREEN}✓${NC} Log files created"
# Summary
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}Installation Complete!${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo "Skill installed to: $SKILL_DIR"
echo ""
echo "Next steps:"
echo " 1. Configure fallback settings in $CONFIG_FILE"
echo " 2. Start the health check monitor:"
echo " python3 $SCRIPT_DIR/health-check.py start"
echo " 3. Check status:"
echo " python3 $SCRIPT_DIR/fallback-trigger.py status"
echo ""
echo "For detailed instructions, see: $SKILL_DIR/SKILL.md"
echo ""
echo "Logs will be written to: $LOG_DIR/"
echo ""