Files
orcs-code/src/services/api/ultrareviewQuota.ts
did:key:z6MkqDnb7Siv3Cwj7pGJq4T5EsUisECqR8KpnDLwcaZq5TPr d2542c9a62 asdf
Squash the current repository state back into one baseline commit while
preserving the README reframing and repository contents.

Constraint: User explicitly requested a single squashed commit with subject "asdf"
Confidence: high
Scope-risk: broad
Reversibility: clean
Directive: This commit intentionally rewrites published history; coordinate before future force-pushes
Tested: git status clean; local history rewritten to one commit; force-pushed main to origin and instructkr
Not-tested: Fresh clone verification after push
2026-03-31 03:34:03 -07:00

39 lines
1.2 KiB
TypeScript

import axios from 'axios'
import { getOauthConfig } from '../../constants/oauth.js'
import { isClaudeAISubscriber } from '../../utils/auth.js'
import { logForDebugging } from '../../utils/debug.js'
import { getOAuthHeaders, prepareApiRequest } from '../../utils/teleport/api.js'
export type UltrareviewQuotaResponse = {
reviews_used: number
reviews_limit: number
reviews_remaining: number
is_overage: boolean
}
/**
* Peek the ultrareview quota for display and nudge decisions. Consume
* happens server-side at session creation. Null when not a subscriber or
* the endpoint errors.
*/
export async function fetchUltrareviewQuota(): Promise<UltrareviewQuotaResponse | null> {
if (!isClaudeAISubscriber()) return null
try {
const { accessToken, orgUUID } = await prepareApiRequest()
const response = await axios.get<UltrareviewQuotaResponse>(
`${getOauthConfig().BASE_API_URL}/v1/ultrareview/quota`,
{
headers: {
...getOAuthHeaders(accessToken),
'x-organization-uuid': orgUUID,
},
timeout: 5000,
},
)
return response.data
} catch (error) {
logForDebugging(`fetchUltrareviewQuota failed: ${error}`)
return null
}
}