feat(scheduled-tasks): 新增 HTML 页面定时任务(生成/预览/收藏/技能)
后端: - 新增 task_kind=html_page 任务类型,与普通定时任务并存,配置存 execution_context(无需迁移) - 执行流水线:智能体检索数据 -> 选定模型渲染 HTML -> 清洗/校验 -> 失败自动修复 -> 完整性闸门(缺 doctype/html/head/body/title 或残留脚本即失败) -> 归档 index.html -> 落库 - 新增 scheduled_html_pages / html_page_favorites 表与 store;收藏去重(不可重复)、可删除、收藏时提取可复用风格 - HTML 预览接口(鉴权 + 公开)、收藏接口 - 渲染注入已启用的 HTML 技能(metadata.kind=html_page);全程使用用户所选模型,去除硬编码 GLM-5 - 定时任务跳过 TitleMiddleware,避免标题生成回退默认模型 前端: - 创建/编辑弹窗增加任务类型与 HTML 配置(页面要求/限制/参考收藏页/模型下拉) - 运行详情页与公开页 iframe 沙箱预览 HTML;收藏按钮(已收藏禁用) - 参考收藏页可选可删 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
e1e9be8daa
commit
d9afaca51f
22 files changed
+1996
-107
No files matched your search
@@ -243,6 +243,39 @@ async def public_get_run(run_id: str) -> dict[str, Any]:
|
||||
return _redact_run(run)
|
||||
|
||||
|
||||
def _html_payload(run_id: str, page: dict[str, Any]) -> dict[str, Any]:
|
||||
return {
|
||||
"run_id": run_id,
|
||||
"task_id": page.get("task_id"),
|
||||
"title": page.get("title"),
|
||||
"html": page.get("html_content"),
|
||||
"style_summary": page.get("style_summary"),
|
||||
"layout_summary": page.get("layout_summary"),
|
||||
"page_id": page.get("id"),
|
||||
"created_at": page.get("created_at"),
|
||||
}
|
||||
|
||||
|
||||
@router.get("/runs/{run_id}/html")
|
||||
async def public_get_run_html(run_id: str) -> dict[str, Any]:
|
||||
"""Return the generated HTML document for an ``html_page`` run (anonymous)."""
|
||||
service = get_scheduled_task_service()
|
||||
page = await service.get_html_page_for_run(run_id)
|
||||
if page is None:
|
||||
raise HTTPException(status_code=404, detail="该执行记录没有 HTML 页面")
|
||||
return _html_payload(run_id, page)
|
||||
|
||||
|
||||
@router.get("/{task_id}/latest-html")
|
||||
async def public_get_latest_html(task_id: str) -> dict[str, Any]:
|
||||
"""Return the most recent generated HTML page for a task (anonymous)."""
|
||||
service = get_scheduled_task_service()
|
||||
page = await service.get_latest_html_page_for_task(task_id)
|
||||
if page is None:
|
||||
raise HTTPException(status_code=404, detail="该任务暂无 HTML 页面")
|
||||
return _html_payload(str(page.get("run_id") or ""), page)
|
||||
|
||||
|
||||
@router.get("/runs/{run_id}/files/{file_index}")
|
||||
async def public_get_run_file(run_id: str, file_index: int) -> dict[str, Any]:
|
||||
"""Return a single result-file entry with its inline text content where
|
||||
|
||||
Reference in new issue
Block a user