Skip to content

feat(providers): Add StepFun provider#815

Open
tevenfeng wants to merge 5 commits intosteipete:mainfrom
tevenfeng:feature/stepfun-provider
Open

feat(providers): Add StepFun provider#815
tevenfeng wants to merge 5 commits intosteipete:mainfrom
tevenfeng:feature/stepfun-provider

Conversation

@tevenfeng
Copy link
Copy Markdown

@tevenfeng tevenfeng commented Apr 30, 2026

Summary

Adds StepFun (阶跃星辰) as a new web-based provider that monitors Step Plan rate limits via the platform.stepfun.com API.

Authentication

StepFun uses a username + password login flow to obtain an Oasis-Token session:

  1. Auto mode (default): Enter username/password in Settings UI → app automatically performs the 3-step login flow:

    • Fetch INGRESSCOOKIE from platform homepage
    • RegisterDevice → get anonymous token
    • SignInByPassword → get authenticated Oasis-Token
    • Token cached in Keychain-backed CookieHeaderCache for reuse
    • On token expiry (API error), automatically clears cache and re-authenticates
  2. Manual mode: Directly paste an Oasis-Token from a browser session

  3. Environment variables: STEPFUN_USERNAME + STEPFUN_PASSWORD, or STEPFUN_TOKEN

Usage Data

Window API Field Maps To
5-hour session five_hour_usage_left_rate Primary RateWindow (300 min)
Weekly weekly_usage_left_rate Secondary RateWindow (10080 min)

Reset times are displayed from five_hour_usage_reset_time / weekly_usage_reset_time.

Files Added

  • Sources/CodexBarCore/Providers/StepFun/ — descriptor, usage fetcher, settings reader
  • Sources/CodexBar/Providers/StepFun/ — app implementation, settings store
  • Sources/CodexBar/Resources/ProviderIcon-stepfun.svg — provider icon
  • Tests/CodexBarTests/StepFunUsageFetcherTests.swift — 22 test cases

Files Modified

  • Providers.swift — added case stepfun to UsageProvider / IconStyle
  • ProviderDescriptor.swift — registered StepFun descriptor
  • ProviderImplementationRegistry.swift — added implementation factory
  • ProviderTokenResolver.swift — added stepfunResolution()
  • ProviderSettingsSnapshot.swift — added StepFunProviderSettings
  • TokenAccountSupportCatalog+Data.swift — added token account support
  • Widget files, CLI, CostUsageScanner, UsageStore — added .stepfun cases

Testing

  • 22 unit tests covering settings reader, token resolver, API response parsing, and token normalization
  • API response parser handles both string ("1777528800") and integer timestamps, and both integer (1) and float (0.99781543) rate values
  • Build and full test suite pass
image image

@tevenfeng tevenfeng changed the title Add StepFun provider feat(providers): Add StepFun provider Apr 30, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5a383ea14

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread Sources/CodexBar/Providers/StepFun/StepFunSettingsStore.swift Outdated
Comment thread Sources/CodexBarCLI/TokenAccountCLI.swift Outdated
@gitguardian
Copy link
Copy Markdown

gitguardian Bot commented Apr 30, 2026

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@tevenfeng tevenfeng force-pushed the feature/stepfun-provider branch 2 times, most recently from 6be1d46 to 8738e10 Compare May 3, 2026 08:44
tevenfeng added 5 commits May 6, 2026 09:51
Add StepFun (阶跃星辰) as a new web-based provider that monitors
Step Plan rate limits via the platform.stepfun.com API.

Authentication flow:
- Auto mode: username + password login via 3-step flow
  (INGRESSCOOKIE → RegisterDevice → SignInByPassword → Oasis-Token)
- Manual mode: direct Oasis-Token paste
- Token cached in CookieHeaderCache (Keychain-backed)

Usage data:
- Primary: 5-hour rate limit window (five_hour_usage_left_rate)
- Secondary: weekly rate limit window (weekly_usage_left_rate)
- Reset times from API (supports both string and int timestamp formats)

Files added:
- CodexBarCore/Providers/StepFun/: descriptor, fetcher, settings reader
- CodexBar/Providers/StepFun/: implementation, settings store
- ProviderIcon-stepfun.svg, StepFunUsageFetcherTests.swift
…napshot

- Apply token-account overrides in StepFun settings snapshot so
  per-account usage fetching works correctly (P1)
- Respect Off auth source in isAvailable — don't fetch when
  cookieSource is .off (P2)
- Add StepFun case to CLI snapshot builder so --account/--all-accounts
  can pass tokens through settings (P2)
- Fetch subscription plan name from GetStepPlanStatus endpoint
- Display plan name (e.g. Plus, Mini) as loginMethod in UI
- Gracefully degrade: if plan status fails, usage still shows
- Add StepFun entry to Providers section in README.md
- Add docs/stepfun.md with auth flow, data sources, and key files
@tevenfeng tevenfeng force-pushed the feature/stepfun-provider branch from 8738e10 to 19981ba Compare May 6, 2026 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant