feat(bash): add env parameter for setting environment variables#21756
Open
taxilian wants to merge 3 commits intoanomalyco:devfrom
Open
feat(bash): add env parameter for setting environment variables#21756taxilian wants to merge 3 commits intoanomalyco:devfrom
taxilian wants to merge 3 commits intoanomalyco:devfrom
Conversation
1 task
Add optional `env` parameter to the bash tool that allows passing environment variables to the spawned process. This enables plugins to inject environment variables like AGENT_MODE and AGENT_ID to track whether commands are running in primary or subagent sessions. Changes: - Add `env` parameter to bash tool schema (z.record(z.string(), z.string())) - Merge env vars with process.env in spawn call - Add tests for single and multiple environment variables
Use Bun's process.env instead of shell-specific echo syntax for cross-platform support - Replace Unix $VAR syntax with bun -e "console.log(process.env.VAR)" - Use existing test helpers (bin, evalarg) for proper quoting - Tests now pass on Windows regardless of shell type
43d2eb8 to
43840f7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #21753
Type of change
What does this PR do?
Add optional
envparameter to the bash tool that allows passing environment variables to spawned processes. This enables plugins to inject variables like AGENT_MODE and AGENT_ID to track whether commands run in primary or subagent sessions. The env vars are merged with the shell environment.This is a replacement for the previously closed PR #11068 / issue #11065 - the need persists and workarounds continue to cause issues.
How did you verify your code works?
Added tests in bash.test.ts for single and multiple environment variables.
Screenshots / recordings
N/A - no UI changes
Checklist