feat: 将插件 stdin 协议定为 v1,并按声明注入凭据

进程外插件改为只读环境变量和自身配置,避免读宿主 appsettings;宿主按 plugin.json 声明注入 LLM / OpenWeather 等凭据。
This commit is contained in:
2026-09-11 10:46:52 +08:00
parent d1b979f2db
commit b631acd42e
22 changed files with 377 additions and 95 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ using MAF1.Utils;
PluginRequest request = await PluginStdio.ReadRequestAsync();
PluginStdio.ApplyCredentialsToEnvironment(request.Credentials);
AgentFactory factory = new(AgentFactory.Load(PluginStdio.LoadHostConfiguration()));
AgentFactory factory = new(AgentFactory.LoadFromEnvironment());
var result = await FileCityAgent.RunAsync(FileCityAgent.Create(factory), request.Inputs);
await PluginStdio.WriteOutputsAsync(result.Outputs);
return 0;
+3
View File
@@ -2,6 +2,8 @@
独立进程。宿主只读取本目录的 `plugin.json`,按 `launch` 原样启动,不会替你拼命令。
`protocolVersion` 为 1。LLM 只从环境变量读取(宿主注入),不读宿主 `appsettings.json`
## 输入 / 输出
字段名必须和 `plugin.json` 以及 `Program.cs` 里读写的 JSON 键一致。
@@ -24,6 +26,7 @@ stdin
```json
{
"protocolVersion": 1,
"inputs": { "filePath": "Data/cities.txt" },
"credentials": {
"llm": { "id": "llm-default", "type": "openai-compatible", "endpoint": "...", "apiKey": "...", "model": "..." }
+1
View File
@@ -3,6 +3,7 @@
"name": "FileCityAgent",
"description": "读取指定文本文件,判断并抽出有效城市名。",
"version": "1.0.0",
"protocolVersion": 1,
"timeoutSeconds": 120,
"launch": {
"command": "dotnet",