(
providerName: string | undefined = KIMI_CODE_PROVIDER_NAME,
options: KimiAuthLoginOptions = {},
)
| 123 | } |
| 124 | |
| 125 | async login( |
| 126 | providerName: string | undefined = KIMI_CODE_PROVIDER_NAME, |
| 127 | options: KimiAuthLoginOptions = {}, |
| 128 | ): Promise<KimiAuthLoginResult> { |
| 129 | const auth = this.resolveManagedAuth(providerName); |
| 130 | const loginAuth = resolveKimiCodeLoginAuth({ |
| 131 | configuredBaseUrl: auth.baseUrl, |
| 132 | configuredOAuthRef: auth.oauthRef, |
| 133 | requestedBaseUrl: options.baseUrl, |
| 134 | requestedOAuthHost: options.oauthHost, |
| 135 | }); |
| 136 | const result = await this.toolkit.login(providerName, { |
| 137 | ...options, |
| 138 | baseUrl: loginAuth.baseUrl, |
| 139 | oauthHost: loginAuth.oauthHost, |
| 140 | oauthRef: options.oauthRef ?? loginAuth.oauthRef, |
| 141 | provisionConfig: true, |
| 142 | }); |
| 143 | if (result.provision === undefined) { |
| 144 | throw new Error('Kimi auth login did not provision model config.'); |
| 145 | } |
| 146 | const updated = readConfigFile(this.options.configPath); |
| 147 | this.options.onConfigUpdated?.(updated); |
| 148 | return { |
| 149 | providerName: result.providerName, |
| 150 | ok: true, |
| 151 | defaultModel: result.provision.defaultModel, |
| 152 | defaultThinking: result.provision.defaultThinking, |
| 153 | configPath: result.provision.configPath, |
| 154 | }; |
| 155 | } |
| 156 | |
| 157 | async logout(providerName?: string | undefined): Promise<KimiAuthLogoutResult> { |
| 158 | const result = await this.toolkit.logout( |
nothing calls this directly
no test coverage detected