Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codex Reorder

Codex Reorder is a passive-only CLIProxyAPI plugin. It learns Codex quota windows from response headers on real requests, preserves CPA priority as the outer routing tier, and balances traffic across accounts whose long-window resets are close to the earliest reset inside the candidate tier supplied by CPA.

It also provides a Management page for previewing and explicitly applying top-level OAuth priority changes by ordered plan/quota categories. It never calls /backend-api/wham/usage or another proactive quota endpoint.

First release scope

  • Linux AMD64 only
  • CLIProxyAPI v7.2.103 or newer (plugin RPC schema v2 required)
  • Go 1.26.5 and CLIProxyAPI SDK pinned to v7.2.130
  • Release ABI baseline: GLIBC 2.31 or older symbols
  • No Node.js or frontend build dependency

Linux ARM64, macOS, Windows, and FreeBSD are intentionally deferred.

The native CPA C ABI remains version 1, while the lifecycle RPC contract requires host JSON schema v2 or newer for both plugin.register and plugin.reconfigure. The plugin always registers with RPC schema v2. This does not enable SDK schema-v3 stream behavior or active request interception: the plugin advertises only Scheduler, UsagePlugin, and ManagementAPI. CPA hosts using schema v2 or v3 accept the schema-v2 plugin contract.

Build

Local ABI development build (inherits the host glibc and is not a release artifact):

make test vet build-dev

Store-compatible Linux AMD64 package (requires Docker and uses a digest-pinned Debian 11/glibc 2.31 image plus the checksum-pinned official Go 1.26.5 archive):

make package-linux VERSION=0.1.0

The package target creates:

dist/codex-reorder_0.1.0_linux_amd64.zip
dist/checksums.txt

The zip contains only codex-reorder.so at its root. The verification target checks the ELF architecture, exported cliproxy_plugin_init, dynamic dependencies, maximum GLIBC symbol version, zip layout, and checksum.

Install

Enable plugins and install codex-reorder.so under CPA's platform directory:

plugins/linux/amd64/codex-reorder.so

Add the plugin configuration shown in plugin.example.yaml, restart CPA, then open the Codex Reorder entry in the Management Center.

reset-tolerance accepts a non-negative Go duration and defaults to 15m when omitted. For known accounts, the plugin finds the earliest usable long-window reset, includes every account resetting at or before earliest plus the tolerance, sorts that group by auth ID, and rotates through it independently per model. For example, resets 0, 4, 12, and 20 minutes after the earliest reset rotate across only the first three accounts with the default tolerance. Setting reset-tolerance: 0 restores strict earliest-reset grouping, while exact earliest ties still rotate.

The lifecycle configuration sent to the plugin contains only plugins.configs.codex-reorder; CPA's global routing strategy is not visible to the Scheduler protocol. The plugin owns selection whenever passive evidence permits a decision, so installing it intentionally supersedes CPA's built-in per-request selector while the plugin returns a handled decision. Pinned-auth candidate narrowing, model eligibility, disabled state, cooldown, and outer priority tiers remain controlled by CPA.

Reorder safety

  • Preview does not write auth files.
  • Apply rejects files changed since preview by comparing SHA-256 hashes.
  • Only the top-level priority field is added or replaced.
  • One-step undo restores the prior priority while preserving unrelated changes.
  • Runtime-only and non-Codex credentials are never written.

When any writable Codex auth lacks a known weekly/monthly passive observation, quota-period categories are disabled for the entire preview. The default rules then degrade from Free / Paid Monthly / Paid Weekly / Paid to a gapless Free / Paid plan-only ordering.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages