Files
AgentLab/backend/app/api/templates.py
T
ThearchyHelios 7739340607 普通用户建应用集成收尾:
- 问数据和个人应用的图放行绑定只读查询等合规工具的调用工具节点,只读和遮罩在这条路径上生效;被治理成写入的工具在只读运行里直接拒;知识库范围在工具层固定(图级默认值、参数名纠错、Agent 都改不了)
- 个人应用的刷新和个人蓝图的试运行只有拥有者能读:运行、事件、证据、工件、文件、运行与审批列表、对比、可验证报告、质询、假设分析、提取工作流一并收紧;个人蓝图的试运行不论谁发起都按个人应用约束
- 共享蓝图只给拥有者、对应应用的管理者、管理员,看不到的一律 404;审核副本归审核人;管理员看别人的个人应用只有元数据、可以归档
- 记录表跨版本汇总(只读挂载旧版本、按当前列 UNION ALL、各版本各自固定高水位,缺的版本照实写进印章);停用前发起的运行可以继续写旧版本;更正沿用原提交人、更正人记审计
- 约定收口:待办种类 review、事件 file.extracted、表单错误 file、模板定义带示例与预置;前端类型一次补齐、去掉临时的局部类型;审核待办卡不再给打不开的链接;读附件事件有中文说法;检查脚本补断言
2026-10-15 13:55:19 +08:00

33 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""场景模板列表(docs/design/normal-user-apps.md §3.3):GET /api/templates。登录即可看(新建应用的「从场景模板开始」)。
模板登记在导入这个模块时核对一遍(blueprints/templates.check_registry → instantiate.registry_problems):首批都登记了、
关节类型认得、每个模板的示例蓝图实例化出来过得了画布校验、骨架比对没有差异。缺一样启动即报错(N3:模板定义、实例化、
测试三样都要给)。
"""
from __future__ import annotations
from typing import Any
from fastapi import APIRouter
from app.blueprints.templates import check_registry, list_templates
router = APIRouter(prefix="/api/templates", tags=["templates"])
_PROBLEMS = check_registry()
if _PROBLEMS:
raise RuntimeError("场景模板登记不完整:" + ";".join(_PROBLEMS))
def template_out(template: Any) -> dict[str, Any]:
"""一个模板交给前端的样子(frontend/src/typesBlueprint.ts 的 TemplateInfo)。"""
return {"id": template.id, "version": template.version, "label": template.label,
"description": template.description, "applies_when": template.applies_when,
"cards": [{"card": card, "note": note} for card, note in template.cards.items()],
"personal": template.personal, "tags": list(template.tags)}
@router.get("")
async def list_templates_api() -> dict[str, Any]:
return {"items": [template_out(t) for t in list_templates()]}