Files
plugins/packages/codearts/package.json
T
yetone 4a78bec3b7 codearts 0.3.8: a window's runsOut is only credit its own remainder holds (#982)
usageFromStatistics took the bonus window's runsOutAt/runsOut from the
soonest check-in batch while remaining/used were the whole bucket, and the
total's from every non-basic batch whatever the buckets had left. So an
account whose check-in was spent (bonus remaining 0) still had a total
runsOut of 82.05 at tonight's midnight, and one with 2344.81 long-lived
gift credits said 100 lapse in hours while the vendor's
package_credit_expiring_amount was 0. magpie's routing reads a total's
RunsOutAt as "what is left is lost then" (Allowance.Renewal), so these
accounts were ranked ahead of ones that really lapse sooner.

Now:
- each bucket's lapse is its own batches' soonest, held to that bucket's
  package_credit_remain; an empty bucket has none;
- the total's lapse is the soonest of the buckets' lapses (same Beijing
  day summed), never from batches of a bucket with nothing left;
- the ledger fallback's batches are marked `estimated` (what was spent of
  a check-in isn't known): they say when, and how much is the vendor's
  own expiring amount, so with 0 or none said there is no lapse; the
  vendor's batch reads (with consumed/expired counts) are used as before;
- each window carries the vendor's package_credit_expiring_amount as
  `expiring` when it is sent;
- comments and README say the ledger keeps the date the claim names (a
  day on for today's check-ins); 30 days is only for a claim with none.

Run (wsl-run, magpie-desktop, at this tree rebased on origin/main):
bun test packages/codearts: 177 pass, 0 fail; bun scripts/check.mjs: ok.
Fixtures are the issue's two accounts as filed (A: bonus 100 used, 0
left, total 82.05 left; B: 4100 / 2344.81 left, ledger grant 100 claimed
2026-11-10T16:01:04.916Z expiring 2026-11-11T16:01:03.812Z, expiring 0),
clock held at 2026-11-11T10:00Z.

Broken by hand: cap = Infinity in bucketLapse: the three #982 tests red
(174 pass, 3 fail). cap = remain (no estimated gate): account B's test
red alone (176 pass, 1 fail).

Not tried: a real CodeArts account; the vendor's horizon for
package_credit_expiring_amount isn't known, so vendor batch reads are not
gated on it. A lagging vendor batch counter is bounded by the bucket's
remainder only.

Reported-by: KiMelody
2026-11-11 18:06:28 +08:00

42 lines
2.7 KiB
JSON

{
"name": "@magpie-community/opencode-codearts-auth",
"version": "0.3.8",
"description": "Huawei Cloud in OpenCode and magpie: CodeArts (码道) and OfficeAce (AgentArts), each from its own Huawei Cloud OAuth sign-in — models, credit rates, credit usage and the daily check-in (unofficial)",
"type": "module",
"main": "./opencode.mjs",
"exports": {
".": "./opencode2.mjs"
},
"files": [
"index.mjs",
"opencode.mjs",
"opencode2.mjs",
"README.md",
"LICENSE"
],
"scripts": {
"test": "bun test"
},
"keywords": [
"opencode",
"opencode-plugin",
"magpie",
"auth",
"provider",
"codearts",
"officeace",
"huaweicloud",
"oauth"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/magpie-community/plugins.git",
"directory": "packages/codearts"
},
"magpie": {
"maxConcurrency": 3,
"icon": "data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjQ0YwQTJDIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+SHVhd2VpPC90aXRsZT48cGF0aCBkPSJNMy42NyA2LjE0UzEuODIgNy45MSAxLjcyIDkuNzh2LjM1Yy4wOCAxLjUxIDEuMjIgMi40IDEuMjIgMi40IDEuODMgMS43OSA2LjI2IDQuMDQgNy4zIDQuNTUgMCAwIC4wNi4wMy4xLS4wMWwuMDItLjA0di0uMDRDNy41MiAxMC44IDMuNjcgNi4xNCAzLjY3IDYuMTR6TTkuNjUgMTguNmMtLjAyLS4wOC0uMS0uMDgtLjEtLjA4bC03LjM4LjI2Yy44IDEuNDMgMi4xNSAyLjUzIDMuNTYgMi4yLjk2LS4yNSAzLjE2LTEuNzggMy44OC0yLjMuMDYtLjA1LjA0LS4wOS4wNC0uMDl6bS4wOC0uNzhDNi40OSAxNS42My4yMSAxMi4yOC4yMSAxMi4yOGMtLjE1LjQ2LS4yLjktLjIxIDEuM3YuMDdjMCAxLjA3LjQgMS44Mi40IDEuODIuOCAxLjY5IDIuMzQgMi4yIDIuMzQgMi4yLjcuMyAxLjQuMz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