Skip to content

Add Abacus AI provider#479

Open
ChrisGVE wants to merge 19 commits intosteipete:mainfrom
ChrisGVE:abacus.ai
Open

Add Abacus AI provider#479
ChrisGVE wants to merge 19 commits intosteipete:mainfrom
ChrisGVE:abacus.ai

Conversation

@ChrisGVE
Copy link

@ChrisGVE ChrisGVE commented Mar 4, 2026

Summary

  • Add Abacus AI as a new cookie-based provider for tracking ChatLLM/RouteLLM compute credit usage
  • Fetches credit usage from _getOrganizationComputePoints (GET) and billing cycle from _getBillingInfo (POST), both called concurrently
  • Shows monthly credit gauge with pace tick, reserve/deficit estimate, and reset date
  • Cookie auth via SweetCookieKit browser import (Safari, Chrome, etc.) with manual override option
  • Supports Basic and Pro subscription tiers

New files

  • AbacusProviderDescriptor.swift — provider metadata, branding (cyan), web-only fetch strategy
  • AbacusUsageFetcher.swift — cookie importer, API fetcher, JSON parsing
  • AbacusProviderImplementation.swift — settings UI (cookie source picker)
  • AbacusSettingsStore.swift — settings persistence
  • ProviderIcon-abacus.svg — provider icon
  • docs/abacus.md — provider documentation (setup, API details, troubleshooting)

Modified files

  • Providers.swift.abacus enum case
  • ProviderSettingsSnapshot.swiftAbacusProviderSettings
  • ProviderDescriptor.swift, ProviderImplementationRegistry.swift — registration
  • MenuCardView.swift, MenuDescriptor.swift — Abacus-specific display (pace tick, credit detail)
  • UsagePaceText.swift — enable pace calculation for Abacus
  • docs/providers.md — added Abacus AI to strategy table and detailed provider section
  • README.md — added Abacus AI to provider list
  • Exhaustive switch updates in CLI, widget, store, and scanner files

Test plan

  • Enable Abacus AI in preferences, verify cookie import from Safari
  • Verify credit values match the Abacus dashboard
  • Verify reset date matches billing cycle (nextBillingDate from API)
  • Verify pace tick and reserve/deficit text display correctly
  • Test with expired cookies — should re-import from browser
  • Run codexbar usage --provider abacusai --verbose to verify CLI output

ChrisGVE added 4 commits March 4, 2026 13:39
Add support for Abacus AI (ChatLLM/RouteLLM) as a new provider. Uses
browser cookie authentication against the describeUser API endpoint to
fetch compute point usage. Values are in centi-credits (divided by 100
for display). Primary window shows monthly credit usage as percentage,
secondary window shows 7-day usage. Reset date derived from lastBilledAt
+ 1 month.
- Fix credits format string (Swift String(format:) has no comma flag;
  use NumberFormatter for thousands separators)
- Remove secondary weekly window (Abacus has monthly billing only)
- Show credits detail below gauge (follow Warp/Kilo pattern for
  resetDescription rendering)
- Add pace/reserve/deficit estimate on primary monthly window
- Remove inactive status page URL (abacus.statuspage.io is inactive)
- Hide account email/org from menu (not relevant for display)
- Set windowMinutes to 30 days so pace calculation works correctly
- Show pace indicator tick (green/red) on the primary gauge bar
- Add reserve/deficit line below gauge with pace right label
- Show credits used/total as detail text below the gauge
- Restore account identity (email, org, plan tier) in card header
Switch from describeUser (stale centi-credit values, no billing date)
to _getOrganizationComputePoints (accurate credits in real units) and
_getBillingInfo (exact nextBillingDate and subscription tier). Both
endpoints are fetched concurrently.
Copy link

@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: e316c9d4c7

ℹ️ 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".

ChrisGVE added 12 commits March 4, 2026 21:24
Skip browser cookie sets that only contain anonymous/marketing cookies
by checking for session/auth cookie names before accepting a set. This
prevents using invalid cookies when a valid session exists in a later
browser profile.

Separate the cookie import and API fetch try blocks so that network,
parse, or auth errors from the API are not misreported as "Browser
cookie import failed" and incorrectly replaced with noSessionCookie.
Update three call sites that still used the removed
UsagePaceText.weeklySummary(provider:window:) and
weeklyPaceDetail(provider:window:now:showUsed:) signatures.

MenuDescriptor and MenuCardView now use the store.weeklyPace()+
UsagePaceText.weeklySummary(pace:) pattern. StatusItemController
computes weeklyPace from primary for Abacus (no secondary window).
Remove Secondary (Weekly) from the menu bar metric picker since
Abacus has no secondary window; only Automatic and Primary (Credits)
are valid options.

Enable pace computation for Abacus in weeklyPace() so the bar
tick indicator (reserve/deficit/on-pace) is rendered correctly.
Abacus uses the simple UsagePace.weekly() path with the monthly
window already set in RateWindow (30 days).
Add docs/abacus.md with setup, API details, and troubleshooting for the
Abacus AI provider. Add Abacus AI entry to docs/providers.md strategy
table and detailed section. Add Abacus AI to README provider list.
Merge upstream changes including refactored debug log switch
(text= → return pattern) and cookieSource/cookieHeader API changes.
Add abacus case to updated debug log switch and fix TokenAccountCLI
to use new self.cookieSource/self.manualCookieHeader method calls.
Add AbacusProviderTests.swift with 23 tests in 3 suites covering:
- AbacusDescriptorTests: provider metadata, source modes, CLI config
- AbacusUsageSnapshotTests: credit conversion, formatting, edge cases
- AbacusErrorTests: error description completeness

Uses the Swift Testing framework (@test + #expect) matching the
convention established by recent upstream provider tests.
@ChrisGVE
Copy link
Author

@steipete is there anything else do to for you to approve this PR?

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