mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-16 08:31:57 +00:00
dd57c12016
跑一段不可信代码不需要一整套容器运行时。macOS 用 Seatbelt (sandbox-exec,系统自带),Linux 用 bubblewrap;冷启动从 ~250ms 降到 ~25ms,且不再需要装任何东西。 守住三件事:默认断网、家目录不可读、只有工作区可写。策略由内核 强制且对子进程继承——沙箱内 subprocess 出来的 cat 读家目录同样是 Operation not permitted。解释器改用 sys.base_prefix 下那个干净的 Python,沙箱代码因此 import 不到后端的 FastAPI、SQLAlchemy 和凭据 处理代码。 如实标注能力边界,不给虚假的安全感: - macOS 不强制 RLIMIT_AS,内存限不住(实测设 256MB 仍可分配 900MB), health 接口申报 enforced 字段,界面把限不住的项划掉 - Seatbelt 是访问控制而非虚拟化:进程表共享,以当前用户身份运行 - bubblewrap 侧多隔离 PID/IPC/挂载视图,内存限额真实生效 顺带修两个 bug: - LocalSandbox 设 RLIMIT_NPROC=64 会误伤——macOS 上它按 uid 全局 计数,用户已有上千进程时沙箱内任何 fork 都失败,连 bash 都起不来 - 模型所属 provider 被停用时,原先静默换一家继续用原模型名,必然 404 且报错指不到原因;改为直接说清是哪个 provider 被停用了 写 SBPL 的坑记在注释里:(deny default) 会让 Python 直接 SIGABRT, 改用「默认允许 + 精确拒绝」。 7 个模板全部回归通过。
35 lines
791 B
TOML
35 lines
791 B
TOML
[project]
|
|
name = "agentlab-backend"
|
|
version = "0.1.0"
|
|
description = "AgentLab — 可视化 Agent 编排实验台后端"
|
|
requires-python = ">=3.12"
|
|
dependencies = [
|
|
"fastapi>=0.115",
|
|
"uvicorn[standard]>=0.32",
|
|
"pydantic>=2.9",
|
|
"pydantic-settings>=2.6",
|
|
"sqlalchemy[asyncio]>=2.0.36",
|
|
"aiosqlite>=0.20",
|
|
"greenlet>=3.1",
|
|
"httpx>=0.28",
|
|
"python-multipart>=0.0.17",
|
|
"langgraph",
|
|
"langgraph-checkpoint-sqlite",
|
|
"langchain-core",
|
|
"langchain-anthropic",
|
|
"langchain-openai",
|
|
"langchain-mcp-adapters",
|
|
"mcp",
|
|
"numpy>=2.0",
|
|
"jsonschema>=4.23",
|
|
"beautifulsoup4>=4.12",
|
|
"cryptography>=43.0",
|
|
]
|
|
|
|
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[tool.hatch.build.targets.wheel]
|
|
packages = ["app"]
|