Skip to content

feat(shell): add env parameter to /v1/shell/exec endpoint#169

Open
Ricardo-M-L wants to merge 1 commit intoagent-infra:mainfrom
Ricardo-M-L:feat/shell-exec-env-params
Open

feat(shell): add env parameter to /v1/shell/exec endpoint#169
Ricardo-M-L wants to merge 1 commit intoagent-infra:mainfrom
Ricardo-M-L:feat/shell-exec-env-params

Conversation

@Ricardo-M-L
Copy link
Copy Markdown

Summary

  • Add optional env parameter to the /v1/shell/exec endpoint request model, allowing callers to pass environment variables that will be merged with the existing process environment during command execution
  • Similar to Python's subprocess.run(env=...) interface, as requested in the issue
  • Updates OpenAPI spec, Python SDK (sync + async clients), and JS SDK type definitions
  • Adds comprehensive test suites for both Python (12 tests) and JS (11 tests) SDKs

Changes

File Description
website/docs/public/v1/openapi.json Add nullable env field to ShellExecRequest schema
sdk/python/agent_sandbox/shell/raw_client.py Add env param to sync/async RawShellClient.exec_command()
sdk/python/agent_sandbox/shell/client.py Add env param to sync/async ShellClient.exec_command()
sdk/js/src/api/resources/shell/client/requests/ShellExecRequest.ts Add env field to TS interface
sdk/js/__test__/shell-exec-env.test.ts JS SDK tests for env parameter
sdk/python/tests/test_shell_exec_env.py Python SDK tests for env parameter

API Usage

# Python SDK
client.shell.exec_command(
    command="echo $MY_VAR",
    env={"MY_VAR": "hello", "DB_HOST": "localhost"}
)
// JS SDK
await client.shell.execCommand({
    command: "echo $MY_VAR",
    env: { MY_VAR: "hello", DB_HOST: "localhost" }
});

Test plan

  • Python SDK: 12 tests passing (signature, serialization, delegation, OpenAPI spec validation)
  • JS SDK: 11 tests passing (type checks, source verification, JSON serialization)
  • All existing tests continue to pass
  • Server-side implementation to handle the env field in the request body

Fixes #165

🤖 Generated with Claude Code

Add optional `env` parameter to the ShellExecRequest model, allowing
callers to pass environment variables that will be merged with the
existing process environment during command execution. Similar to
Python's subprocess.run env parameter.

Changes:
- OpenAPI spec: add nullable env field (object with string values)
- Python SDK: add env param to sync/async ShellClient and RawShellClient
- JS SDK: add env field to ShellExecRequest interface
- Tests: comprehensive test suites for both Python and JS SDKs

Fixes agent-infra#165

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

/v1/shell/exec 增加环境变量参数

1 participant