(input: {
readonly providerName?: string | undefined;
readonly oauthKey?: string | undefined;
})
| 436 | } |
| 437 | |
| 438 | export function resolveKimiTokenStorageName(input: { |
| 439 | readonly providerName?: string | undefined; |
| 440 | readonly oauthKey?: string | undefined; |
| 441 | }): string { |
| 442 | const key = input.oauthKey ?? KIMI_CODE_OAUTH_KEY; |
| 443 | if (key === 'kimi-code' || key === KIMI_CODE_OAUTH_KEY) return 'kimi-code'; |
| 444 | |
| 445 | const prefix = 'oauth/'; |
| 446 | if (key.startsWith(prefix) && key.slice(prefix.length).length > 0) { |
| 447 | return key.slice(prefix.length); |
| 448 | } |
| 449 | |
| 450 | if (!key.includes('/') && !key.startsWith('.')) return key; |
| 451 | throw new Error(`Invalid Kimi OAuth token key: "${key}".`); |
| 452 | } |
| 453 | |
| 454 | function defaultKimiHome(): string { |
| 455 | const override = process.env['KIMI_CODE_HOME']; |
no outgoing calls
no test coverage detected