Add `OpenSandbox(network_policy=)` and `OpenSandboxBackend(credential_proxy=)`, passing OpenSandbox's egress options through

Merged
AD
18d ago
+372-17

Closes #13593

Stack: #13587 E2B network → #13589 boxd secrets → #13590 Daytona secrets → #13591 OpenSandbox network_policy/credential_proxy → #13592 clai2 /sandbox. Each harness PR stands alone; clai2 uses the first two.

Why we make these changes

Part of #13593. An agent in a cloud sandbox needs credentials (a GitHub token for git push and gh) that its commands can use but not read, so a prompt injection cannot copy them out. OpenSandbox's Credential Vault keeps credentials in the server's egress sidecar and adds them to requests for bound hosts. This PR passes that option through unchanged, under the SDK's own name, so users write what the provider documents.

New public surface

  • OpenSandbox(network_policy=) and OpenSandboxBackend(network_policy=, credential_proxy=): the SDK's NetworkPolicy and CredentialProxyConfig, passed to Sandbox.create.
  • credential_proxy is on the backend only. The vault must be filled after the sandbox exists and before the agent's first command, which only a backend you create yourself allows; on the capability it would make a sandbox with an empty vault.

User-visible behavior

Before: no way to give the sandbox's commands a credential they cannot read. After: the new docs section "Give commands a credential they cannot read" shows it for a GitHub token. Without the option, sandbox creation is unchanged.

Verification

  • tests/harness/opensandbox_sandbox/test_backend.py::test_network_policy_and_credential_proxy_pass_through, tests/harness/opensandbox_sandbox/test_opensandbox_sandbox.py::test_network_policy_reaches_creation
  • The sidecar replacing a header the sandbox sent is from its source: components/egress/mitmscripts/system.py deletes the header, then sets the credential.
  • Live, with a dummy token, on a local opensandbox-server 1.2.1 in dns+nft mode with the SDK's CredentialProxyConfig and a deny-by-default NetworkPolicy:
    • an HTTPS request carrying Authorization: token placeholder reached the echo host as Bearer <dummy>;
    • plain HTTP kept the placeholder, and a host not on the allow list was blocked;
    • the sandbox trusted the server's certificate with no setup, and mode = "dns" refused credential_proxy;
    • the echo host's response showed the real value, so the docs say to list only hosts that never send headers back.
  • Not run live: the same through OpenSandboxBackend (the pass-through is covered by the tests above).

What changes for existing users

Nothing.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.