You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
4.1 KiB
C#

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