npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cpa-quota

v0.1.9

Published

CLI 监控远程 CPA 配额与账号状态

Readme

cpa-quota

在终端里监控 CPA Management API 的账号配额。

cpa-quota 是一个基于 Ink 的 CLI,可用于:

  • 仅展示 quota 页对应的 provider:Claude、Antigravity、Codex、Gemini CLI、Kimi
  • 同时监控多组 CPA 渠道
  • 按 provider 展示账号列表
  • 查看每个账号的 quota 状态与配额进度条
  • 查看每个 provider 的汇总 quota 进度
  • 可选显示已禁用账号

安装与使用

直接运行

通过 npx 直接运行:

npx cpa-quota --url "https://your-cpa-host" --password "YOUR_MANAGEMENT_API_KEY"

全局安装

使用 npm 全局安装:

npm install -g cpa-quota

安装后运行:

cpa-quota --url "https://your-cpa-host" --password "YOUR_MANAGEMENT_API_KEY"

使用 pnpm 全局安装:

pnpm add -g cpa-quota

安装后运行:

cpa-quota --url "https://your-cpa-host" --password "YOUR_MANAGEMENT_API_KEY"

使用 bun 全局安装:

bun add -g cpa-quota

安装后运行:

cpa-quota --url "https://your-cpa-host" --password "YOUR_MANAGEMENT_API_KEY"

其他示例

本地开发环境:

cpa-quota --url "http://localhost:8317" --password "123"

指定刷新间隔:

cpa-quota --url "https://your-cpa-host" --password "YOUR_MANAGEMENT_API_KEY" --interval 30

显示禁用账号:

cpa-quota --url "https://your-cpa-host" --password "YOUR_MANAGEMENT_API_KEY" --show-disabled

只刷新一次后退出:

cpa-quota --url "https://your-cpa-host" --password "YOUR_MANAGEMENT_API_KEY" --once

输出一次 JSON 快照,不启动终端界面:

cpa-quota --config ./cpa-quota.json --json

--json 会复用终端界面的账号状态、provider 分组、provider 汇总 quota 和账号 quota 数据,但不会输出倒计时、下次刷新时间、快捷键状态或 password。默认隐藏禁用账号;需要包含禁用账号时可以同时传 --show-disabled

多组 CPA

使用配置文件:

{
  "interval": 60,
  "cpas": [
    {
      "name": "国内 CPA",
      "url": "https://cpa-a.example",
      "password": "CPA_A_MANAGEMENT_API_KEY",
      "interval": 30
    },
    {
      "name": "备用 CPA",
      "url": "https://cpa-b.example/CPA",
      "password": "CPA_B_MANAGEMENT_API_KEY"
    }
  ]
}

启动:

cpa-quota --config ./cpa-quota.json

也可以直接在命令行重复传入多组 --url--password,程序会按出现顺序配对:

cpa-quota \
  --name "国内 CPA" --url "https://cpa-a.example" --password "CPA_A_MANAGEMENT_API_KEY" \
  --name "备用 CPA" --url "https://cpa-b.example/CPA" --password "CPA_B_MANAGEMENT_API_KEY"

如果每组 CPA 需要不同刷新间隔,可以重复传入 --interval,它会按出现顺序和 CPA 配对:

cpa-quota \
  --name "国内 CPA" --url "https://cpa-a.example" --password "CPA_A_MANAGEMENT_API_KEY" --interval 30 \
  --name "备用 CPA" --url "https://cpa-b.example/CPA" --password "CPA_B_MANAGEMENT_API_KEY" --interval 120

--config 不能和 --url / --password / --name 同时使用;配置文件里 name 是可选显示名称,给了就优先显示它,否则显示 URL 短标题。顶层 interval 是默认值,每个 cpas[] 里的 interval 可以覆盖默认值。命令行模式下,--url--password 的数量必须一致;--name 如果传入,数量也必须和 CPA 数量一致;--interval 可以传一次作为全局默认,也可以传和 CPA 数量一致的多次。

参数

| 参数 | 说明 | | --- | --- | | -c, --config <path> | 读取多组 CPA 配置的 JSON 文件 | | -n, --name <name> | CPA 显示名称,可重复传入并按顺序与 CPA 配对 | | -u, --url <url> | CPA 地址,可重复传入,例如 https://example.com/CPA | | -p, --password <password> | CPA Management API key,可重复传入并按顺序与 --url 配对 | | -i, --interval <seconds> | 刷新间隔,单位秒;可传一次作为全局默认,也可重复传入并按顺序与 CPA 配对,默认 60 | | --show-disabled | 显示已禁用账号 | | --once | 只刷新一次;所有 CPA 完成首次刷新后退出 | | --json | 输出一次 JSON 快照,不启动终端界面;如果有 CPA 拉取失败,会在对应 target 写入 status: "error"error |

界面说明

  • 多组模式下,每个 CPA 渠道独立显示为一个紧凑面板
  • 每个面板顶部显示当前连接状态、下次刷新倒计时、最近刷新时间
  • 面板中部显示账号状态摘要:账号数、可用数、冷却数、错误数
  • 每个 provider 区块显示:
    • provider 名称
    • 账号数量
    • provider 级别汇总 quota 进度条
    • 每个账号的邮箱/名称、套餐类型、quota 进度条、重置时间
  • c 可以收起或展开详情;收起后显示每个 CPA 面板的总览摘要和 provider 级 quota 汇总,不显示单个账号明细

其中:

  • 不同 provider 展示的 quota 指标可能不同
  • 例如 Codex 常见为 S / W,Claude 可能显示 5h / 7d / Sonnet / Opus

颜色规则

进度条按剩余额度区分颜色:

  • 0 ~ 30:红色
  • 30 ~ 70:黄色
  • 70 ~ 100:绿色

API 说明

程序会使用 CPA Management API 获取数据,主要包括:

  • /v0/management/auth-files
  • /v0/management/api-call

其中 quota 相关的上游请求统一通过 CPA 的 /api-call 代理,不在客户端直接请求上游 quota 接口。

对于不同部署路径,程序会自动尝试常见的 Management API 基础路径。

本地开发

安装依赖:

npm install

开发模式:

npm run dev -- --url "https://your-cpa-host/CPA" --password "YOUR_MANAGEMENT_API_KEY"

构建:

npm run build

构建后运行:

node dist/cli.js --url "https://your-cpa-host/CPA" --password "YOUR_MANAGEMENT_API_KEY"

Node 版本

需要 Node.js >= 18