Files
yetone b3a3e609ed middleware-reserve 0.1.0: routings that fill to a ceiling, or accounts before keys
A routing-strategy gateway plugin (magpie.gateway, exports strategies):
reserve/ceiling fills accounts in listed order up to `ceiling` percent of
their allowance (80 by default), then the next; past it everywhere, the
least used first. reserve/accounts-first puts subscriptions before API
keys, accounts least used first, keys by weight then recent tokens.
Resting seats go last in both. One file, no imports, for moejs.

Run:
- bun test packages/reserve: 12 tests (10 strategies.json cases through
  checkStrategies, exactly two strategies and no hooks, every answer a
  permutation for 2-8 seats). Breaking the resting rule by hand turned
  its case red.
- Sandbox magpie from yetone/magpie origin/main b03031738: `magpie plugin`
  lists "routings reserve/accounts-first, reserve/ceiling". A stub
  OpenAI-compatible provider on 127.0.0.1:3593 recorded the key of each
  request; the provider had key-a, key-b, key-c (weight 5), listed in that
  order. routing=reserve/accounts-first: 3 of 3 went to key-c. With key-c
  answering 429: key-c 429 once, then key-a, key-b, key-a (key-c resting,
  last; equal weights by fewer tokens). routing=reserve/ceiling: 4 of 4
  to key-a (keys' allowance unknown, so listed order).
Not tried: the over-ceiling tier with real subscription accounts; it is
covered by strategies.json only.
2026-10-16 02:57:43 +08:00

15 lines
664 B
JSON

{
"name": "@magpie-community/middleware-reserve",
"version": "0.1.0",
"description": "Routings for magpie's gateway that keep something in reserve: fill accounts in order up to a ceiling, or spend subscriptions before pay-per-token keys",
"type": "module",
"files": ["reserve.gateway.js", "README.md"],
"keywords": ["magpie", "magpie-middleware", "magpie-routing", "routing", "load-balancing", "llm-gateway"],
"license": "MIT",
"repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/reserve" },
"magpie": {
"gateway": "./reserve.gateway.js",
"options": { "ceiling": 80 }
}
}