-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
Β·300 lines (274 loc) Β· 6.98 KB
/
install.sh
File metadata and controls
executable file
Β·300 lines (274 loc) Β· 6.98 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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
Usage:
curl -fsSL https://elephant.agentic-in.ai/install.sh | bash
bash install.sh [install|upgrade|health] [options]
Options:
--install-root PATH Durable install root. Default: $HOME/.elephant
--bin-dir PATH Directory that will receive the elephant launcher. Default: $HOME/.local/bin
--python PATH Python interpreter to use. Default: python3
--channel CHANNEL Package channel to install. One of: dev, stable. Default: dev
--pip-spec SPEC Explicit pip-installable package spec. Overrides --channel
--skip-run Skip the automatic elephant launch after install or upgrade
--skip-health Deprecated alias for --skip-run
--help Show this help text
Environment overrides:
ELEPHANT_INSTALL_CHANNEL
ELEPHANT_PIP_SPEC
ELEPHANT_PYTHON
EOF
}
command_name="install"
install_root="${HOME}/.elephant"
bin_dir="${HOME}/.local/bin"
python_bin="${ELEPHANT_PYTHON:-python3}"
channel="${ELEPHANT_INSTALL_CHANNEL:-dev}"
pip_spec="${ELEPHANT_PIP_SPEC:-}"
package_name="elephant-agent"
skip_run="0"
while [ "$#" -gt 0 ]; do
case "$1" in
install|upgrade|health)
command_name="$1"
shift
;;
--install-root)
install_root="$2"
shift 2
;;
--bin-dir)
bin_dir="$2"
shift 2
;;
--python)
python_bin="$2"
shift 2
;;
--channel)
channel="$2"
shift 2
;;
--pip-spec|--package-source)
pip_spec="$2"
shift 2
;;
--skip-run|--skip-health)
skip_run="1"
shift
;;
--help|-h)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
done
venv_dir="${install_root}/venv"
venv_python="${venv_dir}/bin/python"
state_dir="${install_root}/herd"
launcher_path="${bin_dir}/elephant"
require_command() {
if ! command -v "$1" >/dev/null 2>&1; then
echo "Missing required command: $1" >&2
exit 1
fi
}
has_uv() {
command -v uv >/dev/null 2>&1
}
require_python_version() {
if ! "$python_bin" - <<'PY'
import sys
sys.exit(0 if sys.version_info >= (3, 12) else 1)
PY
then
echo "Elephant Agent currently requires Python 3.12 or newer." >&2
exit 1
fi
}
ensure_config_yaml() {
mkdir -p "${state_dir}"
local config_path="${install_root}/config.yaml"
if [ ! -f "${config_path}" ]; then
cat > "${config_path}" <<EOF
runtime:
state_dir: ${state_dir}
default_profile_id: default
models:
default_provider_source: config
provider: null
sessions:
persist_system_prompts: true
persist_assistant_responses: true
max_history_rows: 200
skills:
enable_profile_overrides: true
external_dirs: ["~/.agents/skills"]
tools:
require_approval_for_risky: true
gateway:
enabled: false
state_dir: ${state_dir}
dashboard:
host: "127.0.0.1"
port: 4174
extensions: {}
EOF
fi
}
normalize_channel() {
case "$channel" in
dev|stable)
;;
*)
echo "Unsupported channel: $channel" >&2
exit 2
;;
esac
}
describe_package_selection() {
if [ -n "${pip_spec}" ]; then
printf '%s\n' "${pip_spec}"
return
fi
case "${channel}" in
dev)
printf '%s\n' "${package_name} (--pre, latest development release)"
;;
stable)
printf '%s\n' "${package_name} (latest stable release)"
;;
esac
}
ensure_runtime() {
mkdir -p "${install_root}"
if has_uv; then
if [ ! -x "${venv_python}" ]; then
uv venv "${venv_dir}" --python "${python_bin}"
fi
if [ -n "${pip_spec}" ]; then
uv pip install --python "${venv_python}" --upgrade "${pip_spec}"
else
case "${channel}" in
dev)
uv pip install --python "${venv_python}" --upgrade --prerelease=allow "${package_name}"
;;
stable)
uv pip install --python "${venv_python}" --upgrade "${package_name}"
;;
esac
fi
else
if [ ! -x "${venv_python}" ]; then
"${python_bin}" -m venv "${venv_dir}"
fi
"${venv_python}" -m pip install --upgrade pip setuptools wheel >/dev/null
if [ -n "${pip_spec}" ]; then
"${venv_python}" -m pip install --upgrade "${pip_spec}"
else
case "${channel}" in
dev)
"${venv_python}" -m pip install --upgrade --pre "${package_name}"
;;
stable)
"${venv_python}" -m pip install --upgrade "${package_name}"
;;
esac
fi
fi
ensure_browser_runtime
}
ensure_browser_runtime() {
if [ "${ELEPHANT_SKIP_BROWSER_INSTALL:-0}" = "1" ]; then
return
fi
if "${venv_python}" -m playwright install --only-shell chromium >/dev/null 2>&1; then
return
fi
echo "Warning: browser runtime install failed; browser tools will retry on first use." >&2
echo " To repair manually, run: ${venv_python} -m playwright install --only-shell chromium" >&2
}
write_launcher() {
mkdir -p "${bin_dir}"
cat > "${launcher_path}" <<EOF
#!/usr/bin/env bash
set -euo pipefail
install_root="\${ELEPHANT_HOME:-${install_root}}"
state_dir="\${ELEPHANT_HERD_DIR:-${state_dir}}"
venv_python="\${ELEPHANT_PYTHON:-${venv_python}}"
if [ ! -x "\${venv_python}" ]; then
echo "Elephant Agent runtime is missing: \${venv_python}" >&2
echo "Run the installer again." >&2
exit 1
fi
export ELEPHANT_HOME="\${install_root}"
export ELEPHANT_HERD_DIR="\${state_dir}"
exec "\${venv_python}" -m apps.launcher "\$@"
EOF
chmod +x "${launcher_path}"
}
run_health() {
if [ ! -x "${launcher_path}" ]; then
echo "Launcher not found: ${launcher_path}" >&2
echo "Run 'curl -fsSL https://elephant.agentic-in.ai/install.sh | bash' first." >&2
exit 1
fi
"${launcher_path}" status
}
run_launcher() {
if [ ! -x "${launcher_path}" ]; then
echo "Launcher not found: ${launcher_path}" >&2
echo "Run 'curl -fsSL https://elephant.agentic-in.ai/install.sh | bash' first." >&2
exit 1
fi
"${launcher_path}"
}
install_or_upgrade() {
require_command "${python_bin}"
require_python_version
normalize_channel
mkdir -p "${install_root}" "${state_dir}"
ensure_config_yaml
ensure_runtime
write_launcher
echo "Installed Elephant Agent CLI launcher"
echo " package: $(describe_package_selection)"
echo " install_root: ${install_root}"
echo " herd_dir: ${state_dir}"
echo " runtime_db: ${state_dir}/elephant.sqlite3"
echo " config: ${install_root}/config.yaml"
echo " runtime: ${venv_python}"
echo " launcher: ${launcher_path}"
if ! printf '%s' ":${PATH}:" | grep -Fq ":${bin_dir}:"; then
echo " path_hint: add ${bin_dir} to PATH to call 'elephant' directly"
fi
echo "Next commands"
echo " - elephant"
echo " - elephant init"
echo " - elephant status"
echo " - elephant wake"
echo " - elephant herd new nova"
if [ "${skip_run}" != "1" ]; then
echo
echo "Launching Elephant Agent"
run_launcher
fi
}
case "${command_name}" in
install|upgrade)
install_or_upgrade
;;
health)
run_health
;;
*)
echo "Unsupported command: ${command_name}" >&2
exit 2
;;
esac