返回 AiToEarn
agent.state.ts
根目录 / project / aitoearn-web / src / store / agent / agent.state.ts
1 /**
2 * Agent Store - 状态定义
3 * 初始状态和状态类型
4 */
5
6 import type { IAgentState, ITaskMessageData } from './agent.types'
7 import lodash from 'lodash'
8
9 // ============ 默认任务数据 ============
10
11 /** 获取默认的任务消息数据 */
12 export function getDefaultTaskData(): ITaskMessageData {
13 return {
14 messages: [],
15 markdownMessages: [],
16 workflowSteps: [],
17 streamingText: '',
18 progress: 0,
19 isGenerating: false,
20 lastUpdated: 0,
21 }
22 }
23
24 // ============ 初始状态 ============
25
26 export const initialState: IAgentState = {
27 // 当前活跃任务
28 currentTaskId: '',
29
30 // 任务消息存储(按 taskId 隔离)
31 taskMessages: {},
32
33 // 全局状态
34 currentCost: 0,
35 pendingTask: null,
36
37 // Debug 模式状态
38 debugFiles: [],
39 debugMessageIndex: 0,
40 }
41
42 /**
43 * 获取初始状态的深拷贝
44 */
45 export function getInitialState(): IAgentState {
46 return lodash.cloneDeep(initialState)
47 }
48
48 lines TYPESCRIPT