feat(agent): add support for image generation type in event handling and messaging

This commit is contained in:
HouYunFei
2026-07-29 17:32:06 +08:00
parent 2afe2f3898
commit 2002dff78a
5 changed files with 7 additions and 2 deletions
@@ -41,6 +41,8 @@ export type AgentEventItem = {
query?: unknown;
action?: unknown;
path?: unknown;
savedPath?: unknown;
revisedPrompt?: unknown;
};
export type AgentUserDetail = { kind: string; status: string; rows?: Array<{ label: string; value: string }>; output?: string; files?: Array<{ path: string; action?: string }>; tasks?: Array<{ step: string; status: string }>; explanation?: string };
@@ -86,6 +88,7 @@ export function formatAgentActivity(event: AgentEventPayload): Omit<AgentChatIte
return { role: "tool", title: "搜索资料", text: webSearchSummary(item), detail: { kind: "search", status, rows: webSearchDetailRows(item) } };
}
if (item.type === "image_view") return { role: "tool", title: "查看图片", text: stringText(item.path) || "正在查看图片", detail: { kind: "image", status } };
if (item.type === "image_generation") return { role: "tool", title: "内置生图", text: completed ? "图片生成完成" : "正在生成图片…", detail: { kind: "image", status } };
if (item.type === "context_compaction") return { role: "tool", title: "整理上下文", text: completed ? "已整理当前对话,继续处理任务" : "正在整理当前对话…", detail: { kind: "context", status } };
if (isMcpToolItem(item) && isReadTool(String(item.tool || ""))) {
const name = String(item.tool || "");
@@ -754,7 +754,7 @@ export function LocalAgentPanel({ embedded, headless, autoConnect }: { embedded?
return;
}
}
if (event.type === "item.completed" && event.item?.type === "dynamic_tool_call" && event.item.id) {
if (event.type === "item.completed" && event.item?.type === "image_generation" && event.item.id) {
const generated = await importGeneratedImages(endpoint, token, event.item);
if (generated.length) {
const context = canvasContextRef.current;