forked from madrzak/vidclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·80 lines (66 loc) · 2.89 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·80 lines (66 loc) · 2.89 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
#!/bin/bash
set -e
echo "⚡ VidClaw Setup"
echo ""
# Detect workspace path
DASHBOARD_DIR="$(cd "$(dirname "$0")" && pwd)"
NODE_BIN=$(which node 2>/dev/null || echo "/usr/bin/node")
if [ ! -f "$DASHBOARD_DIR/server.js" ]; then
echo "❌ server.js not found. Run this script from the dashboard directory."
exit 1
fi
# Install dependencies
echo "📦 Installing dependencies..."
cd "$DASHBOARD_DIR"
npm install --production=false
# Build frontend
echo "🔨 Building frontend..."
npm run build
# Create data directory
mkdir -p "$DASHBOARD_DIR/data"
# Install systemd service
echo "⚙️ Installing systemd service..."
sudo tee /etc/systemd/system/vidclaw.service > /dev/null << EOF
[Unit]
Description=VidClaw
After=network.target
[Service]
Type=simple
WorkingDirectory=$DASHBOARD_DIR
ExecStart=$NODE_BIN server.js
Restart=always
RestartSec=3
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now vidclaw
# Add task queue check to HEARTBEAT.md
WORKSPACE_DIR="$(dirname "$DASHBOARD_DIR")"
HEARTBEAT="$WORKSPACE_DIR/HEARTBEAT.md"
if [ -f "$HEARTBEAT" ] && grep -q "Task Queue Check" "$HEARTBEAT" 2>/dev/null; then
echo "📋 HEARTBEAT.md already has task queue config, skipping."
else
echo "📋 Adding task queue check to HEARTBEAT.md..."
cat >> "$HEARTBEAT" << 'HEARTBEAT_BLOCK'
## Task Queue Check
0. Record heartbeat: POST http://localhost:3333/api/heartbeat via exec (curl -X POST)
1. Check for stuck in-progress tasks: GET http://localhost:3333/api/tasks and look for status "in-progress"
2. For each in-progress task: check if a sub-agent completed the work (use sessions_list to find recent sub-agents, check their last message for completion). If done, POST to http://localhost:3333/api/tasks/{id}/complete with { "result": "<summary from sub-agent>" }. If the task has been in-progress for over 10 minutes with no active sub-agent, POST with { "error": "Task timed out — no active sub-agent found" }.
3. Fetch http://localhost:3333/api/tasks/queue via exec (curl)
4. If any tasks returned, pick the FIRST one (highest priority)
5. Mark it as picked up: POST http://localhost:3333/api/tasks/{id}/pickup
6. Spawn a sub-agent with the task: use sessions_spawn with the task title + description as the prompt. If a skill is assigned, tell the sub-agent to read that skill's SKILL.md first.
7. When the sub-agent completes, POST to http://localhost:3333/api/tasks/{id}/complete with { "result": "<summary of what was done>" } or { "error": "<what went wrong>" } if it failed
8. Only process ONE task per heartbeat to avoid overload
HEARTBEAT_BLOCK
fi
echo ""
echo "✅ Dashboard installed and running!"
echo ""
echo " Local: http://localhost:3333"
echo " Remote: ssh -L 3333:localhost:3333 $(whoami)@$(hostname -I | awk '{print $1}')"
echo ""
echo " Manage: sudo systemctl {start|stop|restart|status} vidclaw"
echo " Logs: journalctl -u vidclaw -f"