Skip to content

feat: add missing sandbox type definitions for CLI settings parity#862

Open
chatterjeesrijeet wants to merge 1 commit intoanthropics:mainfrom
chatterjeesrijeet:fix/sandbox-type-parity
Open

feat: add missing sandbox type definitions for CLI settings parity#862
chatterjeesrijeet wants to merge 1 commit intoanthropics:mainfrom
chatterjeesrijeet:fix/sandbox-type-parity

Conversation

@chatterjeesrijeet
Copy link
Copy Markdown

Summary

  • Adds SandboxFilesystemConfig TypedDict with allowWrite, denyWrite, denyRead, allowRead, and allowManagedReadPathsOnly fields
  • Extends SandboxNetworkConfig with allowMachLookup, allowedDomains, deniedDomains, and allowManagedDomainsOnly fields
  • Extends SandboxSettings with failIfUnavailable, filesystem, and enableWeakerNetworkIsolation fields
  • Exports SandboxFilesystemConfig in the public API
  • All new fields are optional (total=False) — fully backward compatible

Motivation

The Python SDK's sandbox types were behind the TypeScript SDK and the documented CLI settings schema. The CLI already supports filesystem configuration, domain-based network rules, and other sandbox settings, but Python SDK users had no way to configure them.

This is relevant to #861 — users in containerized environments (e.g. AWS Bedrock AgentCore) need filesystem config options (like allowRead for /etc/hosts and /etc/resolv.conf) to work around bwrap sandbox DNS resolution issues.

Test plan

  • 3 new tests added: test_sandbox_filesystem_config, test_sandbox_network_domains, test_sandbox_new_settings_fields
  • All 84 existing tests continue to pass
  • No transport code changes needed — TypedDict fields automatically serialize through _build_settings_value

🤖 Generated with Claude Code

The Python SDK's sandbox configuration types were significantly behind
the TypeScript SDK and the documented CLI settings schema. This commit
brings them to parity by adding types and fields that the CLI already
supports but the Python SDK did not expose.

Changes:

1. New SandboxFilesystemConfig TypedDict:
   - allowWrite: additional writable paths for sandboxed commands
   - denyWrite: paths where sandboxed commands cannot write
   - denyRead: paths where sandboxed commands cannot read
   - allowRead: re-allow reading specific paths within denyRead regions
   - allowManagedReadPathsOnly: restrict to managed allowRead entries

2. Extended SandboxNetworkConfig with missing fields:
   - allowMachLookup: XPC/Mach service names (macOS, supports * prefix)
   - allowedDomains: outbound domains (supports wildcards like *.example.com)
   - deniedDomains: blocked domains (takes precedence over allowedDomains)
   - allowManagedDomainsOnly: restrict to managed allowedDomains entries

3. Extended SandboxSettings with missing fields:
   - failIfUnavailable: exit with error if sandbox deps are unavailable
   - filesystem: SandboxFilesystemConfig for filesystem restrictions
   - enableWeakerNetworkIsolation: allow system TLS access (macOS only)

4. Exported SandboxFilesystemConfig in public API (__init__.py / __all__)

5. Added 3 new tests:
   - test_sandbox_filesystem_config: verifies filesystem config passthrough
   - test_sandbox_network_domains: verifies domain-based network config
   - test_sandbox_new_settings_fields: verifies failIfUnavailable and
     enableWeakerNetworkIsolation

All new fields use total=False (optional), so this is fully backward
compatible with existing code.

Relates to anthropics#861 — users in containerized environments (e.g. AWS Bedrock
AgentCore) need filesystem and network config options to work around
bwrap sandbox DNS resolution issues where /etc/hosts is not mounted.

Co-Authored-By: Claude Opus 4.6 <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.

1 participant