(
providerName?: string | undefined,
options: {
readonly oauthRef?: KimiOAuthTokenRef | undefined;
readonly baseUrl?: string | undefined;
} = {},
)
| 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, |
no test coverage detected