SIGN IN SIGN UP

fix: honor per-command environment variables in just-bash sandbox run and spawn (#19871)

## Background

The published @ai-sdk/sandbox-just-bash package ignored per-command
environment variables: run and spawn returned empty output, and commands
such as mkdir exited successfully without creating the requested
directory.

## Root Cause

The session passed env to just-bash's outer runCommand execution while
running user commands through a nested bash -c. just-bash only
propagated exported variables to that nested shell; diagnostics
confirmed direct Bash.exec exposed the variable while the nested path
did not.

## Summary

Environment assignments are now passed as safely quoted positional
arguments and exported inside the nested shell before executing the
unchanged user command. A patch changeset was added.

## Testing

Added regression tests covering run and spawn environment access, values
containing shell syntax, environment scoping, and environment-based
directory creation.

## End-to-end Validation

- `pnpm -C examples/ai-functions exec tsx
src/reproduction/sandbox-just-bash-per-command-env.ts` via immutable
replay exited successfully; run, spawn, and mkdir all observed the
supplied environment.

## Related Issues

Fixes #19853

Closes #19856

---------

Co-authored-by: ai-sdk-factory <308175966+ai-sdk-factory@users.noreply.github.com>
Co-authored-by: gr2m <39992+gr2m@users.noreply.github.com>
A
ai-sdk-factory[bot] committed
24fcc9277778d7ded2642bcab923d87f72fe0846
Parent: cc9f6ce
Committed by GitHub <noreply@github.com> on 8/28/2026, 3:10:32 PM