Skip to main content

mainspring-sandbox

工具执行隔离外挂(M7/M8):@sandboxed 把同步工具放进受限 worker 子进程执行,超时真取消; core 的注册表、Hook 与审批管道只看到一个普通函数。

安装

pip install mainspring-sandbox

用法

from mainspring import tool
from mainspring_sandbox import SandboxPolicy, sandboxed

@tool
@sandboxed(SandboxPolicy())
def run_python(code: str) -> str:
    ...

装饰器顺序固定:@tool 在外层、@sandboxed 在内层;函数必须定义在模块顶层——worker 按 模块名 + __qualname__ 定位原函数。

三档引擎:SubprocessEngine(全平台,用户态 audit hook)、BwrapEngine(Linux namespace)、 SeatbeltEngine(macOS sandbox);引擎不可用时注册期显式报错,不静默降级。 Windows 另有 WindowsJobEngine,进程树随主进程退出一起回收。

mainspring 工作区成员,与 core 同源。MIT。

Metadata

Release files for mainspring-sandbox 0.1.2

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

Source distribution (sdist)

Source distribution for mainspring-sandbox 0.1.2
File Size Uploaded Provenance Actions
mainspring_sandbox-0.1.2.tar.gz 19.6 kB With provenance Details for mainspring_sandbox-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mainspring-sandbox 0.1.2
File Interpreter ABI Platform Actions
mainspring_sandbox-0.1.2-py3-none-any.whl Python 3 none any Details for mainspring_sandbox-0.1.2-py3-none-any.whl

Total release size: 46.5 kB

Release files / mainspring_sandbox-0.1.2.tar.gz

Download URL mainspring_sandbox-0.1.2.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bfb4af86163f3d30152bceee546224e0d92de72f0dc3710f19e6a5c2e1ba204d
BLAKE2b-256 checksum
How to use checksums
106fad601114bffe843f88b6d73db740884b836696d8c927dcbe7859587d7b85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 6, 2026.

Transparency log

Release files / mainspring_sandbox-0.1.2-py3-none-any.whl

Download URL mainspring_sandbox-0.1.2-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b57cc7bfe965c8e61bca02a60c1d5f3ac794202af44b0f8606bcd6f02ca2459d
BLAKE2b-256 checksum
How to use checksums
0e4b1975059dcd8996b4c6ff78db5455dcc0a4280ba0b456567d1636f5af52c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 6, 2026.

Transparency log

Security for mainspring-sandbox 0.1.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mainspring_sandbox-0.1.2.tar.gz

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 Dec 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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