Commit Graph
3 Commits
Author SHA1 Message Date
yishu 25194cbc0d fix(provider): a Step Plan's credits show when they never reset (#460)
A monthly Step Plan (Pro, plan_family 2) has no 5-hour or weekly window,
only credits that run out with the plan. QueryStepPlanRateLimit tells them as
subscription_credit_left_rate 0.9019661 with subscription_credit_reset_time
"0", and its credit_buckets entry says next_reset_at "0". readStepPlan dropped
every window whose reset doesn't parse, so the card showed the plan's name
and end date with no window at all, while StepFun's own usage page showed
90% of the credits left.

Credits with no reset are now kept when the answer lists credit_buckets: a
window with no ResetsAt, as other credit windows already are. The 5-hour and
weekly windows are unchanged: 0 left and 0 for the reset is still no window.

TestReadStepPlan gets the real answer from a Pro account (it fails on main
with []) and a plan whose credits are 0/0 with no bucket (still no window).
With a signed-in Pro account, magpie quota stepfun-cn on main shows
"Pro · expires Oct 15  plan" with nothing after it; with the change it shows
"Credits 10%". go vet and go test -tags nogui ./internal/provider pass.
2026-10-02 02:25:11 +08:00
yetone a2714f7506 claude: a Claude account's usage resets are read in the zone /usage names on Windows too, and the provider tests pass whole on Windows (goal: 插件订阅 provider 跟内置的所有逻辑都要一模一样, run on Windows and Linux) — Windows has no time zone database, so "resets Oct 1 at 3:30pm (Asia/Shanghai)" was read in the machine's own zone, hours off for anyone not in that zone; magpie now carries the database (time/tzdata). The provider tests set HOME but not USERPROFILE, which Windows takes the home from, so on Windows they read the test box's own agent sign-ins (Gemini models in a list, an extra provider, a Cursor version); every test home sets both now. Tests whose fake CLI is a shell script (Claude Code's auth status, codex --version, macOS's security) skip on Windows, as the fake devin did, and file mode bits go unchecked there. TestParseClaudeUsage fails on Windows without the change. On Windows and on Linux (WSL) the provider package passes whole, three times on Windows (15 failed before), the plugin package and the move/plugin/Grok/Devin/usage tests five times over on Linux. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. 2026-10-01 13:51:24 +08:00
yetone 9e9c2ce96c providers: StepFun and StepFun (China) show the Step Plan's 5-hour, weekly and credit windows on the Usage page (StepFun 国外版跟国内版这两个provider都应该支持显示额度) — the platform tells them only to a sign-in on platform.stepfun.ai or .com, never to a key ("api key not permitted for this method"), and its session cookie is HttpOnly with no way back to an app, so the user signs in in their own browser and brings the session over: the provider's editor has a bookmarklet that, on the signed-in platform page, asks the platform to renew the session as the page does and copies it, and a box to paste it into (the Oasis-Token cookie from developer tools is taken too). magpie keeps it in stepfun-auth.json (0600), one per site, renews it before it runs out and once more when it is refused, and asks QueryStepPlanRateLimit and GetStepPlanStatus for a card with the plan, its windows and when it ends; an anonymous session, another site's, or one renewed as someone else (past the refresh token's 30 days) is not kept or shown. Tested with a fake StepFun platform (renewal, early expiry, another account, pastes of each kind), the bookmarklet run against a stubbed page, and the field in a sandbox magpie web (signed out, a bad paste, signed in, sign out); not with a real StepFun sign-in 2026-09-29 16:04:47 +08:00