@juanbenjumea/pi-multi-opencode-go

中文文档
0.2.2发布于 2026/11/01MITES Module构建来源已验证

Multi-account failover and rotation for the OpenCode Go provider in Pi.

原始使用文档
文档目录8 节
  1. Install
  2. Requirements
  3. Configure accounts
  4. Commands
  5. Companion extensions
  6. Security
  7. Publish
  8. License

@juanbenjumea/pi-multi-opencode-go

Multi-account failover for Pi’s opencode-go provider. Rotates API keys using live usage from the official OpenCode Go usage API (rolling / weekly / monthly), overrides Authorization per request, and persists cooldowns when limits hit.

Inspired by pi-multicodex and pi-multi-account, but built for OpenCode Go.

Usage fetching lives in @juanbenjumea/pi-provider-usage-fetcher (shared with @juanbenjumea/pi-dynamic-footer). Since v0.2.0 it uses the official API (GET https://opencode.ai/zen/go/v1/usage, same key as chat completions) — no workspace cookies or dashboard HTML scraping.

Install

pi install npm:@juanbenjumea/pi-multi-opencode-go
/reload

From this monorepo (before publishing):

# settings.json packages entry (relative to pi/agent/settings.json):
# "../packages/pi-multi-opencode-go"
pi -e /path/to/dotfiles/pi/packages/pi-multi-opencode-go

Requirements

  • Node 20+
  • @earendil-works/pi-coding-agent ≥ 0.80
  • A primary opencode-go API key in auth.json (or env) so Pi passes its auth check; this extension overrides the header on each request.

Recommended in settings.json:

{
  "retry": {
    "provider": { "maxRetries": 0 }
  }
}

Configure accounts

Environment (up to 8 slots):

export OPENCODE_API_KEY_1="oc_..."
export OPENCODE_GO_LABEL_1="sub-1"

(OPENCODE_GO_WORKSPACE_ID_1 / OPENCODE_GO_AUTH_COOKIE_1 are optional legacy fields, ignored now.)

~/.pi/agent/auth.json:

{
  "opencode-go-failover": {
    "accounts": [
      {
        "label": "sub-1",
        "key": "$OPENCODE_API_KEY_1"
      }
    ]
  }
}

Only key is required — the usage API authenticates with the same key as chat completions. Legacy workspaceId / authCookie fields are accepted but unused.

Env and auth.json are merged (both load). When an env key collides with an auth.json key, the auth.json entry wins so its label/workspace metadata is kept — e.g. auth.json referencing "key": "$OPENCODE_API_KEY_2" while OPENCODE_API_KEY_2 is also exported must not shadow it with an anonymous account-2.

Values support $ENV, $$literal, and !command (shell — use only if you trust your config).

Commands

CommandDescription
/opencode-accountsUsage for all accounts
/opencode-rotateManual rotation
/opencode-failoverStatus summary
/opencode-failover resetClear cooldowns

Companion extensions

Sets globals for footers and slot ladders:

  • __opencode_go_active_label — active account label
  • __opencode_go_has_fallback — another non-cooled account exists
  • __opencode_go_all_exhausted — every account on cooldown

State: ~/.pi/agent/opencode-go-failover-state.json (mode 0600).
Debug log: ~/.pi/agent/opencode-go-failover.log (labels only, no secrets).

Security

This extension reads API keys from your agent directory. Review the source before installing. Do not commit auth.json or state files.

Publish

cd pi/packages/pi-multi-opencode-go
npm publish --access public

Then switch settings.json to npm:@juanbenjumea/[email protected].

License

MIT

版本与发布记录

@juanbenjumea/pi-multi-opencode-go 共发布 6 个版本,首次发布于 2026/08/02;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.2latest2026/11/012 天前
0.2.12026/10/268 天前
0.2.02026/10/268 天前
0.1.32026/08/023 个月前
0.1.22026/08/023 个月前
0.1.12026/08/023 个月前

关于 @juanbenjumea/pi-multi-opencode-go 的常见问题

@juanbenjumea/pi-multi-opencode-go 是什么?

Pi中OpenCode Go提供程序的多帐户故障转移和旋转。

如何安装 @juanbenjumea/pi-multi-opencode-go?

在项目目录运行 npm install @juanbenjumea/pi-multi-opencode-go,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@earendil-works/pi-coding-agent(>=0.80.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@juanbenjumea/pi-multi-opencode-go 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/juanbenjumea__pi-multi-opencode-go 是否存在。

@juanbenjumea/pi-multi-opencode-go 支持 ESM 还是 CommonJS?

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

@juanbenjumea/pi-multi-opencode-go 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@juanbenjumea/pi-multi-opencode-go 可以商用吗?

@juanbenjumea/pi-multi-opencode-go 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@juanbenjumea/pi-multi-opencode-go 还在维护吗?

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