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

Function clearManagedKimiCodeConfig

packages/oauth/src/managed-kimi-code.ts:707–749  ·  view source on GitHub ↗
(
  config: ManagedKimiConfigShape,
)

Source from the content-addressed store, hash-verified

705}
706
707export function clearManagedKimiCodeConfig(
708 config: ManagedKimiConfigShape,
709): ManagedKimiCodeCleanupResult {
710 const removedProvider = Object.hasOwn(config.providers, KIMI_CODE_PROVIDER_NAME);
711 delete config.providers[KIMI_CODE_PROVIDER_NAME];
712
713 const removedModels: string[] = [];
714 const models = config.models;
715 if (models !== undefined) {
716 for (const [key, model] of Object.entries(models)) {
717 if (!isRecord(model) || model['provider'] !== KIMI_CODE_PROVIDER_NAME) continue;
718 delete models[key];
719 removedModels.push(key);
720 }
721 }
722
723 let defaultModelCleared = false;
724 if (typeof config.defaultModel === 'string' && removedModels.includes(config.defaultModel)) {
725 config.defaultModel = undefined;
726 defaultModelCleared = true;
727 }
728
729 const removedServices: string[] = [];
730 if (config.services?.moonshotSearch !== undefined) {
731 delete config.services.moonshotSearch;
732 removedServices.push('moonshotSearch');
733 }
734 if (config.services?.moonshotFetch !== undefined) {
735 delete config.services.moonshotFetch;
736 removedServices.push('moonshotFetch');
737 }
738 if (config.services !== undefined && Object.keys(config.services).length === 0) {
739 config.services = undefined;
740 }
741
742 return {
743 providerName: KIMI_CODE_PROVIDER_NAME,
744 removedProvider,
745 removedModels,
746 defaultModelCleared,
747 removedServices,
748 };
749}
750
751function assertPositiveContextLength(model: ManagedKimiCodeModelInfo): void {
752 if (!Number.isInteger(model.contextLength) || model.contextLength <= 0) {

Callers 1

Calls 3

isRecordFunction · 0.90
keysMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected