A provider is a ProviderKind case, a sign-in, a usage client, and a mapper. Every value it shows
must come from the provider's API. Never read another tool's credentials, files, or logs, and never
compute spend from logs or pricing.
- Add a
ProviderKindcase inSources/OpenUsage/Models/Account.swiftwith itsdisplayName,links, andauthMethods([.oauth]or[.apiKey(keyPage:)]). - Add its icon at
Sources/OpenUsage/Resources/ProviderIcons/<kind>.svg.
- API key:
APIKeyLogincovers it. - Browser OAuth: add a
ProviderLogininServices/BrowserProviderLogins.swift. SendUUID().uuidStringas thestate, never the PKCE verifier. - Device code: add it in
Services/DeviceProviderLogins.swiftwithDeviceCodePoller.
Map the kind in ProviderLoginCatalog.
Create Sources/OpenUsage/Providers/<Name>/ with:
<Name>UsageClient: HTTP calls through the injectedHTTPClient, which applies the user's proxy. Throw aProviderError;ProviderError.requireSuccesshandles non-2xx responses. Never log a credential or a response body.<Name>UsageMapper: a pure function from the response toProviderUsage. Validate the response here.
Then wire up the runtime:
- Add the kind's
widgetDescriptorsinAccountProviderRuntime+Descriptors.swift. Chain.exportingLimit(...)on each metric the command line exports. - Add a
refresh<Name>function and its case inAccountProviderRuntime.swift, and add the kind to thenilcase ofresetClaimService. - Put any token refresh in an extension in the provider folder.
- Every metric with data shows. Confirm the metric order with the owner before you choose it.
- A balance with no limit needs
.exportingLimit(_, kind: .balance, ...)to count as used up at zero. Use it only for money or credits the user holds.
Test the mapper against recorded responses (success, empty plan, error) and the login's parsing,
under Tests/OpenUsageTests/. Run script/test_quiet.sh --filter <Name>.
docs/providers.md: a table row and a section.docs/cli.md: the kind and its resource keys.README.mdandAGENTS.md: the provider lists.