feat(*): 云端 Agent - 增强画布上下文读取并接入 Gemini 缓存

This commit is contained in:
ddcat666
2026-09-26 02:21:47 +08:00
parent 2ce50bbb9d
commit 2cedc4c66b
35 changed files with 1927 additions and 266 deletions

View File

@@ -112,6 +112,7 @@ export type CreateAgentRunInput = {
channelId?: string;
channelModelKey?: string;
skillIds?: string[];
focusNodeIds?: string[];
permissionMode?: AgentPermissionMode;
contextScope?: string[];
budget?: { maxCredits?: number; maxGenerationTasks?: number; maxVideoSeconds?: number; maxSteps?: number };

View File

@@ -8,9 +8,15 @@ export type CloudAgentConversationMessage = {
role: "user" | "assistant" | "system" | "tool" | "error";
title?: string;
text: string;
streaming?: boolean;
reasoning?: boolean;
planItems?: Array<{ id: string; title: string; status: "pending" | "doing" | "done" }>;
planTerminal?: boolean;
question?: { question: string; options: Array<{ label: string; detail?: string }>; allowFreeform?: boolean };
meta?: string;
detail?: unknown;
attachments?: Array<{ id: string; name: string; url: string }>;
interjection?: "sent" | "undelivered";
};
export type CloudAgentConversation = {
@@ -58,7 +64,13 @@ export async function loadCloudAgentConversations(canvasId: string): Promise<Clo
export async function saveCloudAgentConversations(canvasId: string, activeId: string | null, conversations: CloudAgentConversation[]) {
if (!canvasId) throw new Error("缺少画布 ID,无法保存 Agent 对话");
const document: CloudAgentConversationDocument = { version: 1, activeId, conversations };
// 流式标记只属于内存中的观察状态。若网络在最后一个 delta 后断开,
// 也不能让下次恢复把思考卡片误判为仍在实时展开。
const persistedConversations = conversations.map((conversation) => ({
...conversation,
messages: conversation.messages.map((message) => ({ ...message, streaming: false })),
}));
const document: CloudAgentConversationDocument = { version: 1, activeId, conversations: persistedConversations };
await localForageStorageForScope(getActiveUserScope()).setItem(storageKey(canvasId), JSON.stringify(document));
}