@aio-proxy/plugin-sdk

中文文档
0.42.5发布于 2026/10/13TypeScriptES Module构建来源已验证近 30 天下载 2180

Public contracts for extending aio-proxy with provider and OAuth plugins.

原始使用文档
文档目录3 节
  1. Runtime compatibility
  2. Using a sign-in already on this machine
  3. Catalog model metadata

@aio-proxy/plugin-sdk

Public contracts for extending aio-proxy with provider and OAuth plugins.

Runtime compatibility

Plugin runtime hooks execute inside the aio-proxy Bun host. Bun >=1.4.0 is the v1 runtime compatibility target. Plugin authors may use Node-based tooling for development and type checking, but execution under Node or undici is not part of the v1 compatibility promise.

Using a sign-in already on this machine

An OAuth adapter can declare localSignIn?: OAuthLocalSignIn<AccountOptions, Credential> to offer a vendor tool's existing local sign-in as an alternative to its browser OAuth flow. source is a LocalizedText label for the tool, such as Codex. The capability is optional; existing adapters keep their browser flow.

  • detect(context: OAuthLocalSignInContext) returns Promise<boolean> and checks presence only. It must never parse the host store, read secrets, or return account details. The context contains only signal.
  • read(context: OAuthCredentialImportContext, options: AccountOptions) returns Promise<OAuthLoginResult<Credential>>. Read the host store only after explicit user consent for the account. The context supplies progress, signal, and an optional fetch, as with credential imports.
  • write?(context: OAuthLocalSignInContext, next: Credential, previous: Credential) returns Promise<void>. Implement it only for stores whose refresh tokens rotate; omit it for stores that need only a one-time credential copy.

For adapters with write, identical host-store contents must produce identical credential values from read: the framework compares canonical credential digests between reads. Do not synthesize credential fields from the current time or generate random values on each read.

Before an atomic replacement, write must re-check that the host still holds previous, including the same account and refresh token. If either changed, return without writing. Finish writeback even if the signal was aborted after rotation consumed the token. Removing a Provider never calls write or changes the host store. Keep host credentials out of logs, traces, diagnostics, errors, and API responses.

Catalog model metadata

ModelDescriptor.modelMetadata reports typed model information that the host can merge into its upstream metadata layer. Its DescriptorModelMetadata type is a subset of the published @aio-proxy/types ModelMetadataInput: name, description, limit, capabilities, and cost. extend remains a user-config feature and is not available to plugins. Unknown keys are stripped; an invalid modelMetadata value is dropped fail-soft so the rest of the descriptor and catalog remain usable.

import type { ModelCatalog } from '@aio-proxy/plugin-sdk';

const catalog: ModelCatalog = {
  language: [
    {
      id: 'upstream-model-id',
      displayName: 'Upstream Model',
      modelMetadata: {
        limit: { context: 200_000, output: 32_000 },
        capabilities: { reasoning: true, toolCall: true },
        cost: { input: 1, output: 4 },
      },
      extra: { wireFamily: 'example-v2' },
    },
  ],
  image: [],
  video: [], // Optional; served by a plugin raw resolver for openai-video.
  embedding: [],
  speech: [],
  transcription: [],
  reranking: [],
  extra: { catalogRevision: 2 },
};

extra is opaque, plugin-private JSON data. It replaces the former free-form metadata field on ModelDescriptor and ModelCatalog, and the raw resolver input now provides extra instead of metadata. Use modelMetadata only for host-consumed model metadata and extra for wire hints or other plugin state.

版本与发布记录

@aio-proxy/plugin-sdk 共发布 80 个版本,首次发布于 2026/07/30;过去 12 个月发布了 80 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.42.5latest2026/10/1326 天前
0.42.42026/10/1226 天前
0.42.32026/10/1226 天前
0.42.22026/10/1127 天前
0.42.12026/10/1028 天前
0.42.02026/10/0929 天前

关于 @aio-proxy/plugin-sdk 的常见问题

@aio-proxy/plugin-sdk 是什么?

Public contracts for extending aio-proxy with provider and OAuth plugins.

如何安装 @aio-proxy/plugin-sdk?

在项目目录运行 npm install @aio-proxy/plugin-sdk,或使用 pnpm add / yarn add / bun add。

@aio-proxy/plugin-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aio-proxy/plugin-sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@aio-proxy/plugin-sdk 可以商用吗?

@aio-proxy/plugin-sdk 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@aio-proxy/plugin-sdk 的下载量有多少?

根据 npm 官方下载统计,@aio-proxy/plugin-sdk 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,180 次,日均约 73 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aio-proxy/plugin-sdk 还在维护吗?

最新版本 0.42.5 发布于 2026/10/13(26 天前);至今共发布 80 个版本,其中过去 12 个月发布了 80 个;首次发布于 2026/07/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。