feat: 拆分 CLI 与网页宿主,并在无有效城市时暂停等人确认

将原单体 MAF1 拆成 MAF1(控制台工作流)和 MAF1.Web(可视化编排)。
抽城市失败时暂停:网页弹确认、CLI 控制台询问,超时采用默认结束查询;
也可改填城市后继续。共享决策模型放在 MAF1.Core。
This commit is contained in:
2026-08-28 10:43:57 +08:00
parent 5544788917
commit a3cca78592
42 changed files with 1427 additions and 457 deletions
+103
View File
@@ -0,0 +1,103 @@
using MAF1.PluginContract;
namespace MAF1.Web;
public sealed class PortInfo
{
public string Name { get; init; } = "";
public string Type { get; init; } = "";
public string Description { get; init; } = "";
public bool Required { get; init; }
}
public sealed class AgentTypeInfo
{
public string Type { get; init; } = "";
public string Name { get; init; } = "";
public string Description { get; init; } = "";
public string Origin { get; set; } = "system";
public string Version { get; init; } = "";
public string Folder { get; init; } = "";
public bool Overridden { get; set; }
/// <summary>
/// 进程内实现。系统节点必填;插件节点为 None,走独立进程。
/// </summary>
public SystemHandler Handler { get; init; }
public IReadOnlyList<PortInfo> Inputs { get; init; } = [];
public IReadOnlyList<PortInfo> Outputs { get; init; } = [];
public IReadOnlyList<PluginCredentialNeed> Credentials { get; init; } = [];
}
public enum SystemHandler
{
None = 0,
FileCity,
Weather,
}
public static class AgentCatalog
{
public static AgentTypeInfo? FindSystem(string type)
=> SystemNodes.FirstOrDefault(item => item.Type.Equals(type, StringComparison.OrdinalIgnoreCase));
public static IReadOnlyList<AgentTypeInfo> SystemNodes { get; } =
[
new()
{
Type = "fileCity-system",
Name = "FileCityAgent-System",
Description = "读取指定文本文件,判断并抽出有效城市名(系统内置实现)。",
Origin = "system",
Handler = SystemHandler.FileCity,
Inputs =
[
new PortInfo { Name = "filePath", Type = "string", Description = "本地文件路径,例如 Data/cities.txt", Required = true },
],
Outputs =
[
new PortInfo { Name = "hasValidCities", Type = "bool", Description = "是否存在有效城市" },
new PortInfo { Name = "cities", Type = "string[]", Description = "" },
new PortInfo { Name = "reason", Type = "string", Description = "判断说明" },
new PortInfo { Name = "raw", Type = "string", Description = "Agent 原始文本" },
],
Credentials =
[
new PluginCredentialNeed
{
Name = "llm",
Type = "openai-compatible",
Required = true,
Description = "OpenAI 兼容接口:endpoint + apiKey + model",
},
],
},
new()
{
Type = "weather-system",
Name = "WeatherAgent-System",
Description = "按城市列表查询天气并汇总(系统内置实现)。",
Origin = "system",
Handler = SystemHandler.Weather,
Inputs =
[
new PortInfo { Name = "cities", Type = "string[]", Description = "", Required = true },
],
Outputs =
[
new PortInfo { Name = "summary", Type = "string", Description = "天气汇总文本" },
],
Credentials =
[
new PluginCredentialNeed
{
Name = "llm",
Type = "openai-compatible",
Required = true,
Description = "OpenAI 兼容接口:endpoint + apiKey + model",
},
],
},
];
}