feat:三个浮动窗口功能新增
This commit is contained in:
@@ -10,3 +10,4 @@ export function setupStore(app: App<Element>) {
|
||||
|
||||
export * from './modules/agents.ts'
|
||||
export * from './modules/config.ts'
|
||||
export * from './modules/selection.ts'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ref, watch } from 'vue'
|
||||
import { ref, watch, computed } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
import { getAgentMapIcon } from '@/layout/components/config'
|
||||
import { store } from '../index'
|
||||
import { useStorage } from '@vueuse/core'
|
||||
import type { IExecuteRawResponse } from '@/api'
|
||||
@@ -45,10 +45,44 @@ export interface IRawStepTask {
|
||||
InputObject_List?: string[]
|
||||
OutputObject?: string
|
||||
AgentSelection?: string[]
|
||||
Collaboration_Brief_FrontEnd: IRichText
|
||||
Collaboration_Brief_frontEnd: IRichText
|
||||
TaskProcess: TaskProcess[]
|
||||
}
|
||||
|
||||
export interface IApiAgentAction {
|
||||
id: string
|
||||
type: string
|
||||
agent: string
|
||||
description: string
|
||||
inputs: string[]
|
||||
}
|
||||
|
||||
export interface IApiStepTask {
|
||||
name: string
|
||||
content: string
|
||||
inputs: string[]
|
||||
output: string
|
||||
agents: string[]
|
||||
brief: IRichText
|
||||
process: IApiAgentAction[]
|
||||
}
|
||||
|
||||
// 智能体评分数据类型
|
||||
export interface IScoreItem {
|
||||
score: number
|
||||
reason: string
|
||||
}
|
||||
|
||||
export interface IAgentSelectModifyAddRequest {
|
||||
aspectList: string[] // 维度列表
|
||||
agentScores: Record<string, Record<string, IScoreItem>> // agent -> 维度 -> 评分(与后端返回格式一致)
|
||||
}
|
||||
|
||||
export interface IAgentSelectModifyInitRequest {
|
||||
goal: string
|
||||
stepTask: IApiStepTask
|
||||
}
|
||||
|
||||
export interface IRawPlanResponse {
|
||||
'Initial Input Object'?: string[] | string
|
||||
'General Goal'?: string
|
||||
@@ -71,6 +105,95 @@ export const useAgentsStore = defineStore('agents', () => {
|
||||
agents.value = agent
|
||||
}
|
||||
|
||||
// 智能体评分数据存储
|
||||
const IAgentSelectModifyAddRequest = useStorage<IAgentSelectModifyAddRequest | null>(
|
||||
`${storageKey}-score-data`,
|
||||
null,
|
||||
)
|
||||
|
||||
// 设置智能体评分数据
|
||||
function setAgentScoreData(data: IAgentSelectModifyAddRequest) {
|
||||
IAgentSelectModifyAddRequest.value = data
|
||||
}
|
||||
|
||||
// 添加新维度的评分数据(追加模式)
|
||||
function addAgentScoreAspect(aspectName: string, scores: Record<string, IScoreItem>) {
|
||||
if (!IAgentSelectModifyAddRequest.value) {
|
||||
IAgentSelectModifyAddRequest.value = {
|
||||
aspectList: [],
|
||||
agentScores: {},
|
||||
}
|
||||
}
|
||||
|
||||
// 检查维度是否已存在
|
||||
if (!IAgentSelectModifyAddRequest.value.aspectList.includes(aspectName)) {
|
||||
IAgentSelectModifyAddRequest.value.aspectList.push(aspectName)
|
||||
}
|
||||
|
||||
// 添加该维度的评分数据
|
||||
// scores: { agentName: { score, reason } }
|
||||
// 转换为 agentScores[agentName][aspectName] = { score, reason }
|
||||
for (const [agentName, scoreItem] of Object.entries(scores)) {
|
||||
if (!IAgentSelectModifyAddRequest.value.agentScores[agentName]) {
|
||||
IAgentSelectModifyAddRequest.value.agentScores[agentName] = {}
|
||||
}
|
||||
IAgentSelectModifyAddRequest.value.agentScores[agentName][aspectName] = scoreItem
|
||||
}
|
||||
}
|
||||
|
||||
// 清除智能体评分数据
|
||||
function clearAgentScoreData() {
|
||||
IAgentSelectModifyAddRequest.value = null
|
||||
}
|
||||
|
||||
// 智能体分配确认的组合列表存储 - 按任务ID分别存储(不持久化到localStorage)
|
||||
const confirmedAgentGroupsMap = ref<Map<string, string[][]>>(new Map())
|
||||
|
||||
// 获取指定任务的确认的agent组合列表
|
||||
function getConfirmedAgentGroups(taskId: string): string[][] {
|
||||
return confirmedAgentGroupsMap.value.get(taskId) || []
|
||||
}
|
||||
|
||||
// 添加确认的agent组合到指定任务
|
||||
function addConfirmedAgentGroup(taskId: string, group: string[]) {
|
||||
const groups = confirmedAgentGroupsMap.value.get(taskId) || []
|
||||
groups.push(group)
|
||||
confirmedAgentGroupsMap.value.set(taskId, groups)
|
||||
}
|
||||
|
||||
// 清除指定任务的确认的agent组合列表
|
||||
function clearConfirmedAgentGroups(taskId: string) {
|
||||
confirmedAgentGroupsMap.value.delete(taskId)
|
||||
}
|
||||
|
||||
// 清除所有任务的确认的agent组合列表
|
||||
function clearAllConfirmedAgentGroups() {
|
||||
confirmedAgentGroupsMap.value.clear()
|
||||
}
|
||||
|
||||
const planModificationWindow = ref(false)
|
||||
const planTaskWindow = ref(false)
|
||||
const agentAllocationDialog = ref(false)
|
||||
|
||||
function openPlanModification() {
|
||||
planModificationWindow.value = true
|
||||
}
|
||||
function closePlanModification() {
|
||||
planModificationWindow.value = false
|
||||
}
|
||||
function openPlanTask() {
|
||||
planTaskWindow.value = true
|
||||
}
|
||||
function closePlanTask() {
|
||||
planTaskWindow.value = false
|
||||
}
|
||||
function openAgentAllocationDialog() {
|
||||
agentAllocationDialog.value = true
|
||||
}
|
||||
function closeAgentAllocationDialog() {
|
||||
agentAllocationDialog.value = false
|
||||
}
|
||||
|
||||
// 任务搜索的内容
|
||||
const searchValue = useStorage<string>(`${storageKey}-search-value`, '')
|
||||
function setSearchValue(value: string) {
|
||||
@@ -134,6 +257,30 @@ export const useAgentsStore = defineStore('agents', () => {
|
||||
// 额外的产物列表
|
||||
const additionalOutputs = ref<string[]>([])
|
||||
|
||||
// 用户在 Assignment 中选择的 agent 组合(按任务ID分别存储)
|
||||
const selectedAgentGroupMap = ref<Map<string, string[]>>(new Map())
|
||||
|
||||
// 设置指定任务的选择的 agent 组合
|
||||
function setSelectedAgentGroup(taskId: string, agents: string[]) {
|
||||
selectedAgentGroupMap.value.set(taskId, agents)
|
||||
console.log('💾 保存任务选择的 agent 组合:', { taskId, agents })
|
||||
}
|
||||
|
||||
// 获取指定任务的选择的 agent 组合
|
||||
function getSelectedAgentGroup(taskId: string): string[] | undefined {
|
||||
return selectedAgentGroupMap.value.get(taskId)
|
||||
}
|
||||
|
||||
// 清除指定任务的选择的 agent 组合
|
||||
function clearSelectedAgentGroup(taskId: string) {
|
||||
selectedAgentGroupMap.value.delete(taskId)
|
||||
}
|
||||
|
||||
// 清除所有任务的选择的 agent 组合
|
||||
function clearAllSelectedAgentGroups() {
|
||||
selectedAgentGroupMap.value.clear()
|
||||
}
|
||||
|
||||
// 添加新产物
|
||||
function addNewOutput(outputObject: string) {
|
||||
if (!outputObject.trim()) return false
|
||||
@@ -177,6 +324,32 @@ export const useAgentsStore = defineStore('agents', () => {
|
||||
addNewOutput,
|
||||
removeAdditionalOutput,
|
||||
clearAdditionalOutputs,
|
||||
// 用户选择的 agent 组合
|
||||
selectedAgentGroupMap,
|
||||
setSelectedAgentGroup,
|
||||
getSelectedAgentGroup,
|
||||
clearSelectedAgentGroup,
|
||||
clearAllSelectedAgentGroups,
|
||||
planModificationWindow,
|
||||
openPlanModification,
|
||||
closePlanModification,
|
||||
planTaskWindow,
|
||||
openPlanTask,
|
||||
closePlanTask,
|
||||
agentAllocationDialog,
|
||||
openAgentAllocationDialog,
|
||||
closeAgentAllocationDialog,
|
||||
// 智能体评分数据
|
||||
IAgentSelectModifyAddRequest,
|
||||
setAgentScoreData,
|
||||
addAgentScoreAspect,
|
||||
clearAgentScoreData,
|
||||
// 确认的agent组合列表(按任务ID分别存储)
|
||||
confirmedAgentGroupsMap,
|
||||
getConfirmedAgentGroups,
|
||||
addConfirmedAgentGroup,
|
||||
clearConfirmedAgentGroups,
|
||||
clearAllConfirmedAgentGroups,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
247
frontend/src/stores/modules/selection.ts
Normal file
247
frontend/src/stores/modules/selection.ts
Normal file
@@ -0,0 +1,247 @@
|
||||
import { ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { store } from '../index'
|
||||
import type { IRawStepTask, IApiStepTask } from './agents'
|
||||
import type { Node, Edge } from '@vue-flow/core'
|
||||
|
||||
// 分支节点数据接口 - 用于存储流程图中的节点和边
|
||||
export interface IBranchData {
|
||||
id: string // 分支唯一ID
|
||||
parentNodeId: string // 父节点ID(根节点或任务节点)
|
||||
branchContent: string // 分支需求内容
|
||||
branchType: 'root' | 'task' // 分支类型
|
||||
nodes: Node[] // 分支包含的所有节点
|
||||
edges: Edge[] // 分支包含的所有边
|
||||
tasks: IRawStepTask[] // 分支的任务数据
|
||||
createdAt: number // 创建时间
|
||||
}
|
||||
|
||||
export const useSelectionStore = defineStore('selection', () => {
|
||||
// ==================== 任务大纲探索分支数据存储 ====================
|
||||
const flowBranches = ref<IBranchData[]>([])
|
||||
|
||||
// 任务大纲分支管理
|
||||
|
||||
// 添加流程图分支
|
||||
function addFlowBranch(data: {
|
||||
parentNodeId: string
|
||||
branchContent: string
|
||||
branchType: 'root' | 'task'
|
||||
nodes: Node[]
|
||||
edges: Edge[]
|
||||
tasks: IRawStepTask[]
|
||||
}): string {
|
||||
const branchId = `flow-branch-${uuidv4()}`
|
||||
const newBranch: IBranchData = {
|
||||
id: branchId,
|
||||
parentNodeId: data.parentNodeId,
|
||||
branchContent: data.branchContent,
|
||||
branchType: data.branchType,
|
||||
nodes: data.nodes,
|
||||
edges: data.edges,
|
||||
tasks: data.tasks,
|
||||
createdAt: Date.now(),
|
||||
}
|
||||
flowBranches.value.push(newBranch)
|
||||
console.log('📂 保存流程图分支到 store:', newBranch)
|
||||
return branchId
|
||||
}
|
||||
|
||||
// 获取所有流程图分支
|
||||
function getAllFlowBranches(): IBranchData[] {
|
||||
return flowBranches.value
|
||||
}
|
||||
|
||||
// 根据父节点ID获取流程图分支
|
||||
function getFlowBranchesByParent(parentNodeId: string): IBranchData[] {
|
||||
return flowBranches.value.filter((branch) => branch.parentNodeId === parentNodeId)
|
||||
}
|
||||
|
||||
// 删除流程图分支
|
||||
function removeFlowBranch(branchId: string): boolean {
|
||||
const index = flowBranches.value.findIndex((branch) => branch.id === branchId)
|
||||
if (index > -1) {
|
||||
flowBranches.value.splice(index, 1)
|
||||
console.log('🗑️ 删除流程图分支:', branchId)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 清除所有流程图分支
|
||||
function clearFlowBranches() {
|
||||
flowBranches.value = []
|
||||
console.log('🗑️ 清除所有流程图分支')
|
||||
}
|
||||
|
||||
// 根据父节点ID清除流程图分支
|
||||
function clearFlowBranchesByParent(parentNodeId: string) {
|
||||
flowBranches.value = flowBranches.value.filter((branch) => branch.parentNodeId !== parentNodeId)
|
||||
console.log('🗑️ 清除父节点为', parentNodeId, '的流程图分支')
|
||||
}
|
||||
|
||||
// ==================== 任务过程探索分支数据存储 ====================
|
||||
// 用于存储任务过程探索中的分支数据
|
||||
// 结构: Map<taskStepId, IBranchData[]>
|
||||
const taskProcessBranchesMap = ref<Map<string, IBranchData[]>>(new Map())
|
||||
|
||||
// 添加任务过程分支
|
||||
function addTaskProcessBranch(
|
||||
taskStepId: string,
|
||||
data: {
|
||||
parentNodeId: string
|
||||
branchContent: string
|
||||
branchType: 'root' | 'task'
|
||||
nodes: Node[]
|
||||
edges: Edge[]
|
||||
tasks: IRawStepTask[]
|
||||
},
|
||||
): string {
|
||||
const branchId = `task-process-branch-${uuidv4()}`
|
||||
const newBranch: IBranchData = {
|
||||
id: branchId,
|
||||
parentNodeId: data.parentNodeId,
|
||||
branchContent: data.branchContent,
|
||||
branchType: data.branchType,
|
||||
nodes: data.nodes,
|
||||
edges: data.edges,
|
||||
tasks: data.tasks,
|
||||
createdAt: Date.now(),
|
||||
}
|
||||
|
||||
// 获取或创建该任务步骤的分支列表
|
||||
if (!taskProcessBranchesMap.value.has(taskStepId)) {
|
||||
taskProcessBranchesMap.value.set(taskStepId, [])
|
||||
}
|
||||
taskProcessBranchesMap.value.get(taskStepId)!.push(newBranch)
|
||||
|
||||
console.log('📂 保存任务过程分支到 store:', { taskStepId, branch: newBranch })
|
||||
return branchId
|
||||
}
|
||||
|
||||
// 获取指定任务步骤的所有分支
|
||||
function getTaskProcessBranches(taskStepId: string): IBranchData[] {
|
||||
return taskProcessBranchesMap.value.get(taskStepId) || []
|
||||
}
|
||||
|
||||
// 获取所有任务过程分支
|
||||
function getAllTaskProcessBranches(): Map<string, IBranchData[]> {
|
||||
return taskProcessBranchesMap.value
|
||||
}
|
||||
|
||||
// 根据父节点ID获取任务过程分支
|
||||
function getTaskProcessBranchesByParent(taskStepId: string, parentNodeId: string): IBranchData[] {
|
||||
const branches = taskProcessBranchesMap.value.get(taskStepId) || []
|
||||
return branches.filter((branch) => branch.parentNodeId === parentNodeId)
|
||||
}
|
||||
|
||||
// 删除任务过程分支
|
||||
function removeTaskProcessBranch(taskStepId: string, branchId: string): boolean {
|
||||
const branches = taskProcessBranchesMap.value.get(taskStepId)
|
||||
if (branches) {
|
||||
const index = branches.findIndex((branch) => branch.id === branchId)
|
||||
if (index > -1) {
|
||||
branches.splice(index, 1)
|
||||
console.log('🗑️ 删除任务过程分支:', { taskStepId, branchId })
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 清除指定任务步骤的所有分支
|
||||
function clearTaskProcessBranches(taskStepId: string) {
|
||||
taskProcessBranchesMap.value.delete(taskStepId)
|
||||
console.log('🗑️ 清除任务步骤的所有分支:', taskStepId)
|
||||
}
|
||||
|
||||
// ==================== Agent 组合 TaskProcess 数据存储 ====================
|
||||
// 用于存储 fill_stepTask_TaskProcess 接口返回的数据
|
||||
// 结构: Map<taskId, Map<agentGroupKey, IApiStepTask>>
|
||||
// - taskId: 任务ID
|
||||
// - agentGroupKey: agent 组合的唯一标识(排序后的 JSON 字符串)
|
||||
// - IApiStepTask: 该 agent 组合的完整 TaskProcess 数据
|
||||
const agentTaskProcessMap = ref<Map<string, Map<string, IApiStepTask>>>(new Map())
|
||||
|
||||
// 生成 agent 组合的唯一 key(排序后保证一致性)
|
||||
function getAgentGroupKey(agents: string[]): string {
|
||||
return JSON.stringify(agents.sort())
|
||||
}
|
||||
|
||||
// 存储 agent 组合的 TaskProcess 数据
|
||||
function setAgentTaskProcess(taskId: string, agents: string[], taskProcess: IApiStepTask) {
|
||||
const groupKey = getAgentGroupKey(agents)
|
||||
|
||||
// 获取或创建该任务的 Map
|
||||
if (!agentTaskProcessMap.value.has(taskId)) {
|
||||
agentTaskProcessMap.value.set(taskId, new Map())
|
||||
}
|
||||
|
||||
// 存储该 agent 组合的 TaskProcess 数据
|
||||
agentTaskProcessMap.value.get(taskId)!.set(groupKey, taskProcess)
|
||||
console.log(`📦 存储 agent 组合 TaskProcess [任务: ${taskId}, agents: ${agents.join(', ')}]`)
|
||||
}
|
||||
|
||||
// 获取 agent 组合的 TaskProcess 数据
|
||||
function getAgentTaskProcess(taskId: string, agents: string[]): IApiStepTask | undefined {
|
||||
const groupKey = getAgentGroupKey(agents)
|
||||
return agentTaskProcessMap.value.get(taskId)?.get(groupKey)
|
||||
}
|
||||
|
||||
// 检查 agent 组合是否已有 TaskProcess 数据
|
||||
function hasAgentTaskProcess(taskId: string, agents: string[]): boolean {
|
||||
const groupKey = getAgentGroupKey(agents)
|
||||
return agentTaskProcessMap.value.get(taskId)?.has(groupKey) || false
|
||||
}
|
||||
|
||||
// 清除指定任务的所有 agent 组合 TaskProcess 数据
|
||||
function clearAgentTaskProcess(taskId: string) {
|
||||
agentTaskProcessMap.value.delete(taskId)
|
||||
console.log(`🗑️ 清除任务的 agent 组合 TaskProcess 数据: ${taskId}`)
|
||||
}
|
||||
|
||||
// 清除所有任务的 agent 组合 TaskProcess 数据
|
||||
function clearAllAgentTaskProcess() {
|
||||
agentTaskProcessMap.value.clear()
|
||||
console.log('🗑️ 清除所有任务的 agent 组合 TaskProcess 数据')
|
||||
}
|
||||
|
||||
return {
|
||||
// 状态
|
||||
flowBranches,
|
||||
taskProcessBranchesMap,
|
||||
agentTaskProcessMap,
|
||||
|
||||
// 任务大纲分支管理方法
|
||||
addFlowBranch,
|
||||
getAllFlowBranches,
|
||||
getFlowBranchesByParent,
|
||||
removeFlowBranch,
|
||||
clearFlowBranches,
|
||||
clearFlowBranchesByParent,
|
||||
|
||||
// 任务过程分支管理方法
|
||||
addTaskProcessBranch,
|
||||
getTaskProcessBranches,
|
||||
getAllTaskProcessBranches,
|
||||
getTaskProcessBranchesByParent,
|
||||
removeTaskProcessBranch,
|
||||
clearTaskProcessBranches,
|
||||
|
||||
// Agent 组合 TaskProcess 数据管理方法
|
||||
getAgentGroupKey,
|
||||
setAgentTaskProcess,
|
||||
getAgentTaskProcess,
|
||||
hasAgentTaskProcess,
|
||||
clearAgentTaskProcess,
|
||||
clearAllAgentTaskProcess,
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 用于在组件外部使用 Selection Store
|
||||
*/
|
||||
export function useSelectionStoreHook() {
|
||||
return useSelectionStore(store)
|
||||
}
|
||||
Reference in New Issue
Block a user