2025-12-31 19:04:58 +08:00
|
|
|
|
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'
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 分支数据接口
|
|
|
|
|
|
* @description 用于存储流程图中的分支节点和边数据
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
export interface IBranchData {
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/** 分支唯一 ID */
|
|
|
|
|
|
id: string
|
|
|
|
|
|
/** 父节点 ID(根节点或任务节点) */
|
|
|
|
|
|
parentNodeId: string
|
|
|
|
|
|
/** 分支需求内容 */
|
|
|
|
|
|
branchContent: string
|
|
|
|
|
|
/** 分支类型 */
|
|
|
|
|
|
branchType: 'root' | 'task'
|
|
|
|
|
|
/** 分支包含的所有节点 */
|
|
|
|
|
|
nodes: Node[]
|
|
|
|
|
|
/** 分支包含的所有边 */
|
|
|
|
|
|
edges: Edge[]
|
|
|
|
|
|
/** 分支的任务数据 */
|
|
|
|
|
|
tasks: IRawStepTask[]
|
|
|
|
|
|
/** 创建时间 */
|
|
|
|
|
|
createdAt: number
|
2025-12-31 19:04:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const useSelectionStore = defineStore('selection', () => {
|
|
|
|
|
|
// ==================== 任务大纲探索分支数据存储 ====================
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/** 流程图分支列表 */
|
|
|
|
|
|
const flowBranches = ref<IBranchData[]>([])
|
2025-12-31 19:04:58 +08:00
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 添加流程图分支
|
|
|
|
|
|
* @param data 分支数据
|
|
|
|
|
|
* @returns 分支 ID
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
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)
|
|
|
|
|
|
return branchId
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取所有流程图分支
|
|
|
|
|
|
* @returns 所有流程图分支数据
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
function getAllFlowBranches(): IBranchData[] {
|
|
|
|
|
|
return flowBranches.value
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 根据父节点 ID 获取流程图分支
|
|
|
|
|
|
* @param parentNodeId 父节点 ID
|
|
|
|
|
|
* @returns 匹配的流程图分支列表
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
function getFlowBranchesByParent(parentNodeId: string): IBranchData[] {
|
|
|
|
|
|
return flowBranches.value.filter((branch) => branch.parentNodeId === parentNodeId)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 删除流程图分支
|
|
|
|
|
|
* @param branchId 分支 ID
|
|
|
|
|
|
* @returns 是否删除成功
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
function removeFlowBranch(branchId: string): boolean {
|
|
|
|
|
|
const index = flowBranches.value.findIndex((branch) => branch.id === branchId)
|
|
|
|
|
|
if (index > -1) {
|
|
|
|
|
|
flowBranches.value.splice(index, 1)
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/** 清除所有流程图分支 */
|
2025-12-31 19:04:58 +08:00
|
|
|
|
function clearFlowBranches() {
|
|
|
|
|
|
flowBranches.value = []
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 根据父节点 ID 清除流程图分支
|
|
|
|
|
|
* @param parentNodeId 父节点 ID
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
function clearFlowBranchesByParent(parentNodeId: string) {
|
|
|
|
|
|
flowBranches.value = flowBranches.value.filter((branch) => branch.parentNodeId !== parentNodeId)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 任务过程探索分支数据存储 ====================
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 任务过程分支数据映射
|
|
|
|
|
|
* @description 存储结构: Map<taskStepId, Map<agentGroupKey, IBranchData[]>>
|
|
|
|
|
|
* - taskStepId: 任务步骤 ID
|
|
|
|
|
|
* - agentGroupKey: agent 组合的唯一标识(排序后的 JSON 字符串)
|
|
|
|
|
|
* - IBranchData[]: 该 agent 组合在该任务下的所有分支数据
|
|
|
|
|
|
*/
|
2026-01-13 13:57:56 +08:00
|
|
|
|
const taskProcessBranchesMap = ref<Map<string, Map<string, IBranchData[]>>>(new Map())
|
2025-12-31 19:04:58 +08:00
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 添加任务过程分支
|
|
|
|
|
|
* @param taskStepId 任务步骤 ID
|
|
|
|
|
|
* @param agents Agent 列表
|
|
|
|
|
|
* @param data 分支数据
|
|
|
|
|
|
* @returns 分支 ID
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
function addTaskProcessBranch(
|
|
|
|
|
|
taskStepId: string,
|
2026-01-19 09:12:06 +08:00
|
|
|
|
agents: string[],
|
2025-12-31 19:04:58 +08:00
|
|
|
|
data: {
|
|
|
|
|
|
parentNodeId: string
|
|
|
|
|
|
branchContent: string
|
|
|
|
|
|
branchType: 'root' | 'task'
|
|
|
|
|
|
nodes: Node[]
|
|
|
|
|
|
edges: Edge[]
|
|
|
|
|
|
tasks: IRawStepTask[]
|
|
|
|
|
|
},
|
|
|
|
|
|
): string {
|
|
|
|
|
|
const branchId = `task-process-branch-${uuidv4()}`
|
2026-01-19 09:12:06 +08:00
|
|
|
|
const agentGroupKey = getAgentGroupKey(agents)
|
2026-01-13 13:57:56 +08:00
|
|
|
|
|
2025-12-31 19:04:58 +08:00
|
|
|
|
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(),
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-13 13:57:56 +08:00
|
|
|
|
// 获取或创建该任务步骤的 Map
|
2025-12-31 19:04:58 +08:00
|
|
|
|
if (!taskProcessBranchesMap.value.has(taskStepId)) {
|
2026-01-13 13:57:56 +08:00
|
|
|
|
taskProcessBranchesMap.value.set(taskStepId, new Map())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取或创建该 agent 组合的分支列表
|
|
|
|
|
|
const agentMap = taskProcessBranchesMap.value.get(taskStepId)!
|
|
|
|
|
|
if (!agentMap.has(agentGroupKey)) {
|
|
|
|
|
|
agentMap.set(agentGroupKey, [])
|
2025-12-31 19:04:58 +08:00
|
|
|
|
}
|
2026-01-13 13:57:56 +08:00
|
|
|
|
agentMap.get(agentGroupKey)!.push(newBranch)
|
2025-12-31 19:04:58 +08:00
|
|
|
|
|
|
|
|
|
|
return branchId
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取指定任务步骤和 agent 组合的所有分支
|
|
|
|
|
|
* @param taskStepId 任务步骤 ID
|
|
|
|
|
|
* @param agents Agent 列表
|
|
|
|
|
|
* @returns 匹配的任务过程分支列表
|
|
|
|
|
|
*/
|
2026-01-13 13:57:56 +08:00
|
|
|
|
function getTaskProcessBranches(taskStepId: string, agents: string[]): IBranchData[] {
|
|
|
|
|
|
const agentGroupKey = getAgentGroupKey(agents)
|
|
|
|
|
|
return taskProcessBranchesMap.value.get(taskStepId)?.get(agentGroupKey) || []
|
2025-12-31 19:04:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取所有任务过程分支
|
|
|
|
|
|
* @returns 所有任务过程分支数据映射
|
|
|
|
|
|
*/
|
2026-01-13 13:57:56 +08:00
|
|
|
|
function getAllTaskProcessBranches(): Map<string, Map<string, IBranchData[]>> {
|
2025-12-31 19:04:58 +08:00
|
|
|
|
return taskProcessBranchesMap.value
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 根据父节点 ID 获取任务过程分支
|
|
|
|
|
|
* @param taskStepId 任务步骤 ID
|
|
|
|
|
|
* @param agents Agent 列表
|
|
|
|
|
|
* @param parentNodeId 父节点 ID
|
|
|
|
|
|
* @returns 匹配的任务过程分支列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
function getTaskProcessBranchesByParent(
|
|
|
|
|
|
taskStepId: string,
|
|
|
|
|
|
agents: string[],
|
|
|
|
|
|
parentNodeId: string,
|
|
|
|
|
|
): IBranchData[] {
|
2026-01-13 13:57:56 +08:00
|
|
|
|
const agentGroupKey = getAgentGroupKey(agents)
|
|
|
|
|
|
const branches = taskProcessBranchesMap.value.get(taskStepId)?.get(agentGroupKey) || []
|
2025-12-31 19:04:58 +08:00
|
|
|
|
return branches.filter((branch) => branch.parentNodeId === parentNodeId)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 删除任务过程分支
|
|
|
|
|
|
* @param taskStepId 任务步骤 ID
|
|
|
|
|
|
* @param agents Agent 列表
|
|
|
|
|
|
* @param branchId 分支 ID
|
|
|
|
|
|
* @returns 是否删除成功
|
|
|
|
|
|
*/
|
|
|
|
|
|
function removeTaskProcessBranch(
|
|
|
|
|
|
taskStepId: string,
|
|
|
|
|
|
agents: string[],
|
|
|
|
|
|
branchId: string,
|
|
|
|
|
|
): boolean {
|
2026-01-13 13:57:56 +08:00
|
|
|
|
const agentGroupKey = getAgentGroupKey(agents)
|
|
|
|
|
|
const branches = taskProcessBranchesMap.value.get(taskStepId)?.get(agentGroupKey)
|
2025-12-31 19:04:58 +08:00
|
|
|
|
if (branches) {
|
|
|
|
|
|
const index = branches.findIndex((branch) => branch.id === branchId)
|
|
|
|
|
|
if (index > -1) {
|
|
|
|
|
|
branches.splice(index, 1)
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 清除指定任务步骤和 agent 组合的所有分支
|
|
|
|
|
|
* @param taskStepId 任务步骤 ID
|
|
|
|
|
|
* @param agents Agent 列表(可选,不传则清除该任务步骤的所有分支)
|
|
|
|
|
|
*/
|
2026-01-13 13:57:56 +08:00
|
|
|
|
function clearTaskProcessBranches(taskStepId: string, agents?: string[]) {
|
|
|
|
|
|
if (agents) {
|
|
|
|
|
|
// 清除指定 agent 组合的分支
|
|
|
|
|
|
const agentGroupKey = getAgentGroupKey(agents)
|
|
|
|
|
|
const agentMap = taskProcessBranchesMap.value.get(taskStepId)
|
|
|
|
|
|
if (agentMap) {
|
|
|
|
|
|
agentMap.delete(agentGroupKey)
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 清除该任务步骤的所有分支(所有 agent 组合)
|
|
|
|
|
|
taskProcessBranchesMap.value.delete(taskStepId)
|
|
|
|
|
|
}
|
2025-12-31 19:04:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== Agent 组合 TaskProcess 数据存储 ====================
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Agent 组合 TaskProcess 数据映射
|
|
|
|
|
|
* @description 用于存储 fill_stepTask_TaskProcess 接口返回的数据
|
|
|
|
|
|
* 存储结构: Map<taskId, Map<agentGroupKey, IApiStepTask>>
|
|
|
|
|
|
* - taskId: 任务 ID
|
|
|
|
|
|
* - agentGroupKey: agent 组合的唯一标识(排序后的 JSON 字符串)
|
|
|
|
|
|
* - IApiStepTask: 该 agent 组合的完整 TaskProcess 数据
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
const agentTaskProcessMap = ref<Map<string, Map<string, IApiStepTask>>>(new Map())
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 生成 agent 组合的唯一 key
|
|
|
|
|
|
* @description 排序后保证一致性
|
|
|
|
|
|
* @param agents Agent 列表
|
|
|
|
|
|
* @returns Agent 组合的唯一标识
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
function getAgentGroupKey(agents: string[]): string {
|
2026-01-19 09:12:06 +08:00
|
|
|
|
// 处理 undefined 或 null 的情况
|
2026-01-13 13:57:56 +08:00
|
|
|
|
if (!agents || !Array.isArray(agents)) {
|
|
|
|
|
|
return JSON.stringify([])
|
|
|
|
|
|
}
|
|
|
|
|
|
return JSON.stringify([...agents].sort())
|
2025-12-31 19:04:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 存储 agent 组合的 TaskProcess 数据
|
|
|
|
|
|
* @param taskId 任务 ID
|
|
|
|
|
|
* @param agents Agent 列表
|
|
|
|
|
|
* @param taskProcess TaskProcess 数据
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
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)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取 agent 组合的 TaskProcess 数据
|
|
|
|
|
|
* @param taskId 任务 ID
|
|
|
|
|
|
* @param agents Agent 列表
|
|
|
|
|
|
* @returns TaskProcess 数据
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
function getAgentTaskProcess(taskId: string, agents: string[]): IApiStepTask | undefined {
|
|
|
|
|
|
const groupKey = getAgentGroupKey(agents)
|
|
|
|
|
|
return agentTaskProcessMap.value.get(taskId)?.get(groupKey)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 检查 agent 组合是否已有 TaskProcess 数据
|
|
|
|
|
|
* @param taskId 任务 ID
|
|
|
|
|
|
* @param agents Agent 列表
|
|
|
|
|
|
* @returns 是否存在数据
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
function hasAgentTaskProcess(taskId: string, agents: string[]): boolean {
|
|
|
|
|
|
const groupKey = getAgentGroupKey(agents)
|
|
|
|
|
|
return agentTaskProcessMap.value.get(taskId)?.has(groupKey) || false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 清除指定任务的所有 agent 组合 TaskProcess 数据
|
|
|
|
|
|
* @param taskId 任务 ID
|
|
|
|
|
|
*/
|
2025-12-31 19:04:58 +08:00
|
|
|
|
function clearAgentTaskProcess(taskId: string) {
|
|
|
|
|
|
agentTaskProcessMap.value.delete(taskId)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/** 清除所有任务的 agent 组合 TaskProcess 数据 */
|
2025-12-31 19:04:58 +08:00
|
|
|
|
function clearAllAgentTaskProcess() {
|
|
|
|
|
|
agentTaskProcessMap.value.clear()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-09 13:54:32 +08:00
|
|
|
|
// ==================== 当前生效的任务过程分支 ====================
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 当前生效的任务过程分支映射
|
|
|
|
|
|
* @description 记录每个任务步骤和 agent 组合当前生效的分支 ID(持久化选中状态)
|
|
|
|
|
|
* 存储结构: Map<taskStepId, Map<agentGroupKey, branchId>>
|
|
|
|
|
|
* - taskStepId: 任务步骤 ID
|
|
|
|
|
|
* - agentGroupKey: agent 组合的唯一标识
|
|
|
|
|
|
* - branchId: 当前选中的分支 ID
|
|
|
|
|
|
*/
|
2026-01-13 13:57:56 +08:00
|
|
|
|
const activeTaskProcessBranchMap = ref<Map<string, Map<string, string>>>(new Map())
|
2026-01-09 13:54:32 +08:00
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 当前生效的 TaskProcess 数据映射
|
|
|
|
|
|
* @description 用于外部组件显示职责分配
|
|
|
|
|
|
* 存储结构: Map<taskStepId, Map<agentGroupKey, TaskProcess[]>>
|
|
|
|
|
|
*/
|
2026-01-13 13:57:56 +08:00
|
|
|
|
const activeTaskProcessDataMap = ref<Map<string, Map<string, any[]>>>(new Map())
|
2026-01-09 13:54:32 +08:00
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 设置当前生效的分支
|
|
|
|
|
|
* @param taskStepId 任务步骤 ID
|
|
|
|
|
|
* @param agents Agent 列表
|
|
|
|
|
|
* @param branchId 分支 ID
|
|
|
|
|
|
*/
|
2026-01-13 13:57:56 +08:00
|
|
|
|
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)
|
2026-01-09 13:54:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 设置当前生效的 TaskProcess 数据
|
|
|
|
|
|
* @param taskStepId 任务步骤 ID
|
|
|
|
|
|
* @param agents Agent 列表
|
|
|
|
|
|
* @param taskProcess TaskProcess 数据
|
|
|
|
|
|
*/
|
2026-01-13 13:57:56 +08:00
|
|
|
|
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)
|
2026-01-09 13:54:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取当前生效的分支 ID
|
|
|
|
|
|
* @param taskStepId 任务步骤 ID
|
|
|
|
|
|
* @param agents Agent 列表
|
|
|
|
|
|
* @returns 分支 ID
|
|
|
|
|
|
*/
|
2026-01-13 13:57:56 +08:00
|
|
|
|
function getActiveTaskProcessBranch(taskStepId: string, agents: string[]): string | undefined {
|
|
|
|
|
|
const agentGroupKey = getAgentGroupKey(agents)
|
|
|
|
|
|
return activeTaskProcessBranchMap.value.get(taskStepId)?.get(agentGroupKey)
|
2026-01-09 13:54:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取当前生效的 TaskProcess 数据
|
|
|
|
|
|
* @param taskStepId 任务步骤 ID
|
|
|
|
|
|
* @param agents Agent 列表
|
|
|
|
|
|
* @returns TaskProcess 数据
|
|
|
|
|
|
*/
|
2026-01-13 13:57:56 +08:00
|
|
|
|
function getActiveTaskProcessData(taskStepId: string, agents: string[]): any[] | undefined {
|
|
|
|
|
|
const agentGroupKey = getAgentGroupKey(agents)
|
|
|
|
|
|
return activeTaskProcessDataMap.value.get(taskStepId)?.get(agentGroupKey)
|
2026-01-09 13:54:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 清除生效分支
|
|
|
|
|
|
* @param taskStepId 任务步骤 ID
|
|
|
|
|
|
* @param agents Agent 列表(可选,不传则清除该任务步骤的所有生效分支)
|
|
|
|
|
|
*/
|
2026-01-13 13:57:56 +08:00
|
|
|
|
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)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 清除该任务步骤的所有生效分支(所有 agent 组合)
|
|
|
|
|
|
activeTaskProcessBranchMap.value.delete(taskStepId)
|
|
|
|
|
|
activeTaskProcessDataMap.value.delete(taskStepId)
|
|
|
|
|
|
}
|
2026-01-09 13:54:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-31 19:04:58 +08:00
|
|
|
|
return {
|
2026-01-19 09:12:06 +08:00
|
|
|
|
// ==================== 状态 ====================
|
2025-12-31 19:04:58 +08:00
|
|
|
|
flowBranches,
|
|
|
|
|
|
taskProcessBranchesMap,
|
|
|
|
|
|
agentTaskProcessMap,
|
2026-01-09 13:54:32 +08:00
|
|
|
|
activeTaskProcessBranchMap,
|
2026-01-19 09:12:06 +08:00
|
|
|
|
activeTaskProcessDataMap,
|
2025-12-31 19:04:58 +08:00
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
// ==================== 任务大纲分支管理方法 ====================
|
2025-12-31 19:04:58 +08:00
|
|
|
|
addFlowBranch,
|
|
|
|
|
|
getAllFlowBranches,
|
|
|
|
|
|
getFlowBranchesByParent,
|
|
|
|
|
|
removeFlowBranch,
|
|
|
|
|
|
clearFlowBranches,
|
|
|
|
|
|
clearFlowBranchesByParent,
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
// ==================== 任务过程分支管理方法 ====================
|
2025-12-31 19:04:58 +08:00
|
|
|
|
addTaskProcessBranch,
|
|
|
|
|
|
getTaskProcessBranches,
|
|
|
|
|
|
getAllTaskProcessBranches,
|
|
|
|
|
|
getTaskProcessBranchesByParent,
|
|
|
|
|
|
removeTaskProcessBranch,
|
|
|
|
|
|
clearTaskProcessBranches,
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
// ==================== 任务过程分支生效状态管理方法 ====================
|
2026-01-09 13:54:32 +08:00
|
|
|
|
setActiveTaskProcessBranch,
|
2026-01-19 09:12:06 +08:00
|
|
|
|
setActiveTaskProcessData,
|
2026-01-09 13:54:32 +08:00
|
|
|
|
getActiveTaskProcessBranch,
|
2026-01-19 09:12:06 +08:00
|
|
|
|
getActiveTaskProcessData,
|
2026-01-09 13:54:32 +08:00
|
|
|
|
clearActiveTaskProcessBranch,
|
|
|
|
|
|
|
2026-01-19 09:12:06 +08:00
|
|
|
|
// ==================== Agent 组合 TaskProcess 数据管理方法 ====================
|
2025-12-31 19:04:58 +08:00
|
|
|
|
getAgentGroupKey,
|
|
|
|
|
|
setAgentTaskProcess,
|
|
|
|
|
|
getAgentTaskProcess,
|
|
|
|
|
|
hasAgentTaskProcess,
|
|
|
|
|
|
clearAgentTaskProcess,
|
|
|
|
|
|
clearAllAgentTaskProcess,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 用于在组件外部使用 Selection Store
|
2026-01-19 09:12:06 +08:00
|
|
|
|
* @returns Selection Store 实例
|
2025-12-31 19:04:58 +08:00
|
|
|
|
*/
|
|
|
|
|
|
export function useSelectionStoreHook() {
|
|
|
|
|
|
return useSelectionStore(store)
|
|
|
|
|
|
}
|