-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·264 lines (224 loc) · 8.82 KB
/
install.sh
File metadata and controls
executable file
·264 lines (224 loc) · 8.82 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#!/bin/bash
#
# Trinity Deep Agent Platform - One-Line Installer
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/abilityai/trinity/main/install.sh | bash
#
# Or if you've already cloned the repo:
# ./install.sh
#
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
print_banner() {
echo -e "${BLUE}"
echo "╔════════════════════════════════════════════════════════════╗"
echo "║ ║"
echo "║ ████████╗██████╗ ██╗███╗ ██╗██╗████████╗██╗ ██╗ ║"
echo "║ ╚══██╔══╝██╔══██╗██║████╗ ██║██║╚══██╔══╝╚██╗ ██╔╝ ║"
echo "║ ██║ ██████╔╝██║██╔██╗ ██║██║ ██║ ╚████╔╝ ║"
echo "║ ██║ ██╔══██╗██║██║╚██╗██║██║ ██║ ╚██╔╝ ║"
echo "║ ██║ ██║ ██║██║██║ ╚████║██║ ██║ ██║ ║"
echo "║ ╚═╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝ ║"
echo "║ ║"
echo "║ Deep Agent Orchestration Platform ║"
echo "║ ║"
echo "╚════════════════════════════════════════════════════════════╝"
echo -e "${NC}"
}
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[OK]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
check_command() {
if command -v "$1" &> /dev/null; then
log_success "$1 is installed"
return 0
else
log_error "$1 is not installed"
return 1
fi
}
generate_secret_key() {
# Generate a secure random key
if command -v openssl &> /dev/null; then
openssl rand -hex 32
else
# Fallback for systems without openssl
head -c 32 /dev/urandom | xxd -p | tr -d '\n'
fi
}
generate_password() {
# Generate a random password (16 chars)
if command -v openssl &> /dev/null; then
openssl rand -base64 16 | tr -dc 'a-zA-Z0-9' | head -c 16
else
head -c 16 /dev/urandom | xxd -p | head -c 16
fi
}
# =============================================================================
# Main Installation
# =============================================================================
print_banner
echo ""
log_info "Starting Trinity installation..."
echo ""
# -----------------------------------------------------------------------------
# Step 1: Check prerequisites
# -----------------------------------------------------------------------------
log_info "Checking prerequisites..."
MISSING_DEPS=0
if ! check_command "docker"; then
MISSING_DEPS=1
fi
if ! check_command "git"; then
MISSING_DEPS=1
fi
# Check Docker Compose (v2 is bundled with Docker)
if docker compose version &> /dev/null; then
log_success "Docker Compose v2 is available"
else
log_error "Docker Compose is not available"
MISSING_DEPS=1
fi
# Check if Docker daemon is running
if docker info &> /dev/null; then
log_success "Docker daemon is running"
else
log_error "Docker daemon is not running. Please start Docker first."
MISSING_DEPS=1
fi
if [ $MISSING_DEPS -eq 1 ]; then
echo ""
log_error "Missing dependencies. Please install them first:"
echo " - Docker: https://docs.docker.com/get-docker/"
echo ""
exit 1
fi
echo ""
# -----------------------------------------------------------------------------
# Step 2: Clone or use existing repo
# -----------------------------------------------------------------------------
TRINITY_DIR=""
# Check if we're already in the trinity directory
if [ -f "docker-compose.yml" ] && [ -d "src/backend" ]; then
TRINITY_DIR="$(pwd)"
log_info "Using existing Trinity installation at $TRINITY_DIR"
else
# Clone the repository
TRINITY_DIR="$HOME/trinity"
if [ -d "$TRINITY_DIR" ]; then
log_warn "Directory $TRINITY_DIR already exists"
read -p "Remove and re-clone? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf "$TRINITY_DIR"
else
log_info "Using existing directory"
fi
fi
if [ ! -d "$TRINITY_DIR" ]; then
log_info "Cloning Trinity repository..."
git clone https://github.com/abilityai/trinity.git "$TRINITY_DIR"
log_success "Repository cloned to $TRINITY_DIR"
fi
fi
cd "$TRINITY_DIR"
# -----------------------------------------------------------------------------
# Step 3: Create .env file
# -----------------------------------------------------------------------------
log_info "Configuring environment..."
if [ -f ".env" ]; then
log_warn ".env file already exists, backing up to .env.backup"
cp .env .env.backup
fi
if [ ! -f ".env.example" ]; then
log_error ".env.example not found. Repository may be corrupted."
exit 1
fi
# Copy example and configure
cp .env.example .env
# Generate secure values
SECRET_KEY=$(generate_secret_key)
ADMIN_PASSWORD=$(generate_password)
# Update .env with generated values
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS sed syntax
sed -i '' "s/^SECRET_KEY=.*/SECRET_KEY=$SECRET_KEY/" .env
sed -i '' "s/^ADMIN_PASSWORD=.*/ADMIN_PASSWORD=$ADMIN_PASSWORD/" .env
else
# Linux sed syntax
sed -i "s/^SECRET_KEY=.*/SECRET_KEY=$SECRET_KEY/" .env
sed -i "s/^ADMIN_PASSWORD=.*/ADMIN_PASSWORD=$ADMIN_PASSWORD/" .env
fi
log_success "Environment configured"
echo ""
echo -e " ${YELLOW}Admin Credentials (save these!):${NC}"
echo -e " Username: ${GREEN}admin${NC}"
echo -e " Password: ${GREEN}$ADMIN_PASSWORD${NC}"
echo ""
# -----------------------------------------------------------------------------
# Step 4: Build base agent image
# -----------------------------------------------------------------------------
log_info "Building Trinity agent base image (this may take a few minutes)..."
if [ -f "scripts/deploy/build-base-image.sh" ]; then
chmod +x scripts/deploy/build-base-image.sh
./scripts/deploy/build-base-image.sh
log_success "Base image built"
else
log_error "build-base-image.sh not found"
exit 1
fi
# -----------------------------------------------------------------------------
# Step 5: Start services
# -----------------------------------------------------------------------------
log_info "Starting Trinity services..."
docker compose up -d
# Wait for services to be healthy
log_info "Waiting for services to start..."
sleep 5
# Check if services are running
if docker compose ps | grep -q "running"; then
log_success "Services started"
else
log_error "Some services failed to start. Check 'docker compose logs' for details."
exit 1
fi
# -----------------------------------------------------------------------------
# Done!
# -----------------------------------------------------------------------------
echo ""
echo -e "${GREEN}╔════════════════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ ║${NC}"
echo -e "${GREEN}║ Trinity installed successfully! ║${NC}"
echo -e "${GREEN}║ ║${NC}"
echo -e "${GREEN}╚════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e " ${BLUE}Web UI:${NC} http://localhost:3000"
echo -e " ${BLUE}API Docs:${NC} http://localhost:8000/docs"
echo ""
echo -e " ${YELLOW}Next Steps:${NC}"
echo -e " 1. Open http://localhost:3000 in your browser"
echo -e " 2. Login with admin / $ADMIN_PASSWORD"
echo -e " 3. Go to Settings and add your Anthropic API key"
echo -e " 4. Create your first agent!"
echo ""
echo -e " ${BLUE}Useful Commands:${NC}"
echo -e " cd $TRINITY_DIR"
echo -e " docker compose logs -f # View logs"
echo -e " docker compose down # Stop services"
echo -e " docker compose up -d # Start services"
echo ""