Workers AI usage now reads the day's actual Neurons from Cloudflare's GraphQL analytics, keeps the Used/Left toggle on the quota card, and stops the included free allowance from benching a Paid or unknown plan (`aside`). A 429 with code 3036 gets a Retry-After that runs to the next UTC midnight. Version 0.0.4; dist has 0.0.3, and npm has never had the package.
What was run, at reviewed head 38ddeb132ee6c00698952303fbc4949a84287779:
- `bun test packages/cloudflare-workers-ai` with a sandbox HOME/TMPDIR: 23/23 pass.
- `bun scripts/check.mjs`: ok.
- Merged with origin/main, the whole repo `bun test` with a sandbox HOME: 2900 pass, 3 skip, 0 fail across 245 files.
- Broke code and timing by hand:
- Removing the `!info.errors?.length` guard turns only the new partial-reply assertion red.
- A preload that moves Date.now() 700ms forward on every call fails the old (bdc302a) Retry-After test ("26820 vs ~26819"). The new bracketed test passes 3 of 3 under that preload.
- The earlier review at bdc302a covered the rest of the change. That includes nine mutations, each of which turns a test red.
Not tried:
- A real Paid account's billing and inference, as the author says too.
- A fetch call that straddles exactly 00:00:00 UTC. The Retry-After bracket would fail there, but only inside a window a few milliseconds long.