(options: {
readonly configuredBaseUrl?: string | undefined;
readonly configuredOAuthRef?: ManagedKimiOAuthRefInput | undefined;
readonly requestedBaseUrl?: string | undefined;
readonly requestedOAuthHost?: string | undefined;
readonly env?: ManagedKimiEnv | undefined;
})
| 368 | } |
| 369 | |
| 370 | export function resolveKimiCodeLoginAuth(options: { |
| 371 | readonly configuredBaseUrl?: string | undefined; |
| 372 | readonly configuredOAuthRef?: ManagedKimiOAuthRefInput | undefined; |
| 373 | readonly requestedBaseUrl?: string | undefined; |
| 374 | readonly requestedOAuthHost?: string | undefined; |
| 375 | readonly env?: ManagedKimiEnv | undefined; |
| 376 | }): ManagedKimiLoginAuth { |
| 377 | const env = options.env ?? process.env; |
| 378 | const envBaseUrl = kimiCodeEnvBaseUrl(env); |
| 379 | const envOAuthHost = kimiCodeEnvOAuthHost(env); |
| 380 | const hasOverride = |
| 381 | options.requestedBaseUrl !== undefined || |
| 382 | options.requestedOAuthHost !== undefined || |
| 383 | envBaseUrl !== undefined || |
| 384 | envOAuthHost !== undefined; |
| 385 | const baseUrl = |
| 386 | options.requestedBaseUrl !== undefined |
| 387 | ? normalizeBaseUrl(options.requestedBaseUrl) |
| 388 | : envBaseUrl !== undefined |
| 389 | ? normalizeBaseUrl(envBaseUrl) |
| 390 | : options.configuredBaseUrl; |
| 391 | const oauthHost = options.requestedOAuthHost ?? envOAuthHost; |
| 392 | if (hasOverride) return { baseUrl, oauthHost }; |
| 393 | |
| 394 | const configured = configuredOAuthRef(options.configuredOAuthRef); |
| 395 | if (configured === undefined) return { baseUrl, oauthHost }; |
| 396 | const expectedKey = resolveKimiCodeOAuthKey({ |
| 397 | oauthHost: configured.oauthHost, |
| 398 | baseUrl, |
| 399 | }); |
| 400 | return configured.key === expectedKey |
| 401 | ? { baseUrl, oauthHost, oauthRef: configured } |
| 402 | : { baseUrl, oauthHost }; |
| 403 | } |
| 404 | |
| 405 | function toModelInfo(item: unknown): ManagedKimiCodeModelInfo | undefined { |
| 406 | if (!isRecord(item) || typeof item['id'] !== 'string' || item['id'].length === 0) { |
no test coverage detected