Skip to content

[Feature]: let hooks receive selected environment variables (allowlist) so orchestrators can attribute events #4

Open

Description

@homesh-dev

Use case

I'm integrating Muse Code into Orca (an AI orchestrator that hosts CLI agents side-by-side, each in its own terminal pane/worktree, with live working/waiting/done status per pane). Orca installs managed status hooks (UserPromptSubmit/PreToolUse/PostToolUse/PermissionRequest/Stop) and attributes each event to a pane via an env var (ORCA_PANE_KEY) stamped into that pane's environment — the same mechanism Claude Code integrations use.

Problem

Muse Code runs hooks with a cleared environment. Verified against muse 1.0.3: a hook's environment contains only _ HOME LANG LOGNAME OLDPWD PATH PWD SHELL SHLVL TERM TMPDIR USER — every custom variable (including the pane identity) is stripped. The hook fires and its stdin payload is Claude-compatible and complete (hook_event_name, session_id, prompt, last_assistant_message, …), but the event cannot be attributed to a pane: cwd is shared across panes in one worktree, and matching on prompt text risks attributing status to the wrong pane, which is worse than no status.

Request

A per-hook (or settings-level) environment passthrough, e.g. an allowedEnvVars list on hook entries as Claude Code's HTTP hooks have, so orchestrators can pass a pane/session token through to their own hooks without weakening the cleared-environment default for everything else.

Verification notes

  • muse 1.0.3 (1.0.3-R2198.1), macOS arm64; hooks fire fine via both the settings.json hooks block and managed_hooks_path (same schema, no trust step — thank you).
  • muse hooks management CLI is absent in this binary, so there is currently no channel at all to convey per-pane identity to a hook.

Activity

  1. homesh-dev commented on Sep 22, 2026

    @homesh-dev
    Author

    Update after testing Muse Code 1.3.0: this appears fixed for managed hooks.

    Using managed_hooks_path together with the new managed_hooks_env_vars setting, we verified that allowlisted values including ORCA_AGENT_HOOK_TOKEN, ORCA_AGENT_HOOK_ENDPOINT, ORCA_PANE_KEY, ORCA_TAB_ID, and ORCA_WORKTREE_ID reach the managed hook process. Real UserPromptSubmit and Stop payloads were successfully attributed to the correct Orca pane.

    This resolves Orca’s managed-hook use case from #19188. We have not separately tested environment passthrough for inline user-defined hooks, so that portion remains unverified if parity with plain settings hooks is part of this issue’s scope.

  2. mjdouglas commented on Oct 2, 2026

    @mjdouglas
    Contributor

    (Originally posted 2026-09-16; reposted with internal references removed.)

    This is tracked internally: a per-hook environment allowlist (managedEnvVars) is being implemented for managed hooks right now. We are confirming that the same allowlist is available to plain user-settings hooks, which is your case; if it turns out to be scoped to managed configuration only, a follow-up will cover the settings.json path. Your verification notes on 1.0.3 are accurate: hooks currently run with a cleared environment.

  3. mjdouglas commented on Oct 2, 2026

    @mjdouglas
    Contributor

    (Originally posted 2026-10-01; reposted with internal references removed.)

    Thanks for testing this on 1.3.0 and confirming the managed-hook path works for Orca. You're right about the other part: managed_hooks_env_vars applies only to hooks loaded from managed_hooks_path. Inline hooks in settings.json and project hooks still get the cleared environment. Parity for those is tracked internally.

    Until that lands, keep the hooks in a file referenced by managed_hooks_path. That works from your own settings.json, as you set it up. I'm leaving this open for the remaining part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions