MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / getManagedUsage

Method getManagedUsage

packages/oauth/src/toolkit.ts:276–301  ·  view source on GitHub ↗
(
    providerName?: string | undefined,
    options: {
      readonly oauthRef?: KimiOAuthTokenRef | undefined;
      readonly baseUrl?: string | undefined;
    } = {},
  )

Source from the content-addressed store, hash-verified

274 }
275
276 async getManagedUsage(
277 providerName?: string | undefined,
278 options: {
279 readonly oauthRef?: KimiOAuthTokenRef | undefined;
280 readonly baseUrl?: string | undefined;
281 } = {},
282 ): Promise<AuthManagedUsageResult> {
283 const name = providerName ?? KIMI_CODE_PROVIDER_NAME;
284 try {
285 const accessToken = await this.ensureFresh(name, {
286 oauthRef: options.oauthRef ?? this.defaultOAuthRef(options.baseUrl),
287 });
288 const result = await fetchManagedUsage(managedUsageUrl(options.baseUrl), accessToken);
289 if (result.kind === 'error') return result;
290 return {
291 kind: 'ok',
292 summary: result.parsed.summary,
293 limits: result.parsed.limits,
294 };
295 } catch (error) {
296 return {
297 kind: 'error',
298 message: error instanceof Error ? error.message : String(error),
299 };
300 }
301 }
302
303 async submitFeedback(
304 body: SubmitFeedbackBody,

Callers 1

mainFunction · 0.95

Calls 4

ensureFreshMethod · 0.95
defaultOAuthRefMethod · 0.95
fetchManagedUsageFunction · 0.90
managedUsageUrlFunction · 0.85

Tested by

no test coverage detected