mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-18 04:41:56 +00:00
feat(install): add --ensure and --postinstall modes for targeted dep bootstrap
Adds --ensure DEPS for pip-runtime dep installation and --postinstall for pip users who want the full post-install experience without cloning.
This commit is contained in:
parent
384ec9684e
commit
cc07e30f45
1 changed files with 105 additions and 1 deletions
|
|
@ -71,6 +71,8 @@ USE_VENV=true
|
|||
RUN_SETUP=true
|
||||
SKIP_BROWSER=false
|
||||
BRANCH="main"
|
||||
ENSURE_DEPS=""
|
||||
POSTINSTALL_MODE=false
|
||||
|
||||
# Detect non-interactive mode (e.g. curl | bash)
|
||||
# When stdin is not a terminal, read -p will fail with EOF,
|
||||
|
|
@ -109,6 +111,14 @@ while [[ $# -gt 0 ]]; do
|
|||
HERMES_HOME="$2"
|
||||
shift 2
|
||||
;;
|
||||
--ensure)
|
||||
ENSURE_DEPS="$2"
|
||||
shift 2
|
||||
;;
|
||||
--postinstall)
|
||||
POSTINSTALL_MODE=true
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Hermes Agent Installer"
|
||||
echo ""
|
||||
|
|
@ -133,6 +143,12 @@ while [[ $# -gt 0 ]]; do
|
|||
echo " (default /root/.hermes). This keeps Docker bind-mounted volumes"
|
||||
echo " small and ensures the command is on PATH for all shells."
|
||||
echo " Existing installs at \$HERMES_HOME/hermes-agent are preserved in-place."
|
||||
echo " --ensure DEPS Install only specified deps (comma-separated)"
|
||||
echo " Supported: node, browser, ripgrep, ffmpeg"
|
||||
echo " Does NOT clone repo or create venv"
|
||||
echo " --postinstall Run post-install setup only (for pip users)"
|
||||
echo " Installs optional deps + runs hermes setup"
|
||||
echo " Does NOT clone repo or create venv"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
|
|
@ -1872,6 +1888,88 @@ print_success() {
|
|||
fi
|
||||
}
|
||||
|
||||
ensure_mode() {
|
||||
detect_os
|
||||
|
||||
IFS=',' read -ra DEPS <<< "$ENSURE_DEPS"
|
||||
for dep in "${DEPS[@]}"; do
|
||||
dep="$(echo "$dep" | tr -d '[:space:]')"
|
||||
case "$dep" in
|
||||
node)
|
||||
check_node
|
||||
;;
|
||||
browser)
|
||||
check_node
|
||||
if [ "$HAS_NODE" = true ]; then
|
||||
DETECTED_BROWSER_EXECUTABLE="$(find_system_browser 2>/dev/null || true)"
|
||||
if [ -z "$DETECTED_BROWSER_EXECUTABLE" ]; then
|
||||
log_info "Installing agent-browser + Chromium..."
|
||||
npm_bin="$(command -v npm 2>/dev/null || echo "")"
|
||||
if [ -n "$npm_bin" ]; then
|
||||
local agent_browser_dir="$HERMES_HOME/node_modules"
|
||||
mkdir -p "$agent_browser_dir"
|
||||
"$npm_bin" install --prefix "$HERMES_HOME" agent-browser 2>/dev/null || true
|
||||
npx playwright install chromium 2>/dev/null || true
|
||||
fi
|
||||
else
|
||||
log_success "System browser found: $DETECTED_BROWSER_EXECUTABLE"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
ripgrep)
|
||||
if ! command -v rg &>/dev/null; then
|
||||
HAS_RIPGREP=false
|
||||
HAS_FFMPEG=true
|
||||
install_system_packages
|
||||
fi
|
||||
;;
|
||||
ffmpeg)
|
||||
if ! command -v ffmpeg &>/dev/null; then
|
||||
HAS_FFMPEG=false
|
||||
HAS_RIPGREP=true
|
||||
install_system_packages
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
log_warn "Unknown dependency: $dep"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
postinstall_mode() {
|
||||
print_banner
|
||||
detect_os
|
||||
|
||||
log_info "Post-install mode: setting up Hermes for pip install"
|
||||
|
||||
check_node
|
||||
check_network_prerequisites
|
||||
install_system_packages
|
||||
|
||||
if [ "$HAS_NODE" = true ] && [ "$SKIP_BROWSER" = false ]; then
|
||||
DETECTED_BROWSER_EXECUTABLE="$(find_system_browser 2>/dev/null || true)"
|
||||
if [ -z "$DETECTED_BROWSER_EXECUTABLE" ]; then
|
||||
log_info "Installing browser engine..."
|
||||
npm_bin="$(command -v npm 2>/dev/null || echo "")"
|
||||
if [ -n "$npm_bin" ]; then
|
||||
npx playwright install chromium 2>/dev/null || true
|
||||
fi
|
||||
else
|
||||
log_success "System browser found: $DETECTED_BROWSER_EXECUTABLE"
|
||||
fi
|
||||
fi
|
||||
|
||||
HERMES_CMD="$(command -v hermes 2>/dev/null || echo "")"
|
||||
if [ -n "$HERMES_CMD" ]; then
|
||||
log_info "Running hermes setup..."
|
||||
"$HERMES_CMD" setup
|
||||
else
|
||||
log_warn "hermes command not found on PATH"
|
||||
log_info "Try: python -m hermes_cli.main setup"
|
||||
fi
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Main
|
||||
# ============================================================================
|
||||
|
|
@ -1900,4 +1998,10 @@ main() {
|
|||
print_success
|
||||
}
|
||||
|
||||
main
|
||||
if [ -n "$ENSURE_DEPS" ]; then
|
||||
ensure_mode
|
||||
elif [ "$POSTINSTALL_MODE" = true ]; then
|
||||
postinstall_mode
|
||||
else
|
||||
main
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue