-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
104 lines (88 loc) · 2.77 KB
/
Copy pathinstall.sh
File metadata and controls
104 lines (88 loc) · 2.77 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
#!/usr/bin/env bash
set -euo pipefail
PLUGIN_ID="perspective-agents"
PLUGIN_DIR="${OPENCLAW_PLUGIN_DIR:-$HOME/.openclaw/plugins/$PLUGIN_ID}"
RAW_BASE="${PERSPECTIVE_AGENTS_RAW_BASE:-https://raw.githubusercontent.com/Techopolis/Perspective-Agents-OpenClaw-Plugin/main}"
need_cmd() {
command -v "$1" >/dev/null 2>&1
}
run_as_root() {
if [ "$(id -u)" -eq 0 ]; then
"$@"
elif need_cmd sudo; then
sudo "$@"
else
echo "This installer needs root privileges for: $*" >&2
echo "Run it as root or install sudo." >&2
exit 1
fi
}
install_node_deps() {
if need_cmd node; then
return
fi
if need_cmd apt-get; then
run_as_root apt-get update
run_as_root apt-get install -y nodejs
else
echo "Node.js is required. Install Node.js, then rerun this installer." >&2
exit 1
fi
}
fetch() {
local url="$1"
local dest="$2"
if need_cmd curl; then
curl -fsSL "$url" -o "$dest"
elif need_cmd wget; then
wget -qO "$dest" "$url"
else
echo "curl or wget is required." >&2
exit 1
fi
}
install_node_deps
mkdir -p "$PLUGIN_DIR/skills/perspective-agents-setup" "$PLUGIN_DIR/scripts" "$HOME/.local/bin"
fetch "$RAW_BASE/openclaw.plugin.json" "$PLUGIN_DIR/openclaw.plugin.json"
fetch "$RAW_BASE/index.js" "$PLUGIN_DIR/index.js"
fetch "$RAW_BASE/skills/perspective-agents-setup/SKILL.md" "$PLUGIN_DIR/skills/perspective-agents-setup/SKILL.md"
fetch "$RAW_BASE/scripts/setup-link.mjs" "$PLUGIN_DIR/scripts/setup-link.mjs"
chmod 755 "$PLUGIN_DIR/scripts/setup-link.mjs"
rm -f "$PLUGIN_DIR/setup-link.mjs"
ln -sf "$PLUGIN_DIR/scripts/setup-link.mjs" "$HOME/.local/bin/perspective-agents-setup"
if need_cmd qrencode; then
:
elif need_cmd apt-get; then
run_as_root apt-get update
run_as_root apt-get install -y qrencode || true
fi
node - "$PLUGIN_DIR" <<'NODE'
const fs = require('fs');
const os = require('os');
const path = require('path');
const pluginDir = process.argv[2];
const configDir = path.join(os.homedir(), '.openclaw');
const configPath = path.join(configDir, 'openclaw.json');
fs.mkdirSync(configDir, { recursive: true });
let config = {};
try {
config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
} catch {}
config.plugins ??= {};
config.plugins.load ??= {};
config.plugins.load.paths = Array.isArray(config.plugins.load.paths) ? config.plugins.load.paths : [];
if (!config.plugins.load.paths.includes(pluginDir)) {
config.plugins.load.paths.push(pluginDir);
}
config.plugins.entries ??= {};
config.plugins.entries['perspective-agents'] ??= {};
config.plugins.entries['perspective-agents'].enabled = true;
fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`);
NODE
echo
echo "Perspective Agents OpenClaw plugin installed:"
echo " $PLUGIN_DIR"
echo
echo "Restart OpenClaw, then run:"
echo " perspective-agents-setup"
echo