You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
inject=: create_sandbox(inject={"api.example.com": {"Authorization": "Bearer ..."}}) gives the sandbox a credential it can use but not read. The egress proxy ends the sandbox's HTTPS to that host, sets those headers on every request (replacing one of the same name the sandbox sent) and sends it on over TLS of its own, with the host's real certificate verified. The sandbox trusts a certificate authority made for it on your machine, whose private key is dropped after it signs the one certificate the proxy needs; it is told through SSL_CERT_FILE, REQUESTS_CA_BUNDLE, CURL_CA_BUNDLE, GIT_SSL_CAINFO and NODE_EXTRA_CA_CERTS. The credential is not in the sandbox's environment, files or command lines. It is in the proxy container's environment, so whoever can run docker inspect on the host can read it. Plain host names only, https:// on port 443 only (http:// to such a host is refused), one request per connection, no HTTP/2 or websockets to those hosts. A request is only given a credential if it has a path, one Host header naming the host and no folded headers. Needs pip install 'agvisor[inject]' (the cryptography package) and the image needs a CA bundle. Same restrictions as egress=. AGVISOR_INJECT sets it for the MCP server. The README Security section has an entry for it
agvisor.aio: AsyncSandbox, AsyncJob, create_sandbox(), list_sandboxes() and prune_egress() for asyncio code, with the arguments, results and errors of the synchronous ones; every blocking call runs in a worker thread, so calls run side by side. async with AsyncSandbox(...) starts and stops the sandbox. Cancelling an await stops waiting, not the command. exec(on_output=) can be a plain function or an async def
Pool(size, image, **create_sandbox_args): keeps size started sandboxes ready, so acquire() doesn't wait for docker run, and starts a replacement in the background. A spare that expired or fails a health check is skipped. lifetime= or idle_ttl= is required, name=, owner= and gui= are refused. close() or with stops the spares
snapshot() pauses a running sandbox while its data dir is copied, so the snapshot is the data dir at one moment, not a mix of before and after a write. Its processes stop for those few seconds and an exec() meanwhile fails; a running sandbox that can't be paused raises instead of being copied
MCP server, with AGVISOR_NAME: snapshot(tag) and restore(tag) take a tag (no tag still means checkpoint), and there are two new tools, list_snapshots() and delete_snapshot(tag). AGVISOR_SNAPSHOTS (default 3) limits how many snapshots exist at once, since each one is a full copy of /workspace
examples/08_browser.py: a headless Chromium (Playwright's image) opens a page and takes a screenshot under gVisor, with a README section on Limits(shm=), the network and the matching Playwright version. The example is run by the gvisor CI job with the others
README: the two relative links are absolute (they were dead on PyPI), and the intro lists what the library has now
Tested on real gVisor (runsc 20261026.0, GitHub's Ubuntu runner): tests/test_gvisor_aio.py, test_gvisor_pool.py, test_gvisor_snapshot.py (a copy of a running writer spans one pass of it with the pause, several without), test_mcp_stdio.py (named mode), test_inject_gvisor.py and test_inject_mcp_stdio.py (against api.anthropic.com, which answers differently with and without the injected key), and the browser example. inject= was run with Python's urllib only; curl, git, Node and Go were not run against it. Not tested: Pool or aio over host="ssh://...", a browser together with egress=