feat(定时任务): 内置「模板数据转换器」按 HTML 模板填充 JSON 生成大屏
- 模板填充引擎 template_fill.py:模板注册表 + schema 骨架 + 结构校验 + 行级安全填充; 模板自带 DATA 即 schema 来源。no.1 可转换填充(含 MANIFEST 更新时间刷新), no.2 暂为「只展示」(convertible=False) 原样输出已有数据 - 内置 agent template-json-builder(seed + SOUL),随 lifespan 注入,自动出现在 定时任务「执行智能体」下拉 - 调度器新增模板填充执行分支 _run_template_fill_attempt:源 JSON→大模型转换→ 结构校验→失败回喂重试;空源/只展示模板直接用模板默认数据,绝不失败 - API:GET /api/scheduled-tasks/html-templates - 前端:选中该 agent 后条件渲染「HTML模板」下拉 + .json 上传,只展示型模板隐藏 JSON 输入 - 文档同步(前后端 CLAUDE.md) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
1a2ef0a537
commit
cd33aaeded
17 files changed
+1511
-57
No files matched your search
@@ -3,6 +3,7 @@ import { getBackendBaseURL } from "@/core/config";
|
||||
|
||||
import type {
|
||||
HtmlPageFavorite,
|
||||
HtmlTemplateOption,
|
||||
PublishedScheduledTask,
|
||||
ScheduledTask,
|
||||
ScheduledTaskDeliveryProfile,
|
||||
@@ -32,6 +33,14 @@ export async function getSchedulerThread() {
|
||||
return parseResponse<SchedulerThread>(await apiFetch(`${baseUrl()}/thread`));
|
||||
}
|
||||
|
||||
/** 可选的 HTML 模板清单(模板数据转换器填充用)。 */
|
||||
export async function listHtmlTemplates() {
|
||||
const data = await parseResponse<{ templates: HtmlTemplateOption[] }>(
|
||||
await apiFetch(`${baseUrl()}/html-templates`),
|
||||
);
|
||||
return data.templates ?? [];
|
||||
}
|
||||
|
||||
export interface ListScheduledTasksParams {
|
||||
search?: string;
|
||||
tagIds?: string[];
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
deleteScheduledTask,
|
||||
deleteScheduledTaskRun,
|
||||
getSchedulerThread,
|
||||
listHtmlTemplates,
|
||||
getScheduledTaskDeliveryProfile,
|
||||
getScheduledTaskRun,
|
||||
getScheduledTaskRunHtml,
|
||||
@@ -45,6 +46,17 @@ export function useSchedulerThread() {
|
||||
});
|
||||
}
|
||||
|
||||
/** 可选的 HTML 模板清单(模板数据转换器填充用)。模板是后端静态注册,长缓存即可。 */
|
||||
export function useHtmlTemplates(enabled = true) {
|
||||
return useQuery({
|
||||
queryKey: ["scheduled-tasks", "html-templates"],
|
||||
queryFn: listHtmlTemplates,
|
||||
enabled,
|
||||
staleTime: 5 * 60_000,
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
}
|
||||
|
||||
/** A task is currently executing — used to drive live polling of the task list. */
|
||||
function taskIsLive(status?: string | null): boolean {
|
||||
return status === "running" || status === "pending";
|
||||
|
||||
@@ -24,8 +24,27 @@ export type HtmlPageConfig = {
|
||||
model_name?: string | null;
|
||||
};
|
||||
|
||||
/** 选中内置「模板数据转换器」agent 后,要把源 JSON 填充进的 HTML 模板。
|
||||
* 持久化在 ``execution_context.template_config`` 里(无独立列)。 */
|
||||
export type TemplateFillConfig = {
|
||||
template_id?: string | null;
|
||||
/** 可选:覆盖转换所用模型(留空走 agent.model / 系统默认)。 */
|
||||
model_name?: string | null;
|
||||
};
|
||||
|
||||
/** ``GET /api/scheduled-tasks/html-templates`` 返回的一条模板选项。 */
|
||||
export type HtmlTemplateOption = {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string | null;
|
||||
/** false = 暂只「直接展示已有数据」,不需要也不会用源 JSON 转换填充。 */
|
||||
convertible?: boolean;
|
||||
};
|
||||
|
||||
export type ScheduledTaskExecutionContext = {
|
||||
require_markdown?: boolean;
|
||||
/** 模板填充模式:选中「模板数据转换器」+ 选模板后填充进固定 HTML 模板。 */
|
||||
template_config?: TemplateFillConfig;
|
||||
/**
|
||||
* The unified "必须生成 HTML" switch. The task form no longer splits "普通任务 /
|
||||
* HTML 页面" into separate kinds — instead ``require_html`` and
|
||||
|
||||
Reference in new issue
Block a user