Files
codex-proxy-rs/backend/apps/plugin-cli
ZyyandCodex fd436532b8 feat(plugin): add the complete plugin development and management workflow (#256)
Introduce SDK 0.4, manifest v3, protocol v4, the isolated plugin runtime,
and cpr-plugin packaging CLI for independently maintained plugins.

Support installation, permissions, one active configuration per plugin,
version-specific settings, rollback, management pages, and CLI extensions.
Isolate plugin failures so native gateway startup and requests remain available.

Unify plugin settings and version management, support custom provider icons,
and improve narrow layouts. Use the fixed GitHub UI dependency and pnpm 12
for standalone frontend and container builds. Reduce runtime test packaging
cost and align preparation modules with the repository layout.

Co-authored-by: Codex <noreply@openai.com>
2026-09-24 13:40:38 +08:00
..

Codex Proxy Plugin CLI

cpr-plugin 校验并规范化作者清单、收集声明的资源,生成可安装归档及 SHA-256 校验文件。 当前输出使用 manifestVersion: 3、protocolVersion: 4 和 SDK 0.4 合同。

安装

从仓库根目录安装到本地工具目录:

cargo install --locked --path backend/apps/plugin-cli --root /path/to/local-tools

将 /path/to/local-tools/bin 加入 PATH,或使用可执行文件的完整路径。

打包

先构建目标平台的插件二进制;插件提供管理页面时,还需构建页面静态资源。打包命令传入作者清单、二进制和所需的资源目录映射,通过 cpr-plugin package --help 查看完整参数:

cpr-plugin package \
  --manifest /path/to/plugin/plugin.json \
  --binary /path/to/plugin/target/x86_64-unknown-linux-gnu/release/plugin \
  --target x86_64-unknown-linux-gnu \
  --resource-map web=web/dist \
  --output-dir /path/to/output

资源映射相对于作者清单所在目录解析。输出包括完整插件 ID、版本和目标 triple 命名的 .tar.gz 及 .sha256;归档根目录直接包含 plugin.json、可执行文件和已声明资源,不包含开发依赖。

作者清单可省略普通贡献项的 id、version 和固定阶段;middleware 的 request/attempt 仍须显式选择。 Provider 使用一个业务组声明协议与可选功能,例如:

{
  "contributes": {
    "provider": {
      "capabilities": ["models", "quota", "maintenance"],
      "inputFormats": ["openai"],
      "outputFormats": ["openai"]
    }
  }
}

CLI 与 SDK 的 Manifest::from_author_slice、PluginBuilder::from_json 共用规范化入口;归档中的 plugin.json 会写入展开后的 executor、所选 Provider 子能力及完整贡献项字段,不保留另一份作者声明。 完整规则见 SDK 清单。

支持 x86_64-unknown-linux-gnu、aarch64-unknown-linux-gnu 和 aarch64-apple-darwin。完整开发示例在同级 codex-proxy-plugins/examples/workbench 仓库目录;本工具不负责源码构建、上传或启用插件。

图标资源

在作者清单的 icon 中指定图标,并在 resources 中登记对应路径与 MIME 类型,配置方式见 SDK 插件图标。图标与其他声明资源一样参与打包和摘要计算, 无需额外命令参数;工具保留文件原始内容,宿主安装时验证图标内容与资源限制。

开发

Rust 包名为 codex-proxy-plugin-cli,位于宿主的 backend workspace,共享工具链、锁文件和检查规则;内部仅依赖 gateway-plugin-sdk。

cargo run --manifest-path backend/Cargo.toml -p codex-proxy-plugin-cli -- package --help
RUST_MIN_STACK=16777216 cargo +1.97.0 test --manifest-path backend/Cargo.toml -p codex-proxy-plugin-cli --locked