mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-25 18:32:10 +00:00
普通用户建应用的契约骨架(docs/design/normal-user-apps.md 第五部分):蓝图、蓝图留痕、发布单、文件、记录表的模型和迁移,应用的 scope / owner / blueprint_id;运行来源加 trial、personal_app;应用描述的固定版本可以没有版本号(试运行派生的草稿)或改钉蓝图(个人应用),视图来源加 exploratory,组件加 hidden,表单加文件控件;agentlab.blueprint/1 与 bp_* 操作、agentlab.template/1 与关节类型的定义;实例化、试运行、发布单、个人应用、记录表、文件、白话层的接口签名;蓝图、模板、文件、个人应用、蓝图助手的路由桩(501);前端约定 typesBlueprint.ts、接口桩、新建应用与蓝图页的占位路由、termsBlueprint.ts
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
"""蓝图、试运行、发布单的接口(docs/design/normal-user-apps.md §3.5、§3.6、§3.10)。
|
||||
|
||||
权限在接口里判:共享蓝图要 builder(受管级发布单再要 admin),个人蓝图要拥有者且管理员开了 apps.user_personal_apps。
|
||||
骨架阶段全部 501,包 B2 实现(CRUD 调 blueprints/ops,试运行调 blueprints/trial,发布单调 blueprints/publish_plan)。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["blueprints"])
|
||||
|
||||
_TODO = "尚未实现"
|
||||
|
||||
|
||||
@router.post("/blueprints", status_code=201)
|
||||
async def create_blueprint() -> dict[str, Any]:
|
||||
"""起点:{source: {kind: conversation|template|run|workflow_version, id?, version?}, scope: shared|personal, name?}"""
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.get("/blueprints")
|
||||
async def list_blueprints() -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.get("/blueprints/{blueprint_id}")
|
||||
async def get_blueprint(blueprint_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.patch("/blueprints/{blueprint_id}")
|
||||
async def patch_blueprint(blueprint_id: str) -> dict[str, Any]:
|
||||
"""{ops: [bp_* 操作], name?}:用户在卡片上的修改,来源记成 user。"""
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.post("/blueprints/{blueprint_id}/instantiate")
|
||||
async def instantiate_blueprint(blueprint_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.post("/blueprints/{blueprint_id}/trial")
|
||||
async def trial(blueprint_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.get("/blueprints/{blueprint_id}/preview")
|
||||
async def preview(blueprint_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.post("/blueprints/{blueprint_id}/publish-plan")
|
||||
async def publish_plan(blueprint_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.get("/publish-plans/{plan_id}")
|
||||
async def get_plan(plan_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.post("/publish-plans/{plan_id}/run")
|
||||
async def run_plan(plan_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.post("/publish-plans/{plan_id}/resume")
|
||||
async def resume_plan(plan_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
@@ -0,0 +1,25 @@
|
||||
"""蓝图助手和填关节的流式接口(docs/design/normal-user-apps.md §2.2、§2.3、§2.11)。
|
||||
|
||||
- POST /api/copilot/blueprint-stream:蓝图对话。模型输出 bp_* 操作(BlueprintApplier 落地)、look、bp_ask(这一轮就此结束);
|
||||
- POST /api/copilot/fill-joints-stream:按模板填生成关节(sql、metric_expr)。TemplateApplier 只收 fill_joint、只收模板声明过的
|
||||
关节;不同 group 的关节并行填。
|
||||
|
||||
都复用 api/copilot_gen.Generation。包 B1 实现。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
router = APIRouter(prefix="/api/copilot", tags=["copilot-blueprint"])
|
||||
|
||||
|
||||
@router.post("/blueprint-stream")
|
||||
async def blueprint_stream() -> Any:
|
||||
raise HTTPException(501, "尚未实现")
|
||||
|
||||
|
||||
@router.post("/fill-joints-stream")
|
||||
async def fill_joints_stream() -> Any:
|
||||
raise HTTPException(501, "尚未实现")
|
||||
@@ -0,0 +1,24 @@
|
||||
"""文件的上传、下载、删除(docs/design/normal-user-apps.md §3.8)。包 B3 实现。"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
router = APIRouter(prefix="/api/files", tags=["files"])
|
||||
|
||||
|
||||
@router.post("", status_code=201)
|
||||
async def upload() -> dict[str, Any]:
|
||||
"""multipart:file + context({app_id, entry} | {task_id} | {blueprint_id}),交回引用 {file_id, name, size, sha256, type}。"""
|
||||
raise HTTPException(501, "尚未实现")
|
||||
|
||||
|
||||
@router.get("/{file_id}")
|
||||
async def download(file_id: str) -> Any:
|
||||
raise HTTPException(501, "尚未实现")
|
||||
|
||||
|
||||
@router.delete("/{file_id}", status_code=204)
|
||||
async def delete(file_id: str) -> None:
|
||||
raise HTTPException(501, "尚未实现")
|
||||
@@ -0,0 +1,43 @@
|
||||
"""个人应用与审核(docs/design/normal-user-apps.md §3.9)、页面编辑的候选(§2.6),以及记录的逐行查看(§3.7 records_list)。
|
||||
|
||||
要在 apps.router 之前登记(共用 /api/apps 前缀,路径不冲突)。包 B4 实现个人应用和候选,记录列表由包 B3 实现。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["personal"])
|
||||
|
||||
_TODO = "尚未实现"
|
||||
|
||||
|
||||
@router.post("/blueprints/{blueprint_id}/save-personal")
|
||||
async def save_personal(blueprint_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.post("/blueprints/{blueprint_id}/copy", status_code=201)
|
||||
async def copy_for_review(blueprint_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.post("/apps/{app_id}/refresh")
|
||||
async def refresh(app_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.post("/apps/{app_id}/submit-review")
|
||||
async def submit_review(app_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.get("/apps/{app_id}/candidates")
|
||||
async def candidates(app_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
|
||||
|
||||
@router.get("/apps/{app_id}/records")
|
||||
async def records(app_id: str) -> dict[str, Any]:
|
||||
raise HTTPException(501, _TODO)
|
||||
@@ -0,0 +1,13 @@
|
||||
"""场景模板列表(docs/design/normal-user-apps.md §3.3):GET /api/templates。包 B1 实现。"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
router = APIRouter(prefix="/api/templates", tags=["templates"])
|
||||
|
||||
|
||||
@router.get("")
|
||||
async def list_templates() -> dict[str, Any]:
|
||||
raise HTTPException(501, "尚未实现")
|
||||
Reference in New Issue
Block a user