feat(agent): Agent 工作台 - 计划插话记忆、统一模型选择器并修复摘要与视频入库
将计划清单、运行中插话和个人记忆接入云端 Agent;全站模型选择器统一为左右二级菜单。画布摘要按预算截断不再整轮拒绝,首页视频未知宽高可入库。README 补充贡献者 morrow。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
25
web/src/services/api/admin-agent-lessons.ts
Normal file
25
web/src/services/api/admin-agent-lessons.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { compactApiParams, http } from "./request";
|
||||
import { agentMemoryCategoryLabel, AGENT_MEMORY_CATEGORIES, type AgentMemory, type AgentMemoryStep } from "./agent-memories";
|
||||
|
||||
export type AdminAgentLesson = AgentMemory & {
|
||||
authorUserId?: string;
|
||||
authorUsername?: string;
|
||||
authorDisplayName?: string;
|
||||
};
|
||||
|
||||
export type { AgentMemoryStep };
|
||||
|
||||
export function listAdminAgentLessons(params: { status?: string; userId?: string; keyword?: string; limit?: number } = {}) {
|
||||
const { status, userId, keyword, limit = 100 } = params;
|
||||
return http.get<{ lessons: AdminAgentLesson[] }>("/admin/agent-lessons", {
|
||||
params: compactApiParams({ status, userId, keyword, limit }),
|
||||
timeout: 15_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function deleteAdminAgentLesson(id: string) {
|
||||
return http.delete<{ id: string }>(`/admin/agent-lessons/${encodeURIComponent(id)}`, { timeout: 15_000 });
|
||||
}
|
||||
|
||||
export const AGENT_LESSON_CATEGORIES = AGENT_MEMORY_CATEGORIES;
|
||||
export const agentLessonCategoryLabel = agentMemoryCategoryLabel;
|
||||
145
web/src/services/api/agent-memories.ts
Normal file
145
web/src/services/api/agent-memories.ts
Normal file
@@ -0,0 +1,145 @@
|
||||
import { http, compactApiParams } from "./request";
|
||||
|
||||
export type AgentMemoryStep = { tool: string; action: string; note?: string };
|
||||
|
||||
export type AgentMemoryStatus = "pending" | "approved" | "rejected" | string;
|
||||
|
||||
export type AgentMemory = {
|
||||
id: string;
|
||||
topic: string;
|
||||
category?: string;
|
||||
situation: string;
|
||||
lesson?: string;
|
||||
steps?: AgentMemoryStep[];
|
||||
source?: string;
|
||||
status: AgentMemoryStatus;
|
||||
injected: number;
|
||||
hits: number;
|
||||
lastVerifiedAt?: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export type AgentMemoryRequest = {
|
||||
topic: string;
|
||||
category: string;
|
||||
situation: string;
|
||||
lesson?: string;
|
||||
steps?: AgentMemoryStep[];
|
||||
source?: string;
|
||||
};
|
||||
|
||||
export type AgentMemoryBundle = {
|
||||
version: number;
|
||||
kind: string;
|
||||
exportedAt: string;
|
||||
memories: Array<{
|
||||
topic: string;
|
||||
category: string;
|
||||
situation: string;
|
||||
lesson?: string;
|
||||
steps?: AgentMemoryStep[];
|
||||
source?: string;
|
||||
status?: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
export type AgentMemoryImportResult = {
|
||||
imported: number;
|
||||
merged: number;
|
||||
skipped: number;
|
||||
};
|
||||
|
||||
export type AgentMemoryCompactInterval = "off" | "daily" | "weekly" | "monthly" | string;
|
||||
|
||||
export type AgentMemoryCompactStatus = "idle" | "queued" | "running" | "succeeded" | "failed" | string;
|
||||
|
||||
export type AgentMemoryCompactSummary = {
|
||||
rewritten: number;
|
||||
merged: number;
|
||||
removed: number;
|
||||
skipped: number;
|
||||
};
|
||||
|
||||
export type AgentMemoryCompactView = {
|
||||
compactInterval: AgentMemoryCompactInterval;
|
||||
logicalModelId?: string;
|
||||
channelId?: string;
|
||||
channelModelKey?: string;
|
||||
model?: string;
|
||||
lastCompactAt?: string;
|
||||
lastStatus: AgentMemoryCompactStatus;
|
||||
lastError?: string;
|
||||
taskId?: string;
|
||||
summary?: AgentMemoryCompactSummary;
|
||||
};
|
||||
|
||||
export type AgentMemoryCompactRequest = {
|
||||
logicalModelId?: string;
|
||||
channelId?: string;
|
||||
channelModelKey?: string;
|
||||
model?: string;
|
||||
};
|
||||
|
||||
export type AgentMemorySettingRequest = AgentMemoryCompactRequest & {
|
||||
compactInterval: AgentMemoryCompactInterval;
|
||||
};
|
||||
|
||||
export const AGENT_MEMORY_CATEGORIES = [
|
||||
{ key: "storyboard", label: "分镜" },
|
||||
{ key: "video", label: "视频生成" },
|
||||
{ key: "image", label: "图像生成" },
|
||||
{ key: "canvas", label: "画布操作" },
|
||||
{ key: "asset", label: "资产" },
|
||||
{ key: "model", label: "模型选择" },
|
||||
{ key: "workflow", label: "流程顺序" },
|
||||
{ key: "billing", label: "计费" },
|
||||
{ key: "other", label: "其他" },
|
||||
] as const;
|
||||
|
||||
export function agentMemoryCategoryLabel(key?: string) {
|
||||
return AGENT_MEMORY_CATEGORIES.find((entry) => entry.key === key)?.label || "其他";
|
||||
}
|
||||
|
||||
export function listAgentMemories(status?: string, limit = 200) {
|
||||
return http.get<{ memories: AgentMemory[] }>("/agent/memories", {
|
||||
params: compactApiParams({ status, limit }),
|
||||
timeout: 15_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function createAgentMemory(input: AgentMemoryRequest) {
|
||||
return http.post<AgentMemory>("/agent/memories", input, { timeout: 15_000 });
|
||||
}
|
||||
|
||||
export function updateAgentMemory(id: string, input: AgentMemoryRequest) {
|
||||
return http.patch<AgentMemory>(`/agent/memories/${encodeURIComponent(id)}`, input, { timeout: 15_000 });
|
||||
}
|
||||
|
||||
export function decideAgentMemory(id: string, decision: "approve" | "reject") {
|
||||
return http.post<{ id: string; decision: string }>(`/agent/memories/${encodeURIComponent(id)}/decide`, { decision }, { timeout: 15_000 });
|
||||
}
|
||||
|
||||
export function deleteAgentMemory(id: string) {
|
||||
return http.delete<{ id: string }>(`/agent/memories/${encodeURIComponent(id)}`, { timeout: 15_000 });
|
||||
}
|
||||
|
||||
export function exportAgentMemories() {
|
||||
return http.get<AgentMemoryBundle>("/agent/memories/export", { timeout: 30_000 });
|
||||
}
|
||||
|
||||
export function importAgentMemories(bundle: AgentMemoryBundle) {
|
||||
return http.post<AgentMemoryImportResult>("/agent/memories/import", bundle, { timeout: 30_000 });
|
||||
}
|
||||
|
||||
export function getAgentMemorySettings() {
|
||||
return http.get<AgentMemoryCompactView>("/agent/memories/settings", { timeout: 15_000 });
|
||||
}
|
||||
|
||||
export function updateAgentMemorySettings(input: AgentMemorySettingRequest) {
|
||||
return http.patch<AgentMemoryCompactView>("/agent/memories/settings", input, { timeout: 15_000 });
|
||||
}
|
||||
|
||||
export function compactAgentMemories(input: AgentMemoryCompactRequest = {}) {
|
||||
return http.post<AgentMemoryCompactView>("/agent/memories/compact", input, { timeout: 30_000 });
|
||||
}
|
||||
@@ -27,7 +27,7 @@ export type AgentProfileView = {
|
||||
layers: AgentProfileLayer[];
|
||||
};
|
||||
|
||||
export type AgentApprovalPreviewOperation = "add_node" | "update_node" | "connect_nodes" | "generate_media" | "create_storyboard" | "edit_storyboard";
|
||||
export type AgentApprovalPreviewOperation = "add_node" | "update_node" | "connect_nodes" | "generate_media" | "create_storyboard" | "edit_storyboard" | "plan_step";
|
||||
|
||||
export type AgentApprovalPreviewItem = {
|
||||
operation: AgentApprovalPreviewOperation;
|
||||
@@ -114,7 +114,7 @@ export type CreateAgentRunInput = {
|
||||
skillIds?: string[];
|
||||
permissionMode?: AgentPermissionMode;
|
||||
contextScope?: string[];
|
||||
budget?: { maxCredits?: number; maxGenerationTasks?: number; maxVideoSeconds?: number };
|
||||
budget?: { maxCredits?: number; maxGenerationTasks?: number; maxVideoSeconds?: number; maxSteps?: number };
|
||||
idempotencyKey: string;
|
||||
};
|
||||
|
||||
@@ -145,6 +145,10 @@ export async function sendAgentMessage(runId: string, input: CreateAgentRunInput
|
||||
return submitAgentRequest(`/agent/runs/${encodeURIComponent(runId)}/messages`, input);
|
||||
}
|
||||
|
||||
export function sendAgentInterjection(runId: string, input: { text: string; messageId: string }) {
|
||||
return http.post<{ accepted: boolean; pending: number }>(`/agent/runs/${encodeURIComponent(runId)}/interjections`, input, { timeout: 20_000 });
|
||||
}
|
||||
|
||||
export function getAgentCapabilities() {
|
||||
return http.get<{ version: number; permissionModes: AgentPermissionMode[]; contextScopes: string[]; skills: boolean; writeTools: boolean; capabilitySetVersion?: string; capabilitySetHash?: string; nodeTypes?: string[] }>("/agent/capabilities", { timeout: 15_000 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user