Skip to main content

Independent project: Cageforge is not affiliated with, sponsored by, or endorsed by OpenAI.

Cageforge Python binding

cageforge provides a typed Python API for the Cageforge sandbox on Linux, macOS, and Windows. It loads the selected profile and uses the native backend provided by the installed wheel.

The package is built with PyO3 and maturin. The published package name is cageforge.

Use the published cageforge crate as the project-level reference for the sandbox API. See the shared configuration guide for the complete Linux/macOS/Windows profile shape, including the resources a first restricted launch must declare separately from local IPC.

Install

python -m pip install cageforge

Each wheel contains the Python extension and the native resources for one operating-system and architecture target. Linux wheels include the pinned Bubblewrap resource. Applications do not need to install a separate native helper or provide a host-specific resource path.

The release also includes free-threaded CPython 3.14 wheels for each supported operating-system and architecture target. Standard CPython 3.10 and newer builds use the stable abi3 wheel for their platform.

Quick start with the repository smoke profile

The repository already contains one runnable profile for each supported OS. This example selects the profile for the current host and uses Cageforge.from_toml_file to run it. Run it from the repository root:

import platform
from pathlib import Path

from cageforge import Cageforge, PermissionApprover, RuntimeContext

platform_name = platform.system().lower()
profile_name = {
    "linux": "linux",
    "darwin": "macos",
    "windows": "windows",
}[platform_name]
profile = (
    Path("crates")
    / "cageforge-config"
    / "examples"
    / "runnable"
    / profile_name
    / "smoke.toml"
).resolve()

context = RuntimeContext(profile.parent)
toml = profile.read_bytes().decode("utf-8")
Cageforge.check_toml(toml, context=context)
request = Cageforge.permission_request(toml, context=context)
grant = PermissionApprover().approve(request)
with Cageforge.from_toml_file(
    profile, context=context, grant=grant, request=request
) as runtime:
    with runtime.launch() as process:
        print(process.read_stdout(4096).decode().strip())
        assert process.wait().exit_code == 0

The three profiles are linux/smoke.toml, macos/smoke.toml, and windows/smoke.toml. They use the current Cageforge TOML schema, include minimal read access, declare a workspace root, allow writes to workspace-root, and disable the network. The Windows profile uses cmd.exe; the POSIX profiles use /bin/echo.

Profiles with approval.mode = "preflight" require a trusted host grant before launch. PermissionRequest is descriptive; only PermissionApprover can issue the opaque PermissionGrant. A grant never changes an already-running process. When permission_request is called with custom identity or digest arguments, pass that same PermissionRequest to from_toml or from_toml_file; the runtime then authorizes the grant against the exact identity that was approved.

PermissionRequest.local_ipc() returns frozen typed LocalIpcEndpoint values. Their kind is unix_socket or windows_named_pipe, and value is the validated native endpoint. The platform overlay selects which endpoint kind is present; a Windows named-pipe request remains fail-closed if the native backend cannot prove the required isolation.

Persistent grants and store paths

The permission store is host state, not TOML policy. Choose its absolute path explicitly and use a persistent grant when the approval should survive a new process:

from pathlib import Path

from cageforge import PermissionApprover, PermissionStore

store = PermissionStore.open(Path("/var/lib/my-tool/permissions.json"))
toml = profile.read_bytes().decode("utf-8")
request = Cageforge.permission_request(toml, context=context)
grant = PermissionApprover().approve(request, scope="persistent")
store.put(grant, request)

cached = store.get(request)
assert cached is not None
with Cageforge.from_toml_file(
    profile, context=context, grant=cached, request=request
) as runtime:
    ...

PermissionStore protects the file with owner-only permissions on Unix and an owner-only DACL on Windows. It uses a versioned JSON document, a kernel file lock, and atomic replacement. A missing store record is not an approval; preflight remains deny-by-default.

Persistent grants can be inspected and revoked by stable ID without exposing their approved capability payload:

page = store.list_page(page_size=50)
for summary in page.entries:
    print(summary.id, summary.tool_id)
if page.next_cursor is not None:
    page = store.list_page(page_size=50, cursor=page.next_cursor)

result = store.revoke(request.grant_id())
assert str(result) in {"revoked", "not-found"}

GrantPageCursor is opaque and becomes stale when the store changes. The binding exposes stable store exception subclasses for invalid IDs, invalid cursors, page size, stale cursors, lock, read, write, and format failures. All digest and store validation is performed by the shared Rust implementation.

When profile_name is omitted, Cageforge.from_toml and check_toml use the TOML document's default_profile. Cageforge.from_toml_file reads a file and uses its parent directory as the default current directory. RuntimeContext() uses the Python process directory and lets the native adapter provide the platform's default minimal paths. Passing a path in RuntimeContext does not grant access unless the selected profile contains the corresponding rule.

The minimal selector is symbolic. Linux adapters supply the executable and loader paths needed by the selected backend, macOS supplies its system runtime paths, and Windows supplies the system root and System32 paths. Use the separate files under cageforge-config/examples/runnable/ when the command or path syntax is OS-specific. The macOS runtime.executable_roots overlay is passed through the same preflight request; its filesystem capabilities expose map-executable separately from read.

Processes, asyncio, and errors

SandboxProcess provides try_wait, wait, wait_for, kill, and close, as well as read_stdout, read_stderr, write_stdin, and close_stdin. The wait_for method is a compatibility alias for wait. Blocking native waits and stream operations release the GIL.

For asyncio applications, wait_for_async(process) waits in a worker thread so the event loop remains responsive. Cancelling the coroutine terminates the process boundary and then propagates asyncio.CancelledError.

Configuration, initialization, launch, process, stream, and Windows setup failures use typed exceptions under CageforgeError, including CageforgeConfigurationError, CageforgeLaunchError, and CageforgeProcessError:

from cageforge import Cageforge, CageforgeConfigurationError

try:
    Cageforge.check_toml("not valid = [")
except CageforgeConfigurationError as error:
    print(f"invalid Cageforge configuration: {error}")

Windows setup and native resources

Windows provisioning is explicit because installation can require UAC. Before launching on Windows, an application can reconcile and verify the owner-scoped setup:

from cageforge import WindowsSetup

if WindowsSetup.is_supported():
    if WindowsSetup.status() != "ready":
        WindowsSetup.install()
    WindowsSetup.verify()

install() is the only operation in this sequence that may request elevation. Creating a runtime does not silently install Windows components. Linux wheels prefer a compatible system Bubblewrap and fall back to the bundled Bubblewrap resource shipped in the wheel. macOS uses the packaged native helper.

Development

From this directory, install maturin and the Python development tools, then use maturin develop, pytest, mypy --strict, and ruff check. The committed _cageforge.pyi stub is generated by running cargo run --bin stub_gen from this crate directory. The Java and Python bindings share the same native policy contract; binding-specific contract checks live with their respective tests.

Release files for cageforge 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cageforge 0.6.1
File Size Uploaded
cageforge-0.6.1.tar.gz 904.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for cageforge 0.6.1
File
cageforge-0.6.1-cp314-cp314t-win_arm64.whl CPython 3.14 CPython 3.14 free-threading Windows ARM64 Details
cageforge-0.6.1-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details
cageforge-0.6.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 Details
cageforge-0.6.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64 Details
cageforge-0.6.1-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details
cageforge-0.6.1-cp314-cp314t-macosx_10_12_x86_64.whl CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 Details
cageforge-0.6.1-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
cageforge-0.6.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
cageforge-0.6.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
cageforge-0.6.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
cageforge-0.6.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
cageforge-0.6.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 84.2 MB

Release files / cageforge-0.6.1.tar.gz

Download URL cageforge-0.6.1.tar.gz
Size 904.9 kB
Tags Source
SHA-256 checksum
How to use checksums
007298a1c3a45f5bc6b6f9db2a28a79d32fa81ffd943fee99555dbfcc299756f
BLAKE2b-256 checksum
How to use checksums
8e6ca909c97cc07fb6a8e3bc05d17f62b72b2e77a2c8608c0c77a3630dda0e8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / cageforge-0.6.1-cp314-cp314t-win_arm64.whl

Download URL cageforge-0.6.1-cp314-cp314t-win_arm64.whl
Size 6.9 MB
Tags CPython 3.14 CPython 3.14 free-threading Windows ARM64
SHA-256 checksum
How to use checksums
6c7dcc32a2c55881ecf3eeafc58cdbcefee8c34120b25b6f54474f5c892ac51d
BLAKE2b-256 checksum
How to use checksums
3566fbd5726428ae2b9a278a0e96f3fa97761762a76d0298b386dcfe2311864f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / cageforge-0.6.1-cp314-cp314t-win_amd64.whl

Download URL cageforge-0.6.1-cp314-cp314t-win_amd64.whl
Size 7.3 MB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
fae6671fb3ea1c02cf3d6dc41588f5aed1b3f4d30c02a2c637866797c157734e
BLAKE2b-256 checksum
How to use checksums
d3ea3218c5dd1329af315f45c05926aeed912ccf076aca98cc993f624a4d0377
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / cageforge-0.6.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL cageforge-0.6.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 7.4 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
314d216c37622931789a47256932f6fd8587711e4970d6167ae09bd93170ea20
BLAKE2b-256 checksum
How to use checksums
0ffa07f27a942149d4e6e79bcb3e5e5864a89d1fa38b8e94daecef51cedef385
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / cageforge-0.6.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL cageforge-0.6.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 7.2 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
4c71fed1f4bb3888471a349267195e41a531212f977970b17615b7238166f02a
BLAKE2b-256 checksum
How to use checksums
630c0a0c806cda928874f33a2eddc45e35227b12c8b1a02dabd47547749fc73a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / cageforge-0.6.1-cp314-cp314t-macosx_11_0_arm64.whl

Download URL cageforge-0.6.1-cp314-cp314t-macosx_11_0_arm64.whl
Size 6.3 MB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1090a6403afa4549b1c56821a4045690c9d0d76ea3cd1098c00297b7a60fa76e
BLAKE2b-256 checksum
How to use checksums
596a6427f189ece926a2ac663d1b670c50947df55bdc1349938f816018e8e825
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / cageforge-0.6.1-cp314-cp314t-macosx_10_12_x86_64.whl

Download URL cageforge-0.6.1-cp314-cp314t-macosx_10_12_x86_64.whl
Size 6.5 MB
Tags CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
079ca91810400dd57d865a55873098c87aeb036b28367038adc29e4b0703021a
BLAKE2b-256 checksum
How to use checksums
4683feed741f264270c9c5ccfd4c4bebb2d35f1d37d03536cd9e487f198992a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / cageforge-0.6.1-cp310-abi3-win_arm64.whl

Download URL cageforge-0.6.1-cp310-abi3-win_arm64.whl
Size 6.9 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
4bcaef40a4ec82d0aaa67443bc741eef12a4d8689eca0b3a5123340953d79cf3
BLAKE2b-256 checksum
How to use checksums
ef4cd52bc8bb9990cc456074df96fc469e3cea356c66693db0bba437d1a68407
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / cageforge-0.6.1-cp310-abi3-win_amd64.whl

Download URL cageforge-0.6.1-cp310-abi3-win_amd64.whl
Size 7.3 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
243432c1dafa5c32caa4fdfa40669c714aeeb6c0fb0dd4888a7cfe8829914ec9
BLAKE2b-256 checksum
How to use checksums
81b163737b0b4025b532443cb041327141747e3e45cd0b2f123805ad3d64cbd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / cageforge-0.6.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL cageforge-0.6.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 7.4 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
b941231394891e7644fae47429ef9f328152876d93e35df78aab0cc92f135258
BLAKE2b-256 checksum
How to use checksums
0e1e1cac1f812df2c35ec9fd93056d125ae3099402f1d5e833ab3ed81ea3a995
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / cageforge-0.6.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL cageforge-0.6.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 7.3 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
eb10f32683255ad46dcf8bf92d496cd80b66bb5a32cd0330e01855443b59a099
BLAKE2b-256 checksum
How to use checksums
9ac8ae77cfd9795ef21b215d3001f319c55e26d4bc0673323e863a43c581f2dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / cageforge-0.6.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL cageforge-0.6.1-cp310-abi3-macosx_11_0_arm64.whl
Size 6.3 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a80945ce26e3d35ee1b9d047b45799bc09d56fdc37ba6329e9d3619f5fe0a38e
BLAKE2b-256 checksum
How to use checksums
e470434c84ceb86731d63314f4c03345db3d04c6d05ddf4f493477f8cb835a74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / cageforge-0.6.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL cageforge-0.6.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 6.5 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
9e608307ff2df1f2409156b87b4c40eee2c516705e27b62f97490e9689e272ae
BLAKE2b-256 checksum
How to use checksums
3c677645e9b2cee3f9755183beb6cefb5b8d3b693649c38e3b3ad31144f078b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release history Release notifications | RSS feed

0.7.1

13 release files

0.7.0

13 release files

This release

0.6.1 This release

13 release files

0.6.0

13 release files

0.5.0

13 release files

0.4.0

13 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page