进阶 omnigent.ai 2026-10-14 06:47:13 · 27 阅读

第1章 社区 Harness 插件 · Omnigent

社区集成插件

pip install omnigent 命令自带了内置的 harness 功能。除此之外,Omnigent 启动时会通过插件注册表发现额外的 harness,社区因此可以以独立包的形式添加对新运行时环境的支持,而无需修改核心 omnigent 包。各集成方式的维护现状及支持变更机制,详见 。

```bash pip install omnigent # 仅安装核心 harness pip install omnigent-foo # 在同一 omni CLI 中添加 `foo` harness ```

已安装的插件所自带的 harness 与内置 harness 具备完全一致的可见性:它同样支持在 Agent YAML 中指定、可通过 --harness 参数调用,也会自动合并到 Web 界面中的 harness 选择器中。

只要你的 harness 插件正式发布,我们欢迎提交 Pull Request,将其仓库添加到 Harnesses 列表中。

构建插件

Harnes 插件本质是一个 Python 包,需在 omnigent.community.harness 入口点组中声明一个 entry point,并导出 get_contribution() 函数。实现模块需放在 omnigent.community.harness.* 命名空间下。

```toml # pyproject.toml [project] name = "omnigent-foo" dependencies = ["omnigent"] [project.entry-points."omnigent.community.harness"] foo = "omnigent.community.harness.foo.plugin:get_contribution" ```

```python # omnigent/community/harness/foo/plugin.py from omnigent.harness_plugins import HarnessContribution from omnigent.harness_install_spec import HarnessInstallSpec def get_contribution() -> HarnessContribution: return HarnessContribution( name="omnigent-foo", valid_harnesses=frozenset({"foo"}), harness_modules={ "foo": "omnigent.community.harness.foo.harness", }, aliases={"foo-code": "foo"}, harness_labels={"foo": "Foo"}, ) ```

每个 harness 模块需导出 create_app() -> FastAPI 方法,Runner 会调用该方法以启动对应的 harness。请注意保持 plugin.py 顶层导入的轻量化——由于入口点发现阶段执行极早,重资源导入应放在需要它们的回调函数内部。

注意:核心引擎会拒绝注册扁平包路径或试图覆盖内置 harness 名称的插件。目前,社区原生 TUI harness 尚未支持插件化,插件接口仅覆盖直接调用型和 headless 型 harness。

有关完整的插件协议,包括安装/认证元数据、模型覆盖环境变量及每次生成过程的环境构建器,请参阅 设计文档。

评论 (0)