Files
AgentLab/backend/app/api/templates.py
T
ThearchyHelios 277982ead3 普通用户建应用(后端):
- 蓝图:bp_* 操作和逐卡白名单、蓝图检查、留痕、按蓝图判权限;五个场景模板加自由形(骨架、关节、应用骨架、定时任务),实例化与骨架比对;BlueprintApplier / TemplateApplier(只收模板声明过的关节)与自查;look 新类别口径卡;蓝图对话和填关节两个流式接口,不同组的关节并行填、出错的组串行重试;模板列表
- 试运行与发布单:四种起点(对话、模板、问数据的一轮、已发布版本);试运行是探索运行,草稿应用按这次运行解析、印章写试运行,流程类派给自己、不触发升级;发布单九步、预检只读、每步留痕、停下后接着做、核对卡片指纹和应用管理权、启动时整理中断的单;白话层覆盖全部问题编号
- 记录表与文件:平台托管只追加的记录表、按高水位固定数据、连接上的临时视图做行级可见、写入走动作(records_append)、表版本在发布时切换、草稿不影响线上、记录列表遮敏感列;文件按哈希存、两步上传、提交时绑定运行、下载按读权限、清理、file_text、按配方导入一期(table_import_period)
- 个人应用:存成个人应用(问数据的约束)、刷新(遮罩、只读、每日上限)、只有拥有者看得见、提交审核与共享副本、开关下发到认人接口;页面编辑的候选;隐藏组件不下发;三条新检查
2026-10-15 12:09:29 +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/instantiate.registry_problems):首批都登记了、关节类型认得、每个模板的
示例蓝图实例化出来过得了画布校验、骨架比对没有差异。缺一样启动即报错(N3:模板定义、实例化、测试三样都要给)。
"""
from __future__ import annotations
from typing import Any
from fastapi import APIRouter
from app.blueprints.instantiate import registry_problems
from app.blueprints.templates import list_templates
router = APIRouter(prefix="/api/templates", tags=["templates"])
_PROBLEMS = registry_problems()
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()]}