Skip to content

fix: run extension setup_hook during install via host agent#740

Merged
Lightheartdevs merged 2 commits intoLight-Heart-Labs:mainfrom
yasinBursali:fix/run-setup-hook-on-install
Apr 3, 2026
Merged

fix: run extension setup_hook during install via host agent#740
Lightheartdevs merged 2 commits intoLight-Heart-Labs:mainfrom
yasinBursali:fix/run-setup-hook-on-install

Conversation

@yasinBursali
Copy link
Copy Markdown
Contributor

What

Extensions declaring setup_hook in their manifest now have their hook script executed during install, before the container is started.

Why

Extensions with setup_hook: setup.sh (jupyter, dify, flowise, paperless-ngx, frigate, open-interpreter, weaviate, librechat, anythingllm — 9 total) generate required environment variables. The install flow was skipping this step, causing docker compose up to fail with missing required variables (e.g. JUPYTER_TOKEN must be set) and blocking ALL user extensions.

How

  • Added /v1/extension/setup-hook POST endpoint to the host agent that reads the manifest, validates the hook path (path traversal + file checks), and runs bash <hook> <INSTALL_DIR> <GPU_BACKEND>
  • Added _call_agent_setup_hook() helper in extensions.py, called after file copy but before container start
  • Best-effort: if host agent is unreachable, install proceeds with restart_required flag

Testing

  • Python syntax verified on both files
  • Security: path traversal blocked via resolve() + relative_to(), type validation on manifest fields, subprocess uses list form (no injection)

Review

Critique Guardian: APPROVED (after fixing narrowed exception types, added type validation, removed dead symlink check)

Platform Impact

  • macOS: bash available natively, subprocess.run portable
  • Linux: Same
  • Windows/WSL2: Same — host agent runs in WSL2 environment

Note: This PR touches host agent area also modified by #737. Rebase needed after #737 merges.

🤖 Generated with Claude Code

yasinBursali and others added 2 commits April 3, 2026 03:11
Extensions declaring setup_hook in their manifest (jupyter, dify, etc.)
need host-side scripts run to generate required environment variables.
The install flow was skipping this step, causing docker compose up to
fail with missing required variables and blocking all user extensions.

Adds /v1/extension/setup-hook endpoint to the host agent that reads
the extension manifest and executes the setup hook script. The
dashboard-api now calls this endpoint after copying files but before
starting the container.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Narrow exception handler from (OSError, Exception) to (OSError, yaml.YAMLError)
- Add type validation for setup_hook manifest value (must be string)
- Remove dead symlink check after path resolve()

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Lightheartdevs Lightheartdevs merged commit a2137dc into Light-Heart-Labs:main Apr 3, 2026
20 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants