Files
MAF1/Plugins/weather/Program.cs
T
admin777 950d09ddb0 docs: 为 CLI、网页编排器和插件协议补充学习向注释
在核心类型、图执行器、stdio 插件和前端入口写清职责与对照路径,不改运行行为。
2026-08-28 11:51:48 +08:00

20 lines
831 B
C#

// 进程外 Weather 插件。同样只做 stdio 适配,天气实现仍在 MAF1.Core。
using MAF1.Agents.Weather;
using MAF1.PluginContract;
using MAF1.Tools;
using MAF1.Utils;
using Microsoft.Extensions.Configuration;
PluginRequest request = await PluginStdio.ReadRequestAsync();
PluginStdio.ApplyCredentialsToEnvironment(request.Credentials);
IConfiguration config = PluginStdio.LoadHostConfiguration();
AgentFactory factory = new(AgentFactory.Load(config));
WeatherOptions weatherOptions = config.GetSection("Weather").Get<WeatherOptions>() ?? new WeatherOptions();
using HttpClient http = WeatherTools.CreateHttpClient();
var result = await WeatherAgent.RunAsync(
WeatherAgent.Create(factory, new WeatherTools(weatherOptions, http)),
request.Inputs);
await PluginStdio.WriteOutputsAsync(result.Outputs);
return 0;