Files
MAF1/Plugins/README.md
T
admin777 b631acd42e feat: 将插件 stdin 协议定为 v1,并按声明注入凭据
进程外插件改为只读环境变量和自身配置,避免读宿主 appsettings;宿主按 plugin.json 声明注入 LLM / OpenWeather 等凭据。
2026-09-11 10:46:52 +08:00

34 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 插件目录
每个子文件夹是一个插件。软件启动后扫描**网页宿主执行目录**下的 `plugins/`(即 `MAF1.Web.exe` 旁边),不是源码目录。
协议:`plugin.json``protocolVersion`**1**(缺省也当 1)。stdin 形状见 [docs/plugin-protocol-v1.schema.json](../docs/plugin-protocol-v1.schema.json)。
## 必备文件
- `plugin.json`id、protocolVersion、启动命令、凭据声明、inputs、outputs
- `README.md`:给使用者看的说明
- 可执行文件 / 脚本 / 源码:由 `launch.command` + `launch.args` 原样启动
非秘密配置(例如天气 URL 模板)放在**插件自己目录**的 `appsettings.json``plugin.json``env`。不要去读宿主 exe 旁的配置文件。
## 凭据(不要写进 plugin.json
n8n / Dify 一类产品把 API Key 放在宿主凭据库,节点只声明「我需要哪种凭据」。本项目同样:
- Key 和 endpoint 配在宿主的环境变量或 `appsettings.json``Credentials` / `Llm`
- 节点可选 `credentialId`LLM,默认 `llm-default`);其它类型用 `credential:<name>` 或按 type 取默认
- 只注入 **plugin.json 里声明过的**凭据。未声明 LLM 的插件拿不到 `OPENAI_API_KEY`
- 启动子进程时写入对应环境变量,并在 stdin JSON 的 `credentials` 里再传一份
- 浏览器和流程图 JSON **不会**包含 apiKey
已知 `type` 与环境变量:
| type | 环境变量 |
|------|----------|
| `openai-compatible` / `llm` | `OPENAI_ENDPOINT` / `OPENAI_API_KEY` / `OPENAI_CHAT_MODEL` |
| `openweather` | `OPENWEATHER_API_KEY` |
| 其它 | `extra` 里的键原样写入环境变量 |
第三方若要用自己的模型,可在插件目录放 `.env`(不要提交)。节点选中的宿主凭据会覆盖其中的同名变量。