feat: 拆分 CLI 与网页宿主,并在无有效城市时暂停等人确认
将原单体 MAF1 拆成 MAF1(控制台工作流)和 MAF1.Web(可视化编排)。 抽城市失败时暂停:网页弹确认、CLI 控制台询问,超时采用默认结束查询; 也可改填城市后继续。共享决策模型放在 MAF1.Core。
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using MAF1.Agents.FileCity;
|
||||
using MAF1.Agents.Weather;
|
||||
using MAF1.Plugins;
|
||||
using MAF1.Tools;
|
||||
using MAF1.Utils;
|
||||
using Microsoft.Agents.AI;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace MAF1.Web;
|
||||
|
||||
public sealed class AgentRuntime
|
||||
{
|
||||
public AgentRuntime(IConfiguration config)
|
||||
{
|
||||
AgentFactory factory = new(AgentFactory.Load(config));
|
||||
WeatherOptions weatherOptions = config.GetSection("Weather").Get<WeatherOptions>() ?? new WeatherOptions();
|
||||
Http = WeatherTools.CreateHttpClient();
|
||||
WeatherTools weatherTools = new(weatherOptions, Http);
|
||||
FileCity = FileCityAgent.Create(factory);
|
||||
Weather = WeatherAgent.Create(factory, weatherTools);
|
||||
PluginOptions pluginOptions = PluginOptions.Load(config);
|
||||
Credentials = new CredentialStore(config);
|
||||
Scanner = new PluginScanner(pluginOptions);
|
||||
Catalog = new NodeCatalogService(Scanner);
|
||||
PluginRunner = new PluginProcessRunner(pluginOptions, Credentials);
|
||||
RunStore = new WorkflowRunStore();
|
||||
DecisionTimeoutSeconds = Math.Clamp(config.GetValue("Workflow:DecisionTimeoutSeconds", 30), 1, 600);
|
||||
Runner = new ConfigurableWorkflowRunner(FileCity, Weather, Catalog, PluginRunner, RunStore, DecisionTimeoutSeconds);
|
||||
WeatherProvider = weatherOptions.Provider;
|
||||
PluginsRoot = pluginOptions.ResolveRoot();
|
||||
}
|
||||
|
||||
public AIAgent FileCity { get; }
|
||||
public AIAgent Weather { get; }
|
||||
public ConfigurableWorkflowRunner Runner { get; }
|
||||
public WorkflowRunStore RunStore { get; }
|
||||
public int DecisionTimeoutSeconds { get; }
|
||||
public NodeCatalogService Catalog { get; }
|
||||
public PluginScanner Scanner { get; }
|
||||
public PluginProcessRunner PluginRunner { get; }
|
||||
public CredentialStore Credentials { get; }
|
||||
public string WeatherProvider { get; }
|
||||
public string PluginsRoot { get; }
|
||||
public HttpClient Http { get; }
|
||||
}
|
||||
Reference in New Issue
Block a user