@hashimkarim/usagestat-darwin-arm64 2.0.0-alpha.3 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/native-manifest.json +1532 -134
  2. package/package.json +235 -2
  3. package/plugins/UPSTREAM-LICENSES.md +6 -2
  4. package/plugins/_provider-icons/LICENSE +21 -0
  5. package/plugins/_provider-icons/NOTICE +12 -0
  6. package/plugins/_provider-icons/licenses/CodexBar-MIT.txt +21 -0
  7. package/plugins/_provider-icons/licenses/LobeHub-MIT.txt +21 -0
  8. package/plugins/_provider-icons/licenses/UsageStat-Bar-MIT.txt +21 -0
  9. package/plugins/_provider-icons/manifest.json +1219 -0
  10. package/plugins/_provider-icons/provenance.json +269 -0
  11. package/plugins/_provider-icons/source.json +4 -0
  12. package/plugins/abacus-ai/icon-color.svg +18 -0
  13. package/plugins/abliteration/LICENSE +21 -0
  14. package/plugins/abliteration/icon.svg +5 -0
  15. package/plugins/abliteration/plugin.js +89 -0
  16. package/plugins/abliteration/plugin.json +24 -0
  17. package/plugins/aerostack/LICENSE +21 -0
  18. package/plugins/aerostack/icon.svg +1 -0
  19. package/plugins/aerostack/plugin.js +94 -0
  20. package/plugins/aerostack/plugin.json +24 -0
  21. package/plugins/aixy/LICENSE +21 -0
  22. package/plugins/aixy/icon.svg +1 -0
  23. package/plugins/aixy/plugin.js +266 -0
  24. package/plugins/aixy/plugin.json +32 -0
  25. package/plugins/antigravity/plugin.js +189 -65
  26. package/plugins/antigravity-cli/icon-color.svg +1 -0
  27. package/plugins/antigravity-cli/icon.svg +1 -3
  28. package/plugins/antigravity-cli/plugin.js +32 -20
  29. package/plugins/antigravity-ide/icon-color.svg +1 -0
  30. package/plugins/antigravity-ide/icon.svg +1 -3
  31. package/plugins/antigravity-ide/plugin.js +19 -7
  32. package/plugins/atlascloud/LICENSE +21 -0
  33. package/plugins/atlascloud/icon-color.svg +1 -0
  34. package/plugins/atlascloud/icon.svg +1 -0
  35. package/plugins/atlascloud/plugin.js +54 -0
  36. package/plugins/atlascloud/plugin.json +24 -0
  37. package/plugins/augment/icon-color.svg +14 -0
  38. package/plugins/bifrost/LICENSE +21 -0
  39. package/plugins/bifrost/icon.svg +3 -0
  40. package/plugins/bifrost/plugin.js +366 -0
  41. package/plugins/bifrost/plugin.json +31 -0
  42. package/plugins/chatbox/LICENSE +21 -0
  43. package/plugins/chatbox/icon.svg +4 -0
  44. package/plugins/chatbox/plugin.js +208 -0
  45. package/plugins/chatbox/plugin.json +24 -0
  46. package/plugins/claude/plugin.js +340 -153
  47. package/plugins/claude/plugin.json +1 -1
  48. package/plugins/claudeplatform/LICENSE +21 -0
  49. package/plugins/claudeplatform/icon.svg +3 -0
  50. package/plugins/claudeplatform/plugin.js +244 -0
  51. package/plugins/claudeplatform/plugin.json +25 -0
  52. package/plugins/clinepass/plugin.js +19 -3
  53. package/plugins/codebuff/icon-color.svg +92 -0
  54. package/plugins/coderabbit/plugin.js +25 -0
  55. package/plugins/coderabbit/plugin.json +12 -0
  56. package/plugins/codex/plugin.js +15 -8
  57. package/plugins/codex/plugin.json +11 -2
  58. package/plugins/command-code/icon-color.svg +3 -0
  59. package/plugins/command-code/plugin.js +7 -3
  60. package/plugins/copilot/icon.svg +1 -1
  61. package/plugins/copilot/plugin.json +1 -0
  62. package/plugins/cosmic/LICENSE +21 -0
  63. package/plugins/cosmic/icon.svg +1 -0
  64. package/plugins/cosmic/plugin.js +134 -0
  65. package/plugins/cosmic/plugin.json +32 -0
  66. package/plugins/crof/icon-color.svg +3 -0
  67. package/plugins/crofai/icon-color.svg +3 -0
  68. package/plugins/crofai/icon.svg +2 -15
  69. package/plugins/cursor/icon-color.svg +1 -0
  70. package/plugins/cursor/plugin.js +51 -14
  71. package/plugins/cursor-nightly/plugin.json +1 -1
  72. package/plugins/deepinfra/icon-color.svg +1 -0
  73. package/plugins/deepinfra/icon.svg +1 -4
  74. package/plugins/deepseek/plugin.js +150 -59
  75. package/plugins/deepseek/plugin.json +3 -1
  76. package/plugins/devin/plugin.js +3 -0
  77. package/plugins/devpass/LICENSE +21 -0
  78. package/plugins/devpass/icon.svg +3 -0
  79. package/plugins/devpass/plugin.js +120 -0
  80. package/plugins/devpass/plugin.json +24 -0
  81. package/plugins/elevenlabs/icon-color.svg +4 -0
  82. package/plugins/exa/LICENSE +21 -0
  83. package/plugins/exa/icon-color.svg +1 -0
  84. package/plugins/exa/icon.svg +1 -0
  85. package/plugins/exa/plugin.js +75 -0
  86. package/plugins/exa/plugin.json +32 -0
  87. package/plugins/factory/icon-color.svg +1 -0
  88. package/plugins/fal/LICENSE +21 -0
  89. package/plugins/fal/icon-color.svg +1 -0
  90. package/plugins/fal/icon.svg +1 -0
  91. package/plugins/fal/plugin.js +74 -0
  92. package/plugins/fal/plugin.json +24 -0
  93. package/plugins/fireworks-ai/icon-color.svg +1 -0
  94. package/plugins/fireworks-ai/icon.svg +1 -6
  95. package/plugins/flora/LICENSE +21 -0
  96. package/plugins/flora/icon.svg +4 -0
  97. package/plugins/flora/plugin.js +93 -0
  98. package/plugins/flora/plugin.json +32 -0
  99. package/plugins/futureagi/LICENSE +21 -0
  100. package/plugins/futureagi/icon.svg +24 -0
  101. package/plugins/futureagi/plugin.js +139 -0
  102. package/plugins/futureagi/plugin.json +32 -0
  103. package/plugins/gemini-apps/LICENSE +21 -0
  104. package/plugins/gemini-apps/icon-color.svg +1 -0
  105. package/plugins/gemini-apps/icon.svg +1 -0
  106. package/plugins/gemini-apps/plugin.js +141 -0
  107. package/plugins/gemini-apps/plugin.json +25 -0
  108. package/plugins/gitkraken/LICENSE +21 -0
  109. package/plugins/gitkraken/icon.svg +2 -0
  110. package/plugins/gitkraken/plugin.js +158 -0
  111. package/plugins/gitkraken/plugin.json +32 -0
  112. package/plugins/googledeveloper/LICENSE +21 -0
  113. package/plugins/googledeveloper/icon.svg +3 -0
  114. package/plugins/googledeveloper/plugin.js +204 -0
  115. package/plugins/googledeveloper/plugin.json +25 -0
  116. package/plugins/grok/icon-color.svg +1 -0
  117. package/plugins/groqcloud/icon-color.svg +1 -0
  118. package/plugins/helmcode/LICENSE +21 -0
  119. package/plugins/helmcode/icon.svg +5 -0
  120. package/plugins/helmcode/plugin.js +253 -0
  121. package/plugins/helmcode/plugin.json +32 -0
  122. package/plugins/huggingface/LICENSE +21 -0
  123. package/plugins/huggingface/icon-color.svg +1 -0
  124. package/plugins/huggingface/icon.svg +1 -0
  125. package/plugins/huggingface/plugin.js +298 -0
  126. package/plugins/huggingface/plugin.json +26 -0
  127. package/plugins/hyper/LICENSE +21 -0
  128. package/plugins/hyper/plugin.js +137 -0
  129. package/plugins/hyper/plugin.json +27 -0
  130. package/plugins/jetbrains-ai-assistant/LICENSE +22 -0
  131. package/plugins/jetbrains-ai-assistant/plugin.js +502 -16
  132. package/plugins/jetbrains-ai-assistant/plugin.json +27 -4
  133. package/plugins/kilo/icon-color.svg +1 -0
  134. package/plugins/kimi/plugin.js +54 -14
  135. package/plugins/kimi/plugin.json +46 -6
  136. package/plugins/langdock/LICENSE +21 -0
  137. package/plugins/langdock/icon.svg +4 -0
  138. package/plugins/langdock/plugin.js +106 -0
  139. package/plugins/langdock/plugin.json +25 -0
  140. package/plugins/linkup/LICENSE +21 -0
  141. package/plugins/linkup/icon.svg +10 -0
  142. package/plugins/linkup/plugin.js +46 -0
  143. package/plugins/linkup/plugin.json +24 -0
  144. package/plugins/litellm/plugin.js +54 -3
  145. package/plugins/lithosai/LICENSE +21 -0
  146. package/plugins/lithosai/icon.svg +1 -0
  147. package/plugins/lithosai/plugin.js +130 -0
  148. package/plugins/lithosai/plugin.json +26 -0
  149. package/plugins/llmman/LICENSE +21 -0
  150. package/plugins/llmman/icon.svg +4 -0
  151. package/plugins/llmman/plugin.js +138 -0
  152. package/plugins/llmman/plugin.json +31 -0
  153. package/plugins/longcat/icon-color.svg +1 -0
  154. package/plugins/longcat/icon.svg +1 -4
  155. package/plugins/manus/icon-color.svg +6 -0
  156. package/plugins/mimo/icon-color.svg +4 -0
  157. package/plugins/mimo/icon.svg +4 -1
  158. package/plugins/mistral/plugin.js +164 -27
  159. package/plugins/moonshot/icon-color.svg +1 -0
  160. package/plugins/munito/LICENSE +21 -0
  161. package/plugins/munito/icon.svg +7 -0
  162. package/plugins/munito/plugin.js +171 -0
  163. package/plugins/munito/plugin.json +24 -0
  164. package/plugins/muse/LICENSE +21 -0
  165. package/plugins/muse/icon.svg +3 -0
  166. package/plugins/muse/plugin.js +288 -0
  167. package/plugins/muse/plugin.json +34 -0
  168. package/plugins/museai/LICENSE +21 -0
  169. package/plugins/museai/icon.svg +3 -0
  170. package/plugins/museai/plugin.js +161 -0
  171. package/plugins/museai/plugin.json +26 -0
  172. package/plugins/nous/LICENSE +21 -0
  173. package/plugins/nous/icon-color.svg +1 -0
  174. package/plugins/nous/icon.svg +1 -0
  175. package/plugins/nous/plugin.js +129 -0
  176. package/plugins/nous/plugin.json +32 -0
  177. package/plugins/ollama/icon-color.svg +1 -0
  178. package/plugins/ollama/plugin.js +58 -0
  179. package/plugins/openai-api/icon-color.svg +1 -0
  180. package/plugins/opencode/icon-color.svg +1 -0
  181. package/plugins/opencode-go/icon-color.svg +1 -0
  182. package/plugins/opencode-go/plugin.js +104 -37
  183. package/plugins/opendesign/LICENSE +21 -0
  184. package/plugins/opendesign/icon.svg +4 -0
  185. package/plugins/opendesign/plugin.js +108 -0
  186. package/plugins/opendesign/plugin.json +25 -0
  187. package/plugins/openrouter/icon-color.svg +1 -0
  188. package/plugins/parallel/LICENSE +21 -0
  189. package/plugins/parallel/icon.svg +11 -0
  190. package/plugins/parallel/plugin.js +97 -0
  191. package/plugins/parallel/plugin.json +25 -0
  192. package/plugins/perplexity/LICENSE +22 -0
  193. package/plugins/perplexity/plugin.js +122 -0
  194. package/plugins/perplexity/plugin.json +36 -7
  195. package/plugins/pi/plugin.js +113 -0
  196. package/plugins/pi/plugin.json +11 -0
  197. package/plugins/qwencloud/LICENSE +21 -0
  198. package/plugins/qwencloud/icon-color.svg +1 -0
  199. package/plugins/qwencloud/icon.svg +1 -4
  200. package/plugins/qwencloud/plugin.js +197 -0
  201. package/plugins/qwencloud/plugin.json +17 -0
  202. package/plugins/raycast/LICENSE +21 -0
  203. package/plugins/raycast/icon.svg +4 -0
  204. package/plugins/raycast/plugin.js +179 -0
  205. package/plugins/raycast/plugin.json +32 -0
  206. package/plugins/replicate/LICENSE +21 -0
  207. package/plugins/replicate/icon-color.svg +1 -0
  208. package/plugins/replicate/icon.svg +1 -0
  209. package/plugins/replicate/plugin.js +170 -0
  210. package/plugins/replicate/plugin.json +25 -0
  211. package/plugins/sailresearch/LICENSE +21 -0
  212. package/plugins/sailresearch/icon.svg +4 -0
  213. package/plugins/sailresearch/plugin.js +104 -0
  214. package/plugins/sailresearch/plugin.json +24 -0
  215. package/plugins/siliconflow/LICENSE +21 -0
  216. package/plugins/siliconflow/icon.svg +3 -0
  217. package/plugins/siliconflow/plugin.js +87 -0
  218. package/plugins/siliconflow/plugin.json +32 -0
  219. package/plugins/sofya/LICENSE +21 -0
  220. package/plugins/sofya/icon.svg +3 -0
  221. package/plugins/sofya/plugin.js +86 -0
  222. package/plugins/sofya/plugin.json +24 -0
  223. package/plugins/soniox/LICENSE +21 -0
  224. package/plugins/soniox/icon.svg +3 -0
  225. package/plugins/soniox/plugin.js +103 -0
  226. package/plugins/soniox/plugin.json +24 -0
  227. package/plugins/synthetic/icon-color.svg +14 -0
  228. package/plugins/synthetic/plugin.js +12 -0
  229. package/plugins/synthetic/plugin.json +51 -9
  230. package/plugins/tavily/LICENSE +21 -0
  231. package/plugins/tavily/icon.svg +3 -0
  232. package/plugins/tavily/plugin.js +61 -0
  233. package/plugins/tavily/plugin.json +24 -0
  234. package/plugins/tinyapi/LICENSE +21 -0
  235. package/plugins/tinyapi/icon.svg +4 -0
  236. package/plugins/tinyapi/plugin.js +73 -0
  237. package/plugins/tinyapi/plugin.json +25 -0
  238. package/plugins/traecn/LICENSE +21 -0
  239. package/plugins/traecn/icon.svg +3 -0
  240. package/plugins/traecn/plugin.js +103 -0
  241. package/plugins/traecn/plugin.json +25 -0
  242. package/plugins/tripo/LICENSE +21 -0
  243. package/plugins/tripo/icon.svg +4 -0
  244. package/plugins/tripo/plugin.js +60 -0
  245. package/plugins/tripo/plugin.json +24 -0
  246. package/plugins/typesafe/LICENSE +21 -0
  247. package/plugins/typesafe/icon.svg +4 -0
  248. package/plugins/typesafe/plugin.js +181 -0
  249. package/plugins/typesafe/plugin.json +25 -0
  250. package/plugins/v0/LICENSE +21 -0
  251. package/plugins/v0/icon-color.svg +1 -0
  252. package/plugins/v0/icon.svg +1 -0
  253. package/plugins/v0/plugin.js +219 -0
  254. package/plugins/v0/plugin.json +32 -0
  255. package/plugins/venice/plugin.js +50 -1
  256. package/plugins/venice/plugin.json +2 -1
  257. package/plugins/vercel/LICENSE +21 -0
  258. package/plugins/vercel/icon-color.svg +1 -0
  259. package/plugins/vercel/icon.svg +1 -0
  260. package/plugins/vercel/plugin.js +202 -0
  261. package/plugins/vercel/plugin.json +54 -0
  262. package/plugins/windsurf/icon-color.svg +1 -0
  263. package/plugins/workbuddy/LICENSE +21 -0
  264. package/plugins/workbuddy/icon.svg +1 -0
  265. package/plugins/workbuddy/plugin.js +318 -0
  266. package/plugins/workbuddy/plugin.json +63 -0
  267. package/plugins/xai/icon-color.svg +1 -0
  268. package/plugins/xai/icon.svg +1 -7
  269. package/plugins/xai/plugin.js +9 -0
  270. package/plugins/xapi/LICENSE +21 -0
  271. package/plugins/xapi/icon.svg +1 -0
  272. package/plugins/xapi/plugin.js +90 -0
  273. package/plugins/xapi/plugin.json +25 -0
  274. package/plugins/xkiro/LICENSE +21 -0
  275. package/plugins/xkiro/icon.svg +1 -0
  276. package/plugins/xkiro/plugin.js +104 -0
  277. package/plugins/xkiro/plugin.json +24 -0
  278. package/plugins/zai/icon-color.svg +1 -0
  279. package/plugins/zai/plugin.js +5 -1
  280. package/plugins/zenmux/icon-color.svg +1 -0
  281. package/plugins/zenmux/icon.svg +1 -3
  282. package/usagestat +0 -0
  283. package/usagestatd +0 -0
  284. package/plugins/cursor-nightly/plugin.js +0 -1416
@@ -43,6 +43,7 @@
43
43
  }
44
44
 
45
45
  function env(ctx, name) {
46
+ if (ctx.provider.instanceId && ctx.provider.instanceId !== 'kimi') return null
46
47
  try { return clean(ctx.host.env.get(name)) } catch (_) { return null }
47
48
  }
48
49
 
@@ -51,6 +52,7 @@
51
52
  }
52
53
 
53
54
  function cliSession(ctx) {
55
+ if (ctx.provider.instanceId && ctx.provider.instanceId !== 'kimi') return null
54
56
  const override = env(ctx, "KIMI_CODE_HOME")
55
57
  const homes = override ? [override] : ["~/.kimi-code", "~/.kimi"]
56
58
  for (const home of homes) {
@@ -102,6 +104,14 @@
102
104
  })
103
105
  }
104
106
 
107
+ function monthlyBreakdown(ctx, lines, total, code) {
108
+ for (let i=lines.length-1;i>=0;i--) if (["Monthly Kimi Code","Monthly other features"].includes(lines[i].label)) lines.splice(i,1)
109
+ if (!Number.isFinite(total) || total < 0 || !Number.isFinite(code) || code < 0) return
110
+ const percent = value => value > 0 && value < .01 ? "<1% used" : Math.round(Math.min(1,value)*100)+"% used"
111
+ lines.push(ctx.line.text({label:"Monthly Kimi Code",value:percent(code)}),
112
+ ctx.line.text({label:"Monthly other features",value:percent(Math.max(0,total-code))}))
113
+ }
114
+
105
115
  function enrichMembership(ctx, result, token) {
106
116
  if (!token || ctx.provider.settings && ctx.provider.settings.cookieSource === "off") return result
107
117
  try {
@@ -110,24 +120,40 @@
110
120
  if (!data) return result
111
121
  const pool = data.subscriptionBalance
112
122
  const ratio = pool && readNumber(pool.amountUsedRatio)
113
- if (Number.isFinite(ratio) && pool && (!pool.feature || pool.feature === "FEATURE_OMNI") && (!pool.type || pool.type === "SUBSCRIPTION")) {
123
+ if (Number.isFinite(ratio) && ratio >= 0 && pool && (!pool.feature || pool.feature === "FEATURE_OMNI") && (!pool.type || pool.type === "SUBSCRIPTION")) {
114
124
  const reset = ctx.util.toIso(pool.expireTime)
115
125
  const monthly = ctx.line.progress({ label: "Monthly", used: Math.max(0, Math.min(100, ratio * 100)), limit: 100,
116
126
  format: { kind: "percent" }, resetsAt: reset, periodDurationMs: ctx.util.calendarMonthDuration(reset) })
117
127
  // Automatic summaries use the first quota. Reset Code windows cannot
118
128
  // make an exhausted membership pool available again.
119
- if (ratio >= 1) result.lines.unshift(monthly)
120
- else result.lines.push(monthly)
129
+ const existing = result.lines.findIndex(line => line.label === 'Monthly')
130
+ if (ratio >= 1) {
131
+ if (existing >= 0) result.lines.splice(existing,1)
132
+ result.lines.unshift(monthly)
133
+ monthlyBreakdown(ctx,result.lines,ratio,readNumber(pool.kimiCodeUsedRatio))
134
+ } else if (existing < 0) {
135
+ result.lines.push(monthly)
136
+ monthlyBreakdown(ctx,result.lines,ratio,readNumber(pool.kimiCodeUsedRatio))
137
+ }
121
138
  }
122
139
  const weekly = data.ratelimitCode7d
123
140
  const weeklyRatio = weekly && readNumber(weekly.ratio)
124
- if (weekly && weekly.enabled !== false && Number.isFinite(weeklyRatio)) {
141
+ if (weekly && weekly.enabled !== false && Number.isFinite(weeklyRatio) && weeklyRatio >= 0) {
125
142
  const reset = ctx.util.toIso(weekly.resetTime)
126
143
  const used = Math.max(0, Math.min(100, weeklyRatio * 100))
127
- if (!result.lines.some((line) => line.label === "Weekly" && Math.abs(line.used - used) < 0.01 && (line.resetsAt || null) === reset)) {
144
+ if (!result.lines.some((line) => line.label === "Weekly" && Math.abs(line.used - used) <= 1 && reset && line.resetsAt && Math.abs(Date.parse(line.resetsAt) - Date.parse(reset)) <= 300000)) {
128
145
  result.lines.push(ctx.line.progress({ label: "Code 7-day", used, limit: 100, format: { kind: "percent" }, resetsAt: reset, periodDurationMs: WEEK_MS }))
129
146
  }
130
147
  }
148
+ for (const gift of Array.isArray(data.giftBalances) ? data.giftBalances : []) {
149
+ if (!gift || gift.feature && gift.feature !== 'FEATURE_OMNI' || gift.type && gift.type !== 'GIFT') continue
150
+ const used = readNumber(gift.amountUsedRatio)
151
+ const expires = gift.expireTime == null ? null : ctx.util.parseDateMs(gift.expireTime)
152
+ if (used === null || used < 0 || gift.expireTime != null && !Number.isFinite(expires) || expires !== null && expires <= Date.parse(ctx.nowIso)) continue
153
+ result.lines.push(ctx.line.text({label:clean(gift.displayName) || 'Bonus credits',
154
+ value: String(Math.round(Math.max(0,1-used)*1000)/10) + '% remaining',
155
+ subtitle:expires !== null ? 'Expires ' + ctx.util.toIso(expires) : undefined}))
156
+ }
131
157
  } catch (_) { ctx.host.log.warn("Kimi membership enrichment unavailable") }
132
158
  return result
133
159
  }
@@ -265,7 +291,7 @@
265
291
  let data = ctx.util.tryParseJson(resp.bodyText)
266
292
  if (source === "web") {
267
293
  const coding = data && Array.isArray(data.usages) && data.usages.find((item) => item.scope === "FEATURE_CODING")
268
- data = coding ? { usage: coding.detail, limits: coding.limits } : null
294
+ data = coding ? { usage: coding.detail, limits: coding.limits } : data && Array.isArray(data.usages) ? {} : null
269
295
  }
270
296
  if (!data || typeof data !== "object") {
271
297
  throw "Usage response invalid. Try again later."
@@ -324,15 +350,29 @@
324
350
  }
325
351
  }
326
352
 
327
- if (lines.length === 0) {
328
- throw "Kimi usage response did not contain measurable quota counters."
353
+ // Current Code responses expose ratio pools independently of legacy counters.
354
+ for (const [key,label,period] of [['limit_5h','Session',5*3600000],['limit_7d','Weekly',WEEK_MS],['limit_month_total','Monthly',null]]) {
355
+ const pool = data.usages && !Array.isArray(data.usages) && data.usages[key]
356
+ const ratio = pool && readNumber(pool.used_ratio)
357
+ if (!Number.isFinite(ratio) || ratio < 0) continue
358
+ const reset = ctx.util.toIso(pool.reset_time)
359
+ const previous = lines.findIndex(line => line.label === label)
360
+ if (previous >= 0 && lines[previous].periodDurationMs === period && reset && lines[previous].resetsAt &&
361
+ Math.abs(Date.parse(reset)-Date.parse(lines[previous].resetsAt)) <= 2000 && lines[previous].used > ratio*100) continue
362
+ const line = ctx.line.progress({label,used:Math.min(100,ratio*100),limit:100,format:{kind:'percent'},resetsAt:reset,
363
+ periodDurationMs:period || ctx.util.calendarMonthDuration(reset)})
364
+ if (label === 'Monthly' && ratio >= 1) {
365
+ if (previous >= 0) lines.splice(previous,1)
366
+ lines.unshift(line)
367
+ } else if (previous >= 0) lines[previous] = line
368
+ else lines.push(line)
329
369
  }
330
-
331
- return enrichMembership(ctx, {
332
- source,
333
- plan: parsePlanLabel(data),
334
- lines,
335
- }, token)
370
+ if (lines.some(line => line.label === "Monthly")) {
371
+ monthlyBreakdown(ctx,lines,readNumber(data.usages?.limit_month_total?.used_ratio),readNumber(data.usages?.limit_month_code?.used_ratio))
372
+ }
373
+ const result = enrichMembership(ctx, {source,plan:parsePlanLabel(data),lines}, token)
374
+ if (result.lines.length === 0) throw "Kimi usage response did not contain measurable quota counters."
375
+ return result
336
376
  }
337
377
 
338
378
  globalThis.__openusage_plugin = { id: "kimi", probe }
@@ -6,13 +6,53 @@
6
6
  "entry": "plugin.js",
7
7
  "icon": "icon.svg",
8
8
  "brandColor": "#000000",
9
- "supportedModes": ["api", "oauth", "cli", "web"],
9
+ "supportedModes": [
10
+ "api",
11
+ "oauth",
12
+ "cli",
13
+ "web"
14
+ ],
10
15
  "autoMode": "oauth",
11
- "envVars": ["KIMI_CODE_API_KEY", "KIMI_CODE_HOME", "KIMI_CODE_BASE_URL", "KIMI_CODE_OAUTH_HOST", "KIMI_OAUTH_HOST", "KIMI_AUTH_TOKEN"],
16
+ "envVars": [
17
+ "KIMI_CODE_API_KEY",
18
+ "KIMI_CODE_HOME",
19
+ "KIMI_CODE_BASE_URL",
20
+ "KIMI_CODE_OAUTH_HOST",
21
+ "KIMI_OAUTH_HOST",
22
+ "KIMI_AUTH_TOKEN"
23
+ ],
12
24
  "lines": [
13
- { "type": "progress", "label": "Session", "scope": "overview", "primaryOrder": 1 },
14
- { "type": "progress", "label": "Weekly", "scope": "overview", "primaryOrder": 2 },
15
- { "type": "progress", "label": "Monthly", "scope": "overview" },
16
- { "type": "progress", "label": "Code 7-day", "scope": "detail" }
25
+ {
26
+ "type": "progress",
27
+ "label": "Session",
28
+ "scope": "overview",
29
+ "primaryOrder": 1
30
+ },
31
+ {
32
+ "type": "progress",
33
+ "label": "Weekly",
34
+ "scope": "overview",
35
+ "primaryOrder": 2
36
+ },
37
+ {
38
+ "type": "progress",
39
+ "label": "Monthly",
40
+ "scope": "overview"
41
+ },
42
+ {
43
+ "type": "progress",
44
+ "label": "Code 7-day",
45
+ "scope": "detail"
46
+ },
47
+ {
48
+ "type": "text",
49
+ "label": "Monthly Kimi Code",
50
+ "scope": "detail"
51
+ },
52
+ {
53
+ "type": "text",
54
+ "label": "Monthly other features",
55
+ "scope": "detail"
56
+ }
17
57
  ]
18
58
  }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Peter Steinberger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="112.9 211.2 30 30" width="512" height="512">
2
+ <!-- Langdock mark from https://langdock.com/brand-kit (brand-dark.svg). -->
3
+ <path d="M135.301 230.862C135.595 230.358 135.593 229.735 135.296 229.234L130.455 221.061L126.41 214.282C125.786 213.235 124.268 213.24 123.649 214.29L120.175 220.187C119.879 220.69 119.879 221.314 120.175 221.816L124.545 229.234C124.84 229.735 124.841 230.358 124.547 230.86L121.105 236.734C120.479 237.803 121.25 239.15 122.49 239.15H129.534C130.105 239.15 130.632 238.847 130.92 238.355L135.301 230.862Z" fill="currentColor"/>
4
+ </svg>
@@ -0,0 +1,106 @@
1
+ // Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
2
+ globalThis.__usagestat_bundled_options = {"labels":["Session","Weekly","Additional"],"defaults":{},"autoMode":"web"};
3
+ (function(defineProvider) {
4
+ // BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/langdock.js
5
+ defineProvider({
6
+ id: "langdock",
7
+ name: "Langdock",
8
+ endpoints: ["https://app.langdock.com"],
9
+ settings: [],
10
+ capabilities: ["browser-cookies", "http-status"],
11
+ cookieDomains: ["langdock.com", "app.langdock.com"],
12
+ cookiePolicy: {
13
+ selection: "request-url",
14
+ cache: "nonpersistent",
15
+ imports: "access-gated",
16
+ store: "selected-profile",
17
+ requiredCookies: ["auth_token"],
18
+ sessionURL: "https://app.langdock.com/api/trpc/usageSettings.getPersonalUsage",
19
+ },
20
+ snapshotPolicy: { percent: "preserve-overage" },
21
+ async fetchUsage(ctx) {
22
+ const fail = () => {
23
+ throw ctx.fail.parseFailure("Langdock returned an unexpected personal usage response.");
24
+ };
25
+ const object = (value) => (value !== null && typeof value === "object" && !Array.isArray(value) ? value : fail());
26
+ const percent = (value) => (typeof value === "number" && Number.isFinite(value) ? value : fail());
27
+ const reset = (value) => {
28
+ if (value === undefined || value === null) return undefined;
29
+ if (typeof value !== "string") return fail();
30
+ try {
31
+ return ctx.date.iso(value);
32
+ } catch (error) {
33
+ void error;
34
+ return fail();
35
+ }
36
+ };
37
+ const denied = (code) => {
38
+ if (code === "UNAUTHORIZED") {
39
+ throw ctx.fail.authenticationExpired("The selected browser profile is no longer signed in to Langdock.");
40
+ }
41
+ if (code === "FORBIDDEN") throw ctx.fail.permissionDenied("Langdock denied access to personal usage.");
42
+ if (code === "TOO_MANY_REQUESTS") throw ctx.fail.rateLimited("Langdock usage requests are rate limited.");
43
+ if (code === "INTERNAL_SERVER_ERROR" || code === "TIMEOUT") {
44
+ throw ctx.fail.providerUnavailable("Langdock personal usage is temporarily unavailable.");
45
+ }
46
+ throw ctx.fail.apiFailure("Langdock rejected the personal usage request.");
47
+ };
48
+ for await (const session of ctx.browser.sessions("app.langdock.com")) {
49
+ const input = encodeURIComponent(JSON.stringify({ 0: { json: null, meta: { values: ["undefined"], v: 1 } } }));
50
+ const response = await ctx.http.get(
51
+ `https://app.langdock.com/api/trpc/usageSettings.getPersonalUsage?batch=1&input=${input}`,
52
+ {
53
+ cookieSession: session.id,
54
+ headers: { Accept: "application/json", Referer: "https://app.langdock.com/settings/account/usage" },
55
+ },
56
+ );
57
+ if (response.status === 401) return denied("UNAUTHORIZED");
58
+ if (response.status === 403) return denied("FORBIDDEN");
59
+ if (response.status === 429) return denied("TOO_MANY_REQUESTS");
60
+ if (response.status >= 500) return denied("INTERNAL_SERVER_ERROR");
61
+ if (response.status < 200 || response.status >= 300) {
62
+ throw ctx.fail.apiFailure(`Langdock usage request failed with HTTP ${response.status}.`);
63
+ }
64
+ let raw;
65
+ try {
66
+ raw = JSON.parse(response.bodyText);
67
+ } catch (error) {
68
+ void error;
69
+ return fail();
70
+ }
71
+ if (!Array.isArray(raw) || raw.length !== 1) return fail();
72
+ const envelope = object(raw[0]);
73
+ if (envelope.error !== undefined) {
74
+ const code = object(object(object(envelope.error).json).data).code;
75
+ return typeof code === "string" && code.length ? denied(code) : fail();
76
+ }
77
+ const payload = object(object(object(envelope.result).data).json);
78
+ if (payload.hasIncludedUsageLimits !== undefined && typeof payload.hasIncludedUsageLimits !== "boolean") {
79
+ return fail();
80
+ }
81
+ if (payload.hasIncludedUsageLimits === false || payload.planUsage == null) {
82
+ return {
83
+ details: [
84
+ { title: "Usage", rows: [{ label: "Included limits", value: "No included usage limits available" }] },
85
+ ],
86
+ dataConfidence: "percentOnly",
87
+ };
88
+ }
89
+ const plan = object(payload.planUsage);
90
+ if (typeof plan.sessionUsageLimitsEnabled !== "boolean") return fail();
91
+ const sessionReset = reset(plan.sessionResetsAt);
92
+ const weeklyReset = reset(plan.weeklyResetsAt);
93
+ return {
94
+ primary: plan.sessionUsageLimitsEnabled
95
+ ? { usedPercent: percent(plan.sessionUsagePercent), windowMinutes: 300, resetsAt: sessionReset }
96
+ : undefined,
97
+ secondary: { usedPercent: percent(plan.weeklyUsagePercent), windowMinutes: 10080, resetsAt: weeklyReset },
98
+ dataConfidence: "percentOnly",
99
+ };
100
+ }
101
+ throw ctx.fail.missingCredential("No Langdock session was found in the selected browser profile.");
102
+ },
103
+ });
104
+
105
+ // END UPSTREAM
106
+ })(globalThis.defineProvider);
@@ -0,0 +1,25 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "langdock",
4
+ "name": "Langdock",
5
+ "version": "0.1.0",
6
+ "entry": "plugin.js",
7
+ "enabledByDefault": false,
8
+ "supportedModes": [
9
+ "web"
10
+ ],
11
+ "autoMode": "web",
12
+ "usageDashboardUrl": "https://app.langdock.com/settings/account/usage",
13
+ "webUrl": "https://langdock.com",
14
+ "envVars": [
15
+ "LANGDOCK_COOKIE"
16
+ ],
17
+ "setupFields": [],
18
+ "upstream": {
19
+ "repository": "https://github.com/steipete/CodexBar",
20
+ "revision": "1f6da9bec44455288ddee5ef6f3617a803d8eb2a",
21
+ "path": "Sources/CodexBarCore/Resources/Plugins/langdock.js",
22
+ "sha256": "c950eb7566aea322bba26fc97735a7ba688b6cfb7fa6a5e06a2e0cb6fff6f831",
23
+ "license": "MIT"
24
+ }
25
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Peter Steinberger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ <svg width="285" height="198" viewBox="0 0 285 198" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_650_11)">
3
+ <path d="M96.1153 0C115.145 9.96246e-05 131.026 8.72414 143.978 22.1662C149.579 27.9789 154.673 34.7119 159.303 42.0916C177.404 34.9414 195.406 32.5434 211.123 39.016C225.943 45.1194 234.458 56.0167 238.15 69.3667C241.755 82.4004 240.712 97.5027 237.317 112.551C236.123 117.841 234.62 123.193 232.884 128.536C239.707 128.029 246.056 127.795 251.797 127.879C260.507 128.006 268.207 128.866 274.116 130.847C285.12 134.535 288.65 148.138 280.65 156.687C275.381 162.319 266.383 168.603 253.035 175.39C239.593 182.225 221.386 189.745 197.367 197.701C195.644 198.272 193.756 198.015 192.246 197.006C190.737 195.996 189.774 194.345 189.635 192.53C188.645 179.559 186.69 163.856 183.595 147.175C172.198 149.244 160.331 151.672 148.311 154.368C94.6619 166.396 38.6478 183.583 8.34971 197.465C6.49768 198.314 4.34053 198.144 2.64306 197.016C0.945589 195.888 -0.0526946 193.96 0.0021483 191.918C0.84773 160.512 6.41469 113.301 20.5188 73.735C27.5677 53.9608 36.888 35.6927 49.1507 22.2785C61.5163 8.75168 77.0563 0 96.1153 0ZM251.626 139.722C244.9 139.624 237.119 139.996 228.507 140.784C222.883 155.254 215.916 169.209 209.107 181.111C225.195 175.287 237.886 169.815 247.704 164.823C260.564 158.284 268.153 152.74 272.049 148.577C274.097 146.388 273.296 143.061 270.379 142.083C266.169 140.672 259.884 139.843 251.626 139.722ZM154.363 57.2032C134.146 67.0213 112.683 83.0036 92.5185 101.014C72.3972 118.986 53.7959 138.772 39.3029 155.979C31.9268 164.737 25.7098 172.713 20.9227 179.37C53.5158 166.719 100.651 152.916 145.739 142.807C157.803 140.102 169.756 137.653 181.28 135.558C177.168 116.252 171.54 96.2054 164.138 77.9653C161.166 70.6416 157.928 63.6647 154.419 57.1756C154.401 57.1846 154.382 57.1941 154.363 57.2032ZM215.189 142.245C208.813 143.05 202.133 144.03 195.225 145.164C197.088 155.218 198.539 164.912 199.629 173.886C205.045 164.31 210.498 153.477 215.189 142.245ZM96.1153 11.8456C81.0934 11.8456 68.524 18.6064 57.8453 30.2879C47.0636 42.0821 38.4043 58.7186 31.6286 77.7264C21.0555 107.387 15.4078 141.843 13.0465 170.111C17.8505 163.568 23.6922 156.167 30.2916 148.331C45.0869 130.766 64.0751 110.564 84.6755 92.164C104.969 74.0389 127.049 57.4622 148.392 46.9482C144.399 40.7546 140.104 35.1838 135.496 30.4012C124.159 18.635 111.166 11.8457 96.1153 11.8456ZM206.644 49.9744C195.25 45.282 181.19 46.4708 165.297 52.4684C168.864 59.1583 172.114 66.222 175.066 73.4961C182.82 92.6035 188.671 113.5 192.918 133.539C202.399 131.977 211.495 130.692 220.013 129.743C222.352 123.112 224.336 116.453 225.807 109.934C228.997 95.8018 229.646 82.8969 226.78 72.5356C224.002 62.4906 217.886 54.6042 206.644 49.9744Z" fill="black"/>
4
+ </g>
5
+ <defs>
6
+ <clipPath id="clip0_650_11">
7
+ <rect width="285" height="198" fill="currentColor"/>
8
+ </clipPath>
9
+ </defs>
10
+ </svg>
@@ -0,0 +1,46 @@
1
+ // Generated by tools/vendor-codexbar-providers.cjs; see LICENSE.
2
+ globalThis.__usagestat_bundled_options = {"labels":["Balance","Additional","Additional"],"defaults":{},"autoMode":"api"};
3
+ (function(defineProvider) {
4
+ // BEGIN UPSTREAM Sources/CodexBarCore/Resources/Plugins/linkup.js
5
+ defineProvider({
6
+ id: "linkup",
7
+ name: "Linkup",
8
+ endpoints: ["https://api.linkup.so"],
9
+ auth: { type: "bearer", secret: "LINKUP_API_KEY" },
10
+ settings: [{ key: "LINKUP_API_KEY", title: "Linkup API key", type: "secure" }],
11
+ capabilities: ["http-status"],
12
+ async fetchUsage(ctx) {
13
+ const response = await ctx.http.get("https://api.linkup.so/v1/credits/balance");
14
+ const message = `Linkup returned HTTP ${response.status}.`;
15
+ if (response.status === 401) throw ctx.fail.authenticationExpired(message);
16
+ if (response.status === 403) throw ctx.fail.permissionDenied(message);
17
+ if (response.status === 429) {
18
+ const delay = Number(response.headers["retry-after"] ?? 1);
19
+ throw ctx.fail.rateLimited(message, {
20
+ retryAfterSeconds: Number.isFinite(delay) && delay >= 0 ? Math.min(delay, 10) : 1,
21
+ });
22
+ }
23
+ if (response.status >= 500) throw ctx.fail.providerUnavailable(message);
24
+ if (response.status !== 200) throw ctx.fail.apiFailure(message);
25
+ function fail() {
26
+ throw ctx.fail.parseFailure("Linkup returned an unrecognized credit balance.");
27
+ }
28
+ let data;
29
+ try {
30
+ data = JSON.parse(response.bodyText);
31
+ } catch {
32
+ return fail();
33
+ }
34
+ if (!data || Array.isArray(data) || typeof data.balance !== "number" || !Number.isFinite(data.balance)) {
35
+ return fail();
36
+ }
37
+ return {
38
+ details: [{ title: "Account balance", rows: [{ label: "Credit balance", value: ctx.format.usd(data.balance) }] }],
39
+ identity: { loginMethod: "API" },
40
+ dataConfidence: "exact",
41
+ };
42
+ },
43
+ });
44
+
45
+ // END UPSTREAM
46
+ })(globalThis.defineProvider);
@@ -0,0 +1,24 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "linkup",
4
+ "name": "Linkup",
5
+ "version": "0.1.0",
6
+ "entry": "plugin.js",
7
+ "enabledByDefault": false,
8
+ "supportedModes": [
9
+ "api"
10
+ ],
11
+ "autoMode": "api",
12
+ "usageDashboardUrl": "https://app.linkup.so",
13
+ "envVars": [
14
+ "LINKUP_API_KEY"
15
+ ],
16
+ "setupFields": [],
17
+ "upstream": {
18
+ "repository": "https://github.com/steipete/CodexBar",
19
+ "revision": "1f6da9bec44455288ddee5ef6f3617a803d8eb2a",
20
+ "path": "Sources/CodexBarCore/Resources/Plugins/linkup.js",
21
+ "sha256": "7857c63217818a2a9935397a8fe70621b42ab17115a43da2eab6b4a0ea27b775",
22
+ "license": "MIT"
23
+ }
24
+ }
@@ -9,6 +9,8 @@
9
9
  }
10
10
 
11
11
  function apiKey(ctx) {
12
+ if (Object.prototype.hasOwnProperty.call(ctx.provider || {}, 'apiKey')) return ctx.provider.apiKey;
13
+ if (ctx.provider && ctx.provider.instanceId && ctx.provider.instanceId !== 'litellm') return null;
12
14
  var configured = ctx.provider && typeof ctx.provider.apiKey === "string" ? ctx.provider.apiKey.trim() : "";
13
15
  return configured || env(ctx, "LITELLM_API_KEY");
14
16
  }
@@ -51,13 +53,14 @@
51
53
  return Number.isFinite(ms) ? new Date(ms) : null;
52
54
  }
53
55
 
54
- function requestJson(ctx, base, path, key) {
56
+ function requestJson(ctx, base, path, key, optional) {
55
57
  var resp = ctx.util.request({
56
58
  method: "GET",
57
59
  url: base + path,
58
60
  headers: { Authorization: "Bearer " + key, Accept: "application/json" },
59
61
  timeoutMs: 15000,
60
62
  });
63
+ if (optional && [401,403,404].includes(resp.status)) return null;
61
64
  if (ctx.util.isAuthStatus(resp.status)) throw "LiteLLM API key was rejected.";
62
65
  if (resp.status < 200 || resp.status >= 300) {
63
66
  throw "LiteLLM API request failed (HTTP " + resp.status + ").";
@@ -189,10 +192,58 @@
189
192
  var key = apiKey(ctx);
190
193
  if (!key) throw "Missing LiteLLM API key. Set LITELLM_API_KEY or provider apiKey.";
191
194
  var base = baseUrl(ctx);
192
- var info = keyInfo(requestJson(ctx, base, "/key/info", key));
195
+ var keyData = requestJson(ctx, base, "/key/info", key, true);
196
+ if (keyData === null) {
197
+ var end = ctx.nowIso.slice(0,10), start = end.slice(0,7)+'-01';
198
+ var query = '?start_date='+start+'&end_date='+end;
199
+ var rows = requestJson(ctx, base, '/key/spend/report'+query, key, true);
200
+ if (rows === null) rows = requestJson(ctx, base, '/user/spend/report'+query, key);
201
+ if (!Array.isArray(rows) || !rows.length) throw new Error('LiteLLM spend report is empty or invalid.');
202
+ var cost = 0;
203
+ for (var row of rows) {
204
+ if (typeof row.total_cost !== 'number' || !Number.isFinite(row.total_cost) || row.total_cost < 0) throw new Error('Invalid LiteLLM spend.');
205
+ cost += row.total_cost;
206
+ }
207
+ if (!Number.isFinite(cost)) throw new Error('Invalid LiteLLM spend total.');
208
+ return {source:'api',lines:[ctx.line.text({label:'Month to date',value:usd(cost),subtitle:start+' to '+end+' UTC'})]};
209
+ }
210
+ var info = keyInfo(keyData);
193
211
  var snapshot = info.userID ? userSnapshot(ctx, base, key, info) : teamSnapshot(ctx, base, key, info);
194
212
  var plan = snapshot.team && snapshot.team.alias ? snapshot.team.alias : null;
195
- return { displayName: "LiteLLM", source: "api", plan: plan, lines: linesFor(snapshot) };
213
+ var lines = linesFor(snapshot);
214
+ if (info.userID && (ctx.provider?.settings?.modelUsage === true || ctx.provider?.settings?.LITELLM_MODEL_USAGE_ENABLED === 'true')) {
215
+ try { lines.push.apply(lines, modelActivity(ctx,base,key,info.userID)); } catch (_) { ctx.host.log.warn('LiteLLM optional model activity unavailable.'); }
216
+ }
217
+ return { displayName: "LiteLLM", source: "api", plan: plan, lines: lines };
218
+ }
219
+
220
+ function modelActivity(ctx,base,key,user) {
221
+ var end=ctx.nowIso.slice(0,10),start=new Date(Date.parse(end)-29*86400000).toISOString().slice(0,10),totals={};
222
+ for(var page=1;page<=3;page++) {
223
+ var response=ctx.host.http.request({method:'GET',url:base+'/user/daily/activity?user_id='+encodeURIComponent(user)+'&start_date='+start+'&end_date='+end+'&page='+page+'&page_size=1000',
224
+ headers:{Authorization:'Bearer '+key,Accept:'application/json'},timeoutMs:2000});
225
+ if(response.status!==200) throw new Error('Unavailable');
226
+ var data=ctx.util.tryParseJson(response.bodyText);
227
+ if(!Array.isArray(data?.results)||data.results.length>31) throw new Error('Invalid activity');
228
+ for(var row of data.results) {
229
+ if(!/^\d{4}-\d{2}-\d{2}$/.test(row.date)||row.date<start||row.date>end||!row.breakdown?.models) throw new Error('Invalid day');
230
+ for(var [name, value] of Object.entries(row.breakdown.models)) {
231
+ if(!name.trim()||name.length>256||/[\x00-\x1f]/.test(name)||['__proto__','constructor','prototype'].includes(name)) throw new Error('Invalid model');
232
+ var metrics=value.metrics||value,prior=totals[name]||[0,0,0,0];
233
+ totals[name]=['prompt_tokens','completion_tokens','total_tokens','api_requests'].map(function(field,i){
234
+ var n=metrics[field]; if(!Number.isSafeInteger(n)||n<0||!Number.isSafeInteger(n+prior[i])) throw new Error('Invalid count'); return n+prior[i];
235
+ });
236
+ if(Object.keys(totals).length>1000) throw new Error('Too many models');
237
+ }
238
+ }
239
+ var metadata=data.metadata||{};
240
+ if(metadata.page!=null&&metadata.page!==page) throw new Error('Repeated page');
241
+ if(metadata.has_more!=null&&typeof metadata.has_more!=='boolean') throw new Error('Invalid page');
242
+ if(metadata.total_pages!=null&&(!Number.isSafeInteger(metadata.total_pages)||metadata.total_pages<1)) throw new Error('Invalid page');
243
+ if(metadata.has_more!==true&&page>=(metadata.total_pages||1)) return Object.entries(totals).sort((a,b)=>b[1][2]-a[1][2]).slice(0,20)
244
+ .map(([name,n])=>ctx.line.text({label:name,value:n[2]+' tokens / '+n[3]+' requests',subtitle:'30d UTC: '+n[0]+' input / '+n[1]+' output'}));
245
+ }
246
+ throw new Error('Incomplete activity');
196
247
  }
197
248
 
198
249
  globalThis.__openusage_plugin = { id: "litellm", probe: probe };
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Peter Steinberger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M5 3h5v13h9v5H5z"/></svg>