import { StoreApi, UseBoundStore } from 'zustand'; import { Agent, Task } from '..'; import { BaseAgent, Env, LLMConfig } from '../agents/baseAgent'; import { AGENT_STATUS_enum, FEEDBACK_STATUS_enum, TASK_STATUS_enum, WORKFLOW_STATUS_enum } from '../utils/enums'; import { WorkflowLog, WorkflowStats } from '../types/logs'; import { AgentStoreState } from './agentStore.types'; import { TaskResult, TaskStoreState } from './taskStore.types'; import { WorkflowLoopState } from './workflowLoopStore.types'; import { WorkflowDrivenAgentStoreState } from './workflowDrivenAgentStore'; export type CleanedLLMConfig = Partial | Record; export type CleanedAgent = Omit, 'agentInstance'> & { id: string; env: string; llmConfig: CleanedLLMConfig; agentInstance: Partial; }; export type CleanedBaseAgent = Omit, 'llmConfig' | 'executableAgent'> & { llmConfig: CleanedLLMConfig; }; export type CleanedFeedback = { content: string; status: FEEDBACK_STATUS_enum; timestamp: string; }; export type CleanedTask = Partial> & { id: string; agent: CleanedAgent | null; duration: string; endTime: string; startTime: string; feedbackHistory: CleanedFeedback[]; allowParallelExecution?: boolean; referenceId?: string; }; export type CleanedMetadata = { duration: string; endTime: string; startTime: string; feedback?: Partial; [key: string]: string | Partial | Record | undefined; }; export type CleanedWorkflowLog = Omit & { timestamp: string; metadata: CleanedMetadata; agent?: CleanedAgent | CleanedBaseAgent | null; task?: CleanedTask | null; }; export type CleanedTeamState = { teamWorkflowStatus: string; workflowResult: TaskResult | null; name: string; agents: CleanedAgent[]; tasks: CleanedTask[]; workflowLogs: CleanedWorkflowLog[]; inputs: Record; workflowContext: string; logLevel?: string; }; export interface TeamStoreState { teamWorkflowStatus: WORKFLOW_STATUS_enum; workflowResult: TaskResult | null; name: string; agents: Agent[]; tasks: Task[]; workflowLogs: WorkflowLog[]; inputs: Record; workflowContext: string; env: Env; logLevel?: string; memory: boolean; insights: string; flowType?: string; workflowExecutionStrategy: string; workflowController: Record; maxConcurrency: number; } export interface TeamStoreActions { setInputs: (inputs: Record) => void; setName: (name: string) => void; setEnv: (env: Env) => void; addAgents: (agents: Agent[]) => void; addTasks: (tasks: Task[]) => void; updateTaskStatus: (taskId: string, status: TASK_STATUS_enum) => void; setWorkflowExecutionStrategy: (strategy: string) => void; startWorkflow: (inputs?: Record) => Promise; resetWorkflowStateAction: () => void; finishWorkflowAction: () => void; setTeamWorkflowStatus: (status: WORKFLOW_STATUS_enum) => void; handleWorkflowError: (error: Error) => void; handleWorkflowBlocked: (task: Task, error: Error) => void; handleWorkflowAborted: (task: Task, error: Error) => void; workOnTask: (agent: Agent, task: Task, context: string, customInputs?: Record) => Promise; workOnTaskResume: (agent: Agent, task: Task) => Promise; deriveContextFromLogs: (logs: WorkflowLog[], currentTaskId: string) => string; provideFeedback: (taskId: string, feedbackContent: string) => Promise; validateTask: (taskId: string) => Promise; clearAll: () => void; getWorkflowStats: () => WorkflowStats; getTaskResults: () => Record; prepareWorkflowStatusUpdateLog: (params: NewLogParams) => T; } export type NewLogParams = { task?: Task; agent?: Agent; logDescription: string; workflowStatus?: WORKFLOW_STATUS_enum; taskStatus?: TASK_STATUS_enum; agentStatus?: AGENT_STATUS_enum; logType: T['logType']; metadata?: T['metadata']; }; export type CombinedStoresState = AgentStoreState & TaskStoreState & WorkflowLoopState & TeamStoreState & TeamStoreActions & WorkflowDrivenAgentStoreState; export type TeamStore = UseBoundStore>;