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

Function toModelInfo

packages/oauth/src/managed-kimi-code.ts:405–435  ·  view source on GitHub ↗
(item: unknown)

Source from the content-addressed store, hash-verified

403}
404
405function toModelInfo(item: unknown): ManagedKimiCodeModelInfo | undefined {
406 if (!isRecord(item) || typeof item['id'] !== 'string' || item['id'].length === 0) {
407 return undefined;
408 }
409 const contextLength = Number(item['context_length']);
410 if (!Number.isInteger(contextLength) || contextLength <= 0) {
411 throw new Error(`Kimi Code model "${item['id']}" must include a positive context_length.`);
412 }
413 const displayName = item['display_name'];
414 const normalizedDisplayName =
415 typeof displayName === 'string' && displayName.length > 0 ? displayName : undefined;
416 const supportsToolUse = Object.hasOwn(item, 'supports_tool_use')
417 ? Boolean(item['supports_tool_use'])
418 : true;
419 // Effort levels come from the nested `think_efforts` object
420 // ({ support, valid_efforts, default_effort }) returned by /models.
421 const thinkEfforts = parseThinkEfforts(item['think_efforts']);
422 return {
423 id: item['id'],
424 contextLength,
425 supportsReasoning: Boolean(item['supports_reasoning']),
426 supportsImageIn: Boolean(item['supports_image_in']),
427 supportsVideoIn: Boolean(item['supports_video_in']),
428 supportsToolUse,
429 supportsThinkingType: parseSupportsThinkingType(item['supports_thinking_type']),
430 supportEfforts: thinkEfforts.supportEfforts,
431 defaultEffort: thinkEfforts.defaultEffort,
432 displayName: normalizedDisplayName,
433 protocol: parseModelProtocol(item['protocol']),
434 };
435}
436
437export function parseStringArray(value: unknown): readonly string[] | undefined {
438 if (!Array.isArray(value)) return undefined;

Callers 1

Calls 4

isRecordFunction · 0.90
parseThinkEffortsFunction · 0.85
parseModelProtocolFunction · 0.85

Tested by

no test coverage detected