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

Function limitLabel

packages/oauth/src/managed-usage.ts:103–126  ·  view source on GitHub ↗
(
  item: Record<string, unknown>,
  detail: Record<string, unknown>,
  window: Record<string, unknown>,
  idx: number,
)

Source from the content-addressed store, hash-verified

101}
102
103function limitLabel(
104 item: Record<string, unknown>,
105 detail: Record<string, unknown>,
106 window: Record<string, unknown>,
107 idx: number,
108): string {
109 for (const key of ['name', 'title', 'scope']) {
110 const v = item[key] ?? detail[key];
111 if (typeof v === 'string' && v.length > 0) return v;
112 }
113 const duration = toInt(window['duration'] ?? item['duration'] ?? detail['duration']);
114 const rawUnit = window['timeUnit'] ?? item['timeUnit'] ?? detail['timeUnit'];
115 const timeUnit = typeof rawUnit === 'string' ? rawUnit : '';
116 if (duration !== null) {
117 if (timeUnit.includes('MINUTE')) {
118 if (duration >= 60 && duration % 60 === 0) return `${String(duration / 60)}h limit`;
119 return `${String(duration)}m limit`;
120 }
121 if (timeUnit.includes('HOUR')) return `${String(duration)}h limit`;
122 if (timeUnit.includes('DAY')) return `${String(duration)}d limit`;
123 return `${String(duration)}s limit`;
124 }
125 return `Limit #${String(idx + 1)}`;
126}
127
128function resetHintFrom(raw: Record<string, unknown>): string | undefined {
129 for (const key of ['reset_at', 'resetAt', 'reset_time', 'resetTime']) {

Callers 1

parseManagedUsagePayloadFunction · 0.85

Calls 1

toIntFunction · 0.85

Tested by

no test coverage detected