| 123456789101112131415161718192021222324252627282930313233343536373839 |
- """虚拟文件系统 Backend(存储后端)配置。"""
- from __future__ import annotations
- from pathlib import Path
- from deepagents import FilesystemPermission
- from deepagents.backends import (
- CompositeBackend,
- FilesystemBackend,
- StateBackend,
- StoreBackend,
- )
- def build_backend(project_root: Path, namespace: tuple[str, ...]) -> CompositeBackend:
- """按路径划分真实文件、线程文件和长期记忆。"""
- return CompositeBackend(
- default=FilesystemBackend(
- root_dir=str(project_root.resolve()),
- virtual_mode=True,
- ),
- routes={
- "/workspace/": StateBackend(),
- "/memories/": StoreBackend(namespace=lambda _runtime: namespace),
- },
- )
- def build_permissions() -> list[FilesystemPermission]:
- """保护原始资料、组织政策和 Skill,允许写报告与临时文件。"""
- return [
- FilesystemPermission(
- operations=["write"],
- paths=["/data-room/**", "/policies/**", "/skills/**"],
- mode="deny",
- )
- ]
|