using System; using System.Collections.Generic; using Newtonsoft.Json; namespace AI.AgentIntegration { /// /// 表示应用程序的整体状态 /// public class AppState { /// /// 获取或设置用户界面状态 /// public UIState UI { get; set; } = new UIState(); /// /// 获取或设置文件状态 /// public FileState File { get; set; } = new FileState(); /// /// 获取或设置导航状态 /// public NavigationState Navigation { get; set; } = new NavigationState(); /// /// 获取或设置系统状态 /// public SystemState System { get; set; } = new SystemState(); /// /// 获取或设置代理状态 /// public AgentState Agent { get; set; } = new AgentState(); /// /// 将当前状态序列化为 JSON 字符串 /// /// 是否使用缩进格式 /// 表示当前状态的 JSON 字符串 public string ToJson(bool indented = true) { return JsonConvert.SerializeObject(this, indented ? Formatting.Indented : Formatting.None); } } /// /// 表示用户界面状态 /// public class UIState { /// /// 获取或设置活动标签页的标识符 /// public string ActiveTab { get; set; } = string.Empty; /// /// 获取或设置打开的标签页列表 /// public List OpenTabs { get; set; } = new List(); /// /// 获取或设置当前获得焦点的控件 /// public string FocusedControl { get; set; } = string.Empty; } /// /// 表示文件状态 /// public class FileState { /// /// 获取或设置活动文件的路径 /// public string ActiveFilePath { get; set; } = string.Empty; /// /// 获取或设置是否有未保存的更改 /// public bool HasUnsavedChanges { get; set; } /// /// 获取或设置文件类型 /// public string FileType { get; set; } = string.Empty; } /// /// 表示导航状态 /// public class NavigationState { /// /// 获取或设置当前视图名称 /// public string CurrentView { get; set; } = "Home"; /// /// 获取或设置导航堆栈 /// public List NavigationStack { get; set; } = new List(); } /// /// 表示系统状态 /// public class SystemState { /// /// 获取或设置系统是否处于忙碌状态 /// public bool IsBusy { get; set; } /// /// 获取或设置是否有模态对话框打开 /// public bool ModalOpen { get; set; } /// /// 获取或设置最后一次操作的时间(UTC) /// public DateTime LastActionTimeUtc { get; set; } = DateTime.UtcNow; } /// /// 表示代理状态 /// public class AgentState { /// /// 获取或设置代理的操作模式 /// public AgentMode Mode { get; set; } = AgentMode.Observe; /// /// 获取或设置最后执行的命令 /// public string LastCommand { get; set; } = string.Empty; /// /// 获取或设置最后命令的执行结果 /// public string LastResult { get; set; } = string.Empty; } }