214 lines
5.9 KiB
TypeScript
214 lines
5.9 KiB
TypeScript
import type {
|
|
DirectAgentToolCapability,
|
|
DirectAgentToolName,
|
|
} from "@/lib/ai/runtime/direct-agent-execution";
|
|
|
|
type DirectAgentProgressStage =
|
|
| "planning"
|
|
| "clarify"
|
|
| "executing"
|
|
| "completed"
|
|
| "failed";
|
|
|
|
type DirectAgentProgressStep =
|
|
| "lock_target"
|
|
| "analyze"
|
|
| "select_tool"
|
|
| "execute"
|
|
| "finalize";
|
|
|
|
export interface DirectAgentProgressPayload {
|
|
stage: DirectAgentProgressStage;
|
|
currentStep: DirectAgentProgressStep;
|
|
title?: string;
|
|
message?: string;
|
|
toolName?: DirectAgentToolName;
|
|
capability?: DirectAgentToolCapability;
|
|
}
|
|
|
|
function buildDirectAgentProgressPayload(params: DirectAgentProgressPayload) {
|
|
return params;
|
|
}
|
|
|
|
export function buildDirectAgentAnalyzePlanningProgress() {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "planning",
|
|
currentStep: "analyze",
|
|
title: "正在分析目标图片",
|
|
message: "我会先提取稳定的视觉摘要,再整理成更直接的分析结论。",
|
|
toolName: "analyzeImage",
|
|
capability: "analyze",
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentAnalyzeCompletedProgress() {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "completed",
|
|
currentStep: "finalize",
|
|
title: "图片分析完成",
|
|
message: "我已经整理好可直接阅读的分析结论。",
|
|
toolName: "analyzeImage",
|
|
capability: "analyze",
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentAnalyzeFailedProgress(errorMessage: string) {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "failed",
|
|
currentStep: "analyze",
|
|
title: "图片分析失败",
|
|
message: errorMessage,
|
|
toolName: "analyzeImage",
|
|
capability: "analyze",
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentImageGenerateSelectProgress() {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "planning",
|
|
currentStep: "select_tool",
|
|
title: "已选中图片生成工具",
|
|
message: "我正在整理参考图和生图参数,准备开始生成。",
|
|
toolName: "generateImage",
|
|
capability: "generate_image",
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentImageGenerateExecutingProgress() {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "executing",
|
|
currentStep: "execute",
|
|
title: "正在生成图片",
|
|
message: "我会结合当前提示词和参考图生成新的画面。",
|
|
toolName: "generateImage",
|
|
capability: "generate_image",
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentImageGenerateCompletedProgress() {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "completed",
|
|
currentStep: "finalize",
|
|
title: "图片生成完成",
|
|
message: "结果已经回写到对话和画布。",
|
|
toolName: "generateImage",
|
|
capability: "generate_image",
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentImageGenerateFailedProgress(errorMessage: string) {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "failed",
|
|
currentStep: "execute",
|
|
title: "图片生成失败",
|
|
message: errorMessage,
|
|
toolName: "generateImage",
|
|
capability: "generate_image",
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentVideoGenerateSelectProgress() {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "planning",
|
|
currentStep: "select_tool",
|
|
title: "已选中视频生成工具",
|
|
message: "我正在整理模式、参考图和视频参数。",
|
|
toolName: "generateVideo",
|
|
capability: "generate_video",
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentVideoGenerateExecutingProgress() {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "executing",
|
|
currentStep: "execute",
|
|
title: "正在生成视频",
|
|
message: "我正在按当前模式执行视频生成。",
|
|
toolName: "generateVideo",
|
|
capability: "generate_video",
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentVideoGenerateCompletedProgress() {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "completed",
|
|
currentStep: "finalize",
|
|
title: "视频生成完成",
|
|
message: "结果已经写回对话和画布。",
|
|
toolName: "generateVideo",
|
|
capability: "generate_video",
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentVideoGenerateFailedProgress(errorMessage: string) {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "failed",
|
|
currentStep: "execute",
|
|
title: "视频生成失败",
|
|
message: errorMessage,
|
|
toolName: "generateVideo",
|
|
capability: "generate_video",
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentImageEditSelectProgress(params: {
|
|
toolName: DirectAgentToolName;
|
|
capability: DirectAgentToolCapability;
|
|
label: string;
|
|
}) {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "planning",
|
|
currentStep: "select_tool",
|
|
title: `已选中${params.label}`,
|
|
message: "我正在整理目标图和当前参数,准备开始执行。",
|
|
toolName: params.toolName,
|
|
capability: params.capability,
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentImageEditExecutingProgress(params: {
|
|
toolName: DirectAgentToolName;
|
|
capability: DirectAgentToolCapability;
|
|
label: string;
|
|
}) {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "executing",
|
|
currentStep: "execute",
|
|
title: `正在执行${params.label}`,
|
|
message: "执行完成后我会把结果直接回写到当前对话和画布。",
|
|
toolName: params.toolName,
|
|
capability: params.capability,
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentImageEditCompletedProgress(params: {
|
|
toolName: DirectAgentToolName;
|
|
capability: DirectAgentToolCapability;
|
|
label: string;
|
|
}) {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "completed",
|
|
currentStep: "finalize",
|
|
title: `${params.label}完成`,
|
|
message: "结果已经回写到当前对话和画布。",
|
|
toolName: params.toolName,
|
|
capability: params.capability,
|
|
});
|
|
}
|
|
|
|
export function buildDirectAgentImageEditFailedProgress(params: {
|
|
toolName: DirectAgentToolName;
|
|
capability: DirectAgentToolCapability;
|
|
label: string;
|
|
errorMessage: string;
|
|
}) {
|
|
return buildDirectAgentProgressPayload({
|
|
stage: "failed",
|
|
currentStep: "execute",
|
|
title: `${params.label}失败`,
|
|
message: params.errorMessage,
|
|
toolName: params.toolName,
|
|
capability: params.capability,
|
|
});
|
|
}
|