feat:智能体探索窗口与任务过程探索窗口联动修改
This commit is contained in:
@@ -83,12 +83,16 @@ export const useSelectionStore = defineStore('selection', () => {
|
||||
|
||||
// ==================== 任务过程探索分支数据存储 ====================
|
||||
// 用于存储任务过程探索中的分支数据
|
||||
// 结构: Map<taskStepId, IBranchData[]>
|
||||
const taskProcessBranchesMap = ref<Map<string, IBranchData[]>>(new Map())
|
||||
// 结构: Map<taskStepId, Map<agentGroupKey, IBranchData[]>>
|
||||
// - taskStepId: 任务步骤ID
|
||||
// - agentGroupKey: agent 组合的唯一标识(排序后的 JSON 字符串)
|
||||
// - IBranchData[]: 该 agent 组合在该任务下的所有分支数据
|
||||
const taskProcessBranchesMap = ref<Map<string, Map<string, IBranchData[]>>>(new Map())
|
||||
|
||||
// 添加任务过程分支
|
||||
function addTaskProcessBranch(
|
||||
taskStepId: string,
|
||||
agents: string[], // 🆕 新增:需要传入 agents 列表
|
||||
data: {
|
||||
parentNodeId: string
|
||||
branchContent: string
|
||||
@@ -99,6 +103,8 @@ export const useSelectionStore = defineStore('selection', () => {
|
||||
},
|
||||
): string {
|
||||
const branchId = `task-process-branch-${uuidv4()}`
|
||||
const agentGroupKey = getAgentGroupKey(agents) // 🆕 生成 agent 组合 key
|
||||
|
||||
const newBranch: IBranchData = {
|
||||
id: branchId,
|
||||
parentNodeId: data.parentNodeId,
|
||||
@@ -110,50 +116,70 @@ export const useSelectionStore = defineStore('selection', () => {
|
||||
createdAt: Date.now(),
|
||||
}
|
||||
|
||||
// 获取或创建该任务步骤的分支列表
|
||||
// 获取或创建该任务步骤的 Map
|
||||
if (!taskProcessBranchesMap.value.has(taskStepId)) {
|
||||
taskProcessBranchesMap.value.set(taskStepId, [])
|
||||
taskProcessBranchesMap.value.set(taskStepId, new Map())
|
||||
}
|
||||
taskProcessBranchesMap.value.get(taskStepId)!.push(newBranch)
|
||||
|
||||
console.log('📂 保存任务过程分支到 store:', { taskStepId, branch: newBranch })
|
||||
// 获取或创建该 agent 组合的分支列表
|
||||
const agentMap = taskProcessBranchesMap.value.get(taskStepId)!
|
||||
if (!agentMap.has(agentGroupKey)) {
|
||||
agentMap.set(agentGroupKey, [])
|
||||
}
|
||||
agentMap.get(agentGroupKey)!.push(newBranch)
|
||||
|
||||
console.log('📂 保存任务过程分支到 store:', { taskStepId, agents, agentGroupKey, branch: newBranch })
|
||||
return branchId
|
||||
}
|
||||
|
||||
// 获取指定任务步骤的所有分支
|
||||
function getTaskProcessBranches(taskStepId: string): IBranchData[] {
|
||||
return taskProcessBranchesMap.value.get(taskStepId) || []
|
||||
// 获取指定任务步骤和 agent 组合的所有分支
|
||||
function getTaskProcessBranches(taskStepId: string, agents: string[]): IBranchData[] {
|
||||
const agentGroupKey = getAgentGroupKey(agents)
|
||||
return taskProcessBranchesMap.value.get(taskStepId)?.get(agentGroupKey) || []
|
||||
}
|
||||
|
||||
// 获取所有任务过程分支
|
||||
function getAllTaskProcessBranches(): Map<string, IBranchData[]> {
|
||||
function getAllTaskProcessBranches(): Map<string, Map<string, IBranchData[]>> {
|
||||
return taskProcessBranchesMap.value
|
||||
}
|
||||
|
||||
// 根据父节点ID获取任务过程分支
|
||||
function getTaskProcessBranchesByParent(taskStepId: string, parentNodeId: string): IBranchData[] {
|
||||
const branches = taskProcessBranchesMap.value.get(taskStepId) || []
|
||||
function getTaskProcessBranchesByParent(taskStepId: string, agents: string[], parentNodeId: string): IBranchData[] {
|
||||
const agentGroupKey = getAgentGroupKey(agents)
|
||||
const branches = taskProcessBranchesMap.value.get(taskStepId)?.get(agentGroupKey) || []
|
||||
return branches.filter((branch) => branch.parentNodeId === parentNodeId)
|
||||
}
|
||||
|
||||
// 删除任务过程分支
|
||||
function removeTaskProcessBranch(taskStepId: string, branchId: string): boolean {
|
||||
const branches = taskProcessBranchesMap.value.get(taskStepId)
|
||||
function removeTaskProcessBranch(taskStepId: string, agents: string[], branchId: string): boolean {
|
||||
const agentGroupKey = getAgentGroupKey(agents)
|
||||
const branches = taskProcessBranchesMap.value.get(taskStepId)?.get(agentGroupKey)
|
||||
if (branches) {
|
||||
const index = branches.findIndex((branch) => branch.id === branchId)
|
||||
if (index > -1) {
|
||||
branches.splice(index, 1)
|
||||
console.log('🗑️ 删除任务过程分支:', { taskStepId, branchId })
|
||||
console.log('🗑️ 删除任务过程分支:', { taskStepId, agents, branchId })
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 清除指定任务步骤的所有分支
|
||||
function clearTaskProcessBranches(taskStepId: string) {
|
||||
taskProcessBranchesMap.value.delete(taskStepId)
|
||||
console.log('🗑️ 清除任务步骤的所有分支:', taskStepId)
|
||||
// 清除指定任务步骤和 agent 组合的所有分支
|
||||
function clearTaskProcessBranches(taskStepId: string, agents?: string[]) {
|
||||
if (agents) {
|
||||
// 清除指定 agent 组合的分支
|
||||
const agentGroupKey = getAgentGroupKey(agents)
|
||||
const agentMap = taskProcessBranchesMap.value.get(taskStepId)
|
||||
if (agentMap) {
|
||||
agentMap.delete(agentGroupKey)
|
||||
console.log('🗑️ 清除任务步骤的 agent 组合分支:', { taskStepId, agents })
|
||||
}
|
||||
} else {
|
||||
// 清除该任务步骤的所有分支(所有 agent 组合)
|
||||
taskProcessBranchesMap.value.delete(taskStepId)
|
||||
console.log('🗑️ 清除任务步骤的所有分支:', taskStepId)
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== Agent 组合 TaskProcess 数据存储 ====================
|
||||
@@ -166,7 +192,11 @@ export const useSelectionStore = defineStore('selection', () => {
|
||||
|
||||
// 生成 agent 组合的唯一 key(排序后保证一致性)
|
||||
function getAgentGroupKey(agents: string[]): string {
|
||||
return JSON.stringify(agents.sort())
|
||||
// 🆕 处理 undefined 或 null 的情况
|
||||
if (!agents || !Array.isArray(agents)) {
|
||||
return JSON.stringify([])
|
||||
}
|
||||
return JSON.stringify([...agents].sort())
|
||||
}
|
||||
|
||||
// 存储 agent 组合的 TaskProcess 数据
|
||||
@@ -208,40 +238,69 @@ export const useSelectionStore = defineStore('selection', () => {
|
||||
}
|
||||
|
||||
// ==================== 当前生效的任务过程分支 ====================
|
||||
// 记录每个任务步骤当前生效的分支 ID(持久化选中状态)
|
||||
// 结构: Map<taskStepId, branchId>
|
||||
const activeTaskProcessBranchMap = ref<Map<string, string>>(new Map())
|
||||
// 记录每个任务步骤和 agent 组合当前生效的分支 ID(持久化选中状态)
|
||||
// 结构: Map<taskStepId, Map<agentGroupKey, branchId>>
|
||||
// - taskStepId: 任务步骤ID
|
||||
// - agentGroupKey: agent 组合的唯一标识
|
||||
// - branchId: 当前选中的分支ID
|
||||
const activeTaskProcessBranchMap = ref<Map<string, Map<string, string>>>(new Map())
|
||||
|
||||
// 🆕 当前生效的 TaskProcess 数据(用于外部组件显示职责分配)
|
||||
// 结构: Map<taskStepId, TaskProcess[]>
|
||||
const activeTaskProcessDataMap = ref<Map<string, any[]>>(new Map())
|
||||
// 结构: Map<taskStepId, Map<agentGroupKey, TaskProcess[]>>
|
||||
const activeTaskProcessDataMap = ref<Map<string, Map<string, any[]>>>(new Map())
|
||||
|
||||
// 设置当前生效的分支
|
||||
function setActiveTaskProcessBranch(taskStepId: string, branchId: string) {
|
||||
activeTaskProcessBranchMap.value.set(taskStepId, branchId)
|
||||
console.log('✅ 设置当前生效分支:', { taskStepId, branchId })
|
||||
function setActiveTaskProcessBranch(taskStepId: string, agents: string[], branchId: string) {
|
||||
const agentGroupKey = getAgentGroupKey(agents)
|
||||
|
||||
// 获取或创建该任务步骤的 Map
|
||||
if (!activeTaskProcessBranchMap.value.has(taskStepId)) {
|
||||
activeTaskProcessBranchMap.value.set(taskStepId, new Map())
|
||||
}
|
||||
|
||||
activeTaskProcessBranchMap.value.get(taskStepId)!.set(agentGroupKey, branchId)
|
||||
console.log('✅ 设置当前生效分支:', { taskStepId, agents, agentGroupKey, branchId })
|
||||
}
|
||||
|
||||
// 🆕 设置当前生效的 TaskProcess 数据
|
||||
function setActiveTaskProcessData(taskStepId: string, taskProcess: any[]) {
|
||||
activeTaskProcessDataMap.value.set(taskStepId, taskProcess)
|
||||
console.log('✅ 设置当前生效的 TaskProcess 数据:', { taskStepId, taskProcess })
|
||||
function setActiveTaskProcessData(taskStepId: string, agents: string[], taskProcess: any[]) {
|
||||
const agentGroupKey = getAgentGroupKey(agents)
|
||||
|
||||
// 获取或创建该任务步骤的 Map
|
||||
if (!activeTaskProcessDataMap.value.has(taskStepId)) {
|
||||
activeTaskProcessDataMap.value.set(taskStepId, new Map())
|
||||
}
|
||||
|
||||
activeTaskProcessDataMap.value.get(taskStepId)!.set(agentGroupKey, taskProcess)
|
||||
console.log('✅ 设置当前生效的 TaskProcess 数据:', { taskStepId, agents, agentGroupKey, taskProcess })
|
||||
}
|
||||
|
||||
// 获取当前生效的分支 ID
|
||||
function getActiveTaskProcessBranch(taskStepId: string): string | undefined {
|
||||
return activeTaskProcessBranchMap.value.get(taskStepId)
|
||||
function getActiveTaskProcessBranch(taskStepId: string, agents: string[]): string | undefined {
|
||||
const agentGroupKey = getAgentGroupKey(agents)
|
||||
return activeTaskProcessBranchMap.value.get(taskStepId)?.get(agentGroupKey)
|
||||
}
|
||||
|
||||
// 🆕 获取当前生效的 TaskProcess 数据
|
||||
function getActiveTaskProcessData(taskStepId: string): any[] | undefined {
|
||||
return activeTaskProcessDataMap.value.get(taskStepId)
|
||||
function getActiveTaskProcessData(taskStepId: string, agents: string[]): any[] | undefined {
|
||||
const agentGroupKey = getAgentGroupKey(agents)
|
||||
return activeTaskProcessDataMap.value.get(taskStepId)?.get(agentGroupKey)
|
||||
}
|
||||
|
||||
// 清除生效分支
|
||||
function clearActiveTaskProcessBranch(taskStepId: string) {
|
||||
activeTaskProcessBranchMap.value.delete(taskStepId)
|
||||
activeTaskProcessDataMap.value.delete(taskStepId)
|
||||
function clearActiveTaskProcessBranch(taskStepId: string, agents?: string[]) {
|
||||
if (agents) {
|
||||
// 清除指定 agent 组合的生效分支
|
||||
const agentGroupKey = getAgentGroupKey(agents)
|
||||
activeTaskProcessBranchMap.value.get(taskStepId)?.delete(agentGroupKey)
|
||||
activeTaskProcessDataMap.value.get(taskStepId)?.delete(agentGroupKey)
|
||||
console.log('🗑️ 清除任务步骤的 agent 组合生效分支:', { taskStepId, agents })
|
||||
} else {
|
||||
// 清除该任务步骤的所有生效分支(所有 agent 组合)
|
||||
activeTaskProcessBranchMap.value.delete(taskStepId)
|
||||
activeTaskProcessDataMap.value.delete(taskStepId)
|
||||
console.log('🗑️ 清除任务步骤的所有生效分支:', taskStepId)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user